akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, m, a[300][301]; //maxA = 301;

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	bool b[301] = {0};
	int c[300] = {0};
	int ans = INF;
	
	
	for(int j = 0; j < m; j++){
		for(int i = 0; i < n; i++){
			while(b[a[i][c[i]]] == 1){
				c[i]++;
			}
		}
		int cnt[301] = {0};
		for(int i = 0; i < n; i++){
			cnt[a[i][c[i]]]++;
		}
		int e = 0, f;
		for(int i = 1; i <= m; i++){
			if(cnt[i] > e){
				e = cnt[i];
				f = i;
			}
		}
		ans = min(e, ans);
		b[f] = 1;
	}
	
	cout << ans << endl;
	
	return 0;
}

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


def main():
    n, k = map(int, input().split())
    h_list = list(map(int, input().split()))

    dp = [0] + [9999999999] * (n - 1)

    for i in range(n):
        for j in range(1, k + 1):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + abs(h_list[i] - h_list[i - j]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 52448
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

struct edge {
  ll from;
  ll to;
  ll color;
};

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

  ll N;
  cin >> N;
  vector<edge> E(N-1); // edges
  vector<vector<ll>> adj(N, vector<ll>(0)); //id of adjescent edge

  REP(i,N-1){
    ll ai, bi;
    cin >> ai >> bi;
    ai--; bi--;
    adj[ai].push_back(i);
    adj[bi].push_back(i);
    E[i] = edge{ai, bi, -1}; // From, To, color
  }


  // BFS
  ll max_color = 0;
  queue<ll> que;
  que.push(0);
  while (!que.empty()){
    ll n = que.front(); que.pop();
    // Sort adjescent edge
    sort(adj[n].begin(), adj[n].end(), [&E](ll& ia, ll& ib){
      return E[ia].color < E[ib].color;
    });
    if (E[adj[n][0]].color != -1) continue;

    // Set used/unused flag to each color
    vector<ll> used(max_color+1, 0);
    for (ll& i: adj[n]){
      edge e = E[i];
      if (e.color != -1){
        used[e.color] = 1;
      }
    }

    // Set unused color to each edge
    ll c = 0;
    for (ll& i: adj[n]){
      edge e = E[i];

      if (e.color != -1) break;

      // Find unused color
      while (c<used.size() && used[c]!=0) {
        c++;
      }
      E[i].color = c;
      max_color = max(max_color, c);

      // Update used/unused flag
      if (c < used.size()){
        used[c] = 1;
      } else {
        used.push_back(1);
      }

      // Add adjescent node to queue
      if (e.from != n){
        que.push(e.from);
      } else {
        que.push(e.to);
      }
    }
  }

  cout << max_color+1 << "\n";
  REP(i,N-1){
    cout << E[i].color+1 << "\n";
  }
  return 0;
}

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

int n,a[109],b[109];
void gg(){
	puts("Impossible"); exit(0);
}
int main(){
	scanf("%d",&n);
	int i,m=0;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]); b[a[i]]++;
		m=max(m,a[i]);
	}
	for (i=0; i<=m; i++){
		if (!b[max(i,m-i)]) gg();
		b[max(i,m-i)]--;
	}
	int mn=m+3>>1;
	for (i=0; i<mn; i++) if (b[i]) gg();
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    string S;
    
    cin >> N;
    cin >> S;
    bool ans = true;
    
    if(S.size() % 2 == 1){
        cout << "No" << endl;
    }
    else{
        for(int i = 0; i < S.size()/2; i++){
            
            if(S[i] != S[S.size() / 2 + i]){
                ans = false;
            }
        }
        if(ans){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    


}

Measured memory_bytes: 256
a,b = map(int,input().split())

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

def gcd(x,y):
	while y!=0:
		x,y=y,x%y
	return x

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#factorization(24)
## [[2, 3], [3, 1]]
##  24 = 2^3 * 3^1

g = gcd(a,b)
#gcd_list = make_divisors(g)
bunkai = factorization(g)

if len(bunkai) == 1 and bunkai[0][0] == 1:
	print(1)
else:
	print(len(bunkai) + 1 )


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int maxi = max(a, max(b, c));
    int ans;
    if (maxi == a) {
        ans = b * c / 2;
    }
    else if (maxi == b) {
        ans = a * c / 2;
    }
    else ans = b * a / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	int max = 0;

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j <= s.size() - i; j++) {
			string t = s.substr(i, j);
			bool ok = false;
			int size = 0;
			for (int k = 0; k < t.size(); k++) {
				if (t[k] == 'A' || t[k] == 'C' || t[k] == 'G' || t[k] == 'T') size++;
				if (size == t.size()) ok = true;
			}
			if (ok && t.size() > max) max = t.size();
		}
	}
	
	cout << max << endl;

	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B, T; cin >> A >> B >> T;
    cout << T / A * B << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <map>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

int main () {
    int N, M;
    map<string, int> point;
    cin>>N;
    for (int n = 0; n < N; n++) {
        string str;
        cin>>str;
        if (point.count(str) == 0) point[str] = 1;
        else point[str]++;
    }
    cin>>M;
    for (int m = 0; m < M; m++) {
        string str;
        cin>>str;
        if (point.count(str) == 0) point[str] = -1;
        else point[str]--;
    }

    int mx = 0;
    for (auto&& p : point) {
        mx = max(mx, p.second);
    }

    cout<<mx<<endl;

    
    return 0;
}

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

int main(){

  cin.tie(0);
  ios::sync_with_stdio(0);

  char a,b;

  cin >> a >> b;

  if(a == 'H'){
    if(b == 'H'){
      cout << 'H' << endl;
    }else{
      cout << 'D' << endl;
    }
  }else{
    if(b == 'D'){
      cout << 'H' << endl;
    }else{
      cout << 'D' << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), r = next();
  if(n >= 10)return r;
  return r + 100 * (10 - n);
}

Measured memory_bytes: 21192
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    long solve() {
        long result = 0;
        int N = in.nextInt();
        int[][] graph = new int[N][N];
        boolean[][] check = new boolean[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                graph[i][j] = in.nextInt();
                check[i][j] = true;
            }
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (graph[i][j] > graph[i][k] + graph[k][j]) {
                        return -1;
                    } else if (i != j && i != k && j != k && graph[i][j] == graph[i][k] + graph[k][j]) {
                        check[i][j] = false;
                    }
                }
            }
        }

        for (int i = 0; i < N; i++) {
            for (int j = i; j < N; j++) {
                if (check[i][j]) {
                    result += graph[i][j];
                }
            }
        }
        return result;
    }

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        System.out.println(solve());
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 33096
#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
int c[20],a[20][20],n,m,x,ans;
void check(int k)
{
	int cost=0,u[20]={0};
	for(int i=0; i<n; i++)
		if(k&(1<<i))
		{
			cost+=c[i];
			for(int j=0; j<m; j++) u[j]+=a[i][j];
		}
	int ok=1;
	for(int i=0; i<m; i++) if(u[i] < x){ok=0; break;}
	if(ok) ans=min(ans,cost);
}
int main()
{
	//freopen("out.txt","w",stdout);
	cin >> n >> m >> x;
	for(int i=0; i<n; i++)
		for(int j=0; j<m+1; j++)
			if(!j) cin >> c[i];
			else cin >> a[i][j-1];
	ans=INF;
	for(int i=1; i<(1<<n); i++)
	{
		check(i);
	}
	cout << (ans==INF?-1:ans);
	return 0;
}

Measured memory_bytes: 3608
n=int(input())
ab=abs
hr=list(map(int,input().split()))
dp=[-1]*(n+1)
dp[0]=0
dp[1]=ab(hr[1]-hr[0])
for i in range(2,n):
	x=ab(hr[i]-hr[i-2])+dp[i-2]
	y=ab(hr[i]-hr[i-1])+dp[i-1]
	dp[i]=min(x,y)
print(dp[n-1])

Measured memory_bytes: 84680
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

LL n,m,a[500005],sum = 0;

bool cmp(LL x,LL y){
	return x > y;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i];
		sum += a[i];
	}
	sort(a + 1,a + 1 + n,cmp);
	cout << (a[m] * m * 4LL >= sum ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>

int main() {
  using namespace std;
  typedef unsigned long ulong;
  
  int ballCount;
  cin >> ballCount;
  
  int *balls = new int[ballCount];
  for (int *p = balls, *end = p + ballCount ; p < end ; p++) {
    cin >> *p;
  }
  
  const int && dicCount = ballCount+1;
  auto *dic = new int[dicCount];
  memset(dic, 0, dicCount<<2);
  
  for (int *p = balls, *end = p + ballCount ; p<end ; p++) {
    dic[*p]++;
  }

  ulong sum = 0;
  for (int *p = dic, *end = p + dicCount ; p<end ; p++) {
  	sum += ((ulong)*p) * (*p - 1);
  }
  sum >>= 1;
  
  for (auto *p = balls, *end = p + ballCount ; p < end ; p++) {
    const ulong && m = dic[*p] - 1;
    printf("%ld\n", sum - m);
  }
  
  delete[] balls, dic;
}


Measured memory_bytes: 4096
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

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")
}

fn main() {
    let s: String = read();
    let x: i32 = read();
    let y: i32 = read();

    let cmds: Vec<char> = s.chars().collect();
    let mut fs: Vec<&str> = s.split('T').collect();
    // println!("{:?}", fs);

    let mut first_x: i32 = 0;
    if cmds[0] == 'F' {
        first_x = fs[0].len() as i32;
    }
    fs.remove(0);

    let horizon_moves: Vec<i32> = fs.iter().enumerate().filter(|&(i, _)| i % 2 == 1).map(|(_, x)| x.len() as i32).collect();
    let vertical_moves: Vec<i32> = fs.iter().enumerate().filter(|&(i, _)| i % 2 == 0).map(|(_, x)| x.len() as i32).collect();
    // println!("{}", first_x);
    // println!("{:?}", horizon_moves);
    // println!("{:?}", vertical_moves);

    let mut h_set: HashSet<i32> = HashSet::new();
    h_set.insert(first_x);
    for h_move in horizon_moves {
        let mut new_set: HashSet<i32> = HashSet::new();
        for h_pos in h_set {
            new_set.insert(h_pos + h_move);
            new_set.insert(h_pos - h_move);
        }
        h_set = new_set;
    }

    let mut v_set: HashSet<i32> = HashSet::new();
    v_set.insert(0);
    for v_move in vertical_moves {
        let mut new_set: HashSet<i32> = HashSet::new();
        for h_pos in v_set {
            new_set.insert(h_pos + v_move);
            new_set.insert(h_pos - v_move);
        }
        v_set = new_set;
    }

    let ans = if h_set.contains(&x) && v_set.contains(&y) { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        ArrayList<Integer> array = new ArrayList<Integer>();
        Scanner scanner = new Scanner(System.in);
        while(true){
            int x = scanner.nextInt();
            if(x != 0){
                array.add(x);
            }else{
                break;
            }
            
        }
        for(int j=0; j < array.size(); j++){
            System.out.println("Case "+ (j+1) + ": " + array.get(j));
        }
    }
}



Measured memory_bytes: 43128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
#define deb(x) cout << #x << " = " << x << endl
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
struct comp
{
    bool operator()(const pair<ll, ll> &x, const pair<ll, ll> &y) const
    {
        return x.first < y.first;
    }
};
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwr(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    else
        return pwr(mul(x, x), n / 2);
}
ll modInv(ll n)
{
    return pwr(n, mod - 2);
}
ll modInverse(ll a, ll m)
{
    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;
}
unordered_map<ll, ll> g[200005];
bool vis[200005];
int dfs(int u)
{
    vis[u] = true;
    int ans = 1;
    for (auto v : g[u])
    {
        if (!vis[v.first])
            ans += dfs(v.first);
    }
    return ans;
}
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        ll n, m, x, y;
        cin >> n >> m;
        for (int i = 0; i < m; i++)
        {
            cin >> x >> y;
            x--, y--;
            if (!g[x].count(y))
                g[x][y]++;
            if (!g[y].count(x))
                g[y][x]++;
        }
        int count = 0;
        int ans = 0;
        memset(vis, false, sizeof(vis));
        for (int i = 0; i < n; i++)
        {
            if (!vis[i] && g[i].size() > 0)
            {

                count++;
                int temp = dfs(i);
              //  cout << "i " << i << " temp " << temp << endl;
                ans = max(ans, temp);
            }
        }
       // cout << " count " << count << endl;
       // ans = max(ans, count);
        if (ans == 0)
            ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 39656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d%d%d", &a,&b, &c);
  
  
  if(a+b+c>21) printf("bust");
  else printf("win");
  
return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        if (n % 500 <= a)
            System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 22356
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] input = sc.next().toCharArray();
		int[] counts = new int[3];
		for (char c : input) {
			counts[c - 'a']++;
		}
		Arrays.sort(counts);
		if (counts[2] - counts[0] > 1) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


Measured memory_bytes: 25168
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int k;
    cin >> k;
    set<int> ms;
    int ans = 0;
    int v = 7;
    while(true)
    {
        ans++;
        auto m = v % k;
        if(m == 0)
        {
            break;
        }
        if(ms.find(m) != ms.end())
        {
            ans = -1;
            break;
        }
        ms.insert(m);
        v = v * 10 + 7;
        v %= k;
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
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();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void dfs(int k, int color, unordered_map<int, unordered_map<int, int> >& links, vector<int>& colors) {
    if (colors[k] != -1) return;
    colors[k] = color;

    for (const auto link : links[k]) {
        if (link.second % 2 == 0) {
            dfs(link.first, color, links, colors);
        } else {
            dfs(link.first, 1 - color, links, colors);
        }
    }
}

void solve(const int N, unordered_map<int, unordered_map<int, int> >& links) {
    vector<int> colors(N+1,-1);
    REP(i,1,N+1) {
        dfs(i, 0, links, colors);
    }

    REP(i,1,N+1) {
        cout << colors[i] << '\n';
    }

    return;
}

signed main() {
    int N;
    cin >> N;
    unordered_map<int, unordered_map<int, int> > links;
    REP(i,0,N-1) {
        int u,v,w;
        cin >> u >> v >> w;
        links[u][v] = w;
        links[v][u] = w;
    }
    solve(N, links);
    
    return 0;
}



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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	int n, m;
	cin >> n >> m;

	vi d(n + 1);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;

		d[a]++; d[b]++;
	}

	for (int i = 1; i <= n; i++) {
		if (d[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

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

    int sum = 1;
    int fsum = 1;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'a' && sum <= a + b)
        {
            sum++;
            cout << "Yes" << endl;
        }
        else if (s[i] == 'b' && sum <= a + b && fsum <= b)
        {
            sum++;
            fsum++;
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 896
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main
{
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        List<List<Integer>> list=new ArrayList<List<Integer>>();
        List<Integer> node;
        for(int i=0;i<n;i++)
          {
           node=new ArrayList<Integer>();
           for(int j=0;j<3;j++)
              node.add(sc.nextInt());
            sc.nextLine();
            list.add(node);
          }
        for(int i=1;i<n;i++)
        {
            list.get(i).set(0,list.get(i).get(0)+(int)Math.max(list.get(i-1).get(1),list.get(i-1).get(2)));
            list.get(i).set(1,list.get(i).get(1)+(int)Math.max(list.get(i-1).get(0),list.get(i-1).get(2)));
            list.get(i).set(2,list.get(i).get(2)+(int)Math.max(list.get(i-1).get(0),list.get(i-1).get(1)));
        }
        System.out.println((int)(Math.max(list.get(n-1).get(0),(int)Math.max(list.get(n-1).get(1),list.get(n-1).get(2)))));
        sc.close();
    }
}

Measured memory_bytes: 77048
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  vector<int> num(n) ;
  REP(i,n){
    cin >> num.at(i) ;
  }
  int ans = 0 ;
  REP(i,n-1){
    FOR(j,i+1,n){
      ans += num.at(i)*num.at(j) ;
    }
  }
  
  cout << ans <<endl ;


  return 0 ;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int A,B,C;
  cin >> A >> B >> C;
  if(A == B && A != C)
  {
    cout << "Yes" << endl;
  }
   else if(A == C && A != B)
  {
    cout << "Yes" << endl;
  }
   else if(C == B && A != C)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
   
}


Measured memory_bytes: 3640
// ABC167D - Teleporter

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N;
	ull K;
	cin >> N >> K;
	int A[N+1];
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	int ans = 1;
	ull count = 0;
	int m[N+1] = {0};

	if (A[1] == 1) {
		cout << 1 << endl;
		return 0;
	}

//	cout << "K=" << K << endl;

	while (1) {
		++count;
		ans = A[ans];

//		cout << count << ":" << ans << endl;

		if (count >= K) {
			cout << ans << endl;
			return 0;
		}

		if (m[ans] == 0) {
			m[ans] = count;
		} else {
			count += (K - count)/(count - m[ans])*(count - m[ans]);
//			cout << count << ":" << ans << endl;
			if (count >= K) {
				cout << ans << endl;
				return 0;
			}
			while (1) {
				++count;
				ans = A[ans];

//				cout << count << ":" << ans << endl;

				if (count >= K) {
					cout << ans << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 5232
import java.util.Scanner;
  
class Node {
    static Node root;
  
    int key;
    Node left;
    Node right;
  
    Node(int key) {
        this.key = key;
    }
  
    void insert() {
        Node y = null;
        Node x = root;
        while(x != null) {
            y = x;
            if(key < x.key) x = x.left;
            else x = x.right;
        }
  
        if(y == null) root = this;
        else if(key < y.key) y.left = this;
        else y.right = this;
    }
  
    static String inorder(Node x) {
        String str = "";
        if(x == null) return str;
  
        if(x.left != null) str += inorder(x.left);
        str += " " + x.key;
        if(x.right != null)str += inorder(x.right);
  
        return str;
    }
  
    static String preorder(Node x) {
        String str = "";
        if(x == null) return str;
  
        str += " " + x.key;
        if(x.left != null) str += preorder(x.left);
        if(x.right != null) str += preorder(x.right);
  
        return str;
    }
}
  
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
   
        Node.root = null;
        int m = sc.nextInt();
        for(int i = 0; i < m; i++) {
            String cmd = sc.next();
            if(cmd.equals("insert")) {
                new Node(sc.nextInt()).insert();
            }else {
                System.out.println(Node.inorder(Node.root));
                System.out.println(Node.preorder(Node.root));
            }
        }
  
        sc.close();
    }
}


Measured memory_bytes: 576680
k = int(input())

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

tmp = 7%k
i = 1
while True:
    if tmp == 0:
        print(i)
        exit()
    tmp = (tmp*10 + 7)%k
    i += 1

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)
vector<int> divv;

int main(void)
{
    ll x;
    cin >> x;
    divv.push_back(2);
    for(int i = 2; i  < x; i ++ ){
        bool db = true;
        for(auto itr = divv.begin(); itr != divv.end(); itr++) {
            if(i % *itr == 0) {
                db = false;
                break;
            }
        }
        if(db) {
            divv.push_back(i);
        }
    }

    while(1) {
        bool find_d = true;
        for(auto itr = divv.begin(); itr != divv.end() && *itr < x; itr++) {
//            cout << "*" << *itr << "(" << x << ")";
            if(x % *itr == 0) {
                find_d = false;
                break;
            }
        }
//        cout << endl;
        if(find_d) {
            break;
        }
        ++x;
    }
    cout << x << endl;
}


Measured memory_bytes: 384
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    K = int(input())
    ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    que = deque(ans)
    for _ in range(9):
        que_new = deque()
        while que:
            i = que.popleft()
            i_ = i%10
            i_new = i*10+i_
            if i_ != 0:
                ans.append(i_new-1)
                que_new.append(i_new-1)
            ans.append(i_new)
            que_new.append(i_new)
            if i_ != 9:
                ans.append(i_new + 1)
                que_new.append(i_new + 1)
        que = que_new
    print(ans[K-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 54768
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  string s,t;
  cin>>s>>t;
  int sz = s.length();
  int tz = t.length();
  if(tz!=sz){
    cout<<"No";
    return 0;
  }
  vector<int> als[26];
  rep(i,sz){
    int num = s[i]-'a';
    als[num].push_back(i);
  }

  rep(i,26){
  if(als[i].empty()) continue;
  char pre = t[als[i][0]]; 
  for(auto b: als[i]){
    if(t[b]!=pre){
      cout<<"No";
      //cout<<t[b]<<pre<<endl;
      return 0;
    }
  }
  }
  vector<int> als2[26];
  rep(i,sz){
    int num = t[i]-'a';
    als2[num].push_back(i);
  }

  rep(i,26){
  if(als2[i].empty()) continue;
  char pre = s[als2[i][0]]; 
  for(auto b: als2[i]){
    if(s[b]!=pre){
      cout<<"No";
      return 0;
    }
  }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 2824
import scala.math._

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(true) {
      val a = new Array[Int](5)
      a(0) = sc.nextInt()
      if(a(0) == 0) {
        return
      }

      for(i <- 1 until 5) {
        a(i) = sc.nextInt()
      }
      val b = a.toSet match {
        case s if s == Set(1,2,3) => Map(1 -> 3, 2 -> 3, 3 -> 3)
        case s if s == Set(1) => Map(1 -> 3, 2 -> 3, 3 -> 3)
        case s if s == Set(2) => Map(1 -> 3, 2 -> 3, 3 -> 3)
        case s if s == Set(3) => Map(1 -> 3, 2 -> 3, 3 -> 3)
        case s if s == Set(1,2) => Map(1 -> 1, 2 -> 2)
        case s if s == Set(2,3) => Map(2 -> 1, 3 -> 2)
        case s if s == Set(3,1) => Map(3 -> 1, 1 -> 2)
      }
      a.map(b).foreach(println)
    }
  }
}

Measured memory_bytes: 46984
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
締切が早い順にとりかかる
*/

ll n,ti=0;
bool ok=true;
pair<ll,ll> t[200010];

void init(){
	cin>>n;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		t[i]={b,a};
	}
	sort(t,t+n);
}

int main(void){
	init();
	rep(i,n){
		ll b=t[i].first, a=t[i].second;
		if(ti+a<=b){
			ti+=a;
		}else{
			ok=false;
			break;
		}
	}
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt(), w = inp.nextInt();
            long[] dp = new long[100001]; // minimum weight required for value
            Arrays.fill(dp, Long.MAX_VALUE);
            dp[0] = 0;
            for (int i = 0; i < n; i++) {
                int weight = inp.nextInt(), value = inp.nextInt();

                long[] dp2 = new long[100001];
                System.arraycopy(dp, 0, dp2, 0, 100001);

                for (int j = 0; j + value <= 100000; j++) {
                    if (dp[j] != Long.MAX_VALUE) {
                        dp2[j+value] = Math.min(dp[j+value], dp[j] + weight);
                    }
                }
                dp = dp2;
            }
            long res = 0;
            for (int i = 0; i <= 100000; i++) {
                if (dp[i] <= w) res = Math.max(res, i);
            }
            out.print(res);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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


Measured memory_bytes: 58836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+5;
int N,M;
int dp[1002][1<<15];
bool v[1<<15];
int main(){

    memset(dp,0x3f,sizeof dp);
    dp[0][0]=0;
    v[0]=1;
    scanf("%d%d",&N,&M);
    for(int i=1;i<=M;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    int s=0;
    for(int j=1;j<=b;j++){
        int c;
        scanf("%d",&c);
        c--;
        s|=1<<c;
    }

    for(int j=0;j<(1<<N);j++)
        dp[i][j]=dp[i-1][j];

    for(int j=0;j<(1<<N);j++){
        if(v[j]){

        v[j|s]=1;
        dp[i][j|s]=min(dp[i][j|s],dp[i-1][j]+a);

        }
    }

    }

    int ans = dp[M][(1<<N)-1];
    if(!v[(1<<N)-1])ans=-1;
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 131936
import sys
input = sys.stdin.readline
import numpy as np

n = int(input())

AA = [int(a) for a in input().split()]
c = 0
updwn=[None]*(n-1)
for a in AA:
    if c ==0:
        c +=1
        base = a
        continue
    if a - base >= 0:
        updwn[c-1] = True
        base = a
    else:
        updwn[c-1] = False
        base = a
    c += 1
updwn+=[False, False]
base = False
total = 1000
stock = 0

for i in range(n):
    if updwn[i] == True and base == False:
        tdcost= AA[i]
        stock = total // tdcost
        base_cost = tdcost
    elif updwn[i-1] == True and updwn[i]==False:
        tdcost=AA[i]
        total += (tdcost - base_cost)*stock
        stock = 0
    else:
        pass
    base = updwn[i]
print(total)


Measured memory_bytes: 27024
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,i;
	cin>>n>>m;
	multiset<int> r;
	for(i=0;i<n;i++)
	{
		int x;cin>>x;
		r.insert(x);
	}
	while(m)
	{
		auto it=prev(r.end(),1);
		r.insert((*it)/2);
		r.erase(it);
		m--;
	}
	int o=0;
	for(auto it=r.begin();it!=r.end();it++)
		o+=*it;
	cout<<o<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  cin >> a >> b;
  if (a > b)
    cout << a - 1 << endl;
  else
    cout << a << endl;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($H,$W) = explode(" ",trim(fgets(STDIN)));
//$A  = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$H;$i++) {
  $S[] = trim(fgets(STDIN));
}
for($i=0;$i<$W;$i++) {
  for($j=0;$j<$H;$j++) {
    if (chk($i,$j)==false) {
      printf("No\n");
      exit;
    }
  }
}
printf("Yes\n");

//上下左右を見て一つだけ黒のマスがあるとNG?
function chk($x,$y) {
  global $S,$H,$W;
  if ($S[$y][$x]!='#') {
    return true;
  }
  $cnt =1;
  if (isset($S[$y][$x-1]) && $S[$y][$x-1]=='#') {
    $cnt++;
  }
  if (isset($S[$y][$x+1]) && $S[$y][$x+1]=='#') {
    $cnt++;
  }
  if (isset($S[$y-1][$x]) && $S[$y-1][$x]=='#') {
    $cnt++;
  }
  if (isset($S[$y+1][$x]) && $S[$y+1][$x]=='#') {
    $cnt++;
  }
  if ($cnt == 1) return false;
  return true;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    vector<long long> x, v, fwd, rev, foo, goo;
    long long c, ans = 0;
    cin >> n >> c;
    x.assign(n+2, 0);
    v.assign(n+2, 0);
    fwd.assign(n+2, 0);
    rev.assign(n+2, 0);
    foo.assign(n+2, 0);
    goo.assign(n+2, 0);


    for(int i=1;i<=n;i++){
        cin >> x[i] >> v[i];
    }
    for(int i=1;i<=n;i++){
        fwd[i] = v[i] - x[i] + x[i-1] + fwd[i-1];
        goo[i] = max(fwd[i], goo[i-1]);
    }
    x[n+1] = c;
    for(int i=n;i>=1;i--){
        rev[i] = v[i] - x[i+1] + x[i] + rev[i+1];
        foo[i] = max(rev[i], foo[i+1]);
    }
    for(int i=0;i<=n;i++){
        long long res = fwd[i];
        ans = max(ans, res);
        res += foo[i+1] - x[i];
        ans = max(ans, res);
    }
    for(int i=n+1;i>=1;i--){
        long long res = rev[i];
        ans = max(ans, res);
        res += goo[i-1] + x[i] - c;
        ans = max(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
def f(n):
  if n%2==1:
    return 3*n+1
  else:
    return n//2

a=int(input())
L=[a]
b=1
while True:
  L.append(f(L[len(L)-1]))
  S=list(set(L))
  if len(L)==len(S):
    b+=1
  else:
    print(b+1)
    break
  

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

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


Measured memory_bytes: 3620
function Main(input) {
    input = input.split('\n')
    input.pop()
    var s = input[0]
    if (s.slice(0, 4) === 'YAKI')
        console.log('Yes')
    else
        console.log('No')

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8652
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define 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()
int n, i;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>i;
    

    cout << n-i+1 << "\n";
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int dice=0,goal=0;
  int ans=0;
  scanf("%d",&dice);
  scanf("%d",&goal);
  int i=1;
  while(i<goal){
    i*=2;
  }
  for(int j=1;j<=dice;j++){
    int tmp=j;
    int son=i;
    while(tmp<goal){
      tmp*=2;
      son/=2;
    }
    ans+=son;
  }
  printf("%.10f",(double)ans/(i*dice));
  return 0;
}

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

struct Node{
    int num,flag;
};

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    vector<int> graph[9];
    for(int i=0;i<m;++i){
        int a,b;
        scanf("%d %d",&a,&b);
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int cnt = 0;
    for(int i=0;i<graph[1].size();++i){
        queue<Node> que;
        que.push((Node){graph[1][i],1});
        while(!que.empty()){
            Node now = que.front();que.pop();
            if(now.flag & (1<<(now.num-1)))continue;
            if((now.flag | (1<<(now.num-1))) == ((1<<n)-1)){
                ++cnt;
                continue;
            }
            for(int j=0;j<graph[now.num].size();++j){
                que.push((Node){graph[now.num][j],now.flag|(1<<(now.num-1))});
            }
        }
    }
    printf("%d\n",cnt);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int total = 0;
  if(n <= k){
    total = n*x;
  } else {
    total = k*x + (n-k)*y;
  }
  cout << total << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, M;
map<ll, ll> now;
vector<VL> A;
VL Aidx;
vector<bool> stop;

int main() {
    cin >> N >> M;
    A.resize(N);
    Aidx.resize(N);
    stop.resize(M);
    REP(i, N) REP(j, M) { A[i].push_back(IN()); }
    ll ans = N;
    REP(loop, M - 1) {
        ll most = 0, tmp = 0;
        REP(i, N) { now[A[i][Aidx[i]]]++; }
        REP(i, N) {
            if(now[A[i][Aidx[i]]] > tmp) {
                most = A[i][Aidx[i]];
                tmp = now[A[i][Aidx[i]]];
            }
        }
        ans = min(tmp, ans);
        stop[most] = true;
        REP(i, N) {
            while(stop[A[i][Aidx[i]]] && Aidx[i] < M - 1) {
                Aidx[i]++;
            }
        }
        now.clear();
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  switch(n%10)
  {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout<<"hon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<<"pon";
      break;
    case 3:
      cout<<"bon";
      break;
    
  }
	return 0;
}

Measured memory_bytes: 3576