akhauriyash/Code-Regression huggingface dataset:
/*input
4 3
1 2 3 4
1 3
2 3
2 4


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;

vector<vector<int>> graph;
vector<bool> visited;

int dfs(int s,vector<int> &arr){
	int ans = 0;
	for(auto i:graph[s]){
		if(arr[i]>=arr[s]){
			ans--;
			break;
		}
	}
	ans++;
	return ans;
}
int32_t main() {
    IOS;
	int n,m;
	cin>>n>>m;;
	graph.clear();
	visited.clear();
	graph.resize(n+1);
	visited.resize(n+1);
	fill(visited.begin(),visited.end(),false);
	vector<int> arr(n+1);
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	while(m--){
		int u,v;cin>>u>>v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans += dfs(i,arr);
	}
	cout<<ans<<endl;
	return 0;
}






Measured memory_bytes: 9772
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
#define F first
#define S second
const int INF=1000000000;

const int MAX_V=5001;
int cost[MAX_V][MAX_V];
int cnt[MAX_V][MAX_V];
vector<int> e[MAX_V];
P t[MAX_V];
int n,k;
bool used[MAX_V];
int d[MAX_V];

void hoge(int s,int now,int C,int R,bool f[],int cnt){
	if(R==cnt) return;
	for(int i=1; i<=n; ++i){
		if(!f[i]&&e[now][i]){
			f[i]=true;
			cost[s][i]=C;
			hoge(s,i,C,R,f,cnt+1);
			f[i]=false;
		}
	}
}

int main(){
	cin >> n >> k;
	clock_t t1,t2,t3,t4;
	memset(e,0,sizeof(e));
	for(int i=1; i<=n; ++i){
		int c,r;
		cin >> c >> r;
		t[i].F=c;
		t[i].S=r;
	}
	for(int i=1; i<=k; ++i){
		int a,b;
		cin >> a >> b;
		//e[a][b]=e[b][a]=true;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=n; ++j){
			cost[i][j]=INF;
			cnt[i][j]=INF;
			if(i==j) cost[i][j]=0;
		}
	}
	
	for(int i=1; i<=n; ++i){
		bool f[MAX_V];
		memset(f,0,sizeof(f));
		f[i]=true;
		queue<int> que;
		que.push(i);
		cnt[i][i]=0;
		while(que.size()){
			int now=que.front();
			que.pop();
			for(int j=0; j<e[now].size(); ++j){
				if(!f[e[now][j]]&&cnt[i][now]+1<=t[i].S){
					que.push(e[now][j]);
					cnt[i][e[now][j]]=cnt[i][now]+1;
					f[e[now][j]]=true;
				}
			}
		}
	}
	
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=n; ++j){
			if(cnt[i][j]!=INF&&i!=j) cost[i][j]=t[i].F;
			//cout << cost[i][j] << " ";
		}
		//cout << "\n";
	}
	
	memset(used,0,sizeof(used));
	fill(d,d+n+1,INF);
	d[1]=0;
	while(true){
		int v=-1;
		for(int u=1; u<=n; ++u){
			if(!used[u]&&(v==-1||d[v]>d[u])) v=u;
		}
		if(v==-1) break;
		used[v]=true;
		for(int u=1; u<=n; ++u){
			d[u]=min(d[u],d[v]+cost[v][u]);
		}
	}
	cout << d[n] << "\n";
	
	return 0;
}

Measured memory_bytes: 197008
import Control.Monad

main :: IO ()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Int]
  print $ solve' n k

solve :: Int -> Int -> Int
solve n k = length $ filter (validate k) (replicateM 3 [1..n])
  where validate k a = (a !! 0 + a !! 1) `mod` k == 0 && (a !! 1 + a !! 2) `mod` k == 0 && (a !! 2 + a !! 0) `mod` k == 0

solve' n k
  | k `mod` 2 == 1 = m^3 -- odd
  | otherwise = m^3 + p^3
    where
      m = n `div` k
      p = if n `mod` k < k `div` 2
          then m
          else m + 1


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


int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    vector<int> x(M), y(M), c(M);
    rep(i, M) cin >> x[i] >> y[i] >> c[i];

    int mini = INF;
    rep(i, M){
        int price = 0;
        price = a[x[i]-1] + b[y[i]-1] - c[i];
        mini = min(mini, price);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    mini = min(mini, a[0] + b[0]);
    cout << mini << endl;
    return 0;

}


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

int main() {
  string s;
  long k;
  cin >> s >> k;

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

  int idx = 0;
  while (idx < k-1) {
    if (s[idx] == '1') idx++;
    else break;
  }
  cout << s[idx] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#define ll long long
#define rep(i, a, b) for (int i = a; i <= (int)b; i ++)
#define per(i, a, b) for (int i = (int)a; i >= b; i --)
template < typename T > void read(T & x) {
    x = 0; int flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 5010;
const int mod = 1e9 + 7;
int n, sz[maxn], dp[maxn][maxn], tmp[maxn], g[maxn];
vector < int > e[maxn];
void dfs(int u, int fa) {
    sz[u] = 1, dp[u][1] = 1;
    rep(i, 0, e[u].size() - 1) if(e[u][i] != fa) {
        int v = e[u][i];
        dfs(v, u);
        rep(j, 0, sz[u]) {
            tmp[j] = dp[u][j];
            dp[u][j] = 0;
        }
        rep(j, 0, sz[u]) rep(k, 0, sz[v])
            dp[u][j + k] = (dp[u][j + k] + 1ll * dp[v][k] * tmp[j] % mod) % mod;
        sz[u] += sz[v];
    }
    for(int i = 0; i <= sz[u]; i += 2)
        dp[u][0] = (dp[u][0] - 1ll * dp[u][i] * g[i] % mod + mod) % mod;
}
int main()
{
    read(n);
    rep(i, 1, n - 1) {
        int u, v;
        read(u), read(v);
        e[u].push_back(v), e[v].push_back(u);
    }
    g[0] = 1;
    for(int i = 2; i <= n; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
    dfs(1, 0);
    printf("%d\n", mod - dp[1][0]);
    return 0;
}

Measured memory_bytes: 97536
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
using namespace std;

int main(){
	vector <int*> p;
	vector <int> c;
	int k, i, n[9], count = 0;
	{
		int Flags = 0, digit;
		for (k = 0; k < 9; k++){
			digit = 1;
			cin >> n[k];
			if (n[k] != -1){
				for (i = 0; i < n[k] - 1; i++) digit *= 2;
				Flags += digit;
			}
			else{
				p.push_back(&n[k]);
			}
		}
		digit = 1;
		for (k = 0; k < 9; k++){
			if ((Flags&digit) == 0) c.push_back(k + 1);
			digit *= 2;
		}
	}
	do{
		for (k = 0; k < (int)c.size(); k++) *p[k] = c[k];
		if ((n[0] + n[2] + n[5]) % 10 == n[8]){
			if ((((n[0] + n[2] + n[5]) / 10) + n[1] + n[4]) % 10 == n[7]){
				if (((((n[0] + n[2] + n[5]) / 10) + n[1] + n[4]) / 10) + n[3] == n[6]){
					count++;
				}
			}
		}
	} while (next_permutation(c.begin(), c.end()));
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int l, r;
        int sit = 0;
 
        for(int i = 0; i < N; i++){
            l = sc.nextInt();
            r = sc.nextInt();
            sit = sit + r - l + 1;
        }
 
        System.out.println(sit);
        
    }
}

Measured memory_bytes: 25832
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	sort(a,a+n);
	if((4*m*a[n-m])>=sum){
		printf("Yes\n");
	}else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b, c) = (v[0], v[1], v[2]);
    let ans = max(0, c - (a - b));
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
*g=s=1
gets.to_i.times{h=[s=k=0]*256
g.map{|v|(k...k+=4).map{|a|h[a%=256]-=s-s+=a.to_s(4)=~/1.?2.?3|213|132/?0:v}}
g=h}
p s.%10**9+7

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	map<int,int>m;
	m[a]=1;
	m[b]=1;
	for(int i=1;i<=3;i++)
		if(m[i]==0){
			printf("%d\n",i);
			break;
		}
	return 0;
} 

Measured memory_bytes: 256
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7


h1, m1, h2, m2, k = multi_int_input()

start = (h2 - h1)*60 + m2-m1

print(start - k)

Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,a,b; cin>>n>>a>>b;
    if((b-a)%2==0) cout<<(b-a)/2<<endl;
    else{
        ll res=min(a+(b-a-1)/2,n-b+1+(b-a-1)/2);
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	int d,r;
	
	double f;
	
	d=a/b;
	
	r=a%b;
	
	f=(double)a/(double)b;
	
	printf("%d %d %f\n",d,r,f);
	
	return 0;
	
}

Measured memory_bytes: 636
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        long k = sc.NextInt();
        long a = sc.NextInt();
        long b = sc.NextInt();

        // aまで増やす
        // a - 1yen
        // 1yen - b

        long ans = k + 1;

        if (a + 1 < b)
        {
            // aまで増やす
            if (a - 1 < k)
            {
                long d = k - (a - 1);
                long tmp = a + (d / 2) * (b - a);

                if (d % 2 == 1) tmp++;
                ans = Math.Max(ans, tmp);
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    rep2(i, 1, N){
        if(i%3 && i%5) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
const int N=105;
int n;
double ans,A[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lf",&A[i]);
		ans+=1.0/A[i];
	}
	printf("%.6lf",1.0/ans);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int arr[n];
  
  for(int i=0;i<n;i++)
    cin >> arr[i] ;
  
  int dp[n]={0};
  
for(int i=0;i<n;i++){
  int val=INT_MAX;
  for(int j=i-1;j>=0 && i-j<=k ;j--){
    val=min(val,dp[j]+abs(arr[i]-arr[j]));
  }
  if(val==INT_MAX)
    val=0;
  dp[i]=val ;
}
  
  cout<<dp[n-1];
  
  
  return 0;
}


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

bool dfs(int, int);
bool dfs2( int, int, const int, const int, int);

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


bool dfs2(int x, int y, const int basex, const int basey, int sub){


  if(sub < 0) return false;
  if(sub == 0) return dfs( basex + 1, basey);

  Rep(i,4){
    int ny = y + dy[i], nx = x + dx[i];
    if(ny < 0 || ny >= n || nx < 0 || nx >= n || number[ny][nx] <= 0) continue;
    int next = number[ny][nx];
    number[ny][nx] = 0;
    if(dfs2( nx, ny, basex, basey, sub - next)) return true;
    number[ny][nx] = next;
  }
  return false;
}

bool dfs(int x, int y){

  if(y == n){
    Rep(i,n) Rep(j,n) if(number[i][j] != 0) return false;
    return true;
  }
  if(x == n) return dfs( 0, y + 1);
  if(number[y][x] >= 0) return dfs( x + 1, y);
  else{
    int prev = number[y][x];
    number[y][x] = 0;
    if(dfs2( x, y, x, y, -prev)) return true;
    number[y][x] = prev;
  }
  return false;
}

int main(){
  while(cin >> n, n){

    int ret = 0;
    
    Rep(i,n){
      Rep(j,n){
        cin >> number[i][j];
        ret += number[i][j];
      }
    }
    if(ret == 0 && dfs(0,0)) puts("YES");
    else puts("NO");
  }
}

Measured memory_bytes: 1116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
#include <climits>
#include <iomanip>

#define EPS 1e-7
#define LLMAX 9223372036854775807
#define INTMAX 2147483647
#define ULLMAX 18446744073709551615
#define precision(n) cout << setprecision(n) << fixed
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rforr(i, t, n) (int i = n-1; i>=t; --i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1024;

//STRUCTS


//OPERATORS


//GLOBALS


//FUNCTIONS


//PROBLEM: 
//LINK: 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
		int n;
		cin >> n;
		int a[n];
		forn(i,n)
		{
			cin >> a[i];
		}
		int ans = 0;
		forn(i, n)
		{
			forr(j, i+1, n)
			{
				ans+= (a[i]*a[j]);
			}
		}
		cout << ans;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  double n;
  cin >> n;
  cout << (n-int(n/2))/n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 500010

using namespace std;

int n;
int a, b;
int ans, mn;
int vis[10];

int main()
{
	cin >> n;
	
	for(int i=1; i <= n; i++) {
		cin >> b;
		if(b < 3200)
			vis[b/400+1] = 1;
		else
			a++;
	}
	
	for(int i=1; i <= 8; i++) {
		if(vis[i] == 1)
			ans++, mn++;
	}
	
	cout << (mn==0?1:mn) << " " << mn+a;
}

Measured memory_bytes: 256
# k の分 x を含んだ隣り合わせの数字を出力　(負の数も含む)
k,x = gets.split.map(&:to_i)
x2 = x

ans = []
(k).times do
  ans << x
  x -=1
end

(k-1).times do 
  x2 += 1
  ans << x2
end

puts ans.sort.join(' ')

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOSF ios::sync_with_stdio(false)
typedef long long LL;
using namespace std;
const int INF=0x3f3f3f3f;
const int MAX=10e6+5;
const int MOD=10e9+7;



int main()
{
    IOSF;
    int a,b;
    cin>>a>>b;
    if(a<=b)
        cout<<a<<endl;
    else
        cout<<a-1<<endl;
    return 0;
}
/*
7 5 3
*****
*...*
*****
*..**
*****
*.***
*****
4 4 0
****
*...
*.**
*.**
*/



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    string s;cin>>s;
    set<string> s1,s2,s3;
    rep(i,n){
        string t="";
        t+=s[i];
        for(auto k:s2){
            s3.insert(k+t);
        }
        for(auto k:s1){
            s2.insert(k+t);
        }
        s1.insert(t);
    }
    cout<<s3.size()<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

void visit(int);
int dequeue(void);
void enqueue(int);

int map[101][101];
int Q[101],n,head=0,tail=0,color[101],d[101];
int main()
{
  int i,j,v,vv,m,u,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    color[i]=0;
    for(j=0;j<n;j++){
      map[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&m);
    for(j=0;j<m;j++){
      scanf("%d",&vv);
      map[v-1][vv-1]=1;
    }
  }

  for(j=0;j<n;j++){
    if(map[0][j]==1){
      color[j]=0;
    }
  }
  color[0]=1;
  d[0]=0;
  enqueue(0);
  while(head!=tail){
    u=dequeue();
    for(k=0;k<n;k++){
      if(map[u][k]==1 && color[k]==0){
	color[k]=1;
	d[k]=d[u]+1;
	enqueue(k);
      }
      color[u]=2;
    }
  }
  

  
  for(i=0;i<n;i++){
    if(color[i]==2)printf("%d %d\n",i+1,d[i]);
    else printf("%d -1\n",i+1);
  }
  return 0;
}

int dequeue()
{
  int x;
  x=Q[head];
  if(head+1==100)head=0;
  else head=head+1;
  return x;
}

void enqueue(int x)
{
  Q[tail]=x;
  if(tail+1==100)tail=0;
  else tail=tail+1;
}

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

int main()
{
  int64_t N,M ;
  cin>>N>>M ;
  
  int64_t num=0 ;
  if(2*N<M){
    num+=N ;
    num+=(M-2*N)/4 ;
  }else if(2*N==M) num+=N ;
  else{ 
    num+=M/2 ;
  }
  
  cout<<num<<endl ;
  return 0 ;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
        int prev=0;
		int ans=0;
		int max=0;
		for(int i=0;i<n;i++)
		{
			int curr=in.nextInt();
			if(curr<=prev)
			{
				prev=curr;
				ans++;
			}
			else
			{
				if(ans>max)
					max=ans;
				prev=curr;
				ans=0;
			}
		}
		max=Math.max(ans,max);
		System.out.println(max);
	}
}
	

Measured memory_bytes: 48808
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuple (x : y : _) = (x, y)

main = do
    n <- getInt
    xyss <- replicateM n $ do
        a <- getInt
        xys <- map toTuple <$> replicateM a getIntList
        return xys
    let bss = sequence $ replicate n [False, True]
    print . maximum $ map (length . filter id) [bs | bs <- bss, and (map (check bs) (zip bs xyss)) ]

check bs (b, xys) | b = and $ map (\(x, y) -> bs !! (x - 1) == (y == 1)) xys
                  | otherwise = True

Measured memory_bytes: 4220
#include <iostream>
using namespace std;
int main(){
	int n , m;
	int s[100000] , t[50000];
	cin >> n;
	for( int i=0 ; i<n ; i++ )
		cin >> s[i] ;
	cin >> m;
	for( int i=0 ; i<m ; i++ )
		cin >> t[i] ;
	int count=0;
	for( int i=0 ; i<m ; i++ ){
		int right=n , left=0;
		int mid;
		while(left<right){
			mid=(right+left)/2;
			//cout<< left <<"   " << mid <<"  " << right << endl;
			if( t[i] < s[mid] )
				right=mid;
			else if( t[i] > s[mid] )
				left=mid+1;
			else{
				count++;
				break;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3692
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

int N, M;
int Msum = 0;

int main() {
    cin >> N >> M;
    REP(i, M) {
        int tmp;
        cin >> tmp;
        Msum += tmp;
    }
    cout << to_string((N - Msum >= 0) ? N - Msum : -1) << endl;
}

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

int main() {
  string s[3];
  for (int i = 0; i < 3; i++){
    cin >> s[i];
  }
  
  for(int i = 0; i < 3; i++){
    cout << s[i].at(0);
  }
  cout << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const ll MAX_P = 90000000000;
ll N, A, B;

int main(){
  cin >> N >> B >> A;
  if(A + B - 1 > N || A * B < N) {
    cout << -1 << endl;
    return 0;
  }
  if(B == 1) {
    REP(i, N) {
      cout << N - i << " ";
    }
    cout << endl;
    return 0;
  }

  vi p[B];
  int N_ = N - (A + B - 1);
  int num = 1;
  REP(i, B) {
    // cout << i << endl;
    if(i == 0) {
      REP(j, A) {
        p[i].push_back(num);
        num++;
      }
    } else if(i < N_ % (B - 1) + 1) {
      REP(j, N_ / (B - 1) + 2) {
        p[i].push_back(num);
        num++;
      }
    } else {
      REP(j, N_ / (B - 1) + 1) {
        p[i].push_back(num);
        num++;
      }
    }
  }

  REP(i, B) {
    REP(j, p[i].size()) {
      cout << p[i][p[i].size() - j - 1] << " ";
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 16512
mod = 10**9 + 7
P = 500009
Nr = [1 for _ in range(P + 1)]

for i in range(2, P +1):
    Nr[i] = (Nr[i-1] * i)%mod 

Dr = [1 for _ in range(P +1)]
Dr[P]  = pow(Nr[P] , mod - 2 , mod) 

for i in range(P, 0, -1):
    Dr[i-1] = (Dr[i]*i)%mod 
    
def ncr(n,r):
    if n  < r:
        return 0 
    else:
        return ((Nr[n] * Dr[r])%mod * Dr[n-r])%mod
        
def npr(n,r):
    if n<r:
        return 0 
    else:
        return (Nr[n] * Dr[n-r])%mod
        
n,m = map(int, input().split())       
ans = (npr(m,n)**2)%mod 

for i in range(1, n+1):
    ans =  (ans + ((-1)**(i%2)   *  ncr(n,i) %mod   * npr(m,i)%mod   * (npr(m-i, n-i)**2)%mod)%mod)%mod
    
print(ans%mod)

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


 int main()
 {
   int a [10010];
  int n , m ;
  cin >> n >> m ;
    for (int i=0; i < m ; i++) {
      cin >> a[i];
    }
  int s = 0;
   for(int i=0; i < m; i++){
     s += a[i];
   }
  if (s > n) {
   cout << "-1" ;
   }
   else{
   cout << n - s ;
   }
   
 }

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int m = Integer.parseInt(lines[1]);
      int l = Integer.parseInt(lines[2]);
      long[][] mA = new long[n][m];
      long[][] mB = new long[m][l];
      long[][] mC = new long[n][l];

      for(int i = 0; i < n; i++ ) {
        lines = br.readLine().split(" ");
        mA[i] = Stream.of(lines)
                      .mapToLong(Long::parseLong)
                      .toArray();
      }
      for( int i = 0; i < m; i++ ) {
        lines = br.readLine().split(" ");
        mB[i] = Stream.of(lines)
                      .mapToLong(Long::parseLong)
                      .toArray();
      }

      for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < l; j++ ){
          for( int k = 0; k < m; k++ )
          mC[i][j] += mA[i][k] * mB[k][j];
        }
      }

      System.out.println(
        Stream.of(mC)
              .map( a -> ArrayToString(a) )
              .collect(Collectors.joining("\n"))
      );
    }
  }
  public static String ArrayToString(long[] a) {
      if (a == null)
          return "null";
      long iMax = a.length - 1;
      if (iMax == -1)
          return "[]";

      StringBuilder b = new StringBuilder();
      for (int i = 0; ; i++) {
          b.append(a[i]);
          if (i == iMax)
              return b.toString();
          b.append(" ");
      }
  }
}


Measured memory_bytes: 39060
/*
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
ordered_set -> less -> less_equal
ordered_set find_by_order() -> возвращает k-ый элемент(отсчёт с нуля)
ordered_set order_of_key() -> возвращает количество элементов в множестве,строго меньших,чем наш элемент
*/
#include <bits/stdc++.h>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;
using namespace __gnu_pbds;

template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int> > matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=(1ll<<61)-1;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};


int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
	exit(0);
}


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

public class Main {
  private static String solve(int x, int a, int b) {
    if (Math.abs(x - a) < Math.abs(x - b)) {
      return "A";
    } else {
      return "B";
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x = reader.nextInt();
    int a = reader.nextInt();
    int b = reader.nextInt();
    out.println(solve(x, a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 20692
A, B, Q = gets.split(' ')
 
As = A.to_i.times.map { gets.to_i }
Bs = B.to_i.times.map { gets.to_i }
Qs = Q.to_i.times.map { gets.to_i }
 
INF = 10E18
 
As = [-INF] + As + [INF]
Bs = [-INF] + Bs + [INF]
 
Qs.each do |q|
  a = As.bsearch_index { |a| a > q }
  b = Bs.bsearch_index { |b| b > q } 
  puts As[a-1, 2].product(Bs[b-1, 2]).flat_map { |a, b| [(q - a).abs + (a - b).abs, (q - b).abs + (b - a).abs ] }.min
end

Measured memory_bytes: 8044
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a=0,b=0,c=0;
	cin>>s;
	for(int i=0;i<=2;i++){
		if(s[i]=='a') a=1;
		if(s[i]=='b') b=1;
		if(s[i]=='c') c=1;
	}
	if(a==1&&b==1&&c==1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
 string s;
 cin >> s;
 int x1 = stoi(s)/100;
 int x2 = stoi(s)-x1*100;
 
  bool YYMM = (x2>0)&&(x2<13);
  bool MMYY = (x1>0)&&(x1<13);
  
  if ( YYMM && MMYY)
    cout << "AMBIGUOUS";
  if ( YYMM && !(MMYY))
    cout << "YYMM";
   if ( !(YYMM) && MMYY)
    cout << "MMYY";
   if ( !(YYMM) && !(MMYY))
    cout << "NA";
  
  
}


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

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i];
    }

    int dif = INT32_MAX;
    for(int i = 0; i < n; i++) {
        int s1 = 0;
        int s2 = 0;
        for(int j = 0; j <= i; j++) {
            s1 += w[j];
        }
        for(int j = i + 1; j < n; j++) {
            s2 += w[j];
        }

        if(dif > abs(s1 - s2)) {
            dif = abs(s1 - s2);
        }
    }
    print(dif);
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	int cnt = 0;
	for(int i=0;i<n;i++)
	{
		cin >> h[i];
		if(k <= h[i]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;

  Int N = s.size();
  Int c1 = N/2, c2 = N/2;
  if(N%2 == 0) c1--;

  Int ans = 0;
  for(Int i=0;i<N;i++){
    if(c1 - i < 0 || c2 + i>=N) continue;
    if(s[c1-i] != s[c2+i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll h,last=1,ans=0;
	cin>>h;
	while(h){
		ans+=last;
		last*=2;
		h/=2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  int c;
  if(n%2==0){
    c = n/2-1;
  }else{
    c = n/2;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    
    h,w,k = map(int,input().split())
    l = [list(input()) for i in range(h)]

    def check(lis):
        
        num = [0]*(len(lis))
        ans = 0
        for i in range(w):
            num2 = [0]*(len(lis))
            for j in range(h):
                
                if l[j][i] == "1":
                    num2[d[j]] += 1
            if max(num2) > k:
                return float("INF")
            else:
                for i in range(len(num)):
                    num[i] += num2[i]
                    if num[i] > k:
                        ans += 1
                        num = num2
                        break 
            
            
        return ans

    ans = 10**9

    for i in range(2**(h-1)):
        count = 0
        lis1 = []
        d = []
        for j in range(h):
            d.append(count)
            if (i >> j) & 1:
                lis1.append(j)
                count += 1
        lis1.append(count+1)
        ans = min(ans,count+check(lis1))
        
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
        if(N%K==0){
        	System.out.println(0);
        }else{
        	System.out.println(1);
        }
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>
using ll = long long;
using namespace std;
ll N;
int ans;

void dfs(ll n)
{
    if (n > N)
        return;

    bool t = false, f = false, s = false;

    ll temp = n;
    while (temp)
    {
        if (temp % 10 == 3)
            t = true;
        if (temp % 10 == 5)
            f = true;
        if (temp % 10 == 7)
            s = true;
        temp /= 10;
    }
    if (t && f && s)
        ans++;

    dfs(n * 10 + 3);

    dfs(n * 10 + 5);

    dfs(n * 10 + 7);
    return;
}
int main(void)
{
    cin >> N;
    ll n = 0;

    dfs(n + 3);
    dfs(n + 5);
    dfs(n + 7);

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

Measured memory_bytes: 256
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

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

char readc() {
    static char inp[4];
    scanf("%s", inp);
    return *inp;
}

const size_t N = 2e5 + 5;

int n, q;
char s[N], t[N], d[N];

int getPos(int p) {
    for (int i = 0; i < q; ++i) {
        if (s[p] == t[i]) {
            p += d[i] == 'L' ? -1 : 1;
        }
    }
    return p;
}

int main() {
    scanf("%d%d%s", &n, &q, s + 1);
    for (int i = 0; i < q; ++i) {
        t[i] = readc();
        d[i] = readc();
    }
    int lb = 0, rb = n + 1;
    /* calc lb */ {
        int l = 1, r = n, mid;
        while (l <= r) {
            mid = (l + r) >> 1;
            if (getPos(mid)) {
                r = mid - 1;
            } else {
                l = mid + 1; lb = mid;
            }
        }
    } /* calc rb */ {
        int l = 1, r = n, mid;
        while (l <= r) {
            mid = (l + r) >> 1;
            if (getPos(mid) <= n) {
                l = mid + 1;
            } else {
                r = mid - 1; rb = mid;
            }
        }
    }
    cout << max(rb - lb - 1, 0) << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define inf (int)1e9
using namespace std;

#define fi first
#define se second
using P = pair<int, int>;
int d[] = {1, 0, -1, 0};
long long h, w, k;
vector<string> a;
vector<vector<int>> dist;
queue<P> qu;

bool isvalid(const P &p) {
  return p.fi >= 0 && p.fi < h && p.se >= 0 && p.se < w;
}
long long solve();

int main() {
  cin >> h >> w >> k;
  a.resize(h);
  for (int i = 0; i < h; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  dist.assign(h, vector<int>(w, inf));
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (a[i][j] == 'S') {
        a[i][j] = '.';
        qu.push(P(i, j));
        dist[i][j] = 0;
      }
  while (qu.size()) {
    P tmp = qu.front();
    int x = tmp.fi, y = tmp.se;
    qu.pop();
    for (int i = 0; i < 4; ++i) {
      int tx = x + d[i], ty = y + d[1 ^ i];
      if (!isvalid(P(tx, ty)) || a[tx][ty] == '#') continue;
      if (dist[tx][ty] > dist[x][y] + 1 && dist[x][y] + 1 <= k) {
        dist[tx][ty] = dist[x][y] + 1;
        qu.push(P(tx, ty));
      }
    }
  }
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (dist[i][j] <= k) {
        dist[i][j] = 0;
        qu.push(P(i, j));
      }
  while (qu.size()) {
    P tmp = qu.front();
    int x = tmp.fi, y = tmp.se;
    qu.pop();
    for (int i = 0; i < 4; ++i) {
      int tx = x + d[i], ty = y + d[1 ^ i];
      if (!isvalid(P(tx, ty))) continue;
      if (dist[tx][ty] > dist[x][y] + 1) {
        dist[tx][ty] = dist[x][y] + 1;
        qu.push(P(tx, ty));
      }
    }
  }
  int res = 1e9;
  for (int i = 0; i < h; ++i) res = min({res, dist[i][0], dist[i][w - 1]});
  for (int i = 0; i < w; ++i) res = min({res, dist[0][i], dist[h - 1][i]});
  return (res + k - 1) / k + 1;
}

Measured memory_bytes: 8704
i=0
a=0
b=0
c=input()
while i<len(c):
	if c[i]==' ':
		break
	i+=1
s=c[0:i]
s=s.strip()
t=c[i+1:]
t=t.strip()
c=input()
i=0
while i<len(c):
	if c[i]==' ':
		break
	i+=1
aa=c[0:i]
a=int(aa.strip())
bb=c[i+1:]
b=int(bb.strip())
u=input()
if u==s:
	print(a-1,b)
else:
	print(a,b-1)


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[1]=='B') cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
  
  return 0;
}

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

int main() {
  int n, M, h, m;
  set<int> s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h >> m;
    int t = 100 * h + m;
    s.insert(t);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> h >> m;
    int t = 100 * h + m;
    s.insert(t);
  }
  auto itr = s.begin();
  cout << *itr / 100 << ":" << setfill('0') << setw(2) << *itr % 100;
  itr++;
  for (; itr != s.end(); itr++) {
    cout << " " << *itr / 100 << ":" << setw(2) << *itr % 100;
  }
  cout << "\n";
}


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

using ll = long long;

void solve(long long N, long long K, std::vector<long long> A){
    long double ok = 1e18;
    long double ng = 0;
    auto f = [&](long double t){
        int cnt = 0;
        for(int i = 0;i < N;i++){
            cnt += floor(A[i] / t);
        }
        return cnt <= K;
    };
    while(ok - ng > 1e-6){
        long double mid = (ok + ng) /2;
        //cout<<ok<<" "<<ng<<endl;
        if(f(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if(ok - floor(ok) <= 1e-6){
        cout<<(int)floor(ok)<<endl;
    }else{
        cout<<(int)ceil(ok)<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

using namespace std;

int calc(int n,int k) {
  while (n%k!=0) {
  	int t=n/k;
  	n-=(n-t*k+t)/(t+1)*(t+1);
  }
  return n/k;
}

int main() {
  int n;
  scanf("%d",&n);
  int s=0;
  for(int i=1;i<=n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	s^=calc(x,y);
  }
  puts((s)?"Takahashi":"Aoki");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
int const N = 1000000;
ll const MOD = 1e9 + 7;

ll binPow(ll a, ll n) {
    if (n == 1) return a;
    if (n & 1) return (a * binPow(a, n - 1))%MOD;
    ll c = binPow(a, n >> 1) % MOD;
    return (c * c) % MOD;
}

int main()
{
    ll x, y;
    cin >> x >> y;
    ll x0 = (2ll * x - y) / 3ll; 
    ll x1 = (2ll * y - x) / 3ll;
    if ((2ll * x - y) % 3 || (2ll * y - x) % 3 || x0 < 0 || x1 < 0)
    {
        cout << 0;
        return 0;
    }

    ll num = 1;
    for (int i = 1; i <= x0 + x1; i++) {
        num *= i;
        num %= MOD;
    }
    ll den = 1;
    for (int i = 1; i <= x0; i++) {
        den *= i;
        den %= MOD;
    }
    for (int i = 1; i <= x1; i++) {
        den *= i;
        den %= MOD;
    }

    cout << (num * binPow(den, MOD - 2) % MOD) % MOD;
}



Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function
import sys


def main():
    d = set()
    s = sys.stdin.readline().strip()
    for c in s:
        if c in d:
            print("no")
            return
        d.add(c)
    print("yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2692