akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	string inpt;
	while (cin >> inpt) {
		if (inpt.size() % 2 == 1) {
			cout << "NA" << endl;
		} else {
			string res;
			for (ll i = 0; i < inpt.length(); i += 2) {
				if (inpt[i] < '1' || inpt[i] > '6' || inpt[i + 1] < '1' || inpt[i + 1] > '5') {
					res = "NA";
					break;
				} else {
					int a = (int)(inpt[i] - '0');
					int b = (int)(inpt[i + 1] - '0');
					int idx = (a - 1) * 5 + (b - 1);
					res += idx < 26 ? 'a' + idx : ".?! "[idx - 26];
				}
			}
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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(int argc, const char * argv[]) {
    
  
    
    int N,M; cin >> N >> M;
    vector<vector<int>> s(M);
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> s[i][j];
            s[i][j]--;
            
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; i++) cin >> p[i];
    
    
    
    //culcurate
    int Ans = 0;
    //full search
    for (int bit = 0; bit < (1<<N); bit++) {
        bool isLightOn = true;
        for (int m = 0; m < M; m++) {
            
            
            int count = 0;
            
            
            
            for (int k = 0; k < (int)s[m].size(); k++) {
                if( bit & ( 1<<s[m][k] ) ) ++count;
            }
            if( count%2 != p[m] ) {
                isLightOn = false;
                break;
            }
        }
        if(isLightOn) Ans++;
    }
    
    cout << Ans << endl;
    
    
    
    
    
    
}


Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

min_mp = 10**10

for i in range(4**n):
    mp = 0
    li = [0]*4
    count_li = [0]*4
    s = Base_10_to_n(i,4).zfill(n)

    for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1

    if 0 in li[:-1]:
        continue

    mp += abs(a-li[0])
    mp += abs(b-li[1])
    mp += abs(c-li[2])

    for item in count_li[:3]:
        if item >= 2:
            mp += 10*(item-1)
            
    min_mp = min(min_mp,mp)

print(min_mp)

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

#define INF 10000000

int A(int m) {
	int n = m / 200;
	int ret = 0;

	if(m % 200)
		return INF;
	ret += (n / 5) * 5 * 380 * 80 / 100;
	ret += n % 5 * 380;
	
	return ret;
}
int B(int m) {
	int n = m / 300;
	int ret = 0;

	if(m % 300)
		return INF;
	ret += (n / 4) * 4 * 550 * 85 / 100;
	ret += n % 4 * 550;

	return ret;
}
int C(int m) {
	int n = m / 500;
	int ret = 0;

	if(m % 500)
		return INF;
	ret += (n / 3) * 3 * 850 * 88 / 100;
	ret += n % 3 * 850;

	return ret;
}

int main() {
	int m;
	int table[64];

	for(int i = 0; i < 64; i++) {
		table[i] = A(i * 100);
	}

	for(int i = 63; i >= 0; i--) {
		for(int j = 0; j <= i; j++) {
			table[i] = min(table[i], table[i - j] + B(j * 100));
		}
	}
	for(int i = 63; i >= 0; i--) {
		for(int j = 0; j <= i; j++) {
			table[i] = min(table[i], table[i - j] + C(j * 100));
		}
	}

	while(cin >> m, m) {
		cout << table[m / 100] << endl;
	}

	return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds; 
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 998244353

// typedef tree<pii,null_type,less<pii>,rb_tree_tag,
// tree_order_statistics_node_update>PBDS; 

vi prime;

void sieve(){
  vi p;
  p.resize(1001,1);
  prime.pb(2);

  for(int i=3;i<=1e3;i++)
    if(p[i]==1){
      prime.pb(i);
      for(int j=i+i;j<=1e3;j+=i)p[j]=0;
    }

  return;
}

ll res(ll num){
  if(num==1)return 1;

  // ll nn = sqrt(num);

  // ll ck=0;
  // if(nn*nn==num)ck=1;

  ll result = 1;

  for(auto x:prime)
    if(x*x>num)break;
    else if(num%x==0){
      ll cnt = 0;
      while(num%x==0){num=num/x;cnt++;}
      result *= (cnt+1) ;
    }

    if(num!=1)result*=2;

    
    return result;

  
}

int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif  
   
    sieve();
    ll t;
    t=1;
    // cin>>t;
    while(t--){
     ll n;
     cin>>n;

    ll cnt = 0;

     for(int i=1;i<n;i++){
       ll num = n-i;
       cnt += res(num);
     }

     // cout<<res(45);
     cout<<cnt;

     

  






    }
      
     
      

      

    

    
return 0;
}     



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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int N;
vector<vector<int>> item;

int main() {
    cin >> N;
    item = vector<vector<int>>(N, vector<int>(3));
    rep(i, N) cin >> item[i][0] >> item[i][1] >> item[i][2];

    // 状態 (i,prev) : i 日たって，前回 prev の遊びをした状態
    // ma(i,prev) : 状態(i,prev) での幸福度の最大値

    // もらうDP
    vector<vector<int>> ma(N + 1, vector<int>(3, -1));
    ma[0][0] = ma[0][1] = ma[0][2] = 0;

    for (int i = 1; i <= N; i++) {
        for (int prev = 0; prev < 3; prev++) {
            for (int k = 0; k < 3; k++) {
                if (prev == k) continue;
                ma[i][prev] =
                    max(ma[i][prev], ma[i - 1][k] + item[i - 1][prev]);
            }
        }
    }

    int ans = -1;
    for (int i = 0; i < 3; i++) {
        ans = max(ma[N][i], ans);
    }
    cout << ans << endl;

        return 0;
}

Measured memory_bytes: 14000
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<long long> x(n);
    vector<long long> y(n);
    vector<long long> z(n);
    vector<long long> sum1(n);
    vector<long long> sum2(n);
    vector<long long> sum3(n);
    vector<long long> sum4(n);
    vector<long long> sum5(n);
    vector<long long> sum6(n);
    vector<long long> sum7(n);
    vector<long long> sum8(n);
    vector<long long> a(8,0);
    for(int i=0; i<n; i++){
      cin >> x[i] >> y[i] >> z[i];
      sum1[i]=x[i]+y[i]+z[i];
      sum2[i]=x[i]-y[i]+z[i];
      sum3[i]=x[i]+y[i]-z[i];
      sum4[i]=x[i]-y[i]-z[i];
      sum5[i]=-x[i]+y[i]+z[i];
      sum6[i]=-x[i]-y[i]+z[i];
      sum7[i]=-x[i]+y[i]-z[i];
      sum8[i]=-x[i]-y[i]-z[i];
    }
    sort(sum1.begin(),sum1.end());
    sort(sum2.begin(),sum2.end());
    sort(sum3.begin(),sum3.end());
    sort(sum4.begin(),sum4.end());
    sort(sum5.begin(),sum5.end());
    sort(sum6.begin(),sum6.end());
    sort(sum7.begin(),sum7.end());
    sort(sum8.begin(),sum8.end());
    for(int i=0; i<m; i++){
        a[1]+=sum1[n-1-i];
        a[2]+=sum2[n-1-i];
        a[3]+=sum3[n-1-i];
        a[4]+=sum4[n-1-i];
        a[5]+=sum5[n-1-i];
        a[6]+=sum6[n-1-i];
        a[7]+=sum7[n-1-i];
        a[0]+=sum8[n-1-i];
    }
    sort(a.begin(),a.end());
    cout << a[7] << endl;

}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
void gcd(int a,int b){
    if(a<b) swap(a,b);
    while(b>0){
        int r=a%b;
        a=b;
        b=r;
    }
    cout<<a<<endl;;
}
int main(){
    // Your code here!
    int x,y;
    cin>>x>>y;
    gcd(x,y);
    
    
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

const int mod = 1e9+7;
#define ll long long int
const double epsilon = 1e-7;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
int main(void){
    int n;
    scanf("%d", &n);
    if(n == 3){
        printf("2 5 63\n");
        return 0;
    }
    printf("3 9 ");
    if(n % 3 != 0){
        int a;
        if(n%2==0)a = 15000;
        else a = 14999;
        for(int i = 0;i < n-2 && i < a;i++)printf("%d ", i * 2 + 2);
        for(int i = 0;i < n-2-a;i++)printf("%d ", i * 6 + 15);
    }else{
        int a;
        if(n%2==0 || n < 15002){
            a = 15000;
        for(int i = 0;i < n-2 && i < a;i++){
            if(i%3 == 0)printf("%d ", i * 2 + 6);
            if(i%3 == 1)printf("%d ",i * 2);
            if(i%3 == 2)printf("%d ",i * 2);
        }}else{
            a = 14999;
            for(int i = 0;i < n-2 && i < a;i++)printf("%d ", i * 2 + 2);
        }
        for(int i = 0;i < n-2-a;i++)printf("%d ", i*6+15);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int calc(vector<int> a, vector<int> b){
    int apos = 0, bpos = 0, ret = 0;
    while(apos < a.size()){
        while(a[apos] != 1) apos++;
        while(b[bpos] != 1) bpos++;
        ret += abs(bpos-apos);
        apos++;
        bpos++;
    }
    return ret;
}

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

    vector<int> b(n), p(m);
    for(int i = 0; i < n; i++)  cin >> b[i];
    for(int j = 0; j < m; j++)  cin >> p[j];

    vector<int> c;
    for(int j = 0; j < m; j++){
        int add = (j % 2 == 0);
        for(int k = 0; k < p[j]; k++)   c.push_back(add);
    }

    // sentinel
    b.push_back(1);
    c.push_back(1);

    int one = accumulate(b.begin(), b.end(), 0);

    int ans = 1<<21;
    if(accumulate(c.begin(), c.end(), 0) == one){
        ans = min(ans, calc(b, c));
    }

    for(int i = 0; i < n; i++)  c[i] = 1 - c[i];
    if(accumulate(c.begin(), c.end(), 0) == one){
        ans = min(ans, calc(b, c));
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {

    int t, n;
    int s, f;

    while(cin >> t, t) {

        cin >> n;

        int sum = 0;

        for(int i = 0; i < n; ++i) {
            cin >> s >> f;
            sum += f - s;
        }

        if(sum >= t) {
            cout << "OK" << endl;
        } else {
            cout << t - sum << endl;
        }

    }

}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define maxn 210000
using namespace std;
typedef long long ll;
vector<ll>q[2];
ll x[maxn],y[maxn];
ll bit[100];
int n;

ll solve()//???????????
{
    ll ans=0;
    for(ll i=0;i<62;i++)
    {
        ll tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(x[j]>>i)&1].push_back(x[j]);
        for(ll j=0;j<q[0].size();j++)
            x[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            x[++tot]=q[1][j];
        tot=0;
        q[0].clear();q[1].clear();
        for(ll j=1;j<=n;j++)
            q[(y[j]>>i)&1].push_back(y[j]);
        for(ll j=0;j<q[0].size();j++)
            y[++tot]=q[0][j];
        for(ll j=0;j<q[1].size();j++)
            y[++tot]=q[1][j];
        ll len1=1,len2=1,len3=1;
        ll limit1=1ll<<i;
        ll limit2=1ll<<(i+1);
        ll all=(1ll<<(i+1))-1;///???1LL
//        cout<<all<<" all"<<endl;
        ll sum=0;
//        for(int i=1;i<=tot;i++) cout<<x[i]<<" ";
//        cout<<endl;
//        for(int i=1;i<=tot;i++) cout<<(x[i]&all)<<" ";
//        cout<<endl;
//        for(int i=1;i<=tot;i++) cout<<y[i]<<" ";
//        cout<<endl;
        for(ll i=n;i>=1;i--)
        {
            while((((x[i]&all)+(y[len1]&all))<limit1) && (len1<=n)) len1++;//??????()
            while((((x[i]&all)+(y[len2]&all))<limit2) && (len2<=n)) len2++;
            while(((x[i]&all)+(y[len3]&all)<limit1+limit2) && (len3<=n)) len3++;//cout<<(x[i]&all)<<" "<<(y[len3]&all)<<" "<<len3<<" "<<y[len3]<<" "<<(limit1+limit2)<<endl;
            sum+=n-(len1-1-len2+1+len3-1);
//            cout<<len1<<" "<<len2<<" "<<len3<<endl;
//            cout<<n-(len1-1-len2+1+len3-1)<<endl;
        }
//        cout<<sum<<" sum   "<<i<<endl;
        if(sum&1) ans+=bit[i];
    }
    return ans;
}

int main()
{
    bit[0]=1;
    for(ll i=1;i<=61;i++)
    bit[i]=bit[i-1]*2;
        scanf("%lld",&n);
        for(ll i=1;i<=n;i++)
            scanf("%lld",&x[i]);
        for(ll i=1;i<=n;i++)
            scanf("%lld",&y[i]);
//        cout<<solve()<<endl;
       printf("%lld\n",solve()) ;

}


Measured memory_bytes: 6508
#include "bits/stdc++.h"
using namespace std;

int main(){
  string n;
  cin>>n;
  if(n[0]==n[1]&&n[1]==n[2]||n[3]==n[1]&&n[1]==n[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);
  vector<int> C(N);
  for (int i = 0; i < N; i++) cin >> C.at(i);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int tmp = V.at(i) - C.at(i);
    if (tmp > 0) ans += tmp;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
from collections import defaultdict
n, m = map(lambda x: int(x), input().split())

links = defaultdict(set)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    links[a].add(b)
    links[b].add(a)
    
path_counter = 0
    
def path_patterns_number(current_node, remaining_nodes):#, remaining_links):
    if len(remaining_nodes) == 0:
        return 1
    
    patterns = 0
    
    for next_node in (links[current_node] & remaining_nodes):
#         remaining_links_copy = remaining_links.copy()
#         remaining_links_copy[current_node].remove(next_node) <=浅いコピーなので元のからもremoveされてる
        patterns += path_patterns_number(
            next_node,
            remaining_nodes.copy() - {next_node}
#             remaining_links_copy
        )
    
    return patterns
    
print(path_patterns_number(1, set(range(2,n+1))))

Measured memory_bytes: 9400
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	LL n;
	cin>>n;
	deque<LL>que;
	
	for(int i=0;i<n;i++){
		LL x;
		cin>>x;
		if((n-i)%2==0) que.push_back(x);
		else que.push_front(x); 
	}	
	
	for(int i=0;i<n;i++){
		cout<<que.front()<<" ";
		que.pop_front();
	}
	
    return 0;
}


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

int main(void)
{
    int n;
    int in[6];
    int i;
    int keta;
    int flag;
    
    flag = 0;
    while (scanf("%d", &n) != EOF){
        for (i = 0; i < 5; i++){
            in[i] = n % 10;
            n /= 10;
        }

        if (flag == 1){
            printf("\n");
        }
        flag = 1;

        for (keta = 0; keta < 8; keta++){
            for (i = 4; i >= 0; i--){
                switch (keta){
                  case 0:
                    if (in[i] <= 4){
                        printf("*");
                    }
                    else {
                        printf(" ");
                    }
                    break;

                  case 1:
                    if (in[i] <= 4){
                        printf(" ");
                    }
                    else {
                        printf("*");
                    }
                    break;

                  case 2:
                    printf("=");
                    break;

                  default:
                    if (keta - 3 == in[i] % 5){
                        printf(" ");
                    }
                    else {
                        printf("*");
                    }
                    break;
                }
            }
            printf("\n");
        }
    }
    return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(s==u){a--;}
    else{b--;}
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#D
n = int(input())

def c2(x):
    return(((x)*(x-1))//2)

line = [int(x) for x in input().split()]

index = {}

for i in range(0,  len(line)):
    if line[i] in index.keys():
        index[line[i]] = index[line[i]] + 1
    else:
        index[line[i]] = 1

total = 0

for key in index:
    total = total + c2(index[key])

for u in range(0, len(line)):
    print(total-(index[line[u]]-1))


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

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2696
#include <iostream>
#include <vector>
using namespace std;
int main(void){

    int N, ans = 0;
    cin >> N;
    vector<int> d(N);
    
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            if(i != N-1){
                //cout << d[i] << " * " << d[j] << " = " << d[i] * d[j] << endl;
                ans += d[i] * d[j];
            }
            else{
                //cout << d[0] << " * " << d[N-1] << " = " << d[0] * d[N-1] << endl;
                ans += d[0] * d[N-1];
            }
        }
            
    }
    
    cout << ans << endl;
}

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



int main(){
  int64_t N,M;
  cin>>N>>M;
  if(N==1&&M==1) cout<<1<<endl;
  else if(N==1||M==1){
    cout<<N*M-2<<endl;
  }
  else{
    cout<<(N-2)*(M-2)<<endl;
  }
  
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
multiset<int> S;
int P[101010];
vector<pair<int,int>> V;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	S.insert(0);
	S.insert(0);
	S.insert(N+1);
	S.insert(N+1);
	
	FOR(i,N) {
		cin>>P[i+1];
		V.push_back({P[i+1],i+1});
	}
	sort(ALL(V));
	reverse(ALL(V));
	ll ret=0;
	FORR(v,V) {
		ll num=v.first;
		int id=v.second;
		auto it=S.lower_bound(id);
		int R1=*it;
		it++;
		int R2=*it;
		it--;
		it--;
		int L1=*it;
		it--;
		int L2=*it;
		if(R2>R1) ret+=num*(R2-R1)*(id-L1);
		if(L2<L1) ret+=num*(L1-L2)*(R1-id);
		S.insert(id);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6132
loop do
  n, m = gets.split.map(&:to_i)
  break if n.zero? and m.zero?
  xs = Array.new n
  c = 0
  i = 0
  while c < n
    j = 0
    while j < m
      i = (i + 1) % n
      i = (i + 1) % n while xs[i]
      j += 1
    end
    xs[i] = c
    c += 1
  end
  x = xs.find_index n - 1
  p x.zero? ? n : x
end

Measured memory_bytes: 8596
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

ll d[100][100];

int main()
{
    int n;
    cin >> n;
    ll a[200005]{0};
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int k = s.size();
        int c = 0;
        bool f = false;
        for(int j = 0; j < k; j++){
            if(s[j] == '.'){
                f = true;
            }
            else{
                a[i] = a[i] * 10 + (s[j] - '0');
                if(f) c++;
            }
        }
        for(int j = c; j < 9; j++) a[i] *= 10;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int t = 0, f = 0;
        while(a[i] % 2 == 0){
            a[i] /= 2;
            t++;
        }
        while(a[i] % 5 == 0){
            a[i] /= 5;
            f++;
        }
        for(int i = 0; i <= 60; i++){
            for(int j = 0; j <= 40; j++){
                if(i + t >= 18 && j + f >= 18) ans += d[i][j];
            }
        }
        d[t][f]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5168
a, b, c, d = map(int, input().split())
cc = c
dd = d
if cc < dd:
    cc, dd = dd, cc
while cc % dd != 0:
    cc, dd = dd, cc % dd
gcd = dd

sum = 0
mi = (a-1)//c
ma = b//c
sum += ma - mi

mi = (a-1)//d
ma = b//d
sum += ma - mi

cd = c * d // gcd
mi = (a-1)//cd
ma = b//cd
sum -= ma - mi
print(b-a-sum+1)

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

string ls[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
	string S;
	cin >> S;
	for(int i = 0; i < 7; i++){
		if(ls[i] == S){
			cout << 7 - i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int x[N], y[N], h[N];
  for (int i = 0; i < N; i++)
    cin >> x[i] >> y[i] >> h[i];
  for (int cx = 0; cx <= 100; cx++)
  {
    for (int cy = 0; cy <= 100; cy++)
    {
      long ch = 0;
      for (int i = 0; i < N; i++)
      {
        if (0 < h[i])
        {
          ch = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
          break;
        }
      }
      bool ok = true;
      for (int i = 0; i < N; i++)
      {
        if (h[i] != max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0L))
          ok = false;
      }
      if (ok)
      {
        cout << cx << " " << cy << " " << ch << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a, b = map(int, readline().split())
p = list(map(int, readline().split()))
memo = [0, 0, 0]
for check in p:
    if check <= a:
        memo[0] += 1
    elif a < check <= b:
        memo[1] += 1
    else:
        memo[2] += 1
print(min(memo))


Measured memory_bytes: 3064
n = int(input())
A = list(map(int,input().split()))
MOD=10**9+7

s=0
S=[]
for a in A:
    s += a
    s %= MOD 
    S.append(s)    

ans=0
for i in range(n-1):
    ans += S[i]*A[i+1]
    ans %= MOD
print(ans)


Measured memory_bytes: 31540
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;
const int inf = 1e9;

vector<int> merge(vector<int> a, vector<int> &b){
    for(int i=0; i<(int)a.size(); i++){
        a[i] += b[i];
    }
    return a;
}

int main(){
    int h,w,ub;
    cin >> h >> w >> ub;
    vector<vector<int>> a(h, vector<int>(w, 0));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            a[i][j] = c-'0';
        }
    }

    int ans = inf;
    for(int i=0; i<(1<<(h-1)); i++){
        int sub = 0;
        vector<vector<int>> b(1, a[0]);
        for(int j=0; j<h-1; j++){
            if(i>>j&1){
                b.emplace_back(w, 0);
                sub++;
            }
            b.back() = merge(b.back(), a[j+1]);
        }

        vector<int> cnt(b.size(), 0);
        for(int j=0; j<w; j++){
            bool nocut = true;
            for(int k=0; k<(int)b.size(); k++){
                if(cnt[k] +b[k][j] > ub){
                    nocut = false;
                    break;
                }
            }
            if(!nocut){
                sub++;
                cnt = vector<int>(b.size(), 0);
            }
            bool impossible = false;
            for(int k=0; k<(int)b.size(); k++){
                cnt[k] += b[k][j];
                if(cnt[k] > ub){
                    impossible = true;
                    break;
                }
            }
            if(impossible){
                sub = inf;
                break;
            }
        }
        ans = min(ans, sub);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int N;

    cin >> N;

    vector<int> N_cnt(101);
    vector<int> prime;

    bool can_prime;

    for(int i = 2; i <= N; i++){
        can_prime = true;
        for(int j = 2; j < i; j++){
            if(gcd(j, i) != 1){
                can_prime = false;
            }
        }
        if(can_prime){
            prime.push_back(i);
        }
    }

    int tmp;
    for(int i = 2; i <= N; i++){
        tmp = i;
        while(tmp > 1){
            for(int j = 0; j < prime.size(); j++){
                if(tmp % prime[j] == 0){
                    N_cnt[prime[j]]++;
                    tmp /= prime[j];
                }
            }
        }
    }

    vector<int> cnt_241424(5);
    for(int i = 0; i < N_cnt.size(); i++){
        if(N_cnt[i] >= 74){
            cnt_241424[4]++;
            cnt_241424[3]++;
            cnt_241424[2]++;
            cnt_241424[1]++;
            cnt_241424[0]++;
        }else if(N_cnt[i] >= 24){
            cnt_241424[3]++;
            cnt_241424[2]++;
            cnt_241424[1]++;
            cnt_241424[0]++;
        }else if(N_cnt[i] >= 14){
            cnt_241424[2]++;
            cnt_241424[1]++;
            cnt_241424[0]++;
        }else if(N_cnt[i] >= 4){
            cnt_241424[1]++;
            cnt_241424[0]++;
        }else if(N_cnt[i] >= 2){
            cnt_241424[0]++;
        }
    }

    int ans = 0;
    // a^74の形式
    ans += cnt_241424[4];
    // a^2 b^24の形式
    ans += cnt_241424[3] * (cnt_241424[0]-1);
    // a^4 b^14の形式
    ans += cnt_241424[2] * (cnt_241424[1]-1);
    // a^2 b^4 c^4の形式
    ans += ((cnt_241424[1] * (cnt_241424[1]-1)) / 2) * (cnt_241424[0]-2);

    cout << ans << endl;



    system("pause");

    return 0;
}


Measured memory_bytes: 504
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
// 210 5
// 31 41 59 26 53
var input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
var line1 = input[0];
var line2 = input[1];
var h = parseInt(line1.split(' ')[0], 10);
var n = parseInt(line1.split(' ')[1], 10);
var tech = line2.split(' ').map(function (n) { return parseInt(n, 10); });
for (var i = 0; i < tech.length; i++) {
    h -= tech[i];
}
if (h <= 0) {
    console.log('Yes');
}
else {
    console.log('No');
}


Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
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 (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    vector<pll> A(N);
    rep(i,N){
        A[i].S = i+1;
        cin >> A[i].F;
    }
    sort(all(A));
    rep(i,N)cout << A[i].S << " ";
}



Measured memory_bytes: 2432
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	int n;
	cin >> n;
	vint w(n);
	vcin(w, n);
	int x = 0, y = 0, q = nine;

	rop(i, n - 1) {
		rep(j, n) {
			if (j + 1 <= i) {
				x += w[j];
			}
			else {
				y += w[j];
			}
		}
		q = min(q, abs(x - y));
		x = 0, y = 0;
	}
	cout << q << rt;

	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline void solve() {
    string s, t;
    cin >> s >> t;
    int ans = inf;
    for (int i = 0; i <= (int)(s.length() - t.length()); i++) {
        int temp = 0;
        for (int j = 0; j < (int)t.length(); j++) {
            if (s[i + j] != t[j]) {
                temp++;
            }
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

vector<string> Split(char c,string s){
  vector<string> res(0);
  string str = "";
  rep(i,s.size()){
    if(s[i] == c){
      res.push_back(str);
      str.clear();
    }
    else{
      str += s[i];
    }
  }
  res.push_back(str);
  return res;
}
template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin >> n >> m && n && m){
    vector<ll> v(101);
    ll k,tmp;
    rep(i,n){
      cin >> k;
      rep(j,k){
        cin >> tmp;
        v[tmp]++;
      }
    }
    ll ans = 0,cnt = m-1;
    rep(i,101){
      if(v[i] >= cnt){
        if(v[i] > cnt)
          ans = i;
        cnt = v[i];
      }
    }
    if(ans) cout << ans << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3236
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
using namespace std;
int main()
{
    rj
    long double a,b=3.141592654;
    cin>>a;
    cout<<2LL*a*b<<endl;


    return 0;
}


Measured memory_bytes: 3804
loop do
	input=gets.split(" ")
	n=input[0].to_i
	s=input[1].to_i
	i=0

	if n == 0
		break
	end
	number=(0..9).to_a

	combi=number.combination(n).to_a


	for x in 0..combi.size-1
		if combi[x].inject(0){|result,item| result + item} == s
			i += 1
		end
	end

	puts i
end

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

#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 500 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f, BSZ = 320;
int N, K;
int a[MN];

bool f(ll x) {
    vector<ll> rem;
    for (int i = 1; i <= N; i++) {
        int r = a[i] % x;
        if (r != 0) rem.push_back(r);
    }
    if (rem.empty()) return true;
    sort(all(rem));
    ll cnt = 0;
    int l = 0, r = rem.size() - 1;
    while (l < r) {
        ll add = min(rem[l], x - rem[r]);
        rem[l] -= add;
        rem[r] += add;
        cnt += add;
        if (rem[l] == 0) l++;
        else r--;
    }
    if (rem[l] % x) return false;
    return cnt <= K;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> K;
    ll sum = 0, mx = 0;
    for (int i = 1; i <= N; i++) cin >> a[i], sum += a[i];
    for (ll i = 1; i <= sqrt(sum); i++) {
        if (sum % i == 0) {
            if (f(sum / i)) mx = max(mx, sum / i);
            if (f(i)) mx = max(mx, i);
        }
    }
    cout << mx << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i=0;i<s.length()-8;i++){
			System.out.print(s.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 21844
//programimg contest template
//Abu Bakar

#include <bits/stdc++.h>

//typedef pair<int, int> ii;
//typedef vector<ii> vii;
//typedef vector<int> vi;
typedef  long long ll;
typedef unsigned long long ull;

#define MAX 100000
#define inf (1061109567)
#define pb(x) push_back(x)
#define pp(x) pop_back(x)
#define stream istringstream
#define mem(x,y) memset(x,y,sizeof(x));
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define repv(i,n) for(int i=n-1; i>=0; i--)
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define mp make_pair
#define ff first
#define ss second



using namespace std;

int main()
{
    int a,b,k;
    cin >> a >> b >> k;

    set <int > s;

    int c =0;
    for(int i = a ; i <= a+k && i >= a && i <= b && c < k;i++,c++)
      s.insert(i);

    for(int i = b-k+1 ; i <= b && i >= a && i <= b ;i++)
      s.insert(i);

    for (std::set<int>::iterator it=s.begin(); it!=s.end(); ++it)
    std::cout << *it << endl;


	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    cout << vec[n-1]-vec[0] << endl;
}


Measured memory_bytes: 256
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, Mod = 998244353;
int n, k, D[N], C[N];
inline int Power(int a, int b)
{
    int ret = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mod)
        if (b & 1) ret = 1LL * ret * a % Mod;
    return (ret);
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++)
        scanf("%d", &D[i]), C[D[i]] ++;
    if (D[1] != 0 || C[0] != 1)
        return !printf("0\n");
    int tot = 1;
    int MX = * max_element(D + 1, D + n + 1);
    for (int i = 1; i <= MX; i ++)
        tot = 1LL * tot * Power(C[i - 1], C[i]) % Mod;
    printf("%d\n", tot);
    return 0;
}

Measured memory_bytes: 4736
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int n; cin >> n;
    vector<ll> A(n), C(200010);
    rep(i, n){
        cin >> A[i];
        C[A[i]]++;
    }
    ll sum = 0;
    rep(i, 200001){
        ll tmp = C[i];
        sum += tmp * (tmp-1) / 2;
    }
    //クエリ
    rep(i, n){
        ll tmp = C[A[i]];
        ll res = sum - tmp * (tmp-1) / 2 + (tmp-1)*(tmp-2) / 2;
        cout << res << ln;
    }
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+4; 
const int MOD = 1e9+7;
vector<int> adj[N];
int dp[N][2];

int ways(int s, int col, int par)
{
	if(dp[s][col] != -1)
		return dp[s][col];


	dp[s][col] = 1;
	for(auto v: adj[s])
	{
		if(v != par)
		{
			if(col == 0)
				dp[s][col] = (dp[s][col] *(ways(v, 1, s) + ways(v, 0, s)))%MOD;
			else
				dp[s][col] = (dp[s][col] * ways(v, 0, s))%MOD;
		}
	}
	return dp[s][col];
}

int32_t main()
{
	memset(dp, -1, sizeof(dp));
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	int res1 = ways(1, 0, -1);
	memset(dp, -1, sizeof(dp));
	int res2 = ways(1, 1, -1);
	cout<<(res1+res2)%MOD;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {cout << "Cloudy" << endl;}
  else if (s == "Cloudy") {cout << "Rainy" << endl;}
  else if (s == "Rainy") {cout << "Sunny" << endl;}
}


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

using namespace std;

int main(){
    int N, L;
    string S[100];
    string result = "";

    /* input */ 
    cin >> N >> L;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    /* sort */
    sort(S, S + N);

    /* make string */
    for(int i = 0; i < N; i++){
        result += S[i];
    }

    cout << result;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll MAX_N = ll(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    string s;
    ll k;
    cin >> s >> k;
    REP(i,k){
        if(s[i]-'0' > 1){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


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

vector<char>stack;
// stack.back() will bring you to the last index

void checkForT(string s , char character, int index){
	if(!stack.empty() && stack.back()!= 'S'){
		stack.push_back(character);
	}
	else if(!stack.empty()){
		stack.pop_back();
	}
	else if(stack.empty()){
		stack.push_back(character);
	}
}

void checkForS(string s , char character, int index){
	stack.push_back(character);
}

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

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'S'){
			checkForS(s , s[i] , i);
		}
		else{ // else if stack[i]=='T'
			checkForT(s, s[i] , i);
		}
	}
	cout << stack.size() << endl; // Amount of elements left in stack
}

Measured memory_bytes: 3672
import itertools as it

T = input()

def goodset(a, b, c):
    return (a == b and b == c) or (a + 1 == b and b + 1 == c)

def win(c):
    return goodset(c[0], c[1], c[2]) and goodset(c[3], c[4], c[5]) and goodset(c[6], c[7], c[8])

for i in range(T):
    cards = map(int, raw_input().split())
    color = raw_input().split()
    for j in range(9):
        if color[j] == "G":
            cards[j] += 100
        elif color[j] == "B":
            cards[j] += 200
    w = 0
    for c in it.permutations(cards):#range(9)):
        #c = [cards[p[j]] for j in range(9)]
        if win(c):
            w = 1
            break
    print w

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

using namespace std;

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

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

int n, res;
int a[N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(a[i] % 2 == 0)
        {
            while(a[i] % 2 == 0)
            {
                res++;
                a[i] /= 2;
            }
        }
    }

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


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

s = input()

list(s)


isNotKaibun = 0

if len(s)%2 == 0:
    c = len(s)//2
else:
    c = len(s)//2 +1

for num in range(c):
    if s[num] == s[-(num+1)]:
#        print("--YES--")
#        print(s[num])
#        print(s[-(num+1)])
        pass
    else:
        isNotKaibun += 1
#        print("--NO--")
#        print(s[num])
#        print(s[-(num+1)])

print(isNotKaibun)


Measured memory_bytes: 2940