akhauriyash/Code-Regression huggingface dataset:
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def isPrime(n):
    if n <= 2:
        return 0

    m = (n + 1) // 2
    n_sqrt = int(math.sqrt(n))
    for i in range(2, n_sqrt + 1):
        if n % i == 0 or m % i == 0:
            return 0
    else:
        return 1

def main():
    Q = int(input())
    lr = [tuple(map(int, input().split())) for _ in range(Q)]

    MAX = 10 ** 5
    prime = [0] * MAX
    for i in range(1, MAX):
        prime[i] = prime[i-1] + isPrime(i)
    for i in lr:
        l, r = i
        if prime[l] != prime[l-1]:
            print(prime[r] - prime[l]+1)
        else:
            print(prime[r] - prime[l])
if __name__ == '__main__':
    main()

Measured memory_bytes: 20316
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
template<class T> inline void chmin(T& a,T b){ if(a>b) a=b;}
const ll INF=1LL<<60;

int main(void){
  int h,n; cin>>h>>n;
  vector<int> a(n),b(n);
  for(int i=0; i<n; ++i) cin>>a[i]>>b[i];
  vector<vector<ll>> dp(n+1,vector<ll>(h+1,INF));
  dp[0][0]=0;
  for(int i=0; i<n; ++i)
    for(int j=0; j<=h; ++j){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][min(j+a[i],h)],dp[i+1][j]+b[i]);
    }
  cout<<dp[n][h];
  return 0;
}

Measured memory_bytes: 81632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll k,sum = 0;
cin >> k;

for(int i = 1;i < k+1;i++){
    for(int j = 1;j < k+1;j++){
        for(int l = 1;l < k+1;l++){
            sum += gcd(i,gcd(j,l));
        }
    }
}
cout << sum << endl;


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

Measured memory_bytes: 3664
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int r,ord[100010],low[100010];
void cdfs(int s,int *ta,int *to,int *nt,int *p){//printf("s%d %d\n",s,r);
  int i;
  ord[s]=low[s]=r++;
  for(i=ta[s];i+1;i=nt[i]){
    if(p[to[i]]==-1){
      p[to[i]]=s;
      cdfs(to[i],ta,to,nt,p);
      low[s]=MIN(low[s],low[to[i]]);
    }
    else if(to[i]-p[s])low[s]=MIN(low[s],ord[to[i]]);
  }
}
void arpo(int v,int e,int *a,int *b){
  int ta[100010],to[100010],nt[100010],p[100010],ans=0,c=0,i,j,f[100010]={0};
  for(i=0;i<v;i++)ta[i]=p[i]=-1;
  for(p[0]=i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ta[b[ta[a[i]]=i]]=i+e;
  }
  cdfs(0,ta,to,nt,p);
  for(i=1;i<v;i++){
    if(p[i]){
      if(ord[p[i]]<=low[i])f[p[i]]=1;
    }
    else c++;
  }
  if(c>1)f[0]=1;
  for(i=0;i<v;i++){
    if(f[i])printf("%d\n",i);
  }
}
int main(){
  int v,e,m,i,a[100010],b[100010],c[100010],d[100010];
  scanf("%d %d",&v,&e);
  for(i=0;i<e;i++)scanf("%d %d",&a[i],&b[i]);
  arpo(v,e,a,b);
  return 0;
}

Measured memory_bytes: 3096
h, w = list(map(int, raw_input().split()))
grid = [raw_input() for _ in range(h)]

cnt = [[0]*w for _ in range(h)]

yStarts = [-1] * w
yStrks = [0] * w

for y in range(h):
    xStart = -1
    xStrk = 0

    for x in range(w):
        if grid[y][x] == ".":
            if xStart == -1:
                xStart = x
            xStrk += 1

            if yStarts[x] == -1:
                yStarts[x] = y
            yStrks[x] += 1

        if grid[y][x] == "#" or x == w-1:
            if xStart != -1:
                xEnd = x if grid[y][x] == "." else x-1

                for x2 in range(xStart, xEnd+1):
                    cnt[y][x2] += (xEnd-xStart)+1

            xStart = -1
            xStrk = 0

        if grid[y][x] == "#" or y == h-1:
            if yStarts[x] != -1:
                yEnd = y if grid[y][x] == "." else y-1

                for y2 in range(yStarts[x], yEnd+1):
                    cnt[y2][x] += (yEnd-yStarts[x])+1

            yStarts[x] = -1
            yStrks[x] = 0

ans = 0
for y in range(h):
    for x in range(w):
        ans = max(ans, cnt[y][x]-1)

print(ans)


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

void solve(long long N, long long K, std::vector<long long> p) {
    sort(p.begin(), p.end());
    ll ans = 0;
    rep(i, K) { ans += p[i]; }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3688
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	m := map[int]int{}

	for i := 0; i < len(s); i++ {
		tmp := s[i]
		m[int(tmp)]++
		if m[int(tmp)] >= 2 {
			fmt.Println("no")
			return
		}
	}
	fmt.Println("yes")
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
    cin.tie(0);
	long long n,k;
	cin>>n>>k;
	vector<long long>a(n),f(n);
	for(auto& i : a)
	{
		cin>>i;
	}
	for(auto& i : f)
	{
		cin>>i;
	}
	sort(a.begin(),a.end(),[&](auto& i,auto& j){return i>j;});
	sort(f.begin(),f.end());
	long long lo=-1,hi=a[0]*f.back();
	while(hi-lo>1)
	{
		long long mid=(hi+lo)/2;
		long long req=0;
		for(int i=0;i<n;i++)
		{
			req+=max(0LL,a[i]-(mid/f[i]));
		}
		if(req<=k)
		{
			hi=mid;
		}
		else
		{
			lo=mid;
		}
	}
	cout<<hi;
	
	
	
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<long  long> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	const long long MOD = 1000000000 + 7;
	vector<long  long> acc( N + 1 );
	for( int i = 0; i < N; i++ ) {
		acc[i + 1] = acc[i] + A[i];
		acc[i + 1] %= MOD;
	}
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans += A[i] * ((acc[N] - acc[i + 1] + MOD) % MOD) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll a[N],sum=0;
    rep(0,i,N){
        cin>>a[i];
        sum+=a[i];
    }
    ll sum0=0;
    rep(1,i,N-1){
        if(i%2==1)sum0+=a[i];
    }
    ll A=sum-2*sum0;
    cout<<A<<" ";
    rep(0,i,N-1){
        A=2*a[i]-A;
        if(i!=N-2)cout<<A<<" ";
        else cout<<A<<endl;
    }
    return 0;
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if (op.equals("+")) {
                System.out.println((a + b));
            } else if (op.equals("-")) {
                System.out.println((a - b));
            } else if (op.equals("*")) {
                System.out.println((a * b));
            } else if (op.equals("/")) {
                System.out.println((a / b));
            } else {
                break;
            }
        }
    }
}


Measured memory_bytes: 26320
l = input()
MOD = 10**9 + 7
dp1 = [0]*(len(l)+1)#l以下が確定してる
dp2 = [0]*(len(l)+1)#l以下が確定してない
num = l.count("1")
dp1[0]=1
dp2[0]=0
for i in range(1,len(l)+1):
    if(l[i-1]=="1"):
        dp1[i] = 2*dp1[i-1]%MOD
        dp2[i] = ((3*dp2[i-1])+dp1[i-1])%MOD
    else:
        dp1[i] = dp1[i-1]%MOD
        dp2[i] = 3*dp2[i-1]%MOD
print((dp1[-1]+dp2[-1])%MOD)


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

template <int MOD>
struct ModInt {
    using lint = long long;
    using mint = ModInt<MOD>;

    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            int u = s - t * div;
            mint ux = sx - tx * div;
            mint uy = sy - ty * div;

            s = t;
            sx = tx;
            sy = ty;
            t = u;
            tx = ux;
            ty = uy;
        }
        // t == 1 (since val and MOD is coprime)
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

int main() {
    int n, m;
    {
        std::string s;
        std::cin >> n >> s;
        m = s.length();
    }

    std::vector<mint> dp(n + 2, 0), ndp(n + 2);
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        std::fill(ndp.begin(), ndp.end(), 0);
        for (int k = 0; k <= i; ++k) {
            ndp[k] += dp[k + 1];
            if (k > 0) {
                ndp[k] += dp[k - 1] * 2;
            } else {
                ndp[k] += dp[0];
            }
        }
        std::swap(dp, ndp);
    }

    std::cout << dp[m] / ipow(mint(2), m) << std::endl;
    return 0;
}


Measured memory_bytes: 256
////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pii> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=3e5+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;
set<ll>Set;
ll sum[maX],ans[maX];
stack<ll>Stack;
deque<string>DQ1,DQ2;
 ll one[64],zero[64];
void solve(ll casses)
{
    ll n,i,j,cc=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++)cin>>ara[i];
    for(ll musk=0;musk<60;musk++){
        for(i=0;i<n;i++){
            if(checkbit(ara[i],musk))one[musk]++;
            else zero[musk]++;
        }
    }
    ll ans=0;
    ll m=1e9+7;
    for(i=0;i<60;i++){
        ll x=pow(2,i);
        x%=m;
        ll y=(one[i]*zero[i])%m;
        ans+=(x*y)%m;
        ans%=m;
    }
    cout<<ans<<endl;
}
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
int main()
{
    ll test;
    test=1;
    //scanf("%lld",&test);
    ll casses=1;
    while(test--){
    solve(casses);casses++;
    }

return 0;
}
/*
6 8
1 2 3
1 3 7
2 4 7
3 4 2
3 5 3
5 4 5
5 6 11
4 6 3
*/



Measured memory_bytes: 2560
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){

  int T,A,B;
  cin>>T>>A>>B;
  cout<<((T*A)<B ? T*A : B );
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



int n,m;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n >> m;
  vector<vector<int>> to(n);
  REP(i,m){
  	int s,t;
  	cin >> s >> t;
  	s--;t--;
  	to[s].push_back(t);
  }
  vector<double> dp(n);
  for(int v = n - 2; v >= 0; v--){
  	double now = 0;
  	for(int u : to[v]){
  		now+= dp[u];
  	}
  	now /= to[v].size();
  	now += 1;
  	dp[v] = now;
  }

  double ans = dp[0];
  for(int nv = 0; nv < n-1; nv++){
  	if(to[nv].size() == 1){
  		continue;
  	}
  	int nu = to[nv][0];
  	for(int u : to[nv]){
  		if(dp[nu] < dp[u]){
  			nu = u;
  		}
  	}
  	double now = [&]{
  		vector<double> dp(n);
		for(int v = n - 2; v >= 0; v--){
			double now = 0;
			for(int u : to[v]){
				if(v == nv && u == nu){
					continue;
				}
				now+= dp[u];
			}
			int deg = to[v].size();
			if(v == nv){
				deg--;
			}
			now /= deg;
			now += 1;
			dp[v] = now;
		}
		return dp[0];
  	}();
  	ans = min(ans,now);
  }

  cout << setprecision(10) << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        String s = in.next();
        int a[] = new int[26];
        for(int i=0;i<4;i++){
            a[s.charAt(i)-'A']++;
        }int f=0;
        for(int i=0;i<26;i++) if(a[i]!=0 && a[i]!=2) f=1;
        out.println(f==0?"Yes":"No");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            a = Int32.Parse( Console.ReadLine());
            switch (a%10)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    Console.WriteLine("hon");
                    break;

                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 27484
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC
typedef long long ll;
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> b(n - 1);

	ll ans = 0;
	for (int i = 0; i < n-1; i++) {
		cin >> b[i];
	}

	for (int i = 1; i < n-1; i++) {
		ans += min(b.at(i - 1), b.at(i));
	}
	ans += b[0];
	ans += b[n - 2];

	cout << ans;

		return 0;
}









Measured memory_bytes: 384
using System;
    class Program
    {
      static int[] a = new int[100001];
      static long sum;
      static void Main()
      {
        int n = int.Parse(Console.ReadLine());
        var _line = Console.ReadLine().Split(" ");
        for (int i = 0; i < n; i++)
        {
          int num = int.Parse(_line[i]);
          sum += num;
          a[num]++;
        }
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
          _line = Console.ReadLine().Split(" ");
          int b = int.Parse(_line[0]);
          int c = int.Parse(_line[1]);
          sum += (c - b) * a[b];
          Console.WriteLine(sum);
          a[c] += a[b];
          a[b] = 0;
        }
      }
    }

Measured memory_bytes: 49796
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            long[] x = new long[n];
            long[] y = new long[m];
            ModInt xx = new ModInt(0);
            ModInt yy = new ModInt(0);
            for (int i = 0; i < n; i++) {
                x[i] = in.nextLong();
            }
            for (int i = 0; i < m; i++) {
                y[i] = in.nextLong();
            }
            Arrays.sort(x);
            Arrays.sort(y);
            for (int i = 0; i < n; i++) {
                xx = xx.add(x[i] * (-n + 1 + i * 2));
            }
            for (int i = 0; i < m; i++) {
                yy = yy.add(y[i] * (-m + 1 + i * 2));
            }
            out.println(xx.mul(yy).getVal());

        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (int) ((i + MOD) % MOD);
        }

        public ModInt add(long l) {
            return new ModInt(this.val + l);
        }

        public ModInt mul(ModInt m) {
            return new ModInt(this.val * m.getVal());
        }

        public long getVal() {
            return val;
        }

    }
}



Measured memory_bytes: 91576
c,t,d[4010]={1};main(j){for(;t+=(j=getchar())>10?c+=j%3,2:0;d[j]=!t--)for(j=c;j>c-t&&~j;d[j--]%=998244353)d[j]+=d[j-1];printf("%d",d[c]);}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String x = sc.next();
		String y = sc.next();
		
		if((x.charAt(0) == y.charAt(2)) && (x.charAt(1) == y.charAt(1)) && (x.charAt(2) == y.charAt(0))) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 23252
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,y;
    cin >> n >> y;
    int sen = y/1000;
    if(sen<n){
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    int r = sen-n;
    for(int g = 0;g*4<=r;++g){
        if((r-4*g)%9==0){
            if(n-(r-4*g)/9-g>=0){
                printf("%d %d %d\n", (r-4*g)/9, g, n-(r-4*g)/9-g);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>



int main() {
	int N;
	scanf("%d", &N);
	int *W = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &W[i]);
	}
	int res = 0x7fffffff;
	for (int t = 0; t < N ; t++) {
		int s1 = 0, s2 = 0;
		for (int i = 0; i < N; i++) {
			if (i < t) {
				s1 += W[i];
			}
			else {
				s2 += W[i];
			}
		}
		if (abs(s1 - s2) < res) {
			res = abs(s1 - s2);
		}
	}
	printf("%d", res);
}



Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int height = 0;
	static int weight = 0;

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		boolean zeroFlag = true;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		while (zeroFlag) {
			String[] nyuryokuStr = line.split("[\\s]+");
			height = Integer.parseInt(nyuryokuStr[0]);
			weight = Integer.parseInt(nyuryokuStr[1]);
			if (height == 0 && weight == 0) {
				zeroFlag = false;
			} else {
				for (int h = 0; h < height; h++) {
					for (int w = 0; w < weight; w++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
			line = br.readLine();
		}
	}
}

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

int main(){
  int n; cin>>n;
  long long sum=0,sunuke=0,min=-1;
  int card[n];
  for(int i=0;i<n;i++){
    cin>>card[i];
    sum+=card[i];
  }
  for(int i=0;i<n-1;i++){
    sunuke+=card[i];
    if(min==-1 || min>abs(sunuke-(sum-sunuke))){
      min=abs(sunuke-(sum-sunuke));
    }
  } 
  cout<<min<<endl;
  return 0;
}

    


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var cinfo = new List<Tuple<long, long, long, string>>();//index,県(P),誕生年(Y),認識番号
            for (var i = 0L; i < M; ++i)
            {
                var py = Sarray();
                var p = py[0];
                var y = py[1];
                cinfo.Add(Tuple.Create(i, p, y, string.Empty));
            }
            cinfo.Sort((l, r) => (int)(l.Item3 - r.Item3));
            var cg = cinfo.GroupBy(c => c.Item2).ToList();
            var scinfo = new List<Tuple<long, long, long, string>>();
            for(var i=0;i<cg.Count();++i)
            {
                var num = 1;
                foreach (var c in cg[i])
                {
                    scinfo.Add(Tuple.Create(c.Item1,c.Item2,c.Item3,$"{c.Item2:d6}{num:d6}"));
                    num++;
                }
            }
            scinfo.Sort((l, r) => (int)(l.Item1 - r.Item1));
            foreach (var s in scinfo)
                WriteLine(s.Item4);
            Out.Flush();
        }
    }
}

Measured memory_bytes: 46108
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    if(n==1){
        printf("0\n");
        return 0;
    }
    rep(i,1,(ll)sqrt(n)+1){
        if(n%i==0){
            ll m=n/i-1;
            if(n/m==n%m){
                ans+=m;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<bool> ok(n+1);
  REP(i,n+1) cin >> a[i];
  int cnt = 1;
  int now = 1;
  while(1){
    if(ok[now]){
      cout << -1 << endl;
      return 0;
    }
    if(a[now] == 2){
      cout << cnt << endl;
      return 0;
    }
    ok[now] = true;
    cnt++;
    now = a[now];
  }
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'

const int N = 7;
string s[N];
// try all possible states
// bitmasking solution: masks for row and columns

int32_t main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(nullptr), cout.tie(nullptr);
    
    int n, m , k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) cin >> s[i];
    int choices = 0;
    for (int msk1 = 0; msk1 < (1 << n); msk1++) {
        for (int msk2 = 0; msk2 < (1 << m); msk2++) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    bool row_set = msk1 & (1 << i);
                    bool col_set = msk2 & (1 << j);
                    if (row_set || col_set) continue;
                    cnt += s[i][j] == '#';
                }
            }
            choices += cnt == k;
        }
    }
    cout << choices << endl;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int calc(string s) {
    int diff = 0;
    for(int i = 0; i < s.length()-1; i++) {
        if(s[i] != s[i+1])
            diff++;
    }
    return s.length() - diff-1;
}

int main() {
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int diff = 0;
    for(int i = 0; i < n-1; i++) {
        if(s[i] != s[i+1])
            diff++;
    }
    if(diff/2 + 1 <= k) {
        cout << s.length() - 1 << endl;
        return 0;
    }
    cout << s.length()- diff + 2*k -1<< endl;
}


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

int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> vec(m);
  int tem;
  int sum = 0;
  int cou = 0;
  for(int i = 0; i < m; i++)
    cin >> vec.at(i);
  for(int i = 0; i < n; i++) {
    sum = c;
    for(int j = 0; j < m; j++) {
      cin >> tem;
      sum += tem * vec.at(j);
    }
    if(sum > 0)
      cou++;
  }
  cout << cou << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long int w,h,x,y;
	cin >> w >> h >> x >> y;
	double ans;
	ans = (double)w*h/2;
	int flag=0;
	if(w%2==0 && h%2==0){
		if(x*2==w && y*2==h){
			flag=1;
		}else{
			flag=0;
		}
	}else{
		flag=0;
	}
	printf("%lf %d\n",ans,flag);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SQ(a) (a)*(a)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long int 
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int a, b, c;
	vector<int> freq(10, 0);
	cin >> a >> b >> c;
	freq[a]++;
	freq[b]++;
	freq[c]++;
	if (freq[5] == 2 && freq[7] == 1)
		cout << "YES\n";
	else 
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            if(A[i] == 0){
                System.out.println("0");
                return;
            }
        }
        long ans=1;
        for(int i=0;i<N;i++){
            BigInteger a = new BigInteger(String.valueOf(A[i]));
            BigInteger ansn = new BigInteger(String.valueOf(ans));
            if(a.multiply(ansn).compareTo(new BigInteger("1000000000000000000")) > 0){
                System.out.println("-1");
                return;
            }
            ans *= A[i];
        }
        System.out.println(ans);
    }
}


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

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

while(true) {
    int a = scan.nextInt();
    char op = scan.next().charAt(0);
    int b = scan.nextInt();

    if (op == '?'){
      break;
    } else if (op == '+'){
      System.out.println(a + b);
    } else  if (op == '-'){
      System.out.println(a - b);
    } else  if (op == '*'){
      System.out.println(a * b);
    } else  if (op == '/'){
      System.out.println(a / b);
    }
    }
  }
}

Measured memory_bytes: 26224
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    int n;
    
    cin>>n;
    
    cout<<n*n*n<<endl;
    
    return 0;
}


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

int main(){
	int x,h;
	while (cin>>x>>h,x!=0||h!=0) cout<<fixed<<setprecision(6)<<x*x+2*x*sqrt(x*x*.25+h*h)<<endl;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
 
  long long n, ans = 0;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<vector<ll> > ruiseki(n + 1, vector<ll>(60, 0) );
  long long bitmax = 0;
  for(int i = 0; i < n; i++){
    long long tmp = a[i], cnt = 0;
    for(int j = 0; j < 60; j++){
      ruiseki[i + 1][j] += ruiseki[i][j] + tmp % 2;
      if(tmp) cnt++;
      tmp /= 2;
    }
    bitmax = max(bitmax, cnt);
  }
  for(int i = 0; i < n - 1; i++){
    for(int j = 0; j < bitmax; j++){
      if(ruiseki[i + 1][j] == ruiseki[i][j]){
        ans += (ruiseki[n][j] - ruiseki[i + 1][j]) * ((1ll << j) % mod);
      }else{
        ans += ((n - ruiseki[n][j]) - (i + 1 - ruiseki[i + 1][j])) % mod * ((1ll << j) % mod);
      }
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 155008
fun main(args: Array<String>) {

    val a = readLine()!!

    println(abc141a(a))
}

fun abc141a(a: String): Any? {

     return when (a) {

         "Sunny" -> "Cloudy"
         "Cloudy" -> "Rainy"
         "Rainy" -> "Sunny"

         else -> ""
     }

}


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

int main() {
    int x, a;  cin >> x >> a;
    if (x < a)  cout << 0 << endl;
    else  cout << 10 << endl;
}

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

def prime_division(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        if cnt != 0:
            res.append([i, cnt])
    if n != 1:
        res.append([n, 1])
    return res

for i in prime_division(n):
    n *= 1 - (1 / i[0])

print(int(n))



Measured memory_bytes: 5640
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

int main(){
	string input;
	bool lastMonth[10000];
	bool thisMonth[10000];
	int count[10000];

	fill(lastMonth, lastMonth+10000, false);
	fill(thisMonth, thisMonth+10000, false);
	fill(count, count+10000, 0);

	while(1){
		getline(cin, input);
		if(input.size() == 0) break;
		input[input.find(",", 0)] = '\0';
		lastMonth[atoi(input.c_str())] = true;
		count[atoi(input.c_str())]++;
	}
	while(cin >> input){
		input[input.find(",", 0)]  = '\0';
		thisMonth[atoi(input.c_str())] = true;
		count[atoi(input.c_str())]++;
	}
	for(int i=0; i < 10000; i++){
		if(lastMonth[i] && thisMonth[i]) cout << i << " " << count[i] << endl;
	}
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  std::map<std::pair<int, int>, int> m;
  m[{0, 0}] = 0;

  for (int i = 0; i < n; i++) {
    std::map<std::pair<int, int>, int> t;
    int a, b, c;
    std::cin >> a >> b >> c;
    for (const auto &i : m) {
      const std::pair<int, int> v = {i.first.first + a, i.first.second + b};
      const auto w = i.second + c;
      if (t.find(v) != t.cend() && t[v] < w) {
      } else {
        t[v] = w;
      }
    }
    for (const auto &i : t) {
      if (m.find(i.first) != m.cend() && m[i.first] < i.second) {
      } else {
        m[i.first] = i.second;
      }
    }
  }

  int val = 50000;
  for (int i = 1; i * a <= 10 * n && i * b <= 10 * n; i++) {
    if (m.find({i * a, i * b}) != m.cend()) {
      val = std::min(val, m[{i * a, i * b}]);
    }
  }

  if (val == 50000) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << val << std::endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int> VI;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << ((A==B && B==C) ? "Yes" : "No") << endl;
}

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

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    vector<P> input(n);
    for(int i = 0; i < n; ++i)  cin >> input[i].first >> input[i].second;
    sort(input.begin(), input.end());
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        int a = input[i].first, b = input[i].second;
        if(m > b){
            ans += (ll)a * b;
            m -= b;
        }
        else{
            ans += (ll)a * m;
            break;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    long long int n,ans=0;
    cin >> n;
    if(n==1){
        cout << 0;
    }
    else{
        ans =(long long) (n)*(n-1)/2;
        cout << ans;
    }



return 0;
}

Measured memory_bytes: 256
k = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])


Measured memory_bytes: 15784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", (a+b)%24);

    return 0;
}


Measured memory_bytes: 128
n,k = map(int, input().split())

s = {i:0 for i in range(n+1)} 

for i in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  for i in a:
    s[i] += 1

cnt = -1

for i in s:
  if s[i] == 0:
    cnt +=1

print(cnt)



Measured memory_bytes: 9120