akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
#define Test ll q ; cin>>q ; while (q--)
#define ph push_back
#define f first
#define s second
using namespace std ;
int main ()
{
    string s ;
    cin>>s ;
    if (s.find('A')!=string::npos&&s.find('B')!=string::npos)
        cout<<"Yes" ;
    else
        cout<<"No" ;
}


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

int main() {
  ll n,k;
  cin >>n>>k;
  
  ll a=n%k;
  ll b=abs(a-k);
  
  cout << min(a,b) << endl;
  
  
  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
} 
int main() {
	ll N; cin >> N;
	ll a[N + 100];
	for (ll i = 0; i < N; i++)
		cin >> a[i];
	map<ll, ll>mp;
	vector<ll>v;
	for (ll i = 0; i<N; i++) {
      	mp[a[i]]++;
		if (mp[a[i]] >= 2) 
        {v.push_back(a[i]);
      	mp[a[i]]=0;
    	}
        }
		ll ans = 0;
		sort(v.begin(), v.end());
		reverse(v.begin(), v.end());
		if (v.size() >= 2)ans = v[0] * v[1];
		cout << ans << endl;
	}


Measured memory_bytes: 7296
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

LL gcd(LL a, LL b){
   if (a%b == 0) {
       return(b);
   }
   else {
       return(gcd(b, a%b));
   }
}

LL lcm(LL a, LL b){
   return a * b / gcd(a, b);
}

void Main()
{
    LL a,b,c,d;
    cin>>a>>b>>c>>d;

    LL l = lcm(c,d);

    LL x0 = b/l;
    LL x1 = b/c;
    LL x2 = b/d;
    LL y0 = (a-1)/l;
    LL y1 = (a-1)/c;
    LL y2 = (a-1)/d;

    dump(l)
    dump(b-(x1+x2-x0))
    dump(a-1-(y1+y2-y0))

    cout << (b-(x1+x2-x0)) - (a-1-(y1+y2-y0)) << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

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

def combi_num(n):
# n 個 -> a, b, c の組み合わせ数を返す
	if n == 0:
		return 0
	elif n == 1:
		return 1
	elif n == 2:
		return 8
	else:
		return n + 3*n*(n-1) + n*(n-1)*(n-2)


# 1: Kの倍数の個数
num_1 = N // K

# 2: Kの倍数-K/2 の個数	
num_2 = 0
if K % 2 == 0:
	if N%K >= K//2:
		num_2 = num_1 + 1
	else:
		num_2 = num_1

print(combi_num(num_1) + combi_num(num_2))


Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;
	static double[][] P;
	static double[][] memo;

	public static void main(String[] arg) {
		M = sc.nextInt();
		N = sc.nextInt();
		P = new double[M][N];
		memo = new double[N + 1][1 << M];
		for (double[] a : memo) {
			Arrays.fill(a, -1);
		}
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < N; ++j) {
				P[i][j] = sc.nextDouble();
			}
		}
		System.out.printf("%.9f\n", rec(0, 0));
	}

	static double rec(int pos, int st) {
		if (pos == N) return 1;
		if (memo[pos][st] != -1) return memo[pos][st];
		double ret = 0;
		for (int i = 0; i < M; ++i) {
			if ((st & (1 << i)) != 0) continue;
			double prob = 0;
			int nst = st + (1 << i);
			double np = 1;
			for (int j = pos; j < N; ++j) {
				prob += np * (1 - P[i][j]) * rec(j, nst);
				np *= P[i][j];
			}
			prob += np * rec(N, nst);
			ret = Math.max(ret, prob);
		}
		memo[pos][st] = ret;
		return ret;
	}
}

Measured memory_bytes: 32444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1000000000 //1e9

bool graph[50][50];
bool visited[50] = {};

int dfs(int node, int N) {
    bool all_visited = true;
    REP(i, N) {
        if (!visited[i]) {
            all_visited = false;
            break;
        }
    }
    if (all_visited) return 1;

    int ret = 0;
    REP(i, N) {
        if (!graph[node][i]) continue;
        if (visited[i]) continue;
        //cout << i << endl;
        visited[i] = true;
        ret += dfs(i, N);
    }
    return ret;
}

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

    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    REP(i,M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    /*REP(l, N) {
        REP(m, N) {
            cout << graph[l][m];
            if (m==N-1) cout << endl;
        }
    }
    cout << endl;*/

    int ans = 0;
    REP(i,M) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        /*REP(l, N) {
            REP(m, N) {
                cout << graph[l][m];
                if (m==N-1) cout << endl;
            }
        }
        cout <<  endl;*/
        visited[0] = true;
        if (dfs(0, N) == 0) ans++;
        //cout << endl;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        REP(k, N) visited[k] = false;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    let A: Vec<usize> = sc.vec(N);
    let mut ok = 1000000000;
    let mut ng = 0;
    while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        let mut cnt = 0;
        for i in 0..N {
            if A[i] > mid {
                let mut ok = 1000000000;
                let mut ng = 0;
                while ok - ng > 1 {
                    let t = (ok + ng) / 2;
                    if A[i] <= mid * t {
                        ok = t;
                    } else {
                        ng = t;
                    }
                }
                cnt += ok - 1;
            }
        }
        if cnt <= K {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok);
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, T, X;
string S;
signed main(){
  cin >> N >> X;
  vi a(N);
  rep(i,N) {cin >> a[i]; a[i] = abs(a[i]-X);}
  int ans = a[0];
  rep2(i,1,N) ans = gcd(ans,a[i]);

  cout << ans << endl;
  return 0;
}

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

int main()
{

    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >>a.at(i);
    }

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

    cout << a.at(0) + a.at(1) << endl;

}


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

bool check(char c){
  bool ans = false;
  if(c == '0') ans = true;
  if(c == '1') ans = true;
  if(c == '2') ans = true;
  if(c == '3') ans = true;
  if(c == '4') ans = true;
  if(c == '5') ans = true;
  if(c == '6') ans = true;
  if(c == '7') ans = true;
  if(c == '8') ans = true;
  if(c == '9') ans = true;
  return ans;
}

int main(){
  int A, B;
  string S, ans = "Yes";
  cin >> A >> B >> S;
  for(int i = 0; i < A; i++){
    if(check(S.at(i)) == false) ans ="No";
  }
  if(S.at(A) != '-') ans = "No";
  for(int i = A + 1; i < A + B + 1; i++){
    if(check(S.at(i)) == false) ans ="No";
  }
  cout << ans << endl;
  return 0;
}

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

void solve(long long N, std::vector<long long> A)
{
    vector<long long> B(N + 1, 0);
    for (int i = 2; i <= N; i++)
    {
        B[A[i]]++;
    }

    for (int i = 1; i <= N; i++)
    {
        cout << B[i] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    cin >> N;

    std::vector<long long> A(N + 1, 0);
    for (int i = 2; i <= N; i++)
    {
        cin >> A[i];
    }

    solve(N, std::move(A));
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef complex<double> P;

#define pb push_back
#define pf push_front
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define int ll
#define INF 100000000

#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int a,b;

bool check(){
    for (int i = 1; i <= 3; ++i) {
        if((a*b*i) % 2 == 1) return true;
    }

    return false;
}

signed main() {
    cin >> a >> b;
    Yes(check());
}

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

int main(){
	long long int n,m;
  	cin >> n >> m;
  	if(n==1 && m ==1)cout << 1 <<endl;
  	else if(n==1 )cout << m-2 << endl;
  	else if(m==1) cout << n-2 << endl;
  	else cout <<(m-2)*(n-2) << endl;
}


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

using namespace std;

#define MAX 55

string s;
string memo[MAX][MAX];

string get_max(string a, string b)
{
    int alen = a.size(), blen = b.size();
    if (alen > blen) {
        return a;
    } else if (alen < blen) {
        return b;
    }
    return (a > b ? a : b);
}

bool is_pare(int l, int r)
{
    int p = l + 1;
    if (r - l < 5) return 0;
    return ((s[p] == '?' || s[p] == '(') &&
            (s[r] == '?' || s[r] == ')'));
}

string dfs(int l, int r)
{
    string &res = memo[l][r];
    if (res != "*") return res;    
            
    if (s[l] == 'L' || s[l] == 'R' || s[l] == '?') {        
        if (is_pare(l, r)) {
            for (int i = l+3; i <= r-2; i++) {
                if (s[i] == ',' || s[i] == '?') {
                    if (s[l] == 'L' || s[l] == '?') {
                        if (dfs(i+1, r-1) != "/") {
                            res = get_max(res, dfs(l+2, i-1));      
                        }
                    }
                    if (s[l] == 'R' || s[l] == '?') {
                        if (dfs(l+2, i-1) != "/") {
                            res = get_max(res, dfs(i+1, r-1));                   
                        }
                    }
                }
            }
        }
    }
    string ss;
    for (int i = l; i <= r; i++) {
        if (isdigit(s[i])) {
            ss += s[i];
        } else if (s[i] == '?') {
            ss += "9";
        } else {
            ss = "/";
            break;
        }           
    }
    if (!ss.empty() && ss[0] == '0' && ss.size() > 1) {
        ss = "/";
    }
    res = get_max(res, ss);
    return res;
}

void init_table()
{
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            memo[i][j] = "*";
        }        
    }
}

int main()
{
    cin >> s;
    init_table();
    string res = dfs(0, s.size()-1);
    if (res == "/" || res == "*") {
        cout << "invalid" << endl;
    } else {
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3344
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

Int g(string s){
	Int p;
	rep0(p,sz(s))if(isdigit(s[p]))break;
	if(p==sz(s))return sz(s);
	Int c=0,q,r,times=0;
	repn0(q,p,sz(s)-1){
		if(!isdigit(s[q]))break;
		times=times*10+s[q]-'0';
	}
	if(s[q]!='('){
		s=s.substr(0,q)+"("+s.substr(q,1)+")"+s.substr(q+1);
	}
	rep0(r,sz(s)){
		if(s[r]=='(')++c;
		if(s[r]==')'){
			--c;
			if(c==0)break;
		}
	}
	return min(1000001LL,p+times*g(s.substr(q+1,r-q-1))+g(s.substr(r+1)));
}

char f(string s,Int i){
//cout<<s<<" "<<i<<endl;
	Int p;
	rep0(p,sz(s))if(isdigit(s[p]))break;
	if(p==sz(s)){
		if(i<p)return s[i];
		else return '0';
	}
	if(i<p)return s[i];
	s=s.substr(p);
	i-=p;
	Int c=0,q,times=0;
	rep0(p,sz(s)){
		if(!isdigit(s[p]))break;
		times=times*10+s[p]-'0';
	}
	if(s[p]!='('){
		s=s.substr(0,p)+"("+s.substr(p,1)+")"+s.substr(p+1);
	}
	rep0(q,sz(s)){
		if(s[q]=='(')++c;
		if(s[q]==')'){
			--c;
			if(c==0)break;
		}
	}
	Int len=g(s.substr(p+1,q-p-1));
	if(len*times>i){
		i%=len;
		return f(s.substr(p+1,q-p-1),i);
	}else{
		i-=len*times;
		return f(s.substr(q+1),i);
	}
}

int main() {
	string s;
	Int i;
	IL{
		cin>>s>>i;
		if(s=="0"&&i==0)break;
		cout<<f(s,i)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H,W,h,w,block,ans;

		H = sc.nextInt();
		W = sc.nextInt();
		h = sc.nextInt();
		w = sc.nextInt();
		
		block = H*W - (W*h+H*w-h*w);
		
		System.out.println(block);
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
      cin >> b[i];
    }
    int dp[60][60][60];
    memset(dp, -1, sizeof(dp));
    function<bool(int, int, int)> can = [&](int a, int b, int k) {
      int &res = dp[a][b][k];
      if (res != -1) {
        return res;
      }
      if (k == 0) {
        return res = (a == b);
      }
      return res = can(a, b, k - 1) || can(a % k, b, k - 1);
    };
    bool ok = true;
    for (int i = 0; i < N; i++) {
      ok &= can(a[i], b[i], 59);
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    vector<int> ks;
    auto solve = [&](int a, int b, int k) {
      vector<bool> dp(a + 1, false);
      dp[a] = true;
      for (int k : ks) {
        vector<bool> ndp = dp;
        for (int i = 0; i <= a; i++) {
          if (dp[i]) {
            ndp[i % k] = true;
          }
        }
        dp = ndp;
      }
      for (int i = 0; i <= a; i++) {
        if (dp[i] && can(i, b, k - 1)) {
          return false;
        }
      }
      return true;
    };
    for (int k = 60; k >= 1; k--) {
      bool need = false;
      for (int i = 0; i < N; i++) {
        if (solve(a[i], b[i], k)) {
          need = true;
          break;
        }
      }
      if (need) {
        ks.push_back(k);
      }
    }
    ll ans = 0;
    for (int k : ks) {
      ans += 1ll << k;
    }
    cout << ans << endl;
  }
  return 0;
}


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

def main():
  n = int(input())
  T = [[] for _ in range(n)]
  D = {}
  for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)
    D[(a, b)] = 1<<i
    D[(b, a)] = 1<<i
  m = int(input())

  def dfs(u, v):
    parent = [-1]*n
    seen = [False]*n
    stack = [u]
    seen[u] = True
    while stack:
      nv = stack[-1]
      if nv == v:
        return stack
      for i in T[nv]:
        if seen[i]:
          continue
        stack.append(i)
        seen[i] = True
        break
      else:
        stack.pop()

  def popcount(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
              
  E = [0]*m
  for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    edge = dfs(u, v)
    for j in range(len(edge)-1):
      E[i] |= D[(edge[j], edge[j+1])]

  ans = 0
  for i in range(2**m):
    s = 0
    for j in range(m):
      if i>>j & 1:
        s |= E[j]
    cnt = popcount(i) % 2
    ans += (-1)**cnt * 2**(n-1-popcount(s))
  print(ans)
  
if __name__ == "__main__":
  main()

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

int main() {
    
    int k, x;
    
    cin >> k >> x;
    
    if(500 * k >= x) cout << "Yes";
    else cout << "No";
    
    return 0;
}




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

min_cnt = N - 1
for i in range(1, int(N)):
    j = N // i
    if i > j:
        break
    if N % i == 0:
        cnt = (i - 1) + (j - 1)
        if min_cnt > cnt:
            min_cnt = cnt
print(min_cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define inf 1000000007

int main(void){
    long long int h, w;
    cin >> h >> w;
    long long int area = h*w;
    long long int sa, sb, sc;
    long long int ansh = 1000000000000;
    long long int answ = 1000000000000;
    long long int ans;
    int ch, cw;
    for(long long int i = 1; i <= h ; i++){
      sa = i*w; sb = (h-i)*floor(w/2); sc = (h-i)*(w-floor(w/2));
      ansh = min(ansh, max({sa, sb, sc})-min({sa, sb, sc}));
      sa = i*w; sb = floor((h-i)/2)*w; sc = (h-i-floor((h-i)/2))*w;
      ansh = min(ansh, max({sa, sb, sc})-min({sa, sb, sc}));
    }
    for(long long int i = 1; i <= w ; i++){
      sa = i*h; sb = (w-i)*floor(h/2); sc = (w-i)*(h-floor(h/2));
      answ = min(answ, max({sa, sb, sc})-min({sa, sb, sc}));
      sa = i*h; sb = floor((w-i)/2)*h; sc = (w-i-floor((w-i)/2))*h;
      ansh = min(ansh, max({sa, sb, sc})-min({sa, sb, sc}));
    }
  ans = min(ansh, answ);
      cout << ans << endl;
    return 0;
}

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

int main() 
{
  int A, B , C;
  cin >> A >> B >> C;
  int t;
  t = A;
  A = B;
  B = t;
  t = A;
  A = C;
  C = t;
  cout << A << " " << B << " " << C << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
const ll MOD = 1e9+7;
long long powmod(long long x,long long n){
    long long ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;

    ll ans=powmod(10,n);
    ans-=powmod(9,n); ans=(ans+MOD)%MOD;
    ans-=powmod(9,n); ans=(ans+MOD)%MOD;
    ans+=powmod(8,n); ans=(ans+MOD)%MOD;
    cout << ans << endl;
}




Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

int main(void)
{
    ll N;
    cin >> N;
    vector<ll> H(5);
    rep(i,5){
        cin >> H.at(i);
    }

    vector<ll> speed(5);
    rep(i,5){
        if (i == 0) {
            speed.at(i) = H.at(i);
        } else {
            speed.at(i) = min(speed.at(i-1), H.at(i));
        }
    }

    uint64_t ret = 0;
    if (N % speed.at(4) == 0) {
        ret = (uint64_t)(N / speed.at(4));
    } else {
        ret = (uint64_t)(N / speed.at(4)) + 1;
    }
    ret += 4;

    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

void solve() {
  // main coding
  int INF=1e9;
  int n,k; cin>>n>>k;
  vector<int> H(n);
  rep(i,n) cin>>H[i];
  vector<int> dp(n,INF);
  dp[0]=0;
  rep(i,n) for(int j=k;j>0;--j) {
    if(i-j>=0) dp[i]=min(dp[i],dp[i-j]+abs(H[i]-H[i-j]));
  }
  cout<<dp[n-1]<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    cout << min(b/a,c) << endl;


    return 0;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet
{
	#define int long long 

	#define F(i,l,r) for(int i=l;i<=r;++i)
	#define D(i,r,l) for(int i=r;i>=l;--i)
	#define Fs(i,l,r,c) for(int i=l;i<=r;c)
	#define Ds(i,r,l,c) for(int i=r;i>=l;c)
	#define Tra(i,u) for(int i=G.Start(u);~i;i=G.Next(i))
	#define MEM(x,a) memset(x,a,sizeof(x))
	#define FK(x) MEM(x,0)
	int n,s;
	void Input()
	{
		cin>>n>>s;
	}

	int sum(int base,int x)
	{
		if (base==1) return -1;
		if (x==0) return 0;
		if (x<base) return x;

		return (x%base)+sum(base,x/base);
	}
	void Soviet()
	{
		if (s>n) return (void)puts("-1");
		if (s==n) return (void)printf("%lld\n",n+1);

		int m=sqrt(n+0.5)+1;
		F(i,2,m)
		{
			if (sum(i,n)==s)
			{
				printf("%lld\n",i);
				return;
			}
		}

		int ans=0x3f3f3f3f3f3f3f3fll;
		n-=s;
		for(int i=1;i*i<=n;++i)
		{
			if (n%i==0)
			{
				int x=(n/i)+1;
				if (sum(x,n+s)==s) ans=min(ans,x);
			}
		}

		if (ans>=0x3f3f3f3f3f3f3f3fll) return (void)puts("-1");
		else printf("%lld\n",ans);
	}
	void IsMyWife()
	{
		Input();
		Soviet();
	}
	#undef int //long long 
}
int main()
{
	Flandre_Scarlet::IsMyWife();
	getchar();getchar();
	return 0;
}

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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x);        // xの根をrx
    int ry = root(y);        // yの根をry
    if(rx == ry)
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ps(N);
  for(int i = 0; i < N; ++i) {
    cin >> ps[i];
    ps[i] -= 1;
  }
  auto uf = UnionFind(N);
  int x, y;
  for(int i = 0; i < M; ++i) {
    cin >> x >> y;
    uf.unite(x - 1, y - 1);
  }
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(uf.same(i, ps[i])) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] chars = s.toCharArray();
		Set<Character> set = new HashSet<>();
		if(chars.length==2) {
			System.out.println(chars[0]==chars[1] ? "1 2" : "-1 -1");
			return;
		}
		for(int i = 2; i < chars.length; i++) {
			set.add(chars[i-2]);
			set.add(chars[i-1]);
			set.add(chars[i]);
			if(set.size() <= 2) {
				System.out.println((i-1)+" "+(i+1));
				return;
			}
			set.clear();
		}
		System.out.println("-1 -1");
	}
}

Measured memory_bytes: 34456
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>
#include <functional>
int main(){
	int ans = 0;
	std::string fore, just;
	std::cin >> fore >> just;
	for(int i = 0; i < 3; i++){
		if(fore[i] == just[i]){
			ans++;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;


int x[1000], y[1000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N;
  vector<int> a(N);
  int amax = -INF, amin = INF;
  int max_index, min_index;
  REP(i,N){
    cin >> a[i];
    if(a[i] > amax) amax = a[i], max_index = i;
    if(a[i] < amin) amin = a[i], min_index = i;
  }
  int ans = 0;
  
  if(amax > 0 && amin < 0){
    if(abs(amax) - abs(amin) > 0){ // max > min
      REP(i,N) if(a[i] < 0){
        x[ans] = max_index + 1;
        y[ans] = i + 1;
        a[i] += amax,ans++;
      }
    }else{
      REP(i,N) if(a[i] > 0){
        x[ans] = min_index + 1;
        y[ans] = i + 1;
        a[i] += amin,ans++;
      }
    }
  }

  amax = -INF, amin = INF;
  REP(i,N){
    if(a[i] > amax) amax = a[i];
    if(a[i] < amin) amin = a[i];
  }

  if(amin >= 0 && amax >= 0){
    REP(i, N-1) if(a[i + 1] < a[i]){
      x[ans] = i + 1;
      y[ans] = i + 2;
      a[i + 1] += a[i],ans++;
    }
  }else{
    for(int i = N - 2; i >= 0; --i) if(a[i + 1] < a[i]){
        x[ans] = i + 2;
        y[ans] = i + 1;
        a[i] += a[i + 1],ans++;
      }
  }
  cout << ans << endl;
  REP(i,ans){
    cout << x[i] << ' ' << y[i];
    cout << endl;
  }
  /*  cout << "DEBUG" << endl;
      REP(i,N) cout << a[i] << ' ';*/
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define H 250

int main(){
  int h,i,a;
  int A[H];
  
  scanf("%d",&h);
  for(i = 1; i <= h; i++){
    scanf("%d",&A[i]);
  }
  for(i = 1; i <= h; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i != 1){
      printf("parent key = %d, ",A[i / 2]);
      if(i * 2 > h) printf("\n");
    }
    if(i * 2 <= h){
      printf("left key = %d, ",A[i * 2]);
      if(i * 2 + 1 > h) printf("\n");
    }
    if(i * 2 + 1 <= h){
      printf("right key = %d, \n",A[i * 2 + 1]);
    }
    
  }
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
	makei(A);
	makei(B);
	int ans = 0;
	Rep(A, B + 1) {
		if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10)++ans;
	}
	say(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <map> 
#include <set>
#include <vector>
#include <list>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define ll long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int gcd(int a, int b) {
    if (a < b) a, b = b, a;
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

void solve() {
    int N, M;
    cin >> N;
    cin >> M;

    cout << M * 2 - N << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cout.precision(20);
    cout << fixed;

    solve();
}


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

#define mod 1000000007

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int N;
long long K;
int A[2019], B_bef[2019], B_aft[2019];

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

  for (int i = 0; i < N; i++) {
    int cnt_bef = 0;
    int cnt_aft = 0;
    for (int j = 0; j < i; j++) {
      if (A[i] > A[j]) cnt_bef++;
    }
    for (int j = i+1; j < N; j++) {
      if (A[i] > A[j]) cnt_aft++;
    }
    B_bef[i] = cnt_bef;
    B_aft[i] = cnt_aft;
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (B_aft[i] * K % mod) + (B_bef[i] + B_aft[i]) * (K*(K-1)/2%mod) % mod;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[--k] << endl;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

void insertionSort(int A[], int n, int g);
void shellSort(int A[], int n);

int cnt;

int main(void){
	int n;
	scanf("%d", &n);
	
	int A[n], i;
	
	for(i=0; i<n; i++){
		scanf(" %d", &A[i]);
	}
	
	shellSort(A, n);
	printf("%d\n", cnt);
	for(i=0; i<n; i++) printf("%d\n", A[i]);
	
	return 0;
}

void insertionSort(int A[], int n, int g){
	
	int i, v, j;
	
	for(i=g; i<n; i++){
		v=A[i];
		j=i-g;
		
		while(0<=j && v<A[j]){
			A[j+g]=A[j];
			j=j-g;
			cnt++;
		}
		A[j+g]=v;
	}
}

void shellSort(int A[], int n){
	
	int g[100], m, i;
	
	g[0]=1;
	for(m=1; 3*g[m-1]+1<=n; m++) g[m]=g[m-1]*3+1;
	printf("%d\n", m);
	
	cnt=0;
	
	for(i=m-1; i>=0; i--) {
		if(i==0) printf("%d\n", g[i]);
    	else printf("%d ", g[i]);
		insertionSort(A, n, g[i]);
 	}
}


Measured memory_bytes: 5628
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(){
  int n,m,d,p,o;
  typedef pair<int,int> ma;
  
  int i,j,k;
  cin >> n >> m;
  while(n!=0||m!=0){
    vector <ma> map;
    ma b;
    for(i=0;i<n;i++) {
      cin >> d >> p;
      b.first=p;b.second=d;
      map.push_back(b);
    }
    sort(map.begin(),map.end(),greater<ma>());
    o=0;
    for(i=0;i<map.size();i++){
      if(m>=map[i].second) m-=map[i].second;
      else if(m>0) {
	o+=(map[i].second-m)*map[i].first;
	m=0;
      }else o+=map[i].first*map[i].second;
    }
    cout << o << endl;
    cin >> n >> m;
  }
  return 0;
}

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

int main(){

    int n;
    cin >> n;

    for(int i=1; i<=n; i++){

        if(((i % 3) == 0)){
            cout << " " << i;
        }else{
            int x = i;
            while(x>0){
                if(x%10 == 3){
                    cout << " " << i;
                    break;
                }
                x = x/10;
            }

        }
    }
    cout << endl;

    return  0;
}

Measured memory_bytes: 3088
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
#define LEN 105
#define INF 10005
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	char c[105][105];
	for (int i = 0; i < h; i++)
		cin >> c[i];
	int dp[105][105];
	for (int i = 0; i < LEN; i++)
		for (int j = 0; j < LEN; j++)
			dp[i][j] = INF;
	dp[0][0] = c[0][0] == '.' ? 0 : 1;
	for (int i = 1; i < h; i++)
		dp[i][0] = dp[i - 1][0] + (c[i][0] == '.' || c[i][0] == c[i - 1][0] ? 0 : 1);
	for (int i = 1; i < w; i++)
		dp[0][i] = dp[0][i - 1] + (c[0][i] == '.' || c[0][i] == c[0][i - 1] ? 0 : 1);
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (c[i][j] == '.') {
				dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]);
			} else {
				if (c[i][j - 1] == '.')
					dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				else dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				if (c[i - 1][j] == '.')
					dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
				else dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			}
		}
	}
	cout << dp[h - 1][w - 1] << "\n";
	return 0;
}

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

int main() {
  double a,b,c,d,e,f;
  while(cin >>a>>b>>c>>d>>e>>f) {
    double x=(c*e-b*f)/(a*e-b*d);
    double y=(c*d-a*f)/(b*d-a*e);
    if (-0.0001<x&&x<0.0001) x=0;
    if (-0.0001<y&&y<0.0001) y=0;
    printf("%.3f %.3f\n", x, y);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define ULL ull
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int, pii >
#define pll pair <ll,ll>
#define pb push_back
#define big 20160116
#define INF 2147483647
#define pq priority_queue
#define rank rk124232
#define y1 y20160116
#define y0 y20160110
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
namespace Mymath{
	LL qp(LL x,LL p,LL mod){
		LL ans=1;
		while (p){
			if (p&1) ans=ans*x%mod;
			x=x*x%mod;
			p>>=1;
		}
		return ans;
	}
	LL inv(LL x,LL mod){
		return qp(x,mod-2,mod);
	}
	LL C(LL N,LL K,LL fact[],LL mod){
		return fact[N]*inv(fact[K],mod)%mod*inv(fact[N-K],mod)%mod;
	}
	template <typename Tp> Tp gcd(Tp A,Tp B){
		if (B==0) return A;
		return gcd(B,A%B);
	}
	template <typename Tp> Tp lcm(Tp A,Tp B){
		return A*B/gcd(A,B);
	}
};
namespace fwt{
	using namespace Mymath;
	void FWT(int a[],int n,LL mod)
	{
	    for(int d=1;d<n;d<<=1)
	        for(int m=d<<1,i=0;i<n;i+=m)
	            for(int j=0;j<d;j++)
	            {
	                int x=a[i+j],y=a[i+j+d];
	                a[i+j]=(x+y)%mod,a[i+j+d]=(x-y+mod)%mod;
	                //xor:a[i+j]=x+y,a[i+j+d]=x-y;
	                //and:a[i+j]=x+y;
	                //or:a[i+j+d]=x+y;
	            }
	}

	void UFWT(int a[],int n,LL mod)
	{
		LL rev=inv(2,mod);
	    for(int d=1;d<n;d<<=1)
	        for(int m=d<<1,i=0;i<n;i+=m)
	            for(int j=0;j<d;j++)
	            {
	                int x=a[i+j],y=a[i+j+d];
	                a[i+j]=1LL*(x+y)*rev%mod,a[i+j+d]=(1LL*(x-y)*rev%mod+mod)%mod;
	                //xor:a[i+j]=(x+y)/2,a[i+j+d]=(x-y)/2;
	                //and:a[i+j]=x-y;
	                //or:a[i+j+d]=y-x;
	            }
	}
	void solve(int a[],int b[],int n,LL mod)
	{
	    FWT(a,n,mod);
	    FWT(b,n,mod);
	    for(int i=0;i<n;i++) a[i]=1LL*a[i]*b[i]%mod;
	    UFWT(a,n,mod);
	}
};
const int Maxn=2e5+5;
int a[Maxn];
int b[Maxn];
int n;
int check(int v){
	for (int i=1;i<=2*n-1;i++) b[i]=(a[i]>=v)?1:0;
	if (b[n]==b[n+1] || b[n-1]==b[n]){
		return b[n];
	}
	for (int l=n,r=n;l>=1;l--,r++){
		if (b[l]==b[l+1]){
			return b[l];
		}
		if (b[r]==b[r-1]){
			return b[r];
		}
	}
	return b[n]^(n&1)^1;
}
int main(){
	n=read();
	for (int i=1;i<=2*n-1;i++) a[i]=read();
	int lo=1,hi=2*n;
	while (hi-lo>1){
		int mid=lo+hi>>1;
		if (check(mid)){
			lo=mid;
		}
		else{
			hi=mid;
		}
	}
	printf("%d\n",lo);
	return 0;
} 

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

int main(){
    int N;
    cin >> N;
    int min_cnt = 10000;
    for(int i=0; i<N; i++){
        int Ai;
        cin >> Ai;
        int cnt = 0;
        while(true){
            if(Ai%2 == 0){
                cnt++;
                Ai = Ai/2;
            }else{
                break;
            }
        }
        if(cnt < min_cnt){
            min_cnt = cnt;
        }
    }
    cout << min_cnt << endl;
}

Measured memory_bytes: 764
// ABC 161
"use strict"

function Main(input) {
  input = input.split(" ");
  let A = parseInt(input[2],10);
  let B = parseInt(input[0],10);
  let C = parseInt(input[1],10);
  console.log(A + " " + B + " " + C)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8008
import sys
from collections import Counter

def choose(k, r):
    return k*(k-1) // r*(r-1)

N = int(input())
A = list(map(int, sys.stdin.readline().strip().split()))

C = Counter(A)

ANS = sum([choose(v, 2) for v in C.values()])

for k in A:
    v = C[k]
    print(ANS
          - choose(v, 2)
          + choose(v-1, 2)
         )


Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"

#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}

#define SHOW(x) std::cout << #x << " = " << x << std::endl;

inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int main()
{
//    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> mask(8, 0);
    int cnt = 0;
    for(int i = 0 ;i < n; ++i)
    {
        int x;
        cin >> x;
        x /= 400;
        if (x >= 8)
            ++cnt;
        else
            mask[x] = 1;
    }
    int ans = 0;
    for(int x : mask)
        ans += x;
    int m1 = ans;
    if (ans == 0 && cnt > 0)
        m1++;
    int m2 = ans + cnt;
    cout << m1 << ' ' << m2 << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

void print(ll res)
{
        cout<<res<<"\n";
        exit(0);
}

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll n,a,b;
        cin>>n>>a>>b;
        ll profit=b-a;
        if(profit<=1)
        {
                cout<<n+1<<"\n";
                return 0;
        }
        ll bisc=1;
        /// make a bisc
        ll t=min(n,a-1);
        n-=t;
        bisc+=t;
        if(n==0)
        {
                print(bisc);
        }
        /// profit>=2
        if(n%2==1)
        {
                n--;
                bisc++;
        }
        bisc+=(n/2)*profit;
        cout<<bisc<<"\n";
        return 0;
}
/**

**/


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

int main() {
    long long h, w;
    cin >> h >> w;
    
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    } 
    cout << ((h * w) + 1) / 2 << endl;
}

Measured memory_bytes: 256
fn main() {
    let n = rv::<usize>()[0];
    let mut dp = vec![[0;1<<4];n+1];
    dp[0][0]=1;
    for i in 0..n {
        for &j in &[0,1,2,0] {
            dp[i+1][j] += dp[i][0];
        }
        for &j in &[9,1,3,5] {
            dp[i+1][j] += dp[i][1];
        }
        for &j in &[0,11,2,0] {
            dp[i+1][j] += dp[i][2];
        }
        for &j in &[10,11,12,15] {
            dp[i+1][j] += dp[i][3];
        }
        for &j in &[0,1,15,0] {
            dp[i+1][j] += dp[i][5];
        }
        for &j in &[0,1,12,0] {
            dp[i+1][j] += dp[i][9];
        }
        for &j in &[0,1,2,15] {
            dp[i+1][j] += dp[i][10];
        }
        for &j in &[9,1,3,15] {
            dp[i+1][j] += dp[i][11];
        }
        for &j in &[0,11,2,15] {
            dp[i+1][j] += dp[i][12];
        }
        for &j in &[15,15,15,15] {
            dp[i+1][j] += dp[i][15];
        }
        for j in 0..1<<4 {
            dp[i+1][j] %= MOD;
        }
    }
    println!("{}",dp[n][0..15].iter().sum::<u64>()%MOD);
}
const MOD: u64=1000000007;
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
def ispal(a):
    z=[]
    for i in range(len(a)-1,-1,-1):
        z.append(a[i])
    if z==a:
        return True
    else: return False
s=[i for i in input()]
n=len(s)
if ispal(s):
    if ispal(s[:(n-1)//2]):
        if ispal(s[(n+3)//2-1:]):
            print('Yes')
            exit(0)
print('No')
    

Measured memory_bytes: 38352