akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

int g[305][305]; 
map <int,int> mp; 

inline void solve(){
    int r,c,k,cnt=0; cin>>r>>c>>k; 
    string s;
    for (int i=0;i<r;i++){
        cin>>s;
        int cur=0;
        for (int j=0;j<c;j++){
            if (s[j]=='#'){
                cnt++;cur++;
                g[i][j]=cnt;
            }
        }
        mp[i]=cur;
    }
    for (int i=0;i<r;i++){
        if (mp[i]==0) continue;
        for (int j=1;j<c;j++){
            if (g[i][j]==0) g[i][j]=g[i][j-1];
        }
    }
    for (int i=0;i<r;i++){
        if (mp[i]==0) continue;
        for (int j=c-2;j>=0;j--){
            if (g[i][j]==0) g[i][j]=g[i][j+1];
        }
    }
    for (int i=1;i<r;i++){
        if (mp[i]) continue;
        for (int j=0;j<c;j++) g[i][j]=g[i-1][j];
        if (g[0][0]) mp[i]=1;
    }
    for (int i=r-2;i>=0;i--){
        if (mp[i]) continue;
        for (int j=0;j<c;j++) g[i][j]=g[i+1][j];
    }
    for (int i=0;i<r;i++){
        for (int j=0;j<c;j++) 
            cout << g[i][j] << " " ;
        cout << endl; 
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4332
n, k = map(int, input().split())
s = ['R'] + list(input()) + ['L']

#print(s)

ans = 0

u = 0
for i in range(1, n+1):
    if s[i] == 'L':
        if s[i-1] == 'L':
            ans += 1
    if s[i] == 'R':
        if s[i+1] == 'R':
            ans += 1
        else:
            u += 1

if k >= u:
    print(n-1)
else:
    print(ans + (k * 2))

Measured memory_bytes: 4664
#include<iostream>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	if(x+a>=b)
	{
		if(a>=b)
		{
			cout<<"delicious";
			return 0;
		}
		cout<<"safe";
		return 0;
	}
	cout<<"dangerous";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=109,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline void addto(int &x,int y){x=x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int f[N][N][N],a[N],n;
	int main(){
		n=read<int>();
		for(int i=1;i<=2*n-1;i++) a[i]=read<int>();
		sort(a+1,a+2*n);

		f[n][1][0]=1;
		for(int i=n-1;i>=1;i--){
			for(int l=0;l<=2*n-1;l++)
				for(int r=0;l+r<=2*n-1;r++) if(f[i+1][l][r]){
					int tmp=f[i+1][l][r],dl=(a[i]!=a[i+1]),dr=(a[2*n-i-1]!=a[2*n-i]);
					for(int nl=1;nl<=l+dl;nl++) addto(f[i][l-nl+dl+1][r+dr+(nl>1)],tmp);
					for(int nr=1;nr<=r+dr;nr++) addto(f[i][l+dl+1][r-nr+dr],tmp);
				}
		}
		int ans=0;
		for(int l=0;l<=2*n-1;l++)
			for(int r=0;l+r<=2*n-1;r++) ans=add(ans,f[1][l][r]);
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 4980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());

			if(n == 0){
				break;
			}

			int[][] area = new int[21][21];

			for(int i = 0; i < n; i++){
				String[] tmpArray = br.readLine().split(" ");
				int x = Integer.parseInt(tmpArray[0]);
				int y = Integer.parseInt(tmpArray[1]);

				area[y][x] = 1;
			}

			int m = Integer.parseInt(br.readLine());

			int currentX = 10;
			int currentY = 10;
			int caught = 0;

			for(int i = 0; i < m; i++){
//				System.out.println("x = "+currentX +" y = "+currentY);
				String[] tmpArray = br.readLine().split(" ");

				String op = tmpArray[0];
				int d = Integer.parseInt(tmpArray[1]);

				if(op.equals("N")){
					for(int j = 1; j <= d ;j++ ){
//						System.out.println("North j = "+j+" gem "+area[currentY + d][currentX] );
						if(area[currentY + j][currentX] > 0){
//							System.out.println("N GET!!");
							caught++;
							area[currentY + j][currentX]--;
						}
					}
					currentY += d;
				}
				if(op.equals("S")){
					for(int j = 1; j <= d ;j++ ){
						if(area[currentY - j][currentX] > 0){
//							System.out.println("S GET!!");
							caught++;
							area[currentY - j][currentX]--;
						}
					}
					currentY -= d;
				}
				if(op.equals("W")){
					for(int j = 1; j <= d ;j++ ){
						if(area[currentY][currentX - j] > 0){
//							System.out.println("W GET!!");
							caught++;
							area[currentY][currentX - j]--;
						}
					}
					
					currentX -= d;
				}
				if(op.equals("E")){
					for(int j = 1; j <= d ;j++ ){
						if(area[currentY][currentX + j] > 0){
//							System.out.println("E GET!!");
							caught++;
							area[currentY][currentX + j]--;
						}
					}
					
					currentX += d;
				}
				
				
			}
			
			if(caught == n){
				System.out.println("Yes");
			}
			
			else {
				System.out.println("No");
			}

		}
	}

}

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

int main() {
	long long n;cin>>n;
	vector<long long> v(1000,1),v2(1000,0);
//	for(int i=0;i<1000;i++){
//		v[i]=i;
//	}
	v[0]=0;
	v[1]=0;
	for(int i=0;i<1000;i++){
		if(v[i]){
			long long mul=2;
			while(mul*i<=1000){
				v[mul*i]=0;
				mul++;
//				cout<<i<<' '<<v[i]<<' '<<mul<<endl;
			}
		}
	}
	for(int i=2;i<=n;i++){
		long long num=i;
		for(int j=2;j<=n;j++){
			if(v[j]){
				while(num%j==0){
					v2[j]++;
					num/=j;
				}
			}
		}
	}
	long long ans=1;
	long long def=1;
	for(int i=0;i<9;i++){
		def*=10;
	}
	def+=7;
	for(int i=0;i<=n;i++){
		if(v2[i]){
			ans*=v2[i]+1;
			if(ans>=def)ans%=def;
//			cout<<i<<' '<<v2[i]<<endl;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::{self, Read};
use std::iter::FromIterator;

trait Source {
    fn next_chr(&mut self) -> char;
    fn next_str(&mut self) -> String;
}

#[allow(dead_code)]
fn from_stdin() -> SourceImpl {
    let mut data = String::new();
    io::stdin().read_to_string(&mut data).expect("Input error");
    from_str(&data)
}

fn from_str(s: &str) -> SourceImpl {
    let data = String::from(s);
    let chars = data.chars().collect::<Vec<char>>().into_iter();
    SourceImpl { chars: chars }
}

struct SourceImpl {
    chars: std::vec::IntoIter<char>,
}

impl Source for SourceImpl {
    fn next_chr(&mut self) -> char {
        self.chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self
            .chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.is_empty() {
            panic!("eof")
        } else {
            s
        }
    }
}

#[allow(unused_macros)]
macro_rules! input {
    ($src:expr; $($elem:tt)*) => {
        input_inner!($src, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = parse!($src, $ty);
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

fn main() {
    let mut src = from_stdin();
    input! { src; h: usize, w: usize, a: usize, b: usize }

    println!("{}", h * w - (a * w + (b * (h - a))));
}


Measured memory_bytes: 4352
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  if InputLine.to_i == 0 then
    puts '1'
  else
    puts '0'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14312
a,b=map(int,input().split())
grid=[["." for i in range(100)] for j in range(50)]+[["#" for i in range(100)] for j in range(50)]
white=0;black=0
for i in range(49):
    if black==b-1:break
    if i%2==0:continue
    for j in range(100):
        if i%2==j%2:
            grid[i][j]="#"
            black+=1
        if black==b-1:break
    
for i in range(50,100):
    if white==a-1:break
    if i%2==0:continue
    for j in range(100):
        if i%2==j%2:
            grid[i][j]="."
            white+=1
        if white==a-1:break
print(100,100)
for i in range(100):
    stri=""
    for j in grid[i]:
        stri+=j
    print(stri)


Measured memory_bytes: 39792
# coding: utf-8
from math import gcd

def getPrime(x):
    num_list=[i for i in range(2,x+1)]
    prime_list=[]
    D=[x+1 for i in range(x+1)]
    
    while num_list[0]<x**(1/2):
        p=num_list.pop(0)
        prime_list.append(p)
        for i in range(len(num_list)):
            if num_list[i]%p==0:
                if D[num_list[i]]>p:
                    D[num_list[i]]=p
        num_list = [e for e in num_list if e % p != 0]
    
    prime_list = prime_list + num_list
    for i in range(len(prime_list)):
        D[prime_list[i]] = prime_list[i]
    D[0]=1
    D[1]=1
    return D

N = int(input())
A = list(map(int,input().split()))

if max(A) == 1:
    print("pairwise coprime")
    exit()

D = getPrime(max(A))

pc_flg = True

x = A[0]
for i in range(N):
    x = gcd(x,A[i])

prime_flg=[False for i in range(10**6+1)]

for i in range(N):
    num = A[i]
    primes = []
    while True:
        p = D[num]
        num = num//p
        primes.append(p)
        if num == 1:
            break
    for j in set(primes):
        if not(prime_flg[j]):
            prime_flg[j] = True
        else:
            if j != 1:
                pc_flg = False


if pc_flg:
    print("pairwise coprime")
elif x==1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 251884
import std.stdio;
import std.array;
import std.string;
import std.algorithm;
import std.conv;

void main() {
    int n;
    while (readf("%d\n", &n), n) {
        string[] index = new string[n];
        bool[][] table = new bool[][n];
        int x = 0;
        int[string] point;
        foreach (i; 0 .. n) {
            string name;
            readf("%s ", &name);
            index[x] = name;
            table[x] = new bool[31];
            foreach (d; readln.chomp.split(" ").map!(to!int).array[1 .. $]) {
                table[x][d] = true;
            }
            x++;
        }
        foreach (i; 0 .. n) {
            point[index[i]] = 0;
        }
        foreach (d; 0 .. 31) {
            int c = 0;
            foreach (i; 0 .. n) {
                c += table[i][d];
            }
            foreach (i; 0 .. n) {
                if (table[i][d]) {
                    point[index[i]] = point.get(index[i], 0) + (n - c + 1);
                }
            }
        }
        int minPoint = int.max;
        string minName;
        foreach (k, v; point) {
            if (minPoint > v) {
                minPoint = v;
                minName = k;
            }
            if (minPoint == v && minName > k) {
                minName = k;
            }
        }
        writeln(minPoint, " ", minName);
    }
}

Measured memory_bytes: 1768
# coding: utf-8
L=[0 for i in range(4)]

for i in range(3):
    a,b=map(int,input().split())
    L[a-1]+=1
    L[b-1]+=1

cnt1=0
cnt2=0

for i in range(4):
    if L[i]==1:
        cnt1+=1
    elif L[i]==2:
        cnt2+=1

if cnt1==cnt2==2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool han=false;
  rep(i,a){
    int in;
    cin>>in;
    for(int j=b-c;j<=b+c;j++)
      if((double)j/in-j/in==0){han=true;break;}
    if(han){cout<<i+1<<endl;break;}
  }
  if(!han)cout<<"-1"<<endl;

}

Measured memory_bytes: 1164
#include <stdio.h>


int main(){
	int x, eq=0, eq2=0, moedas=0;
	scanf("%d", &x);
	eq= x/500;
	eq2= (x%500)/5;
	moedas= (eq*1000) + (eq2 *5);
	printf("%d\n", moedas);
	return 0;
	
}

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

int main()
{
    int w, h, t, p;

    cin >> w >> h >> t;
    cin >> p;

    int x[p], y[p], z[p], a[50][50];
    for( int i = 0; i < p; i++ )
        cin >> x[i] >> y[i] >> z[i];

    for( int i = 0; i < h; i++ )
        for( int j = 0; j < w; j++ )
            cin >> a[i][j];

    for( int i = 0; i < p; i++ )
        if( a[y[i]][x[i]] != 0 )
            a[y[i]][x[i]]++;

    int sum = 0;
    for( int i = 0; i < h; i++ )
        for( int j = 0; j < w; j++ )
            if( a[i][j] - 1 >= 0 )
                sum += a[i][j] - 1;

    cout << sum << endl;

    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int ans = 0;
   int x,y;
   cin >> x >> y;
   while(x <= y) {
      ans++;
      x *= 2;
   }
   cout << ans << "\n";
}

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

vector<P>E[100000];
int d[100000], b[100000], cnt[200001], u[200000], v[200000], r[200000], que[100000];
int main() {
	int n, m, q; scanf("%d%d%d", &n, &m, &q);
	rep(i, m) {
		scanf("%d%d", &u[i], &v[i]); u[i]--; v[i]--; r[i] = q;
	}
	rep(i, q) {
		int a; scanf("%d", &a); r[a - 1] = i;
	}
	rep(i, m) {
		E[u[i]].push_back(P(v[i], r[i])); E[v[i]].push_back(P(u[i], r[i]));
	}
	d[0] = 1; b[0] = q;
	int s = 0, g = 1;
	while (s != g) {
		int p = que[s++];
		rep(i, E[p].size()) {
			P v = E[p][i];
			if (d[v.first] == 0) {
				d[v.first] = d[p] + 1; que[g++] = v.first;
			}
			if (d[v.first] == d[p] + 1)
				b[v.first] = max(b[v.first], min(b[p], v.second));
		}
	}
	rep(i, n)cnt[b[i]]++;
	int ans = 0;
	rep(i, q) {
		ans += cnt[i];
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 15932
n, m, x = map(int, input().split())
l = list(map(int, input().split()))
a = {}
for t in l:
    a[t] = 1

total1 = 0
i = x
while i >= 0:
    i -= 1
    total1 += a.get(i, 0)

total2 = 0
i = x
while i <= n:
    i += 1
    total2 += a.get(i, 0)

print(min(total1, total2))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iterator>
#include <vector>
#include <unordered_map>
#include <algorithm>

struct pair_hash {
	template <class T1, class T2>
	std::size_t operator() (const std::pair<T1, T2> &pair) const {
		return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
	}
};

int main()
{
  int a[5];
  int res = 0;
  int min = 19;
  for (int i=0; i<5; i++) {
    std::cin >> a[i];
    int x = a[i] % 10;
    if (x!=0 && x<min) min = x;
    if (x!=0) a[i] += 10 - x;
   //std::cout << a[i] << std::endl;
    res += a[i];
  }
  if (min==19) min = 10;
  res -= 10 - min;


  std::cout << res;

  return 0;
}


Measured memory_bytes: 256
var n=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var di : [Int] = []
var sum = 0;

 var i = 0; 

for i in 0..<n[0]  {
    sum += arr[i]
}

var diff = 0;
var total = 0
var min = sum
var min_i = 0

i = 0
for i in 0..<n[0] {
  total += arr[i]
  sum -= arr[i]
  
  diff = sum - total 
  
  diff = diff < 0 ? -diff: diff 
  di.append( diff  )
  
  if( min > diff ) {
    min = diff
    min_i = i
  }

}

print( di[min_i] )

Measured memory_bytes: 4080
import fractions


def binary_search(list, number, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) // 2
        guess = list[mid][0]
        if guess == number:
            if list[mid][1] == item:
                return False
            else:
                return True
        if guess > number:
            high = mid - 1
        else:
            low = mid + 1
    # 見つからなかったとき
    return False


n, m = map(int, input().split())
s = input()
t = input()
check = []
l = n * m // fractions.gcd(n, m)
for i in range(n):
    check.append([i * l // n, s[i]])
for i in range(m):
    if binary_search(check, i * l // m, t[i]):
        print(-1)
        exit()
print(l)


Measured memory_bytes: 17376
# coding:utf-8

N = int(input())
h = [int(x) for x in input().split()]

inf = 100000000000000
dp = [inf for x in range(N)]

dp[0] = 0
for i in range(1, N):
	dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
	if i >= 2:
		dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

Measured memory_bytes: 13924
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;

  for(double i=0;i<1000000;i++){
    int N = i * 0.08;
    int M = i * 0.1;
    if(a == N && b == M){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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 n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += b[a[i]-1];
        if(a[i] == 1) continue;
        if(a[i] == a[i-1] + 1) ans += c[a[i]-2];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int a,b,c;
  vector<int>v;
  cin>>a>>b>>c;
  v.push_back(a);
   v.push_back(b);
   v.push_back(c);
   /*sort(v.begin(),v.end());
   cout<<v[0]<<' '<<v[2]<<endl;*/
   cout<<*min_element(v.begin(),v.end())<<' '<<*max_element(v.begin(),v.end())<<endl;
  return 0;
}



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

using namespace std;

int main(){
	string S, T;
	while(cin >> S >> T){
		vector<int> s(S.size()+1, 0);
		vector<int> t(T.size()+1, 0);
		for(int i=0;i<S.size();i++){
			s[i+1] = (s[i] + (S[i] - 'A' + 1)) % 3;
		}
		for(int i=0;i<T.size();i++){
			t[i+1] = (t[i] + (T[i] - 'A' + 1)) % 3;
		}
		int q; cin >> q;
		for(int i=0;i<q;i++){
			int a, b, c, d; cin >> a >> b >> c >> d;
			int qs = (s[b] - s[a-1] + 3) % 3;
			int qt = (t[d] - t[c-1] + 3) % 3;
			cout << (qs == qt ? "YES" : "NO") << endl;
		}
	}
}



Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main() {
  int n, x;
  int count = 0;
  cin >> n >> x;
  while (n != 0 || x != 0) {
    count = 0;
    for (int a = 1; a <= n; a++) {
      for (int b = a + 1; b <= n; b++) {
        int c = x - a - b;
        if (c > b && c <= n) {
          count++;
        }
      }
    }
    cout << count << endl;
    cin >> n >> x;
  }
}


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

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

  vector<int> sosu;

  int arr[55555];

  for(int i = 0; i < 55555; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(55555 + 1); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < 55555 + 1; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i <= 55555; i++){
		if(arr[i]){
			sosu.push_back(i);
		}
	}

  int cnt = 0;

  for(int i = 0; i < N; i++){
    while(1){
      cnt++;
      if(sosu[cnt] % 5 == 2){
        cout << sosu[cnt] << " ";
        break;
      }
    }
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    ll N;cin >> N;
    if(N == 1){cout << "0" <<endl;}
    else{
        ll ans=0;
        ans = ((N-1)*((N-1) + 1) / 2);
        cout << ans << endl;
    }

}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.data=[-1 for i in range(n)]

    def root(self,x):
        if self.data[x]<0:
            return x
        else:
            self.data[x]=self.root(self.data[x])
            return self.data[x]
    def uni(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if(x==y):
            return
        if self.data[y]<self.data[x]:
            x,y=y,x
        self.data[x]+= self.data[y]
        self.data[y] = x

    def same(self,x,y):
        return self.root(x)==self.root(y)

    def size(self,x):
        return -self.data[self.root(x)]

n,m=map(int,input().split())
data=[]
for i in range(m):
    a,b=map(int,input().split())
    data.append((a,b))

data=data[::-1]
tmp=0
for i in range(n):
    tmp+=i
ans=[tmp]
uf=UnionFind(n)
for i in range(m):
    a,b=data[i]
    if not uf.same(a-1,b-1):
        x,y=uf.size(a-1),uf.size(b-1)
        uf.uni(a-1,b-1)
        ans.append(ans[-1]-x*y)
    else:
        ans.append(ans[-1])
print(*ans[:-1][::-1],sep='\n')


Measured memory_bytes: 26260
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b)
	{printf("a < b\n");}
	else if(a>b)
	{printf("a > b\n");}
	else
	{printf("a == b\n");}
	
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = 0; i < S.length(); i++){
        if (S[i] == '1') {
            S[i] = '9';
        }else{
            S[i] = '1';
        }
    }

    cout << S << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    long long int a,b,c,d;
    std::vector<long long int> vec(4);
    cin >> a >> b >> c >> d;
    for (size_t i = 0; i < vec.size(); ++i) {
        vec[i] = i;
    }
    vec[0] = a*c;
    vec[1] = a*d;
    vec[2] = b*c;
    vec[3] = b*d;
    long long int max = *std::max_element(vec.begin(), vec.end());
    cout << max << endl;
    /////////////////////
    return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/
int main(){
	int P,Q,R;
	cin >> P >> Q >> R;
	cout << P + Q + R - max({P,Q,R}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int n, mn = 1e9;

int obtSum (int n) {
	int res = 0;
	while (n) {
		res += n % 10;
		n /= 10;
	}
	return res;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> n;
    for (int i = 1; i < n; i++)
    	mn = min(mn, obtSum(i) + obtSum(n-i));
    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
int main() {
	int A[4];
	for (int i = 0; i < 4; i++) A[i] = getchar() - '0';
	for (int bit = 0; bit < (1 << 3); bit++) {
		int sum = A[0];
		for (int i = 0; i < 3; i++) {
			if (bit&(1 << i)) sum += A[i + 1];
			else sum -= A[i + 1];
		}
		if (sum == 7) {
			for (int i = 0; i < 4; i++) {
				cout << A[i];
				if (i == 3) break;
				if (bit&(1 << i)) cout << "+";
				else cout << "-";
			}
			cout << "=7" << endl;
			break;
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int N;

signed main() {
  cin >> N;
  vector<int> p(N), a(N), b(N);
  rep(i, N) {
    cin >> p[i];
    --p[i];
  }
  int aim = 30000;
  rep(i, N) {
    a[i] = 1 + aim * i;
    b[i] = 1 + aim * (N - i + 1);
  }
  rep(i, N) { a[p[i]] += i; }

  rep(i, N) {
    if (i) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << endl;
  rep(i, N) {
    if (i) {
      cout << " ";
    }
    cout << b[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 896
n,h = gets.split.map(&:to_i)

a = []
b = []
n.times do
    x,y = gets.split.map(&:to_i)
    a << x
    b << y
end
a = a.max
b.sort!.reverse!

sum = 0
ans = 0
while sum < h
    if b != [] && b[0] >= a
        sum += b.shift
        ans += 1
    else
        k = ((h - sum).to_f / a).ceil
        sum += a * k
        ans += k
    end
end

puts ans

Measured memory_bytes: 4508
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, i, i2, num;
	char str[10][10], a[10];
	
	strcpy (str[0] , "0111111\0");
	strcpy (str[1] , "0000110\0");
	strcpy (str[2] , "1011011\0");
	strcpy (str[3] , "1001111\0");
	strcpy (str[4] , "1100110\0");
	strcpy (str[5] , "1101101\0");
	strcpy (str[6] , "1111101\0");
	strcpy (str[7] , "0100111\0");
	strcpy (str[8] , "1111111\0");
	strcpy (str[9] , "1101111\0");
	
	while (1){
		
		strcpy (a , "0000000\0");
		scanf("%d", &n);
		
		if (n == -1){
			break;
		}
		for (i = 0; i < n; i++){
			
			scanf  ("%d", &num);
			
			for (i2 = 0; a[i2] != '\0'; i2++){
			
				if (a[i2] == str[num][i2]){
					a[i2] = '0';
				}
				else {
					a[i2] = '1';
				}
			}
			printf("%s\n", a);
			strcpy(a , str[num]);
		}
		
		
	}
	return (0);
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 10000
#define empty 0

void BFS(int);
void enqueue(int);
int dequeue();
void visit(int);

int num=0,n,Q,cnt=0;
int d[105];
//int queue[105],color[105];
int G[105][105];

int main()
{
  int i,j,u,k,v;

  scanf("%d",&n);
  if(n<1 || n>100) exit(1);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0; //初期化
    }
  }
  
  for(i=0;i<n;i++){
    
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1] = 1; //0オリジン
    }
    d[i+1] = INF;
  }

  visit(0);
  
  for(i=0;i<n;i++)
    printf("%d %d\n",i+1,((d[i]==INF)?(-1):d[i]));

  return 0;
}
/*
void BFS(int s)
{
  int i,u;
  
  for(i=0;i<n;i++){
    color[i] = WHITE; //全部白
    d[i] = INF; //支点から辿りつけるかどうかの判断をする
  }
  color[s] = GRAY; //訪問1回目
  d[s] = 0; //支点の深さは0
  num = empty; //キューに入ってる数
  enqueue(s); //0をキューの0番目に入れる

  while(num != empty){ //キューの数が空じゃない限り回す
    u = dequeue(); 
    for(i=0;i<n;i++){
      if(G[u][i] == 0) continue; 
      if(d[i] != INF) continue; //深さが1回決まったら変えない
      if(color[i] == WHITE){
	color[i] = GRAY;
	d[i] = d[u]+1;
	enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

void enqueue(int s)
{
  queue[num] = s;
  num++;
}

int dequeue()
{
  int s,i;

  s = queue[0];

  for(i=0;i<queue[num];i++)
    queue[i] = queue[i+1];

  num--;
  queue[num] = 0;
  
  return s;
}
*/
void visit(int a)
{
  int i;

  d[a] = cnt; //cntは深さをカウントする変数
  for(i=0;i<n;i++){
    if(G[a][i] == 1 && d[i] > cnt){
      cnt++;
      visit(i);
      cnt--;
    }
  }
}



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

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i = 0; i < N-1; i++){
    cin >> B.at(i);
  }
  
  int sum = B.at(N-2);
  if( N > 2){
    for(int i = N-3; i >= 0; i--){
      if( B.at(i+1) > B.at(i) ){
        sum += B.at(i);
      }else{
        sum += B.at(i+1);
      }
    }
  }
  sum += B.at(0);
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if (A % B == C) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 0; i <= 100; i++) {
    if (A * i % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  ld l=ld(n)/3;
  lfs<<l*l*l<<endl;
  return 0;
}

Measured memory_bytes: 256
let rec read_lines ic = 
  try let line = input_line ic in
    let line = int_of_string(line) in
    line :: read_lines ic
  with End_of_file -> [];;

let cmp a b = 
  if a < b then 1
  else -1;;

let heights = read_lines stdin;;

let heights = List.stable_sort cmp heights;;

print_endline(string_of_int(List.nth heights 0) );;
print_endline(string_of_int(List.nth heights 1) );;
print_endline(string_of_int(List.nth heights 2) );;

Measured memory_bytes: 2148
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int max = 55555;
        PriorityQueue<Integer> pq = prime(max);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int prime;
            while (true) {
                prime = pq.poll();
                if (prime % 10 == 1) {
                    break;
                }
            }
            
            sb.append(prime);
            sb.append(" ");
        }

        System.out.println(sb.toString());
    }

    static PriorityQueue<Integer> prime(int n) {
        boolean[] is_prime = new boolean[n+1];
        Arrays.fill(is_prime, true);
        is_prime[0] = is_prime[1] = false;
        PriorityQueue<Integer> pq = new PriorityQueue<>(n);
        for (int i = 2; i <= n; i++) {
            if (!is_prime[i]) {
                continue;
            }

            is_prime[i] = true;
            pq.add(i);
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }

        return pq;
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  rep(i,0,H) {
    cin >> S[i];
  }
  i64 ans = H * W;
  for(i64 s = 0; s < (1 << (H - 1)); s++) {
    i64 C = __builtin_popcountll(s) + 1;
    vector<i64> cnt(C);
    i64 WC = 0;
    bool CANT = false;
    rep(j,0,W) {
      vector<i64> next(C);
      i64 i = 0;
      rep(c,0,C) {
        do {
          if(S[i][j] == '1') {
            next[c]++;
          }
        } while(i++, i < H && !(s & (1 << (i - 1))));
      }
      bool OK = true;
      rep(c,0,C) {
        if(cnt[c] + next[c] > K) {
          OK = false;
        }
        if(next[c] > K) {
          CANT = true;
        }
      }
      if(CANT) {
        break;
      }
      if(OK) {
        rep(c,0,C) {
          cnt[c] += next[c];
        }
      }
      else {
        std::swap(cnt, next);
        WC++;
      }
    }
    if(!CANT) {
      ans = std::min(ans, WC + C - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
template<class T>void mini(T &a,T b){a=min(a,b);}
template<class T>void maxi(T &a,T b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
void addin(){}template<class Head,class...Tail>void addin(vector<Head>&vechead,Tail&&...tail){in(Head,head);vechead.emb(head);addin(forward<Tail>(tail)...);}
template<class C>void vecout(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}

// #define int int64_t
// #define double long double


signed main(){
  IOS;

  // in(int,d,n);
  // int x=pow(100,d)*n;
  // out(x);

  in(int,n);
  VI a(n);fou(i,0,n) cin>>a[i];
  int ans=0;
  fou(i,0,n){
    while(true){
      if(a[i]%2==0) ans++;
      else break;
      a[i]/=2;
    }
  }
  out(ans);
}

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

int main(){
  using ll = long long;
  int N, M;
  cin >> N >> M;
  vector<int> T(N);
  for(int i = 0; i < N; ++i)
    cin >> T[i];
  vector<vector<pair<int,int>>> G(N);
  for(int i = 0; i < M; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    --a,--b;
    G[a].emplace_back(c,b);
    G[b].emplace_back(c,a);
  }
  int K;
  cin >> K;
  vector<int> X(K), D(K), P(K);
  for(int i = 0; i < K; ++i){
    cin >> X[i] >> D[i] >> P[i];
    --X[i];
  }
  priority_queue<array<ll,3>,vector<array<ll,3>>,greater<>> pq;
  pq.push({0,0,0});
  const ll INF = 1e18;
  vector<ll> cost(N,INF), day(N,INF), from(N,-1);
  cost[0] = 0;
  day[0] = 0;
  from[0] = 0;
  auto update = [&](int v, ll c, int d, int f){
                  if(cost[v] < c) return false;
                  if(cost[v] > c){
                    cost[v] = c;
                    day[v] = d;
                    from[v] = f;
                    return true;
                  }
                  if(day[v] < d) return false;
                  if(day[v] > d){
                    day[v] = d;
                    from[v] = f;
                    return true;
                  }
                  if(from[v] < 0 or T[from[v]] > T[f]){
                    from[v] = f;
                    return true;
                  }
                  return false;
                };

  while(pq.size()){
    auto p = pq.top();
    pq.pop();
    ll c = p[0], d = p[1], v = p[2];
    if(cost[v] != c or day[v] != d) continue;
    for(auto e : G[v]){
      ll c_ = c + e.first, d_ = d + 1, v_ = e.second;
      if(update(v_,c_,d_,v)){
        pq.push({c_,d_,v_});
      }
    }
  }
  // for(int i = 0; i < N; ++i){
  //   printf("v = %d, cost = %lld, day = %lld, from = %lld\n",i,cost[i],day[i],from[i]);
  // }

  vector<vector<int>> nex(N,vector<int>(25,-1));
  for(int i = 0; i < N; ++i){
    nex[i][0] = from[i];
  }
  for(int i = 1; i < 25; ++i){
    for(int j = 0; j < N; ++j){
      nex[j][i] = nex[nex[j][i-1]][i-1];
    }
  }
  for(int i = 0; i < K; ++i){
    int x = X[i], d = D[i], p = P[i];
    if(day[x] <= d){
      cout << max(0LL,cost[x]-p) << "\n";
      continue;
    }
    ll ans = cost[x];
    int v = x;
    for(int j = 24; j >= 0; --j){
      if(day[nex[v][j]] > d){
        v = nex[v][j];
      }
    }
    if(day[v] > d){
      v = nex[v][0];
    }
    ans -= cost[v];
    ans += max(0LL,cost[v]-p);
    cout << ans << "\n";
  }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    if (n>=1000){
        cout<<"ABD\n";
    }else{
        cout<<"ABC\n";
    }
    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);
		String s = sc.next();
		sc.close();
		
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < s.length();i+=2)
			sb.append(s.charAt(i));
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 28304
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;


int main()
{
#ifdef NIGHT_13
    //freopen("in.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    printf("%d\n", (int)sqrt(n)*(int)sqrt(n));
    return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import deque
from sys import exit

MOD = 1000000007

n, k = getList()
if n == 1:
    print(k % MOD)
    exit()
vertex = [[] for i in range(n)]

for i in range(n-1):
    a, b = getList()
    vertex[a-1].append(b-1)
    vertex[b-1].append(a-1)

for i, v in enumerate(vertex):
    if len(v) == 1:
        root = i
        break

MOD = 1000000007

# initialize
q = deque([])
q.append(vertex[root][0])
q.append(-1)
visited = [0 for i in range(n)]
visited[root] = 1
ans = k
uni = 1
while(q):
    # print(q)
    nxt = q.popleft()

    if nxt == -1:
        uni = 2
        continue
    if visited[nxt] == 1:
        continue
    for edge in vertex[nxt]:
        if visited[edge] == 0:
            q.append(edge)
    q.append(-1)
    ans *= k - uni
    ans = ans % MOD
    uni += 1
    visited[nxt] = 1
    # print(nxt, ans)

print(ans)


Measured memory_bytes: 69920
N, K = map(int, input().split())

kid = [0] * (N + 1)

num = 0

for i in range(1, K + 1):
  d = int(input())
  sweet = input().split()
  for j in range(d):
    kid[int(sweet[j])] += 1
    
for s in range(1, N + 1):
  if kid[s] == 0:
    num += 1

print(num)

Measured memory_bytes: 9196
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
n,m=map(int, input().split())
Edges=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int, input().split())
    Edges[a-1].append(b-1)
    Edges[b-1].append(a-1)
q=int(input())
Q=[list(map(int,input().split())) for _ in range(q)][::-1]
Visited=[-1]*n
Color=[0]*n
que=deque()
for v,d,c in Q:
    v-=1
    if Visited[v]>=d:
        continue
    Visited[v]=d
    que.append((v,d))
    while que:
        v,d=que.popleft()
        if not Color[v]:
            Color[v]=c
        d-=1
        for i in Edges[v]:
            if Visited[i]>=d:
                continue
            Visited[i]=d
            que.append((i,d))
print(*Color,sep="\n")

Measured memory_bytes: 54044
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b;
	cin >> a >> b;
	cout << (a * b % 2 != 0 ? "Yes" : "No") << endl;
	return 0;
}
 

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

int main(int argc, char const *argv[])
{	
	int a,b,k;
	int p = 0;
	vector<int> v(100);
	cin >> a >> b >> k;
	for (int i = 1; i <= ((a < b) ? a : b); ++i)
	{
		if(!(a % i) && !(b % i)){
			v.at(p) = i;
			++p;
		}	
	}
	cout << v.at(p - k) << endl;
	return 0;
}


Measured memory_bytes: 256
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)
    return divisors
  
n = int(input())
d = make_divisors(n)
d.sort()
a = []
for i in range(len(d)-1):
  b = n // d[i]
  if b == d[i]:
    a.append([d[i], d[i]])
    break
  for j in range(i+1, len(d)):
    if b == d[j]:
      a.append([d[i], d[j]])
      break
m = n
ind = 0
for i in a:
  if abs(i[0]-i[1]) < m:
    m = abs(i[0]-i[1])
    ind = a.index(i)

print(a[ind][0]+a[ind][1]-2)

Measured memory_bytes: 3548