akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int energy(vector<int> vec, int p) {
  int enesum = 0;
  rep(i, vec.size()) enesum += (vec.at(i) - p) * (vec.at(i) - p);
  return enesum;
}

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X.at(i);
  int ans = 1000000000;
  sort(X.begin(), X.end());
  for (int i = X.at(0); i < X.at(N - 1) + 1; i++) {
    if (energy(X, i) < ans) ans = energy(X, i);
  }
  cout << ans;
}


Measured memory_bytes: 3564
import sys
input = sys.stdin.readline

n = int(input()) 
num = [int(input()) for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if ind==i:
        print(ma2)
    else:
        print(ma)

Measured memory_bytes: 13404
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  ans = 0
  for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
      ans += i
  print(ans)
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

int main() {

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

    map<int, int> M;
    for(int i = 1; i <= N; i++){
        M[i] = 0;
    }

    for(int i = 0; i < N-1; i++){
        M[A[i]]++;
    }

    for(auto m:M){
        cout << m.second << endl;
    }

    return 0;
}

Measured memory_bytes: 13784
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

#define TOP_NUM 14
#define NOTOP_NUM 12

int main(){
	IO_STREAM;
	int D;	cin>>D;
	vi c(26);
	vector<pair<int,int>>cs(26);
	rep(i,0,26){
		cin>>c[i];
		cs[i].first=c[i];
		cs[i].second=i;
	}
	int s[D][26];
	rep(i,0,D){
		rep(j,0,26){
			cin>>s[i][j];
		}
	}

	sort(all(cs));
	reverse(all(cs));
	vi top(D,1);
	rep(i,0,TOP_NUM){
		top[i]=cs[i].second+1;
	}
	vi notop(D,1);
	rep(i,0,NOTOP_NUM){
		notop[i]=cs[i+TOP_NUM].second+1;
	}

	int cnt=1;
	int nt_idx=0;
	while(1){
		rep(i,0,TOP_NUM){
			cout<<top[i]<<endl;
			cnt++;
			if(cnt>D) return 0;
		}
		rep(i,0,5){
			cout<<notop[nt_idx]<<endl;
			nt_idx++;
			if(nt_idx>=NOTOP_NUM) nt_idx=0;
			cnt++;
			if(cnt>D) return 0;
		}
	}
	return 0;
}


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

using namespace std;

#define ll long long
int main()
{
    int n;  cin >> n;
    // vector <ll> v(n);
    ll s = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 || i % 5 == 0) 
            continue;
        s += i;
    }
    cout << s << "\n";
    
}


Measured memory_bytes: 3636
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 2e5 + 5;

int N;
LL K, A[MAXN];

void input()
{
    read(N); read(K);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
}

void solve()
{
    for (int i = 1; i <= N; ++i) {
        A[i] -= K;
        A[i] += A[i - 1];
    }

    using namespace __gnu_pbds;
    typedef pair<LL, int> Atom;
    tree<Atom, null_type, std::less<Atom>, rb_tree_tag, tree_order_statistics_node_update> S;

    LL ans = 0;
    S.insert(MP(0, 0));
    for (int i = 1; i <= N; ++i) {
        S.insert(MP(A[i], i));
        int k = S.order_of_key(MP(A[i], i));
        ans += k;
    }

    printf("%lld\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 恨君不似江楼月，南北东西，南北东西，只有相随无别离。
//     -- 吕本中《采桑子·恨君不似江楼月》


Measured memory_bytes: 14336
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

// geometry library from hos

const double PI = acos(-1);

int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }

struct PT {
	double x, y, z;
	PT() {}
	PT(double x, double y, double z) : x(x), y(y), z(z) {}
	PT operator+(const PT &a) const { return PT(x + a.x, y + a.y, z + a.z); }
	PT operator-(const PT &a) const { return PT(x - a.x, y - a.y, z - a.z); }
	PT operator-() const { return PT(-x, -y, -z); }
	PT operator*(const double &k) const { return PT(x * k, y * k, z * k); }
	PT operator/(const double &k) const { return PT(x / k, y / k, z / k); }
	double abs() const { return sqrt(x * x + y * y + z * z); }
	double abs2() const { return x * x + y * y + z * z; }
	double dot(const PT &a) const { return x * a.x + y * a.y + z * a.z; }
	PT cross(const PT a) const { return PT(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x); }
	bool operator<(const PT &a) const { return (x != a.x) ? (x < a.x) : (y != a.y) ? (y < a.y) : (z < a.z); }
	bool operator==(const PT &a) const { return (sig(x - a.x) == 0) && (sig(y - a.y) == 0) && (sig(z - a.z) == 0); }
};
ostream &operator<<(ostream &os, const PT &a) { os << "(" << a.x << ", " << a.y << ", " << a.z << ")"; return os; }
PT tri(PT a, PT b, PT c) { return (b - a).cross(c - a); }
double tet(PT a, PT b, PT c, PT d) { return (b - a).cross(c - a).dot(d - a); }

double dLP(PT a, PT b, PT c) {
	return tri(a, b, c).abs() / (b - a).abs();
}
double dSP(PT a, PT b, PT c) {
	if (sig((b - a).dot(c - a)) <= 0) return (c - a).abs();
	if (sig((a - b).dot(c - b)) <= 0) return (c - b).abs();
	return tri(a, b, c).abs() / (b - a).abs();
}

// end of library

int N,M,R;
PT S[2010];
double SR[2010];
PT T[16];
double TB[16];
PT E;
int table[2010];

int main2(){
	fill(table,table+N,0);
	rep(i,N)rep(j,M){
		if(dSP(E,T[j],S[i]) < SR[i]
		&& !(max((E-S[i]).abs2(),(T[j]-S[i]).abs2()) < SR[i]*SR[i])){
			table[i] |= 1<<j;
		}
	}
	
	double ans=0;
	rep(mask,1<<M){
		int rem=0;
		rep(i,N){
			if(table[i]&mask)rem++;
		}
		if(rem<=R){
			double res=0;
			rep(j,M)if(mask>>j&1){
				res+=TB[j]/(E-T[j]).abs2();
			}
			ans=max(ans,res);
		}
	}
	cout<<setprecision(16)<<ans<<endl;
	return 0;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N>>M>>R,N){
		rep(i,N)cin>>S[i].x>>S[i].y>>S[i].z>>SR[i];
		rep(i,M)cin>>T[i].x>>T[i].y>>T[i].z>>TB[i];
		cin>>E.x>>E.y>>E.z;
		main2();
	}
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int cb(int x){
    int res = 0;
    while(x){
        if(x&1)++res;
        x>>=1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<int> F(N, 0);
    REP(i, N){
        REP(j, 10){
            F[i]<<=1;
            int d;
            cin>>d;
            F[i]+=d;
        }
    }
    vector<vector<int>> P(N, vector<int>(11, 0));
    foreach(i, P)
        foreach(j, i)cin>>j;
    int ans = INT_MIN;
    REPA(i, 1<<10){
        int sum = 0;
        REP(j, N){
            sum += P[j][cb(i&F[j])];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

int main(void) {

  int taro = 0;
  int hanako = 0;
  string t_card, h_card;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t_card >> h_card;
    if(t_card == h_card){
      taro++;
      hanako++;
    }
    else if (t_card > h_card)
      taro += 3;
    else
      hanako += 3;
  }

  cout << taro << " " << hanako << endl;
  
}


Measured memory_bytes: 3156
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((a+b == c || b+c == a || a+c == b) ? "Yes" : "No") << endl;
}


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

int main(){
  ll n;
  cin >> n;
  ll s=n*(n+1)*(n+2)/6;
  ll u,v,i;
  for(i=0;i<n-1;i++){
    cin >> u >> v;
    if(u>v){
      swap(u,v);
    }
    s -= u*(n-v+1);
  }
  cout << s << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	printf("%.15lf\n", sqrt(d));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<pair<string, int>> v(N);
    map<pair<string, int>, int> mp;
    for(int i=0; i<N; i++){
        string s;
        int p;
        cin >> s >> p;
        v[i].first = s;
        v[i].second = -p;
        mp[v[i]] = i+1;
    }
    sort(v.begin(), v.end());
    for(int i=0; i<N; i++) cout << mp[v[i]] << endl;

    
}

Measured memory_bytes: 256
import heapq as hq
Q = int(input())
minval = 0
argminval = -(10**9)
#aを大きい方と小さい方に分けて最小ヒープで管理(Lは最大が欲しいので-1掛けておく)
L, R = [10**9], [10**9]
lenL, lenR = 0, 0

for _ in range(Q):
    qi = list(map(int, input().split()))
    if qi[0] == 1:
        ai, bi = qi[1], qi[2]
        LC, RC = -1*L[0], R[0] #左右それぞれで中央に一番近いもの
        if lenL == lenR:
            if ai < RC:
                #Lにaiを追加
                hq.heappush(L, -1*ai)
            else:
                #RCをLに移動, Rにaiを追加
                hq.heappop(R)
                hq.heappush(L, -1*RC)
                hq.heappush(R, ai)
            lenL += 1
            #新しいargminで最小値更新
            argminval = -1*L[0]
            minval += abs(argminval - ai) + bi
        else:
            if ai < LC:
                #LCをRに移動, Lにaiを追加
                hq.heappop(L)
                hq.heappush(L, -1*ai)
                hq.heappush(R, LC)
            else:
                #Rにaiを追加
                hq.heappush(R, ai)
            lenR += 1
            #古いargminで最小値更新
            minval += abs(argminval - ai) + bi
            argminval = -1*L[0]
    else:
        print("{} {}".format(argminval, minval))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll n, res = 0;
  cin >> n;
  vector<ll> a(n), l(n + 1), r(n + 1);

  rep(i, n) cin >> a[i];

  for (int i = 0; i < n; ++i) l[i + 1] = gcd(l[i], a[i]);
  for (int i = n - 1; i >= 0; --i) r[i] = gcd(r[i + 1], a[i]);

  for (int i = 0; i < n; ++i) res = max(gcd(l[i], r[i + 1]), res);

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


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

int main() {
    int a, b;
    cin >> a >>b;
    while(a!=0 && b!=0) {
        for (int i=0; i< a; i++) {
            int rowOdd = (i+1)%2;
            for (int j=0; j<b; j++) {
                int colOdd = (j+1)%2;
                //row odd, col odd #
                //row odd, col even .
                //row even, col odd .
                //row even, col even #
                if ((rowOdd && colOdd) || (!rowOdd && !colOdd)) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;

void solve()
{
   cin>>n>>k>>m;
   c=0;
   map<ll,ll>sum,f;
   for(ll i=0;i<n;i++)
   {
       c+=k;
       sum[i]=c;
       k=(k*k)%m;
       
       if(f.find(k)!=f.end())
       {
           ll rest=(n-i-1);
           ll add=(c-sum[f[k]]);
           ll re=(i-f[k]);
           
           c+=((rest/re)*add)+(sum[f[k]+(rest%re)]-sum[f[k]]);
           break;
       }
       else
       {
           f[k]=i;
       }
   }
   cout<<c;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    
   //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 9836
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

int main() {
  LL h, w, n;
  cin >> h >> w >> n;
  map<pair<int, int>, LL> mp;
  rep(i, n) {
    int x, y; cin >> x >> y;
    x --, y --;
    rep(j, 9) {
      int nx = x + dx[j];
      int ny = y + dy[j];
      if (1 < nx && 1 < ny && nx <= h - 1 && ny <= w - 1) mp[make_pair(nx, ny)] ++;
    }
  }

  vector<LL> ans(10, 0);
  int sum = 0;
  for (auto x : mp) {
    ans[x.second] ++;
    sum ++;
  }
  ans[0] = (h - 2) * (w - 2) - sum;

  rep(i, 10) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 56448
from collections import deque
import numpy as np

N, M, K = [int(x) for x in input().split()]

friends = [[] for _ in range(N + 1)]
for i in range(M):
    A, B = [int(x) for x in input().split()]
    friends[A].append(B)
    friends[B].append(A)

block = [[] for _ in range(N + 1)]
for i in range(K):
    C, D = [int(x) for x in input().split()]
    block[C].append(D)
    block[D].append(C)

G = []
check = [False] * (N + 1)
for i in range(1, N + 1):
    if check[i] == False:
        check[i] = True
        g = [i]
        q = deque([i])
        while q:
            j = q.popleft()
            for k in friends[j]:
                if check[k] == False:
                    check[k] = True
                    g.append(k)
                    q.append(k)
        G.append(g)

gr = np.array([0] * (N + 1))
fr = np.array([len(friends[i]) for i in range(N + 1)])
bl = np.array([0] * (N + 1))

for g in G:
    s = set(g)
    for v in g:
        gr[v] = len(g)
        b = set(block[v])
        bl[v] = len(s & b)

ans = gr - fr - bl - np.array([1] * (N + 1))

for i in range(1, N + 1):
    print(ans[i], end='')
    if i == N:
        print('')
    else:
        print(' ', end='')

Measured memory_bytes: 76252
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int a, b; cin >> a >> b;
    if(a>b) swap(a, b);
    for(int i=0; i<b; ++i) cout << a;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

x,y = map(int,input().split())

if x == 2:
    x = "c"
elif x == 4 or x == 6 or x == 9 or x == 11:
    x = "b"
else:
    x = "a"

if y == 2:
    y = "c"
elif y == 4 or y == 6 or y == 9 or y == 11:
    y = "b"
else:
    y = "a"

if x == y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys

n = int(input()) 
ans = 1
num_list = list(map(int, input().split()))
for i in range(n):
	if(num_list[i] == 0):
		print(0)
		sys.exit(0)

for i in range(n):
	ans *= num_list[i]
	if ans > 1000000000000000000:
		print(-1)
		sys.exit(0)
print(ans)


Measured memory_bytes: 21516
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
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;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

ll dp[4][3005][3005];
ll d[3005][3005];

void solve() {
    int R, C, K;
    cin >> R >> C >> K;
    rep(i, K) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        d[r][c] = v;
    }
    rep(k, 4) rep(i, R) rep(j, C) dp[k][i][j] = 0;

    rep(i, R) rep(j, C) {
        rep(k, 4) {
            if (i > 0) {
                dp[0][i][j] = max(dp[0][i][j], dp[k][i - 1][j]);
            }
        }
        rep(k, 4) {
            if (j > 0) {
                dp[k][i][j] = max(dp[k][i][j], dp[k][i][j - 1]);
            }
        }
        if (d[i][j] > 0) {
            for (int k = 2; k >= 0; k--) {
                //
                ll v = d[i][j];
                dp[k + 1][i][j] = max(dp[k + 1][i][j], dp[k][i][j] + v);
            }
        }
    }

    ll ans = 0;
    rep(i, 4) ans = max(ans, dp[i][R - 1][C - 1]);
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 355480
#include <bits/stdc++.h>
using namespace std;
char s[100010];
int main()
{
	
	
	scanf("%s", s);
	int x = strlen(s);
	int p = -1, q = -1;
	if (x == 2) {
		if (s[0] == s[1]) {
			p = 1, q = 2;
		}
	} else
	for (int i = 0; i + 2 < x; i++) {
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
			p = i + 1, q = i + 3;
			break;
		}
	}
	printf("%d %d\n", p, q);
}

Measured memory_bytes: 384
n = int(input())
a = map(int, input().split())
flag = True
for num in a:
    if num % 2 == 0:
        if num % 3 != 0 and num % 5 != 0:
            flag = False
            break
if flag == False:
    print("DENIED")
else:
    print("APPROVED")

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

using namespace std;

const ll mod = 1e9 + 7;
ll k, fact[2000005], ans;
string s;

ll find(ll x) {
    if (x == 1) return x;
    return (mod - mod / x) * find(mod % x) % mod;
}

ll comb(ll x, ll y) {
    return (fact[y] * find(fact[y - x]) % mod * find(fact[x])) % mod;
}

int main() {
    cin >> k >> s;
    fact[0] = 1;
    for (ll i = 1; i <= 2000000; i++) {
        fact[i] = fact[i - 1] * i % mod;
    }
    ll pow = 1;
    for (ll i = 1; i <= k; i++) pow = pow * 25 % mod;
    for (ll i = 0; i <= k; i++) {
        ans = (ans + pow * comb(s.length() - 1, k - i + s.length() - 1)) % mod;
        pow = (pow * find(25) * 26) % mod;
    }
    if (ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19988
/**
 * code generated by RHelper
 * More info: https://github.com/mkc1370/RHelper
 * @author 
 */

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

public class BCountBalls
{
    private readonly StringReader cin;
    private readonly StringWriter cout;
    private readonly Scanner scanner;

    public BCountBalls(StringReader cin, StringWriter cout)
    {
        this.cin = cin;
        this.cout = cout;
        scanner = new Scanner(cin);
    }

    public void Solve()
    {
        var n = CINL;
        var a = CINL;
        var b = CINL;
        COUT(n/(a+b)*a+Math.Min(a, n%(a+b)));
    }

    private long CINL => scanner.Long();
    private double CIND => scanner.Double();
    private string CINS => scanner.String();
    private static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat(v, (int)n);
    private List<long> CINVL(long n) => Repeat(0, n).Select(_ => CINL).ToList();
    private List<double> CINVD(long n) => Repeat(0, n).Select(_ => CIND).ToList();
    private List<string> CINVS(long n) => Repeat(0, n).Select(_ => CINS).ToList();

    private void COUT(object o) => cout.WriteLine(o);
}

public class Scanner
{
    public Scanner(StringReader stringReader)
    {
        this.stringReader = stringReader;
    }

    private readonly StringReader stringReader;
    private readonly char[] buffer = new char[1024];
    private int len, ptr;
    private bool isEof;

    private char Read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = stringReader.Read(buffer, 0, 1024)) <= 0)
            {
                isEof = true;
                return '\0';
            }
        }

        return buffer[ptr++];
    }

    public char Char()
    {
        char b;
        do b = Read();
        while (b < 33 || 126 < b);
        return b;
    }

    public string String()
    {
        var sb = new StringBuilder();
        for (char b = Char(); b >= 33 && b <= 126; b = Read())
            sb.Append(b);
        return sb.ToString();
    }

    public long Long()
    {
        long ret = 0;
        char b;
        var ng = false;
        do b = Read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = Read();
        }

        for (;; b = Read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }

    public double Double()
    {
        return double.Parse(String(), CultureInfo.InvariantCulture);
    }
}


public class Output
{
	public static void Main()
	{
		var reader = new System.IO.StringReader(Console.In.ReadToEnd());
		var writer = new System.IO.StringWriter();
		var solver = new BCountBalls(reader, writer);
		solver.Solve();
		System.Console.Write(writer.GetStringBuilder().ToString());
	}
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a > 0 && b > 0) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

int D;
vector<int> c;
vector<vector<int>> s;

class Answer {
public:
    // 0~25の構造体
    vector<int> ans;
    explicit Answer() {
        ans.resize(D,0);
    }

    void print_ans() {
        for(const auto &it: ans) cout << it+1 << endl;
    }
};

void read() {
    cin >> D;
    c.resize(26);
    REP(i,26) cin >> c[i];
    s.resize(D);
    REP(i,D) {
        s[i].resize(26);
        REP(j,26) cin >> s[i][j];
    }
}

// 下がりやすさを無視して一番点が高い物を選ぶ
Answer greedy1() {
    Answer answer = Answer();
    REP(day,D) {
        int mx = 0;
        REP(typ,26) if(chmax(mx,s[day][typ])) answer.ans[day] = typ;
    }
    return answer;
}

// 下がりやすさを考慮して一番高い物を選ぶ
Answer greedy2() {
    Answer answer = Answer();
    // あるコンテストi-1が開催されていない日数
    vector<int> not_open_term(26,0);

    REP(day,D) {
        // 期待値の最大値
        int mx = 0;
        REP(typ,26) {
            // そのコンテストを開催した際の満足度変動値を計算する。
            int manzoku = s[day][typ];
            REP(_typ,26) if(_typ != typ )manzoku-=(not_open_term[_typ] * c[_typ]);
            if(chmax(mx,manzoku)) answer.ans[day] = typ;
        }
        REP(i,26) not_open_term[i]++;
        // 開催するコンテストが決定されたらそれの日数を0にする。
        not_open_term[answer.ans[day]] = 0;
    }
    return answer;

}


void solve() {
    read();
    // auto ans = Answer();
    // ans.print_ans();
    auto ans = greedy1();
    ans.print_ans();
}

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if (c % __gcd(a, b) == 0) cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

int main(void){
  int h, n;
  scanf("%d %d\n",&h ,&n);

  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d\n", &a[i]);
  }

  int count=0;
  while(count < n){
    h -= a[count];
    count++;
  }
  if(h > 0)
    printf("No\n");
  else
    printf("Yes\n");

  return(0);
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;

    }
    return 0;
}



Measured memory_bytes: 256
H, N = map(int, input().split())
Magic = []

for i in range(N):
    A, B = map(int, input().split())
    Magic.append((A, B))

HP = [10**9] * (H+1)
HP[0] = 0

for m in Magic:
    if m[0] >= H:
        HP[H] = min(HP[H], HP[0] + m[1])
    else:
        HP[m[0]] = min(HP[m[0]], HP[0] + m[1])

for i in range(1, H+1):
    if HP[i]:
        for m in Magic:
            if i + m[0] >= H:
                HP[H] = min(HP[H], HP[i] + m[1])
            else:
                HP[i + m[0]] = min(HP[i + m[0]], HP[i] + m[1])
print(HP[H])

Measured memory_bytes: 40880
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int h, w, n;
    int nh=1;
    int nw=1;
    int k=0;
    
    cin >> h >> w;
    cin >> n;
    
    vector<int> a(n+1);
    int ans[109][109]={};
    
    for(int i=1; i<=n; i++){
        
        cin >> a.at(i);
        
    }
    
    for(int i=1; i<=n; i++){
        
        k = a.at(i);
        
        for(int j=1; j<=k; j++){
            
            ans[nh][nw] = i;
            
            if(nh%2==1){
                
                if(nw>=w){
                    
                    nh += 1;
                    
                } else {
                    
                    nw += 1;
                    
                }
                
            } else {
                
                if(nw<=1){
                    
                    nh += 1;
                    
                } else {
                    
                    nw -= 1;
                    
                }
                
            }
            
        }
        
    }
    
    for(int i=1; i<=h; i++){
        
        for(int j=1; j<=w; j++){
            
            cout << ans[i][j];
            
            if(j<w){
                
                cout << " ";
                
            }
            
        }
        
        cout << endl;
        
    }
    
    return 0;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    string s; cin>>s;
    
    int n = s.size();
    char l = s[0], r = s[n-1];
    itn cnt = 0;
    string tmp = s;
    bool upd = true;
    while(upd && tmp.size() != 2){
        upd = false;
        s = tmp;
        tmp = l;
        rep(i, s.size()-2){
           // cout<<s[i]<<' '<<s[i+2]<<endl;
            if(s[i+2] == l) {tmp += s[i+1]; upd = true;}
        }
        tmp += r;
        if(tmp == s) break;
    }
    //cout<<tmp<<endl;
    cnt = n - tmp.size();
    //cout<<cnt<<endl;
    if(cnt %2) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}
vector<int> step;
int n, k;
ll ans =0 ;
const int MOD = 1e9+7;
int gcd(int a, int b){
    while(b > 0){
        a %= b;
        swap(a, b);
    }
    return a;
}
void rec(int x){
    if(x == n){
        int g = 0;
        for(auto i : step){
            //cout << i << " ";
            g = gcd(g, i);
        }
        ans = (ans+g)%MOD;
        //cout << endl;
        return;
    }
    for(int i = 1; i <= k; ++i){
        step.push_back(i);
        rec(x + 1);
        step.pop_back();
    }
}
ll nc2(int x){
    return 1LL * x * (x - 1) / 2;
}
void solve(){
    int n;
    cin >> n;
    vector<int> arr(n), cnt(n + 1);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    ll ans = 0;
    for(int j = 1; j <= n; ++j){
        ans += nc2(cnt[j]);
    }
    for(int i = 0; i < n; ++i){
        ll cur = ans - nc2(cnt[arr[i]]) + nc2(cnt[arr[i]] - 1);
        cout << cur <<endl;
    }
}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 4224
#include <cstdio>
using namespace std;

int max(int a, int b) { return a < b ? b : a; }
int board[2010][2010];
int main() {
    int N, K; scanf("%d%d", &N, &K);

    int sum = 0, white = 0;
    for(int i=0; i<N; i++) {
        int x, y; char c; scanf(" %d%d %c", &x, &y, &c);
        x %= 2*K, y %= 2*K;
        if(c == 'B') board[x+1][y+1]++, sum++;
        if(c == 'W') board[x+1][y+1]--, sum--, white++;
    }

    for(int i=1; i<=2*K; i++) {
        for(int j=1; j<=2*K; j++) {
            board[i][j] += board[i][j-1];
        }
    }

    for(int j=1; j<=2*K; j++) {
        for(int i=1; i<=2*K; i++) {
            board[i][j] += board[i-1][j];
        }
    }

    int ma = -(1 << 25);
    for(int i=0; i<=K; i++) {
        for(int j=0; j<=K; j++) {
            int a = board[i][j];
            int b = board[i+K][j+K] - board[i+K][j] - board[i][j+K] + board[i][j];
            int c = board[2*K][j] - board[i+K][j];
            int d = board[i][2*K] - board[i][j+K];
            int e = board[2*K][2*K] - board[2*K][j+K] - board[i+K][2*K] + board[i+K][j+K];
            int tmp = a + b + c + d + e;
            ma = max(ma, max(tmp, sum - tmp));
        }
    }
    ma += white;
    printf("%d\n", ma);
    return 0;
}

Measured memory_bytes: 15872
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string str;
	cin>>str;
	if(str[2]==str[3] && str[4]==str[5])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int A,B,C,D,E,F;
bool dp[3001][3001];
main()
{
	cin>>A>>B>>C>>D>>E>>F;
	dp[0][0]=true;
	int ansa=100*A,ansb=0;
	for(int i=0;i<=F;i++)for(int j=0;j<=F;j++)
	{
		if(!dp[i][j])continue;
		if(i+100*A<=F)dp[i+100*A][j]=true;
		if(i+100*B<=F)dp[i+100*B][j]=true;
		if(i+C<=F&&j+C<=F)dp[i+C][j+C]=true;
		if(i+D<=F&&j+D<=F)dp[i+D][j+D]=true;
		if((i-j)/100*E<j)continue;
		if(ansb*100*i<j*100*ansa)ansa=i,ansb=j;
	}
	cout<<ansa<<" "<<ansb<<endl;
}


Measured memory_bytes: 8576
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	long x = sc.nextLong();
      	long have = 100;
      	int count = 0;
      	while(have < x){
        	have += have/100;
          	count++;
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 35800
N = int(input())
A = list(map(int, input().split()))

ans = [0] * N
sum_A = sum(A)
ans[0] = sum_A - sum(A[1::2]) * 2
for i in range(1, N):
    ans[i] = 2 * A[i-1] - ans[i-1]
print(" ".join(map(str, ans)))


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

int main() {
	char s[3];
	int a = 0, b = 0, c= 0, i = 0;
	cin >> s;
	while (i < 3) {
	    if (s[i] == 'a') a++;
	    else if (s[i] == 'b') b++;
	    else c++;
	    i++;
	}
	if (a == 1 && b == 1 && c == 1) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A = input()
N = len(A)

zero_num = A.count('0')
one_num = A.count('1')


if N == 1 or zero_num == 0 or one_num == 0:
    print(0)
    exit()

if zero_num == 1 or one_num == 1:
    print(2)
    exit()

if zero_num == one_num:
    ans = one_num*2
elif zero_num > one_num:
    ans = one_num*2
else:
    ans = zero_num*2

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    long count1=0;
    bool flag=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        if(flag&&sum>=0){
            count1+=sum+1;
            sum=-1;
        }
        else if(!flag&&sum<=0){
            count1+=abs(sum)+1;
            sum=1;
        }
        flag^=1;
    }
    flag=0;
    sum=0;
    long count2=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        if(!flag&&sum>=0){
            count2+=sum+1;
            sum=-1;
        }
        else if(flag&&sum<=0){
            count2+=abs(sum)+1;
            sum=1;
        }
        flag^=1;
    }
    cout<<min(count1,count2)<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
char s[N];
int a[2][N];
int f(int a){
	if(a == 0) return 0;
	return 1 + f(a % __builtin_popcount(a));
}

int main(){
	int n; scanf("%d%s", &n, s);
	REP(i, n) s[i] -= '0';

	int c = 0;
	REP(i, n) if(s[i] == 1) c++;

	int pp[2] = {c+1, c-1}, q[2] = {};
	REP(j, 2){
		int p = pp[j];
		if(p < 1) continue;

		a[j][n-1] = 1;
		for(int i = n-2; i >= 0; i--)
			a[j][i] = a[j][i+1] * 2 % p;

		REP(i, n) q[j] = (q[j] + s[i] * a[j][i]) % p;
	}
	
	REP(i, n){
		int p = pp[s[i]];
		DEBUG("p = %d\n", p);
		if(p == 0){
			printf("0\n");
			continue;
		}
		int z = q[s[i]];
		z += ((1-s[i]) - s[i]) * a[s[i]][i];
		z = (z % p + p) % p;
		DEBUG("z = %d %+d * %d = %d\n", q[s[i]], ((1-s[i])-s[i]), a[s[i]][i], z);
		printf("%d\n", f(z)+1);
	}
}





Measured memory_bytes: 5544
s = input()
t = input()

s_dic = {}
t_dic = {}
s_cnt = 0
t_cnt = 0
s_mod = ''
t_mod = ''
for i in range(0, len(s)):
  if s[i] not in s_dic:
    s_dic[s[i]] = s_cnt
    s_cnt += 1

  s_mod += str(s_dic[s[i]])
  
  if t[i] not in t_dic:
    t_dic[t[i]] = t_cnt
    t_cnt += 1
  
  t_mod += str(t_dic[t[i]])
  
if s_mod == t_mod:
  print('Yes')
else:
  print('No')

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

using namespace std;

int H,W;
int k=0;
char a[110][110]={};

int solve(int A,int B){
  for(int i=0;i<A;i++){
    k=0;
    for(int j=0;j<B;j++){
      if(a[i][j]!='#'){
        k++;
      }
    }
    cout << k << endl;
    if(k==B){
      for(int I=i;I<A-1;I++){
        for(int j=0;j<B;j++){
          a[I][j]=a[I+1][j];
        }
      }
      A=A-1;
    }
  }
  return A;
}

int main(){
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a[i][j];
    }
  }
  //H=solve(H,W);
  for(int i=0;i<H;i++){
    k=0;
    for(int j=0;j<W;j++){
      if(a[i][j]!='#'){
        k++;
      }
    }
    //cout << k << endl;
    if(k==W){
      for(int I=i;I<H-1;I++){
        for(int j=0;j<W;j++){
          a[I][j]=a[I+1][j];
        }
      }
      H=H-1;
      i--;
    }
  }

/*
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << a[i][j];
    }
    cout << endl;
  }
  */


  //cout << H << W << endl;
  //W=solve(W,H);
  for(int i=0;i<W;i++){
    k=0;
    for(int j=0;j<H;j++){
      if(a[j][i]!='#'){
        k++;
      }
    }
    //cout << k << endl;
    if(k==H){
      for(int I=i;I<W-1;I++){
        for(int j=0;j<H;j++){
          a[j][I]=a[j][I+1];
        }
      }
      W=W-1;
      i--;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << a[i][j];
    }
    cout << endl;
  }




}


Measured memory_bytes: 256
let solve a b c x =
  let rec f acc i j k =
    if i > a then acc
    else if j > b then f acc (i+1) 0     0
    else if k > c then f acc i     (j+1) 0
    else f (acc + if 500*i + 100*j + 50*k = x then 1 else 0) i j (k+1)
  in f 0 0 0 0

let () = Scanf.scanf "%d %d %d %d" solve |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define endl '\n'
//#define IO; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int k=0;
const int N=200005;
vector<vector<int> > G(N);
vi pos(N);
vb vis(N);
map<int,int> MP;
int cyc=0;
int p;
bool flg=false;

void dfs(int root)
{
    vis[root]=true;
    MP[k]=root;
    pos[root]=k;
    k++;

    for(int i=0;i<G[root].size();i++)
    {
        int v=G[root][i];
        if(!vis[v])
        {
            dfs(v);
        }
        else if(!flg){
            cyc=(k-pos[v]);
            p=pos[v];
            flg=true;
            return;
        }
    }
}

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

    for(int i=1;i<=n;i++)
    {
        int u;
        cin>>u;
        G[i].pb(u);
    }

    dfs(1);

    if(K<p) {cout<<MP[K]<<endl;return 0;}
    int ans=MP[p+(K-p)%cyc];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33552
import java.util.Scanner;
        
        class Main {
         
            public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                String N = sc.nextLine();
                sc.close();
                String[] S = N.split("");
                int[] n = new int[4];
                
                for(int i = 0; i < 4; i++) {
                	n[i] = Integer.valueOf(S[i]);
                }
                
                if(n[0] + n[1] + n[2] + n[3] == 7) {
                	System.out.println(n[0] + "+" + n[1] + "+" + n[2] + "+" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] + n[1] + n[2] - n[3] == 7) {
                	System.out.println(n[0] + "+" + n[1] + "+" + n[2] + "-" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] + n[1] - n[2] + n[3] == 7) {
                	System.out.println(n[0] + "+" + n[1] + "-" +  n[2] + "+" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] + n[1] - n[2] - n[3] == 7) {
                	System.out.println(n[0] + "+" + n[1] + "-" + n[2] + "-" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] - n[1] + n[2] + n[3] == 7) {
                	System.out.println(n[0] + "-" + n[1] + "+" +  n[2] + "+" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] - n[1] + n[2] - n[3] == 7) {
                	System.out.println(n[0] + "-" + n[1] + "+" + n[2] + "-" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] - n[1] - n[2] + n[3] == 7) {
                	System.out.println(n[0] + "-" +  n[1] + "-" + n[2]+ "+" + n[3] + "=7");
                	System.exit(0);
                }
                if(n[0] - n[1] - n[2] - n[3] == 7) {
                	System.out.println(n[0] + "-" +  n[1]+ "-" + n[2]+  "-" + n[3] + "=7");
                	System.exit(0);
                }
               
            }
        }

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,m,n) for(int i=(m); i<(n); ++i)

int main() {
  int n;
  cin >> n;
  int dp[10][10] = {};
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    dp[s[0]-'0'][s.back()-'0']++;
  }

  FOR (i,1,10)
    FOR (j,1,10)
      ans += dp[i][j] * dp[j][i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < N; i++){
		int key = A[i];
		int j = i - 1;
		while(A[j] > key & j >= 0)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
		for(int k = 0; k < N - 1; k++){
			cout << A[k] << " ";
		}
		cout << A[N-1] << endl;
	}
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=200000+10;

int n,k;
int a[maxn];
long long s[maxn];
long long kq;
map<int,int> m;

int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) a[i]--;
    s[0]=0;for(int i=1;i<=n;i++) s[i]=(s[i-1]+a[i])%k;
//    for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
//    for(int i=1;i<=n;i++) cout<<s[i]<<" ";cout<<endl;
    m[s[0]]++;kq=0;
    for(int i=1;i<=n;i++){
        if (i-k>=0) m[s[i-k]]--;
        kq=kq+m[s[i]];
        m[s[i]]++;
    }
    cout<<kq;
}


Measured memory_bytes: 11904