akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {
	int h, w;
	cin >> h >> w;
	int c[10][10];
	for (size_t i = 0; i < 10; i++)
	{
		for (size_t j = 0; j < 10; j++)
		{
			cin >> c[i][j];
		}
	}
	int t[201][201];
	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			cin >> t[i][j];
		}
	}

	for (size_t i = 0; i < 10; i++)
	{
		for (size_t j = 0; j < 10; j++)
		{
			for (size_t k = 0; k < 10; k++)
			{
				c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
			}
		}
	}
	
	ll res = 0;
	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0;  j < w;  j++)
		{
			if (t[i][j] == -1) continue;
			res += c[t[i][j]][1];
		}
	}
	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		char[] s = sc.next().toCharArray();
		int k = sc.nextInt();
		
		for (int i = 0; i < s.length; i++) {
			if (s[i] != 'a' && 'z' - s[i] + 1 <= k) {
				k -= 'z' - s[i] + 1;
				s[i] = 'a';
			}
		}
		
		s[s.length - 1] += k % 26;
		
		out.println(s);
		out.flush();
	}
	
}

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 byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte 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();
		}
	}
}


Measured memory_bytes: 10120
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

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

    int d[N];

    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }

    sort(d, d + N);

    cout << d[N /2] - d[N / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#define lli long long int
using namespace std;
int main(){
	lli n, k, q; cin >> n >> k >> q;
	lli w[n+1];
	lli a[q];
	for(lli i=0;i<q;i++) cin >> a[i];
	for(lli i=0;i<n+1;i++) w[i]=0;
	for(lli i=0;i<q;i++) w[a[i]]++;
	for(lli i=1;i<n+1;i++){
		if(k - q + w[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 2176
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

const INF: i64 = (1 << 60);

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      p: i64,
      abcs: [(usize1,usize1,i64); m],
    }

    // ベルマンフォード
    let mut dist = vec![INF; n];
    dist[0] = 0;
    let mut ans = dist[n-1];
    for i in 0..(n*2) {
        for e in 0..m {
            let (a, b, c) = abcs[e];
            let c = -1 * (c-p);
            if dist[a] != INF && dist[b] > dist[a] + c {
                dist[b] = dist[a] + c;
            }
        }
        if i >= n {
            if ans != dist[n-1] {
                return puts!("{}\n", -1);
            }
        } else {
            ans = dist[n-1];
        }
    }
    puts!("{}\n", max(-1 * ans, 0));
}


Measured memory_bytes: 4352
n = int(input())
a = [int(x) for x in list(input().split())]
b = [0] * (n + 1)
c = [0] * 10001
k = max(a)

# C[i] に i の出現数を記録する
for i in a:
    c[i] += 1

# C[i] に i以下の数の出現数を記録する
for i in range(1, k + 1):
    c[i] = c[i] + c[i - 1]

for i in reversed(a):
    b[c[i]] = i
    c[i] -= 1

print(*b[1:])



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

int N, M;
string A[50], B[50];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];

    bool found = false;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i + M - 1 >= N || j + M - 1 >= N) continue;

            bool tmp = true;
            for (int k = 0; k < M; k++) {
                for (int l = 0; l < M; l++) {
                    if (A[i+k][j+l] != B[k][l]) {
                        tmp = false;
                        break;
                    }
                }
                if (!tmp) break;
            }

            if (tmp) {
                found = true;
                break;
            }
        }

        if (found) break;
    }

    cout << ((found) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;
const int mod = 1e9+7;
const int INF=0x3f3f3f3f;

ll vis[3010][3010];
ll dp[3010][3010][4];
void solve() {
    int r,c,t;
    cin>>r>>c>>t;
    for(int i=0;i<t;i++){
        int a,b,c;
        cin>>a>>b>>c;
        vis[a][b]=c;
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++) {
            if (vis[i][j] != 0) {
                for (int k = 1; k < 4; k++) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][3] + vis[i][j]);
                    dp[i][j][k] = max(dp[i][j][k],dp[i][j - 1][k]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + vis[i][j]);
                }
            }else{
                for(int k=0;k<4;k++) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
                }
            }
        }
    }
    ll res=0;
    for(int i=0;i<4;i++){
        res=max(res,dp[r][c][i]);
    }
    cout<<res;
}

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

Measured memory_bytes: 356176
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
   int a,b;
   int sum,sa,mm;
   int max;

   cin>>a>>b;
   sum=a+b;
   sa=a-b;
   mm=a*b;
   max=sum;
   if(max<sa){
       max=sa;
   }
   if(max<mm){
       max=mm;
   }
   cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int p[100000];
int r[100000];
int s[100000];

int parent(int a) {
    if (p[a] != a)
        p[a] = parent(p[a]);
    return p[a];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    stack<ll> res;
    stack<pii> e;
    int n = gi();
    int m = gi();
    for (int i = 0; i < m; i++)
        e.push({gi()-1, gi()-1});

    for (int i = 0; i < n; i++) {
        p[i] = i;
        r[i] = 0;
        s[i] = 1;
    }

    ll v = ll(n) * ll(n-1) / 2LL;
    for (int i = 0; i < m; i++) {
        res.push(v);
        int na = e.top().first;
        int nb = e.top().second;
        e.pop();
        int pa = parent(na);
        int pb = parent(nb);
        if (pa != pb) {
            if (r[pa] < r[pb]) {
                int t = pa;
                pa = pb;
                pb = t;
            }
            p[pb] = pa;
            if (r[pa] == r[pb])
                r[pa]++;
            v -= ll(s[pa]) * ll(s[pb]);
            s[pa] += s[pb];
        }
    }

    for (int i = 0; i < m; i++) {
        cout << res.top() << endl;
        res.pop();
    }

    return 0;
}


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

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

    k = N;

    int sum = 0;

    while (k > 0) {
        /* code */
        sum += k % 10;
        k /= 10;
    }
    if (N % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int n,k,count;

void dfs(int i,int sum,int num)
{
	if(num == n)
	{
		if(sum == k)
		{
			count++;
		}
		return;
	}

	if(i == 10)
	{
		return;
	}
	
	dfs(i+1,sum,num);
	dfs(i+1,sum+i,num+1);
}
int main()
{
	while(cin >> n >> k)
	{
		if(n == 0 && k == 0) break;

		count = 0;
		dfs(0,0,0);
		cout << count << endl;

	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 105;
const int M = 10005;

bool dp[M];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, x;
	cin>>n;
	memset(dp, false, sizeof(dp));
	dp[0] = true;
	for(int i = 0; i < n; i++){
		cin>>x;
		for(int sum = M - 1; sum >= x; sum--){
			dp[sum] |= dp[sum - x];
		}
	}
	int ans = 0;
	for(int i = 0; i < M; i++){
		if(dp[i] && i%10 != 0)ans = i;
	}
	cout<<ans<<endl;;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
#include <cmath>
#include <limits>
#include <queue>
using namespace std;

class Job
{
public:
	Job(int day, int profit) : day(day), profit(profit) {}
public:
	int day;
	int profit;
};

int main()
{
	long long N, M;

	cin >> N >> M;

	vector<Job> J;

	for (int i = 0; i < N; i++) {
		int day, profit;
		cin >> day >> profit;
		Job j(day, profit);
		J.push_back(j);
	}

	std::sort(J.begin(), J.end(), [](const Job &a, const Job &b) {
		return a.day < b.day;
	});//��r�֐��������_����

	long long result = 0;

	std::priority_queue<int> Q;

	int indexJ = 0;

	for (int iLast = 1; iLast <= M; iLast++) {
		//! �����ɊԂɂ����d���̕�V��Q�ɒǉ�
		while(indexJ < N){
			if (J[indexJ].day == iLast) {
				Q.push(J[indexJ].profit);
				indexJ++;
			}
			else {
				break;
			}
		}

		//! Q����ő�̕�V�����o��
		if (Q.size() > 0) {
			result += Q.top();
			Q.pop();
		}
	}

	std::cout << result << endl;

	return 0;
}


//int main()
//{
//	long N;
//
//	cin >> N;
//
//	vector<string> s;
//
//	for (long i = 0; i<N; i++) {
//		string str;
//
//		cin >> str;
//
//		std::sort(str.begin(), str.end());
//
//		s.push_back(str);
//	}
//
//	std::sort(s.begin(), s.end());
//
//	static long long lut[3628810];
//	long long sum = 0;
//	lut[0] = 0;
//	lut[1] = 0;
//	for (long i = 2; i < 3628810; i++) {
//		sum += (i - 1);
//		lut[i] = sum;
//	}
//
//	long result = 0;
//
//	long count = 1;
//	string hold = s[0];
//	for (long i = 1; i < N; i++) {
//		if (hold == s[i]) {
//			count++;
//		}
//		else {
//			result += lut[count];
//			hold = s[i];
//			count = 1;
//		}
//	}
//	result += lut[count];
//
//	cout << result << endl;
//}


//int main()
//{
//	long K, X;
//
//	cin >> K >> X;
//
//	for (long i = -(K - 1); i <= K - 1; i++) {
//		long result = X + i;
//
//		if (result >= -1000000 && result <= 1000000) {
//			cout << result << " ";
//		}
//	}
//
//	cout << endl;
//}


//int main()
//{
//	long A, B;
//
//	cin >> A >> B;
//
//	cout << std::max(A + B, std::max(A - B, A * B)) << endl;
//}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
int a[20];
int main(){
 int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<n;i++) sum+=a[i];
  if(a[n-1]+a[n-1]>=sum) cout<<"No\n";
  else cout<<"Yes\n";
}

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

int main(){
  int n, k;
  cin >> n >> k;
  if(k > (n-1)*(n-2)/2){
    cout << "-1" << endl;
    return 0;
  }
  int m = n*(n-1)/2 - k;
  cout << m << endl;
  int x = 0;
  for(int i = 1; i <= n-1; i++){
    for(int j = i+1; j <= n; j++){
      if(x >= k || j == n) cout << i << " " << j << endl;
      if(j != n) x++;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
left = 0
right = sum(A)
ans = 0

for i in range(N-1):
  left += A[i]
  right -= A[i]
  sa = abs(left-right)
  if i == 0:
    ans = sa
  elif ans > sa:
    ans = sa

print(ans)

Measured memory_bytes: 31496
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val a = (0 until h).map { sc.next().toCharArray() }
    println(problem107b(h, w, a))
}

fun problem107b(h: Int, w: Int, a: List<CharArray>): String {
    val deletedH = mutableSetOf<Int>()
    val deletedW = mutableSetOf<Int>()
    val a = a.toTypedArray()
    for (i in 0 until h) {
        val ai = a[i]
        if (!ai.contains('#')) {
            deletedW.add(i)
        }
    }
    for (i in 0 until w) {
        val col = mutableListOf<Char>()
        for (j in 0 until h) {
            col.add(a[j][i])
        }
        if (!col.contains('#')) {
            deletedH.add(i)
        }
    }

    val sb = StringBuilder()
    for (i in 0 until h) {
        if (deletedW.contains(i)) continue
        for (j in 0 until w) {
            if (deletedH.contains(j)) continue
            sb.append(a[i][j])
        }
        sb.append("\n")
    }

    return sb.toString()
}

Measured memory_bytes: 39548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());

const int N = 1e6 + 10;
int arr[N];
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    arrinp(i, a, 0, n - 1);
    for(int x : a)
    {
        arr[x]++;
    }
    bool flag = true;
    for(int i = 2; i <= 1e6; i++)
    {
        int count = 0;
        for(int j = i; j <= 1e6; j += i)
        {
            count += arr[j];
        }
        if(count >= 2)
        {
            flag = false;
            break;
        }
    }
    if(flag)
    {
        outline("pairwise coprime")
        return 0;
    }
    int gcd_value = a[0];
    for(int x : a)
    {
        gcd_value = __gcd(gcd_value, x);
    }
    if(gcd_value == 1)
    {
        outline("setwise coprime");
        return 0;
    }
    outline("not coprime")
    return 0;
}

Measured memory_bytes: 11072
mod = 10**9 + 7
 
 
def comb(n, k):
    x, y = 1, 1
    k = min(k, n - k)
    for i in range(k):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod

N, M, K = map(int, input().split())

c = comb(N*M-2,K-2)

ans = c * (M**2 * (N**2 * (N+1)//2 - N*(N+1)*(2*N+1)//6) + N**2 * (M**2 * (M+1)//2 - M*(M+1)*(2*M+1)//6)) % mod

print(ans)

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

using namespace std;

int main()
{
    int n,i,j,sum=0;
    cin>>n;
    for(i=1;i<=n;i+=2){
            int count=0;
        for(j=1;j<=i;j+=2){
            if(i%j==0){
                count++;
            }
        }
        if(count==8){
            sum++;}

    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3556
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    if A[0] != 0:
        print(0)
        return 

    ## 一番多い色の帽子の数
    color = [1,0,0]
    answer = 3

    for i in range(1,N):
        if A[i] not in color:
            print(0)
            return 
        
        count = color.count(A[i])
        answer *= count

        for j in range(len(color)):
            if color[j] == A[i]:
                color[j]+=1
                break

    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e2 + 20;
int a[N], n, b[N], m, odd;
vector<int> ans;

bool cmp(int x, int y) {
	if (x % 2 != y % 2)
		return x % 2 < y % 2;
	return x < y;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		odd += a[i] % 2;
	}
	if (m == 1) {
		cout << a[0] << endl;
		if (a[0] == 1) {
			cout << 1 << endl;
			cout << 1 << endl;
		}
		else {
			cout << 2 << endl;
			cout << a[0] - 1 << ' ' << 1 << endl;
		}
		return 0;
	}
	if (odd > 2)
		return cout << "Impossible" << endl, 0;
	sort(a, a + m, cmp);
	if (odd == 2)
		swap(a[m - 2], a[0]);
	for (int i = 0; i < m; i++)
		cout << a[i] << ' ';
	cout << endl;
	if (a[0] == 1) {
		cout << m - 1 << endl;
		for (int i = 1; i < m - 1; i++)
			cout << a[i] << ' ';
		cout << a[m - 1] + 1 << endl;
	}
	else {
		cout << m << endl;
		cout << a[0] - 1 << ' ';
		for (int i = 1; i < m - 1; i++)
			cout << a[i] << ' ';
		cout << a[m - 1] + 1 << endl;
	}
}

Measured memory_bytes: 256
N = int(input())

dp = [[0]*3 for _ in range(N+1)]

for i in range(1, N+1):
  a, b, c = map(int, input().split())
  dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
  dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
  dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c

print(max(dp[N][0], dp[N][1], dp[N][2]))

Measured memory_bytes: 24820
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    # if !block_given?
    #   @comp = Proc.new { |x, y| x <= y }
    # else
    #   @comp = comp
    # end
    @comp = comp
  end
  attr_reader :heap

  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @node_num && !@comp.call(@heap[a], @heap[b])
      break if @comp.call(x, @heap[a])
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
/*
    @uthor: Amit Kumar
    user --> GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
        char b;
        cin>>b;
        (b=='A')? cout<<"T" : (b=='T')? cout<<"A" : (b=='G')?cout<<"C" : cout<<"G";
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    int l = 0, r = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == '('){
            r++;
        }else{
            r--;
            if(r < 0){
                r++;
                l++;
            }
        }
    }
    cout << string(l, '(') << S << string(r, ')') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll n;
vector<vector<P>> shogen;
ll ans;

void dfs(vector<int> v) {
  if ((ll)v.size() == n) {
    bool is_ok = true;
    rep(i, n) {
      if (v[i] == 0) continue;
      rep(j,ll(shogen[i].size())) {
        if (v[shogen[i][j].first] != shogen[i][j].second) {
          is_ok = false;
        }
      }
    }
    if (is_ok) chmax(ans, (ll)count(v.begin(), v.end(), 1));

    return;
  }

  v.push_back(0);
  dfs(v);
  v.back()++;
  dfs(v);
}

int main() {
  cin >> n;
  shogen.resize(n);
  rep(i, n) {
    ll a;
    cin >> a;
    shogen[i] = vector<P>(a);
    rep(j, a) {
      cin >> shogen[i][j].first >> shogen[i][j].second;
      shogen[i][j].first--;
    }
  }

  dfs(vector<int>(0));

  cout << ans << endl;;



  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int n=sc.nextInt();
   int flag=0;
    ArrayList<Integer> a=new ArrayList<Integer>();
    ArrayList<Integer> a1=new ArrayList<Integer>();
    for(int i=0;i<n;i++)
    {
      a.add(sc.nextInt());
    }
    for(int j=0;j<=a.size();j++)
    {
         if(flag==0)
        {
         if(!a.contains(x+j))
         {
               a1.add(x+j);
               flag=1;
         }
         if(!a.contains(x-j))
        {
             a1.add(x-j);
		flag=1;
       }
       if(flag==1)
             break;
      }

        
    }
    Collections.sort(a1);
    if(n>0)
     System.out.println(a1.get(0));
    else
       System.out.println(x);
  }
}
         

Measured memory_bytes: 35764
from collections import deque
n,*t=map(int,open(0).read().split())
con=[[] for _ in range(n)]
dist_f_k=[0]*n

for a,b,c in zip(t[:3*n-3:3],t[1::3],t[2::3]):
	con[a-1].append((b-1,c))
	con[b-1].append((a-1,c))

k=t[3*n-2]
que=deque([k-1])
while que:
	cur=que.popleft()
	for nxt,dd in con[cur]:
		if dist_f_k[nxt]==0 and nxt!=k-1:
			que.append(nxt)
			dist_f_k[nxt]=dist_f_k[cur]+dd

for x,y in zip(t[3*n-1::2],t[3*n::2]):
	print(dist_f_k[x-1]+dist_f_k[y-1])

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



int main(){
    ll a=0,b,n;
    cin >> n;
    rep(i,10){
        rep(j,10){
            if(i*j==n) a++;
        }
    }
    if(a){
        puts("Yes");
    }else{
        puts("No");
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a <= b) cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}


Measured memory_bytes: 3616
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):
    x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=n//3:
    x[0]+=x[1]
    f=c[0]<=n//3
    for i,v in enumerate(p):
        j=(v==f)-1
        a[i]=x[j if x[j]else-1].pop()
else:
    for i,v in enumerate(p):
        a[i]=x[v if x[v]else-1].pop()
print(*a)

Measured memory_bytes: 72064
import java.util.Arrays;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),k=sc.nextInt(),count=0;
    long[] a=new long[n];
    long res=0;
    for(int i=0;i<n;i++) {
    	a[sc.nextInt()-1]++;
    }
    for(int i=0;i<n;i++) {
    	if(a[i]!=0)count++;
    }
    if(count-k<=0) {
    	System.out.println(0);
    }else {
    	Arrays.sort(a);
    	int i=0;
    	while(count-k>0) {
    		res+=a[i];
    		if(a[i]!=0) {
    			count--;
    		}
    		i++;
    	}
    	System.out.println(res);
    }
  }
}


Measured memory_bytes: 87492
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;

int n;
struct Seq{
	int t,id;
}a[M];

bool operator<(const Seq& a,const Seq& b){
	return a.t<b.t;
}

int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i].t;
		a[i].id=i;
	}
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++){
		cout<<a[i].id<<" ";
	}
	return 0;
}


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

int main() {
    char c;
    cin >> c;
    if ('a' <= c && c <= 'z') {
        cout << "a" << endl;
    } else if ('A' <= c && c <= 'Z') {
        c = c + ('a'-'A');
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 101;
const int W = 1e5 + 1;
int n, w;
int wt[N], vl[N];
ll dp[N][W];

void max_self(ll &a, ll b) {
	a = max(a, b);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	scanf("%d%d", &n, &w);
	for (int i = 1; i <= n; i++) scanf("%d%d", &wt[i], &vl[i]);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= w; j++) {
			dp[i][j] = dp[i-1][j];
			if (j >= wt[i]) max_self(dp[i][j], dp[i-1][j-wt[i]] + vl[i]);
		}

	ll answer = 0;
	for (int i = 0; i <= w; i++) max_self(answer, dp[n][i]);
	printf("%lld\n", answer);
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define pii tuple<ll,ll,ll>
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const ll N=1005;
const ll INF=LLONG_MAX;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
int n,k;
cin>>n>>k;
int a[n];
for (int i=0; i<n; i++)
    cin>>a[i];
sort(a,a+n);
int sol=0;
for (int i=0; i<k; i++)
    sol+=a[i];
cout<<sol;

}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>

#define M 1000010000

using namespace std;

typedef long long ll;
int main(void)
{
	ll n,m,i;
	ll ans=0;
	ll count;
	while(scanf("%lld %lld",&n,&m)!=EOF)
	{
		ans=0;
		if(m==1)
		count=1;
		else
		count=m-2;
		if(n==1)
		{
			ans=count;
			printf("%lld\n",ans);
			continue;
		}
		ans=count*(n-2);
		printf("%lld\n",ans);
	}
}

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

class Program
{
	/*
	Cf. 計算量について
	n = 20くらいまでならbit全探索できるよ
	*/

	//n通りのマスクを吐き出す関数（2^0から2^(n-1)まで）
	static List<int> GetMasks(int n){
		//マスクを格納するリストを初期化
		List<int> maskLs = new List<int>();

		//順にリストに格納
		int tempo = 1;
		for(int i=0; i<n; i++){
			maskLs.Add(tempo);
			//1ビット左シフト
			tempo = tempo << 1;
		}

		return maskLs;
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		int H = int.Parse(S[0]);
		int W = int.Parse(S[1]);
		int N = H + W;
		int K = int.Parse(S[2]);

		//グリッドを取得
		char[][] grid = new char[H][];
		for(int i=0; i<H; i++){
			string line = Console.ReadLine();
			grid[i] = new char[H];
			grid[i] = line.ToCharArray();
		}

		//1. 2^n通りの上限値（0 〜 2^N-1 までの全整数を探索すれば良い）
		int max = (int)Math.Pow(2, N) - 1;

		//2. マスクを取得
		List<int> maskLs = new List<int>();
		maskLs = GetMasks(N);

		//3. それぞれ、マスクと照らし合わせて計算
		int ans = 0;

		for(int i=0; i<max; i++){
			//黒いマスのカウンター
			int cnt = 0;

			//マスをカウントするが、マスクと照合してフラグが立っていた場合、スキップ
			for(int j=0; j<H; j++){
				//j行のフラグが立っている場合、スキップ
				if((maskLs[j] & i) != 0){
					continue;
				}
				else{
					for(int k=0; k<W; k++){
						//k列のフラグが立っている場合、スキップ
						if((maskLs[k+H] & i) != 0){
							continue;
						}
						//そうでない場合、黒マスならカウント
						else if(grid[j][k] == '#'){
							cnt ++;
						}
					}
				}
			}

			//ちょうどK個なら、答えを増やす
			if(cnt == K){
				ans ++;
			}
		}

		Console.WriteLine(ans);
	}
}



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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N; cin >> N;
vector<ll> data(N);
ll cnt = 0;
REP(i,N) cin >> data[i];
for(int i = 0;i<N;i++){
  for(int j=i+1;j<N;j++){
    for(int k=j+1;k<N;k++){
      if(data[i]!=data[j]&&data[j]!=data[k]&&data[i]!=data[k]&&(data[i]+data[j])>data[k]&&(data[i]+data[k])>data[j]&&(data[j]+data[k])>data[i])cnt++;
    }
  }
}
cout << cnt;
}

Measured memory_bytes: 3648
N=int(input())
S=input()
ans=0
for i in range(1,N):
    T1=S[:i]
    T2=S[i:]
    sub=0
    L=set(T1)
    for t in set(T2):
        if t in L:
            sub+=1
    ans=max(ans, sub)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    REP(i, N) {
        int v = A[i];
        int j = i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;        
        REP(k, N) cout << A[k] << (k!=N-1 ? " " : "");
        cout << endl; 
    }
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    vector<int> adj[N];
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
    }
    bool vis[N]{};
    int k = 0;
    deque<int> q;
    for (int i = 0; i < N; i++) {
        if (vis[i]) continue;
        q.push_back(i);
        vis[i] = true;
        k++;
        while (!q.empty()) {
            int u = q.front();
            q.pop_front();
            for (int j : adj[u]) {
                if (vis[j]) continue;
                q.push_back(j);
                vis[j] = true;
            }
        }
    }
    cout << k - 1 << "\n";
    return 0;
}

Measured memory_bytes: 9704
def insertionSort(N, A):
    print(" ".join(map(str, A)))
    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str, A)))

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

insertionSort(N,A)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long N,K;
  cin >> N >> K;
  vector<int> x(N);
 
  for(int i = 0; i < N; i++){
    cin >> x.at(i);
    x.at(i) = (x.at(i) + 1);
  }
 
  long m = 0;
  long tmp = 0;
 
  for(int i = 0; i < K; i++){
    tmp += (long)x.at(i);
  }
 
  m = tmp;
  for(int i = 1; i < N - K + 1; i++){
    tmp = tmp - (long)x[i-1] + (long)x[i+K-1];
    if(tmp > m){
      m = tmp;
    }
  }
 
  cout << fixed << setprecision(10) << (long double)(m) / 2.0 << endl;
 
}


Measured memory_bytes: 1024
n = input()
a = map(int, raw_input().split())

ans = 0
isFlag = True
while isFlag:
    for i in range(n):
        if a[i] % 2 != 0:
            isFlag = False
            break
        else:
            a[i] /= 2
    if isFlag:
        ans += 1

print ans

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,x,tot=0;
    cin >> n >> x;
    vector<int> m(n);
    for(int i=0;i<n;i++){
        cin >>m[i];
        x -= m[i];
    }
    tot += n;
    sort(m.begin(),m.end());
    tot += x/m[0];
    cout << tot <<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
import itertools
N = int(input())
L = input().split()
LS = [int(i) for i in L]
count = 0
itr = list(itertools.combinations(LS, 3))

for s in itr:
    if s[0] + s[1] > s[2] and s[1] + s[2] > s[0] and s[2] + s[0] > s[1] \
        and s[0] != s[1] and s[1] != s[2] and s[2] != s[0]:
        count = count + 1
print(count)


Measured memory_bytes: 20636
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template
#pragma region bit 1.0
template <typename T>
struct bit
{
    ll n;
    vector<T> a;

    bit() {}

    bit(ll n) : n(n)
    {
        a.assign(n + 1, 0);
    }

    void add(ll i, T x)
    {
        ++i;
        while (i <= n)
        {
            a[i] += x;
            i += i & -i;
        }
    }

    T sum(ll i)
    {
        T s = 0;
        while (i > 0)
        {
            s += a[i];
            i -= i & -i;
        }
        return s;
    }
};
#pragma endregion bit

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    ll M = N * (N - 1) / 2 + N;
    ll ok = 1;
    ll ng = INF;

    while (ng - ok > 1)
    {
        ll mid = (ok + ng) / 2;
        bit<ll> bit(2 * N + 1);
        ll s = 0;
        bit.add(N, 1);
        ll k = 0;
        FOR(x, a)
        {
            if (x >= mid)
            {
                s += 1;
            }
            else
            {
                s -= 1;
            }
            k += bit.sum(N + s + 1);
            bit.add(N + s, 1);
        }
        if (k >= (M + 1) / 2)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    OUT(ok);
}


Measured memory_bytes: 5616
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
}

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

int main()
{
	int num[3];
	cin >> num[0] >> num[1] >> num[2];

	for (int i = 0; i < 3; i++)
	{
		for (int j = i + 1; j < 3; j++)
		{
			if (num[j] < num[i])
			{
				int tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
		}
	}

	for (int i = 0; i < 3; i++)
	{
		if (i < 2)
		{
			cout << num[i] << " ";
		}
		else
		{
			cout << num[i] << endl;
		}
	}
}

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

ull m[86] = {2, 1};

ull L(int n){
    for(int i = 2; i <= n; i++){
        m[i] = m[i-1] + m[i-2];
    }
    return m[n];
}

int main(){
    int n;
    cin >> n;
    cout << L(n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int x, a, b;
    cin >> x >>a >> b;
    cout << (abs(x - a) < abs(x- b) ? 'A' : 'B') << endl;
    return 0;
}

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

using namespace std;
// Problem https://atcoder.jp/contests/abc098/tasks/arc098_a
// Reference https://img.atcoder.jp/arc098/editorial.pdf

int main(void){
    int answer = 0;
    int N;
    cin >> N;
    answer = N;
    string S;
    S.clear();
    cin >> S;
    vector<int> E,W;
    E.clear();
    W.clear();
    for(int j=0;j < N;j++){
        if(S.at(j)=='E'){
            E.push_back(1);
            W.push_back(0);
        }
        else{
            E.push_back(0);
            W.push_back(1);
        }
    }
/**    for(int j=0;j<N;j++){
        cout << E.at(j) << " ";
    }
    cout << endl;
    for(int j=0;j<N;j++){
        cout << W.at(j) << " ";
    }
    cout << endl;**/
    vector<int> accE(N+1,0),accW(N+1,0);
    
//    cout << "accE " << accE.at(0) << " ";
    for(int j=0;j<N;j++){
        accE.at(j+1) = accE.at(j) + E.at(j);
//        cout << accE.at(j+1) << " ";
    }
//    cout << endl;
//    cout << "accW " << accW.at(0) << " ";
    for(int j=0;j<N;j++){
        accW.at(j+1) = accW.at(j) + W.at(j);
//        cout << accW.at(j+1) << " ";
    }
//    cout << endl;
//    cout << "Change Counter:";
    for(int j=0;j<N;j++){
        int change;
        change = accW.at(j)+accE.at(N)-accE.at(j+1);
//        cout << change << " ";
        if(change < answer){
            answer = change;
        }
    }
//    cout << endl;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256