akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include <vector>
#define ll long long int
#define ve vector<ll>
#define vell vector<ll>
#define ve_pa vector<pair<ll,ll> >
#define pb push_back
#define mod 1000000007
#define ld long double 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define mll map<ll,ll>
#define mii map<int,int>
#define m_ve map<ll,vell >
#define min3(x,y,z) min(x,min(y,z))
#define max3(x,y,z) max(x,max(y,z))
#define se second
#define check cout<<"s"
#define checkx(x) cout<<x
#define W(x) while(x--)
#define ld long double
#define popcount(x) __builtin_popcountll(x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define V 6 
using namespace std;
//int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); 
cout.tie(NULL);
string s,t;cin>>s>>t;
int ans=INT_MAX;
for(int i=0;i<=s.size()-t.size();i++)
{
	string x=s.substr(i,t.size());
	int cnt=0;
	for(int j=0;j<t.size();j++)
	{
		if(x[j]!=t[j])
		cnt++;
	}
	ans=min(ans,cnt);
}
cout<<ans;




}
 
 


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
  int T;
  bool know[101][101];
  bool known[101];
  
  while(cin >> T && T){
    memset(know, false, sizeof(know));
    memset(known, true, sizeof(known));
    
    int n, k;
    
    for(int i = 1 ; i <= T ; i++){
      cin >> n;
      for(int j = 0 ; j < n ; j++){
	cin >> k;
	know[i][k] = true;
      }
    }
    
    cin >> n;
    for(int i = 0 ; i < n ; i++){
      cin >> k;
      for(int i = 1 ; i <= T ; i++) known[i] = known[i] & know[i][k];
    }
    
    int ans = -1;
    int num = 0;
    for(int i = 1 ; i <= T ; i++){
      if(known[i]){
	ans = i;
	num++;
      }
    }
    
    if(num >= 2 || num == 0) cout << -1 << endl;
    else cout << ans << endl;
  } 
  return 0;
}

Measured memory_bytes: 876
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 200005

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

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

	int n, k;
	cin >> n >> k;
	cout.precision(15);
	double ans = 0, k2 = 0.5, k1 = 1.0/n;
	int l = 0, m;
	for (int i = 1; i <= n; ++i)
	{
		l = 0;m = i;
		while(m < k)
			m *= 2, l++;
		// cout << l << "\n";
		ans += k1 * pow(k2, l);
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  string S;
  cin >> S;
 
  int N = S.size();
  int n = (N - 1)/2;
  
  string R;
  R = S;
  reverse(R.begin(), R.end());
  string S1 = "                                                                                                                                                                                                   ";
  string S2 = "                                                                                                                                                                                                   ";
  string R1 = "                                                                                                                                                                                                   ";
  string R2 = "                                                                                                                                                                                                   ";
  for(int i = 0; i < n; i++){
  	S1.at(i) = S.at(i);
  }
  int k = 0;
  for(int i = n + 1 ; i < N; i++){
  	S2.at(k) = S.at(i);
    k++;
  }
  for(int i = 0; i < n; i++){
  	R1.at(i) = S1.at(n - i - 1);
  	R2.at(i) = S2.at(n - i - 1);
  }
  
  if(S == R && S1 == R1 && S2 == R2) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

if n <= 111:
    print("111")

elif n <= 222:
    print("222")

elif n <= 333:
    print("333")

elif n <= 444:
    print("444")

elif n <= 555:
    print("555")

elif n <= 666:
    print("666")

elif n <= 777:
    print("777")

elif n <= 888:
    print("888")

else:
    print("999")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    int c[3] = {0};
    REP(i, n){
        if(p[i] <= a) c[0]++;
        else if(p[i] <= b) c[1]++;
        else c[2]++;
    }
    cout << min({c[0], c[1], c[2]}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> h(n);
    rep0(i, n)cin >> h[i];
    --h[0];
    rep1(i, n - 1){
        if(h[i - 1] > h[i]){No; return 0;}
        else if(h[i - 1] < h[i])--h[i];
    }
    Yes;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = [str(''.join(sorted(input()))) for _ in range(N)]

cnt = {}

for s in S:
    if s in cnt.keys():
        cnt[s] += 1
    else:
        cnt[s] = 1

print(sum(map(lambda x: x * (x - 1) // 2, cnt.values())))


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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(n);
    YN(n==3|n==5|n==7);
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ans_num = [set() for _ in range(N)]

for _ in range(M):
    s, c = map(int, input().split())
    ans_num[s-1].add(c)

ans = []
for i,nums in enumerate(ans_num):
    if len(nums) > 1:
        print(-1)
        break
    elif len(nums) == 1:
        t = nums.pop()
        if i == 0 and N > 1 and t == 0:
            print(-1)
            break
        ans.append(str(t))
    else:
        if i == 0 and N > 1:
            ans.append("1")
        else:
            ans.append("0")
else:
    print("".join(ans))
            


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] input1 = new String[N];
        String[] input2 = new String[N];
        for (int i = 0; i <N;i++){
            String s = sc.next();
            input1[i] = s;
            input2[i] = s;
        }
        bubbleSort(input1,N);
        selectionSort(input2,N);
        print(input1,N);
        System.out.println("Stable");
        print(input2,N);
        System.out.println(match(input1,input2) ? "Stable" : "Not stable");


    }

    static boolean match(String[] s1, String[] s2) {
        for (int i = 0; i < s1.length; i++) {
            if (!s1[i].equals(s2[i])) {
                return false;
            }
        }
        return true;
    }
    static void bubbleSort(String[] input ,int N){
        int i,j;
        for (i = 0; input.length > i;i++ ){
            for(j=N-1;j>=i+1;j--){
                if(input[j].charAt(1) <input[j-1].charAt(1)){
                    String bigger = input[j-1];
                    input[j-1] = input[j];
                    input[j] = bigger;
                }
            }
        }
    }
    static void selectionSort(String []input ,int N){
        int i,j,minj;
        for (i=0; i <N; i++){
            minj = i;
            for (j =i; j < N; j++){
                if(input[j].charAt(1) < input[minj].charAt(1)){
                    minj = j;
                }
            }
            if(i != minj) {
                swap(i,minj,input);
            }
        }
    }
    static void swap(int a, int b, String [] input) {
        String tmp = input[a];
        input[a] = input[b];
        input[b] = tmp;
    }
    static void print(String [] input,int N) {
        int k;
        for (k = 0; k < N - 1; k++) {
            System.out.print(input[k] + " ");
        }
        if (k == N - 1) {
            System.out.println(input[k]);
        }
    }
}



Measured memory_bytes: 26324
def readinput():
    s=list(input())
    return s

def main(s):
    n=len(s)
    count=0
    for i in range(n):
        if s[i]=='1':
            count+=1
    return min(count,n-count)*2

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


Measured memory_bytes: 9740
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;
int num[200010];

#define popcount(B) __builtin_popcountll(B)

int mod_pow(int b,int e,int m){
    if(e==0){
        return 1;
    }else{
        int sum = mod_pow(b,e/2,m);
        if(e%2==0){
            return (sum*sum)%m;
        }else{
            return (((sum*sum)%m)*b)%m;
        }
    }
}

int solve(int b){
	int cnt=0;
	while(b!=0){
		b=b%popcount(b);
		cnt++;
	}
	return cnt;
}

signed main(){
	cin>>N>>S;
	int cnt=0;
	REP(i,N){
		if(S[i]=='1'){
			cnt++;
		}
	}
	int sum=0,sum2=0;
	int cnt2=cnt-1;
	if(cnt>1){
		REP(i,N){
			if(S[N-1-i]=='1'){
				sum+=mod_pow(2,i,cnt2);
				sum%=cnt2;
			}
		}
	}
	int cnt3=cnt+1;
	REP(i,N){
		if(S[N-i-1]=='1'){
			sum2+=mod_pow(2,i,cnt3);
			sum2%=cnt3;
		}
	}
	REP(i,N){
		if(S[i]=='1'){
			if(cnt==1){
				cout<<0<<endl;
				continue;
			}
			int e=mod_pow(2,N-1-i,cnt2);
			int b=(sum-e+cnt2)%cnt2;
			cout<<solve(b)+1<<endl;
		}
		else{
			int e=mod_pow(2,N-1-i,cnt3);
			int b=(sum2+e)%cnt3;
			cout<<solve(b)+1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)
const int mod = 1000000007;
class mint {
  long long x;

 public:
  mint(long long n = 0) : x((n % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint& a) { return (*this) *= a.inv(); }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res /= a;
  }

  friend ostream& operator<<(ostream& os, const mint& m) {
    os << m.x;
    return os;
  }
};
int main() {
  int n;
  cin >> n;

  mint ten = 10;
  mint nine = 9;
  mint eight = 8;

  mint ret = ten.pow(n) - nine.pow(n) - nine.pow(n) + eight.pow(n);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
    int n,k;
    cin >> n >>k;
    int tei = 1;
    int kou = 0;
    float sum = 0;

    for(int i=n;i>=1;i--){
        int up=1;
        while(i*tei<k){
            tei*=2;
            up*=2;
        }
        kou *= up;
        kou += 1;
    }
    sum = (kou*1.0)/(tei*n);
    cout << setprecision(12) << (kou*1.0)/(tei*n) << endl;
    //1/nする
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        long A=sc.nextInt();
        long B=sc.nextInt();
        if((A+B)%2==0){
            System.out.println((A+B)/2);
        }else{
            System.out.println("IMPOSSIBLE");

        }







    }
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}


Measured memory_bytes: 25172
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	IOS;
	int s, w;
	cin >> s >> w;
	if(w >= s)
	cout << "unsafe";
	else
	cout << "safe";	
	return 0;
}


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

using namespace std;
typedef long long ll;

int A,B,C,D;

int main(){
    cin >> A >> B >> C >> D;
    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    string S; cin >> S;

    S += "Z";
    int ans = 0;
    int cnt = 0;
    set<char> ACGT = {'A', 'C', 'G', 'T'};
    for (auto s : S) {
        if (ACGT.count(s) == 1) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (auto &x: a) cin >> x;

  vector<bool> dangerous(n+1);
  for (auto &x: a) dangerous[x] = true;

  vector<ll> dp(n+1);
  dp[0] = 1;
  if (!dangerous[1]) dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!dangerous[i]) dp[i] = (dp[i-2] + dp[i-1]) % mod;
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1408
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(M)]
to_halfway = [0]*(N+1)
from_halfway = [0]*(N+1)
for a, b in AB:
    if a == 1:
        to_halfway[b] = 1
    elif b == N:
        from_halfway[a] = 1
for i in range(N+1):
    if to_halfway[i]*from_halfway[i] == 1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 42388
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt p) {
        x = (int)(1LL * x * p.x % M);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t k) const {
        ModInt ret(1), mul(x);
        while(k > 0) {
            if(k) ret *= mul;
            mul *= mul;
            k >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using modint = ModInt<mod>;

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

    string s;
    cin >> s;
    modint dp[2][13];
    dp[0][0] = 1;

    int n = s.size();
    rep(i, n) {
        rep(j, 13) {
            if(s[i] == '?') {
                rep(k, 10) dp[i + 1 & 1][(j * 10 + k) % 13] += dp[i & 1][j];
            } else {
                dp[i + 1 & 1][(j * 10 + s[i] - '0') % 13] += dp[i & 1][j];
            }
        }
        fill(ALL(dp[i & 1]), 0);
    }
    cout << dp[n & 1][5] << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;
    if ( abs(B-A) <=  (V-W)*T) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 3640
//
//  main.cpp
//  E
//
//  Created by 曾憲揚 on 2020/9/7.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

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

const int N=1e5+5;

vector<int> e[N];

bool vis[N];
int dsus=0;

void dfs(int cur){
    vis[cur]=1;
    dsus++;
    for(int nxt:e[cur])
        if(!vis[nxt])
            dfs(nxt);
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n, m;
    cin>>n>>m;
    for(int i=1; i<=m; i++){
        int x, y, z; cin>>x>>y>>z;
        e[x].push_back(y);
        e[y].push_back(x);
    }
    
    int ans = n;
    
    for(int i=1; i<=n; i++){
        if(!vis[i]){
            dsus=0;
            dfs(i);
            ans-=(dsus-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

vector<ll> a[200001];

ll dfs(int s, vector<bool>& vis)
{
    vis[s]=true;
    
    ll cnt=0;
    for(int i=0;i<a[s].size();i++)
    {
        if(!vis[ a[s][i] ])
            cnt+=dfs(a[s][i],vis);
    }
    return cnt+1;
}
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   ll n,m;
   cin>>n>>m;
   
   for(int i=0;i<m;i++)
    {
        ll s,d;
        cin>>s>>d;
        a[s-1].push_back(d-1), a[d-1].push_back(s-1);
    }
    ll ans=-1;
    
    vector<bool> visited(n,false);
    for(int i=0;i<n;i++)
    {
        if(!visited[i])
            ans=max(ans,dfs(i,visited));
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 23956
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)

int main(void){
	int n,a,i;
	ll cnt[123456],ans=0;
	fill(cnt,cnt+123456,0ll);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a;
		cnt[a]++;
		cnt[a+1]++;
		cnt[a+2]++;
	}
	for(i=0; i<123456; ++i){
		ans = max(cnt[i],ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main{
	
	static int mod = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		long k = Long.parseLong(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		
		int []b = new int [n];
		int []c = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = i ; j < n ;j++) {
				if(a[i] > a[j]) {
					b[i]++;
				}
			}
		}
		for(int i = n-1 ; i >= 0 ; i--) {
			for(int j = i ; j >= 0 ; j--) {
				if(a[i] > a[j]) {
					c[i]++;
				}
			}
		}
		
		long p = Modpow(2,mod-2);
		
		long sum1 = (((k *(k+1))%mod)*p)%mod;
		long sum2 = (((k*(k-1))%mod)*p)%mod;
	
		long ans = 0 ;
		for(int i = 0 ; i < n ;i++) {
			ans = (ans + (b[i] * sum1)%mod)%mod;
			ans = (ans + (c[i] * sum2)%mod)%mod;
		}
		
		System.out.println(ans);
	}
	public static long Modpow(long a, long n) {
		long res = 1;
		while(n > 0) {
			if((n & 1) == 1) {
				res = res * a % mod;
			}
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
	
}


Measured memory_bytes: 25044
import java.util.Scanner;

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

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println("a " + ((a > b) ? ">" : (a < b) ? "<" : "==") + " b");
	}
}

Measured memory_bytes: 17164
#include<cstdio>
#define MAX 10000
#define NIL -1
struct Node {int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];
void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 =0,h2 =0;
  if(T[u].left!=NIL)
	h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)
	h2=setHeight(T[u].right)+1;
  return H[u]= (h1>h2 ? h1:h2);
}
int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL)
	return T[T[u].parent].left;
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL)
	return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent ==NIL){
	printf("root\n");
  }else if(T[u].left == NIL && T[u].right ==NIL){
	printf("leaf\n");
  }else{
	printf("internal node\n");
  }
}
int main(){
  int v,l,r,root=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent=NIL;
  for(int i=0;i<n;i++){
	scanf("%d %d %d",&v,&l,&r);
	T[v].left=l;
	T[v].right=r;
	if(l!=NIL) T[l].parent=v;
	if(r!=NIL) T[r].parent=v;
  }
  for(int i=0;i<n;i++) if(T[i].parent==NIL) root=i;
  setDepth(root, 0);
  setHeight(root);
  for(int i=0;i<n;i++) print(i);
  return 0;
}



Measured memory_bytes: 2744
a=1000000,b=-1000000,t;
main(N){
    long long c=0;
    for(scanf("%d",&N);N--;c+=t){
        scanf("%d",&t);
        if(a>t)a=t;
        if(b<t)b=t;
    }
    printf("%d %d %lld\n",a,b,c);
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
#define pii pair<int, int>
typedef unsigned long long uLL;
typedef long long LL;
using namespace std;
constexpr int MAXM = 2e4 + 4;
vector<LL>vec(3);
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> vec[0] >> vec[1] >> vec[2];
	sort(vec.begin(), vec.end());
	if ((vec[0] == vec[1] && vec[1] != vec[2]) || (vec[1] == vec[2] && vec[1] != vec[0])) {
		puts("Yes");
	} else puts("No");
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int w,h,n;
    int a,b,c,d;
    int x,y,z;
    cin >> w >> h >> n;
    a = 0;
    b = w;
    c = 0;
    d = h;
    rep(i,n){
        cin >> x >> y >> z;
        if(z == 1){ 
            if(x > a){ 
                if(x > b) a = b;
                else a = x;
            }
        }
        else if(z == 2){ 
            if(x < b){ 
                if(x < a) b = a;
                else b = x;
            }
        }
        else if(z == 3){ 
            if(y > c){ 
                if(y > d) c = d;
                else c = y;
            }
        }
        else{
            if(y < d){ 
                if(y < c) d = c;
                else d = y;
            }
        }
    }   
    cout << abs(a - b) * abs(c - d) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    ll res = 0;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        res += a - 1;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		sb.setCharAt(5, ' ');
		sb.setCharAt(13, ' ');
		System.out.println(sb);
	}

}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int64_t n, a, b;
  cin >> n >> a >> b;

  int64_t ans;

  ans = (n / (a + b) * a) + min(n % (a + b), a);

  cout << ans << '\n';

  return 0;
}


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

vector<ll> divisor(ll x) {
  vector<ll> res;
  ll i = 1;
  for (; i * i <= x; ++i) {
    if (x % i != 0)
      continue;
    res.push_back(i);
    res.push_back(x / i);
  }
  --i;
  if (i * i == x)
    res.pop_back();
  return res;
}

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

  auto ds = divisor(n);

  ll ans = 0;
  for (int i = 0; i < ds.size(); ++i) {
    ll m = ds[i] - 1;
    if (m > 0 && n / m == n % m)
      ans += m;
  }
  cout << ans << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    cout << N*800 - N/15*200 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7716
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	min := a[0]
	max := a[0]
	total := 0
	for i := 0; i < n; i++ {
		if max < a[i] {
			max = a[i]
		} else if min > a[i] {
			min = a[i]
		}
		total += a[i]
	}
	fmt.Println(min, max, total)
	return
}



Measured memory_bytes: 1768
S = input()
Q = int(input())
t = ''
for i in range(Q):
  instructions = list(map(str, input().split()))
  if instructions[0] == '1':
    S, t = t, S
  else:
    if instructions[1] == '1':
      t += instructions[2]
    else:
      S += instructions[2]
print(t[::-1] + S)

Measured memory_bytes: 4428
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"

def main():
    s = input()
    t = input()

    for i in range(len(s)):
        if s[i] != t[i]:
            print(no)
            exit()
    print(yes)


main()




Measured memory_bytes: 9892
#include <stdio.h>
#include <stdlib.h>
#define N 2000001
#define M 10000

int main(){
  unsigned short *A, *B;

  int C[M+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= M; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= M; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		
		if(str.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
		
}
}


Measured memory_bytes: 35604
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

long long prime[30005];
bool isprime[30005];
int num;
int n, cnt[30005];
long long ans = 1;
const long long mod = 1e9 + 7;

void calc(int x) {
	for (int i = 1; i <= num && prime[i] * prime[i] <= x; i++) {
		while ( !(x % prime[i]) ) {
			x /= prime[i];
			cnt[prime[i]]++;
		}
	}
	if (x > 1) cnt[x]++;
}

int main() {
	cin>>n;
	isprime[1] = true;
	for (int i = 2; i <= n; i++)
		if (!isprime[i]) {
			prime[++num] = i;
			for (int j = i * i; j <= n; j += i)
				isprime[j] = true;
		}
	for (int i = 2; i <= n; i++)
		calc(i);
	for (int i = 1; i <= num; i++)
	    ans = ans * (cnt[prime[i]] + 1ll) % mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		if(n % 2 == 0) {
			int ans = n/2;
			System.out.println(ans);
		}
		else if(n % 2 == 1) {
			int ans = n/2 + 1;
			System.out.println(ans);
		}

		scan.close();

	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int a[maxn], n;
bool judge()
{
    int tot = 0;
    for(int i = 1; i <= n; i++)if(a[i] < 0)
    {
        int cnt = 0, j = i;
        for(; j <= n; j++)if(a[j] < 0)cnt++;else break;
        if(cnt&1)tot++;
        i = j - 1;
    }
    return tot&1;
}
int main()
{
    int flag = 0, minn = 1e9 + 7;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];sum += abs(a[i]);
        minn = min(minn, abs(a[i]));
        if(!a[i])flag = 1;
    }
    if(flag)cout<<sum<<endl;
    else
    {
        if(judge())cout<<sum - 2 * minn<<endl;
        else cout<<sum<<endl;
    }
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam -1];
#define range(n) for(int i = 0; i < n; i++)
#define forn(x, n) for(int x = 0; x < n; x++)
#define maxn "100000"
#define mod "1000000007"
#define md(x) ((((x) % mod) + mod) % mod)
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF INT_MAX
#define INFd 1e9

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

//Trace dinamico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

//DP debug
int recNum = 0;
void prTabs() { range(recNum) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}
int r, g, b, n;
//vector<int> g[maxn]; 
int li[18000010];

int main(){
    sc("%d %d %d %d\n", &r, &g, &b, &n);
    for(int i = 0; i < 3001; i++) {
        for(int j = 0; j < 3001; j++) {
            li[i*r+j*g]++;
        }
    }
    int r = 0;
    for(int i = 0; i < 3001; i++) {
        int t = b*i;
        if (t <= n) {
            r += li[n-t];
        }
    }
    pr("%d\n", r);
	
 	return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int a, b, c;
int main() {
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
	cin >> a >> b >> c;
	if((a * 100 + b * 10 + c) % 4  == 0) {
		cout << "YES";
	} else {

		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
x, y = map(int, input().split())
data = ['', 'a', 'c', 'a', 'b', 'a', 'b', 'a', 'a', 'b', 'a', 'b', 'a']
print('Yes' if data[x] == data[y] else 'No')


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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> q;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        q.push(a);
    }

    for(int i = 0; i < m; i++){
        int a = q.top();
        q.pop();
        q.push(a/2);
    }

    long long ans = 0;

    for(int i = 0; i < n; i++){
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;

ll A, B;

ll calc1(ll a, int bit) {
    if(bit == -1) return 1;
    for(int i = bit; i >= 0; i--) {
        if(a & (1LL << i)) return 2 * (1LL << i);
    }
    return 1;
}
ll calc2(ll a, int bit) {
    if(bit == -1) return 1;
    for(int i = bit; i >= 0; i--) {
        if(a & (1LL << i)) continue;
        return (1LL << i) + calc2(a, i - 1);
    }
    return 1;
}

ll solve3(ll b, int bit) {
    if(bit == -1) return 1;
    if(b >= (1LL << bit)) return solve3(b - (1LL << bit), bit - 1);
    else return solve3(b, bit - 1) + (1LL << bit);
}

ll solve2(ll a, ll b, int bit) {
    if(a + 1 >= b) return (1LL << (bit + 1));
    if(a & (1LL << bit)) return (1LL << (bit + 1));
    if(b < (1LL << bit)) return (1LL << bit) + solve2(a, b, bit - 1);
    return calc1(a, bit) + solve3(b, bit);
}

ll solve1(ll a, ll b, int bit) {
    if(a > b) return 0;
    if(bit == -1) return 1;
    if(a < (1LL << bit) && (1LL << bit) <= b) return solve2(b - (1LL << bit), a, bit - 1) + calc2(a, bit - 1);
    else return solve1(a & ((1LL << bit) - 1), b & ((1LL << bit) - 1), bit - 1);
}

int main() {
    cin >> A >> B;
    cout << solve1(A, B, 60);
}


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

using namespace std;

int main()
{
    string s;
    int k;

    cin >>k >> s;

    if(s.size() > k)
    {
        s.erase(s.begin() + k, s.end());
        cout << s << "...\n";
    }
    else
    {
        cout << s << "\n";
    }

    return 0;
}

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

int js[1000001] = {0};
int os[1000001] = {0};
int is[1000001] = {0};
string s;

const int J_STATE = 0;
const int O_STATE = 1;
const int I_STATE = 2;

int func(int j,int o,int i){
	if(j < o || i < o){
		return 0;
	}
	return o;
}

int main(){
	cin >> s;
	int ans = 0;
	int num_j = 0;
	int num_o = 0;
	int num_i = 0;
	int state = J_STATE;
	for(int i = 0; i < s.size(); i++){
		if(state == J_STATE){
			if(s[i] == 'J'){
				num_j++;
			}
			else if(s[i] == 'O'){
				num_o++;
				state = O_STATE;
			}
			else{ // I
				num_j = 0;
			}
		}
		else if (state == O_STATE){
			if(s[i] == 'O'){
				num_o++;
			}
			else if (s[i] == 'J'){
				num_o = 0;
				num_j = 1;
				state = J_STATE;
			}
			else{ // I
				num_i++;
				state = I_STATE;
			}
		}
		else{ // I_STATE
			if(s[i] == 'I'){
				num_i++;
			}
			else{ // J O
				ans = max(ans,func(num_j,num_o,num_i));
				num_o = 0;
				num_i = 0;
				state = J_STATE;
				if(s[i] == 'J'){
					num_j = 1;
				}
				else{
					num_j = 0;
				}
			}
		}
	}
	if(state == I_STATE){
		ans = max(ans,func(num_j,num_o,num_i));
	}
		
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3988
#include<stdio.h>

#define N 10000
#define Q 500

int main()
{
  int n,q,s[N],t[Q],i=0,j,cnt=0;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++)
    scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0 ; i<q ; i++)
    scanf("%d",&t[i]);

  for(i=0;i<q;i++){ 
      for(j=0;j<n;j++){
	  if(s[j]==t[i]){
	    cnt++;
	    break;
	    }
	}
    }

  printf("%d\n",cnt);

  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int n,l,A[201],sum;
int main(){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++){
		A[i]=l+i-1;
		sum+=A[i];
	}
	int mi=1e9,p;
	for(int i=1;i<=n;i++){
		if(abs(A[i])<mi){
			p=i;
			mi=abs(A[i]);
		}
	}
	sum-=A[p];
	printf("%d\n",sum);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL



int main(int argc, char * argv[]) 
{
	int a, b, c, k;
	int max;
	cin >> a >> b >> c >> k;
	max = a;
	if (b > max) max = b;
	if (c > max) max =c;
	cout << a + b + c + max * (pow(2, k) - 1)<< endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var H1, M1, H2, M2, K int
	fmt.Scan(&H1, &M1, &H2, &M2, &K)
	if M2 > M1 {
		H2--
		M2 += 60
	}
	T := M2 - M1 + (H2-H1)*60
	fmt.Println(max(0, T-K))
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */
int n, m;
mi mp;
void in(){
    cin >> n >> m;
    rep(i,0,n){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }

}

void solve(){
    
    int ans = 0;
    int buy = 0;
    for(auto e : mp){ 
        if(buy + e.second <= m){
            buy += e.second;
            ans += e.second * e.first;
        }else{
            ans += e.first * (m - buy);
            break;
        }
    }

    print(ans);
    


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 6528
import itertools


n = int(input())
p = [i+1 for i in range(n)]
x = list(itertools.permutations(p, n))
q = tuple(map(int, input().split()))
a = x.index(q)
q = tuple(map(int, input().split()))
b = x.index(q)
print(abs(a-b))

Measured memory_bytes: 8052