akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int k, a, b; cin >> k >> a >> b;
  FOR(i, a, b + 1) {
    if (i % k == 0) {
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();

    ll n, k;
    cin>>n>>k;
    ll a;
    a=n/k;
    cout<<min(abs(n-a*k), abs(n-(a+1)*k));
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く 
　　提出する問題を間違えない */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
int S[100001];
int main(){
  int n,q,cnt = 0,t,min,max,mid;
  cin >> n;
  min = 0;
  max = n-1;
  for(int i=0;i<n;i++){
    cin >>S[i];
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> t;
    min = 0;
    max = n-1;
    while(min<=max){
      mid = (max+min)/2;
      if(S[mid] == t){
	cnt++;
	break;
      }
      else if(S[mid] > t){
	max = mid-1;
	
      }
      else if(S[mid] < t){
	min = mid+1;
      }
      
    }
  }
  ANSWER(cnt);
  
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    string n;
    cin >> n;
    
    int k = n.size();
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        char a = n.at(i);
        sum += ((int)a - 48);
    }
    
    // ll n;
    // cin >> n;
    // cout << n << endl;
    // ll a = n;
    // ll b = n;
    // ll sum = 0;
    // while (a != 0)
    // {
    //     b = a;
    //     a = a/10;
    //     sum += (b - a*10);
    // }
    //cout << sum << endl;
    if(sum%9) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3720
/*
    author:ujwalll
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std; 
#define rep(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1<<29;
const int MOD=1073741824;
#define pp pair<ll,ll>
#define ppi pair<int,int>
typedef long long int ll;
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
////////////////////////////////////////////////////////////////////

int main(){
    int tc=1;
    // cin>>tc;
    while(tc--){
        int n,x,t;
        cin>>n>>x>>t;
        int u = (n/x);
        if(n==u*x)cout<<u*t;
        else cout<<(u+1)*t;
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
string s;
int main(void){
	cin>>s;
	if((s[1]==s[0]&&s[2]==s[3]&&s[2]!=s[1])||(s[0]==s[2]&&s[1]==s[3]&&s[1]!=s[2])||(s[0]==s[3]&&s[1]==s[2]&&s[3]!=s[2]))cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")
int t[30];
int main(){
  int a,b;
  rep(i,3){
    cin>>a>>b;
    t[a-1]++;
    t[b-1]++;
  }
  bool f=1,ff=1;
  rep(i,4){
    if(t[i]%2==1)f=0;
  }
  int c=0,d=0;
  rep(i,4){
    if(t[i]%2==1)c++;
    else d++;
  }

  if(f || (c==2))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for _ in range(H)]
left = [[0]*W for _ in range(H)]
right = [[0]*W for _ in range(H)]
up = [[0]*W for _ in range(H)]
down = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if(S[i][j]=="."):
            if(j == 0):
                left[i][j] = 1
            else:
                left[i][j]=left[i][j-1]+1
for i in range(H):
    for j in range(W-1,-1,-1):                
        if(S[i][j]=="."):
            if(j == W-1):
                right[i][j]=1
            else:
                right[i][j]=right[i][j+1]+1
for i in range(H):
    for j in range(W):                   
        if(S[i][j]=="."):
            if(i == 0):
                up[i][j] = 1
            else:
                up[i][j]=up[i-1][j]+1
for i in range(H-1,-1,-1):
    for j in range(W):     
        if(S[i][j]=="."):
            if(i == H-1):
                down[i][j]=1
            else:
                down[i][j]=down[i+1][j]+1
ans = 0
X = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        X[i][j] = left[i][j]+right[i][j]+up[i][j]+down[i][j]-3
    ans = max(ans,max(X[i]))
print(ans)

Measured memory_bytes: 213764
/**
 * Created by hiramekun at 16:19 on 2019-09-17.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, k, q;
    cin >> n >> k >> q;

    vl a(q);
    cin >> a;

    vl nominus(n);
    rep(i, q) {
        a[i]--;
        nominus[a[i]]++;
    }

    rep(i, n) {
        if (k - (q - nominus[i]) > 0) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 2176
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
max=a
min=a
if (max<b):
    max=b
if (max<c):
    max=c
if (max<d):
    max=d
if (max<e):
    max=e
if (min>b):
    min=b
if (min>c):
    min=c
if (min>d):
    min=d
if (min>e):
    min=e
z= max-min
if (z>k):
    print(':(')
else :
    print('Yay!')

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    string S,T;
    long long ans=0;

    cin>>S>>T;

    for(long long i=0;i<S.size();i++){
        if(S[i] != T[i]){
            ans++;
        }
    }

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3856
#include<bits/stdc++.h>
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		int n,x,tr;
		cin>>n>>x>>tr;
		int c=1;
		if(n%x==0){
			c=0;	
		}
		cout<< (int)(n/x)*tr+c*tr<<endl;			
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  map<string, int> strs;
  int max = 0;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    auto it = strs.find(str);
    int num;
    if (it == strs.end()) {
      strs.emplace(str, 1);
      num = 1;
    }
    else {
      it->second += 1;
      num = it->second;
    }
    if (num > max)
      max = num;
  }
  auto itend = strs.end();
  for (auto it = strs.begin(); it != itend; ++it) {
    if (it->second == max)
      cout << it->first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
n = int(input())
if n < 10:
  r = n
elif n < 10**2:
  r = 9
elif n < 10**3:
  r = n-99 + 9
elif n < 10**4:
  r = 999-99 + 9
elif n < 10**5:
  r = n-9999 + 999-99 + 9
elif n == 10**5:
  r = 99999-9999 + 999-99 + 9

print(r)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<tuple<string,ll,ll>> vec(N);
  for(ll i=0;i<N;i++) {
string S;
    cin>>S;
    ll P;
    cin>>P;
    vec[i]=make_tuple(S,P,i+1);
  }
  
  sort(all(vec));
for (ll i=0;i<N;i++) {
if(get<0>(vec[i])!=get<0>(vec[i+1]) ){
  cout<<get<2>(vec[i])<<endl;
}
  
  else {
    ll count=0;
for(ll j=i+1;j<N;j++) {
if(get<0>(vec[j])==get<0>(vec[i])) {
count++;
}
              else {
break;
              }
              }
              
 for(ll h=0;h<=count;h++) {
   cout<<get<2>(vec[i+count-h])<<endl;
 }
              i+=count;
              }
              }
              }

              
              
              
              
              
              
              
              
              
              
              
              
  
  

Measured memory_bytes: 3660
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define eb emplace_back   
#define aint(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    string s;
    cin >> s;
    int n = s.length(), ans = 0;
    stack <char> st;
    FOR(i,0,n)
    {
        if (st.empty())
            st.push(s[i]);
        else
        {
            if (st.top() != s[i])
            {
                st.pop();
                ans += 2;
            }
            else
                st.push(s[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
        
    int main() {
        int N;
        cin >> N;
     
        unsigned long long L0 = 2;
        unsigned long long L1 = 1;
        unsigned long long L2 = L1;
        N--;
        if (!N) {
          L2 = L1;
        } else if (N > 0) {
            while (N--) {
                L2 = L0 + L1;
                L0 = L1;
                L1 = L2;
            }
        } else {
            L2 = L0;
        }
     
        cout << L2 << "\n";
        return 0;
    }

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

const ll mod = 1e9 + 7;

int main() {
    int n, A = 0, B = 0, C = 0;
    cin >> n;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ll a, cnt = 0;
        bool b = false;
        cin >> a;
        if (a == A) {
            cnt++;
            if (!b) A++, b = true;
        }
        if (a == B) {
            cnt++;
            if (!b) B++, b = true;
        }
        if (a == C) {
            cnt++;
            if (!b) C++, b = true;
        }
        ans = (ans * cnt) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  string s; cin >> s;
  int N = s.size();
  s += "DDD";
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(s[i] == 'A'){
      int a = 1;
      int pos = i+1;
      for(int j = i+1; j < N; j++){
        if(s[j] == 'A') a++;
        else if(s[j] == 'B' && s[j+1] == 'C'){
          ans += a;
          j++;
        }
        else {
          pos = j;
          break;
        }
        if(j == N-1){
          pos = j;
          break;
        }
      }
      i = pos-1;
    }
  }
  cout << ans << endl;


  return 0;
}


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

lst = []
def Gcd(a , b):
    r =  b % a
    if r == 0:
        return a
    else:
        b = a
        return Gcd(r, a)

for i in range(N - 1):
    v = Gcd(A[i], A[i + 1])
    lst.append(v)

print(min(lst))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int main(){
  int n,k,a=0;string s;cin>>n>>k>>s;
  REP(i,n-1)
    if(s[i]==s[i+1])a++;
  cout<<min(n-1,k*2+a)<<endl;
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		int res = 0; ;
		int n = int.Parse(Console.ReadLine());
		string val = Console.ReadLine();



		int[] w = new int[n];
		int[] e = new int[n];

		if ( val[0] == 'W' ) {
			w[0] =  1;
		} else {
			e[0] =  1;
		}
		for ( int i = 1; i < n; i++ ) {
			if ( val[i] == 'W' ) {
				w[i] = w[i - 1] + 1;
				e[i] = e[i - 1] ;
			} else {
				e[i] = e[i - 1] + 1;
				w[i] = w[i - 1] ;
			}


		}
		res= e[n - 1] - e[0];
		for ( int i = 1; i < n-1; i++ ) {
			int cnt = 0;
				cnt = w[i - 1];
				cnt += e[n - 1] - e[i];
				res = Math.Min(res, cnt);
		}
		int cn=w[n-1];
		res = Math.Min(res, cn);

			//deug
			Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 14432
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N; cin >> N;
	string s; cin >> s;
	int ans = 0;
	int cnt = 0;
	rep(i, N) {
		if (s[i] == 'I')++cnt;
		else --cnt;
		chmax(ans, cnt);
	}
	cout << ans << "\n";
	

	return 0;
}

Measured memory_bytes: 256
package main

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

func maxHeapify(heap []int, no int) {
	largestNo := no
	maxNo := len(heap)
	leftNo, rightNo := no * 2, no * 2 + 1

	if leftNo <= maxNo && heap[largestNo-1] < heap[leftNo-1] {
		largestNo = leftNo
	}
	if rightNo <= maxNo && heap[largestNo-1] < heap[rightNo-1] {
		largestNo = rightNo
	}

	if largestNo != no {
		heap[largestNo-1], heap[no-1] = heap[no-1], heap[largestNo-1]
		maxHeapify(heap, largestNo)
	}
}

func buildMaxHeap(heap []int) {
	for i := len(heap)/2; i > 0; i-- {
		maxHeapify(heap, i)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	heap := make([]int, n)
	for i := 0; i < n; i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		heap[i] = x
	}
	buildMaxHeap(heap)
	fmt.Println(formatHeap(heap))
}

func formatHeap(heap []int) string {
	as := make([]string, len(heap))
	for i, v := range heap {
		as[i] = strconv.Itoa(v)
	}
	return " " + strings.Join(as, " ")
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


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

n = input()
S = ['']*n
common = []
#読み込み
for i in range(n):
    S[i] = raw_input()
    
#共通文字の抽出
common = list(S[0])
for k in range(1,n):
    deletelist = []
    for i in range(len(common)):
        findchar = S[k].find(common[i])
        if(findchar != -1):
            S[k] = S[k].replace(common[i],'A',1)
        else:
            deletelist.append(i)
    for j in deletelist[::-1]:
        common.pop(j)
    
sortedcommon = sorted(common)
print ''.join(sortedcommon)

Measured memory_bytes: 2692
n, m = map(int,input().split())

a = [0] * m
b = [0] * m
c = [0] * m

for i in range(0,m):
    a[i], b[i], c[i] = map(int,input().split())
    a[i] = a[i] - 1
    b[i] = b[i] - 1
    c[i] = -c[i]

INF = (n-1) * max(abs(min(c)),abs(max(c)))

dist = [INF] * n

dist[0] = 0

for j in range(0,n-1):
    for i in range(0,m):
        if dist[a[i]] == INF:
            continue
        dist[b[i]] = min(dist[b[i]], dist[a[i]] + c[i])

ans = - dist[n-1]

negative = [False] * n

for j in range(0,n):
    for i in range(0,m):
        if dist[a[i]] == INF:
            continue
        if negative[a[i]]:
            negative[b[i]] = True
        elif dist[a[i]] + c[i] < dist[b[i]]:
            dist[b[i]] = dist[a[i]] + c[i]
            negative[b[i]] = True

if negative[n-1]:
    print("inf")
else:
    print(ans)
            


Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
	char str[1000];
	int i = 0;
	scanf("%s",str);
	while(str[i] != '\0'){
		if(str[i] == 'D'){
			str[i] = 'A';
			i++;
		}
		else if(str[i] == 'E'){
			str[i] = 'B';
			i++;
		}
		else if(str[i] == 'F'){
			str[i] = 'C';
			i++;
		}
		else if(str[i] =='G'){
			str[i] = 'D';
			i++;
		}
		else if(str[i] =='H'){
			str[i] = 'E';
			i++;
		}
		else if(str[i] =='I'){
			str[i] = 'F';
			i++;
		}
		else if(str[i] =='J'){
			str[i] = 'G';
			i++;
		}
		else if(str[i] =='K'){
			str[i] = 'H';
			i++;
		}
		else if(str[i] =='L'){
			str[i] = 'I';
			i++;
		}
		else if(str[i] =='M'){
			str[i] = 'J';
			i++;
		}
		else if(str[i] =='N'){
			str[i] = 'K';
			i++;
		}
		else if(str[i] =='O'){
			str[i] = 'L';
			i++;
		}
		else if(str[i] =='P'){
			str[i] = 'M';
			i++;
		}
		else if(str[i] =='Q'){
			str[i] = 'N';
			i++;
		}
		else if(str[i] =='R'){
			str[i] = 'O';
			i++;
		}
		else if(str[i] =='S'){
			str[i] = 'P';
			i++;
		}
		else if(str[i] =='T'){
			str[i] = 'Q';
			i++;
		}
		else if(str[i] =='U'){
			str[i] = 'R';
			i++;
		}
		else if(str[i] =='V'){
			str[i] = 'S';
			i++;
		}
		else if(str[i] =='W'){
			str[i] = 'T';
			i++;
		}
		else if(str[i] =='X'){
			str[i] = 'U';
			i++;
		}
		else if(str[i] =='Y'){
			str[i] = 'V';
			i++;
		}
		else if(str[i] =='Z'){
			str[i] = 'W';
			i++;
		}
		else if(str[i] =='A'){
			str[i] = 'X';
			i++;
		}
		else if(str[i] =='B'){
			str[i] = 'Y';
			i++;
		}
		else{
			str[i] = 'Z';
			i++;
		}
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 524
N,M,X = gets.chomp.split.map(&:to_i)
C = N.times.map{gets.chomp.split.map(&:to_i)}

bits = [0, 1].repeated_permutation(N).to_a
ans = 10**7

bits.each do |bit|
  rikaido = [0] * (M + 1)
  (0..N-1).each do |j|
    if bit[j] == 1
      (0..M).each do |k|
        rikaido[k] += C[j][k]
        if rikaido[1..M].all? {|n| n >= X}
          ans = rikaido[0] if ans >= rikaido[0]
        end
      end
    end
  end
end

puts ans == (10**7) ? -1 : ans


Measured memory_bytes: 15592
#include <iostream>
#include <string>
#include <string.h>

using namespace std;
#define copy(a, b) number[a - 1] = temp[b - 1];

class Dice {
public:
	Dice() {
		for (int i = 0; i < 6; i++)
			cin >> number[i];
	}

	void rotate(char c) {
		int temp[6];
		for(int i = 0; i < 6; i++)
			temp[i] = number[i];
		switch (c) {
		case 'E':
			copy(1, 4);
			copy(4, 6);
			copy(6, 3);
			copy(3, 1);
			break;
		case 'W':
			copy(1, 3);
			copy(3, 6);
			copy(6, 4);
			copy(4, 1);
			break;
		case 'N':
			copy(5, 1);
			copy(1, 2);
			copy(2, 6);
			copy(6, 5);
			break;
		case 'S':
			copy(2, 1);
			copy(1, 5);
			copy(5, 6);
			copy(6, 2);
			break;
		}
	}
	void print(int x) {
		cout << number[x - 1] << endl;
	}
	int getnum(int x) {
		return number[x - 1];
	}
	void spin() {
		int temp[6];
		for (int i = 0; i < 6; i++)
			temp[i] = number[i];
		copy(2, 3);
		copy(3, 5);
		copy(5, 4);
		copy(4, 2);	
	}
private:
	int number[6];
};

int main() {
	int n;

	cin >> n;

	Dice d[n];
	int check = 0;
	int count = 0;


	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {

			for (int k = 0; k < 4; k++) {
				d[i].rotate('S');
				if (d[i].getnum(1) == d[j].getnum(1))
					break;
			}

			if (d[i].getnum(1) != d[j].getnum(1)) {
				for (int k = 0; k < 4; k++) {
					if (d[i].getnum(1) == d[j].getnum(1))
						break;
					d[i].rotate('E');
				}
				if (d[i].getnum(1) != d[j].getnum(1))
					break;
			}

			for (int k = 1; k <= 4; k++) {
				if (d[i].getnum(2) == d[j].getnum(2)) break;
				d[i].spin();		
			}

			for (int k = 1; k <= 6; k++) {
				if (d[i].getnum(k) == d[j].getnum(k)) {
					check++;
				}
			}

			if (check == 6)
				break;
			else
				check = 0;
		}
		if (check == 6)
			break;
	}
	if (check == 6)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;	
}
		


Measured memory_bytes: 3124
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

#include <complex>
typedef complex<double> Point;
const double EPS = 1e-8;

// テ・ツ?・テ・ツ環崚」ツつケテ」ツδ暗」ツδェテ」ツδシテ」ツδ?」ツ?凝」ツつ嘉・ツョツ淌ヲツ閉ーテ、ツコツ古」ツ?、テ」ツつ津」ツ?ィテ」ツ?」テ」ツ?ヲ Point テ」ツ?ク
istream& operator >> ( istream &s, Point &a )
{
	double r, i;
	s >> r >> i;
	a = Point( r, i );
	return s;
}

// a == b
bool eq( const double a, const double b )
{
	return abs( a - b ) <= EPS;
}


// テ・ツ、ツ姪ァツゥツ催ッツシツ暗」ツつッテ」ツδュテ」ツつケテァツゥツ催ッツシツ?
double cross( const Point &a, const Point &b )
{
	return a.real() * b.imag() - a.imag() * b.real();
}

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

	int n;
	cin >> n;
	REP( i, 0, n )
	{
		Point a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << ( eq( cross( a - b, c - d ), 0 ) ? "YES" : "NO" ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const double pi=acos(-1.0);
int main()
{
    double a,b;
    double h,m;
    cin>>a>>b>>h>>m;
    h=h+m/60.0;
    m=m/5.0;
    double num=fabs(h-m);
    if(num>6.0)num=12.0-num;
   // cout<<num<<endl;
    double angle=num/12.0*360*pi/180.0;
    //cout<<angle<<endl;
    //cout<<cos(angle)<<endl;
    double dis=a*a+b*b-2*a*b*cos(angle);
    printf("%.9f\n",sqrt(dis));
    return 0;
}


Measured memory_bytes: 4124
#include<stdio.h>
typedef long long LL;
LL IN(void)
{
  LL x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  LL N=IN();static int i=0,str[11],sz=0;
  while(N){N--;str[sz++]=97+N%26;N/=26;}
  while(i<sz){printf("%c",str[sz-i-1]);i++;}
}

Measured memory_bytes: 1532
N = int(input())
xs = []
ys = []
hs = []
for _ in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

for x in range(101):
    for y in range(101):
        for n in range(N):
            if hs[n] > 0:
                h = hs[n] + abs(x - xs[n]) + abs(y - ys[n])
                break
        flg = True        
        for n in range(N):
            if hs[n] != max(0, h - abs(x - xs[n]) - abs(y - ys[n])):
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(x, y, h))

Measured memory_bytes: 3064
n = int(input())
*A, = map(int, input().split())

result,right,asum=0,0,0
for left in range(n):
    for r in range(right,n):
        if asum&A[right]:
            break
        asum|=A[right]
        right += 1
    asum -= A[left]
    result += right-left
print(result)

Measured memory_bytes: 24712
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 200001;
char a[maxn];
int l,r;
int main(){
    cin>>a;
    for(int i=0;i<strlen(a);i++)
        if(a[i]=='A')
		{
            l=i;
            break;
        }
    for(int i=strlen(a)-1;i>=0;i--)
        if(a[i]=='Z'){
            r=i;
            break;
        }
    cout<<r-l+1<<endl;
    return 0; 
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    zoom;
    ll M, D, i, j;
    cin >> M >> D;
    ll ans = 0;
    for(i = 1; i <= M; i += 1) {
        for(j = 2; j <= D; j += 1) {
            if(i % j != 0)
                continue;
            ll temp = i / j;
            if(j * 10 + temp > D || temp < 2 || temp >= 10)
                continue;
            ans += 1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
deque < long long > a;
deque < long long > b;
int main()
{
	int n,a2,b2;
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>a2;
		a.push_back(a2);
	}
	for(long long i=0;i<n;i++)
	{
		cin>>b2;
		b.push_back(b2);
	}
	long long k=0,k2=0;
	for(long long i=0;i<n;i++)
		k+=b[i]-a[i];
	for(long long i=0;i<n;i++)
	{
		if(b[i]-a[i]>0)
			k-=(b[i]-a[i]+1)/2;
	}
	if(k<0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
struct Edge{
  Edge(int to, int cost) : to(to), cost(cost) {}
  int to, cost;
};
vector<Edge> edges[MAX_N];

int color[MAX_N];

void dfs(int pos, int sum) 
{
  color[pos] = sum%2;
  for(const Edge& edge : edges[pos]) {
    if(color[edge.to] != -1) continue;
    dfs(edge.to, sum + edge.cost);
  }
}

signed main()
{
  cin >> N;
  REP(n,N-1) {
    int a,b,c; cin >> a >> b >> c; a--; b--;
    edges[a].push_back(Edge(b,c));
    edges[b].push_back(Edge(a,c));
  }

  memset(color, -1, sizeof(color));

  dfs(0, 0);

  REP(n,N) {
    cout << color[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  char grid[100][100];
  bool skip_h[100];
  bool skip_w[100];
  rep(i,H) { rep(j,W) { cin >> grid[i][j]; } }

  rep(i,H) {
    rep(j,W) {
      if(grid[i][j] != '.') goto nexti;
    }
    skip_h[i] = true;
    nexti:
      continue;
  }

  rep(j, W) {
    rep(i, H) {
      if(grid[i][j] != '.') goto nextj;
    }
    skip_w[j] = true;
    nextj:
      continue;
  }

  rep(i,H) {
    if(skip_h[i] == false) {
      rep(j,W) {
        if(skip_w[j] == false) {
          cout << grid[i][j];
        }
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
X,N = map(int,input().split())
p = list(map(int,input().split()))
# p = [i+1 for i in range(99)]
L = [i-99 for i in range(202)]
# L = [i for i in range(101)]
for item in p:
    L.pop(L.index(item))
 
MIN = 10**5
ans = 10**5
for item in L:
    if abs(item-X) < MIN:
        MIN = abs(item-X)
        ans = item
 
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1000006, INF=1000000009;
long long a[N], b[N], t[N], n, u;

void upd(int i){ while(i <= 200002) ++t[i], i+=(i&-i); }    

ll sum(int i){
    int x=0;
   	while(i) x+=t[i], i-=(i&-i); 
    return x;
}     
        
int main(){ ios_base::sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++)
      	cin>>a[i];
    int l=1, r=1e9;
	ll x=((ll)n*((ll)n+1ll)/(ll)2+(ll)1)/(ll)2;
    while(l<=r){
       	int mid=(l+r)/2, k=100001;
      	ll ans=0;
      	for (int i=0; i<=200002; i++)t[i]=0;
       	upd(k);
    	for (int i=1; i<=n; i++)
     		if(a[i]>mid) ans+=sum(k+1), upd(++k);
      		else 		 ans+=sum(k-1), upd(--k);
     	
       	if(ans>=x)l=mid+1;
       	else	  r=mid-1;
    }
    cout<<r+1;
   	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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 n; 
vector <vector<pair <int,int>>> dp(420,vector <pair <int,int>>(420, {0, INF}));
vector <int> a(421);
pair <int,int> solve(int l, int r){
    if(l == r){
        dp[l][r] = {a[l],0};
        return dp[l][r];
    }
    if(dp[l][r].S != INF) return dp[l][r];
    for(int i=l;i<r;i++){
        pair <int,int> lc = solve(l, i), rc = solve(i+1, r);
        int cost = lc.S + rc.S + lc.F + rc.F;
        int sz = lc.F + rc.F;
        if(dp[l][r].S > cost) dp[l][r] = make_pair(sz, cost);
    }
    return dp[l][r];
}
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n) cin>>a[i];
    int ans = 0;
    
    cout<<solve(0,n-1).S<<endl;
}



Measured memory_bytes: 3072
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    k = int(input())
    d = deque([0])

    while 1:
        a = d.popleft()
        if a==0:
            for i in range(1, 10):
                d.append(i)
                k -= 1
                if k==0:
                    print(i)
                    exit()
        else:
            b = a%10
            if b==0:
                d.append(a*10+b)
                k -= 1
                if k == 0:
                    print(a*10+b)
                    exit()
                d.append(a*10+(b+1))
                k -= 1
                if k == 0:
                    print(a*10+(b+1))
                    exit()
            elif b==9:
                d.append(a*10+(b-1))
                k -= 1
                if k == 0:
                    print(a*10+(b-1))
                    exit()
                d.append(a*10+b)
                k -= 1
                if k == 0:
                    print(a*10+b)
                    exit()
            else:
                d.append(a*10+(b-1))
                k -= 1
                if k == 0:
                    print(a*10+(b-1))
                    exit()
                d.append(a*10+b)
                k -= 1
                if k == 0:
                    print(a*10+b)
                    exit()
                d.append(a*10+(b+1))
                k -= 1
                if k == 0:
                    print(a*10+(b+1))
                    exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 40816
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

int main(void){
    
    string s;
    cin>>s;
    vector<int> a;
    vector<int> count(s.size());
    for(int i=0;i<s.size();i++){
        count[i] = 0;
    }
    
   
   for(int i=0;i<s.size()-1;i++){
       if(s[i]=='R' && s[i+1] == 'L'){
           a.push_back(i);
       }
   }
//    for(int i=0;i<a.size();i++){
//        cout<<a[i]<<" ";
//    }
//    cout<<endl;
   
   int j=0;
   int first = a[j];
   int second = a[j];
   int index = a[j];

   for(int i=0;i<s.size();i++){
      // cout<<i<<endl;
       if(i>index+1){
           if(s[i]=='R'){
               j++;
                index = a[j];
           }
        //    cout<<"loop"<<endl;
        //    j++;
        //    first = second;
        //    if(j<a.size()) second = a[j];
        //    cout<<first<<" "<<second<<endl;
       }
    //    if(i==0){
    //        if((a[0]-i)%2==1)count[a[0]+1]++;
    //        else count[a[0]]++;
    //    }else{
    //        if(R)
    //    }

    if(abs(i-index)%2==0) count[index]++;
        else count[index+1]++;


    // if(s[i] == 'L'){
    //     cout<<"L"<<endl;
    //     if(abs(i-first)%2==0) count[first]++;
    //     else count[first+1]++;
    // }else{
    //     cout<<"R"<<endl;
    //      if(abs(i-second)%2==0) count[second]++;
    //     else count[second+1]++;
    // }

//     for(int i=0;i<s.size();i++){
//        cout<<count[i]<<" ";
//    }
//    cout<<endl;
       
   }

   for(int i=0;i<s.size();i++){
       cout<<count[i]<<" ";
   }
   cout<<endl;
    
    
    return 0;

}

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

int main(){
  string w;
  cin >> w;
  map<char,int> mp;
  
  rep(i,w.size()) cin >> w.at(i);
  rep(i,w.size()){
    mp[w.at(i)]++;
  }
  
  string ans = "Yes";
  for(auto p : mp){
    if(p.second % 2 != 0) ans = "No"; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
string S;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

ll mystoi(string s) {
   ll ans = 0;
   for (int i = 0; i < s.size(); i++) {
      ans += ctoi(s[i]) * pow(10, s.size() - i - 1);
   }
   return ans;
}


int main() {
   cin >> S;
   int len = S.size() - 1;
   ll ans = 0;
   for (int mask = 0; mask < (1 << len); mask++) {
      // cout << "------" << endl;
      string tmp = "";
      tmp += S[0];
      for (int i = 0; i < len; i++) {
         // cout << i << " " << ((mask >> i) & 1) << endl;
         if ((mask >> i) & 1) {
            // cout << tmp << " " << mystoi(tmp) << endl;
            ans += mystoi(tmp);
            tmp = "";
            tmp += S[i + 1];
         } else {
            tmp += S[i + 1];
         }
      }
      // cout << tmp << " " << mystoi(tmp) << endl;
      ans += mystoi(tmp);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, C, ans = 0; cin >> A >> B >> C;
    while (C > 0) {
        ans++;
        if (ans % 7 != 0) {
            C -= A;
        } else {
            C -= (A+B);
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define aint(v) v.begin(),v.end()
#define endl "\n"
#define all(v) v.begin(),v.end()
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<15> MASK;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int MAX = 2e3 + 5;

struct DSU {
    int parent[MAX];
    int groupSize[MAX];
    int rank[MAX];
    int CC;

    DSU() {
        CC = MAX;
        for (int i = 0; i < MAX; ++i) {
            parent[i] = i;
            groupSize[i] = 1;
        }
    }

    int findLeader(int node) {
        if (parent[node] == node)return node;
        return parent[node] = findLeader(parent[node]);
    }

    int sameGroup(int i, int j) {
        return findLeader(i) == findLeader(j);
    }

    int mergeGroup(int i, int j) {
        int leader1 = findLeader(i);
        int leader2 = findLeader(j);
        if (leader1 == leader2)return 0;
        CC--;
        if (groupSize[leader1] > groupSize[leader2]) {
            parent[leader2] = leader1;
            groupSize[leader1] += groupSize[leader2];
        } else {
            parent[leader1] = leader2;
            groupSize[leader2] += groupSize[leader1];

        }
        return 1;
    }

    void mergeGroupByRank(int i, int j) {
        int leader1 = findLeader(i);
        int leader2 = findLeader(j);
        if (leader1 == leader2)return;
        if (rank[leader1] < rank[leader2])swap(leader1, leader2);
        parent[leader2] = leader1;
        if (rank[leader1] == rank[leader2])rank[leader1]++;
        CC--;


    }

    int getCC() {
        return CC;
    }

    int getSize(int node) {
        return groupSize[findLeader(node)];
    }
};

struct edge {
    ll w;
    int from, to;

    bool operator<(const edge &e) const {
        return e.w < w;
    }
};

vector<edge> edgList, edges;

int n, m, src, e, ans = 1e9;

double kruskal() {
    DSU d;
    double total = 0;
    priority_queue<edge> q;
    for (int i = 0; i < edgList.size(); ++i) {
        q.push(edgList[i]);
    }
    bool ok = 0;
    while (!q.empty()) {
        edge e = q.top();
        q.pop();
        if (d.mergeGroup(e.from, e.to)) {
            total += e.w;
            edges.push_back(e);
        }
    }

    return total;
};
vector<vector<int>> adj(MAX, vector<int>(MAX, 1e8));
int OO = 1e9;

bool comp(edge &a, edge &b) {
    return a.w < b.w;
}

double dist(pi x, pi y) {
    return sqrt((x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second));
}
int adjM[MAX][MAX];
int main() {
    fast();
    int n;cin>>n;
    string arr[n];
    map<char,ll>freq;
    string march="MARCH";
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
        freq[arr[i][0]]++;
    }
    ll ans=0;
    for (int j = 0; j < 5; ++j) {
        for (int i = j+1; i <5 ; ++i) {
        for (int k = i+1; k <5 ; ++k) {
            ans += (freq[march[j]] * freq[march[i]]*freq[march[k]]);
        }   }
    }
    cout<<ans;
}


Measured memory_bytes: 22516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    boost;
    ll n;
    cin >> n;
    char arr[26];
    for (int i = 0; i < 26; i++)
    {
        arr[i] = 'a' + i;
    }
    string ans = "";
    while (n)
    {
        n--;
        // cout << n << endl;
        ans += arr[n % 26];
        n = n / 26;
        // cout << n << endl;

    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;



}

Measured memory_bytes: 3612
#include <stdio.h>
int main() {
  int A, B, num, count;
  count = 1;
  scanf("%d%d", &A, &B);
  num = A;
  for (;;) {
    if (num >= B) {
      break;
    }
    num += A - 1;
    ++count;
  }
  if (B == 1) {
    count = 0;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

long long binary_search(long long ng, long long ok,
                        function<bool(long long)> f) {
  while (abs(ok - ng) > 1) {
    long long mid = (ng + ok) / 2;
    if (f(mid))
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}

int main() {
  long long n, A, B;
  cin >> n >> A >> B;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  auto f = [&](long long K) {
    long long x = 0;
    for (const auto& e : h) {
      long long rem = (long long)e - B * K;
      if (rem > 0) {
        x += (rem + A - B - 1) / (A - B);
      }
    }
    return x <= K;
  };
  // N.B. : We can use max(h[i]) / B as ok.
  cout << binary_search(0, (1e9 + B - 1) / B, f) << endl;
  return 0;
}


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int freq[27];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int h, w; cin >> h >> w;

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            char k; cin >> k;
            ++freq[k - 'a'];
        }
    }

    // count x of 4s, y of 2s, z of 1s

    int x = w * h, y = 0, z = 0;

    if(h % 2 == 1 && w % 2 == 1){
        y = w + h - 2;
        x -= w + h - 1;
        z = 1;
    } else if(w % 2 == 1){
        y = h;
        x -= h;
    } else if(h % 2 == 1){
        y = w;
        x -= w;
    }

    x /= 4; y /= 2;

    for(int i = 0; i < x; ++i){
        bool f = true;
        for(int c = 0; c < 26; ++c){
            if(freq[c] >= 4){
                f = false; freq[c] -= 4; break;
            }
        }
        if(f){
            cout << "No\n";
            return 0;
        }
    }

    for(int i = 0; i < y; ++i){
        bool f = true;
        for(int c = 0; c < 26; ++c){
            if(freq[c] >= 2){
                f = false; freq[c] -= 2; break;
            }
        }
        if(f){
            cout << "No\n";
            return 0;
        }
    }

    for(int i = 0; i < z; ++i){
        bool f = true;
        for(int c = 0; c < 26; ++c){
            if(freq[c] >= 1){
                f = false; freq[c] -= 1; break;
            }
        }
        if(f){
            cout << "No\n";
            return 0;
        }
    }

    for(int i = 0; i < 26; ++i){
        if(freq[i] > 0){
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# @Time    : 2020/3/1 19:59
# @Author  : DIRICHLET
# @File    : main.py

n,m=map(int,input().split())
mm={}
f=1
ans=[0 for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    if a not in mm:
        mm[a]=b
    else:
        if mm[a]!=b:
            print('-1')
            exit()
l=sorted(mm.keys())
for i in l:
    ans[i-1]=mm[i]
if ans[0]==0:
    if len(ans)==1:
        print('0')
        exit()
    else:
        if 1 in mm:
            print('-1')
            exit()
        else:
            print('1',end='')
            for i in ans[1:]:
                print(i, end='')
else:
    for i in ans:
        print(i,end='')

Measured memory_bytes: 3192