akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int h,w; cin>>h>>w;
   char c[110][110];
   rep(i,0,h)rep(j,0,w)cin>>c[i][j];
   int dp[110][110];
   rep(i,0,h)rep(j,0,w)dp[i][j]=inf; dp[0][0]=(c[0][0]=='#');
   rep(i,0,h)rep(j,0,w){
      chmin(dp[i+1][j],dp[i][j]+(c[i+1][j]=='#' and c[i][j]=='.'));
      chmin(dp[i][j+1],dp[i][j]+(c[i][j+1]=='#' and c[i][j]=='.'));
   }
   cout<<dp[h-1][w-1]<<endl;
   return 0;
}

Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))

def get_sequence(arr):
    if len(arr) == 0:
        return [], []
    elements = []
    nums = []
    n = 1
    prev = arr[0]
    for c in arr[1:]:
        if c == prev:
            n += 1
        else:
            elements.append(prev)
            nums.append(n)
            prev = c
            n = 1
    elements.append(prev)
    nums.append(n)
    return elements, nums

N = int(input())
S = input()

ele, num = get_sequence(S)
B = S.count('#')
W = N - B

if ele[0] == '#':
    ans = W
    i = 1
else:
    ans = W - num[0]
    i = 2

M = len(num)
cur = ans
while i < M:
    cur += num[i-1]-num[i]
    ans = min(ans,cur)
    i += 2

print(ans)

Measured memory_bytes: 6720
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
int A, B, C;
int main() {
    cin >> A >> B >> C;
    if(A==B&&B==C&&A%2!=0){
        cout << 0 << endl;
        return 0;
    }
    if(A==B&&B==C){
        cout << -1 << endl;
        return 0;
    }
    int cnt=0;
    while(A%2==0&&B%2==0&&C%2==0){
        int half_A = A/2;
        int half_B = B/2;
        int half_C = C/2;
        A = half_B + half_C;
        B = half_A+ half_C;
        C = half_A + half_B;
        cnt++;
    }
    cout << cnt << endl;
    
	return 0;
}


Measured memory_bytes: 256
def solve():
  N, K = [int(i) for i in input().split()]
  H = [int(i) for i in input().split()]
  dp = [0] * N
 
  for i in range(1, N):
    dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(i - K, 0), i))
 
  return dp[N - 1]
 
print(solve())

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

inline int64_t ceiling_div(int64_t a, int64_t b){
  int64_t ans= ((a>=0 && b > 0) || (a<=0 && b < 0)) ? (abs(a)+abs(b)-1)/abs(b)
                                                    : -abs(a)/abs(b);
  return ans;
}

int main(){
  int H,W,N;
  cin >> H >> W >> N;

  int ans= ceiling_div(N, max(H,W));

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N, K;

  scanf("%d %d", &N, &K);

  int i;

  char S[N+10];

  scanf("%s", S);

  int X[N];

  for(i = 0; i < N; i++){
    X[i] = S[i] - 48;
  }

  int count[100005] = {};
  int c = 0, j = 0;

  int ins = X[0];

  for(i = 0; i < N; i++){
    if(ins != X[i]){
      ins = X[i];
      j++;
    }
    count[j]++;
  }
  
  int max = 0;

  i = 0; c = 0; j = 0; ins = 0;
  
  while(count[i] != 0){
    if(j < K){;
      if(i % 2 == X[0]){
        j++;
      }
      ins += count[i];
      if(max < ins) max = ins;
      i++;
    }
    else{
      if(i % 2 == X[0]){
        if(X[0] == 1){
          ins -= count[2 * c] + count[2 * c + 1];
        }
        else{
          if(c != 0) ins -= count[2 * c - 1];
          ins -= count[2 * c];
        }
        c++;
      }
      ins += count[i];
      i++;
      if(max < ins) max = ins;
    }
  }

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

  return 0;
}




Measured memory_bytes: 1024
toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y

getCoin x y n
  | n <= 0 = 0
  | x > y = x + getCoin (x - 1) y (n - 1)
  | otherwise = y + getCoin x (y - 1) (n - 1)

main :: IO ()
main = do
  line <- getLine
  let a = toInt ((words line) !! 0)
      b = toInt ((words line) !! 1)
  print (getCoin a b 2)


Measured memory_bytes: 508
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
mod=10**9+7

def bfs(v):
  child=[0]*n
  next=[v]
  next2=set()
  visited=[-1]*n
  visitct=0
  while len(next)!=0 and visitct!=n:
    for i in range(len(next)):
      if visited[next[i]]==-1:
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            child[next[i]]+=1
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return child

child=bfs(0)
ans=k
for i in range(n):
  if i==0:
    for j in range(k-1,k-1-child[i],-1):
      ans*=j
      ans%=mod
  else:
    for j in range(k-2,k-2-child[i],-1): 
      ans*=j
      ans%=mod
print(ans%mod)

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  cout << max(a + b, max(a - b, a * b)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin>>N>>W;
    int dp[d5];
    //dp[i]:価値iを達成するのに必要な最小の重さ
    for(int i=0;i<d5;i++)dp[i]=inf;
    dp[0]=0;
    for(int i=0;i<N;i++){
        int w,v;
        cin>>w>>v;
        for(int j=d5;j>=0;j--){
            if(dp[j]==inf)continue;
            if(j+v>=d5)continue;
            dp[j+v]=min(dp[j+v],dp[j]+w);
        }
    }
    int res=0;
    for(int i=0;i<d5;i++){
        if(dp[i]<=W)res=max(res,i);
    }
    cout<<res<<endl;
}

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

typedef long long ll;
typedef long double ld;

#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define max(a,b) (a>b ? a : b)
#define min(a,b) (a<=b ? a : b)


#define pb push_back
#define f first
#define s second
const int N=1e5+5;
using namespace std;
int h[N];
int dp[N];
int K;
int solve(int i,int n)
{
    if(i>=n-1)return 0;
    if(dp[i]!=-1)return dp[i];
    int t=abs(h[i]-h[i+1])+solve(i+1,n);
    rep(j,2,K+1)
    {
        if(i+j<n)t=min(abs(h[i]-h[i+j])+solve(i+j,n),t);
    }
    return dp[i]=t;

}
int main()
{
    ios::sync_with_stdio(0);
    memset(dp,-1,sizeof(dp));
    int n;
    cin >> n >> K;
    rep(i,0,n)cin >> h[i];
    cout << solve(0,n) << endl;

    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    LL x=100,n,cnt=0;
    cin >> n;
    while(x < n)
    {
        ++cnt;
        x+=x/100;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <climits>

typedef long long ll;
//const int MOD = pow(10,9)+7;
//const ll LMAX = 100000000000000000;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int main() {

    int N = in();
    
    set<int> st;
    
    int temp;
    unsigned long countCoder=0;
    
    for(auto i = 0; i < N ; i++){
        temp = in();
        
        if(temp >= 3200){
            countCoder++;
            continue;
        }
        
        st.insert(temp/400);
        
    }
    
    
    if (st.size() == 0){
        cout << 1 <<  " " << countCoder << endl;
    }else{
        cout << st.size() <<  " " << st.size() + countCoder << endl;
    }
    
    
    return 0;
    
    
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;


int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int xmin,xmax,ymin,ymax;
  rep(i,n){
    int input;
    cin >> input;
    if(i == 0){
      xmin = input;
      xmax = input;
    }else{
      xmin = min(input,xmin);
      xmax = max(input,xmax);
    }
  }
  rep(i,m){
    int input;
    cin >> input;
    if(i == 0){
      ymin = input;
      ymax = input;
    }else{
      ymin = min(input,ymin);
      ymax = max(input,ymax);
    }
  }

  for(int i = x+1; i <= y;i++){
    if(xmax < i && i <= ymin){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


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

memo=[10**6]*100001
memo[0]=0

for i in range(100001):
    for j in range(1,8):
        if i+6**j>100000:
            continue
        memo[i+6**j]=min(memo[i]+1,memo[i+6**j])
        
    for j in range(1,7):
        if i+9**j>100000:
            continue
        memo[i+9**j]=min(memo[i]+1,memo[i+9**j])
    
    if i!=100000:
        memo[i+1]=min(memo[i]+1,memo[i+1])

print(memo[n])

Measured memory_bytes: 43756
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 

    fast;

    ll n;
    cin>>n;

    cout<<pow(n,3)<<endl;
 
}


Measured memory_bytes: 256
def maxExept(lis):
    data = [0,0,0]
    data[0] = max(lis[1],lis[2])
    data[1] = max(lis[0],lis[2])
    data[2] = max(lis[0],lis[1])
    return data
k = int(input())
grid = []
for i in range(k):
  x = list(map(int,input().split(' ')))
  grid.append(x)
for i in range(len(grid)-2,-1,-1):
    x,y,z = maxExept(grid[i+1])
    grid[i][0] +=x
    grid[i][1] +=y
    grid[i][2] +=z
print(max(grid[0]))    

Measured memory_bytes: 30400
#include "bits/stdc++.h" 
using namespace std; 
#define ll long long
#define MAXN   1000001 
  
// stores smallest prime factor for every number 
ll spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (ll j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 

  
// driver program for above function 
int main() 
{ 
    // precalculating Smallest Prime Factor 
    sieve(); 
    ll f[1000001];
    memset(f, 0,sizeof(f));
    ll n;
    cin>>n;
    ll m=n;
    ll g=0;
    
    while(m--){
        ll x;
        cin>>x;
    
        if(!g)
            g=x;
        else g=  __gcd(x, g); 
        
        if(x==1)
            continue;
            
        map<ll, bool> check;
        while (x != 1) 
        { 
            // cout<<spf[x]<<' ';
            
            if(!check[spf[x]]){
                f[spf[x]]++; 
                check[spf[x]]=1;
            }
            x = x / spf[x];
            
        }
        // cout<<'\n';
    }
    
    
    
    bool f1=1, f2=1;
    
    for(ll i=2;i<1000001;i++){
        //  cout<<f[i]<<' ';
        if(f[i]>1)
            f1=0;
            
        if(f[i]>=n)
            f2=0;
        
    }
    // cout<<f[3]<<'\n';
    // cout<<f1<<' '<<f2<<'\n';
    // cout<<'\n';
    if(f1)
        cout<<"pairwise coprime";
    
    else if(g==1)
        cout<<"setwise coprime";

    else cout<<"not coprime";
    
    
} 

Measured memory_bytes: 19216
L,R = map(int, input().split())
x = L // 2019
y = R // 2019
if y-x>0:
    min=0
else:
    min = 2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            n = (i*j)%2019
            if n<min:
                min= n
print(min)

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

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using Graph = vector<vector<int>>;
inline int in() { int x; cin >> x; return x; }

int counte;
vector<bool> seen;
vector<bool> watch;
vector<int> member;
int answer[100100];
void dfs(const Graph &G, int v) {
  if (!seen[v]) {
    counte++;
    member.push_back(v);
  }
  seen[v] = true;
  watch[v] = true;
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;
    dfs(G, next_v); // 再帰的に探索
  }
}

int main(){
  int N = in(), M = in(), K = in();
  watch.assign(N,false);
  //vector<int> answer(N);
  Graph F(N),B(N);
  REP(i,M) {
    int a = in()-1, b = in()-1;
    F[a].push_back(b);
    F[b].push_back(a);
  }
  REP(i,K) {
    int a = in()-1, b = in()-1;
    B[a].push_back(b);
    B[b].push_back(a);
  }
  REP(i,N) {
    if (watch[i] == 0) {
      counte = 0;
      seen.assign(N,false);
      member.assign(0,0);
      dfs(F,i);
      REP(l,member.size()){
        int counter = 0;
        REP(k,B[member[l]].size()){
          if(seen[B[member[l]][k]] == 1)counter++;
        }
        REP(k,F[member[l]].size()){
          if(seen[F[member[l]][k]] == 1)counter++;
        }
        answer[member[l]] = counte - counter - 1;
      }
    }
  }
  REP(i,N) cout << answer[i] << endl;
}


Measured memory_bytes: 13564
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
    int A,B;
    cin >>A >>B;
    if(A<=5){
        cout << "0"<<endl;
    }
    else if(A<=12){
        cout << B/2<<endl;
    }
    else {
        cout << B<<endl;
    }
 return 0;
}

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

using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b;
  if(a==0||b==0){
    cout << "Zero" << endl;
  }
  else if(a>0){
    cout << "Positive" << endl;
  }
  else if(b<0){
    if((b-a)%2==0){
      cout << "Negative" << endl;
    }
    else{
      cout << "Positive" << endl;
    }
  }
  else{
    cout << "Zero" << endl;
  }
}


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

using namespace std;

int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if (a>b) cout<<0<<endl;
	else if (n==1)
	{
		if (a==b) cout<<1<<endl;
		else cout<<0<<endl;
	}
	else if (n==2)
	{
		cout<<1<<endl;
	}
	else cout<<((n-1)*b+a)-((n-1)*a+b)+1<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int count = 1;

		char[] array = S.toCharArray();
		for (int a = 0; a < N - 1; a++) {
			for (int b = a+1; b < N; b++) {
				if (array[a] == array[b]) {
					break;
				} else {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 27956
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int c = 0;
        for(int i = 0 ; i < n ; i++){
            int a = scanner.nextInt();
            while(a%2 == 0){
                c++;
                a = a/2;
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 33832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vl a(n),b(n),c(n);
    REP(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll ans=-LINF;
    REP(i,2){
        REP(j,2){
            REP(k,2){
                vl t(n);
                REP(l,n){
                    if(i){
                        t[l]+=a[l];
                    }else{
                        t[l]-=a[l];
                    }
                    if(j){
                        t[l]+=b[l];
                    }else{
                        t[l]-=b[l];
                    }
                    if(k){
                        t[l]+=c[l];
                    }else{
                        t[l]-=c[l];
                    }
                }
                ll now=0;
                sort(t.rbegin(),t.rend());
                REP(l,m){
                    now+=t[l];
                }
                chmax(ans,now);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int  solve()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int n;
    cin >> n;
    vi a(n);
    rep(i, n)cin >> a[i];
    vvi b(2, vi(int(pow(10,5))+1, 0));
    for(int i = 0; i<2; i++)
    for(int j = i; j < n; j+=2){
        b[i][a[j]]++;
    }
    int M = int(pow(10, 5))+1;
    int ans=0;
    vi ma(2,0);
    vi ma2(2, 0);
    vi maxj(2, 0);
    vi maxj2(2 ,0);
    
    for(int i=0; i < 2; i++){
        for(int j = 0; j < M; j++){
            if(ma[i] <= b[i][j]){
                
                ma[i] = b[i][j];

                maxj[i] = j;
            } 
        }
    }


    if(maxj[0] == maxj[1]){
            sort(all(b[0]));
            sort(all(b[1]));

            return min(n - ma[0] - b[1][b[1].size() -2], n-ma[1] - b[0][b[0].size() -2]);
        
    }
    return n - ma[0] - ma[1];

}

int main(){
    cout << solve() << "\n";
    return 0;
}

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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int cnt=1,day=1;
        while(true){
            day = cnt*a[i]+1;
            if(day <= d){
                cnt++;
            }
            else{
                break;
            }
        }
        ans += cnt;
    }
    cout << x+ans << endl;

}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc137/tasks/abc137_c

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int main (int argc, char* argv[]) {
	long long n;
	cin >> n;

	long long res = 0;

	unordered_map<string, long long> prevs;
	for (auto i = 0ll; i < n; i++) {
		string current;
		cin >> current;
		sort(current.begin(), current.end());
		auto prevs_itr = prevs.find(current);
		if (prevs_itr == prevs.end()) {
			prevs[current] = 1;
		} else {
			res += (*prevs_itr).second;
			(*prevs_itr).second++;
		}
	}

	cout << res << endl;
}


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

using ll = long long;

int main()
{
    ll a;
    string bs;
    cin >> a >> bs;
    ll b = bs[3]-'0' + (bs[2]-'0')*10 + (bs[0]-'0')*100;
    ll c = a*b;
    c /= 100;
    cout << c;
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back


int main() {
    ll c;
    cin>>c;
    for(ll a=-1000;a<=1000;++a) {
        for(ll b=-1000;b<=1000;++b) {
            if(a*a*a*a*a-b*b*b*b*b==c) return cout<<a<<" "<<b<<endl,0;
        }
    }
}

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

typedef long long lint;
const int maxn = 2000005, mod = (int)1e9 + 7, inv2 = (mod + 1) >> 1;

int n, ans, a[maxn], cnt[maxn], S;
int D[maxn], invD[maxn];
int zero[maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int Pow(int x, int k)
{
	int ret = 1;
	while (k) {
		if (k & 1) ret = (lint)ret * x % mod;
		x = (lint)x * x % mod; k >>= 1;
	}
	return ret;
}

inline void inc(int &a, int b) {a + b >= mod ? a += b - mod : a += b;}
inline void dec(int &a, int b) {a - b >= 0 ? a -= b : a += mod - b;}

struct BIT
{

	int sum[maxn];
	
	void clear() {memset(sum + 1, 0, sizeof(int) * n);}
	void insert(int x, int a)
	{
		while (x <= n) {
			inc(sum[x], a);
			x += x & (-x);
		}
	}
    int query(int x)
	{
		int ret = 0;
		while (x) {
			inc(ret, sum[x]);
			x -= x & (-x);
		}
		return ret;
	}
	
} bit1, bit2;

int main()
{
	n = gi();
	for (int i = 1; i <= n; ++i) a[i] = gi(), ++cnt[a[i]];
	for (int i = n; i >= 1; --i) cnt[i] += cnt[i + 1];
	S = 1;
	for (int i = 1; i <= n; ++i) S = (lint)S * (cnt[i] - (n - i)) % mod;
	if (!S) {puts("0"); return 0;}

	zero[0] = D[0] = 1;
	for (int i = 1; i <= n; ++i) {
		D[i] = (lint)(cnt[i] - (n - i) - 1) * Pow(cnt[i] - (n - i), mod - 2) % mod;
		if (!D[i]) zero[i] = i, D[i] = D[i - 1];
		else zero[i] = zero[i - 1], D[i] = (lint)D[i - 1] * D[i] % mod;
		invD[i] = Pow(D[i], mod - 2);
	}

	for (int i = 1; i <= n; ++i) {
		inc(ans, (lint)(bit1.query(a[i]) - bit1.query(zero[a[i]] - 1) + mod) % mod * S % mod * D[a[i]] % mod * inv2 % mod);
		bit1.insert(a[i], invD[a[i]]);
	}

	bit1.clear();

	for (int i = n; i >= 1; --i) {
		dec(ans, (lint)(bit1.query(a[i] - 1) - bit1.query(zero[a[i]] - 1) + mod) % mod * S % mod * D[a[i]] % mod * inv2 % mod);
		inc(ans, (lint)bit2.query(a[i] - 1) * S % mod);
		bit1.insert(a[i], invD[a[i]]);
		bit2.insert(a[i], 1);
	}

	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 19456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		while (true) {

			int n = sc.nextInt();
			int m = sc.nextInt();

			if(n == 0 && m == 0) {
				break;
			}

			int a[] = new int[n];

			int ans = -1;

			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			for (int i = 0; i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					if (ans < a[i] + a[j] && a[i] + a[j] <= m) {
						ans = a[i] + a[j];
					}
				}
			}

			if (ans == -1) {
				System.out.println("NONE");
			} else {
				System.out.println(ans);
			}

		}

		sc.close();

	}

}


Measured memory_bytes: 49616
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

ll a[105],dp[105][100005],sum[105][100005];//d,n

void add(ll& a, ll b) {
	a += b;
	if (a >= mod)
		a -= mod;
}

ll sub(ll a, ll b) {
	a -= b;
	if (a < 0)
		a += mod;
	return a;
}

int main() {
	ll n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 0; i <= k; i++) {
		sum[0][i] = 1;
	}
	for (int i = 1; i <= n; i++) {

		for (int j = 0; j <= k; j++) {
			if (j - a[i] - 1 >= 0) {
				add(dp[i][j],sub(sum[i - 1][j],sum[i - 1][j - a[i] - 1]));
			}
			else {
				add(dp[i][j],sum[i - 1][j]);
			}
			dp[i][j] %= mod;
			add(sum[i][j],(sum[i][j - 1]+dp[i][j])%mod);
			sum[i][j] %= mod;
		}
	}
	cout << dp[n][k]%mod << endl;
}

Measured memory_bytes: 160000
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int ac=0, wa=0, tle=0, re=0;
    int num=scan.nextInt();
    for(int a=0; a<num; a++){
      String in=scan.next();
      switch(in){
        case "AC":
          ac++;
          break;
        case "WA":
          wa++;
          break;
        case "TLE":
          tle++;
          break;
        case "RE":
          re++;
          break;
      }
    }
    System.out.println("AC x "+ac);
    System.out.println("WA x "+wa);
    System.out.println("TLE x "+tle);
    System.out.println("RE x "+re);
  }
}

Measured memory_bytes: 57584
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll x;
	cin >> x;
	ll a = x / 11, b = x % 11;
	if (b == 0)cout << a * 2 << endl;
	else if (b <= 6)cout << a * 2 + 1 << endl;
	else cout << (a + 1) * 2 << endl;
	ggr
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll x1,y1,x2,y2;
    cin >>x1>>y1>>x2>>y2;
    

    ll x3,y3,x4,y4;

    x3 = x2 - y2+y1;
    y3 = y2 - x1+x2;
    x4 = x1 - y2+y1;
    y4 = y1 - x1+x2; 

    cout << x3<<" "<< y3<<" "<< x4<<" "<< y4 << endl;


    return 0;
    

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll a,b; cin >> a >> b;
  cout << (b-1+a-2)/(a-1) << endl;
}

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

int main() {
    int a,b;
    cin >> a >> b ;
    if ( a < b ) {
    cout << "a < b" << endl;
    }
    else if ( a > b ) {
    cout << "a > b" << endl;
    }
    else if ( a == b ) {
    cout << "a == b" << endl;
    }
    return 0;
}



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

int main() {
	int n;
	cin>>n;
	vector<int>v;
	for(int i=0;i<n;i++){
		int h;
		cin>>h;
		h--;
		v.push_back(h);
	}
	int now=0,c=0;
	for(int i=0;i<n;i++){
		if(now==1){
			cout<<c<<endl;
			return 0;
		}
		if(c>=n){
			cout<<-1<<endl;
			break;
		}
		c++;
		now=v[now];
	}
	cout<<-1<<endl;
	return 0;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=1; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int A, B;
    cin >> A >> B;

    int ans = -1;

    for(float i = 1.0; i < 1010.0; i++){
        if(int(i * 0.08) == A && int(i * 0.1) == B){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int a,b;
	cin>>a>>b;
	int count=0;
	int ans=1;
	while(ans<b)
	{
		ans+=(a-1);
		count++;
		if(ans>=b)
			break;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
import itertools
import copy
A, B, C = map(int,input().split())
K = int(input())
ckList = list(itertools.product([0,1,2], repeat=K))
for i in ckList:
    numList = [copy.copy(A),copy.copy(B),copy.copy(C)]
    for j in i:
        numList[j] *= 2
    if numList[1] > numList[0] and numList[2] > numList[1]:
        print("Yes")
        exit()
print("No")

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

int main(){
    char a;
    cin >> a;

    if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g,i;
	f=10000;
	g=10000;
	for(i=1;i<=3;i++){
		scanf("%d",&a);
		if(f>=a){
			f=a;
		}
	}
	for(i=1;i<=2;i++){
		scanf("%d",&s);
		if(g>=s){
			g=s;
		}
	}
	printf("%d\n",f+g-50);
	return 0;
}

Measured memory_bytes: 1020
def main():
  n, s = map(int, input().split())
  a = [int(x) for x in input().split()]
  mod = 998244353
  
  dp = [[0]*(s+1) for _ in range(n+1)]
  dp[0][0] = 1
  for i in range(1, n+1):
    for j in range(s, -1, -1):
      dp[i][j] += dp[i-1][j]*2
      dp[i][j] %= mod
      if dp[i-1][j] and j+a[i-1] <= s:
        dp[i][j+a[i-1]] += dp[i-1][j]
        dp[i][j+a[i-1]] %= mod

  print(dp[n][s])
  
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 132408
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	int len;
	bool pd=false;
	cin>>s;
	len=s.length()-1;
	for(int a=0;a<=len;a++)
	{
		if(s[a]=='C')
		{
			pd=true;
		}
		else
		{
			if(s[a]=='F'&&pd==true)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var v = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var dic = new Dictionary<int, int>[2];
        dic[0] = new Dictionary<int, int>();
        dic[1] = new Dictionary<int, int>();
        for (var i = 0; i < num; i++)
            if (dic[i % 2].ContainsKey(v[i])) dic[i % 2][v[i]]++;
            else dic[i % 2][v[i]] = 1;
        for (var i = 0; i < 2; i++)
            dic[i] = dic[i].OrderByDescending(p => p.Value).ToDictionary(p => p.Key, p => p.Value);

        var ind0 = 0;
        var ind1 = 0;
        while (true)
        {
            var d0 = dic[0].Skip(ind0).FirstOrDefault();
            var d1 = dic[1].Skip(ind1).FirstOrDefault();
            if (d0.Key != d1.Key)
            {
                WriteLine(num - d0.Value - d1.Value);
                return;
            }
            else if (d0.Value == d1.Value)
            {
                WriteLine(num - d0.Value - Max(dic[0].Skip(ind0 + 1).FirstOrDefault().Value, dic[1].Skip(ind1 + 1).FirstOrDefault().Value));
                return;
            }
            else if (d0.Value > d1.Value)
                ind1++;
            else ind0++;
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

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

int main() {
    int N;
    cin >> N;
    int P[N];
    int Q[N];
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);  
    int count = 0;
    int p_num = 0;
    int q_num = 0;
    do {
        int p = 1;
        int q = 1;
        count++;
        rep(i,N) {
            if(v[i] != P[i]) p = 0; 
            if(v[i] != Q[i]) q = 0; 
        }    
        if(p==1) p_num = count;
        if(q==1) q_num = count;
    } while( next_permutation(v.begin(), v.end()) );  
    cout << abs(p_num-q_num) << endl;  
    return 0;
}

Measured memory_bytes: 256
let () =
    let a = Array.init 5 (fun _ -> Scanf.scanf " %d" (fun i -> i)) in
    let f k =
        if k mod 10 = 0 then 10 else k mod 10
    in
    Array.sort (fun a b -> compare (f a) (f b)) a;
    let rec loop i time =
        if i < 0 then time else
            loop (i - 1) (((time + 9)/10*10) + a.(i))
    in
    loop 4 0 |> Printf.printf "%d\n"

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

int main(){
    int n;cin>>n;
    int flag=1;
    ll ans=1;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    if(n%2==0){
        int check=1;
        for(int i=0;i<n;i+=2){
            ans*=2;ans%=MOD;
            if(check==a[i] & check==a[i+1]) check+=2;
            else flag=0;
        }
    }
    else{
        if(a[0]!=0) flag=0;
        int check=2;
        for(int i=1;i<n;i+=2){
            ans*=2;ans%=MOD;
            if(check==a[i] & check==a[i+1]) check+=2;
            else flag=0;
        }
    }
    if(flag) cout<<ans<<endl;
    else cout<<0<<endl;
}

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

using namespace std;

#define Q int t, q; scanf("%d", &t); for(q=1; q<=t; q++)
typedef long long int lli;
#define pi pair<int, int>

int main()
{
    lli a, b, c;
    cin >> a >> b >> c;

    lli aa = max(0LL, a-c);

    c = max(0LL, c-a);

    lli bb = max(0LL, b-c);

    cout << aa << " " << bb << "\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    ll n,w;
    cin>>n>>w;
    ll dp[n+1][w+1];
    ll wt[n],val[n];
    rep(i,n)
    {
        cin>>wt[i]>>val[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(wt[i-1]<=j)
            dp[i][j]=max(dp[i-1][j-wt[i-1]]+val[i-1],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 82504
import itertools
import bisect

N = int(input())
LS = list(map(int,input().split()))
LS.sort()

ans = 0

for a,b in itertools.combinations(LS,2):
  a,b = min(a,b),max(a,b)
  lo = b - a
  up = a + b
  
  cnt = bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1
  if lo < a:
    cnt -= 1
    
  if cnt <= 0:
    continue
    
  ans += cnt
  
print(ans // 3)



Measured memory_bytes: 75920
#!/usr/bin/env python3
import sys
from itertools import product

def solve(N: int, S: "List[str]"):
    answer = 0
    march_dict = {'M':0,'A':0,'R':0,'C':0,'H':0}
    for i in range(N):
        if march_dict.get(S[i][0]) != None:
            march_dict[S[i][0]] += 1
    values = list(march_dict.values())
    bit_list = product([0,1],repeat=5)

    for bit in bit_list:
        if bit.count(1) == 3:
            a = 1
            for i in range(5):
                if bit[i] == 1:
                    a *= values[i]
            answer += a

    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


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

/** Problem0030 : Sum of Integer **/
int cnt, ans;

void solve(int i, int s, int n)
{
	if (n==0 && s == ans) {
		cnt++;
		return;
	}
	
	if (n==0 || i>9)
		return;
	
	solve(i+1, s+i, n-1);
	solve(i+1, s, n);
}

int main()
{
	int n;
	
	while (1) {
		cnt=0;
		cin >> n >> ans;
		if (n == 0 && ans == 0) break;
		
		solve(0, 0, n);
		cout << cnt << endl;
	}
	return 0;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p[i];

  int c = 0;
  rep(i,n){
    if(p[i] == i+1){
      c++;
      i++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main (){
	int a,b,c,d, t, g;
	cin >> a >> b >> c >> d;
	 t = a*b;
	 g = c*d;
	 if (t>=g){
	 	cout << t << endl;
	 }else {
	 	cout << g << endl;
	 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  string s, t;
  cin >> s >> t;
  ll dp[3100][3100];
  for(int i=0; i<3100; i++) for(int j=0; j<3100; j++) dp[i][j] = 0;
  // dp[i][j]: sのi文字目、tのj文字目まで見た時の最大の共通部分列の数
  // dp[i+1][j+1] = dp[i][j] if s[i+1] != t[j+1]
  //                max(dp[i][j+1], dp[i+1][j]) else  
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<t.size(); j++){
      if(s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
      }
      else {
        dp[i+1][j+1] = max(dp[i][j], dp[i][j+1]);
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
      }
    }
  }
  
  int a = s.size();
  int b = t.size();

  string ret = "";
  while(a>0 && b>0){
    if(dp[a][b] == dp[a][b-1]) b--;
    else if(dp[a][b] == dp[a-1][b]) a--;
    
    else if(dp[a][b] == dp[a-1][b-1] +1){
      ret = t[b-1] + ret;
      a--; b--;
    }
  }
  
  cout << ret << endl;
  return 0;
}


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

map < string , int> m1;
int main() {
     int n , m ; 
    string x ; 
    cin >> n  ;
    for ( int i = 0 ; i < n ;++i){
          cin >> x ;
          m1 [ x ]++; 
    }
    cin >> m ;
    for ( int i = 0 ;  i < m ;++i){
        cin >> x ;  
        m1 [ x ]--; 
    }
    int ans = 0 ; 
    //cout << m1["apple" ] << endl;
    for ( auto vl : m1 ){
          ans = max (ans , vl.second ) ; 
    }
    cout << ans  ; 
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  for(int i=0;i<a+b+1;++i){
    if(i!=a){
      if(s[i]<'0' || s[i]>'9'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i]!='-'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a.back() - a.front() << endl;
    return 0;
}

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, X; cin >> N >> X;
    if(N==1){
        int X0; cin >> X0;
        cout << abs(X0-X) << endl;
        return 0;
    }
    
    vector<int> vX(N+1);
    for(int i=0; i<N; ++i){ cin >> vX[i]; }
    vX[N] = X;
    sort(vX.begin(), vX.end());
    /*
    vector<int> vX(N+1);
    for(int i=0; i<N+1; ++i){
        int tmp; cin >> tmp;
        if(tmp>X){
            vX[i] = X; ++i;
            vX[i] = tmp;
            X = INT_MAX;
            continue;
        }
        vX[i] = tmp;
    }
    if(X!=INT_MAX){ vX[N]=X; }
    //*/
    
    int64 gcd_val=gcd(vX[1]-vX[0], vX[2]-vX[1]);
    for(int i=3; i<N; ++i){
        gcd_val = gcd(vX[i]-vX[i-1], gcd_val);
    }
    cout << gcd_val << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>  
#include <algorithm>
using namespace std;  
int main() { 	
	int a,b,c;
	int d;
	scanf("%d %d %d %d", &a, &b, &c, &d);

		if(abs(a-c)<=d){
			printf("Yes");
		}
		
	
	else if(abs(a-b)<=d && abs(b-c)<=d){
		printf("Yes");
	}
	else{
		printf("No");
	}
	
}






Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
 
 
long long N, K;
 
long long solve() {
    long long res = 0;
    for (long long b = K+1; b <= N; ++b) {
        long long tmp = min(b-1, b-K);
        long long A = N - (b-1);
        long long B = N-K;
        long long add = (A/b) * (b - K);
        if (B/b == A/b + 1) add += (B%b) + 1;
        tmp += add;
        res += tmp;
    }
    return res;
}
 
int main() {
    while (cin >> N >> K) {
        cout << solve() << endl;
    }
}
 
 

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

 long int n,a[10000000];
int main()
{
	long int MIN = 10000000,MAX = -10000000,total = 0;

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		total += a[i];
		MIN = min(MIN,a[i]);
		MAX = max(MAX,a[i]);
	}

	cout << MIN << " " << MAX << " " << total << endl;

	return 0;
}

Measured memory_bytes: 1244