akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			int i;
			int data[] = new int[str.length()];
			for(i=0; i<str.length(); i++){
				switch (str.charAt(i)){
					case '\\':data[i]=-1;break;
					case '/' :data[i]= 1;break;
					case '_' :data[i]= 0;break;
				}
			}
			int start=0, end=0, saveEnd, base=0;
			int A=0, Li=0, k=0;
			int L[] = new int[str.length()];
			while(true){
				for(i=base; i<data.length; i++){
					saveEnd=end;
					end+=data[i];
					if(data[i]==-1||data[i]==1){
						Li++;
					}
					if(data[i]==0){
						Li+=2;
					}
					Li+=(start-(end<saveEnd?end:saveEnd)-1)*2;
					if(start>end){
					} else if(start<end){
						start=end;
						Li=0;
						base=i+1;
					} else{
						if(Li>0){
							A+=Li/2;
							L[k]=Li/2;
							k++;
							Li=0;
						}
						base=i+1;
					}
				}
				base++;
				if(base>=data.length) break;
				start--;
				end=start;
				Li=0;
			}
			System.out.println(A);
			System.out.print(k);
			for(i=0; i<k; i++){
				System.out.print(" "+L[i]);
			}
			System.out.println();
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
}

Measured memory_bytes: 23044
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

struct XorShift { // Reference: http://yukicoder.me/submissions/44108
    unsigned z;
    XorShift() : z((unsigned)time(NULL)) {}
    XorShift(int seed) : z(z) {}
    unsigned next() {
        z ^= z << 13;
        z ^= z >> 17;
        z ^= z << 5;
        return z;
    }
    unsigned nextInt(unsigned a, unsigned b) {
        return next() % (b - a + 1) + a;
    }
    double nextDouble() {
        return next() / (double)(1ll << 32);
    }
};

int D;
vector<ll> C;
vector<vector<ll>> S;
vector<int> T;

struct state {
    int d, c;
    vector<ll> pen, cpen;
    vector<int> TT;
    ll ans;
};

state incremental(ll ans, vector<ll> pen, vector<ll> cpen, vector<int> TT, int d, int c) {
    int prev = TT[d];
    int cur = c;
    ans += cpen[prev] + cpen[cur];
    ans -= S[d][prev];
    ans += S[d][cur];
    pen[prev] = 0;
    pen[cur] = 0;
    cpen[prev] = 0;
    cpen[cur] = 0;
    TT[d] = c;
    rep(i, D) {
        pen[prev] += C[prev];
        pen[cur] += C[cur];
        if(TT[i] == prev) pen[prev] = 0;
        if(TT[i] == cur) pen[cur] = 0;
        cpen[prev] += pen[prev];
        cpen[cur] += pen[cur];
    }
    ans -= cpen[prev] + cpen[cur];
    return {d, c, pen, cpen, TT, ans};
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    cin >> D;
    C.resize(26);
    rep(i, 26) cin >> C[i];
    S.resize(D, vector<ll>(26));
    rep(i, D) rep(j, 26) cin >> S[i][j];
    T.resize(D);
    rep(i, D) {
        T[i] = i % 26;
    }
    
    ll ans = 0;
    vector<ll> pen(26);
    vector<ll> cpen(26);
    rep(i, D) {
        ans += S[i][T[i]];
        rep(j, 26) pen[j] += C[j];
        pen[T[i]] = 0;
        rep(j, 26) {
            cpen[j] += pen[j];
            ans -= pen[j];
        }
    }
    
    
    state F = {0, 0, pen, cpen, T, ans};
    
    
    XorShift xs;
    rep(xx, 500000) {
        pair<int, int> m1 = mp(xs.nextInt(0, D - 1), xs.nextInt(0, 25));
        pair<int, int> m2 = mp(xs.nextInt(0, D - 1), xs.nextInt(0, 25));
        state tmpF = F;
        state FS = incremental(F.ans, F.pen, F.cpen, F.TT, m1.first, m1.second);
        state FSS = incremental(FS.ans, FS.pen, FS.cpen, FS.TT, m2.first, m2.second);
        if(FSS.ans > F.ans) {
//            cout << F.ans << "->" << FSS.ans << endl;
            F = FSS;
        }
    }
    
    rep(i, D) {
        output(F.TT[i] + 1);
    }
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> maze(h);
    rep(i,h) cin >> maze[i];

    ll ans = 0;
    for(int bit=0;bit<(1<<h);bit++){
        for(int bite=0;bite<(1<<w);bite++){
            int res = 0;
            rep(i,h)rep(j,w){
                if((bit>>i)&1) continue;
                if((bite>>j)&1) continue;
                if(maze[i][j]=='#') ++ res;
            }
            if(res==k) ++ ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
 
using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
  
void solve() {
	int h, w;
	cin >> h >> w;
	
	vector<vi> dp(h, vi(w, 0));
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if(c == '#') dp[i][j] = -1;
		}
	}
	
	dp[0][0] = 1;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(dp[i][j] == -1) {
				dp[i][j] = 0;
				continue;
			}
			
			if(i - 1 >= 0) dp[i][j] += dp[i - 1][j];
			if(j - 1 >= 0) dp[i][j] += dp[i][j - 1];
			dp[i][j] %= P;	
		}
	}
	
	cout << dp[h - 1][w - 1] << endl;
}
 
int main(){
#define MULTITEST 0
#if MULTITEST  
 
    CASET {
        solve();
    }
    
#else
 
    solve();
    
#endif
 
    return 0;
}

Measured memory_bytes: 7580
n = int(input())
l = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(l[1] - l[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i] - l[i-1]))
print(dp[n-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    	string s;
      	int n,x=0,ans=0;
      	cin>>n;
      	cin>>s;
      for(int i=0;i<s.size();i++){
        if(s[i]=='I')
          x++;
        else
          x--;
     	if(ans<x)
          ans=x;
      }
      cout<<ans<<endl;
      return(0);
    }

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

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

    int N; string L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S[i];

    sort(S.begin(), S.end());
    string ret = "";
    for (int i = 0; i < N; i++) ret += S[i];

    cout << ret << endl;

    return 0;
}

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

int main(){
 int x, n;
cin >> x >> n;

if(n==0){
  cout << x << endl;
  return 0;
}
int ans;
int ab;
vector<int> p(n);
vector<int> q(n);
for(int i= 0;i<n;i++) {
    cin >> p[i]; 
    q[i] = abs(p[i]-x);
 }
sort(q.begin(), q.end());
 if(q[0]!=0) {
   ans = x;
   cout << ans << endl;
   return 0;
 }
 else{
  for(int i=1;i<=100;i++){
     if(q[2*i-1]!=i) {
      ab=i;
      break;
    }
     if(q[2*i]!=i) {
        ab=i;
        break;
      }
   }
 }
for(int i= 0;i<n;i++) {
   if(p[i]==x-ab) {
       ans = x+ab;
       break;
     }
   ans = x- ab;
}
cout << ans << endl;
return 0;
}
 

Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cnt = sc.nextInt();
    int bnd = sc.nextInt();
    int a[] = new int[cnt];
    int dist=0;
    int answer=1;
    for(int i=0;i<cnt;i++){
      a[i]=sc.nextInt();
    }
    for(int i=0;i<cnt;i++){
      
      dist+=a[i];
      if(dist>bnd){  
        break;
      }
      answer++;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

ll MOD = 1000000007;

int main(void){
    // Your code here!
    int N;
    cin >> N;

    ll A[N+10];
    for(int i = 1; i <= N; i++) cin >> A[i];
    
    ll x[N+10];
    ll y[N+10];
    ll z[N+10];
    
    x[0] = y[0] = z[0] = 0;
    
    
    ll ans = 1;
    int tmp = 0; 
    for(int i = 1; i <= N; i++){
        tmp = 0;
        if(A[i]==x[i-1]) tmp++;
        if(A[i]==y[i-1]) tmp++;
        if(A[i]==z[i-1]) tmp++;
        ans = ans * tmp;
        ans = ans % MOD;
        
        
        if(A[i]==x[i-1]) {
            x[i] = x[i-1] + 1;
            y[i] = y[i-1];
            z[i] = z[i-1];
        }
        else if(A[i]==y[i-1]) {
            x[i] = x[i-1];
            y[i] = y[i-1] + 1;
            z[i] = z[i-1];
        }
        else {
            x[i] = x[i-1];
            y[i] = y[i-1];
            z[i] = z[i-1] + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int A,B;
    cin >> A >> B;
    if(A==B) rep(i,A) cout << A;
    else if(A>B) rep(i,A) cout << B;
    else rep(i,B) cout << A;
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    ll N; cin >> N;
    ll ans = 0;
    for(ll i = 0; i * i <= N;i++) ans = i;
    cout << ans * ans << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
mod=10**9+7
dp = [0]*m
for s in S:
    k=0
    d = [0]*(m+1)
    for i in range(m):
        if T[i]==s:
            k+=dp[i-1]+1
        d[i]=(dp[i]+k)%mod
    dp=d
print(dp[-2]+1)

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll d;
  vec2ll c(3, vecll(3));
  bool correct = true;
  forll(i, 0, 3){
	forll(j, 0, 3){
	  cin >> c[i][j];
	}
  }

  forll(i, 1, 3){
	d = c[i][0] - c[i-1][0];
	forll(j, 0, 3){
	  if (c[i][j] - c[i-1][j] != d)
		correct = false;
	}
  }
  forll(i, 1, 3){
	d = c[0][i] - c[0][i-1];
	forll(j, 0, 3){
	  if (c[j][i] - c[j][i-1] != d)
		correct = false;
	}
  }
  if (correct == true)
	cout << "Yes" << endl;
  else
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 200000

int main(){
  int A[MAX],n,i,M,m;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  M=A[1]-A[0];
  m=A[0];
  for(i=1;i<n;i++){
    if(M<A[i]-m)M=A[i]-m;
    if(m>A[i])m=A[i];
  }
  printf("%d\n",M);
  return 0;
}



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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int a, b; cin >> a >> b;
    if (a + b == 15) cout << '+' << '\n';
    else if (a * b == 15) cout << '*' << '\n';
    else cout << 'x' << '\n';
    return 0;
}

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

int main(){
	int s; cin >> s;
	set<int> u;
	int res = 1;
	// sと同じものがuの中で見つかるまでぶんぶん回す
	while(u.find(s) == u.end()){
		u.insert(s);
		s = (s&1) == 0 ? s / 2 : 3 * s + 1;
		res++;
	}
	
	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int main() {
	int n;
	read(n);
	print((n - 1) / 2);
}


Measured memory_bytes: 3004
using System;
using System.Linq;

namespace ALDS1_1
{
    class Program
    {
        private static string Join(int[] a)
        {
            string r = "";
            for(int i = 0; i < a.Length; i++)
            {
                r += a[i].ToString();
                if(i != a.Length - 1) r += ' ';
            }
            return r;
        }

        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for(int i = 0; i < n; i++)
            {
                int v = a[i], j = i - 1;
                while (j >= 0 && a[j] > v)
                {
                    a[j + 1] = a[j--];
                    a[j + 1] = v;
                }
                Console.WriteLine(Join(a));
            }
        }
    }
}

Measured memory_bytes: 10224
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;
             boolean first=true;
            while((line=br.readLine())!= null){if(line.isEmpty())break;
                String[] spl = line.split(" ");
            
            int n1 = Integer.parseInt(spl[0]),n2 = Integer.parseInt(spl[1]);
                if(n1==0&&n2==0)break;
                    
            if(first){first=false;}else{System.out.println("");}
                
                ArrayList<Integer>al = new ArrayList<Integer>();
                for(int i=n1; i<=n2; i++){
                    if(i%400==0)al.add(i);
                    else if(i%4==0&&i%100!=0)al.add(i);
                }
                if(al.size()==0)System.out.println("NA");
                else for(int in : al){
                    System.out.println(in);
                }
            }br.close();
       
         }catch(Exception e){e.printStackTrace();}         
     }
     
}
  

Measured memory_bytes: 20072
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9

int dfs(int v, vector<set<int>> &g, vector<int> &dp){
    if(v == 0) return 0;
    if(dp[v]) return dp[v];
    // debug(g[v].size());
    int res = dfs(v-1,g,dp);
    for(int to : g[v]){
        res = max(res,v-to + dfs(to,g,dp));
    }
    // debug(v);
    // debug(res);
    return dp[v] = res;
}

int main(void){
    int n;
    while(cin>>n, n){
        vector<int> w(n+1);
        rep1(i,n) cin>>w[i];
        w[0] = INF;

        // g[i][j] := i番目が消える時に右側に会わせられる
        //             ブロックのindex
        vector<set<int>> g(n+1);
        rep1(i,n){
            if(abs(w[i]-w[i-1]) <= 1){
                g[i] = g[i-2];
                g[i].insert(i-2);
            }
            for(int l : g[i-1]){
                if(abs(w[i]-w[l]) <= 1){
                    for(int ll : g[l-1]){
                        g[i].insert(ll);
                    }
                    g[i].insert(l-1);
                }
            }
        }
        // rep1(i,n){
        //     printf("i = %d\n",i );
        //     for(int x : g[i]){
        //         cout<<x<<" ";
        //     }
        //     cout<<endl;
        // }
        vector<int> dp(n+1);
        cout<<dfs(n,g,dp)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3908
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int a,b,c,x,y,mn=1000000000;
	cin>>a>>b>>c>>x>>y;
	mn=min(mn,x*a+y*b);
	mn=min(mn,max(x,y)*c*2);
	int z=min(x,y);
	int ans=c*2*z;
	x-=z;y-=z;
	mn=min(mn,ans+x*a+y*b);
	cout<<mn<<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);

		while (sc.hasNext()) {
			int[] a = {sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
			int[] b = {sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
			int hit = 0, blow = 0;
			for (int i = 0; i < a.length; i++) {
				for (int j = 0; j < a.length; j++) {
					if (i == j && a[i] == b[j])
						hit++;
					else if (a[i] == b[j]) blow++;
				}
			}
			System.out.println(hit + " " + blow);
		}

	}

}

Measured memory_bytes: 18140
#include<iostream>
#include<set>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;
using ll=long long;

int main(){
  int N;
  cin >> N;
  set<int> d;
  int c;
  REP(i,N){
    cin>>c;
    d.insert(c);
  }
  
  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;

int main() {
    IO;
    int k;
    string s;
    cin >> k >> s;
    cout << s.substr(0,k);
    if((int) s.size() > k) cout << "...";
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    LL T;cin >> T;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    vector<LL> m(N);
    m[0] = INF;
    LL tmp = INF;
    for(int i = 1;i < N;++i){
        if(A[i-1] < tmp)tmp = A[i-1];
        m[i] = tmp;
    }

    vector<LL> gain(N);
    rep(i,N)gain[i] = A[i] - m[i];
    sort(rall(gain));

    LL ct = 0;
    rep(i,N)if(gain[i] == gain[0])ct++;

    cout << ct << endl;
}


Measured memory_bytes: 2560
from itertools import accumulate
from math import ceil
N = int(input())
A = list(map(int, input().split()))


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


ok, ng = 0, 10 ** 9 + 1
BIT = BinaryIndexedTree(N + 1)
while abs(ok - ng) > 1:
    X = (ok + ng) // 2
    B = [(1 if a >= X else -1) for a in A]
    B = [0] + list(accumulate(B))
    B_sorted = {b: i for i, b in enumerate(sorted(B), start=1)}

    tmp = 0
    BIT.reset()
    for j, b in enumerate(B):
        tmp += BIT.sum(B_sorted[b])
        BIT.add(B_sorted[b], 1)

    if tmp >= ceil((N * (N + 1) / 2) / 2):
        ok = X
    else:
        ng = X

print(ok)


Measured memory_bytes: 135700
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
if c4-c1==c5-c2==c6-c3 and c7-c1==c8-c2==c9-c3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

static const int kModulo = 1000 * 1000 * 1000 + 7;

int main() {
    ios::sync_with_stdio(false);

    int N; cin >> N;

    vector< vector<int> > A(N, vector<int>(N));
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            cin >> A[i][j];

    vector<int> dp(1 << N, 0);
    dp[0] = 1;
    for (int i = 0; i < (1 << N); ++i) {
        int count = 0;
        for (int j = 0; j < N; ++j)
            if ((1 << j) & i)
                ++count;

        for (int j = 0; j < N; ++j)
            if (((1 << j) & i) == 0 && A[j][count])
                dp[i | (1 << j)] = (dp[i | (1 << j)] + dp[i]) % kModulo;
    }

    cout << dp.back() << "\n";
}


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

int main(){

	int X, A, B;
  
  	cin >> X >> A >> B;
  	
  	if( B <= A )cout << "delicious" << endl;
    else if( B <= A + X )cout << "safe" << endl;
    else if( A+X < B)cout << "dangerous" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

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

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

void solve(){
	string s, t; cin >> s >> t;
	int n = s.size();
	int m = t.size();
	string ans = "?";
	rep(i, n - m + 1) {
		string cop = s;
		bool valid = true;
		rep(j, m) {
			if (s[i + j] != '?') {
				if (s[i + j] != t[j])valid = false;
			}
		}
		if (valid) {
			rep(j, m)cop[i + j] = t[j];
			rep(j, n)if (cop[j] == '?')cop[j] = 'a';
			if (ans == "?")ans = cop;
			else ans = min(ans, cop);
		}
	}
	if (ans == "?") {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << ans << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// 11224111122411
// 2012/12/04
public class Main{
	Scanner sc=new Scanner(System.in);

	void run(){
		long mod=100000007;
		for(;;){
			String s=sc.next();
			if(s.equals("#")){
				break;
			}

			int pm=-1;
			long res=1;
			long[] dp={1}, dp2=null;
			int n=1;
			s+="#";
			int k=0;
			for(char c : s.toCharArray()){
				int m=c-'0';
				if(m==pm){
					k++;
					for(int i=0; i<n; i++){
						dp2[i]=dp[i];
					}
					fill(dp, 0);
					for(int i=0; i<n; i++){
						if(i==n-1){
							if(k%n==0)
								dp[0]+=1;
						}else{
							dp[i+1]+=dp2[i];
						}
						dp[0]+=dp2[i];
					}
					for(int i=0; i<n; i++){
						dp[i]%=mod;
					}
				}else{
					long mul=0;
					for(int i=0; i<n; i++){
						mul+=dp[i];
					}
					res=res*mul%mod;
					if(m==8||m==0){
						n=3;
					}else{
						n=5;
					}
					dp=new long[n];
					dp2=new long[n];
					dp[0]=1;
					k=0;
				}
				pm=m;
				if(c=='#'){
					break;
				}
			}
			println(((int)res)+"");
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b, c, x;
	int tmp = 0;
	cin >> a >> b >> c >> x;
	auto count = 0;
	FOR(i, 0, a+1){
		FOR(j, 0, b + 1) {
			FOR(k, 0, c + 1) {
				tmp = 500*i + 100*j + 50*k;
				if (tmp == x) count++;
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
A=[]
B=[False]*9
for i in range(3):
    A+=[int(i) for i in input().split()]
n=int(input())
for _ in range(n):
    b=int(input())
    for i in range(9):
        if b==A[i]:
            B[i]=True
C=[[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
ans=False
for a,b,c in C:
    if B[a-1] and B[b-1] and B[c-1]:
        ans=True
print("Yes" if ans else "No")

Measured memory_bytes: 3064
s = input()
flag = 0
for i in range(len(s)//2):
    if s[i] != s[len(s)-1-i]:
        flag = 1
for i in range((len(s)-1)//2//2):
     if s[i] != s[(len(s)-1)//2-1-i]:
        flag = 1
j = 0
for i in range((len(s)+3)//2-1,len(s)):
    if s[i] != s[len(s)-1-j]:
        flag = 1
    j += 1
if flag == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
import math
import itertools
n = int(input())
al = [0] * n
bl = [0] * n
for i in range(n):
    al[i], bl[i] = map(int, input().split())
bunbo = math.factorial(n)
ans = 0
for p in itertools.permutations(list(range(n))):
    for i in range(n-1):
        ans += ((al[p[i+1]]-al[p[i]])**2+(bl[p[i+1]]-bl[p[i]])**2)**0.5
print(ans/bunbo)


Measured memory_bytes: 68196
def dfs(node):
  visited[node]=True
  stack=[node]
  while stack:
    node=stack.pop()
    for child in g[node]:
      if visited[child]==False:
        visited[child]=True
        stack.append(child)
n,m=map(int,input().split())
g={i:[] for i in range(1,n+1)}
for i in range(m):
  u,v=map(int,input().split())
  g[u].append(v)
  g[v].append(u)
visited=[False for i in range(n+1)]
c=0
for i in range(1,n+1):
  if visited[i]==False:
    c=c+1
    dfs(i)
print(c-1)

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

using namespace std;

int f(int n)
{
	if (n % 2 == 0) {
		return n / 2;
	}
	return 3 * n + 1;
}

int main()
{
	int s;
	cin >> s;

	set < int >logset;

	int a = s;
	logset.insert(a);
	for (int i = 2; i < 1000010; i++) {
		a = f(a);
		if (logset.find(a) != logset.end()) {
			cout << i << endl;
			break;
		}
		logset.insert(a);
	}

	return 0;
}


Measured memory_bytes: 256
/* AOJ0004 */
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  // むずすぎぃ
  double a, b, c, d, e, f;
  while( cin >> a >> b >> c >> d >> e >> f){
    double y = ( a * f - c * d) / ( a * e - b * d);
    double x = ( c - b * y ) / a;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
  return 0;
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------
ll dist(ll x, ll y){
  return x*x + y*y;
}

int main(void) {
  int n;
  cin >> n;
  string c;
  cin >> c;

  int w=0;
  rep(i,n){
    if(c[i]=='W'){
      w++;
    }
  }
  int ans=0;
  if(w==n){
    ans=0;
  } else {
    rep(i,w){
      if(c[n-1-i]=='R') ans++;
    }
  }

  prt(ans);
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  long long L[N];
  for(int i = 0; i < N; i++)
  	cin >> L[i];
  
  // cout << L[4] << endl;
 
  long long ans = 0;
  int M = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      for(int k = j + 1; k < N; k++){
        //cout << i << j << k;
        //cout << " ";
        //cout << L[i] << L[j] << L[k] << endl;
		M++;
        if(L[i] == L[j]) continue;
        if(L[j] == L[k]) continue;
        if(L[k] == L[i]) continue;
        
        if(L[i] >= L[j] + L[k]) continue;
        if(L[j] >= L[k] + L[i]) continue;
        if(L[k] >= L[i] + L[j]) continue;
        ans++;
        //cout << "o" << endl;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
H, W, D = map(int, input().split())
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

num = [() for _ in range(H*W+1)]
for i in range(H):
    for j in range(W):
        num[A[i][j]] = (i,j)
wa = [0]*(H*W+1)
for i in range(D+1, H*W+1):
    wa[i] = wa[i-D] + abs(num[i][0]-num[i-D][0])+abs(num[i][1]-num[i-D][1])

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(wa[r]-wa[l])


Measured memory_bytes: 18032
s = input()
t = input()

sl = len(s)
tl = len(t)
dp = [[0 for i in range(tl+1)] for i in range(sl+1)]

#dp[i][j] sをi文字目、tをj文字目まで求めたときの最大の長さ

for i in range(1,sl+1):
    for j in range(1,tl+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])

ansl = dp[sl][tl]
i = sl
j = tl
ans = [""]*ansl
while(ansl>0):
    if s[i-1] == t[j-1]:
        ans[ansl-1] = s[i-1]
        i -= 1
        j -= 1
        ansl -= 1
    elif dp[i][j]==dp[i-1][j]:
        i -= 1
    else:
        j -= 1

print("".join(ans))

Measured memory_bytes: 153040
import numpy as np
from collections import deque
import sys

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([list(next(inp).strip()) for _ in range(H)])

dis = [0, 0, 1, -1]
djs = [1, -1, 0, 0]

def search(S, i, j, Q, R):
    H, W = S.shape
    R[i, j] = True
    Q.append((i, j))
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if S[i, j] == "#":
            n1 += 1
        else:
            n0 += 1
        gen = ((i + di, j + dj) for di, dj in zip(dis, djs))
        ijs = (g for g in gen if 0 <= g[0] and g[0] < H and 0 <= g[1] and g[1] < W)
        for ni, nj in ijs:
            if not R[ni, nj] and S[ni, nj] != S[i, j]:
                R[ni, nj] = True
                Q.append((ni, nj))
    return n0 * n1


def test(S):
    i, j = 0, 0
    Q = deque()
    R = np.full(S.shape, False)
    H, W = S.shape
    n = 0
    for i in range(H):
        for j in range(W):
            if not R[i, j]:
                n += search(S, i, j, Q, R)
    return n

print(test(parse(sys.stdin)))

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

using namespace std;

using ll = long long;

int main() {
   ll A, V, B, W, T;
   cin >> A >> V >> B >> W >> T;
   ll distA = V * T;
   ll distB = W * T;
   if (distA - distB >= abs(A - B)) {
      cout << "YES\n";
   } else {
      cout << "NO\n";
   }
}


Measured memory_bytes: 3632
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
ans = 0
for n in range(1,N+1):
  div = make_divisors(n)
  if len(div) == 8 and n%2 != 0:
    ans += 1

print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vint G[5555];

int dp[5555],topused[5555];

void dfs(int v,int p){
    dp[v]=0;
    topused[v]=0;

    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
        dp[v]+=dp[u];
        topused[v]|=!topused[u];
    }

    if(topused[v])dp[v]++;
}

signed main(){
    cin>>N;

    for(int i=1;i<=N;i++){
        int p;cin>>p;
         G[p].pb(i);
         dfs(0,-1);
         cout<<dp[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3432
n = int(input())
def doit(s):
    if len(s) > 0 and int(s) > n:
        return 0
    ret = 1 if '3' in s and '5' in s and '7' in s else 0
    for d in '357':
        ret += doit(d + s)
    return ret
print(doit(''))


Measured memory_bytes: 48604
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    vi ans(n, 0);
    rep(i,n-1){
        lli a;
        cin >> a;
        a--;
        ans[a]++;
    }
    vout(ans);
}

Measured memory_bytes: 6444
unittest
{
	assert( [ "sippuu" ].parse.expand.solve == "Yes" );
	assert( [ "iphone" ].parse.expand.solve == "No" );
	assert( [ "coffee" ].parse.expand.solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return ( s[ 2 ] == s[ 3 ] && s[ 4 ] == s[ 5 ] ) ? "Yes" : "No";
}


Measured memory_bytes: 256
import math
from functools import reduce

n,m = map(int, input().split())
A = list(map(int, input().split()))

def lcm_base(x,y):
  return x*y//math.gcd(x,y)

def lcm(target_list):
  return reduce(lcm_base, target_list)

A_gcd = reduce(math.gcd, A)
flg = True

for a in A:
  if a//A_gcd%2==0:
    flg = False
    break
    
if flg:
  min_x = int(lcm(A))//2
  ans = m//min_x - m//(2*min_x)
  print(ans)
else:
  print(0)

Measured memory_bytes: 21064
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, m)
	bs := make([]int, m)
	graph := make([][]bool, n)
	for i := range graph {
		graph[i] = make([]bool, n)
	}
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a, b = a-1, b-1

		as[i] = a
		bs[i] = b
		graph[a][b] = true
		graph[b][a] = true
	}

	var dfs func(x int, visited []bool)
	dfs = func(x int, visited []bool) {
		if visited[x] {
			return
		}
		visited[x] = true

		for i := range graph[x] {
			if graph[x][i] {
				dfs(i, visited)
			}
		}
	}
	visitedAll := func(visited []bool) bool {
		for i := range visited {
			if !visited[i] {
				return false
			}
		}
		return true
	}

	countBridge := 0
	for i := 0; i < m; i++ {
		a, b := as[i], bs[i]
		graph[a][b] = false
		graph[b][a] = false

		visited := make([]bool, n)
		dfs(0, visited)
		if !visitedAll(visited) {
			countBridge++
		}

		graph[a][b] = true
		graph[b][a] = true
	}
	fmt.Println(countBridge)
}


Measured memory_bytes: 512
h,w=map(int,input().split())
count=0
S=["."]*(w+2)
T=[list(input()) for i in range(h)]
for i in range(h):
  T[i].insert(0,".")
  T[i].append(".")
T.insert(0,S)
T.append(S)
for i in range(1,h+1):
  for j in range(1,w+1):
    if T[i][j]=="#" and T[i-1][j]==T[i][j-1]==T[i+1][j]==T[i][j+1]==".":
      count+=1
print("Yes" if count==0 else "No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int num,min=999,count;
  cin >> num;
  for(int i=0;i < num;i++) {
    int n;
    cin >> n;
    for(count=0;n%2==0;count++){
      n/=2;
    }
    if(count < min) min=count;
}
  cout << min <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define INF (int)(1e9)

struct UnionFind{
    int n;
    vi par;
    UnionFind(int N){
        n=N;
        par.resize(n); fill(all(par),-1);
    }
    int root(int a){ 
        if(par[a]<0) return a;
        else return par[a]=root(par[a]);
    }
    bool same(int a, int b){ return root(a)==root(b);}
    void unite(int a, int b){
        a=root(a); b=root(b);
        if(!same(a,b)) par[a>b?b:a]=a>b?a:b; 
    }
};

int main(){
    int n,m; cin>>n>>m;
    vi a(n); for(auto&i:a){ cin>>i; i--;}
    UnionFind uf(n);
    rep(i,m){
        int p,q; cin>>p>>q;
        uf.unite(p-1,q-1);
    }
    int ans=0;
    rep(i,n){
        //cout<<i<<uf.root(i)<<uf.root(a[i])<<endl;
        if(uf.same(i,a[i])) ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
	
	string s;
	cin >> s;
	set<char> setic(s.begin(),s.end());
	vector<char> v(s.begin(), s.end());
	(int) setic.size() == (int) v.size() ? cout << "yes" : cout << "no";
	
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll n,k,s;
  cin >> n >> k >> s;

  rep(i,k){
  cout << s << endl;
  }
  
  if(s!=1000000000){
    rep(i,n-k){
    cout << 1000000000 << endl;
    }
  }
  else{
    rep(i,n-k){
    cout << 999999999 << endl;
    }  
  }
  
}


Measured memory_bytes: 1280
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .split(" ")
    .map((n) => parseInt(n, 10));
 
  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();
 
  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );
 
  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];
 
  const answer = selection
    .map((s) => [s, abs(x - s)])
    .sort(byAsc)[0][0];
 
  console.log(answer);
};
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30124
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long

using namespace std;

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

    int a, b, c, k, result;
    cin >> a >> b >> c >> k;
    auto max = std::max({ a,b,c });
    result = max;
    for (size_t i = 0; i < k; i++)
    {
        result *= 2;
    }
    cout << result + a + b + c - max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n;
  string s;
  cin >> n;
  cin.ignore();
  cin >> s;
  vector<int64_t> r(n),b(n),g(n);
  rep(i,n){
    if(s[i] == 'R'){
      r[i]++;
    }else if(s[i] == 'B'){
      b[i]++;
    }else{
      g[i]++;
    }
  }
  rep(i,n-1){
    r[i+1] += r[i];
    g[i+1] += g[i];
    b[i+1] += b[i];
  }
  vector<int64_t> ss(n);
  rep(i,n){
    if(s[i] == 'R'){
      ss[i] = 0;
    }else if(s[i] == 'B'){
      ss[i] = 1;
    }else{
      ss[i] = 2;
    }
  }   
  int64_t total = 0;
  for(int64_t i=0;i < n;i++){
    for(int64_t j=i+1;j < n;j++){
      if((ss[i]+ss[j] == 1) && (ss[i] != ss[j])){
        if(i == 0){
          total += g[j];
        }else{
          total += g[j] - g[i-1];
        }
        if(((i+j)%2 == 0) && ss[(i+j)/2] == 2){
          total--;
        }
      }else if((ss[i]+ss[j] == 2) && (ss[i] != ss[j])){
        if(i==0){
          total += b[j];
        }else{
          total += b[j] - b[i-1];
        }
        if(((i+j)%2 == 0) && ss[(i+j)/2] == 1){
          total--;
        }
      }else if((ss[i]+ss[j] == 3) && (ss[i] != ss[j])){
         if(i==0){
          total += r[j];
        }else{
          total += r[j] - r[i-1];
        }
        if(((i+j)%2 == 0) && ss[(i+j)/2] == 0){
          total--;
        }
      }
    }
  }
  cout << total << endl;
}
        
        
        
      
         

        
    

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

template<typename T>
struct Edge{
  T capacity;
  int from;
  int to;
};

template<typename T>
T ford_fulkerson(int src, int dst, std::vector<std::vector<Edge<T>>> graph){
  int t = 0;

  std::vector<int> used(graph.size(), -1);
  auto dfs = [&](auto this_function, int node, T current_flow){
    if(node == dst) return current_flow;

    used[node] = t;

    for(Edge<T>& e : graph[node]){
      if(used[e.to] == t || e.capacity <= 0) continue;

      T ret = this_function(this_function, e.to, std::min(current_flow, e.capacity));

      if(ret){
        e.capacity -= ret;
        graph[e.to][e.from].capacity += ret;
        return ret;
      }
    }

    return T(0);
  };

  T flow(0);

  for(T f; f = dfs(dfs, src, std::numeric_limits<T>::max()); ++t){
    flow += f;
  }

  return flow;
}

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector graph((N + 1) << 1, vector<Edge<int>>((N + 1) << 1));
  for(int i = 0; i <= (N << 1) + 1; ++i){
    for(int j = 0; j <= (N << 1) + 1; ++j){
      graph[i][j] = {0, i, j};
    }
  }
  
  vector<pair<int, int>> reds(N), blues(N);
  for(int i = 0; i < N; ++i){
    cin >> reds[i].first >> reds[i].second;
    graph[0][i + 1] = {1, 0, i + 1};
  }
  
  for(int j = 0; j < N; ++j){
    cin >> blues[j].first >> blues[j].second;
    graph[N + 1 + j][(N << 1) + 1] = {1, N + 1 + j, (N << 1) + 1};
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(reds[i].first < blues[j].first && reds[i].second < blues[j].second){
        graph[i + 1][N + 1 + j] = {1, i + 1, N + 1 + j};
      }
    }
  }
  
  cout << ford_fulkerson(0, (N << 1) + 1, graph) << endl;
  
  return 0;
}

Measured memory_bytes: 4492