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

const int MAXV = 1000010, MAXE = 1000010;

struct edge { int u, v, weight, next; } g[MAXE];

int n, q;
int head[MAXV], idx;
bool visited[MAXV];

long long cnt[MAXV];

void dfs(int u){
    for (int j = head[u]; ~j; j = g[j].next) {
        if (!visited[g[j].v]) {
            cnt[g[j].v] += cnt[u];
            visited[g[j].v] = true;
            dfs(g[j].v);
        }
    }
}

int main(int argc, char *argv[])
{
   
    cin.tie(0);
    ios::sync_with_stdio(false);

    idx = 0;
    memset(head, -1, sizeof(head));
    memset(cnt, 0, sizeof(cnt));
    memset(visited, false, sizeof(visited));
    
    cin >> n >> q;

    for (int i = 1, u, v; i < n; i++)
    {
        cin >> u >> v;
        
        g[idx] = edge{u, v, 0, head[u]};
        head[u] = idx++;
        
        g[idx] = edge{v, u, 0, head[v]};
        head[v] = idx++;
        
    }
    
    for (int i = 0, u; i < q; i++) {
        long long delta;
        cin >> u >> delta;
        cnt[u] += delta;
    }
    visited[1] = true;
    dfs(1);

    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 31900
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

typedef long long ll;

long long gcd(long long a, long long b){
  if(b > a){
    long long c = a;
    a = b;
    b = c;
  }
  while(b != 0){
    long long c = b;
    b = a%b;
    a = c;
  }
  return a;
}

int main(){
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  a--;
  long long g = gcd(c, d);
  g = lldiv(c*d,g).quot;
  long long invb = lldiv(b,c).quot + lldiv(b,d).quot;
  long long inva = lldiv(a,c).quot + lldiv(a,d).quot;
  invb -=  lldiv(b,g).quot;
  inva -= lldiv(a,g).quot;
  cout << b-a - (invb - inva) << endl;
}


Measured memory_bytes: 256
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

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

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


const int NM = 1000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int B[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//double Perf[NM];

ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program


struct Info
{
    int A;
    int B;
    double Perf;

    bool operator<(const Info& another) const
    {
        return Perf == another.Perf ? A < another.A : Perf < another.Perf;//年齢を比較
    };
    //2つのconstを付けないとコンパイルエラーになるので注意!!
};


void solve() {
    ll  N,K;
    cin >> N >> K;
	ll cnt;
  
  while(1){
  	N/=K;
    cnt++;
    if(N==0){
    	break;
    }
  }
  cout << cnt;
    return;

}



int main() {
    solve();
    return 0;
}








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

int main(){
    int a,b,C;
    double S,L,h,s,c,Cr,Pi;
    cin >> a>>b>>C;
    
    Pi = acos(-1);
    Cr = Pi*C / 180;

    s = sin(Cr);
    
    S = a * b * s/2;
    c = sqrt(a*a + b*b - 2*a*b*cos(Cr));
    L = a + b + c;
    h = 2 * S / a;
    
    printf("%5f",S);
    cout << endl;
    printf("%5f",L);
    cout << endl;
    printf("%5f",h);
    cout << endl;
    
    return 0;
    
    
    
    
}


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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h,w, d, q;
	cin >>h >>w >>d;
	VI ps(h*w+10);
	rep(i,h) rep(j,w){
		int a; cin >> a;
		ps[a] = i*w + j;
	}
	cin >>q;
	VI vl(q), vr(q);
	rep(i,q) cin >> vl[i] >>vr[i];

	
	vector<ll> cst(h*w+10);
	rep(i, d){
		int st = i ;
		for( ;st +d <= h*w; st+=d){
			int cy= ps[st]/w, cx=ps[st]%w;
			int ny= ps[st+d]/w, nx=ps[st+d]%w;
			cst[st+d] = cst[st] +abs(cy-ny)+abs(cx-nx);
		}
	}
	//for(auto x: cst ) cout << x <<" ";puts("");
	
	rep(g, q){
		cout << cst[vr[g]] - cst[vl[g]] <<"\n";
	}
	return 0;
	
}


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

int main() {
  int k, s;
  cin >> k >> s;
  
  int cnt = 0;
  
  for (int x=0;x<=k;x++){
    for (int y=0;y<=k;y++){
      if (s-x-y<=k&&s-x-y>=0) cnt++;
    }
  }
  
  cout << cnt << endl;
  
}


Measured memory_bytes: 256
using System;
using System.Reflection.Metadata.Ecma335;

namespace Minor
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int M_num = 0; 
            int N_num = 0;

            for (int i = 0; i < S.Length; i++)
            {
                if (S.Substring(i,1).Equals(T.Substring(i,1)))
                {
                M_num++;
                }
                else
                {
                    N_num++;
                }
            }
            Console.WriteLine(N_num);
        }
    }
}


Measured memory_bytes: 36852
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

class Binary_Indexed_Tree:
    #Binary_Indexed_Tree
    #A1 ... AnのBIT(1-indexed)
    def __init__(self,n):
        self.N = n
        self.BIT = [0]*(n+1)
        self.l2 = 2**(len(format(n,'b'))-1)

    #A1 ~ Aiまでの和 O(logN)
    def query(self,idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def update(self,idx,x):
        while idx <= self.N:
            self.BIT[idx] += x
            idx += idx&(-idx)
        return

    def lower_bound(self,w):
        if w <= 0:
            return 0
        x = 0
        k = self.l2
        while k > 0:
            if x+k <= self.N and self.BIT[x+k] < w:
                w -= self.BIT[x+k]
                x += k
            k //= 2
        return x+1

    def upper_bound(self,w):
        x = 0
        k = self.l2
        while k > 0:
            if x+k <= self.N and self.BIT[x+k] <= w:
                w -= self.BIT[x+k]
                x += k
            k //= 2
        return x

def main():
    n = int(ipt())
    ans = 0
    a = [int(i) for i in ipt().split()]
    pl = [-1]*(n+1)
    for i,ai in enumerate(a):
        pl[ai] = i+1

    bt = Binary_Indexed_Tree(n)

    for i in range(1,n+1):
        pi = pl[i]
        bi = bt.query(pl[i])
        lb = bt.lower_bound(bi)
        ub = bt.upper_bound(bi)
        ans += (pi-lb)*(ub-pi+1)*i
        bt.update(pi,1)

    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 101540
N,M = map(int, input().split())
Ss = list(map(int, input().split()))
Ts = list(map(int, input().split()))
mod = 10**9 + 7

x = 2160
dp = [[0]*x for i in range(x)]
sum2d = [[0]*x for i in range(x)]
for i in range(N):
    for j in range(M):
        if Ss[i] == Ts[j]:
            dp[i+1][j+1] = sum2d[i][j] + 1
        sum2d[i+1][j+1] = (dp[i+1][j+1]+sum2d[i][j+1]+sum2d[i+1][j]-sum2d[i][j])%mod
print((sum2d[N][M]+1)%mod)


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int ncr(int n,int r)
{
    int ans=1;
    for(int i=1;i<=r;++i)
    {
        ans = (((ans*n)%mod)*(powmod(i,mod-2)))%mod;
        n--;
    }
    return ans;
 
}
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int s;
		cin>>s;
		if(s<3)
		cout<<0;
		else
		{
			int ans = 0;
			for(int i=0;i<s;++i)
			{
				int res = s-3*(i+1);
				if(res<0)
				break;
				(ans+=ncr(res+i,res))%=mod;
			}
			cout<<ans;
		}		
    }
    return 0;
}


Measured memory_bytes: 3640
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn dfs(
    lv: &Vec<i32>,
    n: usize,
    a: i32,
    b: i32,
    c: i32,
    i: usize,
    m: i32,
    x: i32,
    y: i32,
    z: i32,
) -> i32 {
    if i == n {
        return if x == 0 || y == 0 || z == 0 {
            a + b + c // inf
        } else {
            m + (x - a).abs() + (y - b).abs() + (z - c).abs()
        };
    }
    return vec![
        dfs(lv, n, a, b, c, i + 1, m, x, y, z),
        dfs(
            lv,
            n,
            a,
            b,
            c,
            i + 1,
            m + if x == 0 { 0 } else { 10 },
            x + lv[i],
            y,
            z,
        ),
        dfs(
            lv,
            n,
            a,
            b,
            c,
            i + 1,
            m + if y == 0 { 0 } else { 10 },
            x,
            y + lv[i],
            z,
        ),
        dfs(
            lv,
            n,
            a,
            b,
            c,
            i + 1,
            m + if z == 0 { 0 } else { 10 },
            x,
            y,
            z + lv[i],
        ),
    ]
    .into_iter()
    .min()
    .unwrap();
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let c: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut lv = vec![0i32; n];
    for i in 0..n {
        lv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let ans = dfs(&lv, n, a, b, c, 0, 0, 0, 0, 0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> d(N);
    for (int& x : d) cin >> x;
    int res = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        res += d[i] * d[j];
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
dp = [1 for _ in range(n+2)]
for i in range(n):
	b = bisect(dp, -a[i])
	dp[b] = -a[i]
ans = 1
while dp[ans] <= 0:
	ans += 1
print(ans)

Measured memory_bytes: 11416
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC102_B();
        }

        static void ABC102_B()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(A.Max() - A.Min());
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner stdIn = new Scanner(System.in);
		
		String input = stdIn.next();
		if(input.indexOf("9") >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 23508
use std::io::stdin;

fn main() {
    let n: u64 = read().parse().unwrap();
    let a: u64 = read().parse().unwrap();
    let b: u64 = read().parse().unwrap();
    let c: u64 = read().parse().unwrap();
    let d: u64 = read().parse().unwrap();
    let e: u64 = read().parse().unwrap();
    
    let mut min = a;
    for v in &[a, b, c, d, e] {
        if *v < min {
            min = *v;
        }
    }
    
    let t = if n % min == 0 {
        n / min
    } else {
        n / min + 1
    };
    
    println!("{}", t + 4);
}

fn read() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

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

const int _ = 200007;

char s[_];

int main()
{
	fread(s,1,_,stdin);
	long long ans=0,cnta=0;
	for(int i=0;s[i];++i)(s[i]=='A')?(++cnta):((s[i]=='B' && s[i+1]=='C')?(ans+=cnta,++i):(cnta=0));
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 384
use std::cmp::*;
use std::io::*;

fn check(x: usize, mut n: usize) -> bool {
    while n % x == 0 {
        n /= x;
    }
    (n - 1) % x == 0
}

fn calc(n: usize) -> usize {
    let mut res = 1; // 1, n
    let mut i = 2;
    while i * i <= n {
        if n % i == 0 {
            res += check(i, n) as usize;
            if n / i != i {
                res += check(n / i, n) as usize;
            }
        }
        i += 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    let m = n - 1;
    let mut i = 2;
    if m > 1 {
        ans += 1;
    }
    while i * i <= m {
        if m % i == 0 {
            ans += 1;
            if m / i != i {
                ans += 1;
            }
        }
        i += 1;
    }
    println!("{}", calc(n) + ans);
}


Measured memory_bytes: 2060
#include <iostream>
#include <set>
int main(){
  int N;
  std::cin >> N;
  std::set<int> s;
  
  for(int i=0;i<N;++i){
    int size;
    std::cin >> size;
    s.insert(size);
  }
  std::cout << s.size();
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    sort(all(s));
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
macro p(z);:((x->parse(Int,x)).(split($z)));end
n=parse(Int,readline())
a=@p(readline())
b=@p(readline())
ans=0
for i=1:n
  if a[i]>=b[i];ans+=b[i]
  elseif b[i]>=a[i]+a[i+1]; ans+=a[i]+a[i+1];a[i+1]=0
  else a[i+1]-=b[i]-a[i]; ans+=b[i];end
end
print(ans)

Measured memory_bytes: 153296
n=int(input())
x=input()
one=x.count("1")
amari_m=0
amari_p=0
for i in range(n):
	if x[-i-1]=="1":
		amari_p+=pow(2,i,one+1)
		if one==1:
			amari_m=-1
		else:
			amari_m+=pow(2,i,one-1)
		amari_p%=one+1
		if one!=1:
			amari_m%=one-1
for i in range(n):
	cnt=0
	if x[i]=="1":
		if one==1:
			print(0)
			continue
		r=(amari_m-pow(2,(n-i-1),one-1))%(one-1)
	else:
		r=(amari_p+pow(2,(n-i-1),one+1))%(one+1)
	while r:
		r%=bin(r).count("1")
		cnt+=1
	print(cnt+1)


Measured memory_bytes: 79844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 
int Main(int X, int Y)
{
    if((X+Y)%3) return 0;
    int n, m;
    n = (2*X - Y) / 3;
    m = (2*Y - X) / 3;
    if(n < 0 || m < 0) return 0;
    combination c(n+m);
    return c(m+n, n).x;

}
 
int main(void){
    int X, Y;
    cin >> X >> Y;
    cout << Main(X, Y) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int n;
ll v[(1 << 16)];
int mat[16][16];
vector<int> m[(1 << 16)];

void get_masks(int idx, int mask, int a)
{
    if(idx == n){
      m[a].push_back(mask);
      return;
    }
    get_masks(idx + 1, mask, a);
    if(mask & (1 << idx))
    {
      get_masks(idx + 1, mask ^ (1 << idx), a);
    }
}

ll dp[(1 << 16)];
bool mark[(1 << 16)];
ll solve(int mask)
{
    if(mask == (1 << n) - 1)
      return 0;
    ll &ans = dp[mask];
    if(mark[mask])
      return ans;
    mark[mask] = 1;
    ans = -1e12;
    for(auto &x: m[mask])
    {
      ans = max(ans, solve(mask | x) + v[x]);
    }
    return ans;
}

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        cin >> mat[i][j];
    for(int i = 0; i < (1 << n); i++)
    {
      vector<int> p;
      for(int j = 0; j < 16; j++)
      {
        if(i & (1 << j))
          p.push_back(j);
      }
      ll val = 0;
      for(int k = 0; k < p.size(); k++)
        for(int z = k + 1; z < p.size(); z++)
          val += mat[p[k]][p[z]];
      int newMask = i;
      for(int j = 0; j < n; j++)
        newMask ^= (1 << j);
      get_masks(0, newMask, i);
      v[i] = val;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0);
}


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

const int mod = 998244353;

void Mod(ll& a) {
    a = (a % mod + mod) % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> v;
    for (ll i = 0;i < k;++i) {
        ll l, r;
        cin >> l >> r;
        v.push_back({ l,r });
    }
    vector<ll> dp(n, 0);
    dp[0] = 0;
    for (auto p : v) {
        dp[p.first] += 1;
        if (p.second + 1 < n) {
            dp[p.second + 1] -= 1;
        }
    }
    for (ll i = 1;i < n;++i) {
        dp[i] += dp[i - 1];
        Mod(dp[i]);
        for (auto p : v) {
            if (p.first + i < n) {
                dp[p.first + i] += dp[i];
                Mod(dp[p.first + i]);
                if (p.second + i + 1 < n) {
                    dp[p.second + i + 1] -= dp[i];
                    Mod(dp[p.second + i + 1]);
                }
            }
        }
    }
    cout << dp.back() << endl;
}

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

int main(){
	int x,N,K,Q;
	cin >> N >> K >> Q;
	int A[N];
	for(int i=0;i<N;i++){
		A[i]=K-Q;
	}
	for(int i=0;i<Q;i++){
		cin >> x;
		A[x-1]++;
	}
	for(int i=0;i<N;i++){
		if(A[i]>0){
			cout << "Yes" << endl;
		}else{
			cout <<"No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;
int cnt = 0;

int test(ll i)
{
    bool e7 = 0;
    bool e5 = 0;
    bool e3 = 0;
    while(i != 0)
    {
        if(i % 10 == 7)
        {
            e7 = 1;
        }
        else if(i % 10 == 5)
        {
            e5 = 1;
        }
        else if(i % 10 == 3)
        {
            e3 = 1;
        }
        else
        {
            return 0;
        }
        i /= 10;
    }
    return e7 && e5 && e3;
}

void dfs(int n, ll i)
{
    if(i > n)
    {
        return;
    }
    cnt += test(i);
    dfs(n, i * 10 + 7);
    dfs(n, i * 10 + 5);
    dfs(n, i * 10 + 3);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    dfs(n, 0);
    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CRectangle {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int H, W, h, w;
        cin >> H >> W >> h >> w;

        if (H % h == 0 && W % w == 0) {
            cout << "No" << endl;
            return;
        }

        cout << "Yes" << endl;
        vector<vector<int>> ans(H, vector<int>(W));
        if (H % h != 0) {
            REP(i, H) {
                REP(j, W) {
                    ans[i][j] = i % h == 0 ? h * 1000 - 1001 : -1000;
                }
            }
        } else {
            REP(i, H) {
                REP(j, W) {
                    ans[i][j] = j % w == 0 ? w * 1000 - 1001 : -1000;
                }
            }
        }
        REP(i, H) {
            REP(j, W) {
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CRectangle solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <queue>
#define ll long long
#define N 10000
#define mod 1000000007
#define LL 100
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    ll num[n+1];
    for (int i=1; i<=n; i++) cin>>num[i];
    
    map <ll,ll> data;
    ll count1=1;
    ll count2=0;
    ll ans=1; //現在の位置
    vector<ll> pp;
    data[1]++;
    //cout<<num[1];
    
    while(true){
        //cout<<ans<<endl;
        ans=num[ans];
        if (data[ans]==0){
            count1++;
            data[ans]++;
        }
        else if (data[ans]==1){
            pp.push_back(ans);
            count2++;
            data[ans]++;
        }
        else break;
    }
    if (k>=count1){
        ll p=k-count1;
    //cout<<count1<<endl;
        ll r=p%count2;
    //cout<<count2<<endl;
        cout<<pp[r]<<endl;
    }
    else{
        ans=1;
        for (int i=0; i<k; i++){
            ans=num[ans];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 18308
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int m=s.nextInt();
		
		int[] arr=new int[n];
		
		int sum=0;
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
			sum=sum+arr[i];
		}
		
		int min=0;
		
		if(sum%(4*m)==0)
		{
			min=sum/(4*m);
		}
		else
		{
			min=(sum/(4*m))+1;
		}
		
		int count=0;
		
		for(int i=0;i<n;i++)
		{
			if(arr[i]>=min)
			{
				count++;
			}
		}
		
		if(count>=m)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
		
	}
	
}


Measured memory_bytes: 22228
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N;
  cin >> N;
  vi h(N);
  cin >> h;

  vi dp(N);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  rep(i, N - 2) {
    dp[i + 2] = min(dp[i] + abs(h[i] - h[i + 2]), dp[i + 1] + abs(h[i + 1] - h[i + 2]));
  }
  out(dp[N - 1]);
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

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

    cout << lcm(a, b);

    return 0;
}


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

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int cnt = 0;

int dfs(int n, string s, long t){
    if(s.size() == n){
        if (contain(s, "3") && contain(s, "5") && contain(s, "7") && stoi(s) <= t)
        {
            cnt++;        
        }
        return cnt;
    }

    dfs(n, s+"3", t);
    dfs(n, s+"5", t);
    dfs(n, s+"7", t);
    return cnt;
}

int main(){
    string n;
    cin>>n;
    for(int i=3; i<=n.size(); i++){
        dfs(i, "", stoi(n));
    }
    cout << cnt << endl;
}

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

int main()
{
  int ans = 0;
  rep(i, 5)
  {
    int x;
    cin >> x;
    if (x == 0)
      ans = i + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3536
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

P, Q, R = MAP()
print(P+Q+R - max(P, Q, R))

Measured memory_bytes: 5148
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ns()

p = 0
for s in n:
    p += int(s)

if p%9==0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 69288
(N,M)=gets.split.map(&:to_i)
p ARGF.map{|s| s.split.map(&:to_i)}.sort_by(&:first).map {|e,n|
    c=M
    if c==0 then
        0
    elsif c <n then
        M=0
        e*c
    else
        M-=n
        e*n
    end
}.reduce(:+)

Measured memory_bytes: 18396
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> a;
    vector<ll> v(n);

    rep(i, n){
        cin >> v[i];
    }
    sort(all(v));
    v.push_back(-1);

    ll cnt = 1;
    rep(i, n){
        if(v[i+1] == v[i]) cnt++;
        else{
            a.push_back(cnt);
            cnt = 1;
        }
    }

    sort(all(a));

    ll ans = 0;
    rep(i, a.size()-k){
        ans += a[i];
    }

    cout << ans;

}

Measured memory_bytes: 6884
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

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

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

const int N=55, mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int mul(int x,int y) {return (LL)x*y%mod;}

inline void add1(int &x,int y) {x=add(x,y);}

int n,f[N][N],c[N][N];

int main() {
	cin>>n;
	f[1][0]=f[1][1]=1;
	for(int i=0;i<=n;i++) c[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			c[i][j]=add(c[i-1][j-1],c[i-1][j]);
	for(int i=1;i<n;i++)
		for(int j=0;j<=i;j++) if(f[i][j]) 
			for(int x=0;x+i<=n;++x)
				for(int y=0;x+y+i<=n;++y) if((x+y) && (x+y>=j) && (!((x+y-j)&1)))
					add1(f[i+x+y][abs((x+y-j)/2+j-x)],mul(f[i][j],mul(c[i+x+y][x+y],c[x+y][x])));
	cout<<f[n][0]<<'\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		if (d == 1) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    vector<unsigned> a, b;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 1; i <= n; i++) {
        if (s[i - 1] == t[i - 1]) a.push_back(1);
        else a.push_back(2), i++;
    }
    if (a[0] == 1) b.push_back(3);
    else b.push_back(6);
    for (int i = 1; i < a.size(); i++) {
        if (a[i] == 1 && a[i - 1] == 1) b.push_back(b[i - 1] * 2 % mod);
        else if (a[i] == 1 && a[i - 1] == 2) b.push_back(b[i - 1]);
        else if (a[i] == 2 && a[i - 1] == 1) b.push_back(b[i - 1] * 2 % mod);
        else b.push_back(b[i - 1] * 3 % mod);
    }
    cout << b.back();
}


Measured memory_bytes: 256
def main():
  n,m,k=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in range(m)]
  cd=[list(map(int,input().split())) for _ in range(k)]
  friend=[set()for _ in range(n)]
  block=[set()for _ in range(n)]
  for a,b in ab:
    friend[a-1].add(b-1)
    friend[b-1].add(a-1)
  for c,d in cd:
    block[c-1].add(d-1)
    block[d-1].add(c-1)
  # 友達連結内でかつ友達でもブロックでもない。
  # 友達連結グループわけ
  ans=[0]*n
  seen=[0]*n
  for t in range(n):
    if seen[t]==1:
      continue
    member=set()
    todo=[t]
    seen[t]=1
    while todo:
      t=todo.pop()
      member.add(t)
      f=friend[t]
      for fi in f:
        if seen[fi]==0:
          todo.append(fi)
          seen[fi]=1
    mn=len(member)
    for m in member:
      ans[m]=mn-len(block[m].intersection(member))-len(friend[m])-1
  print(' '.join(map(str,ans)))
if __name__=='__main__':
  main()


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

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N,0);
    rep(i,N)cin>>A[i];

    sort(A.begin(),A.end());
    
    long long pre = A[0];
    long long ans = 0;
    long long count = 1;

    rep(i,N){
        if(i==0)continue;

        long long val = A[i];
        if(val != pre){
            ans += count%2;
            count = 1;
        }else{
            count++;
        }
        pre = val;
    }
    ans += count%2;

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

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;
using namespace __gnu_pbds;

// typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

bool mysort(pair<ll,ll>&p1,pair<ll,ll>&p2)
{
  return p1.second<p2.second;
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll i,j,k,n;
      cin>>n;
      vector<ll>a(n);
      rep(i,0,n-1) cin>>a[i];
      set<vector<ll>>st;
      ll ans=0;
      for(i=0;i<n;i++)
      {
        for(j=i+1;j<n;j++)
        {
          for(k=j+1;k<n;k++)
          {
            if(a[k]>=a[j]+a[i] || a[i]>=a[k]+a[j] || a[j]>=a[k]+a[i]) continue;
            if(a[i]==a[k] || a[i]==a[j] || a[j]==a[k]) continue;
            ans++;
            // vector<ll>tmp;
            // tmp.pb(a[i]);tmp.pb(a[j]);tmp.pb(a[k]);
            // sort(all(tmp));
            // st.insert(tmp);
          }
        }
      }
      cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 14148
#include<stdio.h>
#define min(x,y) ((x)<(y)?(x):(y))
int a,b,c,d,e;
main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a<=b&&a<=c)d=a;
	if(b<=a&&b<=c)d=b;
	if(c<=a&&c<=b)d=c;
	if(d==a)e=min(b,c);
	if(d==b)e=min(a,c);
	if(d==c)e=min(a,b);
	printf("%d",d*e/2);
}/**/

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int n,m,x,y;
  scanf("%d%d%d%d",&n,&m,&x,&y);
  int a[n],b[m],i;
  for(i=0;i<n;++i)
      scanf("%d",&a[i]);
  
  for(i=0;i<m;++i)
      scanf("%d",&b[i]);
  
  int j,k;
  int flag=0;
  for(k=x+1;k<=y;++k)
  {
     flag=0; 
    for(i=0;i<n;++i)
    {
      if(k>a[i])
         continue;
      
      else
      {flag=1;
       break;
      }
    }
    
    if(flag==0)
    {
    for(j=0;j<m;++j)
    {
        if(k<=b[j])
            continue;
      
        else
        {
          flag=1;
          break;
        }
    }
    
    if(flag==0)
        break;
    }
  }
  
  if(k>y)
     printf("War");
  
  else
      printf("No War");
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String s = readLine()[0];
		int ff = Integer.parseInt(s.substring(0,2));
		int ll = Integer.parseInt(s.substring(2,4));
		if(ff<=12&&ff!=0) {
			if(ll<=12&&ll!=0) {
				print("AMBIGUOUS");
			}else {
				print("MMYY");
			}
		}else {

			if(ll<=12&&ll!=0) {
				print("YYMM");
			}else {
				print("NA");
			}
		}
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 22484
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>

#define rep(i, n) for(int i = 0, end = (int)(n); i < end; i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

bool is_seven(string s, bool p1, bool p2, bool p3) {
    int a1 = p1 ? ctoi(s[0]) + ctoi(s[1]) : ctoi(s[0]) - ctoi(s[1]);
    int a2 = p2 ? a1 + ctoi(s[2]) : a1 - ctoi(s[2]);
    int a3 = p3 ? a2 + ctoi(s[3]) : a2 - ctoi(s[3]);
    return a3 == 7;
}

inline string kigou(bool f) {
    return f ? "+" : "-";
}

string create(string s, bool p1, bool p2, bool p3) {
    string ss = s.substr(0,1);
    ss += kigou(p1);
    ss += s.substr(1,1);
    ss += kigou(p2);
    ss += s.substr(2,1);
    ss += kigou(p3);
    ss += s.substr(3,1);
    return ss += "=7";
}

int main() {
    string s;
    cin >> s;
    rep(i, 8) {
        bool p1 = i & 1;
        bool p2 = i & 2;
        bool p3 = i & 4;
        if(is_seven(s, p1, p2, p3)){
            cout << create(s,p1,p2,p3) << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll ans = 0;
    ll x, y; cin >> x >> y;
    if(x > y){
        ans += x; x--;
    }
    else{
        ans += y; y--;
    }
    
    if(x > y){
        ans += x;
    }
    else{
        ans += y;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a=input()
x = [a[i:i+1] for i in range(len(a))]
if (a[0]==a[1] and a[2]==a[3]) or (a[0]==a[2] and a[1]==a[3]) or (a[0]==a[3] and a[1]==a[2]):
    if a[0]==a[1] and a[0]==a[2] and a[0]==a[3]:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064