akhauriyash/Code-Regression huggingface dataset:
// ABC043_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define vl vector<ll>
#define pll pair<ll, ll>
#define F first
#define S second

int main() {
    // input
    ll N;
    cin >> N;
    vl vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    ll M = *MAX(vec), m = *MIN(vec), res = 100000000, tmp;
    for (ll i = m; i <= M; ++i) {
        tmp = 0;
        for (ll j = 0; j < N; ++j) {
            tmp += pow(i - vec[j], 2);
        }
        res = min(res, tmp);
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 251

int main(){

  int a[MAX];
  int i,n;

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

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i!=1) printf("parent key = %d, ",a[i/2]);
    if(n>=2*i) printf("left key = %d, ",a[2*i]);
    if(n>=2*i+1) printf("right key = %d, ",a[2*i+1]);
    printf("\n");
  }

  return 0;
}

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

int main(){
 int count=0;
 string s, t;
  
 cin >> s;
 cin >> t;
  
 rep(i,s.size()){
   if(s.at(i)!=t.at(i)){
     s.at(i)=t.at(i);
     count++;
   }
 }
  
 cout << count << endl;

}


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

int main() {
  int n,k; cin >> n >> k;
  int beki = 1;
  int i = 1;
  for(i = 1; true; i++){
    beki*=k;
    //cout << beki << endl;
    if(beki > n) break;
  }

  cout << i << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
using namespace std;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    vector<bool> nbroken(n,true);
    ll a,i; 
    rep(i,0,m){
        cin>>a;
        nbroken[a]=false;
    }

    vector<ll>dp(n+1);
    dp[0]=1;
    dp[1]=nbroken[1]==true;
    erep(i,2,n){
        if(nbroken[i-2]) dp[i]+=dp[i-2];
        if(nbroken[i-1]) dp[i]+=dp[i-1];
        dp[i]%=MOD;
    }

    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const ll N = 1e6+3;
ll f[N], r[N];
int q;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  f[0] = 1;
  FOR(i, 1, N) f[i] = f[i-1] * i % N;
  r[N-1] = modInv(f[N-1], N);
  FORR(i, N-1, 1) r[i-1] = r[i] * i % N;
  cin >> q;
  FOR(_, 0, q){
    ll x, d, n;
    cin >> x >> d >> n;
    if(!d){
      cout << modPow(x, n, N) << endl;
      continue;
    }
    x = x * modInv(d, N) % N;
    if(!x || N<x+n){
      cout << 0 << endl;
      continue;
    }
    cout << f[x+n-1] * r[x-1] % N * modPow(d, n, N) % N << endl;
  }
}

Measured memory_bytes: 16640
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>
#include <set> 
#include <map> 

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int tmp = a + b;
	if (b + c < tmp) tmp = b + c;
	if (a + c < tmp) tmp = a + c;
	cout << tmp << endl;
}


Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__ )
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________

int N;
int a[3][102];

signed main()
{
   FAST();
   cin >> N;
   rep(i, 2){
      rep(j, N)cin >> a[i][j];
   }

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

   for(int i=1; i<N; ++i){
      a[1][i] += max(a[1][i-1], a[0][i]);
   }

   outl(a[1][N-1]);

}



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

int main() {
    int N;
    cin >> N;
    rep(i,N+1){
        if(N == (int)(i*1.08)){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;
using iL = long long;
using iUL = unsigned long long;
using dL = long double;
#define rep(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define brep(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

#define MOD 1000000007L

int main()
{
    //----------------
    int n;
    cin >> n;
    struct my
    {
        my() {}
        my(iUL v, int i)
        {
            value = v;
            idx = i;
        }
        iUL value = 0L;
        int idx = 0;
    };
    vector<my> vec;
    iUL asum = 0L, bsum = 0L;
    rep(i, n)
    {
        iUL a, b;
        cin >> a >> b;
        vec.push_back(my(a, i));
        vec.push_back(my(b, i));
        asum += a;
        bsum += b;
    }
    sort(vec.begin(), vec.end(), [](const auto &a, const auto &b) { return a.value < b.value; });
    VEC(bool, n, bvec, false);
    iUL sum = 0L;
    int i = 0;
    bool b = false;
    my x0, x1, x2, x3;
    for (auto &pair : vec)
    {
        ++i;
        if (i == n + 1)
        {
            x2 = pair;
            continue;
        }
        if (i == n + 2)
        {
            x3 = pair;
            break;
        }
        if (i == n - 1)
            x0 = pair;
        if (i == n)
            x1 = pair;
        sum += pair.value;
        int se = pair.idx;
        if (bvec[se])
            b = true;
        else
            bvec[se] = true;
    }
    if (b || sum == asum || sum == bsum)
        cout << sum << endl;
    else
    {
        if (x1.idx != x2.idx)
            cout << sum - x1.value + x2.value << endl;
        else
        {
            iUL xx0 = x1.value + x2.value;
            iUL xx1 = x0.value + x3.value;
            cout << sum - x0.value - x1.value + min(xx0, xx1) << endl;
        }
    }

    //----------------
    return 0;
}

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

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

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M,K;
  cin>>N>>M>>K;
  for(int i=0;i<=M;i++){
    for(int j=0;j<=N;j++){
      ll ans=N*i+M*j-2*i*j;
      if(ans==K){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

int INF = 1001001001;

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n);
    rep(i,n) dp[i] = INF;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            dp[0] = 0;
            continue;
        }
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));

    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3976
#include<stdio.h>
int main(){
    int a, b, c, d;
    scanf("%d %d %d", &a, &b, &c);
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2052
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

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

	cin >> N >> K;
	while (N > 0) {
		N = N / K;
		ans += 1;
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define el '\n'
#define M 998244353
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  if(n>m)ans+=n,n--;
  else ans+=m,m--;
   if(n>m)ans+=n,n--;
  else ans+=m,m--;
  cout<<ans<<el;
  return 0;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string a = sc.Next();
        string b = sc.Next();

        int check = 0;

        if (a.Length > b.Length)
        {
            check = 1;
        }
        else if (a.Length < b.Length)
        {
            check = 2;
        }
        else
        {
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] > b[i])
                {
                    check = 1;
                    break;
                }
                if (a[i] < b[i])
                {
                    check = 2;
                    break;
                }
            }
        }

        string answer = check == 0 ? "EQUAL" : (check == 1 ? "GREATER" : "LESS");

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
###### Importing Libraries ######
import math
import operator as op
from functools import reduce
from fractions import Fraction as frac
#################################
##### User defined function #####

############ NCR ###############
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
    
############ READ ###############
def rd(p):
    if(p==0):
        return input()
    if(p==1):
        return int(input())
    if(p==2):
        return map(int,input().split())
    if(p==3):
        return list(map(int,input().split()))


############ DSU ###############
global par
# par=[-1 for i in range(100001)]
# t=rd(1)
def find(u):
    if(par[u]<0):
        return u
    else:
        return find(par[u])
def uni(x,y):
    u=find(x)
    v=find(y)
    if u==v:
        return
    if(par[u]<par[v]):
        par[u]+=par[v]
        par[v]=u
    else:    
        par[v]+=par[u]
        par[u]=v
################################        
        

t=1
for term in range(1,t+1):
    h,n=rd(2)
    P=[list(map(int,input().split())) for i in range(n)]
    x=max(a for a,b in P)
    DP=[0]*(h+x)
    for i in range(1,h+x):
        DP[i]=min(DP[i-a]+b for a,b in P)
    print(DP[h])
    
    
    
    
    
    
    
    
    
    
    
    

Measured memory_bytes: 5696
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
//a
//b
//c 29
int X, n;
vector<int> a;

int N[1000000];

signed main() {
	ios::sync_with_stdio(false);
	int x, t;
	cin >> x >> t;
	int ans = x - t;
	if (ans > 0) cout << ans << endl;
	else cout << 0 << endl;
	return 0;
}



Measured memory_bytes: 256
import itertools

n = int(input())

p = "".join(input().split())
q = "".join(input().split())

lst = []

for v in itertools.permutations(map(str, range(1, n+1)), n):
    lst.append("".join(v))

lst.sort()

d = {lst[i]: i for i in range(len(lst))}

print(abs(d[p] - d[q]))


Measured memory_bytes: 8976
#include <stdio.h>
 
int main()
{
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);
    while(1){
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    else if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    else if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    else break;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 596
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  16:30-
//A 16:36AC
//B 16:46AC
//C 16:51AC
//D 17:15WA
//D 17:17TLE
//D 17:22AC

int solve(void){
	llint kasu=(1LL<<52),sisu=0,kwa,n,i;
	cin>>n;if(n==0){return 0;}
	string str;cin>>str;
	for(i=0;i<52;i++){
		if(str[i]=='1'){kasu+=(1LL<<(51-i));}
	}
	kwa=kasu;
	while(-1){
		llint kai;
		if(kwa>0){kai=((1LL<<53)-kasu-1)/kwa+1;}
		else{kai=1e18;}
		//cerr<<"kai="<<kai<<endl;
		if(n<kai){
			kasu+=kwa*n;
			//output
			for(i=11;i>=0;i--){if(sisu&(1LL<<i)){cout<<'1';}else{cout<<'0';}}
			for(i=51;i>=0;i--){if(kasu&(1LL<<i)){cout<<'1';}else{cout<<'0';}}
			cout<<endl;
			return 1;
		}else{
			n-=kai;
			kasu+=kwa*kai;
			kasu/=2;kwa/=2;sisu++;
		}
		
	}
	return 1;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    char dummy;
    int flag[50][3]{0};
    cin>>n>>m;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            cin>>dummy;
            switch(dummy){
                    case 'W':
                    ++flag[i][0];
                    break;
                    case 'B':
                    ++flag[i][1];
                    break;
                    case 'R':
                    ++flag[i][2];
            }
        }
    }
    int answer=n*m;
    int W,B,R;
    W=0;
    for(int i=0;i<n-2;++i){
        B=0;
        W+=flag[i][1]+flag[i][2];
        for(int j=i+1;j<n-1;++j){
            B+=flag[j][0]+flag[j][2];
            R=0;
            for(int k=j+1;k<n;++k){
                R+=flag[k][0]+flag[k][1];
            }
            answer=min(answer,W+B+R);
        }
    }
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>

int main(){
	long long int sum=0;
	double ave=0.0;
	int v,a;
	int sa=0;
	while(~scanf("%d,%d",&v,&a)){
		sum += v*a;
		ave += a;
		sa++;
	}
	ave = ave/sa;
	printf("%d\n",sum);
	printf("%.0f\n",ave+0.5);
	return 0;
}

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

struct Card{
	char suit;
	int value;
}; 

void bubble(struct Card c[],int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(c[j].value<c[j-1].value){
				Card t=c[j];
				c[j] = c[j-1];
				c[j-1] = t;
			}
		}
	}
}

void selection(struct Card c[],int n){
	int minj=0;
		for(int i=0;i<n;i++){
			minj=i;
			for(int j=i;j<n;j++){
				if(c[j].value<c[minj].value){
					minj=j;
				}
			}
				Card t = c[i];
					c[i]= c[minj];
					c[minj] = t;
		}
}

bool isStabel(struct Card in[],struct Card out[],int n){
	for(int i=0;i<n;i++){
		if(in[i].suit!=out[i].suit)
		return false;
	}
	return true;
}

void print(struct Card a[],int n){
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<a[i].suit<<a[i].value; 
	}
	cout<<endl;
}

int main(){
	Card c1[100],c[100];
	int n;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c1[i].suit>>c1[i].value;
	}
	for(int i=0;i<n;i++){
		c[i]=c1[i];
	}
	
	bubble(c1,n);
	selection(c,n);
	
	print(c1,n);
	cout<<"Stable"<<endl;
	
	print(c,n);
	if(isStabel(c1,c,n))
	cout<<"Stable"<<endl;
	else 
	cout<<"Not stable"<<endl;
	
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=2e5+51;
struct Node{
	ll x,y;
	inline bool operator <(const Node &rhs)const
	{
		return this->x<rhs.x;
	}
};
struct Segment{
	ll l,r,id;
};
struct Edge{
	ll to,prev,id;
};
Node nd[MAXN];
Segment seg[MAXN];
Edge ed[MAXN<<1];
ll n,m,tot,cnt,l,r,lx,rx,flg,rr;
ll last[MAXN],res[MAXN],w[MAXN],c[MAXN],diff[MAXN],vis[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline void addEdge(ll from,ll to,ll id)
{
	ed[++tot].prev=last[from];
	ed[tot].to=to;
	ed[tot].id=id;
	last[from]=tot;
}
inline ll discrete(ll x)
{
	ll l=1,r=n+1,res=0,mid;
	while(l<=r)
	{
		mid=(l+r)>>1;
		w[mid]>=x?res=mid,r=mid-1:l=mid+1;
	}
	return res;
}
inline ll discrete2(ll x)
{
	ll l=1,r=n,res=0,mid;
	while(l<=r)
	{
		mid=(l+r)>>1;
		w[mid]<=x?res=mid,l=mid+1:r=mid-1;
	}
	return res;
}
inline ll dfs(ll node,ll fa,ll x)
{
	ll t=0;
	vis[node]=1;
	for(register int i=last[node];i;i=ed[i].prev)
	{
		if(!vis[ed[i].to])
		{
			t^=dfs(ed[i].to,node,i);
		}
	}
	if(node==fa)
	{
		return t;
	}
	if(diff[node]^t)
	{
		res[++rr]=ed[x].id;
		return 1;
	}
	return 0;
}
int main()
{
	n=read(),m=read();
	for(register int i=1;i<=n;i++)
	{
		nd[i].x=read(),nd[i].y=read();
	}
	sort(nd+1,nd+n+1);
	for(register int i=1;i<=n;i++)
	{
		c[i]=nd[i].y,w[i]=nd[i].x;
	}
	for(register int i=1;i<=m;i++)
	{
		l=discrete(lx=read()),r=discrete2(rx=read());
		if(rx<lx)
		{
			continue;
		}
		seg[++cnt]=(Segment){l,r,i};
	}
	for(register int i=1;i<=n;i++)
	{
		diff[i]=c[i]^c[i-1];
	}
	for(register int i=1;i<=cnt;i++)
	{
		addEdge(seg[i].l,seg[i].r+1,seg[i].id);
		addEdge(seg[i].r+1,seg[i].l,seg[i].id);
	}
	dfs(n+1,n+1,0);
	for(register int i=1;i<=n;i++)
	{
		if(vis[i])
		{
			continue;
		}
		if(dfs(i,i,0)!=diff[i])
		{
			return puts("-1"),0;
		}
	}
	printf("%d\n",rr),sort(res+1,res+rr+1);
	for(register int i=1;i<=rr;i++)
	{
		printf("%d ",res[i]);
	}
}

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

int min(vector<int>a,int m){
sort(a.begin(),a.end());
  return a.at(0);
}

int max(vector<int>a,int m){
sort(a.begin(),a.end());
  return a.at(m-1);
}
 
 
int main(){
  int n,m;
  cin >>n>>m;
  vector<int> L(m);
  vector<int> R(m);
  int ans=0;
  
  for(int i =0;i<m;i++){
  cin >> L.at(i) >> R.at(i);
  }
  
  int Lmax = max(L,m);
  int Rmin = min(R,m);
  
 if(Lmax > Rmin)
   cout <<0;
 else
   cout << Rmin - Lmax +1;
    
}

Measured memory_bytes: 1416
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
#include <functional>

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  vector<ll> sum(N, 0LL);
  sum[0] = A[0];
  for(int i=1; i<N; i++){
    sum[i] += sum[i-1] + A[i];
  }
  vector<int> L(N, 0);
  vector<int> R(N, 0);
  int mid = 0;
  for(int i=0; i<N; i++){
    while(sum[mid] < sum[i] - sum[mid] && mid < i)
      mid++;
    int best;
    if(mid == 0)
      best = mid;
    else
      if(abs(sum[mid] - (sum[i] - sum[mid])) < abs(sum[mid-1] - (sum[i] - sum[mid-1])))
	best = mid;
      else
	best = mid-1;
    L[i] = best;
  }
  mid = 0;
  for(int i=0; i<N; i++){
    while(sum[mid] - sum[i] < sum[N-1] - sum[mid] && mid < N-1)
      mid++;
    int best;
    if(mid == 0)
      best = mid;
    else
      if(abs((sum[mid] - sum[i]) - (sum[N-1] - sum[mid])) < abs((sum[mid-1] - sum[i]) - (sum[N-1] - sum[mid-1])))
	best = mid;
      else
	best = mid-1;
    R[i] = best;
  }
  ll ans = 1e+15;
  for(int i=1; i<N-2; i++){
    vector<ll> num(4);
    num[0] = sum[L[i]];
    num[1] = sum[i] - sum[L[i]];
    num[2] = sum[R[i]] - sum[i];
    num[3] = sum[N-1] - sum[R[i]];
    ll max_num = *max_element(num.begin(), num.end());
    ll min_num = *min_element(num.begin(), num.end());
    if(max_num - min_num < ans){
      ans = max_num - min_num;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

MAX = 10 ** 6

a = A.sort

non_unique = Set.new

a.each_cons(2) do |x, y|
  if x == y
    non_unique.add(x)
  end
end

set = Set.new

ans = 0

a.each do |x|
  unless set.include?(x)
    ans += 1 unless non_unique.include?(x)
    test = x
    while test <= MAX
      set.add(test)
      test += x
    end
  end
end

puts ans


Measured memory_bytes: 70176
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
#define EPS 1e-15
using namespace std;
vvi E(1100);
vector<string>vs;
void dfs(ll now,ll dep){
  if(now != 0){
    for(int i = 0;i<dep-1;i++){
      cout<<".";
    }
    cout<<vs[now]<<endl;
  }
  for(auto e:E[now]){
    dfs(e,dep+1);
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vs.pb("");
  for(int i=1;i<=n;i++){
    ll k;cin>>k;
    string s;cin>>s;
    vs.pb(s);
    E[k].pb(i);
  }
  dfs(0,0);
  return 0;
}



Measured memory_bytes: 3420
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2e5+10;
int n,head[N],cnt,fa[N];
int siz[N],mx[N],rt,sum,vis[N],cc,top;
ll Ans,w[N];
struct Ed{int fr,to;ll w;}E[N*30];
struct edge{int next,to,w;}a[N<<1];
void link(int x,int y,int w) {a[++cnt]=(edge){head[x],y,w};head[x]=cnt;}
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int cmp1(const Ed&A,const Ed&B) {return A.w<B.w;}
void Getsum(int x,int fr)
{
	for(int i=head[x];i;i=a[i].next)
		if(a[i].to!=fr&&!vis[a[i].to])
			Getsum(a[i].to,x);sum++;
}
void Getrt(int x,int fr)
{
	siz[x]=1;mx[x]=0;
	for(int i=head[x];i;i=a[i].next)
	{
		int R=a[i].to;
		if(R==fr||vis[R]) continue;
		Getrt(R,x);
		siz[x]+=siz[R];
		mx[x]=max(mx[x],siz[R]);
	}
	mx[x]=max(mx[x],sum-siz[x]);
	if(mx[rt]>mx[x]) rt=x;
}
int P;ll VAL;
void DFS(int x,int fr,ll dep)
{
	if(dep+w[x]<VAL) VAL=dep+w[x],P=x;
	for(int i=head[x];i;i=a[i].next)
		if(!vis[a[i].to]&&a[i].to!=fr)
			DFS(a[i].to,x,dep+a[i].w);
}
void Link(int x,int fr,ll dep)
{
	E[++cc]=(Ed){x,P,VAL+dep+w[x]};
	for(int i=head[x];i;i=a[i].next)
		if(!vis[a[i].to]&&a[i].to!=fr)
			Link(a[i].to,x,dep+a[i].w);
}
void Solve(int x)
{
	rt=sum=0;Getsum(x,0);Getrt(x,0);
//	printf("solve %d\n",rt);
	vis[x=rt]=1;VAL=1e18;DFS(x,0,0);Link(x,0,0);
	for(int i=head[x];i;i=a[i].next)
		if(!vis[a[i].to]) Solve(a[i].to);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%lld",&w[i]);
	for(int i=1,x,y,w;i<n;i++)
		scanf("%d%d%d",&x,&y,&w),link(x,y,w),link(y,x,w);
	mx[0]=1e9;Solve(1);
	sort(E+1,E+cc+1,cmp1);
	for(int i=1;i<=cc;i++)
	{
		if(E[i].fr>E[i].to) swap(E[i].fr,E[i].to);
//		printf("%d %d w=%lld\n",E[i].fr,E[i].to,E[i].w);
	}
	for(int i=1;i<=n;i++) fa[i]=i;
//	cout<<"cc="<<cc<<endl;
	for(int i=1;i<=cc;i++)
	{
		int x=find(E[i].fr),y=find(E[i].to);
		if(x!=y) fa[x]=y,Ans+=E[i].w;
	}
	cout<<Ans<<endl;
}


Measured memory_bytes: 72576
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;


int main(){
    int n;
    cin >> n;
    string str;
    pair<pair<string, int>, int> p[n];
    REP(i, n){
        int t;
        cin >> str >> t;
        p[i] = make_pair(make_pair(str, -t), i);
    }
    sort(p, p + n);
    REP(i, n) cout << p[i].second + 1 << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r, g;
  cin >> r >> g;
  cout << 2*g-r << endl;
	return 0;
}


Measured memory_bytes: 256
//please refer from line no. 207
/////*31022618*/////
//_MONU KUMAR
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tc ll t=1; cin>>t; while(t--)
#define ll long long int
#define ld long double
#define ull unsigned long long
#define p1(x) cout <<x<<"\n";
#define p2(x,y) cout <<x<<" "<<y<<"\n";
#define p3(x,y,z) cout <<x<<" "<<y<<" "<<z<<"\n";
#define p4(x,y,z,w) cout <<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
#define trace(x) cout<<#x<<": "<<x<<" "<<"\n";
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n";
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n";
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<"\n";
#define nL cout<<"\n";
#define lp(i,l,r) for (long long int i = l; i < r; i++)
#define lpr(i,r,l) for (long long int i = r-1; i >=l ; i--)
#define mem(a,x) memset(a,x,sizeof(a))              //set elements of array to some value
#define pi 3.1415926535897932384626
#define mod 1000000007
#define big 1e18
#define small -big
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define ff first
#define ss second
#define siz 256
#define leadzero(a) __builtin_clz(a)        // count leading zeroes
#define trailzero(a) __builtin_ctz(a)       // count trailing zeroes
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define all(v) v.begin(),v.end()
#define lps(v,x) (lower_bound(all(v),x)-v.begin())
#define ups(v,x) (upper_bound(all(v),x)-v.begin())
#define ina(a,n) ll a[n]; lp(i,0,n) cin>>a[i];
#define ona(a,n) lp(i,0,n) cout<<a[i]<<" ";

ll dp[110][110000], we[110], v[110];

int main() {
    fast
    ll n, w;
    cin >> n >> w;
    lp(i,1,n+1) {
        cin >> we[i] >> v[i];
    }

    lp(i,1,110000) {
        dp[0][i] = big;
    }

    lp(i,1,n+1)
     {
        lp(j,1,110000)
        {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i] >= 0)
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + we[i]);
            }
        }
    }
    ll ans = 0;
    lp(i,0,110000) {
        if (dp[n][i] <= w) {
            ans = max(ans, i);
        }
    }
    p1(ans)



  //clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
  return 0;
}
//////////*********************end of program*********************//////////


Measured memory_bytes: 88448
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;



int dp[20050];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int a,b,c; cin >> a >> b >> c;
        if(a == b && b != c) cout << "Yes" << endl;
        else if(a == c && b != c) cout << "Yes" << endl;
        else if(b == c && a != b) cout << "Yes" << endl;
  		else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int gcd(int a, int b) {
    if (a % b == 0) return b;
    else return gcd(b, a%b);
}

int main() {
    int a, b;
    while (cin >> a >> b) {
        if (a < b) {
            int t; t = a; a = b; b = t;
        }
        cout << gcd(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;
#define rep(i,n) for(long i=0; i<n; i++)


void solve(){
  int n;
  cin >> n;
  int d[n+10];
  rep(i,n) {cin >> d[i];}
  
  sort(d,d+n);
  int mid = n/2;
  cout << d[mid] - d[mid-1] << endl;
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int K;
    int A, B;
    cin >> K >> A >> B;
    bool check = false;
    for (int i = A; i <= B; i++) {
        if (i%K == 0) {
            check = true; break;
        }
    }
if(check) cout << "OK" << endl;
else cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL a;
    LL b;
    LL ab;
    cin >> a >> b;
    LL idx=1;
    LL tmp=b;
    while(tmp>0){
        idx*=10;
        tmp/=10;
    }
    ab=a*idx+b;
    bool is_ok=false;
    for(LL i=1; i*i<=ab; i++){
        if(i*i==ab){
            is_ok=true;
        }
    }

    if(is_ok==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<(n+1)/2;
	return 0;
}


Measured memory_bytes: 256
#!python3

# input
N = int(input())
S = [input() for _ in range(N)]


def main():
    l = ["AC", "WA", "TLE", "RE"]
    d = {x: 0 for x in l}
    for s in S:
        d[s] += 1
    for x in l:
        ans = "{} x {}".format(x, d[x])
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16216
#include<cstdio>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;

const long long mod = 1000000007;

typedef pair<int, int> P;

map<P, long long> mp;

int a[110];
int N;

int vals[110];

long long mul(long long a, long long b){
	return (a * b) % mod;
}

long long ex(long long a, long long e){
	if(e == 0) return 1;
	long long tmp = ex(a, e / 2);
	tmp = mul(tmp, tmp);
	if(e % 2 == 1) tmp = mul(tmp, a);
	return tmp;
}

long long dp[110];

long long solve(){
	for(int i = 1; i <= N; ++i){
		int ub = a[i];
		for(int j = i; j <= N; ++j){
			ub = min(ub, a[j]);
			int lb = max(a[i - 1], a[j + 1]);
			if(lb == 0) lb = 1;
			if(ub > lb){
				mp[P(i, j)] = ub - lb;
			}
		}
	}
	dp[0] = 1;
	for(int i = 1; i <= N; ++i){
		long long e = 0;
		for(int j = i - 1; j >= 0; --j){
			for(int k = j + 1; k <= i; ++k){
				e += mp[P(j + 1, k)];
			}
			dp[i] += mul(dp[j], ex(2, e));
			dp[i] %= mod;
		}
	}
	long long ans = mul(dp[N], 2);
	ans += mod;
	ans %= mod;
	return ans;
}

void input(){
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i){
		scanf("%d", a + i);
	}
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, h, w, n);
    VEC(int, a, n);
    int m[h][w];
    int num = 1, cnt = 1;
    REP(i, h){
        if(i%2){
            REP(j, w){
                m[i][j] = num;
                if(cnt < a[num-1]) {
                     cnt++;
                 } else {
                     num++;
                     cnt = 1;
                 }
            }
        }else{
            RREP(j, w){
                m[i][j] = num;
                if(cnt < a[num-1]) {
                     cnt++;
                 } else {
                     num++;
                     cnt = 1;
                 }
            }
        }
    }
    REP(i, h){
        REP(j, w){
            if(j) SP;
            OUT(m[i][j]);
        }
        BR;
    }
RET;}


Measured memory_bytes: 384
N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    tmp = ''.join(s)
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1

ans = 0

for v in dic.values():
    ans += v * (v-1) / 2

print(int(ans))


Measured memory_bytes: 98416
#include<stdio.h>
#include<string.h>
int main()
{
  int n;
  char S[100],T[100]="\0";
  scanf("%d",&n);
  scanf("%s",S);
  strncat(T,S,n);
  if(strlen(S)>n)
    strcat(T,"...");
  printf("%s\n",T);
  return 0;
}

Measured memory_bytes: 2084
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

void sim() {

	vector<int> a(8, 4);

	rep(i, 0, 4) {
		a[i] = 8;
	}
	sort(all(a));

	do {
		int cnt1 = 0, cnt2 = 0;
		{
			stack<int> st;
			for (auto x : a)st.push(x);
			while (st.size() > 1) {
				int x, y;
				x = st.top(); st.pop();
				y = st.top(); st.pop();
				int z = x + y;
				if (z >= 10) {
					st.push(z % 10);
					st.push(z / 10);
				}
				else {
					st.push(z);
				}
				cnt1++;
				dump(st);
			}
		}
		{
			stack<int> st;
			vector<int> b = a;
			reverse(all(b));
			for (auto x : b)st.push(x);
			while (st.size() > 1) {
				int x, y;
				x = st.top(); st.pop();
				y = st.top(); st.pop();
				int z = x + y;
				if (z >= 10) {
					st.push(z / 10);
					st.push(z % 10);
				}
				else {
					st.push(z);
				}
				cnt2++;
				dump(st);
			}
		}
		break;
		dump(a, cnt1, cnt2);
		if (cnt1 != cnt2) {
			dump(a, cnt1, cnt2);
		}
	} while (next_permutation(all(a)));

}

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

	int M; cin >> M;
	vector<int> d(M), c(M); rep(i, 0, M) {
		cin >> d[i] >> c[i];
		c[i]--;
	}

	vector<int> a(M);
	int cnt = 0;
	rep(i, 0, M) {

		int add = 0;
		int t = 0;
		int x = d[i];
		vector<int> A, X;
		A.push_back(0);
		X.push_back(d[i]);
		do {
			t++;
			add++;
			x += d[i];
			if (x >= 10) {
				add++;
				x = (x / 10) + (x % 10);
			}
			A.push_back(add);
			X.push_back(x);
			dump(t, add, x);
		} while (x != d[i]);
		dump(A);

		cnt += (c[i] / t) * A.back();
		cnt += A[c[i] % t];
		a[i] = X[c[i] % t];
		dump(i, cnt);
	}

	stack<int> st;
	for (auto x : a)st.push(x);
	while (st.size() > 1) {
		int x, y;
		x = st.top(); st.pop();
		y = st.top(); st.pop();
		int z = x + y;
		if (z >= 10) {
			st.push(z % 10);
			st.push(z / 10);
		}
		else {
			st.push(z);
		}
		cnt++;
		dump(st);
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 6656
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>
#include <limits.h>

using namespace std;

// Used to track farthest node. 
int x;

// Sets maxCount as maximum distance from node. 
void dfsUtil(int node, int count, bool visited[],
	int& maxCount, list<int>* adj)
{
	visited[node] = true;
	count++;
	for (auto i = adj[node].begin(); i != adj[node].end(); ++i) {
		if (!visited[*i]) {
			if (count >= maxCount) {
				maxCount = count;
				x = *i;
			}
			dfsUtil(*i, count, visited, maxCount, adj);
		}
	}
}

// The function to do DFS traversal. It uses recursive 
// dfsUtil() 
void dfs(int node, int n, list<int>* adj, int& maxCount)
{
	bool visited[n + 1];
	int count = 0;

	// Mark all the vertices as not visited 
	for (int i = 1; i <= n; ++i)
		visited[i] = false;

	// Increment count by 1 for visited node 
	dfsUtil(node, count + 1, visited, maxCount, adj);
}

// Returns diameter of binary tree represented 
// as adjacency list. 
int diameter(list<int>* adj, int n)
{
	int maxCount = INT_MIN;

	/* DFS from a random node and then see
	farthest node X from it*/
	dfs(1, n, adj, maxCount);

	/* DFS from X and check the farthest node
	from it */
	dfs(x, n, adj, maxCount);

	return maxCount;
}

int main() {
	int n, i, j, ans = 0,x,y,p,max,c[111];
	cin >> n;
  vector<pair<int, int>> a(n),b(n);
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		a[i] = make_pair(x, y);
	}
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		b[i] = make_pair(x, y);
		c[i] = 0;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (i = 0; i < n; i++) {
		max = -1;
		for (j = 0; a[j].first < b[i].first; j++) {
			if (a[j].second<b[i].second&&a[j].second>max&&c[j]==0) {
				p = j;
				max = a[j].second;
			}
		}
		if (max > -1) {
			ans++;
			c[p]++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256