akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int main()
{
	int N,K,x[100],a[100],result=0;
	
	scanf("%d %d",&N,&K);
	
	for(int i=0; i<N; i++)
	{
		scanf("%d",&x[i]);
	}
	
	for(int i=0; i<N; i++)
	{
		a[i] = x[i]*2;
		if(a[i] > (abs(K-x[i])*2))
		{
			a[i] = abs(K-x[i])*2;
		}
		
		result += a[i];
	}
	
	printf("%d",result);
	
	return 0;
}

Measured memory_bytes: 128
a = int(input()) 
b = int(input())


listt = []
listt.append(a)
listt.append(b)
if 1 in listt and 2 in listt:
    print(3)

if 2 in listt and 3 in listt:
    print(1)

if 1 in listt and 3 in listt:
    print(2)



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(string, S);
    CIN(string, T);
    int N = S.size();

    for (int i = 0; i < 26; i++) {
        char t;
        bool check = false;
        for (int j = 0; j < N; j++) {
            if ( S[j] == 'a' + i ) {
                S[j] = 'A' + i;
                t = T[j];
                check = true;
            }
        }
        if (!check) continue;
        for (int j = 0; j < N; j++) {
            if ( T[j] == t ) {
                T[j] = 'A' + i;
            }
        }
    }

    string ans = "Yes";
    for (int i = 0; i < S.size(); i++) {
        if ( S[i] != T[i] ) {
            ans = "No";
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 776
#include <iostream>

using namespace std;

class A {
	int N;
public:
	void solve()
	{
		cin >> N;

		if (N < 1000) cout << "ABC" << endl;
		else cout << "ABD" << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  sort(all(s));
  sort(all(t), greater<char>());
  cout << (s<t ? "Yes" : "No") << endk;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> B(m);
    vector<vector<int>> A(n, vector<int>(m));
    rep(i, m) cin >> B[i];
    rep(i, n) {
        rep(j, m) cin >> A[i][j];
    }

    int ans = 0;
    rep(i, n) {
        int sum = c;
        rep(j, m) {
            sum += A[i][j] * B[j];
        }
        if(sum > 0) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){    
  long long X;
  cin >> X;
  long long sum=0;

  long long Y = X/500;
    sum += 500*Y;
  
    
   long long Z = X/5;
    sum += 5*Z;
    
  
  cout << sum << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<u32 M = 1000000007>
struct modint{
    u32 val;
    modint(): val(0){}
    template<typename T>
    modint(T t){t %= (T)M; if(t < 0) t += (T)M; val = t;}

    modint pow(ll k) const {
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T t){t %= (T)M; if(t < 0) t += (T)M; val = t; return *this;}
    modint inv() const {return pow(M-2);}
    modint& operator+=(modint a){val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){if(val < a.val) val += M-a.val; else val -= a.val; return *this;}
    modint& operator*=(modint a){val = (u64)val*a.val%M; return *this;}
    modint& operator/=(modint a){return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){return modint(M-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
};
using mint = modint<MOD>;

int main() {
    int n;
    cin >> n;
    vector<string> v(n);
    for (auto &&i : v) cin >> i;
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<mint> dp1(n), dp2(n);
    auto dfs = [&](int x, int par, auto &&f) -> void {
        if(v[x].size() >= 2) dp2[x] = 1;
        for (auto &&y : G[x]) if(y != par) f(y, x, f);
        if(v[x][0] == 'E'){
            dp1[x] = 1;
            for (auto &&y : G[x]) if(y != par) dp1[x] *= (dp1[y]+dp2[y]);
        }else if(v[x][0] == 'A'){
            for (auto &&y : G[x]) if(y != par) dp1[x] += (dp1[y]+dp2[y]);
        }else if(v[x][0] == 'R'){
            dp1[x] = 1;
            mint a = 1;
            for (auto &&y : G[x]) if(y != par) dp1[x] *= (dp1[y]+dp2[y]+1);
            dp1[x] -= 1;
        }
    };
    dfs(0, -1, dfs);
    /*for (int i = 0; i < n; ++i) {
        printf("%10d ", dp1[i].val);
    }
    puts("");
    for (int i = 0; i < n; ++i) {
        printf("%10d ", dp2[i].val);
    }*/
    cout << (dp1[0]+dp2[0]).val << "\n";
    return 0;
}


Measured memory_bytes: 3396
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int32_t main(){
    init;
    int n,m,i,j,k,l,p;
    cin >> n >> m;
    vector<int> heights(n + 1);
    for(i = 1;i <= n; i++)cin >> heights[i];

    vector<set<int> >adj(n + 1);
    for(i = 0; i < m; i++){
        cin >> j >> k;
        adj[j].in(k);
        adj[k].in(j);
    }

    p = 0 ;
    for(i = 1;i <= n; i++){
        if(adj[i].size() == 0){
            p++;
            continue;
        }
        l = 1;
        for(auto j : adj[i]){
            if(heights[j] >= heights[i]){
                l = 0;
                break;
            }
        }
        p += l;
    }

    cout << p << endc;
    return 0;
}

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

struct edge { int from, to; };
vector<edge> E;

int main() {
	int m, n, x, y;
	cin >> m >> n;

	int c[21] = {};
	for (int i=0; i<n; ++i) {
		cin >> x >> y;
		E.push_back((edge){x, y});
		c[y] ++;
	}

	for (int i=0; i<m; ++i) {
		for (int j=1; j<=m; ++j) {
			if (c[j] == 0) {
				cout << j << endl;
				c[j] = 1e8;
				for (int k=0; k<n; ++k) {
					c[E[k].to] -= (E[k].from == j);
				}
				break;
			}
		}
	}
	return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    cout << ( (2 + n - 1) * (n - 2) ) / 2 + 1 << endl;
    //cout << (1 + n - 1) * (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
int main(){
  cin>>n;
  REP(i,n) scanf("%d",&ar[i]),--ar[i];
  int res=0;
  REP(i,n) if(ar[ar[i]]==i) ++res;
  assert(res%2==0);
  cout<<res/2<<endl;
  return 0;
}




Measured memory_bytes: 640
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
x,y=MI()
u=make_divisors(y)
for j in u:
    if j>=x:
        ans=y//j
        break
print(ans)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    deque<int> dq;
    for (int i = 0; i < k; i++)
        dq.push_back(a[i]);
    for (int i = k; i < n; i++)
    {
        int fr = dq.front();
        dq.pop_front();
        if (fr < a[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        dq.push_back(a[i]);
    }
    return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int H, W, N;
    cin >> H >> W >> N;

    int i = max(H, W);
    int ans = ceil(float(N) / i);
    print(ans);
}

signed main() {
    solve();
}


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

import math

n = int(input())
o = math.floor(math.log(n, 10))
ans = 0

for i in range(o):
    if i % 2 == 0:
        ans += 10 ** (i + 1) - 10 ** i
    else:
        continue

if o % 2 == 0:
    ans += n - (10 ** o) + 1


print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
    long long int n, a, b, c, d, ans;
    cin >> n >> a >> b;
    c = n / (a + b);
    d = n % (a + b);
    ans = c * a;
    if (d < a)
        ans += d;
    else
        ans += a;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.Math.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int r = sc.nextInt();
		int c =0;
		while(n>0) {
			c++;
			n/=r;
		}
		pw.println(c);
		pw.close();

	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}

	}

	static class pair2 implements Comparable<pair2> {
		long x;
		int y;

		@Override
		public String toString() {
			// TODO Auto-generated method stub
			return y + " ";
		}

		public pair2(long d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair2 o) {
			// TODO Auto-generated method stub
			if (x - o.x > 0)
				return 1;
			else if (x - o.x == 0)
				return 0;
			return -1;
		}

	}

}


Measured memory_bytes: 23252
import sys
readline = sys.stdin.readline

def main():
    S = readline().rstrip()
    N = len(S)
    ans = 0
    for i in range(2**(N-1)):
        b = bin(i)[2:].zfill(N-1)
        f = [S[i]+'+' if b[i]=='1' else S[i] for i in range(N-1)]
        f += S[-1]
        ans += eval(''.join(f))
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
int W, H, x, y, r, xu, xd, yl, yr;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
xu = x + r;
xd = x - r;
yl = y - r;
yr = y + r;
if((xd < 0)||(xu > W)||(yl < 0)||(yr > H)){
printf("No\n");
}else{
printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

string S;

bool is_month(string s) {
    int n = stoi(s);
    return 1 <= n && n <= 12;
}

int main() {
    cin >> S;

    string first = S.substr(0, 2);
    string last = S.substr(2, 2);

    if (!is_month(first) && is_month(last)) {
        cout << "YYMM" << endl;
    } else if (is_month(first) && !is_month(last)) {
        cout << "MMYY" << endl;
    } else if (is_month(first) && is_month(last)) {
        cout << "AMBIGUOUS" << endl;
    } else {
        cout << "NA" << endl;
    }
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::BTreeMap;

fn main() {
    let n: usize = read();
    let mut bmap: BTreeMap<String, Vec<(i64, usize)>> = BTreeMap::new();
    for i in 0..n {
        let c: String = read();
        let p: i64 = read();
        let current = bmap.entry(c).or_insert(vec![]);
        current.push((p, i + 1));
    }

    for (key, value) in bmap {
        let mut valuec = value.clone();
        valuec.sort_by(|a, b| a.0.cmp(&b.0));
        valuec.reverse();
        for i in valuec {
            println!("{}", i.1);
        }
    }
}


Measured memory_bytes: 2144
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> t[i];
    }
    constexpr ll mod = 1000000007LL;
    vector<vector<ll>> dp(n, vector<ll>(m));
    vector<vector<ll>> sum(n, vector<ll>(m));
    dp[0][0] = sum[0][0] = s.front() == t.front();
    for (int i = 1; i < n; ++i) {
        dp[i][0] = s[i] == t.front();
        sum[i][0] = dp[i][0] + sum[i - 1][0];
    }
    for (int i = 1; i < m; ++i) {
        dp[0][i] = s.front() == t[i];
        sum[0][i] = dp[0][i] + sum[0][i - 1];
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            if (s[i] == t[j])
                dp[i][j] = sum[i - 1][j - 1] + 1;
            sum[i][j] = ((sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]) % mod + mod) % mod;
            sum[i][j] += dp[i][j];
            sum[i][j] %= mod;
        }
    }
    cout << (sum.back().back() + 1) % mod << endl;
    return 0;
}

Measured memory_bytes: 62976
n = int(input())
testimony = [[] for _ in range(n)]
for i in range(n):
    for j in range(int(input())):
        x,y = map(int, input().split())
        testimony[i].append((x,y))
honest = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i>>j)&1:
            for x,y in testimony[j]:
                if (i>>(x-1))&1 != y:
                    flag = False
                    break
    if flag:
        honest = max(honest, bin(i)[2:].count('1'))
print(honest)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 998244353;
long double PI = acosl(-1);
const ll infl = 3e18+100;
const int inf = 1e8+100;
const int nmax = 3000+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int k;
int ek, zir;
string s;
vector< vector<vector<int> > >dp;
int arr[nmax];
int curpos;


int recc(int pos, int hate, int uthaisi){
    if(uthaisi > k) return 0;
    if(pos==curpos) return 1;
    if(dp[pos][hate][uthaisi]!=-1) return dp[pos][hate][uthaisi];

    int ase = arr[pos];
    int ret = 0;
    for(int i=0; i<=ase; i++){
        ret = (1LL*ret + recc(pos+1, hate+i, uthaisi+i) ) % mod;
    }
    for(int i=1; i<=hate; i++){
        ret = (1LL*ret + recc(pos+1, hate-i, uthaisi) ) % mod;
    }
    return dp[pos][hate][uthaisi] = ret;
}

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

    cin>>s>>k;
    for(char ch : s) {
        if(ch=='0') zir++;
        else ek++;
    }

    dp.resize(zir+2);
    for(auto &z : dp){
        z.resize(ek+2);
        for(auto &zz : z){
            zz.resize(ek+2, -1);
        }
    }

    while(s.size()){
        if(s.back()=='0') curpos++;
        else arr[curpos]++;
        s.pop_back();
    }

    cout<<recc(0, 0, 0)<<endl;
}


Measured memory_bytes: 19756
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int a, b;
    cin >> a >> b;

    if((a * b) % 2 == 0){
        cout << "Even";
    }else{
        cout << "Odd";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#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()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

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<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<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  V<int> a(n);
  REP(i, n) cin >> a[i];

  V<int> cnt1(1e5+1);
  for(int i=0; i<n; i+=2) {
    cnt1[a[i]]++;
  }

  V<int> cnt2(1e5+1);
  for(int i=1; i<n; i+=2) {
    cnt2[a[i]]++;
  }

  int mi1 = -INF, mi2 = -INF, idx = -1;
  REP(i, 1e5+1) {
    if(mi1 < cnt2[i]) {
      mi2 = mi1;
      mi1 = cnt2[i];
      idx = i;
    } else if(mi2 < cnt2[i]) {
      mi2 = cnt2[i];
    }
  }

  int ans = INF;
  REP(i, 1e5+1) {
    int tmp1 = cnt1[i];
    int tmp2;
    if(idx == i) {
      tmp2 = mi2;
    } else {
      tmp2 = mi1;
    }
    chmin(ans, n - tmp1 - tmp2);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
	int m,n;
	while(cin>>m){
		if(m==0)break;
		cin>>n;
		int count=0;
		for(int i=m;i<=n;++i){
			int a=i;
			while((a%2==0)||(a%3==0)||(a%5==0)){
				if(a%2==0)a/=2;
				else if(a%3==0)a/=3;
				else if(a%5==0)a/=5;
			}
			if(a==1)count++;
		}
		cout<<count<<"\n";
	}
}

Measured memory_bytes: 864
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String...args) {
        String str = new Scanner(System.in).nextLine();
        String[] list = str.split(" ");

        int a = Integer.parseInt(list[0]);
        int b = Integer.parseInt(list[1]);
        int c = Integer.parseInt(list[2]);

        int tmp = 0;

        if (c < b) {
            tmp = b;
            b = c;
            c = tmp;

            if (b < a) {
                tmp = a;
                a = b;
                b = tmp;

                if (c < b) {
                    tmp = b;
                    b = c;
                    c = tmp;

                }
            }

        } else if (b < a) {
            tmp = a;
            a = b;
            b = tmp;

            if (c < b) {
                tmp = b;
                b = c;
                c = tmp;

            }
        }


        System.out.println(a + " " + b + " " + c);





    }

}

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

long long factorial(long long n) {
  return n * (n + 1) / 2;
}


vector<int> factsums(long long n) {
  if (n == 0) return {};

  long long v = 1;
  while (factorial(v) < n) v++;
  vector<int> rs(v);
  for (int i = 0; i < v; i++) rs[i] = i + 1; 

  vector<int> remain = factsums(factorial(v) - n);

  for (const int &rem : remain) {
    rs.erase(remove(rs.begin(), rs.end(), rem), rs.end());
  }

  return rs;
}

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

  vector<int> rs = factsums(n);

  for (const int &r : rs) {
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
program ABC079B
    implicit none
    integer(8)::N,Li,i
    integer(8)::L0=2
    integer(8)::L1=1

    read(5,*)N

    do i=2,N
        Li=L0+L1
        L0=L1
        L1=Li
    end do

    if(N==1)then
        print'(i0)',L1
    else
        print'(i0)',Li
    end if
    
end program ABC079B

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

const int BIG_NUM = 1e9;

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

    int r, d, x;
    cin >> r  >> d >> x;
    for(int i = 0; i < 10; i++ ) {
        x = r * x - d;
        cout << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef long long ll;

int main() {
	int a = 0, b = 0, c = 0;
	int n = 0;
	std::string str;
	int ar[100000] = {};
	std::cin >> n;

	if (n < 1000) {
		std::cout << "ABC"<< std::endl;
	}
	else {
		std::cout << "ABD" << std::endl;
	}

	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    bool flag = true;
    rep(i, n, 0) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                flag = false;
                break;
            }
        }
    }

    if(flag) {
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* 
    AABRA KA DABRA.. !! 
*/
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
#define int long long
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(int i=k; i<=n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
#define deb(x) cout<<#x<<" = "<<x<<endl
#define gcd __gcd
#define inf LLONG_MAX
#define minf LLONG_MIN 
const int mod = (int)(1e9+7);

int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
bool is_power_2(int n)  { return log2(n)==floor(log2(n));}
bool is_prime(int n){   for(int i=2; i*i<=n; i++)   if(n%i==0)  return 0;   return 1;}

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

/*                                                                 
    ╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦═╩═╦═╩═╦═╩╦═╩═╦═╩═╦ 
*/  




void solve()
{   
    int n,i,j,k,m;
    cin>>n;
    string ans = "";
    while(n)
    {
        n--;
        ans += 'a' + n%26;
        n/=26;
    }
    reverse(all(ans));
    cout<<ans;
}   
signed main()
{
    RAGE;
    int t=1;
    //  cin>>t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3668
import numpy as np
N, M =map(int,input().split())
search = np.zeros(M+1)
for i in range(N):
   K = list(map(int,input().split()))
   for j in range(1,K[0]+1):
       search[K[j]]+=1
place = np.where(search==N)
print(len(place[0]))

Measured memory_bytes: 12504
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int[] b = new int[m];
        int[][] a = new int[n][m];
        for(int i=0;i<m;i++)b[i] = Integer.parseInt(sc.next());
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        int res = 0;
        int sum;
        for(int i=0;i<n;i++){
            sum =0;
            for(int j=0;j<m;j++){
                sum+=a[i][j]*b[j];
            }
            if(sum+c > 0){
                res++;
            }
        }
        System.out.println(res);
        sc.close();
    }
    
}

Measured memory_bytes: 23892
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int c5=0,c7=0;
    for(int i=0;i<3;++i)
    {
        int xx;
        cin>>xx;
        if(xx==5)c5++;
        else if(xx==7)c7++;
    }
    if(c5==2 && c7==1)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e11

typedef long long ll;

ll n, s;

ll f(ll b, ll n) { return n < b ? n : f(b, n / b) + n % b ; }

int main() {
    scanf("%lld%lld", &n, &s) ;
    if(s > n) return puts("-1"), 0;
    if(s == n) return printf("%lld\n", n + 1), 0;
    ll bl = sqrt(n) + 1;
    for (ll i = 2; i <= bl; ++i) if (f(i, n) == s) return printf("%lld\n", i), 0;
    ll ans = INF; 
	n -= s;
    for (ll i = 1; i <= sqrt(n); ++i) if (n % i == 0) {
        ll b = n / i + 1;
        if (f(b, n + s) == s) ans = std :: min(ans, b);
    }
    printf("%lld\n", ans != INF ? ans : -1);
    return 0 ;
} 

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 10005;

int n;
char s[10];

bool check(int x) {
	int res = s[1] - '0';
	for(int i = 0; i < 3; i++) {
		if((1 << i) & x) res += s[i + 2] - '0';
		else res -= s[i + 2] - '0';
	}
	if(res == 7) return 1;
	else return 0;
}

int main()
{
	while(scanf("%s", s + 1) != EOF)
	{
		int ans = 0;
		for(int i = 0; i <= 7; i++) {
			if(check(i) == 1) {
				ans = i;
				break;
			}
		}
		for(int i = 1; i <= 3; i++) {
			if(((1 << (i - 1)) & ans) )
				printf("%c+", s[i]);
			else printf("%c-", s[i]);
		}
		printf("%c=7\n", s[4]);
	}
	return 0;
}

Measured memory_bytes: 128
s = int(input())

a = s%10

base_1 = [2,4,5,7,9]
base_2 = [0,1,6,8]

if a in base_1:
  ans = "hon"
elif a in base_2:
  ans = "pon"
elif a == 3:
  ans = "bon"
  
print(ans)

Measured memory_bytes: 9176
N, H = map(int, input().split())
# B = []
A = []
B = []
amax = -1
bmax = -1

for _ in range(N):
    a, b = map(int, input().split())
    # B.append((a,b))
    A.append(a)
    B.append(b)

    if amax < a:
        amax = a
    
    if bmax < b:
        bmax = b

if amax >= bmax:
    m = H % amax
    if m != 0:
        ans = H // amax + 1
    else:
        ans = H // amax

else:
    ans = 0
    throw_lst = list(filter(lambda x: x > amax, B))
    throw_lst.sort(reverse=True)

    for tb in throw_lst:
        H -= tb
        ans += 1
        if H <= 0:
            print(ans)
            exit(0)

    m = H % amax
    if m != 0:
        ans += H // amax + 1
    else:
        ans += H // amax

print(ans)

Measured memory_bytes: 17952
#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int M,N;
int p[MAXN];

int Find(int x){
    return p[x]==x ? x : p[x]=Find(p[x]);
}

int same(int u,int v){
    return Find(u)==Find(v);
}

void unite(int u,int v){
    p[Find(u)]=Find(v);
}

void work(){
    while(~scanf("%d%d",&N,&M)){
        for(int i=0;i<N;i++) p[i]=i;
        while(M--){
            int a,b,c; scanf("%d%d%d",&a,&b,&c);
            if(a==0) unite(b,c);
            else printf("%d\n",same(b,c));
        }
    }
}

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



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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; i++) {
        cin >> h.at(i);
    }

    int cnt = 0;
    int before = 0;

    for (int i=0; i<n; i++) {
        if (before < h.at(i)) {
            cnt += h.at(i) - before;
        }
        before = h.at(i);
    }
    cout << cnt << endl;
}

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

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

using namespace std;
typedef pair<int,int> pii;

const int INF = 0x3fffffff;

class Flow{
	public:
		int N, en;
		vector< vector<int> > F, C;
		vector< vector<pii> > edge;
		Flow(int n, int e): F(n,vector<int>(n)), C(n,vector<int>(n)), N(n), edge(n){ en=0; }
		void addEdge(int f, int t, int c){
			F[f][t] = C[f][t] = c;
		}
		int flow(int n, int c, int T, vector<bool> &bf){
			if( n == T ) return c;
			bf[n] = true;
			rep(i,N){
				if( F[n][i] > 0 && !bf[i] ){
					int f = flow(i, min(c, F[n][i]), T, bf);
					if( f > 0 ){
						F[n][i] -= f;
						F[i][n] += f;
						return f;
					}
				}
			}
			return 0;
		}
		int maxFlow(int S, int T){
			for(int ret=0;;){
				vector<bool> bf(N);
				int add = flow(0, INF, T, bf);
				ret += add;
				if( add==0 ) return ret;
			}
		}
		void clear(){
			//fill( F.begin(), F.end(), 0 );
		}
};

int main(){
	int V, E;
	cin >> V >> E;
	Flow fl(V,E);
	for(int i=1; i<=E; i++){
		int u, v, c;
		cin >> u >> v >> c;
		fl.addEdge( u, v, c );
	}

	cout << fl.maxFlow(0, V-1) << endl;

	return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int ac;
	cin >> ac;
	if (ac >= 30) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define inf 0x3f3f3f3f
typedef long long LL;
#define cls(x) memset(x,0,sizeof(x))
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Rep(i,j,k) for(register int i=(j);i>=(k);--i)
#define rint register int
#define il inline


const int N=2000+5;
int n,k,tot;
int head[N],ver[N<<1],nxt[N<<1],edge[N<<1];

il void add(int x,int y,int z)
{ ver[++tot]=y; nxt[tot]=head[x]; head[x]=tot; edge[tot]=z; }
int d[N][N];
int v[N];
void dfs(int x,int u)
{
    v[x]=u;
    for(rint i=head[x];i;i=nxt[i])
    {
        int y=ver[i]; if(v[y]==u) continue;
        d[u][y]=d[u][x]+edge[i];
        dfs(y,u);
    }
}

int ans=inf;
int main()
{
    scanf("%d %d",&n,&k);
    For(i,1,n-1) {int x,y; scanf("%d%d",&x,&y); add(x,y,1); add(y,x,1);}
    For(i,1,n) dfs(i,i);

    if(k&1)
    {
        for(rint x=1;x<=n;++x)
            for(rint i=head[x];i;i=nxt[i])
            {
                int y=ver[i]; int c=0;
                for(rint z=1;z<=n;++z)
                    c+=(d[x][z]>k/2 && d[y][z]>k/2);
                ans=min(ans,c);
            }
    }
    else
    {
        for(rint x=1;x<=n;++x)
        {
            int c=0;
            for(rint y=1;y<=n;++y)
                c+=(d[x][y]>k/2);
            ans=min(ans,c);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 16128
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;


int main()
{
    bool flag = false;
    
    int N;
    cin >> N;
    vector<string> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }

    for (int i = 0; i < N-1; i++) {
        if (W[i].back() != W[i+1].front()) {
            flag = true;
        }
    }
    
    for (int i = 0; i < W.size(); i++) {
        for (int j = 0; j < i; j++) {
            if (W[i] == W[j]) {
                flag = true;
            }
        }
    }
    
    if (!flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    rep(i, N){
        cin >> a[i];
    }
    sort(a, a+N);
    printf("%d\n", a[N-1]-a[0]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
int N,M,Q;
int V[11];
int A[50],B[50],C[50],D[50];
int ans=0;
int preans;

void bfs(int n,int d){
    //nは数列をどこまで決めたか、dはA[n-1]=dをあらわす
    V[n]=d;
    if(n==N){
        preans=0;
        REP(i,Q){
            if(V[B[i]]-V[A[i]]==C[i])preans+=D[i];
        }
        ans=max(ans,preans);
    }
    else{
        for(int i=d;i<=M;i++){
            bfs(n+1,i);
        }
    }
}

signed main(){
    cin>>N>>M>>Q;
    REP(i,Q){
        cin>>A[i]>>B[i]>>C[i]>>D[i];
    }
    bfs(1,1);
    cout<<ans<<endl;
}

Measured memory_bytes: 3524
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

ll pow_5(ll x)
{
    return x * x * x * x * x;
}

int main(){
    std::ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    for(int i=-122;i<=122;++i)
    {
        for(int j=-122;j<=122;++j)
        {
            if(pow_5(i) - pow_5(j) == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=3;i++)
	{
		if(a*b*i%2==1) 
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	int cnt = 0;
	int l = -1;
	int r = 999999;
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;

		l = max(l, x);
		r = min(r, y);
	}

	int b = r - l + 1;
	if (b < 0)
	{
		b = 0;
	}
	cout << b << endl;
}

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

int n;
int a[25][25];

int dp[25][1 << 21];

const int MOD = 1e9 + 7;

inline void add(int &a, int b) {
	a += b;
	
	if (a >= MOD) {
		a -= MOD;
	}
}
int rec(int id, int mask) {
	if (id == n) return 1;
	if (dp[id][mask] >= 0) return dp[id][mask];
	
	int res = 0;
	
	for (int i = 0; i < n; i++) {
		if (mask & (1 << i)) {
			continue;
		}
		
		if (!a[id][i]) {
			continue;
		}
		
		add(res, rec(id + 1, mask | (1 << i)));
	}
	
	return dp[id][mask] = res;
}
int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	
	memset(dp, -1, sizeof(dp));
	
	cout << rec(0, 0);
}


Measured memory_bytes: 205056
import java.io.IOException;
import java.util.Arrays;
import java.util.NoSuchElementException;

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		
		int[] a = new int[3];
		for(int i=0;i<3;i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		for(int i=0;i<2;i++){
			System.out.print(a[i] +  " ");
		}
		System.out.println(a[2]);
	}
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





Measured memory_bytes: 24172