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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int N; cin >> N;
    REP(i, 50001) {
        if (i * 108 / 100 == N) {
            cout << i << endl; return;
        }
    }
    cout << ":(" << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define MOD (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

int h,w;
char board[410][410];
bool board1[410][410];

bool check1(int i, int j) {
	return (i >= 0) && (i < h) && (j >= 0) && (j < w) && (!board1[i][j])&&(board[i][j]=='#');
}

bool check2(int i, int j) {
	return (i >= 0) && (i < h) && (j >= 0) && (j < w) && (!board1[i][j])&&(board[i][j]=='.');
}

int main(void){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>board[i][j];
		}
	}
	queue<P>que;
	ll ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ll w=0;
			ll b=0;
			if(board1[i][j])continue;
			que.push(P(i,j));
			while(!que.empty()){
				P p=que.front();que.pop();
				int x=p.first;
				int y=p.second;
				if(board1[x][y])continue;
				if(board[x][y]=='.'){
					if(check1(x,y+1))que.push(P(x,y+1));
					if(check1(x,y-1))que.push(P(x,y-1));
					if(check1(x-1,y))que.push(P(x-1,y));
					if(check1(x+1,y))que.push(P(x+1,y));
					w++;
					board1[x][y]=true;
				}
				else{
					if(check2(x,y+1))que.push(P(x,y+1));
					if(check2(x,y-1))que.push(P(x,y-1));
					if(check2(x-1,y))que.push(P(x-1,y));
					if(check2(x+1,y))que.push(P(x+1,y));
					b++;
					board1[x][y]=true;
				}
				//cout<<b<<" "<<w<<endl;
			}
			//cout<<b<<" "<<w<<endl;
			ans+=b*w;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXL=1050;
char s[MAXL];
int cnt[300];

int main() {
	scanf("%s",s);
	for(int i=0;s[i];i++) cnt[(int)s[i]]++;
	for(int i='A';i<='Z';i++) if(cnt[i]>0) cnt[i]=1;
	if(cnt['N']!=cnt['S'] || cnt['W']!=cnt['E']) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s int
	m := make(map[int]int)

	fmt.Scan(&s)

	n := s
	m[s] = 1
	for i := 2; i <= 1000000; i++ {
		var fn int
		if n%2 == 0 {
			fn = n / 2
		} else {
			fn = 3*n + 1
		}
		if _, ok := m[fn]; ok {
			fmt.Println(i)
			break
		}
		m[fn] = i
		n = fn
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
vector<ll> adj[100005];
ll vis[100005];
ll dp[100005];

void dfs(ll u){

    for (auto i = adj[u].begin(); i != adj[u].end(); ++i)
    {
        if(!vis[*i]){
            vis[*i]=true;
            dfs(*i);
        }
        dp[u]=max(dp[u], dp[*i]+1);
    }
}

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n,m;
    cin>>n>>m;

    for (int i = 0; i < m; ++i)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].push_back(b);
    }
    for (int i = 1; i < n+1; ++i)
    {
        vis[i]=false;
        dp[i]=0;
    }

    for (int i = 1; i <=n; ++i)
    {
        if(!vis[i]){
            vis[i]=true;
            dfs(i);
        }
    }

    ll ans=0;
    for (int i = 1; i < n+1; ++i)
    {
        ans=max(ans, dp[i]);
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


string solve(string s,string t){
    int LCS[sz(s)+10][sz(t)+10];
    rep(i,sz(s)+10) rep(j,sz(t)+10) LCS[i][j] = 0;
    rep1(i,sz(s)) rep1(j,sz(t)){
        if(s[i-1]==t[j-1]) LCS[i][j] = max({LCS[i-1][j-1]+1, LCS[i][j-1], LCS[i-1][j]});
        else LCS[i][j] = max({LCS[i-1][j-1], LCS[i-1][j], LCS[i][j-1]});
    }
    string ans = "";
    int i = sz(s);
    for(int j = sz(t); j >= 1; j--){
        if(LCS[i][j] != LCS[i][j-1]) ans += t[j-1], i--;
        if(!i) break;
    }
    reverse(ALL(ans));
    return ans;
    
}

string solve2(string s,string t){
    int LCS[sz(s)+10][sz(t)+10];
    rep(i,sz(s)+10) rep(j,sz(t)+10) LCS[i][j] = 0;
    rep1(i,sz(s)) rep1(j,sz(t)){
        if(s[i-1]==t[j-1]) LCS[i][j] = max({LCS[i-1][j-1]+1, LCS[i][j-1], LCS[i-1][j]});
        else LCS[i][j] = max({LCS[i-1][j-1], LCS[i-1][j], LCS[i][j-1]});
    }
    string ans = "";
    
    int n = sz(s), m = sz(t);
	while (n && m) {
		if (LCS[n - 1][m] == LCS[n][m]) { --n; }
		else if (LCS[n][m - 1] == LCS[n][m]) { --m; }
		else {
			ans += s[n - 1];
			--n, --m;
		}
	}reverse(ALL(ans));
 
    return ans;
    
}


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

Measured memory_bytes: 35712
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ReadLine();
            if (x == "a" || x == "i" || x == "u" || x == "o" || x == "e")
            {
                WriteLine("vowel");
            }
            else
            {
                WriteLine("consonant");
            }
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 13140
/**    Rose's very long and elaborated template    **/

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
long long n, m;
long long fact[200002], inv[200002];
long long pw(long long b, long long e)
{
    long long sol = 1;
    while(e)
    {
        if(e&1)
            sol = (sol * b)%mod;
        b = (b*b)%mod;
        e >>= 1;
    }
    return sol;
}
void build()
{
    fact[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= 200000; ++i)
        fact[i] = (fact[i-1] * i)%mod, inv[i] = pw(fact[i], mod-2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(permutation.begin(), permutation.end(), rng);
    cin>>n>>m;
    build();
    long long sol = 1;
    for(int i = 2; i*i <= m; ++i)
    {
        int cnt = 0;
        if(m % i == 0)
        {
            while(m % i == 0)
                m/=i, ++cnt;
            int N = (n + cnt - 1);
            int K = cnt;
            long long aa = fact[N];
            aa = (aa * inv[K])%mod;
            aa = (aa * inv[N-K])%mod;
            sol = (sol * aa)%mod;
        }
    }
    if(m > 1)
        sol = (sol * n)%mod;
    cout << sol;
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 55;
const int Maxc = 3;

int n;
int ways[Maxn][Maxc][Maxc];
string A[2];

int main()
{
	cin >> n;
	cin >> A[0];
	cin >> A[1];
	if (A[0][0] == A[1][0])
		for (int i = 0; i < Maxc; i++)
			ways[1][i][i] = 1;
	else for (int i = 0; i < Maxc; i++)
			for (int j = 0; j < Maxc; j++) if (i != j)
				ways[2][i][j] = 1;
	for (int i = 1; i < n; i++)
		for (int j = 0; j < Maxc; j++)
			for (int k = 0; k < Maxc; k++) if (ways[i][j][k] != 0)
				if (A[0][i] == A[1][i]) {
					for (int z = 0; z < Maxc; z++) if (z != j && z != k)
						ways[i + 1][z][z] = (ways[i + 1][z][z] + ways[i][j][k]) % mod;
				} else for (int z = 0; z < Maxc; z++) if (z != j)
						for (int c = 0; c < Maxc; c++) if (c != z && c != k)
							ways[i + 2][z][c] = (ways[i + 2][z][c] + ways[i][j][k]) % mod;
	int res = 0;
	for (int j = 0; j < Maxc; j++)
		for (int k = 0; k < Maxc; k++)
			res = (res + ways[n][j][k]) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    q = int(input())
    for _ in range(q):
        x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(lambda x: int(x),
                                                             input().split())
        s1 = (x_p1 - x_p0, y_p1 - y_p0)
        s2 = (x_p3 - x_p2, y_p3 - y_p2)

        if s1[0] * s2[0] == - s1[1] * s2[1]:
            print(1)
        elif s1[0] * s2[1] == s1[1] * s2[0]:
            print(2)
        else:
            print(0)



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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  ll ans1, ans2;
  ans1 = *a.begin();
  ans2 = 0;
  ll d = 0;
  for (int i = 0; i < n; i++)
  {
    ll tmp = min(a[i], ans1 - a[i]);
    if (tmp > d)
    {
      ans2 = a[i];
      d = max(d, tmp);
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


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

int main(){
  ll n, m;
  cin >> n >> m;
  ll div = m / n;

  for(int i = div; i >= 0; --i){
    if(m % i == 0){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;
  int ans=0;
  int sum;
  int flag=1;
  int temp=0;
  while(cin>>s){
    sum = 0;
    for(int i=0;i<s.size();i++){
      if('0' <= s[i] && s[i] <= '9'){
	sum = 10*sum + (s[i]-'0');
      }else{
	ans += sum;
	sum = 0;
      }
    }
    ans += sum;
  }
  cout<<ans<<endl;
}

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

int main()
{
  int a,b; cin>>a>>b;
  string ans;
  if(a<b) ans="a < b";
  if(a==b) ans="a == b";
  if(a>b) ans="a > b";
  cout<<ans<<endl;
}



Measured memory_bytes: 3160
ans=[""]
ans.pop()
s=""
w=["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","}"]
x=[0]
x.pop()
def uni(seq):
    seen = set()
    seen_add = seen.add
    return [ x for x in seq if x not in seen and not seen_add(x)]

def check(a):
	global s
	global w
	n=len(a)
	# print "before ",a
	for i in range(26):
		if i==0:
			continue
		a=a.replace(w[i],w[i-1],1);
	# print "after ",a
	if a==s[0:n]:
		return True
	else:
		return False

def foo(a,n):
	# print a
	global ans
	global x
	if n==len(a):
		if check(a):
			ans.append(a)
		return
	sz=len(a)
	t=a+s[sz]
	if check(t):
		foo(t,n)
	if w[x[sz]]=="z":
		return
	t=a+w[x[sz]+1]
	# print t
	if check(t):
		# print t
		foo(t,n)



while True:
	s = raw_input()
	if s=="#":
		break
	ans=[""]
	ans.pop()
	x=[0]
	x.pop()
	for i in range(len(s)):
		for j in range(26):
			if w[j]==s[i]:
				x.append(j)
	# print s
	foo("",len(s))
	# ans=uni(ans)
	ans.sort()
	if len(ans)<=10:
		print len(ans)
		for i in range(len(ans)):
			print ans[i]
	else:
		print len(ans)
		for i in range(5):
			print ans[i]
		for i in range(5):
			print ans[len(ans)-5+i]

Measured memory_bytes: 7368
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    int ans1=0,ans2=0;
    rep(i,s.size()){
        if(s[i]=='0') ans1++;
        else ans2++;
    }
    cout <<min(ans1,ans2)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    vector<ll> ans(N);
    rep(i, N) {
        for (ll j = i + 1; j < N; j++) {
            ll mi = min(min(abs(j - i), abs(X - i - 1) + 1 + abs(Y - j - 1)),
                        abs(Y - i - 1) + 1 + abs(X - j - 1));
            ans[mi - 1] += 1;
        }
    }
    rep(i, N - 1) { cout << ans[i] << endl; }
    return 0;
}


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

using namespace std;

int main () {

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    while (a > 0 && k > 0) {
        sum += 1;
        a--;
        k--;
    }
    while (b > 0 && k > 0) {
        b--;
        k--;
    }
    while (c > 0 && k > 0) {
        sum -= 1;
        c--;
        k--;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3568
use std::cmp;
use std::i64::{MAX,MIN};
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let line = stdin.lock().lines().nth(1).unwrap().unwrap();
    let (min, max, sum) = line.split_whitespace()
        .map(|s| s.parse::<i64>().unwrap())
        .fold((MAX, MIN, 0), |(min, max, sum), x| {
            (cmp::min(min, x), cmp::max(max, x), sum + x)
        });
    println!("{} {} {}", min, max, sum);
}


Measured memory_bytes: 5036
//JSD
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  if(abs(n-m)%2==0)
    cout<<abs(n-m)/2+min(n,m);
  else 
    cout<<"IMPOSSIBLE";
  return 0;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0, state=0;
vector<ll> A;
vector<vector<ll>> B;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
        if(a>=N) state = 1;
    }
    while(state) {
        state = 0;
        tmp = 0;
        vector<ll> tmps;
        for(int i=0;i<N;i++) {
            ll tmp1 = A[i]-A[i]%N;
            tmp1 /= N;
            tmp += tmp1;
            tmps.push_back(tmp1);
            A[i] %= N;
        }
        ans += tmp;
        for(int i=0;i<N;i++) {
            A[i] += tmp-tmps[i];
            if(A[i]>=N) state = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

// using bigInt = boost::multiprecision::cpp_int;
static int64_t k;
int subSolve(int64_t v, int d) {
  std::queue<std::pair<int64_t, int>> q;
  q.push(std::make_pair(v, d));
  while (!q.empty()) {
    auto const vv = q.front();
    q.pop();
    if (vv.second >= 1000000) {
      return -1;
    }
    if (vv.first == 0) {
      return vv.second;
    }
    for (int i = 0; i < 10; i++) {
      int64_t vvv = vv.first + k * i;
      if (vvv % 10 != 7) {
        continue;
      }
      vvv /= 10;
      q.push(std::make_pair(vvv, vv.second + 1));
    }
  }
}

int64_t solve() {
  if (k % 2 == 0) {
    return -1;
  }
  if (7 % k == 0) {
    return 1;
  }
  if (77 % k == 0) {
    return 2;
  }
  if (777 % k == 0) {
    return 3;
  }
  int64_t ret = -1;
  for (int i = 1; i < 10; i++) {
    if ((k * i) % 10 != 7) {
      continue;
    }
    auto const r = subSolve(k * i / 10, 1);
    if (r < 0) {
      continue;
    }
    if (ret < 0 || r < ret) {
      ret = r;
      continue;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> k;
  auto const res = solve();
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,m;

int main(){
  cin>>n>>m;
  
  if(n==0){
    if(m==100)cout<<101<<endl;
    else
    cout<<m<<endl;
  }
  if(n==1){
    if(m==100) cout<<10100<<endl;
    else
    cout<<m*100<<endl;
  }
  if(n==2){
    if(m==100) cout<<1010000<<endl;
    else
    cout<<m*10000<<endl;
  }

  return 0;
}

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

int main() {
	int a[5], last=9, ans=0, i_last;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	bool frag10=true;
	for (int i = 0; i < 5; i++) {
		if (a[i] % 10 != 0) {
			frag10 = false;
		}
	}
	if (frag10) {
		for (int i = 0; i < 5; i++) {
			ans += a[i];
		}
		cout << ans << endl;
		return 0;
	}

	for (int i = 0; i < 5; i++) {
		int temp;
		temp = a[i] % 10;
		if (temp == 0) {
			continue;
		}
		else if (temp <= last) {
			last = temp;
			i_last = i;
		}
	}

	for (int i = 0; i < 5; i++) {
		if (i == i_last) {
			continue;
		}
		int temp;
		temp = a[i] % 10;
		if (temp == 0) {
			continue;
		}
		else {
			a[i] += 10 - temp;
		}
	}

	for (int i = 0; i < 5; i++) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
}
    

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


int n, pos;
vector<int>pre, in, post;

void rec(int l, int r) {
	if (l >= r)return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve() {
	pos = 0;
	rec(0, pre.size());
	for (int i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << post[i];

	}cout << endl;
}

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

	for (int i = 0; i < n; i++) {
		cin >> k;
		pre.push_back(k);
	}
	for (int i = 0; i < n; i++) {
		cin >> k;
		in.push_back(k);
	}

	solve();

	return 0;
}


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


int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  ll ans = 0;
  rep(i,n-1) {
    ll dx = d[i+1] - d[i];
    if(dx*a>b) ans += b;
    else ans += dx*a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u){
  for (int v = nt[u]; v < n; v++) {
    nt[u]=v+1;
    if(M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r) {
  for (int i = 0; i < n; i++)  nt[i] =0;

  stack<int> S;
  S.push(r);
  color[r]=GRAY;
  d[r]=++tt;

  while (!S.empty()) {
   int u= S.top();
   int v= next(u);
   if(v!=-1){
     if(color[v]==WHITE){
       color[v]=GRAY;
       d[v]=++tt;
       S.push(v);
     }
   }else{
     S.pop();
     color[u]=BLACK;
     f[u]=++tt;
   }
  }
}

void dfs(){
  for (int i = 0; i < n; i++) {
    color[i]=WHITE;
    nt[i]=0;
  }
  tt=0;

  for (int u = 0; u < n; u++) {
    if(color[u]==WHITE) dfs_visit(u);
  }
  for (int i = 0; i < n; i++) {
    cout <<i+1 <<" "<<d[i]<<" "<<f[i]<<endl;
  }
}

int main(){
  int u,k,v;

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

  for (int i = 0; i < n; i++) {
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin >>v;
      v--;
      M[u][v]=1;
    }
  }
  dfs();

  return 0;
}



Measured memory_bytes: 3128
# 入力                                                                                   
S = input()
K = int(input())

# kindリストに同じ文字が続くものごとに区切ったものを格納                                 
kind = []
back = "0"
len_S = len(S)
i = 0
for moji in S:
    if i == 0:
        back = moji
        i += 1
        continue
    if moji == back[-1]:
        back = moji + back
        if i == len_S-1:
            kind.append(back)
    else:
        kind.append(back)
        back = moji
    i += 1

score = 0
# 文字列が1文字の時
if len(S) == 1:
  	print(K//2)
   
# 最初の文字と最後の文字が異なる時                                                       
elif S[0] != S[-1]:
    for word in kind:
        len_word = len(word)
        score += len_word // 2
    print(score*K)
# 最初の文字と最後の文字が一緒の時                                                       
else:
    if len(set(kind)) == 1:
      	if len(kind) == 1:
          	print(len(kind[0])*K//2)
      	else:
        	print((len(kind[0])//2)*K)
    else:
        # 最初と最後がつながることでできる文字列の長さ                                   
        len_sg = len(kind[0] + kind[-1])
        for word in kind[1:-1]:
            len_word = len(word)
            score += len_word // 2
        print(score*K + (len_sg//2)*(K-1) + (len(kind[0]))//2 + (len(kind[-1]))//2 )

Measured memory_bytes: 3064
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

# n, k = map(int, input().split())
s = getInputInt()
k = getInputInt()

data = list(str(s))

ans = 1

for i in range(len(data)):
    if int(data[i]) != 1 and i < k:
        ans = int(data[i])
        break

print(ans)

Measured memory_bytes: 21892
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	for(int i=0;i<s.size()-1;i++)
		if(s[i]=='C')
			for(int j=i+1;j<s.size();j++)
				if(s[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
all_snuke = [0] * N
have_snuke = []
for i in range(K) :
    d = int(input())
    li = [i for i in input().split()]
    for snuke in li :
        if (snuke not in have_snuke) :
            have_snuke.append(snuke)
    
print(len(all_snuke) - len(have_snuke))

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

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

    //good luck kittu!
    int n, m; cin>>n>>m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout<<ans<<"\n";
    return 0;
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int arr[1000001];
bool pc;

vector<int> prime;

int gcd(int n1,int n2){
    if(n1*n2==0){
        return n1+n2;
    }
    return gcd(n2%n1,n1);
}

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    prime.push_back(2);
    for(int i=3;i<1000;i++){
        bool flag=1;
        for(int j=0;j<prime.size();j++){
            if(i%prime[j]==0){
                flag=0;
            }
        }
        if(flag==1){
            prime.push_back(i);
        }
    }

    int n;
    int GCD;

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

    GCD=arr[0];
    for(int i=1;i<n;i++){
        GCD=gcd(GCD,arr[i]);
    }

    pc=1;

    for(int i=0;i<prime.size();i++){

        int cnt=0;

        for(int j=0;j<n;j++){

            if( arr[j]%prime[i]==0 ){
                cnt++;
                while(arr[j]%prime[i]==0){
                    arr[j]/=prime[i];
                }
            }

        }

        if(cnt>=2){
            pc=0;
            break;
        }

    }

    sort(arr,arr+n);
    for(int i=0;i<n-1;i++){
        if(arr[i]==arr[i+1] and arr[i]>=2){
            pc=0;
            break;
        }
    }

    if(pc==1){
        cout<<"pairwise coprime"<<endl;
    }
    else if(GCD==1){
        cout<<"setwise coprime"<<endl;
    }
    else{
        cout<<"not coprime"<<endl;
    }

    return 0;
}


Measured memory_bytes: 11344
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <iostream>
#include <cmath>
using namespace std;

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() {return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
}

struct Segment {
  Point p1, p2;
};

typedef Segment Line;
/////////////////////////////////////////////////////

bool isOrthogonal(Vector a, Vector b) {
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Segment s1, Segment s2) {
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b) {
  return equals(cross(a, b), 0.0);
}

bool isParallel(Segment s1, Segment s2) {
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    Segment s1, s2;
    cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y;
    cin >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
    if (isOrthogonal(s1, s2)) cout << 1 << endl;
    else if (isParallel(s1, s2)) cout << 2 << endl;
    else cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>
#define MAX 100
#define INFTY 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int a[MAX][MAX];
int head=0,tail=0,q[MAX];

void enqueue(int t){
  q[tail]=t;
  if(t+1==MAX) tail=0;
  else tail++;
}

int dequeue(){
  int t=q[head];
  if(head+1==MAX) head=0;
  else head++;
  return t;
}

int isEmpty(){
  if(head==tail) return 1;
  else return 0;
}

void bfs(){
  int color[MAX],d[MAX],i,j;

  for(i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INFTY;

  }
  color[0]=GRAY;
  d[0]=0;
  enqueue(0);

  while(!isEmpty()){
    int u;
    u=dequeue();

    for(j=0;j<n;j++){
      if(a[u][j] && color[j]==WHITE){
        color[j]=GRAY;
        d[j]=d[u]+1;
        enqueue(j);
      }
    }
    color[u]=BLACK;
  }

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

int main()
{
  int u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      a[u][v]=1;
    }
  }

  bfs();

  return 0;
}

Measured memory_bytes: 636
n = int(input())
s = input()
list_s = [[] for _ in range(10)]
exist = []
a_c = []
count = 0

# 数字毎にindexをまとめる
for index, num_str in enumerate(s):
    list_s[int(num_str)].append(index)

# 存在しない数字を省く
for i in range(10):
    if list_s[i]:
        exist.append(i)

# 最初と最後の桁の候補
for a in exist:
    for c in exist:
        a_c.append((a, c))

for b in exist:  # bを決めて
    for a, c in a_c:  # a,cを決めて
        for b_index in list_s[b]:  # bのindexをあたる
            if list_s[a][0] < b_index < list_s[c][-1]:
                count += 1
                break

print(count)


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


int main()
{
	int a[301][301];

	memset(a,0,sizeof(a));
	for(int i=0;i<301;i++)
		a[1][i]=1;

	for(int i=2;i<=17;i++){
		for(int j=0;j<301;j++){
			a[i][j]=a[i-1][j];
			if(j-i*i>=0) a[i][j]+=a[i][j-i*i];
		}
	}
	int n;
	while(cin>>n && n!=0)
		cout<<a[17][n]<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 998244353
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

lli powD(lli n,lli k){
	lli now = 1;
	REP(i,0,k){
		now*=n;
		now%=MOD;
	}
	return now%MOD;
}

signed main(){

	lli n;
	cin>>n;
	vector<lli> d(n);
	lli maxD = 0;
	lli data[100010];
	REP(i,0,100010)data[i]=0;
	REP(i,0,n){
		cin>>d[i];
		if( (i==0 && d[i] != 0) || (i!=0 && d[i] == 0)){
			cout<<0<<endl;
			return 0;
		}
		maxD = max(maxD,d[i]);
		data[d[i]]++;
	}
	if(DEBUG){
		REP(i,0,maxD+1){
			cout<<"i="<<i<<" data[i]="<<data[i]<<endl;
		}
	}

	lli before = data[1];
	lli sum = 1;
	if(DEBUG)cout<<"sum="<<sum<<" before="<<before<<endl;

	for(lli i=2;i<=maxD;i++){
		sum *= powD(before,data[i]);
		sum %= MOD;
		before = data[i];
		if(DEBUG)cout<<"sum="<<sum<<" before="<<before<<endl;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys

N, M = map(int, input().split())
X = list(map(int, sys.stdin.readline().rsplit()))

X.sort()
tmp = [0] * (M - 1)
for i in range(M - 1):
    tmp[i] = X[i + 1] - X[i]
tmp.sort()

if N >= M:
    print(0)
else:
    print(sum(tmp[0:M - N]))


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

const int N = 2e5+23;
const int mod = 1e9+7;

int a[N];

long long binpow(long long b, long long e) {
  if (!e) return 1;
  if (e&1) return b*binpow(b, e-1)%mod;
  return binpow(b*b%mod, e/2);
}

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  long long ans = 1;
  if (k == n) {
    for (int i = 0; i < n; ++i) {
      ans = (ans * a[i]) % mod;
    }
    printf("%lld", (ans+mod)%mod);
    return;
  }
  sort(a, a+n);
  if (a[n-1] <= 0 && k%2) {
    for (int i = n-1; i >= 0 && k; --i) {
      ans = (ans * a[i]) % mod;
      --k;
    }
    printf("%lld", (ans+mod)%mod);
    return;
  }
  sort(a, a+n, [](int x, int y){return abs(x) > abs(y);});
  long long neg = -2e9, pos = 2e9;
  for (int i = 0; i < k; ++i) {
    if (a[i] < 0) neg = a[i];
    if (a[i] > 0) pos = a[i];
    ans = (ans * a[i]) % mod;
  }
  if (ans >= 0) {
    printf("%lld", ans);
    return;
  }
  long long neg2 = -2e9, pos2 = 2e9;
  for (int i = k; i < n; ++i) {
    if (a[i] < 0 && neg2 == -2e9) neg2 = a[i];
    if (a[i] > 0 && pos2 == 2e9) pos2 = a[i];
  }
  if (neg != -2e9 && neg2 != -2e9 && pos != 2e9 && pos2 != 2e9) {
    if (neg2*neg > pos*pos2) {
      ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
    } else {
      ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
    }
  } else if (neg2 != -2e9 && pos != 2e9) {
    ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
  } else {
    ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
  }
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

deque<int> dq;
int main() {
	int M, K; scanf("%d %d", &M, &K);
	if ((1 << M) <= K) return !printf("-1");
	if (M == 1) {
		if (K == 1) return !printf("-1");
		else return !printf("0 0 1 1");
	} 
	dq.push_back(K);
	for (int i = 0; i < (1 << M); i++) {
		if (i != K) {
			dq.push_front(i);
			dq.push_back(i);
		}
	}
	dq.push_back(K);
	for (int x : dq) {
		printf("%d ", x);
	}

}

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

int a, b;

// claudio van
int main() {
  scanf("%d %d", &a, &b);
  int sum = max(a, b);
  if (a == sum) {
    a--;
  } else {
    b--;
  }
  printf("%d\n", sum + max(a, b));
  return 0;
}

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

bool ask(int i) {
  cout << i << endl;
  string res;
  cin >> res;
  if (res == "Vacant") {
    exit(0);
  }
  return res == "Male";
}

signed main() {
  int n;
  cin >> n;
  bool vl = ask(0);
  bool vr = ask(n - 1);
  int l = 0, r = n - 1;
  while (true) {
    int c = (l + r) / 2;
    bool vc = ask(c);
    if ((vc + vl + c + l) % 2) {
      r = c, vr = vc;
    } else {
      l = c, vl = vc;
    }
  }
}


Measured memory_bytes: 852
from collections import defaultdict

#エラトステネス
L = [1 for i in range(101)]
L[0] = 0
L[1] = 0
plist = []
for i in range(101):
	if L[i] == 1:
		plist.append(i)
		c = 2
		while True:
			if i * c <= 100:
				L[i * c] = 0
				c += 1
			else:
				break

#初期化
N = int(input())
if N <= 9:
	print(0)
else:
	D = defaultdict(int)
	for i in range(1, N + 1):
		m = i
		while m != 1:
			for j in plist:
				if m % j == 0:
					D[j] += 1
					m = m // j
					break

	data = []
	for i in D:
		data.append(D[i])
	ans = 0
	n = len(data)
	for i in range(n):
		if data[i] >= 74:
			ans += 1
	for i in range(n):
		for j in range(n):
			if i != j:
				if data[i] >= 2 and data[j] >= 24:
					ans += 1
				if data[i] >= 4 and data[j] >= 14:
					ans += 1
	for i in range(n):
		for j in range(n):
			for k in range(j + 1, n):
				if i != j and j != k and k != i:
					if data[i] >= 2 and data[j] >= 4 and data[k] >= 4:
						ans += 1
	print(ans)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
map<int, pair<int, int>> mp;

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, D;
    cin >> H >> W >> D;
    int A[310][310];
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) {
        mp[A[i][j]] = make_pair(i, j);
    }
    vector<int> sum[100010];
    for(int k = 1; k <= D; k++) {
        int cost = 0;
        sum[k % D].push_back(cost);
        for(int i = k; i + D <= H * W; i += D) {
            cost += abs(mp[i].first - mp[i + D].first);
            cost += abs(mp[i].second - mp[i + D].second);
            sum[k % D].push_back(cost);
        }
    }
    int Q; cin >> Q;
    rep(i, Q) {
        int L, R; cin >> L >> R;
        int m = L % D;
        int step1 = L / D - (L % D == 0);
        int stepN = R / D - (L % D == 0);
        //cout << step1 << " " << stepN << endl;
        //cout << sum[m].size() << endl;
        //rep(j, sum[m].size()) cout << sum[m][j]<< " ";
        cout << sum[m][stepN] - sum[m][step1] << endl;
    }


    return 0;
}


Measured memory_bytes: 12032
N, M = map(int, input().split())
def euc(n,m):
    if n%m == 0:
        return m
    else:
        return euc(m, n%m)
g = euc(N, M)
l = int(N*M/g)
S = input()
T = input()
steps = int(l/M)
stept = int(l/N)
stepnumber = int(N / steps)

for i in range(stepnumber):
    if S[i*steps] != T[i*stept]:
        print(-1)
        break
else:
    print(l)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N, T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  double mean = (T - A)/0.006;
  double del = 10e5;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (del > abs(mean - H[i])) {
      del = abs(mean - H[i]);
      ans = i;
    }
  }
  cout << ans+1;
}

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

int main(){
  int64_t A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A>=K){
    cout << K << endl;
  }else if(A+B>=K){
    cout << A << endl;
  }else{
    cout << A-(K-A-B) <<endl;
  }
}
   

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    map<int,int>m;
    m[a]++;
    m[b]++;
    m[c]++;
    m[d]++;
    if(m[1]>0&&m[9]>0&&m[7]>0&&m[4]>0)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }
    else{
        cout<<"red"<<endl;
    }
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

int dfs(int n, int k, int s) {
    if (k == 0 && s == 0) {
        return 1;
    }
    if (n <= 0 || k <= 0 || s <= 0) {
        return 0;
    }

    int ret = 0;
    ret += dfs(n - 1, k - 1, s - n);
    ret += dfs(n - 1, k, s);
    return ret;
}

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

    int n, k, s;
    while (cin >> n >> k >> s, n) {
        cout << dfs(n, k, s) << endl;
    }

}

Measured memory_bytes: 2980
#include <stdio.h>

int main()
{
	int A;
	int B;
	scanf("%d %d", &A, &B);
	if (A==1 && B==2){
		printf("3\n");
	}
	else if (A==2 && B==3){
		printf("1\n");
	}
	else if (A==1 && B==3){
		printf("2\n");
	}
	else if (A==3 && B==1){
		printf("2\n");
	}
	else if (A==2 && B==1){
		printf("3\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}

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

int main(void){
    map<char,string> s;
    cin>>s['a']>>s['b']>>s['c'];
    map<char,int> use = { {'a',0}, {'b',0},{'c',0}};
    char turn = 'a', next = 'a';
    while(true){
        turn = next;
        if(use[turn]==s[turn].size()) break;
        next = s[turn][use[turn]];
        use[turn] ++; 
    }
    cout<<(char)toupper(turn)<<endl;

}

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

int main()
{
  int m,n;
  cin >> m >> n;
  vector<vector<char>> a(m+2,vector<char>(n+2,'#'));
  for(int i = 1;i <= m;i++){
    for(int j = 1;j <= n;j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0;i < m+2;i++){
    for(int j = 0;j < n+2;j++){
      cout << a[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
s=list(input())
k=0
for i in range(len(s)):
    if i % 2==0:
        if s[i] =="L":
            print("No")
            k+=1
            break
    else:
        if s[i]=="R":
            print("No")
            k+=1
            break
if k==0:
    print("Yes")

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

using namespace std;

int digit_sum(int i)
{
	int sum=0;
	while(i)
	{
		sum+=i%10;
		i/=10;
	}
	return sum;
}

int main()
{
	int N,a,b,sum=0;
	cin>>N>>a>>b;
	for(int i=1;i<=N;i++)
	{
		if(digit_sum(i)>=a&&digit_sum(i)<=b)
		sum+=i;
	} 
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    long long n,k,sum=0,p=0;
    cin>>n>>k;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end());
    while(sum<k){
        sum+=a[p].second;
        p++;
    }
    cout<<a[p-1].first<<endl;
    return 0;
}

Measured memory_bytes: 1024
loop do
    n, t, l, b = gets.split.map(&:to_i)
    break if n == 0

    lose = {}
    l.times do
        lose[gets.to_i] = 1
    end

    back = {}
    b.times do
        back[gets.to_i] = 1
    end

    prob = (0..t+1).map { [0] * (n+1) }
    prob[0][0] = 1.0

    (1..t).each do |i|
        prob[i][n] += prob[i-1][n]
        (0..n-1).each do |j|
            (1..6).each do |d|
                k = j
                loop do
                    k += d
                    if k > n
                        d = n - k
                        k = n
                    elsif k < 0
                        d = -k
                        k = 0
                    else
                        break
                    end
                end

                if lose[k]
                    prob[i+1][k] += prob[i-1][j] / 6
                elsif back[k]
                    prob[i][0] += prob[i-1][j] / 6
                else
                    prob[i][k] += prob[i-1][j] / 6
                end
            end
        end
    end
    printf("%.6f\n", prob[t][n])
end

Measured memory_bytes: 9072
#include <iostream>
#include <vector>

using namespace std;

int main(void){
    long long x;
    long long y;
    long long N;
    long long D;
    int ans=0;
    
    cin >> N >> D;
    
    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        if ((x*x + y*y) <= D*D) {
            ans++;
        }
    }
    cout << ans << '\n';
    
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(num,init,name) vector<int> name((num),(init));

int main(){
    int a,b,c,x,y;
    int ans=0;
    cin>>a>>b>>c>>x>>y;
    if(a+b<=c*2){
        cout<<x*a+y*b<<endl;
        return 0;
    }else if(x<=y){
        ans+=x*2*c;
        ans+=(min((y-x)*b,(y-x)*2*c));
    }else{
        ans+=y*2*c;
        ans+=(min((x-y)*a,(x-y)*2*c));
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
import numpy as np

s = np.array(input().split()).astype(int)
# =============================================================================
# if s.find("A") >= 0 and s.find("B") >= 0:
#     print("Yes")
# else:
#     print("No")
# =============================================================================

N,A,B = s

print(N//(A+B)*A + np.array([N%(A+B),A]).min())

# =============================================================================
# A,B = s
# 
# eight =  100/8
# ten = 100/10
# x1 = A*eight
# x2 = A*ten
# if (int)(A * 10/8) != B:
#     print(-1)
# else:
#     print(np.array(x1,x2).min().astype(int))
# =============================================================================


Measured memory_bytes: 12416