akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc121_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, M;
  cin >> N >> M;

  vector<pl> c(N);
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    c[i] = make_pair(a, b);
  }
  sort(c.begin(), c.end());

  ll cnt = 0;
  ll ans = 0;
  rep(i, N) {
    ll a = c[i].first;
    ll b = c[i].second;
    if (cnt + b < M) {
      ans += a * b;
      cnt += b;
    } else {
      ans += (M - cnt) * a;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4688
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using System.Collections;

class P
{
    static void Main()
    {
        var a = int.Parse(Console.ReadLine());
        int res = 0;
        while(a>=25){
            res++;
            a-=25;
        }
        while(a>=10){
            res++;
            a-=10;
        }
        while(a>=5){
            res++;
            a-=5;
        }
        while(a>=1){
            res++;
            a-=1;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 17944
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,a[K],all;
set<int> s;
map<long long,long long> m;
map<long long,long long> ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],m[a[i]]++,s.insert(a[i]);
	for(set<int>::iterator it=s.begin();it!=s.end();it++)
	{
		int i=*it;
		all+=(m[i]*(m[i]-1)/2);
	}
	for(int i=1;i<=n;i++)
	{
		long long k=a[i];
		if(m[k]<2)
		{
			cout<<all<<'\n';
			continue;
		}
		if(ans[m[k]]!=0)
		{
			cout<<ans[m[k]]<<'\n';
			continue;
		}
		long long num=all-m[k]+1;
		ans[m[k]]=num;
		cout<<num<<'\n';
	}
	return 0;
}	

Measured memory_bytes: 17024
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long LL;
const int MAXN = 20;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
int a[MAXN],x[MAXN][MAXN],y[MAXN][MAXN];
inline int cont(int x){
    if(x==0) return 0;
    return cont(x>>1)+(x&1);
}
signed main(){
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        for(int j=1;j<=a[i];j++) cin>>x[i][j]>>y[i][j];
    }
    int res=0;
    for(int i=1;i<(1<<n);i++){
        bool ok = true;
        for(int j=1;j<=n;j++){
            if(!((i>>(j-1))&1)) continue;
            for(int k=1;k<=a[j];k++)
                if(((i>>(x[j][k]-1))&1)!=y[j][k])
                    ok=false;
        }
        if(ok) res=max(res,cont(i));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
build = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
sep = '#'*20
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    build[b-1][f-1][r-1] += v
cnt = 0
for F in build:
    for f in F:
        print(' ', end='')
        f = map(str, f)
        print(' '.join(f))
        cnt += 1
    if cnt <= 10:
        print(sep)


Measured memory_bytes: 5604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int x,k,r[100010];
	scanf("%d%d",&x,&k);
	rep1(i,k)scanf("%d",&r[i]);
	r[0] = 0; r[k+1] = 1000000000;
	
	static int b[100010],c[100010],d[100010],e[100010];
	b[0] = 0; c[0] = x;
	d[0] = 0; e[0] = x;
	rep1(i,k+1){
		if(i%2){
			b[i] = b[i-1];
			c[i] = c[i-1];
			d[i] = d[i-1]-r[i]+r[i-1];
			e[i] = e[i-1]-r[i]+r[i-1];
			if(d[i] < 0){
				b[i] += -d[i];
				d[i] = 0;
			}
			if(e[i] < 0){
				c[i] = b[i];
				e[i] = d[i];
			}
		}
		else{
			b[i] = b[i-1];
			c[i] = c[i-1];
			d[i] = d[i-1]+r[i]-r[i-1];
			e[i] = e[i-1]+r[i]-r[i-1];
			if(e[i] > x){
				c[i] -= e[i]-x;
				e[i] = x;
			}
			if(d[i] > x){
				b[i] = c[i];
				d[i] = e[i];
			}
		}
	}
	
	static int q,t[100010],a[100010];
	scanf("%d",&q);
	rep(i,q){
		scanf("%d%d",&t[i],&a[i]);
		int L = 0, R = k+1;
		while(L < R){
			int m = (L+R+1)/2;
			if(r[m] <= t[i]){
				L = m;
			}
			else R = m-1;
		}
		int ret;
		if(L%2){
			if(a[i] <= b[L])ret = d[L];
			else if(a[i] >= c[L])ret = e[L];
			else ret = d[L]+a[i]-b[L];
			ret += t[i]-r[L];
			ret = min( ret , x );
		}
		else {
			if(a[i] <= b[L])ret = d[L];
			else if(a[i] >= c[L])ret = e[L];
			else ret = d[L]+a[i]-b[L];
			ret -= t[i]-r[L];
			ret = max( ret , 0 );
		}
		printf("%d\n",ret);
	}
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;

inline int two(int n) { return 1 << n; }
inline int test(int n, int pos) { return (bool) (n & two(pos)); }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }

const int DMAX = 1e3+10;

struct nume{
    int node,val;
};

vector <int> arb[DMAX];

queue <pii> Coada;

bool uz[DMAX][DMAX];
int M[DMAX][DMAX];

int dl[]={1,-1,0,0};
int dc[]={0,0,1,-1};

int n,ans,m;

void lee();

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

    int t,i,j,val;
    char c;

    cin>>n>>m;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++){
            cin>>c;
            if(c == '#'){
                Coada.push({i,j});
                uz[i][j]=true;
            }
        }
    lee();
    cout<<ans<<'\n';
    return 0;
}
void lee(){
    int i,k,x,y;
    pii node;
    while(!Coada.empty()){
            node=Coada.front();
            Coada.pop();
            for(k=0;k<4;k++){
                x=node.first+dl[k];
                y=node.second+dc[k];
                if(x>=1 && x<=n && y>=1 && y<=m && !uz[x][y]){
                   Coada.push({x,y});
                   M[x][y]=M[node.first][node.second]+1;
                   uz[x][y]=true;
                   ans=max(ans,M[x][y]);
                }
            }
      }
}


Measured memory_bytes: 11408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
map<ll,ll> mp;
int main(){
    int num;
    cin>>num;
    int sqt_num=(int)sqrt((double)num);
    vector<bool> prime(num,true);
    prime.at(0)=false;
    for(int i=0;i<sqt_num;i++){
        if(prime.at(i)){
            for(int j=2;(i+1)*j<=num;j++){
                prime.at((i+1)*j-1)=false;
            }
        }
    }
    for(int i=num;i>=1;i--){
   int  n=i;
    for(int j=0;j<=i-1;j++){
        if(n==1)break;
        if(prime.at(j)){
            while(n%(j+1)==0){
                n/=(j+1);
                mp[(j+1)]++;
            }
        }
    }
    }
    ll ans=1;
    for(auto p:mp){
        ll res=p.second;
        ans*=(res+1);
        if(ans>mod)ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys 

string1 = str(input())
string2 = str(input())

n, m = len(string2), len(string1) 

ans = sys.maxsize 
for i in range(m - n + 1): 
    minRemovedChar = 0 
    for j in range(n): 
        if (string2[j] != string1[i + j]): 
            minRemovedChar += 1
    ans = min(minRemovedChar, ans) 

print(ans)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h1,m1,h2,m2,k;
    IN(h1,m1,h2,m2,k);
    int h = h2-h1, m=m2-m1;
    cout << 60*h+m-k << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    char str[1001];
    while(1) {
        scanf("%s", str);
        if(str[0]=='0') break;
        int sum = 0;
        for (int i = 0; i < strlen(str); ++i)
        {
            sum += (str[i]-'0');
        }

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

Measured memory_bytes: 1132
#include <iostream>
#include <sstream>
using namespace std;
int main(){
        string x,y;
        cin >> x>>y;
        istringstream iss(x+y);
        int xy;
        iss >> xy;
        for(int i=1 ; i<1000 ; i++ ){
                if(i*i==xy){
                        cout <<"Yes"<<endl;
                        return 0;
                }
                else if(i*i>xy)
                        break;
        }
        cout <<"No"<<endl;
        return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass {
  public static void Main (string[] args) {
    //入力
    var input = Console.ReadLine().Split(' ');
    var W = int.Parse(input[0]);
    var a = int.Parse(input[1]);
    var b = int.Parse(input[2]);

    //処理
    var ans = Math.Max(a, b) - (Math.Min(a, b) + W);
    if(ans < 0) ans = 0;
    //出力
    Console.WriteLine(ans);
  }
 
}   


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  char C1,C2,C3,C4,C5,C6;
  cin >> C1 >> C2 >> C3 >> C4 >> C5 >> C6;
  if(C3==C4&&C2==C5&&C1==C6)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int MOD = 998244353;
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

const int N = 500010;
int jc[N], ijc[N], n, m;
void prework(int sz) {
  jc[0] = 1;
  rep (i, 1, sz) jc[i] = 1ll * jc[i-1] * i % MOD;
  ijc[sz] = power(jc[sz], MOD - 2);
  rrp (i, sz-1, 0) ijc[i] = 1ll * ijc[i+1] * (i+1) % MOD;
}
int comb(int a,int b) {
  if (a < b || b < 0) return 0;
  return 1ll * jc[a] * ijc[b] % MOD * ijc[a-b] % MOD;
}
int main() {
  read(n), read(m);
  prework(max(n, m));
  int ans = 0;
  rep (k, 0, min(n, m)) {
    int tmp = 1ll * comb(n, k) * comb(m, k) % MOD * jc[k] % MOD;
    tmp = 1ll * tmp * power(n+1, m - k) % MOD;
    tmp = 1ll * tmp * power(m+1, n - k) % MOD;
    if (k&1) Sub(ans, tmp);
    else Add(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()

A = [0]  # A[i] = f(i) (0<=i<=N-1)
for i in range(1,N):
    a = 0  # iの2進表記に現れる1の個数
    for j in range(18):
        a += (i >> j) & 1
    A.append(1 + A[i % a])

X = LS2()

b = 0  # Xの2進表記に現れる1の個数
for i in range(N):
    if X[i] == '1':
        b += 1
if b >= 2:
    c1,c2 = b-1,b+1

    amari1 = [1]
    amari2 = [1]
    for i in range(1,N):
        amari1.append((amari1[-1]*2) % c1)
        amari2.append((amari2[-1]*2) % c2)
    amari1.reverse()
    amari2.reverse()

    # amari1[i] = 2**(N-i-1) mod c1
    # amari2[i] = 2**(N-i-1) mod c2

    r1,r2 = 0,0  # ri = X mod ci
    for i in range(N):
        if X[i] == '1':
            r1 += amari1[i]
            r1 %= c1
            r2 += amari2[i]
            r2 %= c2
    ANS = []
    for i in range(N):
        if X[i] == '1':
            ANS.append(A[(r1-amari1[i]) % c1]+1)
        else:
            ANS.append(A[(r2+amari2[i]) % c2]+1)
else:
    c2 = b+1

    amari2 = [1]
    for i in range(1, N):
        amari2.append((amari2[-1]*2) % c2)
    amari2.reverse()

    # amari2[i] = 2**(N-i-1) mod c2

    r2 = 0  # X mod c2
    for i in range(N):
        if X[i] == '1':
            r2 += amari2[i]
            r2 %= c2
    ANS = []
    for i in range(N):
        if X[i] == '1':
            ANS.append(0)
        else:
            ANS.append(A[(r2+amari2[i]) % c2] + 1)

print(*ANS,sep='\n')

Measured memory_bytes: 133692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum,min;
  sum=0;
  cin >> N;
  vector<int> s(110);
  for(int i=0;i<N;i++){cin >> s[i];}
  for(int i=0;i<N;i++){sum+=s[i];}
  min=sum;
  for(int i=0;i<N;i++){
    if(min>s[i] && s[i]%10!=0){min=s[i];}
  }
  if(sum%10!=0){cout << sum << endl;}
  else{cout << sum-min << endl;}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int i;
    int idx=1;
    int ans=0;
    int n;
    int a;

    scanf("%d", &n);
    for ( i=0; i<n; i++ ) {
        scanf("%d", &a);
        if ( a != idx )
            ans++;
        else
            idx++;
    }

    if ( ans == n )
        printf("-1\n");
    else
        printf("%d\n", ans);

    return EXIT_SUCCESS;
}


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

const int MAX_SIZE = 300;

int cost(int x, int y) {
  int sum = 0, c = 0;
  while (x || y) {
    sum += (x % 10) * (y % 10) + c;
    c = x % 10 + y % 10 + c < 10 ? 0 : 1;
    x /= 10;
    y /= 10;
  }
  return sum + c;
}

int calc(int a[], int b[][MAX_SIZE], int s[][MAX_SIZE], int N) {
  for (int i = 0; i < N; ++i) {
    s[i][i] = a[i];
  }
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < N - i; ++j) {
      s[j][j + i] = s[j][j + i - 1] + a[j + i];
      b[j][j + i] = numeric_limits<int>::max();
      for (int k = 0; k < i; ++k) {
        b[j][j + i] = min(b[j][j + i],
                          b[j][j + k] + b[j + k + 1][j + i] + cost(s[j][j + k], s[j + k + 1][j + i]));
      }
    }
  }
  return b[0][N - 1];
}

int main() {
  int N;
  int a[MAX_SIZE];
  int s[MAX_SIZE][MAX_SIZE] = {};
  int b[MAX_SIZE][MAX_SIZE] = {};
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  cout << calc(a, b, s, N) << endl;
}

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

using namespace std;

#define int long long

signed main() {
  int N, D;
  cin >> N >> D;
  vector<int> t(N), F(N);
  for(int i = 0; i < N; i++) {
    cin >> t[i] >> F[i];
  }
  if(t[0] < F[0]-1) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0, cap = 1;
  for(int i = 1; i < N; i++) {
    if(t[i-1]+(F[i-1]-1)+(F[i]-1) <= t[i]) {
      ans += (F[i-1]-1)*cap;
      cap = 1;
    } else if(t[i-1]+llabs(F[i-1]-F[i]) <= t[i]) {
      ans += (t[i]-t[i-1])*cap;
      cap++;
      if(cap > D) {
	cout << -1 << endl;
	return 0;
      }
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans+(F[N-1]-1)*cap << endl;


  return 0;
}

Measured memory_bytes: 4400
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int b[2010][2010];

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

    if(s == "AKIHABARA" ||
    s == "AKIHABAR" ||
    s == "AKIHABRA" ||
    s == "AKIHABR" ||

    s == "AKIHBARA" ||
    s == "AKIHBAR" ||
    s == "AKIHBRA" ||
    s == "AKIHBR" ||

    s == "KIHABARA" ||
    s == "KIHABAR" ||
    s == "KIHABRA" ||
    s == "KIHABR" ||

    s == "KIHBARA" ||
    s == "KIHBAR" ||
    s == "KIHBRA" ||
    s == "KIHBR")cout << "YES" << endl;
    else cout << "NO" << endl;
    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
bool bo[105];
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	for(int i=a;i<b;i++)	bo[i]++;
	int sum=0;
	for(int i=c;i<d;i++)	if(bo[i]==1)	sum++;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> A(N);
	int count = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j*A[i] + 1 <= D; j++) {
			count++;
		}
	}
	cout << count + X << endl;
	return 0;
}

Measured memory_bytes: 3604
[<EntryPoint>]
let main argv = 
    let numOfProblems = stdin.ReadLine() |> int

    let scoreOfProblems = stdin.ReadLine().Split(' ') |> Array.map int |> Array.sort

    let idx1 = numOfProblems / 2
    let idx2 = idx1 - 1

    printfn "%d" (scoreOfProblems.[idx1] - scoreOfProblems.[idx2])

    0 // return an 

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

using namespace std;

long long gcd(long long i, long long j) {

	//ユークリッドの互除法で最大公約数を求める
	//2変数の場合

	if (i < j) { swap(i, j); }

	while (i%j != 0) {
		long long r;
		r = i % j;
		if (r == 0) { return j; }
		else { i = j; j = r; }
	}
	return j;
}

int main() {

	int n;
	cin >> n;
	long long i0;
	if (n == 1) { cin >> i0; cout << i0 << endl; return 0; }

	vector<long long> a(n,0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long i1 = a[0];
	long long i2 = a[1];
	long long tlcm = (i1 / gcd(i1, i2))*i2;

	for (int i = 2; i < n; i++) {
		tlcm = (a[i] / gcd(a[i], tlcm))*tlcm;
	}
	cout << tlcm << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  int H,W;

 while(true){

 cin >> H >> W;

 if (H==W && H==0) break;

 for (int j = 0; j < H ; j++){
    for (int i = 0; i < W ;i++){
      cout << "#";
    }
      cout << endl;
    } 
      cout << endl;
  }
}


Measured memory_bytes: 3072
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


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



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

using namespace std;

int main()
{
   //cout << "Hello World" << endl;
   
    long int N,D;
   cin>>N>>D;
   //cin>>x;
   int count = 0;
   while(N--){
       
        long int X,Y;
       cin>>X>>Y;
        long double dist = sqrt(X*X + Y*Y);
        if(dist<=D){
            count+=1;
        }
       
   }
   cout<<count<<"\n";
   
   return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] a = sc.next().toCharArray();
		sc.close();

		int[] x = new int[a.length - 1];
		boolean one = false;
		for ( int j = 0 ; j < a.length - 1 ; j++ ) {
			x[j] = Math.abs((int)a[j + 1] - (int)a[j]);
			if ( x[j] == 1 ) {
				one = true;
			}
		}

		int ans = 0;
		if ( one ) {
			int n = x.length - 1;
			boolean odd = false;
			for ( int r = 0 ; r < x.length ; r++ ) {
				if ( x[r] == 1 && n == ( n | (n - r)) ) {
					odd = !odd;
				}
			}
			ans = odd ? 1 : 0;
		} else {
			int n = x.length - 1;
			boolean odd = false;
			for ( int r = 0 ; r < x.length ; r++ ) {
				if ( x[r] == 2 && n == ( n | (n - r)) ) {
					odd = !odd;
				}
			}
			ans = odd ? 2 : 0;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 38776
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, m, n) for(int i = m; i >= n; i--)

bool prime[20000];
int main(){
	int n;
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for(int i = 2; i * i <= 10000; i++){
		if(prime[i]){
			for(int k = i * 2; k <= 10000; k += i) prime[k] = false;
		}
	}
	while(cin>>n){
		int cnt = 0;
		rep2(i, 1, n+1){
			if(prime[i] && prime[n-i+1]) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define FR(i, l, r) for(int i = (l); i <= (r); i++)
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <pll> vll;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

main()
{
	int x, y;
	cin >> x >> y;
	cout << (x % y > 0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, m;
map<int, int> p;
vector<int> v[100010];
int c[100001], d[100001];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		c[i] = a; d[i] = b;
		v[a].push_back(b);
	}
	
	for(int i = 1; i <= n; i++){
		sort(v[i].begin(), v[i].end());
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < v[i].size(); j++){
			p[v[i][j]] = j+1;
		}
	}
	
	for(int i = 0; i < m; i++){
		int s = 100000;
		while(c[i] / s == 0){
			s /= 10;
			cout << '0';
		}
		cout << c[i];
		s = 100000;
		while(p[d[i]] / s == 0){
			s /= 10;
			cout << '0';
		}
		cout << p[d[i]] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 12416
#include <stdio.h>

int main()
{
    int h_hi, w_hi, h_low, w_low;
    
    scanf("%d %d",&h_hi, &w_hi);
    scanf("%d %d",&h_low, &w_low);
    
    printf("%d",(h_hi - h_low) * (w_hi - w_low));
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 11111, M = 111111 * 4;

struct edge
{
	int other[M], succ[M], last[M], sum;
	void clear(){
		memset(last, -1, sizeof(last));
		sum = 0;
	}
	void Add(int a, int b) {
		other[sum] = b, succ[sum] = last[a], last[a] = sum ++;
		other[sum] = a, succ[sum] = last[b], last[b] = sum ++;
	}
}e;

int n, m;
struct point
{
	int x, y;
	point(int x, int y) : x(x), y(y) {}
	point() {}
	friend point operator - (point a, point b) {
		return point(a.x - b.x, a.y - b.y); 
	}
	double arg()
	{
		return atan2(y, x);
	}
}points[N];

vector<pair<int, double> > vecs;
vector<int > ee[M];
vector<pair<double, pair<int, int> > > edges;
double length[M];
int tot, father[M], next[M], visit[M];

int find(int x) { return father[x] == x ? x : father[x] = find(father[x]); }

long long det(point a, point b)
{
	return 1LL * a.x * b.y - 1LL * b.x * a.y;
}

double dist(point a, point b) {
	return sqrt(1.0 * (a.x - b.x) * (a.x - b.x) + 1.0 * (a.y - b.y) * (a.y - b.y));
}

int main( )
{
	scanf("%d %d", &n, &m);
	e.clear();
	for (int i = 1; i <= n; i ++)
		scanf("%d %d", &points[i].x, &points[i].y);
	for (int i = 1; i <= m; i ++)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		e.Add(a, b);
	}
	for (int x = 1; x <= n; x ++)
	{
		vector<pair<double, int> > pairs;
		for (int i = e.last[x]; ~i; i = e.succ[i]) {
			int y = e.other[i];
			pairs.push_back(make_pair((points[y] - points[x]).arg(), i));
		}
		sort(pairs.begin(), pairs.end());
		for (int i = 0; i < (int )(pairs.size()); i ++)
			next[pairs[(i + 1) % (int )(pairs.size())].second ^ 1] = pairs[i].second;
	}
	memset(visit, 0, sizeof(visit));
	tot = 0;
	for (int start = 0; start < e.sum; start ++)
	{
		if (visit[start]) continue;
		long long total = 0;
		int now = start;
		vecs.clear();
		while (!visit[now])
		{
			visit[now] = 1;
			total += det(points[e.other[now ^ 1]], points[e.other[now]]);
			vecs.push_back(make_pair(now / 2, dist(points[e.other[now ^ 1]], points[e.other[now]])));
			now = next[now];
		}
		if (now == start && total > 0)
		{
			++ tot;
			for (int i = 0; i < (int )(vecs.size()); i ++)
				ee[vecs[i].first].push_back(tot);
		}
	}
	for (int i = 0; i < e.sum / 2; i ++)
	{
		int a = 0, b = 0;
		if (ee[i].size() == 0) continue;
		else if (ee[i].size() == 1)a = ee[i][0];
		else if (ee[i].size() == 2) a = ee[i][0], b = ee[i][1];
		edges.push_back(make_pair(dist(points[e.other[i * 2]], points[e.other[i * 2 + 1]]), make_pair(a, b)));
	}
	sort(edges.begin(), edges.end());
	for (int i = 0; i <= tot; i ++) father[i] = i;
	double ans = 0;
	for (int i = 0; i < (int )(edges.size()); i ++)
	{
		int a = edges[i].second.first, b = edges[i].second.second;
		double v = edges[i].first;
		if (find(a) != find(b))
		{
			ans += v;
			father[father[a]] = father[b];
		}
	}
	printf("%.5f\n", ans);
	return 0;
}

Measured memory_bytes: 24788
/**
*    created: 09.07.2020 00:48:00
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int a, b, c;
    cin >> a >> b >> c;
    if (b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N, M;
int mod = 998244353;

int power(int a, int n){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        int b = power(a, n / 2);
        return 1ll * b * b % mod;
    } else {
        return 1ll * a * power(a, n - 1) % mod;
    }
}

int main() {
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    
//    rank計算
    int rank = 0;
    for (int j = 0; j < M; j++) {
        int pivot = -1;
        for (int i = rank; i < N; i++) {
            if (A[i][j]) {
                pivot = i;
                break;
            }
        }
        if (pivot != -1) {
            swap(A[rank], A[pivot]);
            for (int i = rank + 1; i < N; i++) {
                if (A[i][j]) {
                    for (int k = j; k < M; k++) {
                        A[i][k] ^= A[rank][k];
                    }
                }
            }
            rank++;
        }
    }
    int a = power(2, N + M - 1), b = power(2, N + M - rank - 1);
    cout << (a - b + mod) % mod << endl;
}

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

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void BFS(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++)d[i]=INFTY;
    d[s]=0;
    int u;
    while(!q.empty()){
      u=q.front();
      q.pop();
      for(int v=0;v<n;v++){
	if(M[u][v]==0)continue;
	if(d[v]!=INFTY)continue;
	d[v]=d[u]+1;
	q.push(v);
      }
    }
    for(int i=0;i<n;i++){
      cout << i+1 << " " <<((d[i]==INFTY)?(-1):d[i]) << endl;
    }
}

int main() {
  int u,k,v;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)M[i][j]=0;
  }
  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v]=1;
    }
  }
  BFS(0);
  return 0;
}



Measured memory_bytes: 3120
from itertools import accumulate

N,Q=map(int,input().split())
S=input()
l=[0 for i in range(0,Q)]
r=[0 for i in range(0,Q)]
for i in range(0,Q):
    l[i],r[i]=map(int,input().split())
check=[]
for i in range(0,N-1):
    if S[i]+S[i+1]=='AC':
        check.append(1)
    else:
        check.append(0)
ans=list(accumulate(check))
for i in range(0,Q):
    if l[i]==1:
        print(ans[r[i]-2])
    else:
        print(ans[r[i]-2]-ans[l[i]-2])

Measured memory_bytes: 16636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
	int n, l;
	cin >> n >> l;

	int i;
	int ans = 0;
	int tmp = 0;
	int m = 10000;
	for(i = 1; i <= n; i++){
		ans += l + i - 1;
	}

	for(i = 1; i <= n; i++){
		if(m > abs(ans - (ans - (l+i-1)))){
			m = abs(ans - (ans - (l+i-1)));
			tmp = ans - (l+i-1);
		}
	}

	cout << tmp << endl;
}
	


Measured memory_bytes: 256
N = int(input())
*a, = map(int, input().split())
# 何が何回連続で出現するかを記録する
Nums, Cnts = [a[0]], [1]
index = 0  # Nums,Cntsを参照するindex
for i in range(1, N):
	if a[i] == Nums[index]:
		Cnts[index] += 1
	else:
		Nums.append(a[i])
		Cnts.append(1)
		index += 1
ans = 0
for j in range(len(Cnts)):
	if Cnts[j] > 1:
		ans += Cnts[j] // 2
print(ans)


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

bool isPrime(ll X){
  ll X_sqrt = (ll)sqrt(X)+1;
  for(ll i=2; i<=X_sqrt; ++i){
    if(X%i==0) return false;
  }
  return true;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X;
  IN(X);
  if(X<=2){
    X=2;
  }else{
    while(!isPrime(X)) X++;
  }
  OUT(X);

  return 0;
}


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

int main() {
    //freopen( "in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    double n;
    cin >> n;
    double x = (double) 2 * 3.14159*n;
    cout << fixed << setprecision(2) << x << '\n';
    return 0;
}


Measured memory_bytes: 3796
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int a, b;

int main() {
    fastio();

    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible\n";
    } else {
        cout << "Impossible\n";
    }

    return 0;
}

Measured memory_bytes: 256
#memo = [0] * 100000000
#memo[1] = 1

def saiki(n):
#    global memo
    tmp = 0
    if n <= 1:
        return 1
#        return memo[1]
    else:
        tmp = int(n/2)
        return saiki(tmp) * 2 + 1
#        if memo[tmp] == 0:
#            memo[tmp] = saiki(tmp)
#        return memo[tmp]+memo[tmp]+1
    
h = int(input())
print(saiki(h))


Measured memory_bytes: 9044
module Main (main)
    where

import Data.List

readIntegers :: String -> [Integer]
readIntegers = map read . words

solve :: [Integer] -> Integer
solve [a, b] = maximum $ [(+), (-), (*)] <*> [a] <*> [b] 

main :: IO ()
main = putStrLn . toStr. solve . readIntegers =<< getLine
    where toStr = show

Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll alph[26];
    rep(i, 26) alph[i]=1;
    char S[100100];
    ins(S);
    rep(i, strlen(S)) alph[S[i]-'a'] = 0;
    rep(i, 26){
        if(alph[i]){
            printf("%c\n", 'a'+i);
            return 0;
        }
    }
    puts("None");
    return 0;
}


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

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

       for(int i = 1; i <= 100000; i++) {
            if((i * 108) / 100 == n) {
                    cout << i << endl;
                    return 0;
            }
       }
        cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define N 200000
#define WHITE 0
#define BLACK 1
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

void dfs(int n, int comp[], vector<int> G[]) {
    int i, j, vertex, neighbor, color[N];
    stack<int> S;
    rep(i, n) color[i] = WHITE;
    rep(i, n) {
        if(color[i] == WHITE) {
            S.push(i);
            while(!S.empty()) {
                vertex = S.top();
                S.pop();
                color[vertex] = BLACK;
                comp[vertex] = i;
                rep(j, G[vertex].size()) {
                    neighbor = G[vertex][j];
                    if(color[neighbor] == WHITE) S.push(neighbor);
                }
            }
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    int comp[N];
    vector<int> G[N];
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        G[s].pb(t);
        G[t].pb(s);
    }
    dfs(n, comp, G);
    int ans = 0;
    map<int,int> mp;
    rep(i, n) {
        mp[comp[i]]++;
    }
    for(auto x : mp) {
        ans = max(ans, x.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n,m;
    pair<int,int> arr[101];
    while(cin>>n>>m, n|m){
        rep(i,m){
            arr[i+1].second=i+1;
            arr[i+1].first=0;
        }
        rep(i,n){
            rep(j,m){
                int c; cin>>c;
                arr[j+1].first+=c;
            }
        }
        sort(arr+1, arr+1+m,[](const pair<int,int>& a,const pair<int,int>& b){
                if(a.first!=b.first) return a.first>b.first;
                return a.second<b.second;
            });
        rep(i,m){
            cout<<arr[i+1].second<<(i!=m-1?' ':'\n');
        }
    }
}

Measured memory_bytes: 1152
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong();
        System.out.println((800 * N - 200 * (N / 15)));
	}
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int a, b, c, x, y;

int main()
{
    cin >> a >> b >> c >> x >> y;
    if(a + b <= 2 * c) cout << x * a + y * b << endl;
    else
    {
        int res = 0;
        int n = min(x, y);

        res = n * 2 * c;
        x -= n, y -= n;

        int d, p;
        if(!x) d = y, p = b;
        else d = x, p = a;
        if(2 * c <= p) res += 2 * c * d;
        else res += d * p;

        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
 
int main(){
  int N,K;
  cin>>N>>K;
  VI A(N);
  rep(i,N) cin>>A[i];
  ll sum=0;
  rep(i,K) sum+=A[i];
  ll M=sum;
  rep(i,N-K){
    sum=sum-A[i]+A[i+K];
    if(M<sum) M=sum;
  }
  double MM=(M+K)/(double)2;
  cout<<setprecision(10);
  cout<<MM<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[i + 1]) {
			ans++;
		}
	}
	if (ans == 0) {
		cout << 1;
	}
	else {
		cout << ans;
	}
	
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    
    rep(i, s.size()-1) {
        if(s[i] == 'A' && s[i+1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    long long A[N+1],B[N],i,f,s;
    for(i=0;i<N+1;i++)
        cin>>A[i];
    for(i=0;i<N;i++)
        cin>>B[i];
    s=0;
    for(i=0;i<N;i++){
        if(B[i]>A[i]){
            s=s+A[i];
            f=B[i]-A[i];
            if(f>=A[i+1]){
                s=s+A[i+1];
                A[i+1]=0;
            }
            else{
                s=s+f;
                A[i+1]=A[i+1]-f;
            }
        }
        else{
            s=s+B[i];
        }
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 1792
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

len1 = T1 * A1 + T2 * A2
len2 = T1 * B1 + T2 * B2
if len1 == len2:
  print("infinity")
  quit()

ans = 0
subs = 0  
sub1 = T1 * (A1 - B1)
sub2 = T2 * (A2 - B2)

if sub1 > 0:
  if len1 - len2 > 0:
    ans = 0
  else:
    S = (-1 * sub1) // (sub1 + sub2)
    T = (-1 * sub1) % (sub1 + sub2)
    if T == 0:
      ans = 2 * S
    else:
      ans = 2 * S + 1
else:
  if len1 - len2 < 0:
    ans = 0
  else:
    S = (-1 * sub1) // (sub1 + sub2)
    T = (-1 * sub1) % (sub1 + sub2)
    if T == 0:
      ans = 2 * S
    else:
      ans = 2 * S + 1
    
print(ans) 

Measured memory_bytes: 3064