akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

int n;
int k;
int zeros;
vector < int > pos , neg , all;

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        int x;
        scanf("%d" , &x);
        all.push_back(abs(x));
        if(x < 0){
            neg.push_back(-x);
        }
        if(x > 0){
            pos.push_back(x);
        }
        if(x == 0)
            zeros++;
    }
    long long mul = 1;
    int p = pos.size() , ne = neg.size();
    if(p + ne/2*2 >= k && (k % 2 == 0 || p > 0)){
        sort(pos.rbegin() , pos.rend());
        sort(neg.rbegin() , neg.rend());
        if(k & 1){
            mul = pos[0];
        }
        vector < long long > pp;
        for(int i = k&1; i+1 < pos.size(); i += 2){
            pp.push_back(1LL * pos[i] * pos[i + 1]);
        }
        for(int j = 0; j+1 < neg.size(); j += 2){
            pp.push_back(1LL * neg[j] * neg[j + 1]);
        }
        sort(pp.rbegin() , pp.rend());
        for(int i = 0; i < k/2; i++){
            pp[i] %= mod;
            mul = (mul * pp[i]) % mod;
        }
    } else {
        //you can't make value +ve
        //so it must be non-positive value.
        sort(all.begin() , all.end());
        for(int i = 0; i < k; i++){
            mul = (mul * all[i]) % mod;
        }
        mul = (mod - mul) % mod;
    }
    printf("%lld\n" , mul);
    return 0;
}


Measured memory_bytes: 6828
v[50],p,n,s;f(X){for(;n<X;n+=v[p++]);n=50*(n-X);}main(){for(;n=atoi(gets(v));printf("%d\n",s)){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;n;)n=0,p=++s,f(5),f(7),f(5),f(7),f(7);}}

Measured memory_bytes: 532
#include <stdio.h>
#define N 100

int main(){
  int a[N],i,j,minj,b,n,count;
  scanf("%d",&n);
  if(n>100){
    printf("Cannot\n");
    return 0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]<0||a[i]>100) return 0;
  }

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    b=a[i];
    a[i]=a[minj];
    a[minj]=b;
    if(a[i]!=a[minj]) count++;
  }

  printf("%d",a[0]);
  for(i=1;i<n;i++) printf(" %d",a[i]);
  printf("\n%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>vec;
    int a,b;
    cin>>a>>b;
    while(b--)
    {
        int k;
        cin>>k;
        for(int i=1;i<=k;i++)
        {
            int q;
            cin>>q;
            vec.push_back(q);
        }
    }
    int count=0,i=1;

    while(i<=a)
    {
        int c=0;
        for(int p=0;p<vec.size();p++)
        {
            if(i!=vec[p])c++;
        }
        if(c==vec.size())
        {
            count++;
        }
        i++;
    }

    cout<<count<<endl;

    return 0;

}


Measured memory_bytes: 3652
import java.util.Scanner;

class Problem {
    private int N;
    private String S;
    private final long D = (long) 1e9 + 7;

    Problem() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        S = sc.next();
    }

    long solve() {
        long[] counts = new long[26];

        for (int i = 0; i < N; i++) {
            int c = S.charAt(i) - 'a';
            counts[c]++;
        }

        long ans = 1;
        for (int i = 0; i < counts.length; i++) {
            ans *= (counts[i] + 1);
            ans %= D;
        }
        return ans - 1;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 24912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N),S(100,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
        S[A[i]]++;
    }
    sort(all(A));
    bool flag=true;
    if(A[0]*2<A[N-1]) flag=false;
    if(N!=2&&A[0]==A[1]&&A[0]==1) flag=false;
    if(A[N-2]!=A[N-1]) flag=false;
    
    if(N==2){
        if(A[0]!=1||A[1]!=1) flag=false;
    }
    else{
        for(int i=1;i<N-1;i++){
            if(S[i-1]&&S[i+1]&&!S[i]) flag=false;
        }
        if(A[0]==A[2]) flag=false;
        if(A[N-1]<=A[0]*2-2) flag=false;
        if(A[0]==A[1]&&A[N-1]==A[0]*2) flag=false;
    }
    if(flag) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define PI 3.1415926535898
#define ANGLE (PI/180.0)
int main(){
	int step,dir;
	double x=0.0, y=0.0, angle=0.0;
	
	while(1){
		scanf("%d,%d", &step, &dir);
		if(step==0 && dir==0) break;
		x += (double)(step) * sin( angle*ANGLE );
		y += (double)(step) * cos( angle*ANGLE );
		angle += (double)dir;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

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

int main(){
  int n,m,X,Y,mn=10000,mx=-1;
  cin>>n>>m>>X>>Y;
  vector<int>x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  vector<int>y(m);
  for(int i=0;i<m;i++){
    cin>>y[i];
  }
  for(int i=0;i<m;i++){
    mn=min(mn,y[i]);
  }
  for(int i=0;i<n;i++){
    mx=max(mx,x[i]);
  }
  if(mx<mn&&X<Y&&mx<Y&&X<mn){
    cout<<"No War"<<endl;
  }
  else{
    cout<<"War"<<endl;
  }
}
  


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1800; i >= 400; i -= 200)
    {
        ans++;
        if (n >= i)
        {
            cout << ans << endl;
            break;
        }
    }
}


Measured memory_bytes: 3584
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = map(int, input().split())

memo = {}
def solve(i, m):
    if m == 0:
        return True
    if i >= n:
        return False
    if memo.get((i, m), None) == None:
        memo[(i, m)] = solve(i + 1, m) or solve(i + 1, m - A[i])
    return memo[(i, m)]
for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')

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

int main(){
    int N,K,tmp,L=0;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> tmp;
        tmp = min(tmp,K - tmp);
        L += (2 * tmp);
    }
    cout << L << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;

namespace AtCoderSolve
{
    class Solve
    {

        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static int N;
        static int[] h;
        
        //static long[] A, B;


        public static void Input()
        {
            var cin = new Scanner();
            N = int.Parse(Console.ReadLine());
            h = cin.SplitReader();
        }


        static void Main(string[] args)
        {
            Input();
            
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long[] dp = new long[N];
            
            dp[0] = 0;
            dp[1] = Abs(h[0] - h[1]);
            for(var i = 2; i < N; i++)
            {
                dp[i] = Min(dp[i - 1] + Abs(h[i] - h[i - 1]), dp[i - 2] + Abs(h[i] - h[i - 2]));
            }

            Console.WriteLine(dp[N - 1]);
            

            //Console.Out.Flush();
        }
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
}






Measured memory_bytes: 18400
using System;


namespace ABC172Test
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine().Trim());
            long result = 0;
            result = abc172_f2(N);
            Console.WriteLine(result);
        }
      
        static long abc172_f2(int k)
        {
            long sum = 0;
            for (int i = 1; i <= k; i++) {
                int max = k / i;
                for (int j = 1; j <= max; j++) {
                    sum += i * j;
                }
            }
            return sum;
        }


    }

}


Measured memory_bytes: 27496
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100005
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;


int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(7);

cin>>n>>k;
vector<ll>a(n);

lp(i,n)cin>>a[i];
// ll pos = min_element(all(a)) - a.begin();
// ll md1 = pos%(k-1);
// ll md2 = (n-pos-1)%(k-1);
// if(md1>=md2){
//   ans = (pos+k-2)/(k-1);
//   pos += md1;
//   ans += (n-pos-1 +k -2)/(k-1);
// }
// else 
n--;
ans = (n+k-2)/(k-1);
cout<<ans;






  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

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

int main(){
    string S;
    cin >> S;
    int count_max=0;;
    int i=0;
    while(1){
        int count=0;
        while(1){
            if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
                count++;
            }else{
                i++;
                break;
            }  
            i++;
            if(i>=S.size()) break;
            
        }
        count_max=max(count,count_max);
        if(i>=S.size()) break;
    }
    cout << count_max <<endl;
    return 0;
}

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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] str = s.split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        if(!(a<1) || (b>Math.pow(10,9))){
            
            int num1 = a / b;
            int num2 = a % b;
            String num3 = String.format("%.5f",((double)a / (double)b));
            System.out.println(num1+" "+ num2 +" "+ num3);
            
            //System.out.println(String.format("%d %d %.5f",a/b,a%b,(double)a/b));
        }
    }
}

Measured memory_bytes: 17116
#include<stdio.h>

int main(void){
    int N,K,i,j;
    scanf("%d%d",&N,&K);
    int d,ans[N];
    for(i=0;i<N;i++){
        ans[i]=0;
    }
    for(i=0;i<K;i++){
        scanf("%d",&d);
        for(j=0;j<d;j++){
            int A;
            scanf("%d",&A);
            ans[A-1]++;
        }
    }
    int Answer=0;
    for(i=0;i<N;i++){
        if(ans[i]==0) Answer++;
    }
    printf("%d\n",Answer);
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < max(a, b); ++i)
		cout << min(a, b);
	cout << endl;
}

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

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

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

int main()
{
	int n;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			for(int k=1;k<=n;++k) {
				ans+=gcd(gcd(i,j),k);
			}
	cout<<ans;
}

Measured memory_bytes: 3760
#include <iostream>                                                             
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int H, W;                                                                     
  while (true) {                                                                
    cin >> H;                                                                   
    cin >> W;                                                                   
    if (H==0 && W==0) {                                                         
      break;                                                                    
    }                                                                           
    for (int i=0; i<H; i++) {                                                   
      for (int j=0; j<W; j++) {                                                 
        cout << "#" << flush;                                                   
      }                                                                         
      cout << endl;                                                             
    }                                                                           
    cout << endl;                                                               
  }                                                                             
}                                                                               
                                                                                
                                                                                
                                  

Measured memory_bytes: 3096
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 101000

int main()
{
	int x1,y1,x2,y2;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	int a=x2-x1,b=y2-y1;
	printf("%d %d %d %d\n",x2-b,y2+a,x1-b,y1+a);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
using namespace std;
const int MAXN=100005,MAXH=405;

int N,H;
int in[MAXH],out[MAXH];
int cntS[MAXH],cntT[MAXH];
bool vis[MAXH];

int fa[MAXH];
int Root(int x)
{return fa[x]==0?x:(fa[x]=Root(fa[x]));}
void Union(int x,int y)
{
	int r1=Root(x),r2=Root(y);
	if(r1==r2)
		return;
	fa[r1]=r2;
}

int ID(int h,int d)
{return h*2-1+d;}

int main()
{
	scanf("%d%d",&N,&H);
	for(int i=1;i<=N;i++)
	{
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int u,v;
		if(c==0)
			u=ID(a,0);
		else
			u=ID(c,1);
		if(d==0)
			v=ID(b,1);
		else
			v=ID(d,0);
		out[u]++;
		in[v]++;
		vis[u]=vis[v]=true;
		Union(u,v);
		//printf("(%d,%d)->(%d,%d)          %d->%d\n",(u-1)/2+1,(u&1)^1,(v-1)/2+1,(v&1)^1,u,v);
	}
	
	for(int i=1;i<=2*H;i++)
	{
		if(in[i]-out[i]>=1)
		{
			if(i&1)
			{
				puts("NO");
				return 0;
			}
			cntT[Root(i)]+=in[i]-out[i];
		}
		if(out[i]-in[i]>=1)
		{
			if((i&1)^1)
			{
				puts("NO");
				return 0;
			}
			cntS[Root(i)]+=out[i]-in[i];
		}
	}
	for(int i=1;i<=2*H;i++)
		if(vis[i]&&fa[i]==0&&(cntS[i]!=cntT[i]||(cntS[i]==0&&cntT[i]==0)))
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  string s; cin >> s;
  int n = s.size();
  int ans[n];
  memset(ans,0,sizeof(ans));
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      int k=0;
      while(s[i+k]=='R') k++;
      int x = i+k;
      int y = k/2;
      ans[x] += y;
      ans[x-1] += y+k%2;
      i += k-1;
    }else{
      int k=0;
      while(s[i+k]=='L') k++;
      int x = i-1;
      int y = k/2;
      ans[x] += y;
      ans[x+1] += y+k%2;
      i += k-1;
    } 
  }
  
  for(int i=0;i<n;i++){
    cout << ans[i] << " ";
  }
  
}


Measured memory_bytes: 4092
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	char c;cin>>c;
	cout<<(char)(c+1)<<endl;
	return 0;
}



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

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] == -1:
    memo[x] = fib(x-1) + fib(x-2)
  return memo[x]

def fib2(x):
  if x <= 1:
    return memo[x]
  else:
    for i in range(x - 1):
      if memo[i + 2] == 0:
        continue
      memo[i + 2] = memo[i] + memo[i + 1]
    return memo[x]

# print(fib2(n))
# print(memo)
print(fib2(n) % 1000000007)


Measured memory_bytes: 466000
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    int n;
    cin>>n;

    string s;
    cin>>s;

    ll num2 = 0;
    ll num3 = 0;
    ll x2 = 1;
    ll x3 = 1;

    ll pos2[n] = {0};
    ll pos3[n] = {0};

    int digi = 0;
    for(int i=0;i<n;++i) {
        if(s[i] == '1') digi++;
    }
    int m2 = digi - 1;
    int m3 = digi + 1;

    // ll num = 0, x = 1;


    for(int i=n-1;i>=0;--i) {
        if(s[i] == '1') {
            if(m2 != 0)
                num2 = (num2 + x2)%m2;
            num3 = (num3 + x3)%m3;
            // num = num + x;

        }
        if(m2 != 0)
            pos2[n-i-1] = x2;
        pos3[n-i-1] = x3;
        if(m2 != 0)
            x2 = (x2*2)%m2;
        x3 = (x3*2)%m3;
        // x = x*2;
    }
    // cout<<num<<"\n";
    // cout<<num3<<"\n";

    for(int i=0;i<n;++i) {
        if(s[i] == '0') {
            ll pp = n-i-1;
            // cout<<pp<<"\n";
            // cout<<pos3[pp]<<"\n";
            ll tempnum = (num3 + pos3[pp])%m3;
            // cout<<tempnum<<"\n";
            ll ans = 1; 

            while(tempnum > 0) {
                bitset<32> b(tempnum);
                int y = b.count();
                if(y == 0) break;
                b = (tempnum % y);
                ans += 1;
                tempnum = b.to_ulong(); 
            }

            cout<<ans<<"\n";
            // break;
        }
        else {
            if(m2 == 0) {
                cout<<"0\n";
                continue;
            }
            ll pp = n-i-1;
            ll tempnum = (num2 - pos2[pp] + m2)%m2;
            ll ans = 1; 

            while(tempnum > 0) {
                bitset<32> b(tempnum);
                int y = b.count();
                if(y == 0) break;
                b = (tempnum % y);
                ans += 1;
                tempnum = b.to_ulong(); 
            }

            cout<<ans<<"\n";

        }
    }
    // cout<<num<<"\n";

    return 0;
}

Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int x,y,z;
  cin>>x>>y>>z;
  int v=max({x,y,z});
  if(v==x) cout<<"A"<<endl;
  if(v==y) cout<<"B"<<endl;
  if(v==z) cout<<"C"<<endl;
  return 0;
}



Measured memory_bytes: 3080
/* Murad Eynizade */
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair
using namespace std;
int mx = INT_MIN,in = -1,a[100002],x,mins;
int main() {
	int n;
	cin>>n;
	for (int i = 0;i<n;i++) {
		cin>>x;
		a[x]++;
		if (x == 0)mins++;
		else a[x-1]++;
		a[x+1]++;
	}
	if (mins > mx)mx = mins;
	for (int i = 0;i<=100001;i++) {
		if (a[i] >= mx) {
			mx = a[i];
			in = i;
		}
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define P pair<int,int>
using namespace std;
const int maxn = 100100;
ll arr[maxn], n, m;
bool cut[maxn];

int main() {
    cin>>m>>n;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
    }

    sort(arr+1, arr+n+1);

    vector<P>v;
    for(int i=1;i<n;i++) {
        v.pb(mp(abs(arr[i+1]-arr[i]), i));
    }

    sort(v.rbegin(), v.rend());

    for(int i=0;i<min(n, m)-1;i++) {
        cut[v[i].second] = true;
    }

    ll result = 0LL;
    for(int i=1;i<n;i++) {
        if(!cut[i]) result += abs(arr[i+1] - arr[i]);
    }
    cout<<result<<"\n";
    return 0;
}

Measured memory_bytes: 2168
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int m = 0;
    int d = max(x, y) - min(x, y);
    m += min(a+b, c+c) * min(x, y);
    if(x > y) m += min(a, c*2) * d;
    else m += min(b, c*2) * d;
    cout << m;
}


Measured memory_bytes: 256
n, s=map(int,input().split())
q=[list(map(int, input().split())) for i in range(n)]

import numpy as np
import itertools
import pprint

bit=[0,1]

cmp=list(itertools.product(bit, repeat=n))

cp=[0]*n
qt=[0]*n
cnt=[0]*2**n

for i in range(n):
	cp[i]=100*(i+1)*q[i][0]+q[i][1]
	qt[i]=q[i][0]

cmp_cnt=np.dot(np.array(qt),np.array(cmp).T)

for i in range(2**n):
	score=np.dot(np.array(cp),np.array(cmp[i]).T)
	cnt[i]=cmp_cnt[i]
	if score<s:
		j=n-1
		while score<s and j>=0:
			if cmp[i][j]==0:
				for k in range(qt[j]):
					score+=(j+1)*100
					cnt[i]+=1
					if score>=s:
						j=0
						break
			j-=1
                
print(min(cnt))

Measured memory_bytes: 21684
n = gets.to_i
d = gets.split.map(&:to_i)
h = Array.new(n, 0)
if d[0] != 0
  puts 0
else
  flag = true
  for i in 1...n do
    if d[i] == 0
      flag = false
      break
    end
  end
  if !flag
    puts 0
  else
    max_d = 0
    for i in 0...n do
      h[d[i]] += 1
      max_d = d[i] if max_d < d[i]
    end
    count = 1
    for i in 1..max_d do
      count = count * (h[i - 1] ** h[i]) % 998244353
    end
    puts count
  end
end


Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

using mat=vector<vector<ll>>;

mat mul(mat &a,mat &b){
    int l=a.size();
    int m=b.size();
    int n=b[0].size();
    mat res(n,vector<ll>(b[0].size()));
    for(int i=0;i<l;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                res[i][j]+=a[i][k]*b[k][j];
                res[i][j]%=MOD;
            }
        }
    }
    return res;
}

mat pow(mat a,ll k){
    int n=a.size();
    mat res(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        res[i][i]=1;
    }
    while(k>0){
        if(k&1)res=mul(res,a);
        a=mul(a,a);
        k>>=1;
    }
    return res;
}

int main(){
    ll n,k;
    cin>>n>>k;
    mat a(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    a=pow(a,k);
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans+=a[i][j];
        }
    }
    ans%=MOD;
    cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
  int N, K;
  char S[12];

  cin >> N >> S >> K;

  char t = S[K - 1];
  for (int i = 0; i < N; i++) {
    S[i] = S[i] != t ? '*' : t;
  }

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.range;
import std.array;
import std.conv;
import std.typecons;

alias Tuple!(int, "count", string, "name") Word;

Word[] search_words(string[] lines, char prefix) {
  string[] res;
  Word[string] rank;
  foreach(line; lines) {
    auto words = line.split(" ");
    foreach(word; words) {
      if (word[0] == prefix) {
        if (word in rank) rank[word].count++;
        else {
          rank[word] = Word(1, word);
        }
      }
    }
  }
  Word[] words = rank.values;
  return sort!((a, b) {
      if (a.count != b.count) return a.count > b.count;
      return a.name < b.name;
    })(words).take(5).array;
}

void main() {
  while(true) {
    int times = readln.chomp.to!(int);
    if (times == 0) break;
    string[] lines;
    foreach(t; 0..times) lines ~= readln.chomp;
    char prefix = readln.chomp[0];
    Word[] words = search_words(lines, prefix);
    if (words == []) {writeln("NA"); continue;}
    for(uint i = 0; i < words.length; i++) {
      write(words[i].name);
      if (i != words.length - 1) write(" ");
    }
    writeln;
  }
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int ans = 0;

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

		for (int i = 0; i < n - 1; i++) {
			if (a[i] > a[i + 1]) {
				ans = gcl(a[i], a[i + 1]);
			} else {
				ans = gcl(a[i + 1], a[i]);
			}
			a[i + 1] = ans;
		}

		System.out.println(ans);

		sc.close();
	}

	public static int gcl(int max, int min) {
		if (max % min == 0) {
			return min;
		}
		return gcl(min, max % min);
	}
}


Measured memory_bytes: 50388
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;

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

    sort(a.begin(), a.end());

    for(int i = 1; i < n; i++){
        if(a.at(i) == a.at(i-1)){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

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

    std::cout << std::fixed << std::setprecision(20);
    std::cout << (a / b) << " " << (a % b) << " " << double(a) / b << std::endl;
}


Measured memory_bytes: 3284
#include <iostream>

using namespace std;

int main(){
    long long n,a,b,c,d,e,min,ans;
    cin >> n >> a >> b >> c >> d >> e;
    min = 1000000000000001;
    if(a < min)
        min = a;
    if(b < min)
        min = b;
    if(c < min)
        min = c;
    if(d < min)
        min = d;
    if(e < min)
        min = e;
    if(n <= min){
        cout << 5 << endl;
        return 0;
    } else {
        if (n%min == 0){
            ans = 4 + n/min;
            cout << ans << endl;
        } else {
            ans = 4 + n/min + 1;
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,d[100010],c=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i+1]);
  for(i=1;i<=n;i++)c+=d[d[i]]==i?1:0;
  printf("%d\n",c/2);
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {//atcoder ABC128B - 

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int n = seer.nextInt();
		Res[] rs = new Res[n];
		for(int i = 0; i < n; i++){
			String name = seer.next();
			int p = seer.nextInt();
			rs[i] = new Res(name, p, i+1);
		}
		Arrays.sort(rs);
		for(int i = 0; i < n; i++){
			System.out.println(rs[i].index);
		}
	}
	static class Res implements Comparable<Res>{
		String name; int score; int index;
		public Res(String name, int score, int index){
			this.name = name; this.score = score; this.index = index;
		}
		@Override
		public int compareTo(Res arg0) {
			if(name.equals(arg0.name)){
				return arg0.score - score;
			}
			else return name.compareTo(arg0.name);
		}
		
	}
}


Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
void sort(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] > x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
void sort2(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] < x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
int main(void){
    int n, x;
    int a[100];
    int i, y, cou=0;
    
    n = num();
    x = num();
    for(i=0; i<n; i++){
        a[i] = num();
    }
    
    sort(a, n);
    
    for(i=0; i<n; i++){
        if(x >= a[i]){
            x -= a[i];
            cou++;
        }
    }
    
//    sort2(a, n);
    
    if(cou == n && x > 0){
        cou -= 1;
    }
    else{
        y = 0;
    }
    
//    i=0;
//    while(x > 0){
//        x -= a[i];
//        if(y==1){
//            cou--;
//        }
//        x -= a[i];
//        if(x < 0){
//            x *= -1;
//        }
//        if(a[i] >= x){
//            break;
//        }
//        
//    }
//    if(x < 0){
//        cou++;
//    }
    
    printf("%d\n", cou);
    
    return 0;
    
}

Measured memory_bytes: 128
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 2101
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			ArrayList<Integer> div = divisor(N);
			div.remove(div.indexOf(N));
			int S = 0;
			for (int i = 0; i < div.size(); i++) S += div.get(i);
			if (N > S) {
				System.out.println("deficient number");
			} else if (N < S) {
				System.out.println("abundant number");
			} else {
				System.out.println("perfect number");
			}
		}
	}
	
	public static ArrayList<Integer> divisor(int n) {
		ArrayList<Integer> ret = new ArrayList<Integer>();
		for (int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				ret.add(i);
				if (i != (n / i)) ret.add(n / i);
			}
		}
		return ret;
	}
}

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

int main()
{
    int n, ans = 0;

    cin >> n;
    vector<uint64_t> a(n);
    for (int i = 0; i < n; i++) { cin >> a.at(i); }

    bool flag = true;
    while(flag)
    {
        for (int i = 0; i < n; i++)
        {
            if (a.at(i) % 2 != 0)
            {
                flag = false;
                cout << ans << endl;
                return 0;
            }
            else
            {
                a.at(i) /= 2;
            }
        }
        ans++;
    }

    cout << ans << endl;    
}

Measured memory_bytes: 256
from collections import defaultdict
def solve():
    N = int(input())
    d = defaultdict(lambda: 0)
    for i in range(N):
        S = input()
        d[S] += 1
    M = int(input())
    for i in range(M):
        T = input()
        d[T] -= 1
    ans = 0
    for v in d.values():
        ans = max(ans,v)
    return ans
print(solve())

Measured memory_bytes: 3316
x, y = map(int, input().split())
d = {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1, 4:2, 6:2, 9:2, 11:2, 2:3}
if d[x]==d[y]:
    print("Yes")
else:
    print("No")

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

#define ll long long int

int main() {
	// your code goes here
	
	ll a,b,c;
	cin>>a>>b>>c;
	map<ll,ll>mp;
	mp[a]++;
	mp[b]++;
	mp[c]++;
	if((a==b && a!=c) || (b==c && a!=c) || (a==c && b!=c)){
		cout<<"Yes\n";
	}
	else{cout<<"No\n";}
	
	return 0;
}

Measured memory_bytes: 256
///In the name of GOD
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 200 + 10;
ll n, m;
ll dp[MXN][MXN];
bitset<MXN> mark[MXN];
bool check(ll x, ll y){
    return(1 <= x && 1 <= y && x <= n && y <= m);
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i ++){
        string s;cin >> s;
        for(int j = 1; j <= m; j ++) mark[i][j] = (s[j - 1] == '#' ? 1 : 0);
    }
    dp[1][1] = (mark[1][1]);
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            if(i == 1 && j == 1) continue;
            dp[i][j] = 1e16;
            if(!mark[i][j]){
                if(check(i - 1, j)) dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                if(check(i, j - 1)) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
                continue;
            }
            if(check(i - 1, j)) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (!mark[i - 1][j]));
            if(check(i, j - 1)) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (!mark[i][j - 1]));
        }
    }
    cout << dp[n][m];
    return 0;
}
/*!
    Be careful who you share your weaknesses with.
    Some people can't wait for the opportunity to use them against you!!
*/
//! N.N


Measured memory_bytes: 384
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
       BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
       String str=buf.readLine();
       String[] rs=str.split(" ");
       int x,y,z;
       int cnt=0;
           x=Integer.parseInt(rs[0]);
           y=Integer.parseInt(rs[1]);
           z=Integer.parseInt(rs[2]);
           for(int i=x; i<=y;i++){
           if(z % i == 0)
               cnt++;
           }
       System.out.println(cnt);
    }
}

Measured memory_bytes: 24356
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
Sum = sum(B)
for i in range(N-1):
  if A[i+1] - A[i] == 1:
    Sum += C[A[i]-1]
print(Sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
// #define int long long
using namespace std;
using ll = long long;

int main() {
  int a;
  cin >> a;
  cout <<  a+a*a+a*a*a << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d)
    {
        cout << "Left" << endl;
    }
    else if (a + b < c + d)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }
    return 0;
}

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

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t=1;
   // cin>>t;
   while(t--){
	   int n;
      cin>>n;
      vector<ll>v(n);
      ll ans=0;
      for(int i=0;i<n;i++) cin>>v[i];
      for(int i=0;i<n;i++){
         for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
               if((v[i]!=v[k]) && (v[k]!=v[j]) && (v[i]!=v[j])){
                  if(((v[i]+v[j])>v[k]) && ((v[i]+v[k])>v[j]) && ((v[k]+v[j])>v[i])){
                     ans++;
                  }
               }
            }
         }
      }
      cout<<ans;
}
   return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

vector<int> ans;

int solve(int n, int r){
    vector<int> cards(n);
    for (int i = n-1; i >= 0; i--){
        cards[i] = n-i;
    }

    for (int i = 0; i < r; i++){
        int p, c; cin >> p >> c;
        vector<int> tmp;
        for (int j = p-1; j < p-1+c; j++){
            tmp.push_back(cards[j]);
        }
        for (int j = 0; j < p-1; j++){
            tmp.push_back(cards[j]);
        }
        for (int j = p-1+c; j < n; j++){
            tmp.push_back(cards[j]);
        }
        cards = tmp;
    }
    return cards[0];
}


int main(){
    cin.tie(0);

    while (1){
        int N, R; cin >> N >> R;
        if (!N && !R) break;
        ans.push_back(solve(N, R));
    }
    for (auto itr = ans.begin(); itr != ans.end(); itr++){
        cout << *itr << endl;
    }
}




Measured memory_bytes: 2984
#include<stdio.h>
int main(void)
{
    int i,j,a,b,c[10000];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<10;i++){
		c[i]=0;
		}
		for(i=0;i<a;i++){
			scanf("%d",&b);
			c[b]+=1;
		}
		for(i=0;i<10;i++){
			if(c[i]>0){
				for(j=0;j<c[i];j++){
					printf("*");
				}
			printf("\n");
			}
			else{
				printf("-\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 576
#include <stdio.h>
#include <stdbool.h>

bool judge_beginning_era(int year, int month, int day, int beginning_year, int beginning_month, int beginning_day)
{
    if (beginning_year < year || (beginning_year == year && (beginning_month < month || (beginning_month == month && beginning_day <= day)))) {
        return true;
    } else {
        return false;
    }
} //元号の始まり以後かどうか

bool judge_end_era(int year, int month, int day, int end_year, int end_month, int end_day)
{
    if (year < end_year || (end_year == year && (month < end_month || (month == end_month && day <= end_day)))) {
        return true;
    } else {
        return false;
    }
} //元号の終わり以前かどうか

int main(void)
{
    int year;
    int month;
    int day;
    while (scanf("%d %d %d", &year, &month, &day) != EOF) {
        if (judge_end_era(year, month, day, 1868, 9, 7)) {
            printf("pre-meiji\n");
        } else if (judge_beginning_era(year, month, day, 1868, 9, 8) && judge_end_era(year, month, day, 1912, 7, 29)) {
            printf("meiji %d %d %d\n", year - 1868 + 1, month, day);
        } else if (judge_beginning_era(year, month, day, 1912, 7, 30) && judge_end_era(year, month, day, 1926, 12, 24)) {
            printf("taisho %d %d %d\n", year-1912 + 1, month, day);
        } else if (judge_beginning_era(year, month, day, 1926, 12, 25) && judge_end_era(year, month, day, 1989, 1, 7)) {
            printf("showa %d %d %d\n", year - 1926 + 1, month, day);
        } else {
            printf("heisei %d %d %d\n", year - 1989 + 1, month, day);
        }
    }
    return 0;
}

Measured memory_bytes: 1036
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def getDivCount(x: Int): Int = {
    var tmp = x
    var count = 0
    while (tmp % 2 == 0) {
      count += 1
      tmp = tmp / 2
    }
    count
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    val loopCount =
      a.map(v =>
        if (v % 2 == 0) getDivCount(v)
        else 0
      ).sum
    println(loopCount)
  }
}


Measured memory_bytes: 39612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
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()
{
cin.tie(0);
ios::sync_with_stdio(false);

int n;
cin >> n;
vector<int> a(n);
rep(i,n) cin >> a[i];

int ans = 0;
int now = 1;

rep(i,n){
    if(a[i] == now) now++;
    else ans++;
}

if(ans == n){cout << -1 << endl;
}else{
    cout << ans << endl;
}

return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <stack>

using namespace std;

int main() {

  string op;
  stack<int> st;  
  int sec,fir;

  while(cin >> op){
    if(op=="+"||op=="-"||op=="*"){
      fir = st.top();
      st.pop();
      sec = st.top();
      st.pop();
      if(op=="+") st.push(fir+sec);
      if(op=="-") st.push(sec-fir);
      if(op=="*") st.push(fir*sec);
    }
    else st.push(atoi(op.c_str()));
  }
  cout << st.top() << endl;
  
}


Measured memory_bytes: 3208
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, n = 0;
  string S;
  cin >> N >> S;
  while (n < S.length() - 1)
  {
    if (S[n] == S[n + 1])
    {
      S.erase(n, 1);
    }
    else
    {
      n++;
    }
  }
  cout << S.length() << endl;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll n, m, x, y, parent[200005], mux = -inf;
unordered_map<ll, ll> m1;
void make_set (ll v) {
	parent[v] = v;
}

int find_set (ll v) {
	if (v == parent[v])
		return v;
	return parent[v] = find_set (parent[v]);
}

void union_sets (ll a, ll b) {
	a = find_set (a);
	b = find_set (b);
	if (a != b)
		parent[b] = a;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (ll i = 1; i <= n; ++i)
        make_set(i);
    for (ll i = 1; i <= m; ++i) {
        cin >> x >> y;
        union_sets(x, y);
    }
    for (ll i = 1; i <= n; ++i) {
        x = find_set(i);
        ++m1[x];
        mux = max(mux, m1[x]);
    }
    cout << mux;
    return 0;
}


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

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>0 && c*c+a*a+b*b-2*a*b-2*b*c-2*c*a>0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<ll> node;
};

ll CA[100005];
ll CT[100005];
Vertex V[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, T;
    cin >> N >> T >> A;
    T--;
    A--;
    REP(i, N) {
        CT[i] = CA[i] = INF;
    }
    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(b);
        V[b].node.push_back(a);
    }

    {
        queue<pll> q;
        q.push(pll(A, 0));
        CA[A] = 0;
        while (!q.empty()) {
            pll t = q.front();
            q.pop();
            ll cost = t.second + 1;
            for (auto n : V[t.first].node) {
                if (CA[n] <= cost)
                    continue;
                CA[n] = cost;
                q.push(pll(n, cost));
            }
        }
    }
    {
        queue<pll> q;
        q.push(pll(T, 0));
        CT[T] = 0;
        while (!q.empty()) {
            pll t = q.front();
            q.pop();
            ll cost = t.second + 1;
            for (auto n: V[t.first].node) {
                if (CT[n] <= cost)
                    continue;
                CT[n] = cost;
                q.push(pll(n, cost));
            }
        }
    }

    ll ans = 0;
    REP(i, N) {
        if (CA[i] >= CT[i])
            ans = std::max(ans, CA[i] - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>

int main(void){
  
  int s,i,j;
  int result_n = 1;
  int a[10000000];
  
  scanf("%d",&s);
  
  a[0] = s;
  for(i = 1;i < 10000000;i++){
    if(a[i - 1] % 2 == 0){
      a[i] = a[i - 1] / 2;
    }else if(a[i - 1] % 2 != 0){
      a[i] = a[i - 1] * 3 + 1;
    }
    for(j = 0;j < i;j++){
      if(a[j] == a[i] && i != 1){
        result_n += i; 
        goto finish;
      }
    }
  }
  finish:;
  
  printf("%d",result_n);
  return 0;
}

Measured memory_bytes: 128