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

int main()
{
    int A, B, Q;
    cin >> A >> B >> Q;

    vector<long long> s(A + 2);
    s[0] = -99999999999;
    s[A + 1] = 99999999999;
    for (int i = 1; i <= A; i++)
    {
        cin >> s[i];
    }

    vector<long long> t(B + 2);
    t[0] = -99999999999;
    t[B + 1] = 99999999999;
    for (int i = 1; i <= B; i++)
    {
        cin >> t[i];
    }

    long long ans;
    long long x;
    for (int i = 0; i < Q; i++)
    {
        cin >> x;

        vector<long long>::iterator s_it = lower_bound(s.begin(), s.end(), x);
        long long s_r = *s_it;
        s_it--;
        long long s_l = *s_it;

        vector<long long>::iterator t_it = lower_bound(t.begin(), t.end(), x);
        long long t_r = *t_it;
        t_it--;
        long long t_l = *t_it;

        ans = x - min(s_l, t_l);
        ans = min(ans, max(s_r, t_r) - x);
        ans = min(ans, x - s_l + t_r - s_l);
        ans = min(ans, t_r - x + t_r - s_l);
        ans = min(ans, x - t_l + s_r - t_l);
        ans = min(ans, s_r - x + s_r - t_l);
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
mod = 10 ** 9 + 7

def fact(n,k,mod):
    res = 1
    for i in range(k):
        res = res * (n-i) % mod
    return res % mod

n, a, b = map(int, input().split())

ans = pow(2,n,mod) - 1

ans = (ans - fact(n,a,mod)*pow(fact(a,a,mod),mod-2,mod)) % mod
ans = (ans - fact(n,b,mod)*pow(fact(b,b,mod),mod-2,mod)) % mod

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	string s,t;
	cin>>s>>t;
	int ans=1e9;
	rep(i,size(s)-size(t)+1){
		int cnt=0;
		rep(j,size(t)){
			if(s[i+j]!=t[j]){
				cnt++;
			}
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  cin >> n;
  VI s(n);
  VI t, u;
  REP(i, 0, n) {
    cin >> s[i];
    if (s[i] % 10 == 0) {
      t.push_back(s[i]);
    } else {
      u.push_back(s[i]);
    }
  }
  if (u.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  int tot = 0;
  sort(u.begin(), u.end());
  REP(i, 0, u.size()) {
    tot += u[i];
  }
  REP(i, 0, t.size()) {
    tot += t[i];
  }
  if (tot % 10 == 0) {
    tot -= u[0];
  }
  cout << tot << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAXM 3
#define MAXN 31
#define INF 0x3f3f3f3f
using namespace std;
int N, C;
int grid[MAXN][MAXN], ans[MAXM][MAXN];
int good = INF;

int main () {
cin >> N >> C;
for (int i=1; i<=C; i++) {
for (int j=1; j<=C; j++) {
cin >> grid[i][j];
}
}
for (int i=1, x; i<=N; i++) {
for (int j=1; j<=N; j++) {
cin >> x;
for (int k=1; k<=C; k++)  ans[(i + j) % 3][k] += grid[x][k];
}
}
for (int i=1; i<=C; i++) {
for (int j=1; j<=C; j++) {
for (int k=1; k<=C; k++) {
if (i == j || i == k || j == k) continue;
good = min(good, ans[0][i] + ans[1][j] + ans[2][k]);
}
}
}
cout << good << endl;
  return 0;
}

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

struct UnionFind {
    vector<int> Parent;
    vector<int> Size;

    UnionFind(int N) : Parent(N), Size(N,1){
        for(int i = 0; i < N; i++) Parent[i] = i;
    }

    int root(int A) {
        if (Parent[A] == A) return A;
        return Parent[A] = root(Parent[A]);
    }

    bool merge(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return false;

        if (Size[A] < Size[B]) swap(A, B);

        Size[A] += Size[B];
        Parent[B] = A;
        return true;
    }

    bool issame(int A, int B) { //
        return root(A) == root(B);
    }

    int findsize(int A) {
        return Size[root(A)];
    }
};

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

  int n,m;
  cin >> n >> m;

  UnionFind Tree(n);
  rep(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    x--, y--;
    Tree.merge(x,y);
  }
  set<int> st;
  for (int i = 0; i < n; i++) {
    int root = Tree.root(i);
    st.insert(root);
  }
  int answer = (int)st.size();
  cout << answer << '\n';
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w; cin>>h>>w;
  vector<string> P(h);
  rep(i,h) cin>>P.at(i);
  rep(i,h){
    cout<<P.at(i)<<endl;
    cout<<P.at(i)<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
  long long a;
  double b;
  cin >> a >> b;
  b = b*100+0.1;
  long long ans = a*(long long)b;
  cout << ans/100 << endl;
}


Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  vector<int>v;
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    v.push_back(k);
  }
   sort(v.begin(),v.end());
 int sum=0;
  for(int i=0;i<k;i++){
    sum+=v[i];
  }
      cout<<sum;
      return 0;
      }

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1+a2+a3 > 21) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}

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

using namespace std;

#define int long long
#define endl "\n"

void rwf() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

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

	//rwf();

	int n, sum = 0;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				sum += __gcd(i, __gcd(j, k));
			}
		}
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 3652
import sys
import os
import math
import string
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    H = il()
    ret = 0
    for h in H:
        if h >= K: ret += 1
    print(ret)


if __name__ == '__main__':
    main()


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long cnt1 = b / c - (a - 1) / c;
        long cnt2 = b / d - (a - 1) / d;
        long cnt3 = b / lcm(c, d) - (a - 1) / lcm(c, d);
        long ans = b - (a - 1) - (cnt1 + cnt2 - cnt3);
        System.out.println(ans);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23124
using System;

class Program
{
    static void Main()
    {
		uint S = uint.Parse(Console.ReadLine());

		uint h = S / 3600;
		uint m = S % 3600 / 60;
		uint s = S % 60;

		Console.WriteLine("{0}:{1}:{2}", h, m, s);
		Console.ReadLine();
    }
}


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int n,x;
int main()
{
	scanf("%d",&n);int tot=0,c1=0;
	for(int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		if(x%4==0) tot++;
		if(x%2==0&&x%4!=0) c1++;
	}
	if(tot+c1/2>=n/2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>1
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 50
#define P pair<int,int>
using namespace std;
int n;
int maxx;
int d[Maxn][Maxn];//d[i][j]从i到j的最短距离
void Floyd()
{
    for(int k=0; k<=maxx;k++)
        for(int i=0;i<=maxx;i++)
            for(int j=0;j<=maxx;j++)
                d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
}
int main()
{
    IOS;
    while(cin>>n,n)
    {
        MEM(d,INF);
        for(int i=0;i<=n;i++)
            d[i][i]=0;
        maxx=-1;
        while(n--)
        {
            int a,b,c;
            cin>>a>>b>>c;
            maxx=max(maxx,max(a,b));
            d[a][b]=d[b][a]=c;
        }
        Floyd();
        int ans=INF;
        int pos;
        for(int i=0;i<=maxx;i++)
        {
            int sum=0;
            for(int j=0;j<=maxx;j++)
                sum+=d[i][j];
            if(ans>sum)
            {
                ans=sum;
                pos=i;
            }
        }
        cout<<pos<<" "<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <vector>
#include <cassert>

template<class T>
struct potentialized_union_find {
    using value_type = T;
    using size_type = std::size_t;
private :
    size_type _size;
    std::vector<int> node;
    std::vector<value_type> potential;

public :
    potentialized_union_find (size_type n, const value_type &ie) : 
        _size(n), node(n, -1), potential(n, ie) { }

    size_type root (size_type x) {
        if (node[x] < 0) return x;
        int r = root(node[x]);
        potential[x] += potential[node[x]];
        return (node[x] = r);
    }

    value_type weight (size_type x) {
        root(x);
        return (potential[x]);
    }

    bool unite (size_type x, size_type y, value_type p) {
        p += (weight(x) - weight(y));
        if ((x = root(x)) == (y = root(y))) return false;
        if (node[x] > node[y]) {
            std::swap(x, y);
            p = -p;
        }
        node[x] += node[y];
        node[y] = x;
        potential[y] = p;
        _size--;
        return true;
    }

    bool same (size_type x, size_type y) {
        return (root(x) == root(y));
    }

    value_type diff (size_type x, size_type y) {
        assert(same(x, y));
        return (weight(y) - weight(x));
    }

    const size_type& size () const noexcept {
        return (_size);
    }

    size_type size (size_type x) {
        return (size_type(-node[root(x)]));
    }

};


#include <iostream>

int main() {
    std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
    
    std::size_t n;
    int query;
    std::cin >> n >> query;

    potentialized_union_find<int> uf(n, 0);

    while (query--) {
        int type;
        std::size_t x, y;
        std::cin >> type >> x >> y;
        if (type == 0) uf.unite(x, y, 0);
        else std::cout << uf.same(x, y) << '\n';
    }

    return 0;
}


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

int steps(int num){
	if (num == 0)
		return 0;
	int count = __builtin_popcount(num);
	return 1 + steps(num % count);
}

signed main(){
	int n; cin >> n;
	vector<char> x(n);
	int m = 0;
	for (int i=0; i<n; ++i){
		char inp; cin >> inp;
		if (inp == '1') m++;
		x[i] = inp;
	}

	
	int rem_minus = 0;
	int rem_plus = 0;
	int cur_m = 1;
	int cur_p = 1;
	for (int i=n-1; i>=0; --i){
		if (x[i] == '1'){
			if (m > 1){
				rem_minus = (rem_minus + cur_m)%(m-1);

			}
			rem_plus = (rem_plus + cur_p)%(m+1);
		}

		if (m > 1)
			cur_m = (cur_m*2)%(m-1);
		cur_p = (cur_p*2)%(m+1);
	}

	vector<int> ans(n);
	cur_m = 1; cur_p = 1;
	for (int i=n-1; i>=0; --i){
		if (x[i] == '0'){
			int val = rem_plus;
			val = (val + cur_p)%(m+1);
			ans[i] = 1 + steps(val);
		}
		else {
			if (m == 1){
				ans[i] = 0;
			}
			else {
				int val = rem_minus;
				val = (val - cur_m)%(m-1);
				if (val < 0) val += (m-1);
				ans[i] = 1 + steps(val);
			}
			
		}
		if (m > 1)
			cur_m = (cur_m*2)%(m-1);
		cur_p = (cur_p*2)%(m+1);
	}

	for (int i=0; i<n; ++i){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <string.h>
int main() {

    int n,m;
    std::cin >> n >> m;
    //nC2;
    int ev = n*(n-1)/2;
        
     // mC2;
    int odd = m*(m-1)/2;

    std::cout << odd+ev << std::endl;


    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C, D);


// ===

fn powmod(a: i64, p: i64, m: i64) -> i64 {
    let mut ret = 1i64;
    let mut aa = a;
    let mut pp = p;
    while pp >= 1 {
        if pp & 1 == 1 {
            ret *= aa;
            ret %= m;
        }
        aa = aa * aa % m;
        pp >>= 1;
    }
    ret
}

fn inv(a: i64, m: i64) -> i64 {
    powmod(a, m-2, m)
}

struct Combination {
    fact: Vec<i64>,
    invfact: Vec<i64>,
    modulo: i64
}

impl Combination {
    fn new(n: usize, modulo: i64) -> Self {
        let mut fact: Vec<i64> = vec![0; n];
        let mut invfact: Vec<i64> = vec![0; n];
        fact[0] = 1;
        for i in 1..n {
            fact[i] = fact[i-1] * i as i64 % modulo;
        }
        invfact[n-1] = inv(fact[n-1], modulo);
        for i in (0..n-1).rev() {
            invfact[i] = (invfact[i+1] * (i+1) as i64) % modulo;
        }

        Combination { fact: fact, invfact: invfact, modulo: modulo }
    }

    fn combination(&self, n: usize, k: usize) -> i64 {
        if n < k {
            return 0;
        }
        self.fact[n] * self.invfact[n-k] % self.modulo * self.invfact[k] % self.modulo
    }
}

// ===

const MOD: i64 = 1000000007;

fn main() {
    let (h, w, a, b): (usize, usize, usize, usize) = read();
    let comb = Combination::new(h + w + 100, MOD);

    let mut ans: i64 = 0;
    for x in b..w {
        let y = (h - a) - 1;

        ans += comb.combination(x + y, x) * comb.combination(w - 1 - x + a - 1, a - 1) % MOD;
        ans %= MOD;
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444
import sys
from heapq import heapify,heappush,heappop
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
N=int(input())
List=[[] for i in range(N)]
for i in range(1,N):
  a=int(input())
  List[a-1].append(i)

def f(x):
  if len(List[x])==0:
    return 0
  L=[]
  heapify(L)
  for a in List[x]:
    heappush(L,f(a))
  n=len(L)
  res=0
  for i in range(n):
    b=heappop(L)
    res=max(res,b+n-i)
  return res
print(f(0))
  

Measured memory_bytes: 112712
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    A=LI()
    S=sum(A)
    A.sort(reverse=True)
    a=A[M-1]
    if a>=S/(4*M):
        print("Yes")
    else:
        print("No")

main()


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

int main() {
    int n;
    cin >> n;
    if(n % 2 == 0)
        cout << 0.50000000<< endl;
    else {
        double d = 0.0000000;
        d = d + n;
        cout << ((d + 1) / 2) / d << endl;
    }
}

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

int main(){
	int a,b,ss;
	string s;
	
	while(cin>>s){
		if(s[0]=='0')break;
		ss=s.size();
		if(ss>=22){
			
			if(s[s.size()-1]=='A'){
				cout<<ss/2+1<<" "<<ss/2-1<<endl;
			}else{
				cout<<ss/2-1<<" "<<ss/2+1<<endl;
			}
			
		}else{
			
			if(s[s.size()-1]=='A'){
				cout<<11<<" "<<ss-11<<endl;
			}else{
				cout<<ss-11<<" "<<11<<endl;
			}
			
		}
	}
	
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using P = std::tuple<int,int>;
using ll = long long;

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

array<int, 26> cnt;

int main(){
    //*
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    /*/
      /*/

    string S;
    std::cin >> S;

    for(int i=0;i<S.size();++i){
        for(int j=2;j<4;j++){
            if(i + j > S.size()){continue;}

            cnt.fill(0);

            for(int k=i;k<i+j;k++){
                ++cnt[S[k]-'a'];
            }

            bool f = false;
            for(int k=0;k<26;++k){
                if(2 * cnt[k] > j){f = true;}
            }

            if(f){
                std::cout << (i+1) << " " << (i+j) << std::endl;
                return 0;
            }
        }
    }

    std::cout << "-1 -1" << std::endl;
}


Measured memory_bytes: 512
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]+[0]
temp = 0
ans = 0
for i in range(n+1):
  if an[i] >= temp:
    an[i] -= temp
    ans += temp
  else:
    ans += an[i]
    an[i] = 0
  if an[i] >= bn[i]:
    temp = 0
    ans += bn[i]
  else:
    temp = bn[i]-an[i]
    ans += an[i]
print(ans)

Measured memory_bytes: 18396
c = [] 
for i in range(3):
  box = list(map(int, input().split()))
  c.append(box)

  
for i in range(101):
  a1 = i
  b1 = c[0][0]-a1
  b2 = c[0][1]-a1
  b3 = c[0][2]-a1
  if c[1][0]-b1 == c[1][1]-b2 == c[1][2]-b3:
    if c[2][0]-b1 == c[2][1]-b2 == c[2][2]-b3:
      print('Yes')
      exit()
print('No')


Measured memory_bytes: 3064
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ee := make([][2]int, n-1)
	for i := 0; i < n-1; i++ {
		u := getNextInt(scanner) - 1
		v := getNextInt(scanner) - 1
		if u > v {
			u, v = v, u
		}
		ee[i][0] = u
		ee[i][1] = v
	}
	var vs, es int64
	for i := 0; i < n; i++ {
		vs += int64(n-i) * int64(n-i+1) / 2
	}
	for i := 0; i < n-1; i++ {
		es += int64(ee[i][0]+1) * int64(n-ee[i][1])
	}
	fmt.Fprintln(writer, vs-es)
}


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
    long long N, K;
    cin >> N >> K;

    long long x = N % K;
    //x = K % x;
    x = min(x, abs(x - K));
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
     
#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
     
const int N = 223;
const int inf = (int)1e9 + 7;
     
pii ar[N];
vector < int > gr[N];
bool used[N];
int mt[N];
     
bool kuhn(int v) {
if (used[v]) return false;
 used[v] = 1;
 for (int to : gr[v]) {
   if (mt[to] == -1 || kuhn(mt[to])) {
     mt[to] = v;
     return true;
   }
 }
 return false;
}
     
main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &ar[i].fr, &ar[i].sc);
  }
  for (int i = n + 1; i <= n + n; i++) {
    scanf("%d %d", &ar[i].fr, &ar[i].sc);
    mt[i] = -1;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = n + 1; j <= n + n; j++) {
      if (ar[i].fr < ar[j].fr && ar[i].sc < ar[j].sc) {
	gr[i].pb(j);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(used, 0, sizeof(used));
    kuhn(i);
  }
     
  for (int i = n + 1; i <= n + n; i++) {
    if (mt[i] != -1) {
      ans++;
      // cout << i << ' ' << mt[i] << endl;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long int
int32_t main()
{
  int n;
  cin>>n;
  int arr[2*n],j;
  for(j=0;j<2*n;j++)
    cin>>arr[j];
  sort(arr,arr+2*n);
  int answer=0;
  for(j=0;j<2*n;j+=2)
    answer+=arr[j];
  cout<<answer<<endl;
}


Measured memory_bytes: 3668
#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>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 DSORT(c, type) sort(ALL(c), greater<type>())

#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SUM(v) accumulate(ALL(v), 0)
#define AVE(v) SUM(v) / (v).size()
// 入力eと同じ値の要素の数
#define COUNT(v, e) count(ALL(v), e)

using namespace std;


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

  int n, k;
  cin >> n >> k;

  double prob = 0;
  for(int d=1; d<=n ; ++d) {
    double p = 0;
    for(int c=0; ; ++c) {
      if(d * pow(2.0, c) >= k) {
        p += 1.0/n * pow(0.5, c);
        break;
      }
    }
    prob += p;
  }

  cout << setprecision(13) <<  prob << endl;

  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 200000
#define MAX_K 200000

i64 N, K;
i64 A[MAX_N];


int main() {
  cin >> N >> K;
  REP(i, N) {
    cin >> A[i];
  }

  // 隣接する3つの合計値が最大のものを選ぶ
  i64 maxv = 0;
  i64 maxi;
  i64 prev_s = 0; // 前の区間の総和
  REP(i, N-K+1) {
    if (i == 0) {
      i64 s = 0;
      REP(j, K) {
        s += A[i + j];
      }
      maxv = s;
      maxi = i;
      prev_s = s;
      continue;
    }

    prev_s -= A[i-1];
    prev_s += A[i + K - 1];
    if (prev_s > maxv) {
      maxv = prev_s;
      maxi = i;
    }
  }

  f64 E = 0;
  REP(i, K) {
    E += (f64)(0.5 * A[i + maxi] * (A[i + maxi] + 1)) / A[i + maxi];
  }
  cout << E << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
struct Node{
  int key;
struct Node *right, *left, *parent;
};
struct Node *root , *NIL;
void insert(int);
void inorder(struct Node*);
void preorder(struct Node*);
int main(){
  int n,i,x;
  char c[10];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(c[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){  
  struct Node *y=NIL,*x=root,*z;
z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}




Measured memory_bytes: 25184
def main():
    N = int(input())
    answer = []
    while N != 0:
        cmd = [i for i in input().split()]
        ans = 0
        g_flag = True
        p = ["ld", "rd"]
        for c in cmd:
            if c[0] == "l":
                p[0] = c
            else:
                p[1] = c
            if g_flag and p[0] == "lu" and p[1] == "ru":
                g_flag = False
                ans += 1
            if not g_flag and p[0] == "ld" and p[1] == "rd":
                g_flag = True
                ans += 1
        answer.append(ans)
        N = int(input())
    print(*answer,sep="\n")


if __name__ == '__main__':
    main()



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    int c [3][3];
    rep(i,3){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    int a [3];
    int b [3];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool flag = true;

    rep(i,3){
        rep(j,3){
            if(c[i][j] != a[i] + b[j])flag = false;
        }
    }
    if(flag)print("Yes");
    else print("No");
}

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

char a_pop(queue<char> &aa)
{
  	if(aa.empty())
      	return '0';
	char ea = aa.front();
    aa.pop();
  	return ea;
}

char b_pop(queue<char> &bb)
{
  	if(bb.empty())
      	return '0';
	char ea = bb.front();
    bb.pop();
  	return ea;
}

char c_pop(queue<char> &cc)
{
  	if(cc.empty())
      	return '0';
	char ea = cc.front();
    cc.pop();
  	return ea;
}

int main()
{
  	string a, b, c;
  	cin>>a>>b>>c;
  	bool fa = false, fb = false, fc = false;
  	queue<char> aa, bb, cc;
  	for(int i = 0; i < a.length(); i++)
    	aa.push(a[i]);
  	for(int i = 0; i < b.length(); i++)
    	bb.push(b[i]);
  	for(int i = 0; i < c.length(); i++)
    	cc.push(c[i]);
  	char ea = aa.front();
    aa.pop();
  	while(1)
    {
      	if(ea == 'a')
        {
          	ea = a_pop(aa);
          	if(ea == '0')
            {
              	cout<<'A'<<"\n";
          		break;
            }
        }
      	else if(ea == 'b')
        {
          	ea = b_pop(bb);
          	if(ea == '0')
            {
              	cout<<'B'<<"\n";
          		break;
            }
        }
      	else
        {
          	ea = c_pop(cc);
          	if(ea == '0')
            {
              	cout<<'C'<<"\n";
          		break;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
mix=0
mx=w
miy=0
my=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        mix=max(mix,x)
    elif a==2:
        mx=min(mx,x)
    elif a==3:
        miy=max(miy,y)
    else:
        my=min(my,y)
if mix>=mx or miy>=my:
    print(0)
else:
    print((mx-mix)*(my-miy))


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

using namespace std;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int count=0;
  for(int i=0;i<N-2;i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
      count++;
    }

  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = input()
dict = {'r': p, 's': r, 'p': s}

texts = []
for i in range(k):
    text = T[i::k]
    texts.append(text)

ans = 0
for text in texts:
    prev = ''
    for t in text:
        if t == prev:
            prev = ''
            continue

        else:
            prev = t
            ans += dict[t]

print(ans)


Measured memory_bytes: 8820
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		boolean[] is_prime = new boolean[1000002];
		is_prime[0] = is_prime[1] = false;
		for(int i = 2; i < 1000002; i++){
			is_prime[i] = true;
		}
		
		
		for(int i = 2; i < 1001; i++){
			for(int j = i*i; j < 1000002; j += i){
				is_prime[j] = false;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			
			int count = 0;
			int max = n / 2;
			for(int i = 2; i <= max; i++){
				if(!is_prime[i]){
					continue;
				}else if(!is_prime[n - i]){
					continue;
				}else{
					count++;
				}
			}
			
			
			System.out.println(count);
		}
		
	}
	
	
}

Measured memory_bytes: 13000
n = int(input())
a = [int(_) for _ in input().split()]
x = [0]*n

for i in range(n):
    x[0] += ((-1)**i)*a[i]

for i in range(1,n):
    x[i] = 2*a[i-1] - x[i-1]

for i in range(n):
    print(x[i],end= ' ')
print()

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

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 400010

int n, m;
int f[N];
int px[N], py[N], pz[N];
set<PII> A;

int fa(int x) {
	if (f[x] == x) return x;
	f[x] = fa(f[x]);
	return f[x];
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i ++) {
		cin >> px[i] >> py[i] >> pz[i];
		A.insert(mp(pz[i], i));
		px[i+m] = py[i]; py[i+m] = (px[i]+1)%n; pz[i+m] = pz[i]+1;
		A.insert(mp(pz[i]+1, i+m));
	}
	for (int i = 0; i < n; i ++) f[i] = i;
	ll S = 0;
	while (!A.empty()) {
		PII _x = *A.begin();
		A.erase(A.begin());
		int i = _x.se; 
		int z = _x.fi;
		int x = px[i];
		int y = py[i];
		if (fa(x) != fa(y)) {
			S += z;
			f[fa(x)] = fa(y);
			(px[i] += 1) %= n;
			(py[i] += 1) %= n;
			A.insert(mp(z+2, i));
		}
	}
	cout << S << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && B == C) {
        if(A%2) {
            cout << 0 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    int a, b, c;
    int ans = 0;
    while(true) {
        if(A%2 || B%2 || C%2) {
            cout << ans << endl;
            return 0;
        }
        ans++;
        a = A;
        b = B;
        c = C;
        A = b + c;
        B = a + c;
        C = a + b;
        A /= 2;
        B /= 2;
        C /= 2;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int h,w;
	char c;
	cin >> h >> w;
	h++,w++;
	vector<vector<int>> map(h+1,vector<int>(w+1,0));
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			cin >> c;
			if(c == '#'){
				map[i+1][j+1] += 1;
				map[i+1][j] += 1;
				map[i+1][j-1] += 1;
				map[i][j+1] += 1;
				map[i][j-1] += 1;
				map[i-1][j+1] += 1;
				map[i-1][j] += 1;
				map[i-1][j-1] += 1;
				map[i][j] = -100;
			}
		}
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(map[i][j] >= 0)
				cout << map[i][j];
			else
				cout << "#";
		}
		cout << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

string s;

int main(){
	cin >> s;
	if(s == "A")cout << "T" << endl;
	if(s == "T")cout << "A" << endl;
	if(s == "C")cout << "G" << endl;
	if(s == "G")cout << "C" << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int m=sc.nextInt();
		int a[]=new int[n];
		int c[]=new int[m];
		int b[]=new int[n];
		int d[]=new int[m];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		for(int j=0;j<m;j++) {
			c[j]=sc.nextInt();
			d[j]=sc.nextInt();
		}
		int ans[]=new int[n];
		
		for(int i=0;i<n;i++) {
			int dis=400000000;
			ans[i]=60;
			for(int j=0;j<m;j++) {
				if(dis>Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j])||(dis==Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j])&&ans[i]>j+1)) {
					ans[i]=j+1;
					
					dis=Math.min(dis,Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]));
				}
			}	
			
		}
		for(int i=0;i<n;i++) {
			System.out.println(ans[i]);
		}
	}
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 21204
#include <stdio.h>
 
int main(void){
    int n;
    int a[250];
 
    scanf("%d", &n);
    for(int i = 0;i < n;++i){
        scanf("%d", &a[i]);
    }
 
    int flag = 0;
    int cnt = 0;
    while(1){
        for(int i = 0;i < n;++i){
            if(a[i] % 2 == 0) a[i] /= 2;
            else{
                flag = 1;
                break;
            }
        }
        if(flag == 1) break;
        else cnt++;
    }
 
    printf("%d\n", cnt);
 
    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll x;
	cin >> x;
	ll y = x % 11;
	if (y > 6) {
		y = 2;
	}
	else if (y == 0) {
		y = 0;
	}
	else {
		y = 1;
	}
	cout <<2*( x / 11)+y << endl;

}




Measured memory_bytes: 256
import sys
import fractions
input = sys.stdin.readline

MOD = pow(10, 9) + 7
n = int(input())
a = list(map(int, input().split()))

lcm = a[0]
for i in range(n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = []
for i in range(n):
    b.append(lcm // a[i])

print(sum(b) % MOD)

Measured memory_bytes: 327540
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n,ans; cin >> n;
  vector<int> p(n),q(n);
  rep(i,0,n) cin >> p[i];
  rep(i,0,n) cin >> q[i];
  if(p>q) swap(p,q);
  while(p!=q){
    ans+=1;
    next_permutation(p.begin(),p.end());
  }
  cout << ans << endl;
}






Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    //int ti = clock();
    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

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

    ll ans = 0;

    rep(i, n)
    {   
        int x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        int y = c.end() - lower_bound(c.begin(), c.end(), b[i]+1);

        ans += (ll)x*y;
    }


    cout << ans << endl;
    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);

    
    return 0;
}

Measured memory_bytes: 1408
#include "stdio.h"
int main()
{
	int A, B, C;
	int max;
	int min;
	int mid;
	int count = 0;
	scanf("%d %d %d", &A, &B, &C);
	//最大値、中央値を求める
	if (A > B) {
		max = A;
		mid = B;
	}
	else {
		max = B;
		mid = A;
	}
	if (max < C) {
		mid = max;
		max = C;
	}
	else {
		if (mid < C) {
			mid = C;
		}
	}
	//最小値を求める
	if (A < B) {
		min = A;
	}
	else {
		min = B;
	}
	if (min > C) {
		min = C;
	}
	//小さい数字二つの差/2 (2づつ足す)
	count = (mid - min)/2;
	//はみ出す場合は+1(minとmax)
	if ((mid - min) % 2 == 1) {
		count++;
		max++;
	}
	count = count + (max - mid);
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int partition(int *, int, int);
void swap(int *, int, int);

int main(){
  int i, q, n;
  int *A;

  scanf("%d", &n);

  A = malloc(sizeof(int) * n);

  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  
  q = partition(A, 0, n-1);

  for(i=0; i<n-1; i++){
    if(i == q) printf("[%d] ", A[i]);
    else printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);

  return 0;
}

int partition(int *A, int p, int r){
  int x, i, j;

  x = A[r];
  i = p-1;

  for(j=p; j<r; j++){
    if(A[j] <= x){
      i = i+1;
      swap(A, i, j);
    }
  }
  swap(A, i+1, r);

  return i+1;
}

void swap(int *A, int i, int j){
  int temp;

  temp = A[i];
  A[i] = A[j];
  A[j] = temp;

}

Measured memory_bytes: 992
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j;
  string s[15]={"Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge","Paper","Air","Water","Dragon","Devil","Lightning","Gun"};
  int n;
  while(cin>>n,n){
    bool a[15]={};
    for(i=0;i<n;++i){
      string t;
      cin>>t;
      for(j=0;s[j]!=t;++j);
      a[j]=true;
    }
    int ct=0;
    for(i=0;i<15;++i)
      ct+=a[i];
    if(ct==1){
      cout<<"Draw"<<endl;
      continue;
    }
    for(i=0;i<15;++i){
      if(!a[i])
	continue;
      for(j=1;j<=7;++j){
	if(a[(i-j+15)%15])
	  break;
      }
      if(j>7)
	break;
    }
    if(i<15)
      cout<<s[i]<<endl;
    else
      cout<<"Draw"<<endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

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

  int ans_n = *max_element(a.begin(), a.end());
  int ans_r = 0;

  for (int i = 0; i < n; i++) {
    if (ans_n == a[i])
      continue;
    if (abs(ans_n / 2 - ans_r) > abs(ans_n / 2 - a[i])) {
      ans_r = a[i];
    }
  }

  cout << ans_n << " " << ans_r << endl;

  return 0;
}


Measured memory_bytes: 3708
N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5+1)):
  if M%i == 0:
    d. append(i)
    d.append(M//i)
dd=list(set(d))
dd.sort()
for x in dd:
  if x>=N:
    print(M//x)
    break

Measured memory_bytes: 3060
s = input()
s = s[:len(s)-1]
while len(s)>0:
      if len(s)%2:
            s = s[:len(s)-1]
            continue
      f = s[:len(s)//2]
      b = s[len(s)//2:]
      if f == b:
            print(len(s))
            break
      s = s[:len(s)-1]

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

const long long mod = 1e9 + 7;
long long fact[2000013];

long long sum_mod (long long a, long long b) {
	return (a + b) % mod;
}

long long mul_mod (long long a, long long b) {
	return (a * b) % mod;
}

long long pow_mod (long long a, long long b) {
	long long res = 1, t = a;
	while (b) {
		if (b & 1) {
			--b;
			res = mul_mod(res, t);
		}
		else {
			b >>= 1;
			t = mul_mod(t, t);
		}
	}
	return res;
}

long long sub_mod (long long a, long long b) {
	return (a - b + mod) % mod;
}

long long div_mod (long long a, long long b) {
	return mul_mod(a, pow_mod(b, mod - 2));
}

void precalc () {
	fact[0] = 1;
	for (long long i = 1; i < 2e6 + 13; ++i) 
		fact[i] = mul_mod(fact[i - 1], i);
}

long long c_mod (int n, int k) {
	if (n < k)
		return 0LL;
	return div_mod (fact[n], mul_mod (fact[k], fact[n - k]));
}

long long f (int r, int c) {
	return c_mod(r + c, c);
}

long long g (int r, int c) {
	long long res = 0LL;
	for (int x = 0; x <= r; ++x)
		res = sum_mod(res, f(x + 1, c));
	return res;
}

signed main () {
	precalc();
	
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	long long total = g(r2, c2), adding = g(r1 - 1, c1 - 1);
	long long sub1 = g(r2, c1 - 1), sub2 = g(r1 - 1, c2);
	long long ans = sub_mod(sum_mod (total, adding), sum_mod(sub1, sub2));
	cout << ans << '\n';
}


Measured memory_bytes: 15872