akhauriyash/Code-Regression huggingface dataset:
num = gets.chomp.split(" ").map(&:to_i)
maisu = num[0]
money = num[1] / 1000
found = false
i = money % 5
while i <= maisu
    j = ((money - i) % 10) / 5
    while j <= maisu - i
        k = maisu - i - j
        if (money - i - 5 * j) / 10 == k
            puts "#{k} #{j} #{i}"
            found = true
            break
        end
        j += 2
    end
    if found
        break
    end
    i += 5
end

if !found
    puts "-1 -1 -1"
end

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

int main () {

  int N, K;
  cin >> N >> K;

  int A[100000];
  int pos;
  for (int i=0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 1) {
      pos = i;
    }
  }

  // int before, after;                                                                      
  // before = (pos + K - 2) / (K - 1);                                                       
  // after = (N-1 - pos + K - 2) / (K - 1);                                                  


  // cout << before << endl;                                                                 
  // cout << after << endl;                                                                  
  cout << (N + K - 3) / (K - 1) << endl;

  return 0;
}


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

int main(){
  int N;
  int a=9,b=900,c=90000;
  int d;
  int n=0;
  int i=1;
  
  cin >> N;
  n = N;

  while(n > 9){
    n = n/10;
    i++;       //桁がわかる
  }

  if(i == 6){
    d = a + b + c;
  }    
  if(i == 4){
    d = a + b; 
  }
  if(i == 2){
    d = a;
  }
  if(i == 5){
    d = a + b + (N-10000+1);
  }
  if(i == 3){
    d = a + (N-100+1); 
  }
  if(i == 1){
    d = N;
  }
  
  cout << d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
typedef long long ll; const int inf=2e9;
typedef double lf; const lf err=1e-7;
typedef pair<int,int> pii;
#define repeat(i,a,b) for(int i=(a),iE=(b);i<iE;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,iE=(a);i>=iE;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define Clear(a) {a=decltype(a)();}
#define qwq {cerr<<"qwq"<<endl;}
#define orz(x) {cerr<<#x": "<<x<<endl;}
ll read(){ll n; scanf("%lld",&n); return n;}
const int N=2010;
const int mod=1e9+7;
#define int ll
int n;
int side(int x,int y){
	int ans=0;
	if(x==y && x<=n)ans++;
	for(int j=10;j<1000000;j*=10){
		int a=x*j+y;
		int b=x*j+j-10+y;
		if(a>n)continue;
		if(b>n){
			b=n;
			while(b%10!=y)b--;
		}
		if(a<=b)ans+=(b-a)/10+1;
	}
	return ans;
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int ans=0; cin>>n;
	repeat(i,1,10)
	repeat(j,1,10)
		ans+=side(i,j)*side(j,i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   ll l,r;cin>>l>>r;
   vector<ll> v;
   ll ans=2020;
   for(ll i=l;i<=min(r,2019+l);i++)v.push_back(i%2019);
   int n=v.size();
   for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
       ans=min(ans,v[i]*v[j] %2019);
   }
   cout<<ans;
}

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

#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const long long int infLL = 9000000000000000000;

#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937

const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;

#define MOD 1000000007

typedef long long ll;
const int mx=2e5+125;

ll pr[mx],ar[mx],br[mx];

#define PB push_back
#define endl '\n'
#define S second
#define F first

int main()
{
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;

    return 0;
}


Measured memory_bytes: 3580
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (int A, int B) = Slice2<int>();
            WriteLine((A + B) % 24);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27520
D, G = map(int, input().split())
p, c = list(zip(*[list(map(int, input().split())) for _ in range(D)]))

ans = sum(p)
for i in range(2 ** D):
    complete_indexes = [j for j in range(D) if (i >> j) & 1]

    question = 0
    point = 0
    for j in complete_indexes:
        question += p[j]
        point += p[j] * 100 * (j + 1) + c[j]

    if point < G:
        incomplete_indexes = [j for j in range(D) if j not in complete_indexes]
        if incomplete_indexes:
            index = incomplete_indexes[-1]
            required_question = (G - point + 100 * (index + 1) - 1) // (100 * (index + 1))
            question += min(required_question, p[index])
            point += min(required_question, p[index]) * 100 * (index + 1)

    if G <= point and question < ans:
        ans = question

print(ans)


Measured memory_bytes: 74468
use std::io;

fn main() {
    let vs = parse_values::<usize>(3);
    let n = vs[0];
    let a = vs[1];
    let b = vs[2];
    let loop_count = n / (a + b);
    let remain = n % (a + b);
    let remain_a = if a < remain { a } else { remain };
    println!("{}", loop_count * a + remain_a);
}

/// Parse line from io::stdin into T Value
fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

/// Parse whitespace split into T values from io::stdin
fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}

Measured memory_bytes: 4352
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,v,u,x,y,t,p,j;
ll a[205][205],f[405][205][205];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)cin>>a[i][j];
	for(i=1;i<=n+m-1;i++)
	{
		for(x=1;x<=n;x++)
		{
			for(y=1;y<=n;y++)
			{
				v=i-x+1,u=i-y+1;
				if(v<=0 || u<=0)continue;
				//cout<<x<<" "<<v<<" "<<y<<" "<<u<<endl;
				for(t=-1;t<1;t++)
				{
					for(p=-1;p<1;p++)
					{
						f[i][x][y]=max(f[i][x][y],f[i-1][x+t][y+p]);
					}
				}
				f[i][x][y]+=a[x][v]+a[y][u];
				if(x==y && v==u)f[i][x][y]-=a[x][v];
			}
		}
	}
	cout<<f[n+m-1][n][n]<<endl;
    return 0;
}

Measured memory_bytes: 131584
use std::cell::Cell;

const MOD: i32 = 1000000007;

fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut edges = vec![vec![]; n];
	for _ in 0..n - 1 {
		let a = s.next().unwrap().parse::<u32>().unwrap() - 1;
		let b = s.next().unwrap().parse::<u32>().unwrap() - 1;
		edges[a as usize].push(b);
		edges[b as usize].push(a);
	}
	let tree = Tree::new(edges);
	tree.dfs();
	let y = tree.calc();
	let x = mod_pow(tree.two_power[n] as i64, MOD as u32 - 2, MOD as i64);
	println!("{}", y as i64 * x % MOD as i64);
}

struct Tree {
	edges: Vec<Vec<u32>>,
	children: Vec<Cell<u32>>,
	parent: Vec<Cell<u32>>,
	two_power: Vec<i32>,
}

impl Tree {
	fn new(edges: Vec<Vec<u32>>) -> Tree {
		let n = edges.len();
		let pow: Vec<_> = (0..n + 1)
			.scan(1, |s, _| {
				let a = *s;
				*s = a * 2 % MOD;
				Some(a)
			})
			.collect();
		Tree { edges: edges, children: vec![Cell::new(0); n], parent: vec![Cell::new(0); n], two_power: pow }
	}

	fn dfs(&self) {
		let mut q1 = vec![(0, std::u32::MAX)];
		let mut q2 = vec![];
		while let Some(p) = q1.pop() {
			q2.push(p);
			for e in self.edges[p.0 as usize].iter() {
				if *e == p.1 {
					continue;
				}
				q1.push((*e, p.0));
			}
		}
		while let Some(p) = q2.pop() {
			let mut c = 0;
			self.parent[p.0 as usize].set(p.1 as u32);
			for e in self.edges[p.0 as usize].iter() {
				if *e == p.1 {
					continue;
				}
				c += self.children[*e as usize].get() + 1;
			}
			self.children[p.0 as usize].set(c);
		}
	}

	fn calc(&self) -> i32 {
		let n = self.edges.len();
		let mut r = 0;
		for i in 0..n {
			let mut csum = 0;
			let mut pat = 0;
			for e in self.edges[i].iter() {
				if *e == self.parent[i].get() {
					continue;
				}
				let c = self.children[*e as usize].get() + 1;
				pat = (pat + self.two_power[c as usize] - 1) % MOD;
				csum += c;
			}
			pat = (pat + self.two_power[n - 1 - csum as usize] - 1 + 1) % MOD;
			pat = (self.two_power[n - 1] + MOD - pat) % MOD;
			r = (r + pat) % MOD;
		}
		r
	}
}

fn mod_pow(a: i64, n: u32, m: i64) -> i64 {
	let mut r = 1;
	let mut a = a;
	let mut n = n;
	while n > 0 {
		if n & 1 != 0 {
			r = r * a % m;
		}
		a = a * a % m;
		n >>= 1;
	}
	r
}


Measured memory_bytes: 28916
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<vector<int>> a(n, vector<int>(n));

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

    using ll = long long;
    const ll mod = 1000000007;

    vector<ll> dp(1 << n);

    dp[0] = 1;

    for (int j = 0; j < (1 << n); j++) {
        int i = 0;
        for (int k = 0; k < n; k++) {
            if (j >> k & 1) {
                i++;
            }
        }

        if (i == n) {
            break;
        }

        for (int k = 0; k < n; k++) {
            if (a[i][k] && !(j >> k & 1)) {
                dp[j | (1 << k)] += dp[j];

                if (dp[j | (1 << k)] >= mod) {
                    dp[j | (1 << k)] -= mod;
                }
            }
        }
    }

    cout << dp[(1 << n) - 1] << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    ll n;
    cin >> n;
    VL a(n);
    rep(i,n) cin >> a[i];

    ll ans = 4000050;
    rep(i,201){
        ll x = i - 100, out = 0;
        rep(i,n){
            out += (a[i]-x)*(a[i]-x);
        }
        chmin(ans,out);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8

int a[N][N]={0};



void printboard(){
	int i,j;
	
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(a[i][j]==1)printf("Q");
			else printf(".");
		}
		printf("\n");
	}

	return;	
}


int check(int y,int x){
	int i,j;
	
	/*横*/
	for(i=0;i<N;i++){
		if(i!=x && a[y][i]==1)return 0;
	}
	/*縦*/
	for(i=0;i<N;i++){
		if(i!=y && a[i][x]==1)return 0;
	}
	/*右上*/
	i=y-1; j=x+1;
	while(i>=0 && j<N){
		if(a[i--][j++]==1)return 0;
	}
	/*左上*/
	i=y-1; j=x-1;
	while(i>=0 && j>=0){
		if(a[i--][j--]==1)return 0;
	}
	/*左下*/
	i=y+1; j=x-1;
	while(i<N && j>=0){
		if(a[i++][j--]==1)return 0;
	}
	/*右下*/
	i=y+1; j=x+1;
	while(i<N && j<N){
		if(a[i++][j++]==1)return 0;
	}
	
	return 1;
	
}


int Get_Solution(int d){
	int i;
	
	for(i=0;i<N;i++){
		if(a[d][i]==1){
			if(!Get_Solution(d+1))return 0;
		}
	}
	

	if(d==N){
		printboard();
		return 1;
	}
	
	else {
		for(i=0;i<N;i++){
			if(a[d][i]==0 && check(d,i)){
				a[d][i]=1;
				if(!Get_Solution(d+1)){
					a[d][i]=0;
				}
			}
		}
	}
	
	
	return 0;

}

int main(){
	int n,i,j;
	int x,y;
	int d=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d",&y,&x);
		a[y][x]=1;
	/*	update(y,x);*/
	}
	
	i=Get_Solution(d);

	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, K[15], S[15][15], P[15], ans;
int now[15];

int Solve(int num){
  for (int i = 1; i <= N; i++){
    now[i] = num % 2; num /= 2;
  }

  for (int i = 1; i <= M; i++){
    int cnt = 0;
    for (int j = 0; j < K[i]; j++){
      if (now[S[i][j]]) cnt++;
    }
    if (cnt % 2 != P[i]) return 0;
  }

  ans++;
  return 0;
}

int main(){
  cin >> N >> M;
  for (int i = 1; i <= M; i++){
    cin >> K[i];
    for (int j = 0; j < K[i]; j++){
      cin >> S[i][j];
    }
  }
  for (int i = 1; i <= M; i++) cin >> P[i];
  for (int i = 0; i < (1<<N); i++) Solve(i);
  cout << ans << endl;

  return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    if (s[0] == t[2] and s[1] == t[1] and s[2] == t[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 310

const int mod = 1e9 + 7;

int L[NR][4], R[NR][4], n, m, f[NR][NR][NR];

bool valid(int i, int j, int k) {
	if (i > j) swap(i, j);
	if (j > k) swap(j, k);
	if (i > j) swap(i, j);

	if (k == 0) return true;

	return j + 1 <= L[k][1] &&
		i + 1 <= L[k][2] && R[k][2] <= j && 
		R[k][3] <= i;
}

int dfs(int i, int j, int k) {
//	printf("!%d %d %d\n", i, j, k);
	if (!valid(i, j, k)) return 0;
	int &w = f[i][j][k];
	if (w != -1) return w;
	int s = max(i, max(j, k));
	if (s == n) return 1;
	w = (0ll + dfs(s + 1, j, k) + dfs(i, s + 1, k) + dfs(i, j, s + 1)) % mod;
	return w;
}

int main() {
	memset(f, -1, sizeof(f));
	scanf("%d%d", &n, &m);
	iter(i, n) iter(j, 3) L[i][j] = n;
	iter(i, m) {
		int l, r, x;
		scanf("%d%d%d", &l, &r, &x);
		L[r][x] = min(L[r][x], l);
		R[r][x] = max(R[r][x], l);
	}
	printf("%d\n", dfs(0, 0, 0));
	return 0;
}


Measured memory_bytes: 116736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define reg register
#define maxn 200005
inline ll read(){
	reg ll x=0,w=0;reg char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n;
ll a[maxn],k;
inline ll tran(ll x,ll y){
	if(x<0)
	{
		x=-x,y=-y;
		return (x-1)/y+1;
	}
	return x/y;
}
inline ll calc(ll x){
	reg int i;reg ll res=0,tmp;
	for(i=1;i<n;++i){
		if(a[i]<0){
			tmp=a+1+n-lower_bound(a+i+1,a+1+n,tran(x,a[i]));
			res+=tmp;
		}
		else if(a[i]>0){
			tmp=upper_bound(a+i+1,a+1+n,x/a[i])-a-i-1;
			res+=tmp;
		}
		else {
			if(x>=0)res+=n-i;
		}
	}
	return res;
}
int main()
{
	n=read();k=read();reg int i;
	for(i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+1+n);
	reg ll mid,l=-1e18,r=1e18;--l; 
	while(l<r-1){
		mid=(l+r)>>1;
		if(calc(mid)>=k)r=mid;
		else l=mid;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int a, b, c;
   cin >> a >> b >> c;
   if (a + b + c >= 22)
      cout << "bust" << endl;
   else
      cout << "win" << endl;
   return 0;
}

Measured memory_bytes: 3636
import itertools

n, m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))

light = [0 for i in range(n)]

ans = 0
for x in itertools.product(range(2), repeat=n):
    flag = 0
    for i in range(m):
        now = 0
        for j in range(1, len(ks[i])):
            #print(ks[i][j]-1)
            if x[ks[i][j]-1] == 1:
                now += 1
        #print(now)
        #print(x, p[i], now % 2,ks[i])
        if now % 2 != p[i]:
            flag = 1
            #break
    #print(flag)
    #print('')
    if flag == 0:
        ans += 1
        
print(ans)

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
int n; cin>>n;
	while (n--) {
      int x; cin>>x;
      if (x%2==0) {
        if (x%3!=0 && x%5!=0) out("DENIED");
      }
    }
  out("APPROVED");
  
  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b, c = [], []
smap = {}
sum_ = sum(a)

for i in range(q):
    bt, ct = map(int, input().split())
    b.append(bt)
    c.append(ct)

for aa in a:
    smap[aa] = smap.get(aa, 0) + 1

# print(smap)

for i in range(q):

    try:
        count = smap[b[i]]
        diff = (c[i] - b[i]) * count
        smap[c[i]] = smap.get(c[i], 0) + count
        del smap[b[i]]
        sum_ += diff
        # print(diff)
    except KeyError:
        pass

    print(sum_)
    # print(smap)


Measured memory_bytes: 96924
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>

using namespace std;

const int maxN = 100010;
const long long oo = 1000000000000ll;

#define foru(i, l, r) for (int i = l; i <= r; ++i)
#define ford(i, r, l) for (int i = r; i >= l; --i)
#define repu(i, r) for (int i = 0; i < r; ++i)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pint pair < ll, int >

ll n, m;

int main() {
    cin >> n >> m;
    if ((ll) abs(m - n) > 1) cout << "Alice";
    else cout << "Brown";
}


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    char ch;
    cin >> ch;
    if(ch>='A' and ch<='Z')
        cout << 'A';
    else 
        cout << 'a';
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 2000005

ll n , m , k , x;
ll a[MAXX];

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

int main()
{
    _FastIO;

    cin >> n >> m >> k;
    multiset<pair<ll , ll> > b;
    multiset<pair<ll , ll> >::iterator it;
    b.insert({0 , 0});
    for(ll i = 1; i <= n; i++){
        cin >> x;
        a[i] = a[i - 1] + x;
    }
    ll y = 0;
    for(ll i = 1; i <= m; i++){
        cin >> x;
        y += x;
        b.insert({y , i});
    }
    ll ans = 0;
    for(ll i = 0; i <= n; i++){
        if(a[i] > k)
            break;
        if(a[i] == k)
            ans = max(ans , i);
        else{
            it = b.lower_bound({(k - a[i]) , m});
            y = (*it).first;
            while(y > (k - a[i])){
                it--;
                y = (*it).first;
            }
            ll j = (*it).second;
            ans = max(ans , i + j);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17732
#![allow(unused_imports)]
#[macro_use]
mod reader {
    // mod calc;

    // use calc::*;


    #![allow(dead_code)]
    use std;
    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);
    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }
}
#[macro_use]
mod misc {
    #![allow(dead_code)]
    use std;
    #[macro_export]
    macro_rules! bind_from_vec((
                               $ ( $ variable : ident ) , + = $ vector : expr
                               ) => {
                               let mut v = $ vector . clone (  ) . into_iter (
                                ) ; $ (
                               let $ variable = v . next (  ) . unwrap (  ) ;
                               ) + } ;);

}
use reader::*;
use misc::*;
fn main() {
    bind_from_vec!(a , b = read_to_vec :: < i32 > (  ));
    println!("{}" , if a >= 13 { b } else if a >= 6 { b / 2 } else { 0 });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int LOG=20;
int l,n,m,u[1005],v[1005],w[1005];
int main(){
    scanf("%d",&l);
    for(int i=0;i<=LOG;i++)
        if((1<<i)>l){
            n=i;
            break;
        }
    for(int i=1;i<n;i++){
        u[++m]=i,v[m]=i+1,w[m]=0;
        u[++m]=i,v[m]=i+1,w[m]=1<<(i-1);
    }
    int t=1<<(n-1);
    l-=t;
    for(int i=n-1;i;i--)
        if((1<<(i-1))<=l){
            u[++m]=i,v[m]=n,w[m]=t;
            t+=1<<(i-1);
            l-=1<<(i-1);
        }
    printf("%d %d\n",n,m);
    for(int i=1;i<=m;i++)
        printf("%d %d %d\n",u[i],v[i],w[i]);
    return 0;
}

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

int main(void) {
  int i, j, ans = 0;
  char s[210];
  scanf("%s", s);
  for(i = 0; i < strlen(s) / 2; ++i) {
    char t = 1;
    for(j = 0; j < i; ++j) if(s[j] != s[i + j]) t = 0;
    if(t) ans = i * 2;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	var last = IntArray(3){scn.nextInt()}
	repeat(n-1){
		val hps = IntArray(3){scn.nextInt()}
		last = IntArray(3){l ->
			val i = mutableListOf(0,1,2)
			i.removeAt(l)
			return@IntArray i.map{ last[it] }.max()!!+hps[l]
		}
	}
	print(last.max())
}

Measured memory_bytes: 110476
N = int(input())
A_list = [int(input()) for i in range(N)]

sorted_A_list = sorted(A_list)

for i, item in enumerate(A_list):
  if item != sorted_A_list[-1]:
    print(sorted_A_list[-1])
  else:
    print(sorted_A_list[-2])
  

Measured memory_bytes: 14112
#include <stdio.h>
int main(void){
  int n,i,j,c;
  while(scanf("%d",&n)!=EOF){
    int a[n+1];
    c=0;
    for(i=2;i<=n;i++)
      a[i]=i;
    for(i=2;i<=n;i++){
      if(a[i]){
	for(j=2*i;j<=n;j+=i){
	  if(a[j]%a[i]==0)
	    a[j]=0;
	}
      }
    }
    for(i=2;i<=n;i++){
      if(a[i])
	c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <tuple>
#include <climits>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <numeric>
#include <fstream>
#include <map>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <array>
#include <chrono>

using namespace std;

int main()
{
    uint64_t a, b, x;
    cin >> a >> b >> x;
    if(a % x != 0)
        a += x - (a % x);
    if(a >= b) {
        if(b % x == 0) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    cout << 1 + ((b-a) / x) << endl;
}


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

int main(){
    vector<int>v(4);
    for(auto& e : v) cin >> e;
    int ans = 1e9;
    sort(v.begin(),v.end());
    do{
        ans = min(ans,abs((v[0] + v[1]) - (v[2] + v[3])));
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,len; cin>>n>>len;
	string s[n];
	for(int i=0;i<n;i++) cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++) cout<<s[i];
	
	
	
	return 0;
}


Measured memory_bytes: 256
# [A,B) + [B,C)の中で過半数なら、どっちかで過半数
# 長さ3以下の区間に帰着できる
# 'xx' or 'xyx'

txt = input()
L = len(txt)

def solve():
  for i in range(L-1):
    if txt[i] == txt[i+1]:
      return ' '.join([str(x) for x in [i+1,i+2]])
  for i in range(L-2):
    if txt[i] == txt[i+2]:
      return ' '.join([str(x) for x in [i+1,i+3]])
  return '-1 -1'

ans = solve()
print(ans)


Measured memory_bytes: 3188
A,B,C,D=map(int,input().split())
if B<C or D<A:
    print(0)
elif D>=B and A>=C:
    print(B-A)
elif D>B:
    print(B-C)
elif B>=D and C>=A:
    print(D-C)
else:
    print(D-A)

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n,k;
  cin >> n >> k;
  
  cout << 1 + (n-k+k-2)/(k-1) << endl;
  // 1 + (n-k)/(k-1)
  //  切り上げるので(n-k+k-2)
         
  return 0;
}



Measured memory_bytes: 3676
i,s[60],n,f,g;main(){while(~scanf("%d",s+n++));for(n--;i<n;printf("%d\n",f),i++,f=0){for(int a=0;a<10;a++){for(int b=0;b<10;b++){for(int c=0;c<10;g=s[i]-a-b-c++,g>-1&&g<10?f++:0);}}}exit(0);}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b == c || b+c == a || c+a == b) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

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); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s, t;
    cin >> s >> t;
    const ll n = s.size(), m = t.size();

    vector<ll> last(26, LLINF);
    vector<vector<ll>> nxt(n);
    for(ll i=2*n-1; i>=0; --i) {
        REP(j, 26) last[j]++;
        last[s[i%n]-'a'] = 0;
        if(i < n) nxt[i] = last;
    }

    // REP(i, n) cout << nxt[i] << endl;

    ll idx = 0;
    REP(i, m) {
        if(nxt[idx%n][t[i]-'a'] >= LLINF) {
            cout << -1 << endl;
            return 0;
        }
        idx += nxt[idx%n][t[i]-'a'] + 1;
        // cout << i << " " << idx << endl;
    }
    cout << idx << endl;

    return 0;
}


Measured memory_bytes: 24656
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    ll ans=power(10,n,hell);
    ll v=power(9,n,hell);
    ans-=v;
    ans+=hell;
    ans%=hell;
    ans-=v;
    ans+=hell;
    ans%=hell;
    ans+=power(8,n,hell);
    cout<<ans%hell;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	int N;
	cin >> N;
	int ans = 0;
	int index = -1;

	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if(a>index){
			index = a;
			ans = a + b;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#068_C
n,m=map(int,input().split())
s1=set()
sn=set()
for _ in range(m):
    a,b=map(int,input().split())
    if a==1:
        s1.add(b)
    if b==n:
        sn.add(a)
print('POSSIBLE' if len(s1&sn) else 'IMPOSSIBLE')

Measured memory_bytes: 19024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 105
//---------------------

bool l[MAXN];
ll n;
int main(){
	ZERO(l);
	REP1(i,9) REP1(j,9) l[i*j] = true;
	cin>> n;
	YNPRT(l[n]);
	return 0;
}









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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  char str[100005];
  scanf("%s", str);

  int a = 0;
  for (int i = 1; i < n; ++i) {
    if (str[i] == str[i - 1]) {
      a += 1;
    }
  }
  cout << min(n - 1, a + 2 * k) << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll a=0;
  FOR(i,0,10000000000){
    a++;
  }
  co(3*n*n)
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  ll x,y;
  cin >> x >> y;
  bitset<32> b(x),c(y);
  cout << (b&c) << endl;
  cout << (b|c) << endl;
  cout << (b^c) << endl;
}



Measured memory_bytes: 3148
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define mod 1000000007 //1e9+7
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,n,k,ans,cnt=0;
    string s;
    cin>>n>>k;
    ll a[n];
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(a[i]>a[j])
                cnt++;
        }
    }
    ans=cnt*(k%mod);
    cnt=0;
    for(i=0; i<n; i++)
    for(j=0; j<n; j++)
            if(a[i]>a[j])
                cnt++;

      k=(k*(k-1)/2%mod);
    ans+=cnt%mod*k;
    cout<<ans%mod<<endl;
    return 0;
}





Measured memory_bytes: 3632
package main

import(
	"fmt"
)

var a, b, c, d int

func main() {
	fmt.Scan(&a, &b, &c, &d)

	for true {
		c -= b
		if c <= 0 {
			fmt.Println("Yes");
			return
		}
		a -= d
		if a <= 0 {
			fmt.Println("No");
			return
		}
	}
}

Measured memory_bytes: 1756
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int dp[100010];

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

	vector<int> nums(1, 1);

	for (int i = 6; i <= n; i *= 6)
	{
		nums.push_back(i);
	}
	for (int i = 9; i <= n; i *= 9)
	{
		nums.push_back(i);
	}

	sort(ASC(nums));

	for (int i = 0; i < 100010; i++) dp[i] = inf;

	dp[0] = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < nums.size(); j++)
		{
			if (i - nums[j] < 0) continue;

			chmin(dp[i], dp[i - nums[j]] + 1);
		}
	}

	//for (int i = 0; i <= n; i++) cout << dp[i] << " ";

	cout << dp[n] << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll cost(int i, int s, VL &a){
	if(s==0||s==4) return a[i];
	else if(s==1||s==3){
		if(a[i]%2==0&&a[i]>0) return 0LL;
		else if(a[i]>0) return 1LL;
		else return 2LL;
	}else{
		if(a[i]%2LL==0LL) return 1LL;
		else return 0LL;
	}
}

signed main() {
	ll n; cin>>n;
	VL a(n); rep(i,n)cin>>a[i];
	ll dp[n+1][5];
	rep(i,n+1)rep(j,5) dp[i][j]=LINF;
	dp[0][0]=0LL;

	rep(i,n){
		rep(j,5){
			for(int k=j; k<5; k++){
				chmin(dp[i+1][k], dp[i][j]+cost(i,k,a));
			}
		}
	}
	ll ans=LINF;
	rep(j,5) chmin(ans,dp[n][j]);
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    REP(i,b) cout<<a;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
h,w,i=0,0,0
while i<n-1:
    if a[i]==a[i+1]:
        if h==0:
            h=a[i]
            i+=1 #
        else:
            w=a[i]
            break
    i+=1
print(h*w)

Measured memory_bytes: 14252