akhauriyash/Code-Regression huggingface dataset:
#[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)*}
    };
}

#[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),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n:i32,
        d:[i32; n],
    }

    let mut ans = 0;

    for i in 0..n {
            for j in (i+1)..n {
                ans = ans + d[i as usize] * d[j as usize]
            }
    }

    println!("{}", ans)
   

}


Measured memory_bytes: 4352
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll k;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k;
    ll ans=0;
    for (int i = 1; i <= k; i++)
    {
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ans+=gcd(l,gcd(i,j));
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3652
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static PrintWriter out = new PrintWriter(System.out);
	static Scanner stdIn = new Scanner(System.in);
	static FastScanner sc = new FastScanner();

	
	public static void main(String[] args) {
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int max = 0;
			int min = Integer.MAX_VALUE;
			for(int i = 0; i < n; i++) {
				int sum = 0;
				for(int j = 0; j < 5; j++) {
					sum += sc.nextInt();
				}
				max = Math.max(max, sum);
				min = Math.min(min, sum);
			}
			out.println(max + " " + min);
		}
		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 int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    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();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
     
    public int nextInt() {
        return (int)nextLong();
    }
     
    public double nextDouble() {
        return Double.parseDouble(next());
    }
     
 
}

Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000003;

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

signed main(){
	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;
}


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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  cout <<n*m<<'\n';
  return (0);
}


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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T, size_t N> ostream& operator << (ostream &os, const array<T, N> &a) {os << "("; for (int i=0; i<(int)N; i++) {if (i) os << ", "; os << a[i];} return os << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int n, numZeroes = 0;
long long k;
vector<int> pos, neg;

bool check(long long x) {
    long long numPairs = 0;
    if (x < 0) {
        for (int i : neg) {
            int l = 0, r = pos.size();
            while (l < r) {
                int m = (l + r) / 2;
                if ((long long) i * pos[m] < x)
                    r = m;
                else
                    l = m + 1;
            }
            numPairs += pos.size() - l;
        }
    } else {
        numPairs += (long long) pos.size() * neg.size();
        if (x > 0) {
            numPairs += (long long) numZeroes * (pos.size() + neg.size()) + (long long) numZeroes * (numZeroes - 1) / 2;
            for (int i=0, j=(int)pos.size()-1; i<j; ) {
                if ((long long) pos[i] * pos[j] < x) {
                    numPairs += j - i;
                    i++;
                } else {
                    j--;
                }
            }
            for (int i=0, j=(int)neg.size()-1; i<j; ) {
                if ((long long) neg[i] * neg[j] < x) {
                    numPairs += j - i;
                    i++;
                } else {
                    j--;
                }
            }
        }
    }
    return numPairs < k;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> k;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a < 0)
            neg.push_back(a);
        else if (a > 0)
            pos.push_back(a);
        else
            numZeroes++;
    }

    sort(pos.begin(), pos.end());
    sort(neg.rbegin(), neg.rend());

    long long l = -1e18, r = 1e18;
    while (l < r) {
        long long m = (l + r + 1) / 2;
        if (check(m))
            l = m;
        else
            r = m - 1;
    }

    cout << l << "\n";

    return 0;
}


Measured memory_bytes: 1400
object Main {
  def main(args: Array[String]): Unit = {
    val Seq(n, t): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt)
    val ts = io.StdIn.readLine().split(' ').map(_.toLong)

    val (ans, _) = ts.foldLeft((0.toLong, 0.toLong)){(z, time) =>
      val (acc, prev) = z
      val add = if (time - prev <= t) time - prev else t.toLong
      (add + acc, time)
    }

    println(ans + t)
  }
}

Measured memory_bytes: 56696
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 998244353
typedef long long ll;
long long modinv(long long a, long long m = MOD) {
    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;
}
vector<ll> fact(400005);
long long comb(long long n, long long r, long long m = MOD){
    if(n<r) return 0;
    if(r<0) return 0;
    return (((fact[n] * modinv(fact[n-r]))%m) * modinv(fact[r])) % m;
}

int main(){
    fact[0] = 1;
    FOR(i,1,400002) fact[i]  = (fact[i-1] * i) % MOD;
    ll n,a,b,k; cin >> n >> a >> b >> k;
    ll ans = 0;
    rep(i,n+1){
        if((k - i*a) % b == 0){
            ll y = (k - i*a) / b;
            ans += (comb(n,i) * comb(n, y)) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int N = 100 * 1000 + 5;
int root = -1;

vector <int> adj[N];
int par[N];
int dp0[N];
int dp1[N];

void dfs(int v) {
	if (adj[v].size() == 1) {
		dp0[v] = 1;
		return ;
	}
	int maxi = 0;
	bool b = false;
	if (adj[v].size() == 2 && v != root) {
		for (auto u : adj[v]) {
			if (u != par[v]) {
				par[u] = v;
				dfs(u);
				dp1[v] = dp1[u];
				dp0[v] = dp0[u];
			}
		}
		return;
	}
	for (auto u : adj[v]) {
		if (u != par[v]) {
		//	cout << 73 << " " << v << " " << u << endl; 
			par[u] = v;
			dfs(u);
		//	dp0[v] += dp0[u];
			dp0[v] += max(dp1[u], 1);
			if (dp1[u] == 0) {
				b = true;
			}
		//	maxi = max(maxi, dp0[u] - dp1[u]);
		}
	}
	dp1[v] = dp0[v];
	if (b) {
		dp1[v]--;
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	if (n <= 2) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (adj[i].size() > 2) {
			root = i;
		}
	}
	if (root == -1) {
		cout << 1;
		return 0;
	}
//	root = 2;
//	cout << "94 " << root << endl;
	par[root] = -1;
	dfs(root);
//	for (int i = 0 ; i < n; i++) {
//		cout << i << " " << dp0[i] << " " << dp1[i] << endl;
//	}
	cout << dp1[root] << endl;
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,x,c;
  cin >> a >> b >> x;
  c=0;
  if(a==0){
    printf("%lld",b/x+1);
    return 0;
  }
  printf("%lld",b/x-(a-1)/x);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string w[n];
    bool flag = true;
    cin >> w[0];
    for(int i = 1;i < n;i++)
    {
        cin >> w[i];
        if(w[i][0] != w[i - 1][w[i - 1].size() - 1])
        {
            flag = false;
        }
        for(int j = 0;j < i;j++)
        {
            if(w[i] == w[j])
            {
                flag = false;
            }
        }
    }
    if(flag)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text.RegularExpressions;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            for (int i = 0; i < input.Length; i++)
            {
                ChangeStr(input[i]);
            }

            Console.WriteLine("");
        }

        static void ChangeStr(char c)
        {
            if (Regex.IsMatch(c.ToString(), @"[a-z]"))
            {
                Console.Write(c.ToString().ToUpper());
            }
            else
            {
                Console.Write(c.ToString().ToLower());
            }
        }
    }
}

Measured memory_bytes: 11412
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,k,q;cin>>n>>k>>q;
    ll a[q];
    ll c[n+1];
    ll i;
    for(i=1;i<=n;i++){
        c[i]=0;
    }
    for(i=0;i<q;i++){
        cin>>a[i];
        c[a[i]]++;
    }
    for(ll i=1;i<=n;i++){
        if(c[i]<=q-k){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    
    
    
    return 0;
}



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

char visited[200][200];

int dfs(int x,int y,int turn) {
	int sum=0;
	if(visited[y][x]==0)sum++;
	if(visited[y][x]>=turn+1)return 0;
	visited[y][x]=turn+1;
	if(turn>0) {
		sum+=dfs(x,y+1,turn-1);
		sum+=dfs(x+1,y+1,turn-1);
		sum+=dfs(x-1,y,turn-1);
		sum+=dfs(x+1,y,turn-1);
		sum+=dfs(x-1,y-1,turn-1);
		sum+=dfs(x,y-1,turn-1);
	}
	return sum;
}

int main(void) {
	int t,n;
	while(scanf("%d%d",&t,&n)==2 && (t|n)!=0) {
		int i,j;
		int x[300],y[300];
		int sx,sy;
		memset(visited,0,sizeof(visited));
		for(i=0;i<n;i++)scanf("%d%d",&x[i],&y[i]);
		scanf("%d%d",&sx,&sy);
		for(i=0;i<n;i++)visited[y[i]+100][x[i]+100]=100;
		printf("%d\n",dfs(sx+100,sy+100,t));
	}
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	int f=1;
	for(int i=0;i<n;i++){
		if(a[i]%2)continue;
		if(a[i]%3==0 or a[i]%5==0)continue;
		f=0;
		break;
	}
	if(f)cout << "APPROVED";
	else cout << "DENIED";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n;
int x[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> x[i];
}

void solve()
{
	vector<int> actual;
	for(int i = 0; i < n; i++)
		actual.push_back(x[i]);

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

	for(int i = 0; i < n; i++)
	{
		int v = actual[n / 2 - 1]; 
		if(x[i] <= v) v = actual[n / 2];
		cout << v << endl;
	}
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 3956
#include <cstdio>

const int MN = 21;

int N, K, s[1 << MN], tr[1 << MN][2];
int f[MN][1 << MN], Ans;

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i <= N; ++i)
		for (int x = 0; x < 1 << i; ++x)
			scanf("%1d", &f[i][1 << i ^ x]);
	s[0] = -1;
	for (int A = 1; A < 2 << N; ++A) s[A] = s[A >> 1] + 1;
	for (int A = 2; A < 2 << N; ++A)
		if (A >> (s[A] - 1) & 1) {
			tr[A][1] = A ^ 1 << s[A];
			tr[A][0] = tr[tr[A][1]][0];
		} else {
			tr[A][0] = A ^ 3 << (s[A] - 1);
			tr[A][1] = tr[tr[A][0]][1];
		}
	for (int i = N; i >= 1; --i) {
		for (int A = 1 << i; A < 2 << N; ++A) {
			if (!f[i][A]) continue;
			int _ = A >> i, B = (A & ((1 << i) - 1)) ^ 1 << i;
			if (tr[B][0]) f[s[tr[B][0]]][(_ << 1 ^ 1) << s[tr[B][0]] ^ tr[B][0]] += f[i][A];
			if (tr[B][1]) f[s[tr[B][1]]][(_ << 1 ^ 0) << s[tr[B][1]] ^ tr[B][1]] += f[i][A];
			f[0][_] += f[i][A];
		}
	}
	Ans = 1;
	for (int A = 2; A < 2 << N; ++A) if (f[0][A] >= K && s[A] > s[Ans]) Ans = A;
	int j = N;
	while (~Ans >> j & 1) --j;
	while (j--) printf("%d", Ans >> j & 1);
	puts("");
	return 0;
}

Measured memory_bytes: 194816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
const ll INF = 1LL<<60;

int main(){
  ll K;
  cin>>K;
  rep(i,K){
  cout<<"ACL";}
  cout<<endl;
}


Measured memory_bytes: 3568
// https://atcoder.jp/contests/abc065/tasks/abc065_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

const int MOD = 1000000007;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
    int x = a.n + b.n;
    return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
    int x = a.n - b.n;
    return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    if (a == b) {
        cout << P(a, a) * P(b, b) * 2 << endl;
    } else if (a + 1 == b) {
        cout << P(a, a) * P(b, b) << endl;
    } else {
        cout << "0\n";
    }
    return 0;
}


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

int main(){

    ll n, w; cin >> n >> w;
    vector< ll > wi(n+1), v(n+1);

    for(int i=1; i<=n; i++)
        cin >> wi[i] >> v[i];

    vector< vector<ll> > dp;
    dp.assign(n+1, vector<ll>(w+1, 0));

    for(int i=1; i<=n; i++)
    for(int j=0; j<=w; j++){
        dp[i][j] = max(dp[i][j], dp[i-1][j]);
        if(j >= wi[i])
            dp[i][j] = max(dp[i][j], v[i]+dp[i-1][j-wi[i]]);
    }

    cout << *max_element(dp[n].begin(), dp[n].end()) << "\n";

    return 0;
}


Measured memory_bytes: 83000
n, k = map(int,input().split())

p = [0] * (n+1)

for i in range(1,n+1):
    r = k / i
    t = 0
    while 2 ** t < r:
        t += 1
    #print(t)
    p[i] = 0.5 ** t

#print(p)

print(sum(p)/n)


Measured memory_bytes: 6132
def calc(N, S):
    ll = 1
    lr = N // 2 + 1
    l = (ll + lr) // 2
    while True:
        d = {}
        for i in range(0, N - l + 1):
            s = S[i: i + l]
            if s in d:
                d[s] += [i]
            else:
                d[s] = [i]
        f = True
        for s in d:
            if len(d[s]) > 1 and [e for e in d[s][1:] if e > d[s][0] + l - 1]:
                ll = l
                f = False
                break
        if f:
            if l == 1:
                return 0
            lr = l
            if ll == lr:
                return ll
        else:
            if ll == lr - 1:
                return ll
        l = (ll + lr) // 2
    return 0


N = int(input())
S = input()
print(calc(N, S))

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
vector<vector<int>> graph(100010);
vector<int> color(100010,-1);
map<string,int> output;

void dfs(int n,int parent_color,int parent){
    int co=1;
    for(int itr : graph[n]){
        if(co == parent_color) co++;
        if(color[itr] == -1){
            string tmp = to_string(itr)+","+to_string(n);
            string tmp1 = to_string(n)+","+to_string(itr);
           // cout << tmp << endl;
            //cout << tmp1 << endl;
            output[tmp] = co;
            output[tmp1] = co;
            color[itr] = co;
            dfs(itr,co,n);
            co++;
        }
    }
}

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

    vector<string> ab;
    rep(i,1,n){
        int a,b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
        string tmp = to_string(a-1)+","+to_string(b-1);
        ab.push_back(tmp);
    }
    int maxi = 0;
    color[0] = 1000000;
    rep(i,0,n) maxi = max(maxi,(int)graph[i].size());
    dfs(0,-1,0);
    cout << maxi << endl;
    rep(i,0,n-1){
        cout << output[ab[i]] << endl;
    }
}

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

int h, w;
string field[25];
int c[25][25];

int bfs(int x, int y, int count) {
  c[x][y] = count;

  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
  int result = -1;
  for(int i=0; i < 4; i++) {
    int nx = x+dx[i], ny = y+dy[i];
    if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == '.') {
      if(c[nx][ny] <= count+1) continue;
      result = max(bfs(nx, ny, count+1), result);
    }
  }
  return result;
}

int main() {
  cin >> h >> w;
  for(int i=0; i < h; i++) cin >> field[i];

  int result = -1;
  for(int i=0; i < h; i++) for(int j=0; j < w; j++) {
    if(field[i][j] == '#') continue;
    for(int a=0; a < 25; a++) for(int b=0; b < 25; b++){
      c[a][b] = 100000;
    }

    bfs(i, j, 0);

    for(int a=0; a < h; a++) for(int b=0; b < w; b++) {
      if(field[a][b] == '#') continue;
      result = max(result, c[a][b]);
    }
  }
  cout << result << endl;
}


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

lli n;

int main(void){
	cin >> n;
	vector<lli> v(n);
	vector<lli> e(N), o(N);
	rep(i, n) cin >> v[i];
	rep(i, n){
		if(i%2 == 0){
			e[v[i]]++;
		}else{
			o[v[i]]++;
		}
	}
	auto p1 = max_element(e.begin(), e.end())-e.begin();
	auto p2 = max_element(o.begin(), o.end())-o.begin();
	if(p1 != p2){
		cout << n-e[p1]-o[p2] << endl;
	}else{
		sort(e.rbegin(), e.rend());
		sort(o.rbegin(), o.rend());
		cout << n-max(e[0]+o[1], e[1]+o[0]) << endl;
	}

	return 0;
}


Measured memory_bytes: 5640
import java.util.Scanner;

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

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        double timeSpeed = 360. / 12 / 60;
        double minuteSpeed = 360. / 1 / 60;

        double x = (minuteSpeed - timeSpeed) * (h * 60 + m);

        double c2 = a * a + b * b - 2 * a * b * Math.cos(x * Math.PI / 180);

        System.out.println(Math.sqrt(c2));
    }
}

Measured memory_bytes: 35852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	string s;
	cin >> s;
	int ans = 100000;
	int cnt = 0;
	FOR(i, s.length()) {
		if (i % 2 == 0) {
			if (s[i] == '1')cnt++;
		}
		else {
			if (s[i] == '0')cnt++;
		}
	}
	ans = min(ans, cnt);
	cnt = 0;
	FOR(i, s.length()) {
		if (i % 2 == 0) {
			if (s[i] == '0')cnt++;
		}
		else {
			if (s[i] == '1')cnt++;
		}
	}
	ans = min(ans, cnt);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
m, d = map(int, input().split())
ans = 0

for i in range(22, d+1):
    num = str(i)
    d_1 = int(num[-1])
    d_10 = int(num[-2])
    if 0 < d_1 * d_10 <= m and d_1 > 1 and d_10 > 1:
        ans += 1
print(ans)


Measured memory_bytes: 3068
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

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

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n, m;
	cin >> n >> m;
	vector<edge>e(m);
	f(i, 0, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--; c *= (-1);
		e[i].from = a; e[i].to = b; e[i].cost = c;
	}
	vi d(n, ll_INF);
	d[0] = 0;
	f(cnt, 0, n - 1) {
		f(i, 0, m) {
			if (d[e[i].from] == ll_INF) {
				continue;
			}
			if (d[e[i].to] > d[e[i].from] + e[i].cost) {
				d[e[i].to] = d[e[i].from] + e[i].cost;
			}
		}
	}
	int ans = d[n - 1];
	vb neg(n, false);
	f(cnt, 0, n) {
		f(i, 0, m) {
			if (d[e[i].from] == ll_INF) {
				continue;
			}
			if (d[e[i].to] > d[e[i].from] + e[i].cost) {
				d[e[i].to] = d[e[i].from] + e[i].cost;
				neg[e[i].to] = true;
			}
			if (neg[e[i].from]) {
				neg[e[i].to] = true;
			}
		}
	}
	if (neg[n - 1]) {
		cout << "inf";
	}
	else {
		cout << -ans;
	}
	return 0;
}

Measured memory_bytes: 256
ticket = input()
A,B,C,D = [n for n in ticket]
for i in range(2**3):
  answer = int(ticket[0])
  for j in range(3):
    if (i>>j)&1 == 1:
      answer += int(ticket[j+1])
    else:
      answer -= int(ticket[j+1])
  if answer == 7:
    op = bin(i)[2:]
    if len(op) == 1:
      op = "00"+op
    elif len(op) == 2:
      op = "0"+op
    op = op.replace("1","+").replace("0","-")
    result = A + op[2] + B + op[1] + C + op[0] + D + "=7"
    break
print(result)

Measured memory_bytes: 9160
if __name__=="__main__":
    n = int(input())
    a = [int(i) for i in input().split(' ')]
    ave = 0.0
    for i in a:
        ave += i
    ave /= n
    ans = 0
    for id, i in zip(range(n), a):
        if abs(a[ans] - ave) > abs(i - ave):
            ans = id
    print(ans)

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A, B;
	cin >> A >> B;
	cout << A*B << endl;

	return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from collections import deque


def read():
    H, W = map(int, input().strip().split())
    S = []
    for i in range(H):
        s = list(input().strip())
        S.append(s)
    return H, W, S


def solve(H, W, S):
    n_cells = 0
    for y in range(H):
        for x in range(W):
            if S[y][x] == ".":
                n_cells += 1
    A = [[-1 for j in range(W)] for i in range(H)]
    A[0][0] = 1
    D = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque()
    q.append((0, 0))
    while q:
        y, x = q.popleft()
        for dy, dx in D:
            ny, nx = y + dy, x + dx
            if 0 <= ny < H and 0 <= nx < W and S[ny][nx] == "." and A[ny][nx] == -1:
                A[ny][nx] = A[y][x] + 1
                q.append((ny, nx))
    shortest = A[H-1][W-1]
    return n_cells - shortest if shortest > 0 else -1


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 9540
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

int main() {
	string s;
	int w;

	cin >> s;
	cin >> w;

	int cnt = 0;

	for (int i = 0; i < s.length(); i += w) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}


template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
	ModInt pow(long long n){
		ModInt r=1,x2=x;
    	while(n){
    		r*=((n%2)?x2:1);
    		x2*=x2;
    		n>>=1;
    	}
    	return r;
	}
};
typedef ModInt<998244353> mint;

vector<mint> fact, factinv;
void nCr_computeFactinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	reg(i, 1, N) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for (int i = N; i >= 1; i --) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if (n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}
mint nPr(int n, int r) {
	if (r<0)return 0;
	return r > n ? 0 : fact[n] * factinv[n-r];
}
mint nHr(int n, int r) { return r == 0 ? 1 : nCr(n + r - 1, r); }

ll modpow(__int128_t a, ll n,ll mo) {
	__int128_t r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

/*
*/

ll n,m,k;
mint ans;


int main(void){
	cin>>n>>m>>k;
	nCr_computeFactinv(n);
	rep(i,k+1)ans += nCr(n-1,i)*m*modpow(m-1,n-1-i,998244353);
	cout<<ans.get()<<endl;
	return 0;
}

Measured memory_bytes: 4848
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

object Solve {

  private val br = BufferedReader(InputStreamReader(System.`in`))
  private val out = PrintWriter(System.out)

  fun solve() {

    val (d, t, s) = br.readLine()!!.split(' ').map { it.toInt() }

    out.println(if(d <= t * s) "Yes" else "No")
    out.flush()
  }
}

fun main(args: Array<String>) {
  Solve.solve()
}

Measured memory_bytes: 36428
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const double pi= 3.1415926535897932384626; 

int main(){
    double R;
    cin>>R;
    cout<<2*pi*R<<endl;
}


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

int findDigits(int num)
{
    int digit = 0;
    while(num > 0)
    {
        num /= 10;
        digit++;
    }
    return digit;
}


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

    int num_test = sqrt(N);

    int ans = findDigits(N);
    int digit;
    for (int i = 1; i < num_test + 1; i++)
    {
        if (N % i == 0)
        {
            digit = findDigits(N / i);
             if (digit < ans)
             {
                 ans = digit;
             }
        }
    }

    cout << digit << endl;
    
    return 0;
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int count = 0;
  int mcount=0;
  int num=0;
  for(int i=1;i<=n;i++){
    int k=i;
    count = 0;
    for(;;){
     if(k%2!=0)break;
      k = k / 2;
      count ++;
    }
    if(mcount <= count) num = i;
    mcount = max(mcount , count);
  }  
  cout << num << endl;
}

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

int main(){
	int64_t A, B;
	int K;
	cin >> A >> B >> K;

	rep(i, K){
		if (A + i > B) return 0;
		cout << A + i << endl;
	}
	for(int i = K - 1; i >= 0; i--){
		if (B - i < A + K) continue;
		cout << B - i << endl;
	}
}

Measured memory_bytes: 256
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s, n, node):
    # 頂点が探索済みかどうかのチェック配列
    check = [False for _ in range(n)]
    check[s] = True
    # 次見る頂点を格納するキュー
    queue = deque([s])
    visited_num = 1

    # 問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color = [-1 for _ in range(n)]
    color[s] = 0

    while visited_num < n:
        # グラフが全連結ではない場合
        if len(queue) == 0:
            # 空配列を返す
            # 現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex = queue.popleft()
        # インデックスがない場合は
        for next_vertex in node[now_vertex]:

            if check[next_vertex] == True:
                continue

            queue.append(next_vertex)
            check[next_vertex] = True

            # 問題固有の計算
            color[next_vertex] = color[now_vertex]+1
            visited_num += 1

    return color


mod = 10**9+7
# n=int(input())
# n,m=list(map(int,input().split()))
# a=list(map(int,input().split()))
def ceil(x, y): return (x+y-1)//y
def input_list(): return list(map(int, input().split()))


n = int(input())
s = input()
w = s.count("W")
#print(s[w*-1:])
print(w-s[w*-1:].count("W"))


Measured memory_bytes: 9808
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
int main(){
  char W[101];
  scanf("%s",W);
  int l=strlen(W);
  for(int i=0;i<l;i++){
    if(W[i]!='#'){
      int j=i;
      while(1){
        if(W[++j]==W[i]){
          W[j]='#';W[i]='#';break;
        }
        if(j==l){
          printf("No\n");return 0;
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = -1;
    int max2 = -1;
    int maxi = -1;
    for (int i = 0; i < N; i++) {
    	int a = sc.nextInt();
    	if (a > max) {
    		max2 = max;
    		max = a;
    		maxi = i;
    	} else 	if (a > max2) {
    		max2 = a;
    	}
    }
    for (int i = 0; i < N; i++) {
    	System.out.println(i == maxi ? max2 : max);
    }
  }
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll a,b,c; cin >> a >> b >> c;
    ll k; cin >> k;
    // c > b > aになればいい
    rep(i,k){
        if(b <= a)b*=2;
        else if(c <= b)c*=2;
        else c*=2;
    }
    if(c > b && b > a)out("Yes");
    else out("No");
}

Measured memory_bytes: 3652
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int n;
  scanf("%d", &n);

  vector<vector<pii>> G(n, vector<pii>());
  for (int i = 0; i < n; i++) {
    int u, k, v, c;
    scanf("%d %d", &u, &k);
    for (int j = 0; j < k; j++) {
      scanf("%d %d", &v, &c);
      G[u].pb(pii(v, c));
    }
  }

  vi d(n, INF);
  vector<bool> visited(n, false);
  int vc = 0;
  priority_queue<pii, vector<pii>, greater<pii>> q;

  d[0] = 0;
  visited[0] = true;
  vc = 1;
  q.push(pii(0, 0));
  
  while(!q.empty()) {
    pii p = q.top(); q.pop();
    int u = p.second;

    if (d[u] < p.first) continue;

    visited[u] = true;
    for (auto e:G[u]) {
      int v = e.first;
      int c = e.second;
      if (!visited[v] && (d[u] + c < d[v])) {
        d[v] = d[u] + c;
        q.push(pii(d[v], v));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];

  ll ans = 0;
  for(int i=0;i<N;i++){
    ans=gcd(A[i],ans);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        
        char a[] = sc.nextLine().toCharArray();
        for(char b : a){
            
            System.out.print(Character.toUpperCase(b));
            
        }
    System.out.println();
    }
}



Measured memory_bytes: 26008
import java.util.Scanner;

//Cleaning Robot
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int x = sc.next().charAt(0)-'A';
			int si = x/3;
			int sj = x%3;
			x = sc.next().charAt(0)-'A';
			int gi = x/3;
			int gj = x%3;
			x = sc.next().charAt(0)-'A';
			int pi = x/3;
			int pj = x%3;
			double[][][] ex = new double[3][3][n+1];
			ex[si][sj][0] = 1;
			for(int k=1;k<=n;k++){
				for(int i=0;i<3;i++){
					for(int j=0;j<3;j++){
						for(int d=0;d<4;d++){
							int ni = i+move[d][0];
							int nj = j+move[d][1];
							if(0<=ni&&ni<3&&0<=nj&&nj<3&&!(ni==pi&&nj==pj)){
								ex[ni][nj][k] += 0.25*ex[i][j][k-1];
							}
							else{
								ex[i][j][k] += 0.25*ex[i][j][k-1];
							}
						}
					}
				}
			}
			System.out.printf("%.8f\n", ex[gi][gj][n]);
		}
	}
}

Measured memory_bytes: 12000