akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int N;
  cin>>N;
  int V[N],C[N];
  for(int i=0;i<N;i++){
  	cin>>V[i];
  }
  int ans=0;
  for(int i=0;i<N;i++){
  	cin>>C[i];
  	if(V[i]>C[i]){
    	ans+=V[i]-C[i];
    }
  }
  cout<<ans;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //???????????\??¢??°

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //???????????°??????dout?????????????????????????????????
    #define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
    //???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif


#define disp(A) dout << #A << " = " << (A) << endl;

#define SIZE 67108864 //4^13 ????????????????????????1??¨???????????§???????????????4^12*2????????????2^25=33554432??§??????

int key[128];
bool dic[SIZE];


int Hash(string str) { //????????????4????????§??°??????????????????
    const char *c = str.c_str();
    
    int hashCode = 1;
    
    while(*c) {
//        disp(*c)
        hashCode *= 4;
        hashCode += key[*c];
//        disp(hashCode)
        c++;
    }
    
    return hashCode;
}

int main(void) {

    key['A']=0;
    key['C']=1;
    key['G']=2;
    key['T']=3;

    size_t N;
    cin >> N;
    
    string order;
    string str;
    
    while(N--) {
        cin >> order >> str;
        
        if(order[0]=='i') {
            dic[Hash(str)]=1;
        }
        else {
            cout << ( dic[Hash(str)] ? "yes" : "no" ) << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 4544
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int mod = 1e9 + 7;
inline void reduce(int &x) { x += x >> 31 & mod; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
//ruogu_alter
const int N = 2e5 + 5;
int n, a[N];
int vis[N];
//
int main() {
  n = getint(); ll k; cin >> k;
  rep(i, n) a[i] = getint() - 1;
  memset(vis, -1, sizeof(vis));
  vector<int> v;
  int cnt = 0, now = 0;
  while (vis[now] == -1) {
    vis[now] = cnt++;
    v.emplace_back(now);
    now = a[now];
  }
  int cyclen = cnt - vis[now];
  if (k < v.size() - cyclen) return !printf("%d\n", v[k] + 1);
  k -= v.size() - cyclen;
  k %= cyclen;
  cout << v[v.size() - cyclen + k] + 1 << endl;
  return 0;
}


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

using namespace std;

#define REP(i, n) for ((i) = 0;(i) < (int)(n);(i)++)
#define M 2000

bool ab[100000], ac[100000], bc[100000];

 bool match(char c1, char c2) {
	return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main(void) {
	int i, j;
	
	string a, b, c;
	cin >> a >> b >> c;
	
	int A = a.length();
	int B = b.length();
	int C = c.length();
	
	REP(i, A) REP(j, B) if (!match(a[i], b[j])) ab[i - j + 50000] = true;
	REP(i, A) REP(j, C) if (!match(a[i], c[j])) ac[i - j + 50000] = true;
	REP(i, B) REP(j, C) if (!match(b[i], c[j])) bc[i - j + 50000] = true;
	
	int ans = 3 * M;
	for (i = -2 * M;i <= 2 * M;i++) for (j = -2 * M;j <= 2 * M;j++) if (!ab[i + 50000] && !ac[j + 50000] &&
		!bc[j - i + 50000]) {
		int L = min(0, min(i, j));
		int R = max(A, max(B + i, C + j));
		ans = min(ans, R - L);
	}
	cout << ans << endl;
	return 0;
	
}

Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
    string s;
    cin >> s;
    if (s=="ABC") puts("ARC");
    else puts("ABC");
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	int n;
	string s;
	cin >> n >> s;

	string answer;
	answer += s[0];
	int count = 0;

	for (int i = 0; i < n; i++) {
		if (answer[count] != s[i]) {
			answer += s[i];
			count++;
		}
	}

	cout << answer.size() << endl;



	return 0;
}

Measured memory_bytes: 640
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    V, E = next(it), next(it)
    inf = float("inf")

    dp = [[inf for i in range(V)] for i in range(V)]

    for si, ti, di in zip(it, it, it):
        dp[si][ti] = di
    for i in range(V):
        dp[i][i] = 0

    for s in range(V):
        for t, dts in ((t, dp[t][s]) for t in range(V)):
            if s == t: continue
            for u, (dtu, dsu) in enumerate(zip(dp[t], dp[s])):

                d1 = dts + dsu
                if dtu > d1:
                    if u == t:
                        return print("NEGATIVE CYCLE")
                    dp[t][u] = d1
                    update = True

    for dr in dp:
        print(*["INF" if x == inf else x for x in dr])



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 7688
#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;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 2*1e5+3;

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i+1<n;i++)
	{
		if(s[i]=='W'&&s[i+1]=='R') cnt++;
	}
	if(cnt==0)
	{
		cout<<"0";
		return;
	}
	int cr=0,cw=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='W') cw++;
		else cr++;
	}
	int ans=0;
	for(int i=0;i<cr;i++)
	{
		if(s[i]=='W') ans++;
	}
	cout<<ans<<"\n";

}
// RRR...WWW....
// WRWWRWRR
// RRRRWWWW
// RRWWWWRR
// xxxy
// 7, 7*11, 7*3*37 , 7*11*101,
int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


Measured memory_bytes: 3772
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	while(-1){
		int h,w,j;cin>>h>>w;
		if(h+w==0){RE;}
		while(h--){
			for(j=0;j<w;j++){cout<<'#';}
			cout<<endl;
		}
		cout<<endl;
	}
	RE;
}


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

int main()
{
	int n[10000], s[10000], N, S, cnt = 0;
	cin >> N;
	for (int i = 0;i<N;i++)
		cin >> n[i];
	cin >> S;
	for (int i = 0;i<S;i++)
		cin >> s[i];
	for (int i = 0;i<S;i++)
		for (int j = 0;j<N;j++)
			if (n[j] == s[i])
			{
				cnt++;
				break;
			}

	cout << cnt << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  vector<vector<long long>> dp(N + 5, vector<long long>(N + 5));
  for (int i = N - 1; i >= 0; i--) {
    for (int j = i; j < N; j++) {
      if ((N - j + i) % 2) {
        if (i == j) {
          dp[i][j] = A[i];
        } else {
          dp[i][j] = max(dp[i + 1][j] + A[i], dp[i][j - 1] + A[j]);
        }
      } else {
        if (i == j) {
          dp[i][j] = -A[i];
        } else {
          dp[i][j] = min(dp[i + 1][j] - A[i], dp[i][j - 1] - A[j]);
        }
      }
    }
  }
  cout << dp[0][N - 1] << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 70912
#include <bits/stdc++.h>
 
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);
 
    string S;
    cin >> S;
    
    int cnt_a = 0, cnt_b = 0, cnt_c = 0;
    
    for(int i = 0; i < 3; i++){
    	if(S[i] == 'a'){
    		cnt_a++;
    	}else if(S[i] == 'b'){
    		cnt_b++;
    	}else{
    		cnt_c++;
    	}
    }
    
    if((cnt_a==1 && cnt_b==1) && cnt_c==1){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 


using namespace std;
 


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


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

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

    long long ans = 0, cnt = 0;
    char t = s[0];

    bool f = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t) f = false;
        else cnt++;
    }

    if (f) {
        ans = (cnt * k) / 2;
        cout << ans << endl;
        return 0;
    }

    cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t) cnt++;
        else {
            ans += cnt / 2;
            t = s[i];
            cnt = 1;
        }
    }
    ans += cnt / 2;

    ans *= k;

    if (s.size() == 1) {
        ans += k - 1;

        cout << ans << endl;
        return 0;
    }

    if (s[0] == s[s.size() - 1]) {
        if (s[s.size() - 2] == s[s.size() - 1] && s[s.size() - 1] == s[0]) {

        }
        else if (s[s.size() - 1] == s[0] && s[0] == s[1]) {

        }
        else {
            ans += k - 1;
        }


        long long cnt_1 = 0, cnt_2 = 0;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == t) cnt_1++;
            else break;
        }
        for (int i = s.size() - 1; i >= 0; i--) {
            if (s[i] == t) cnt_2++;
            else break;
        }

        if ((cnt_1 >= 3 || cnt_2 >= 3) && (cnt_1 % 2 == 1 && cnt_2 % 2 == 1)) {
            ans += k - 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
count = 0

for i in range(1000):
    pin = ("00" + str(i))[-3:]

    j = 0
    for num in S:
        if pin[j] == num:
            j += 1
        if j == 3:
            count += 1
            break

print(count)


Measured memory_bytes: 42428
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string s, t; cin >> s >> t;
  string ans = "UNRESTORABLE";
  int n = s.size(), m = t.size();
  for(int i = 0; i <= n - m; i++){
    int j;
    for(j = 0; j < m; j++){
      if(s[i + j] != '?' && s[i + j] != t[j]) break;
    }
    if(j == m){
      string st = s;
      int tn = 0;
      for(int k = 0; k < n; k++){
        if(k >= i && k < i + m) st[k] = t[tn++];
        else if(st[k] == '?') st[k] = 'a';
      }
      if(ans == "UNRESTORABLE") ans = st;
      else ans = min(st, ans);
    }
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
// Confessions of a Dangerous Mind

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 2e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 3e-16;

/*
	Keep moving forward. Take the Leap of Faith
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
    long long n, m; cin >> n >> m;
    
    set<long long> p;
    for(long long i = 1; i <= n; i++){
    	p.insert(i);
    }
    
    while(m--){
    	long long q; cin >> q;
    	while(q--){
    		long long x; cin >> x;
    		if(p.count(x)){
    			p.erase(p.find(x));	
    		}
    	}
    }
    
    cout << p.size();
    
    return 0;
}

Measured memory_bytes: 3664
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split("\n");
   
    var a= parseInt(input[0], 10);
     
    var s= input[1];
   // console.log(a,s)
   
   if (a >= 3200){console.log(s);}
            else {console.log('red');}
   
 
 
  	   }    //    1    
     
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  


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

int main() {
  int n, i, j;
  cin >> n;
  vector<vector<int>> A(2, vector<int>(n)), dp(2, vector<int>(n + 1));
  for (i = 0; i < 2; i++) {
    for (j = 0; j < n; j++) {
      cin >> A[i][j];
    }
  }
  dp[0][0] = A[0][0];
  dp[1][0] = dp[0][0] + A[1][0];
  for (j = 0; j < n; j++) {
    dp[0][j + 1] = dp[0][j] + A[0][j + 1];
  }

  for (j = 0; j < n; j++) {
    dp[1][j + 1] = max(dp[0][j + 1], dp[1][j]) + A[1][j + 1];
  }
  cout << dp[1][n - 1] << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N; cin >> N;
	int A[N], c[N];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		c[i] = A[i];
	}
	sort(c, c + N);

	for (int i = 0; i < N; i++)
	{
		if(A[i] == c[N-1]) {
			cout << c[N-2] << endl;
		}
		else cout << c[N-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
H, W = gets.strip.split.map(&:to_i)
S = H.times.map{ gets.strip.split("") }

A = Array.new(H).map{ Array.new(W) }
R = []

P = [-1, 0, 1]
A.each_with_index do |h, y|
  h.each_with_index do |w, x|
    if S[y][x] == "#"
      A[y][x] = "#"
      next
    end
    count = 0

    P.each do |yy|
      P.each do |xx|
        yyy = y + yy
        xxx = x + xx
        next if yyy < 0 || yyy > H - 1
        next if xxx < 0 || xxx > W - 1
        
        count += 1 if S[yyy][xxx] == "#"
      end
    end

    A[y][x] = count
  end
end
 
puts A.map{|r| r.join }.join("\n")


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s;
  cin>>s;
  int n=s.length();
  int c=0;
  rep(i,0,n) if(s[i]=='-') c--; else c++;
  cout<<c<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

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

using std::vector;
using std::sort;

int main(){
    long a,b,x;
    cin >> a >> b >> x;
    long ax=a/x;
    long bx=b/x;
    if(ax*x!=a){
        ax++;
    }
    cout << bx-ax+1 << endl;
    return 0;
}



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

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

int main() {
    // input
    ll N;
    cin >> N;
    vector< pair<string, double> > vec(N);
    double yen;
    string moji;
    REP(i, N) {
        cin >> yen >> moji;
        vec[i] = make_pair(moji, yen);
    }
    
    // calculation
    double BTC = 380000.0, res = 0;
    
    REP(i, N) {
        if (vec[i].first == "JPY") res += vec[i].second;
        else res += vec[i].second*BTC;
    }
    
    cout << setprecision(10+10) << res << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define mod ((ll)1e9+7)
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f
#define Ninf -0x3e3e3e3f
#define Ninfl -0x3e3e3e3e3e3e3e3f
#define maxx ((ll)1e5+5)
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
ll add(ll x, ll y) { x += y; if (x >= mod) return x-mod; return x;}
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + mod; return x;}
ll mult(ll x, ll y) { return (x * y) % mod;}
ll rev(ll x) { return expm(x, mod - 2);}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
int a,b,n;
int f(int x){
  return (a*x)/b-(x/b)*a;
}
signed main(){
  fast;
  //test
  {
    cin>>a>>b>>n;
    cout<<f(min(b-1,n));
  }
  return 0;
}

Measured memory_bytes: 3604
def bfs(x, y, tx, ty, kx, ky, depart)
  return 0 if tx == kx && ty == ky

  memo = {"#{tx},#{ty},#{kx},#{ky}" => 0}
  q = [[tx, ty, kx, ky]]

  mv = [[-1, 0], [1, 0], [0, -1], [0, 1]]

  until q.empty?
    tx, ty, kx, ky = q.shift

    n = memo["#{tx},#{ty},#{kx},#{ky}"]
    return 'NA' if n >= 100

    mv.each do |mx, my|
      txn = tx + mx
      tyn = ty + my
      kxn = kx - mx
      kyn = ky - my
      if mx != 0
        txn = tx if txn < 0 || txn >= x || depart[tyn][txn] == 1
        kxn = kx if kxn < 0 || kxn >= x || depart[kyn][kxn] == 1
      else
        tyn = ty if tyn < 0 || tyn >= y || depart[tyn][txn] == 1
        kyn = ky if kyn < 0 || kyn >= y || depart[kyn][kxn] == 1
      end

      return n + 1 if txn == kxn && tyn == kyn

      key = "#{txn},#{tyn},#{kxn},#{kyn}"
      next if memo[key]

      memo[key] = n + 1
      q.push [txn, tyn, kxn, kyn]
    end
  end

  'NA'
end

while true
  x, y = gets.chomp.split(' ').map(&:to_i)
  break if x == 0 && y == 0

  tx, ty = gets.chomp.split(' ').map(&:to_i)
  kx, ky = gets.chomp.split(' ').map(&:to_i)

  depart = []
  y.times do |i|
    depart[i] = gets.chomp.split(' ').map(&:to_i)
  end
  puts bfs(x, y, tx - 1, ty - 1, kx - 1, ky - 1, depart)
end

Measured memory_bytes: 36404
#include <stdio.h>

int main(void){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);

        if(a==b && b==c) printf("1\n");
        else if(a!=b && b!=c && a!=c)printf("3\n");
        else printf("2\n");
        return 0;
}


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

  int main() {
    long long N,M;
    cin>> N>>M;
 
      vector<long long>vec(N);
      for(long long i = 0; i < N; i++){
        cin >> vec.at(i);
      }
     long long sum = 0;
    for(long long i = 0; i < N; i++){
      sum += vec.at(i);
    }
    
     sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    if(vec.at(M-1)*(4*M) >= sum ){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    
  }

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

int main() {
  int n;
  cin >> n;
  unordered_map<string, int> mp;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  long long ans = 0;
  for (auto &p : mp) {
    int s = p.second;
    ans += (long long)s*(s-1)/2;
  }

  cout << ans << "\n";
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,k,memo[2][2][1000][1000],ans;

signed main() {
    cin >> n >> k;
    rep(i,n) {
        int x,y,a;
        char c;
        cin >> x >> y >> c;
        a = ((x/k)%2) ^ ((y/k)%2);
        x %= k;
        y %= k;
        if (c == 'W') memo[0][a][y][x] += 1;
        else memo[1][a][y][x] += 1;
    }
    rep(r,2) rep(R,2) rep(i,k) rep11(j,k) memo[r][R][i][j] += memo[r][R][i][j-1];
    rep(r,2) rep(R,2) rep11(i,k) rep(j,k) memo[r][R][i][j] += memo[r][R][i-1][j];
    rep(i,k) rep(j,k) {
        int c1=0,c2=0;
        c1 += memo[0][0][k-1][k-1] - memo[0][0][k-1][j] - memo[0][0][i][k-1] + 2*memo[0][0][i][j];
        c1 += memo[0][1][k-1][j] + memo[0][1][i][k-1] - 2*memo[0][1][i][j];
        c2 += memo[1][1][k-1][k-1] - memo[1][1][k-1][j] - memo[1][1][i][k-1] + 2*memo[1][1][i][j];
        c2 += memo[1][0][k-1][j] + memo[1][0][i][k-1] - 2*memo[1][0][i][j];
        ans = max(ans, max(c1+c2, n-c1-c2));
    }
    cout << ans << endl;
}




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

int main()
{
    int n, a;
    cin >> n;
    vector<int> b(n, 0);
    rep(i, n - 1)
    {
        cin >> a;
        b[a - 1]++;
    }
    rep(i, n)
    {
        cout << b[i] << endl;
    }
}

Measured memory_bytes: 4056
#include <iostream>
#include <cstdio>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int adj[128][128];

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

	long long ret = 0;
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			ret += min(adj[i][j], adj[j][i]);
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
const db pi = acos(-1.0);
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

int main()
{
	int a = read();
	int b = read();
	if(a > 0) puts("Positive");
	else if(a <= 0 && b >= 0) puts("Zero");
	else
	{
		int num = b - a + 1;
		if(num & 1) puts("Negative");
		else puts("Positive");
	}
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();

  println!("{}", if a <= c && c <= b { "Yes" } else { "No" });
}



Measured memory_bytes: 4352
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w, k = ns()
    dp = [[0 for _ in range(w)] for __ in range(h + 1)]
    dp[0][0] = 1
    fibo = [1, 2]
    for i in range(10):
        fibo.append(fibo[-1] + fibo[-2])

    for y in range(1, h + 1):
        for x in range(w):
            if x == 0:
                # from U
                dp[y][x] += dp[y - 1][x] * fibo[max(0, w - 1 - 1)]
                if w > 1:
                    # from R
                    dp[y][x] += dp[y - 1][x + 1] * fibo[max(0, w - 1 - 2)]
            elif x == w - 1:
                # from U
                dp[y][x] += dp[y - 1][x] * fibo[max(0, w - 1 - 1)]
                if w > 1:
                    # from L
                    dp[y][x] += dp[y - 1][x - 1] * fibo[max(0, w - 1 - 2)]
            else:
                # from U
                dp[y][x] += dp[y - 1][x] * fibo[x - 1] * fibo[max(0, w - 1 - x - 1)]
                # from L
                dp[y][x] += dp[y - 1][x - 1] * fibo[max(0, x - 1 - 1)] * fibo[max(0, w - 1 - x - 1)]
                # from R
                dp[y][x] += dp[y - 1][x + 1] * fibo[x - 1] * fibo[max(0, w - 1 - x - 2)]
            dp[y][x] %= MOD

    print(dp[h][k - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9588
#include <cstdio>
#include <cassert>
#include <string>
#include <algorithm>
#include <map>

int f(int a, int L) {
  char buf[8];
  snprintf(buf, sizeof buf, "%0*d\n", L, a);
  std::string min(buf);
  std::sort(min.begin(), min.end());
  std::string max(min.rbegin(), min.rend());
  return std::stoi(max) - std::stoi(min);
}

int testcase_ends() {
  int a0, L;
  scanf("%d %d", &a0, &L);
  if (a0 == 0 && L == 0) return 1;

  std::map<int, size_t> x{{a0, 0}};
  for (size_t i = 1; i < 1000000; ++i) {
    int a1 = f(a0, L);
    auto it = x.find(a1);
    if (it != x.end()) {
      size_t j = it->second;
      return !printf("%zu %d %zu\n", j, a1, i-j);
    }
    x[a1] = i;
    a0 = a1;
  }
  assert(false);
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2800
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut b: Vec<usize> = vec![0; n];
    for i in 1..n {
        b[i] = 2 * a[i - 1] - b[i - 1];
    }

    let d = (*a.last().unwrap() * 2 - *b.last().unwrap()) / 2;

    for i in 0..n {
        if i % 2 == 0 {
            b[i] += d;
        } else {
            b[i] -= d;
        }
    }

    return b.iter().map(|it| it.to_string()).collect::<Vec<String>>().join(" ");
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll n;
    cin>>n;
    ll i=2;
    
    while(1){
        
    if(n==2||n==3){
        cout<<n<<endl;
        return 0;
    }
    
    if(n%i==0){
    n++;
    i=2;
    continue;
    }
    
    
    if(i==n/2){
        cout<<n<<endl;
        return 0;
    }
    i++;
    }
    
}


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

bool isPalindrome (int num) {
  return num / 10000 == num % 10 && (num / 1000) % 10 == (num % 100) / 10;
}

int main () {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  for (int i = A; i <= B; ++i) {
    if (isPalindrome(i)) {
      ++sum;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

long long int combination(long long int n, long long int r) {
  if ( r * 2 > n ) r = n - r;
  long long int dividend = 1;
  long long int divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
long long int tmp(long long int n, long long int r) {
  return combination(n+r-1, r);
}


int main() {
  long long int N, D, cnt = 0;
  //vector<long long int> a_v, x_v;
  cin >> N >> D;

  for (int i = 0; i < N; i+=2*D+1) {
    cnt ++;
    //cout << i << endl;
    // cnt++;
    // if (i + D >= N) {
    //   break;
    // }
    // else if (i + 2*D >= N) {
    //   cnt ++;
    //   break;
    // }
    // i += 2*D;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

from math import sqrt
X=int(input())
sqrt_X=int(sqrt(X))
ans=1

for b in range(sqrt_X):
    for p in range(2,sqrt_X):
        now_num = (b+1)**p
        if now_num <= X and ans <= now_num:
            ans =now_num
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,d;

int main(){
  int ans=0;
  cin >> n >> d;
  vector<vector<int>> vv = vector<vector<int>>(n, vector<int>(d, 0));

  
  REP(i,n){
      REP(j,d){
          cin>>vv[i][j];
      }
  }
  
  double len=0.0;
  REP(i,n){
      REP(j,i){
          len=0.0;
          REP(k,d){
              len+=(vv[i][k]-vv[j][k])*(vv[i][k]-vv[j][k]);
          }
          double dlen=sqrt(len)+0.00000000000001;
          int ilen=dlen;
          if ((len-ilen*ilen)==0.0)ans++;
      }
  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define ld long double
const ll mod=1e9 + 7;
const ll N=15;
bitset<12805> ans[80][80]; 
ll power(ll a,ll b)
{
	a=a%mod;
	ll ans=1;
	while(b>0)
	{
		if(b%2==1)
		{
			ans=(ans*a)%mod;
		}
		b=b/2;
		a=(a*a)%mod;
	}
	return ans;
}




int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand(time(NULL));
    ll n,m;
    cin>>n>>m;
    ll a[n][m];
    ll b[n][m];
    for(ll i=0;i<n;i++)
    {
    	for(ll j=0;j<m;j++)
    	{
    		cin>>a[i][j];
		}
	}
    for(ll i=0;i<n;i++)
    {
    	for(ll j=0;j<m;j++)
    	{
    		cin>>b[i][j];
		}
	}
	ll c=12805/2;
	ll f=abs(a[0][0]-b[0][0]);
	ans[0][0][c+f]=1;
	ans[0][0][abs(c-f)]=1;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m;j++)
		{
			ll diff=abs(a[i][j]-b[i][j]);
			if(i>0)
			{
				ans[i][j] |= (ans[i-1][j] << diff);
				ans[i][j] |= (ans[i-1][j] >> diff);
			}
			if(j>0)
			{
				ans[i][j] |= (ans[i][j-1] << diff);
				ans[i][j] |= (ans[i][j-1] >> diff);
			}
		}
	}
	ll res=INT_MAX;
	for(ll i=0;i<12805;i++)
	{
		if(ans[n-1][m-1][i]==1)
		{
			res=min(res,abs(i-c));
		}
	}
	cout<<res<<endl;
}



Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        long[] nums = new long[5];
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String name = sc.next();
            switch (name.charAt(0)) {
            case 'M':
                nums[0]++;
                break;
            case 'A':
                nums[1]++;
                break;
            case 'R':
                nums[2]++;
                break;
            case 'C':
                nums[3]++;
                break;
            case 'H':
                nums[4]++;
                break;
            }
        }

        long ans = 0l;
        for (int i = 0; i < 5 - 2; i++) {
            for (int j = i + 1; j < 5 - 1; j++) {
                for (int k = j + 1; k < 5; k++) {
                    ans += nums[i] * nums[j] * nums[k];
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 49284
#include <set>
#include <map>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cstring>
#include <algorithm>
#define pc putchar
#define gc() getchar()
typedef long long LL;
//const int N=

inline int read()
{
	int now=0,f=1;register char c=gc();
	for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
	for(;isdigit(c);now=now*10+c-48,c=gc());
	return now*f;
}

int main()
{
	int n=read(),K=read();
	puts((n+1)/2>=K?"YES":"NO");

	return 0;
}

Measured memory_bytes: 128
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    use itertools_num::ItertoolsNum as _;
    input! {
       N: usize,
    }

    let mut h = HashMap::new();
    for _ in 0..N {
        input! {
            a:String,
        }
        let mut hp = h.entry(a).or_insert(0);
        *hp += 1;
    }

    if let Some(x) = h.get("AC") {
        echo!(format!("AC x {}", x));
    } else {
        echo!(format!("AC x {}", 0));
    }
    if let Some(x) = h.get("WA") {
        echo!(format!("WA x {}", x));
    } else {
        echo!(format!("WA x {}", 0));
    }
    if let Some(x) = h.get("TLE") {
        echo!(format!("TLE x {}", x));
    } else {
        echo!(format!("TLE x {}", 0));
    }
    if let Some(x) = h.get("RE") {
        echo!(format!("RE x {}", x));
    } else {
        echo!(format!("RE x {}", 0));
    }
}


Measured memory_bytes: 2588
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s0 = SI()
    s1 = SI()
    ans = [""] * (len(s0) + len(s1))
    for i in range(len(s0)):
        ans[i * 2] = s0[i]
    for i in range(len(s1)):
        ans[i * 2 + 1] = s1[i]
    print("".join(ans))

main()


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL N, K;
    cin >> N >> K;
    LL mc = 0, zc = 0, pc = 0;
    vector<LL> v(N), mi, pl;
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
        if(v[i] < 0) ++mc, mi.pb(v[i]);
        if(v[i] == 0) ++zc;
        if(v[i] > 0) ++pc, pl.pb(v[i]);

    }

    LL minus, zero, plus;
    minus = mc * pc;
    zero = zc * (zc - 1) / 2 + zc * mc + zc * pc;
    plus = pc * pc + mc * mc;
    if(K <= minus) {
        sort(all(mi));
        LL l, r;
        l = -1e18 - 1, r = -1;
        while(r - l > 1) {
            LL m = (r + l) / 2;
            LL cnt = 0;
            for(int i = 0; i < pl.size(); ++i) {
                LL t = (m - pl[i] + 1) / pl[i];
                cnt += upper_bound(all(mi), t) - mi.begin();

            }
            if(cnt >= K) r = m;
            else l = m;
        }
        cout << r << endl;

    } else if(K <= minus + zero) {
        cout << 0 << endl;

    } else {
        K -= (minus + zero);
        for(int i = 0; i < mi.size(); ++i) {
            mi[i] = llabs(mi[i]);

        }
        sort(all(pl));
        sort(all(mi));

        LL l, r;
        l = -1, r = 1e18;
        while(r - l > 1) {
            LL m = (r + l) / 2;
            LL cnt = 0;
            for(int i = 0; i < pl.size(); ++i) {
                LL t = m / pl[i];
                LL tmp = upper_bound(all(pl), t) - pl.begin();
                if(i < tmp) --tmp;
                cnt += tmp;

            }
            for(int i = 0; i < mi.size(); ++i) {
                LL t = m / mi[i];
                LL tmp = upper_bound(all(mi), t) - mi.begin();
                if(i < tmp) --tmp;
                cnt += tmp;

            }

            cnt /= 2;
            if(cnt >= K) r = m;
            else l = m;
        }
        cout << r << endl;
    }
    return 0;
}


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

typedef long long LL;

const int N=500000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}
int Get_inv(int a,int p=mod){return Power(a,p-2,p);}

int n,a[N+9],cnt[N+9];
vector<int>p[N*3+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	scanf("%d",&a[i]);
	cnt[i]=cnt[i-1]+!(a[i]^=a[i-1]);
	p[a[i]].push_back(i);
  }
}

int x[N+9],c[N+9],cx;
int dp[N+9][2],sum[N+9][2];

int Get_dp(int t){
  if (!p[t].size()) return 0;
  for (int vs=p[t].size(),i=0;i<vs;++i){
	int now=cnt[p[t][i]]-cnt[i?p[t][i-1]:0];
	if (now) x[++cx]=0,c[cx]=now;
	if (!cx||now) x[++cx]=1,c[cx]=1;
	else ++c[cx];
	if (i==vs-1&&!a[n]) x[++cx]=0,c[cx]=cnt[n]-cnt[p[t][i]];
  }
  sum[0][0]=dp[0][0]=1;
  for (int i=1;i<=cx;++i){
	dp[i][x[i]]=mul(sum[i-1][x[i]^1],c[i]);
	sum[i][0]=add(dp[i][0],sum[i-1][0]);
	sum[i][1]=add(dp[i][1],sum[i-1][1]);
  }
  int res=sum[cx-1][x[cx]^1];
  for (int i=0;i<=cx;++i) x[i]=c[i]=dp[i][0]=dp[i][1]=sum[i][0]=sum[i][1]=0;
  cx=0;
  return res;
}

int ans;

void Get_ans(){
  if (!a[n]) sadd(ans,Power(2,cnt[n]-1));
  for (int i=1;i<1<<20;++i){
	if (a[n]&&a[n]^i) continue;
	sadd(ans,Get_dp(i));
  }
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 51968