akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int K , i , n;
    string s ;
    cin >> s;
    cin >> K;
    n = s.size();
    for(i=0;i<n-1;i++)
    {
        if(K >= 26 - abs(s[i] - 'a') && s[i] != 'a')
        {
            K = K - (26 - abs(s[i] - 'a'));
            s[i] = 'a';
        }
    }
    K = K%26;
    for(i=1;i<=K;i++)
    {
        if(s[n-1] == 'z')
            s[n-1] = 'a';
        else s[n-1] =(char)(s[n-1] + 1);
    }
    cout << s;
    return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define MOD 1000000007
#define TIME system("date +%M:%S.%N")
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// ABC103C　方針
// 数列aの最小公倍数をgとすればf(g) = 0となりこれが最小値
// 一方f(g-1)=(a1-1)+(a2-1)...(an-1)が最大値だろう

int main() {
  int n;cin>>n;
  int ans = 0;
  rep(i,n) {
    int a;cin>>a;
    a--;
    ans += a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        
        N = N - N/K*K;
        
        while(N > sub(N,K)) {
        N = sub(N,K);
        }
        System.out.println(N);

        sc.close();
    }
    public static long sub(long A, long B) {
        return Math.abs(A-B);
    }
}


Measured memory_bytes: 35688
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 T+=R[::-1]
 return T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63916
#include <iostream>
#include <cstdlib>

using namespace std;
int main()
{
    int n;
    cin >> n;
    unsigned long long cs[5] = {};
    
    char name[256];
    for(int i = 0; i < n; ++i) {
        cin >> name;
        switch (name[0]) {
        case 'M': ++cs[0]; break;
        case 'A': ++cs[1]; break;
        case 'R': ++cs[2]; break;
        case 'C': ++cs[3]; break;
        case 'H': ++cs[4]; break;
        }
    }
    unsigned long long r = cs[0] * cs[1] * cs[2]
        + cs[0] * cs[1] * cs[3]
        + cs[0] * cs[1] * cs[4]
        + cs[0] * cs[2] * cs[3]
        + cs[0] * cs[2] * cs[4]
        + cs[0] * cs[3] * cs[4]
        + cs[1] * cs[2] * cs[3]
        + cs[1] * cs[2] * cs[4]
        + cs[1] * cs[3] * cs[4]
        + cs[2] * cs[3] * cs[4];
    cout << r << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, a[105];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	FOR(i, n) cin >> a[i];
	sort(a, a+n);
	int c1 = 0, c2 = 0;
	for (int i = n-1; i >= 0; i -= 2) c1 += a[i];
	for (int i = n-2; i >= 0; i -= 2) c2 += a[i];
	cout << c1-c2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
 
int main(){
    char a;
  cin >> a;
  if(isupper(a)){
       cout << "A" << endl;
  }else{
      cout << "a" << endl;
  }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3620
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  @scala.annotation.tailrec
  def gcd(x: Long, y: Long): Long = if (y == 0) x else gcd(y, x % y)
  val A, B = sc.nextLong()
  println((A * B) / gcd(A, B))
}


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

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int ans=1;
    int sum = 0;
    rep(i, n){
        sum += l[i];
        if(sum>x){
            cout << i+1 << endl;
            break;
        }
        if(i==n-1){
            cout << n+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a.insert(0,[0,0,0])
ans = True
for i in range(1,n+1):
  t = a[i][0]-a[i-1][0]
  xy = a[i][1]+a[i][2]-a[i-1][1]-a[i-1][2]
  if not (t >= xy and t%2 == xy%2):
    ans = False
    break
print("Yes" if ans else "No")
   
  


Measured memory_bytes: 27300
import math
N = int(input())
e = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
count=0
for i in range(N):
    for j in range(i+1,N):
        ans += ((e[i][0]-e[j][0])**2+(e[i][1]-e[j][1])**2)**(1/2)
        count+=1
print(ans*2/N)


Measured memory_bytes: 38256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


int main(void) {

	int i, j, k, tmp, n, ans = 1;
	scanf("%d", &n);
	rep(i, 3) {
		ans *= n;
	}
	printf("%d", ans);


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b, c) << " ";
    if (b + c < a) {
        cout << 0 << endl;
    }
    else {
        cout << b + c - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

bool ok(int x, int K, vi D) {
    string s = to_string(x);
    for (char c : s) {
        int num = c-'0';
        for (int i = 0; i < K; i++) {
            if (num == D[i]) return false;
        }
    }
    return true;
}

int solve(int N, int K, vi D) {
    for (int i = N; ; i++) {
        if (ok(i, K, D)) return i;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for (int i = 0; i < K; i++)
        cin >> D[i];
    cout << solve(N, K, D) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long w;
int n;
long arr[101][2];
long dp[101][100001];

int main() {
	// your code goes here
	cin>>n>>w;
	long v=0;
	for(int i=1;i<=n;++i)
	    {cin>>arr[i][0]>>arr[i][1];v+=arr[i][1];}
	    
	if(arr[1][0]<=w) dp[1][arr[1][1]]=arr[1][0];
	for(int i=2;i<=n;++i)
	 {   if(arr[i][0]<=w) dp[i][arr[i][1]]=arr[i][0];
	     for(int j=1;j<=v;++j)
	        {   if(dp[i-1][j])
	        {
	            dp[i][j] = ( dp[i][j] && dp[i-1][j]>dp[i][j])? dp[i][j]:dp[i-1][j];
	          if( dp[i-1][j]+arr[i][0]<=w)
	            {   
	                dp[i][j+arr[i][1]] 
	                =  ( dp[i][j+arr[i][1]] && (dp[i-1][j]+arr[i][0])>dp[i][j+arr[i][1]]) ?dp[i][j+arr[i][1]]:(dp[i-1][j]+arr[i][0]);
	            
	                
	            }
	           // cout<<dp[i][j]<<" ";
	        } 
	        }
	       // cout<<endl;
	 }    
	 


	for(int i=v;i>=1;--i)
	    {
	        if(dp[n][i]) {cout<<i; return 0;}
	    }
	 
	return 0;
}


Measured memory_bytes: 77056
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    
    int n, m, x;
    cin>>n>>m>>x;
    vector<bool> a(n, false);
    for(int i=0; i<m; i++){
        int t;
        cin>>t;
        
        a[t]=true;
    }
    
    int cos0=0;
    int cos1=0;
    
    for(int i=x; i>=0; i--){
        
        if(a[i]){
            cos0++;
        }
    }
    
    for(int i=x; i<=n; i++){
        if(a[i]){
            cos1++;
        }
    }
    
    if(cos0<cos1){
        cout<<cos0<<endl;
    }else{
        cout<<cos1<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n,k;
  cin>>n>>k;
  int ar[n];
  for(int i=0;i<n;i++)
  cin>>ar[i];
  int count=0;
  int flag=0;
  if(n<=k)
  cout<<1;
  else{
  for(int i=0;i<n-1;i+=k-1)
  {if(ar[i+1]==1&&i+1==n-1)
	  flag=1;
	  else
	  count++;}
  
  
	  cout<<count;
  }
}

 


Measured memory_bytes: 3944
package main

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

func main() {
	s, t := readBytes(), readBytes()

	ans:=0
	for i := range s {
		if s[i] == t[i] {
			ans++
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        long count = 0L;
        if (k == 0) {
            count = (long)n*n;
            System.out.println(count);
        } else {
            for (int y = k + 1; y <= n; y++) {
                count += (long)(n / y) * (y - k);
                if (n % y >= k) {
                    count +=(long) n % y - k + 1;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;
public class Main{
	public static void hanafuda(int num[], int p, int c)
	{
		int tmp[] = new int[c];
		for(int i = 0 ; i < c ; i++)
			tmp[i] = num[p + i - 1];
		for(int i = p - 2 ; i >= 0 ; i--)
			num[i + c] = num[i];
		for(int i = 0 ; i < c ; i++)
			num[i] = tmp[i];
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true)
		{
			int n = sc.nextInt();
			int r = sc.nextInt();
			if(n == 0 && r == 0)
				break;
			int num[] = new int[n];
			for(int i = n ; i > 0 ; i--)
				num[n - i] = i;
			for(int i = 0 ; i < r ; i++)
			{
				int p = sc.nextInt();
				int c = sc.nextInt();
				hanafuda(num,p,c);
			}
			System.out.println(num[0]);
		}
	}
}


Measured memory_bytes: 37764
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt(); // 5
      
      long prevPrev = 2; // 2
      long prev = 1;  // 1

      if(n == 0) { System.out.println(prevPrev); return; } 
      if(n == 1) { System.out.println(prev); return; }

      long res = 0;
      for(int i = 2; i <= n; i++) { // i = 6
        res = prevPrev + prev;  // 11
        prevPrev = prev;  // 7
        prev = res; // 11
      }

      System.out.println(res);
  }
}



Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
  int a,b,c,d,i,j;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  i=c/b;
  if(c%b) i++;
  j=a/d;
  if(a%d) j++;
  if((i-1)<j)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

const int N = 2e5 + 5;

LL x[N], y[N];
void solve() {
    int n;
    cin >> n;
    for (int i=0;i<n;++i) {
        cin >> x[i] >> y[i];
        LL t = x[i] + y[i], s = x[i] - y[i];
        x[i] = t; y[i] = s;
    }
    sort(x, x+n);
    sort(y, y+n);
    LL ans = max(x[n-1] - x[0], y[n-1] - y[0]);
    cout << ans << '\n';
}

int main() {
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 6752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string a, b;
    cin>>a>>b;
    int count=0;
    for(int i=0; i<a.size(); i++){
        if(a[i]!=b[i])
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 3428
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
using namespace std;
char H[105];

int main()
{
	char c;
	int i = 1;
	while (cin >> c) {
		H[i] = c;
		i++;
	}
	i--;
	int n = i;
  //cout<<n<<endl;
 if(n==3){
   
   if(H[1]==H[3])cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
 }
  else{
	for (int j = 1; j <= (n-1)/2; j++) {
		//cout<<j<<(n + 1) / 2 - j<<(n + 1) / + j;
		if (H[j] == H[n + 1 - j] && H[(n + 1) / 2 - j] == H[j] && H[j] == H[(n + 1) /2 + j]) {

		}
		else {
			cout << "No" << endl;
			return 0;
		}
		
	}
    cout << "Yes" << endl;
  }
 

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}


int main() {
	
	int N,A,B;
	cin>>N>>A>>B;
	if(A>B){
		ce(0)
	}else if(A==B){
		ce(1)
	}else if(N==1){
		ce(0)
	}else{
		ll n=N-2;
		int C=B-A;
		ll ans=1+n*C;
		ce(ans)
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2001;
int n,f[N][N],b[N],x,y,a[N];
int main()
{
	cin>>n>>x>>y;
	f[x][y]=1;
	for(int i=2;i<=n;i++)f[i-1][i]=1,b[i]=b[i-1]+1;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			f[i][j]=min(b[j]-b[i],abs(x-i)+1+abs(y-j));
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			a[f[i][j]]++;
	for(int i=1;i<=n-1;i++)cout<<a[i]<<endl;
}

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

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    return true;
}

int main(){
    int Q; cin >> Q;
    //vector<pair<int,int> > P(Q);
    //set<int> st;
    vector<bool> is_2017(1e5 + 1, 0);
    vector<int> S(1e5 + 1,0);
    for(int i = 3; i < 1e5 + 1; i++) 
    if(is_prime(i) && is_prime((i+1)/2)) is_2017[i] = true;
    for(int i = 3; i < 1e5 + 1; i++ ) S[i] = S[i-1] + is_2017[i];
    rep(i, 0, Q){
        int l, r; cin >> l >> r;
        cout << S[r] - S[l-1] << endl;
        //cout << distance(st.lower_bound(l),st.upper_bound(r)) << endl;
    }
    return 0;

}

Measured memory_bytes: 1024
#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);
  }
  int count = -1;
  bool judgment = 1;
  while (judgment) {
    for (int i = 0; i < N; i++) {
      if (A.at(i) % 2 == 0) {
        A.at(i) /= 2;
      }
      else {
        judgment = 0;
        break;
      }
    }
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,capacity;
	cin>>n>>capacity;
	ll wt[n],val[n];

	for(int i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	ll dp[n+1][capacity+1]={};

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=capacity;j++)
		{
			ll a=0,b=0;
			if(wt[i-1]<=j)
				a=dp[i-1][j-wt[i-1]]+val[i-1];
			b=dp[i-1][j];
			dp[i][j]=max(a,b);
		}
	}


	cout<<dp[n][capacity];

}

Measured memory_bytes: 82416
#098_D
def search_1(x):
    l = set()
    n = len(bin(int(x))) - 2
    for j in range(n):
        if (int(x) >> j) & 1:
            l.add(j)
    return l

n = int(input())
a = [search_1(x) for x in input().split()]
#print(a)

ans = 0
cur = set()
r = 0
for l in range(0, n):
    while r < n and len(cur & a[r]) == 0:
        cur |= a[r]
        r += 1
    #print(l, r)
    ans += r - l 
    
    cur -= a[l]
print(ans)

Measured memory_bytes: 162508
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(void){
  string s, ans;
  cin >> s;

  ans = "";
  REP(i, s.size()){
    if(s[i] == '0') ans += "0";
    else if(s[i] == '1') ans += "1";
    else{
      if(ans != ""){
        ans = ans.substr(0, ans.size()-1);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;


int main(){
  int n; cin >> n; int san, ni;
  if(n==3){
    cout << "2 5 63" << endl; return 0;
  }
  rep(i, min(5001, n-1)){
    if(i==0) continue;
    if(i%2==0 && ((n-i)%3==2 || (n-i)%3==0)){
      san = i;
    }
  }
  ni = n - san;
  rep(i, san){
    cout << 3+6*i; cout << " ";
  }
  rep(i, ni){
    cout << 2*(i+1); if(i!=(ni-1)) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
const int N = 100050;
typedef long long LL;
int A[N], B[N], C[N];
bool cmp(int a, int b) { return a > b; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &B[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &C[i]);
  std::sort(A, A + n, cmp);
  std::sort(B, B + n, cmp);
  std::sort(C, C + n, cmp);
  int i = 0, j = 0, k = 0;
  LL ans = 0, tmp = 0;
  while (i < n) {
    while (j < n && A[i] < B[j]) {
      while (k < n && B[j] < C[k])
        ++k;
      tmp += k;
      ++j;
    }
    ans += tmp;
    ++i;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,n) loop(i,0,n)
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int h,w;
    while(cin >> h >> w){
        int ans=0;
        rep(i,h){
            int t=0;
            rep(i,w){
                int s; cin >> s;
                if(s==1) t++;
            }
            ans=max(ans,t);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1164
/**
 * Author RDP
 * 
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#define endl '\n'
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0);
typedef long long ll;
using namespace std;

void test_case()
{
    FAST_IO
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while(a>0 && c>0)
    {
        if(i&1)
            a-=d;
        else 
            c-=b;
        i++;
    }
    if(i&1)
        cout << "Yes" <<endl;
    else 
        cout << "No" <<endl;
    return ;
}
int main()
{
    FAST_IO
    test_case();
    return 0;
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> C(N, 0);
  for(int i = 1; i < N; i++){
    int temp;
    cin >> temp;
    C[temp - 1]++;
  }
  for(int i = 0; i < N; i++){
    cout << C[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
T = [tuple(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)

for t in T:
    ans = min(ans, a[t[0] - 1] + b[t[1] - 1] - t[2])

print(ans)

Measured memory_bytes: 28988
#include<cstdio>
int n,c[510],s[510],f[510],i,a,j;main(){for(scanf("%d",&n);~scanf("%d%d%d",c+j++,s+j,f+j););for(f[j-1]=1;i<n;a=0*printf("%d\n",a))for(j=i++;j<n;)a=(a<s[j]?s[j]:(~-a/f[j]+1)*f[j])+c[j++];}

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

int main(){
    int N;
    string S;
    cin >> N >> S;

    int ans = 0; 
    for(int  i = 0; i < 10; i++){
        int I = 0;
        while(I < N){ 
            if(S[I] - '0' != i) I++; 
            else break;
        }
        for(int j = 0; j < 10; j++){
            int J = I+1;
            while(J < N) {
                if(S[J] - '0' != j) J++;
                else break;
            }
            for(int k = 0; k < 10; k++){
                int K = J+1;
                while(K < N) {
                    if(S[K] - '0' != k) K++;
                    else {
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {

            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();   
          int a=ab[0];
           int b= ab[1];
            if (a == b)
            {
                Console.WriteLine("a == b");



            }
            else if (a < b)
            {

                Console.WriteLine("a < b");

            }
            else
            {
                Console.WriteLine("a > b");

            }



        }
    }
}

Measured memory_bytes: 9132
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k, c = map(int,input().split())
    S = input()
    dp = [0] * n
    for i in range(n-1, -1, -1):
        if S[i] == 'o':
            dp[i] = 1
            if i + c + 1 < n:
                dp[i] += dp[i + c + 1]
        else:
            dp[i] = dp[i + 1] if i + 1 < n else 0

    if max(dp) > k:
        return

    res = []
    now = 0
    while now < n:
        prev = now
        day = dp[now]
        cnt = 0
        fix = INF
        while now < n and dp[now] == day:
            if S[now] == 'o':
                fix = min(fix, now)
                cnt += 1
            now += 1
        if cnt == 1:
            now = fix + c + 1
            res.append(fix + 1)
        else:
            now = max(now, fix + c + 1)

    print(*res)
resolve()

Measured memory_bytes: 63328
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n,k; cin>>n>>k;
    fi(i,n) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    fi(i,k) ans+=a[i];
    cout<<ans<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ARatedForMe {
public:
	void solve(istream& in, ostream& out) {
        int r; in >> r;
        if(r < 1200) out << "ABC" << endl;
        if(1200 <= r && r < 2800) out << "ARC" << endl;
        if(2800 <= r) out << "AGC" << endl;
	}
};

int main() {
	ARatedForMe solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            var count = 0;
            for (var i = 0; i < s.Length / 2; i++)
            {
                if (s[i] != s[s.Length - i - 1]) count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
N = int(input())
W = [str(input()) for i in range(N)]


if N != len(set(W)):
    print("No")
else:
    counter = 0
    for i in range(1, N):
        if W[i-1][-1] == W[i][0]:
            counter += 1
    if counter == N-1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#include <unordered_set>
#include <unordered_map>

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
typedef set<LL> SLL;
typedef unordered_set<LL> USLL;
typedef string STR;

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;

int main() {
  std::string s, t;
  R(s, t);
  LL res = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      ++res;
    }
  }
  W(res);
  return 0;
}


Measured memory_bytes: 3864
#coding:utf-8
# O(Dlogn)解法?
N,K=map(int, raw_input().split(" "))   
D=map(int, raw_input().split(" "))   
keta=len(str(N))
strN=str(N)
ans1=""
for x in range(keta-1):
    p=int(strN[keta-x-1])
    d=0
    for dd in range(10):
        if dd not in D:
            d=dd
            break
    ans1=str(d)+ans1
candidate=int(strN[0])
def ok(n):
    s=str(n)
    for ss in s:
        if int(ss) in D: return False
    return True
while True:
    if ok(candidate) and int(str(candidate)+ans1)>=N: # shit
        break
    candidate+=1

ans1=str(candidate)+ans1
if ok(N):
    print(N)
else:
    print(int(ans1))

Measured memory_bytes: 2696
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static int ccw(double x1, double y1, double x2, double y2, double x3, double y3) {
		x2 -= x1;x3 -= x1;y2 -= y1;y3 -= y1;
		double c = x2 * y3 - x3 * y2;
		if (c > 0)return +1;
		if (c < 0)return -1;
		if (x2 * x3 + y2 * y3 < 0)return +2;
		if (x3 * x3 + y3 * y3 - x2 * x2 - y2 * y2 > 0)return -2;
		return 0;
	}
	public static double[][] convexHull(double[][] ps) {
		int n = ps.length, k = 0;
		Arrays.sort(ps, new Comparator<double[]>() {
			public int compare(double[] a, double[] b) {
				double x = a[0] - b[0];
				double y = a[1] - b[1];
				if (x != 0)return x > 0 ? 1 : -1;
				if (y != 0)return y > 0 ? 1 : -1;
				return 0;
			}
		});
		double[][] ch = new double[2*n][];
		for (int i = 0; i < n; ch[k++] = ps[i++])
			while (k >= 2 && ccw(ch[k - 2][0], ch[k - 2][1], ch[k - 1][0], ch[k - 1][1], ps[i][0], ps[i][1]) <= 0)
				--k;
		for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
			while (k >= t && ccw(ch[k - 2][0], ch[k - 2][1], ch[k - 1][0], ch[k - 1][1], ps[i][0], ps[i][1]) <= 0)
				--k;
		return Arrays.copyOf(ch, k - 1);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in).useDelimiter("[^0-9\\-\\.]+");
		while(true){
			int n = Integer.parseInt(sc.next());
			if(n==0)break;
			double[][] ps = new double[n][2];
			for(int i = 0;i<n;i++){
				ps[i][0] = Double.parseDouble(sc.next());
				ps[i][1] = Double.parseDouble(sc.next());
			}
			double[][] ch = convexHull(ps);
			System.out.println(n-ch.length);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	vector<int>H(N);
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	int total=1,hei=H[0];	
	for(int j=1;j<N;j++){
		if(H[j]>=hei){
			total++;
			hei=H[j];
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,m,dp[5000][1100];
int a[1100], b[1100];bool c[1100][20];
signed main(){
  cin>>n>>m;
  repd(i,1, m+1){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
      int cc;cin>>cc;cc--;
      c[i][cc] = true;
    }
  }
  rep(i,5000)rep(j,1100)dp[i][j] = INF;
  dp[0][0] = 0;
  repd(i,1,m+1){
    rep(bit,1<<n){
      dp[bit][i] = dp[bit][i-1];
      int nbit = bit;
      rep(j,n){
        if(bit&(1<<j) && c[i][j])nbit &= ~(1<<j);
      }
      chmin(dp[bit][i], dp[nbit][i-1]+a[i]);
    }
  }
  int ans = INF;
  repd(i,1,m+1)chmin(ans, dp[(1<<n)-1][i]);
  cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 43264
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pll pair<long long int, long long int>
#define great (long long int)(1e9+7)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fst first
#define scd second

void solve()
{
   string s,T;
   cin>>s>>T;
   ll c=0;
   ll l=s.length();
   for(ll i=0;i<l;i++)
   {
       if(s[i]!=T[i])
        c++;

   }
   cout<<c<<endl;
}
int main()
{
    //fastio;
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  vector<string> S(h); rep(i, h) cin >> S[i];
  queue<int> q;
  vector<int> dis(h*w, inf);
  vector<int> vis(h*w);
  q.push(0);
  dis[0] = 0;
  int dx[] = {-1, 0, 1, 0};
  int dy[] = {0, 1, 0, -1};
  vector<int> par(h*w);
  while(!q.empty()) {
    int cur = q.front(); q.pop();
    int x = cur/w;
    int y = cur%w;
    if(vis[cur]) continue;
    vis[cur] = true;
    rep(k, 4) {
      int nx = x+dx[k];
      int ny = y+dy[k];
      int ne = nx*w+ny;
      if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if(vis[ne]) continue;
      if(S[nx][ny] == '#') continue;
      if(dis[ne] > dis[cur]) {
        dis[ne] = dis[cur]+1;
        par[ne] = cur;
        q.push(ne);
      }
    }
  }
  if(dis[h*w-1] == inf) cout << -1 << endk;
  else {
    set<int> st;
    int tmp = h*w-1;
    while(tmp != 0) {
      st.insert(tmp);
      tmp = par[tmp];
    }
    st.insert(0);
    int ans = 0;
    rep(i, h) rep(j, w) {
      if(!st.count(i*w+j) && S[i][j] == '.') ans++;
    }
    cout << ans << endk;
  }
  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int k, t;
    cin >> k >> t;
    map<int,int> mii;
    rep(i,t){
        int a;
        cin >> a;
        mii[i] = a;
    }
    priority_queue<pair<int, int>> que;
    for(auto u : mii){
        que.push({u.second, u.first});
    }
    int ans = 0;
    int pre = -1;
    while(!que.empty()){
        int top_first = que.top().first;
        int top_second = que.top().second;
        que.pop();
        if(top_second == pre){
            if(!que.empty()){
                int second_first = que.top().first;
                int second_second = que.top().second;
                que.pop();
                pre = second_second;
                que.push({top_first, top_second});
                if(second_first > 1){
                    que.push({second_first - 1, second_second});
                }
                
            }else{
                ans = top_first;
                break;
            }
        }else{
            pre = top_second;
            if(top_first > 1){
                que.push({top_first - 1, top_second});
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N,K,l[60];
  cin >> N >> K ;
  cinf(N,l) ;
  sort(l ,l+N,greater<int>()) ;
  int ans ;
  for(int i=0;i<K;i++){
    ans += l[i] ;
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 384
var
  s,t:string;
  i:longint;
begin
  readln(s);
  for i:=length(s) downto 1 do t:=t+s[i];
  for i:=1 to length(t) do
  case t[i] of
   'b': t[i]:='d'; 
   'd': t[i]:='b';
   'p': t[i]:='q';
   'q': t[i]:='p';
  end;
  if t=s then writeln('Yes')
         else writeln('No');
end.

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

int main(){
	int n,m;
	cin >> n >> m;
	map<int,int> mp;
	rep(i,n){
		int k;
		cin >> k;
		rep(i,k){
			int a;
            cin >> a;
			mp[a]++;
		}
	}
	int cnt = 0;
	for(auto p:mp){
		if(p.second == n) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ld n, m; cin >> n >> m;
	ld a = m * 1900 + (n - m) * 100;
	cout << int(a * pow(2, m) + 1e-6) << endl;
	return 0;
}

Measured memory_bytes: 640
def gcd(x, y):
    if y == 0:
        return x
    if x < y:
        return gcd(y, x)
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(x, y)


N, M = map(int, input().split())
s = input()
t = input()

g = gcd(N, M)
l = lcm(N, M)

n = N // g
m = M // g

k = 0
flg = True
while k * n * m < l:
    if s[k * n] != t[k * m]:
        flg = False
        break
    k += 1

print(l if flg else -1)


Measured memory_bytes: 3316
#include <iostream> 
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <cstring>

#define mp make_pair
#define s second
#define f first
#define ll long long
using namespace std;
ll size[103], value[103], dp[100003];

int main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	for (int i=0; i<n; i++) {
		cin >> size[i] >> value[i];
		for (int j=m; j-size[i]>=0; j--) {
			dp[j] = max(dp[j], dp[j-size[i]] + value[i]);
		} 
	}
	
	cout << dp[m];	
return 0;	
}




Measured memory_bytes: 1024
n,c,k = [int(x) for x in input().split()]
t = [int(input()) for _ in range(n)]
t.sort()
bus = c
f_bus = 0
ans = 0
for i in range(n):
    if t[i] > f_bus or bus == 0:
        ans += 1
        f_bus = t[i]+k
        bus = c-1
    else:
        bus -= 1

print(ans)

Measured memory_bytes: 7384
n = gets.to_i
G = Array.new(n){Array.new(n,true)}
ans = n*(n-1)/2
if n%2 == 0
  (n/2).times do |i|
    G[i][n-i-1] = false
    ans -= 1
  end
else
  ((n-1)/2).times do |i|
    G[i][n-i-2] = false
    ans -= 1
  end
end
p ans
n.times do |i|
  (i+1).upto(n-1) do |j|
    if G[i][j]
      puts "#{i+1} #{j+1}"
    end
  end
end


Measured memory_bytes: 1916
n, m = map(int, input().split())
if m == 1:
    print(1, 2)
    exit()
l1 = 1
l2 = m + 2
f = True
for length in range(m, 0, -1):
    if f:
        print(l1, l1 + length)
        l1 += 1
        f = not f
    else:
        print(l2, l2 + length)
        l2 += 1
        f = not f


Measured memory_bytes: 9224
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

typedef pair<long long int, long long int> P;

int main(){
	
	int n;
	cin >> n;
	
	cout << n << ":";
	
	for(int i = 2; i * i <= n; i++){
		while(n % i == 0){
			n /= i;
			cout << " " << i;
		}
	}
	
	if(n != 1){
		cout << " " << n;
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

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

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

    if(a<b && b<c){
    System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26088