akhauriyash/Code-Regression huggingface dataset:
#pragma region Include
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << endl
template <class T>
using VV = vector<vector<T>>;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;
#pragma endregion

int main() {
  int N, K;
  cin >> N >> K;
  int h;
  int res = 0;
  rep(i, N) {
    cin >> h;
    if (h >= K) {
      ++res;
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

////////////////////////////////////////////////////////////////////

int main()
{
    ll N;
    cin >> N;
    int ans = to_string(N).size();

    for (ll A = 1; A * A <= N; A++)
    {
        if (N % A != 0)
            continue;
        const ll B = N / A;
        const int res = max(to_string(A).size(), to_string(B).size());
        //cout << "A= " << A << " B= " << B << endl;
        if (res < ans)
            ans = res;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric
import Data.List

type House = [Floor]
type Floor = [Room]
type Room  = Int

officialHouseInit :: [House]
officialHouseInit = replicate 4 houseInit

houseInit :: House
houseInit = replicate 3 floorInit

floorInit :: Floor
floorInit = replicate 10 roomInit

roomInit :: Room
roomInit = 0

showOfficialHouse :: [House] -> String
showOfficialHouse = intercalate (replicate 20 '#' ++ "\n") . map showHouse

showHouse :: House -> String
showHouse = unlines . map showFloor

showFloor :: Floor -> String
showFloor = concatMap ((' ' :) . showRoom) 

showRoom :: Room -> String
showRoom = show

main :: IO ()
main = do
  { [n] <- getInts
  ; hs <- loop n officialHouseInit
  ; putStr $ showOfficialHouse hs
  }

loop :: Int -> [House] -> IO [House]
loop 0 hs = return hs
loop n hs = do
  { [b,f,r,v] <- getInts
  ; let (fronts, ho : ends) = splitAt (b - 1) hs
  ; let (lows, fl : ups)    = splitAt (f - 1) ho
  ; let (xs, rm : ys)       = splitAt (r - 1) fl
  ; let fl' = xs ++ (rm + v) : ys
  ; let ho' = lows ++ fl' : ups
  ; let hs' = fronts ++ ho' : ends
  ; loop (n-1) hs'
  }
  
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4632
#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++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int n; cin >> n;
    int sum = 0, time = 0;
    while(sum < n){
        time++;
        sum += time;
    }

    cout << time << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left vadia
#define lb lower_bound
#define right puta
using namespace std;
using namespace __gnu_pbds;
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 998244353;
const int MAXN = 2e5 + 5;
const int MAXV = 1e6+5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

int bit[MAXN], n;

void update(int x, int k) {
	if(x > n)
		return;
    while(x <= n) {
        bit[x] = (bit[x] + k)%mod;
        while(bit[x] < 0) bit[x] += mod;
        x += (x & -x);
    }
}

int query(int x) {
    int s = 0;
    while(x > 0) {
        s = (s + bit[x])%mod;
        while(s < 0) s += mod;
        x -= (x & -x);
    }

    return s%mod;
}

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

	vector<pii> seg(k);
	for(pii &i : seg)
		cin >> i.f >> i.s;

	update(1, 1);
	update(2, -1);

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < k; j++) {
			
			int l = seg[j].f, r = seg[j].s;
			update(i+l, query(i));
			update(i+r+1, -query(i));

		}

	cout << query(n) << endl;

}


Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main() {
    int n, q, t, all_time = 0;
    string pn;
    queue<int> times;
    queue<string> names;
    queue<int> fin_times;
    queue<string> fin_names;
    
    cin >> n >> q;
    
    for(int i = 0;i < n;i++) {
        cin >> pn >> t;
        
        times.push(t);
        names.push(pn);
    }
    
    while(!names.empty()) {
        if(times.front() <= q) {
            all_time += times.front();
            times.pop();
            fin_times.push(all_time);
            fin_names.push(names.front());
            names.pop();
        } else {
            all_time += q;
            times.push(times.front() - q);
            times.pop();
            names.push(names.front());
            names.pop();
        }
    }
    
    while(!fin_names.empty()) {
        cout << fin_names.front() << " " << fin_times.front() << endl;
        fin_times.pop();
        fin_names.pop();
    }
    
    return 0;
}

Measured memory_bytes: 6148
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int c[20];

int main()
{
	int n,ma = 0,mi = 0x3fffffff;
	scanf("%d",&n);
	for(int i = 1,x;i <= n;i++)
	{
		scanf("%d",&x);
		if(x > ma)ma = x;
		if(mi > x)mi = x;
	}
	printf("%d\n",ma - mi);
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
    vector<int> x(5);
    int save1,save2;
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(int i=0;i<4;i++){
        if(x[i]%10==0)
          save1=0;
        else
          save1=10-x[i]%10;
      for(int j=i+1;j<5;j++){
        if(x[j]%10==0)
          save2=0;
        else
          save2=10-x[j]%10;
        if(save1>save2)
          swap(x[i],x[j]);
      }
    }
    int calc=0;
    for(int i=0;i<4;i++){
      if(x[i]%10!=0)
        calc+=x[i]+(10-x[i]%10);
      else
        calc+=x[i];
    }
    calc+=x[4];
    cout << calc << "\n";
    return 0;
}


Measured memory_bytes: 256
// beetに勝つ

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;


int H, W, K;
int dp[101][9];

int rec(int height, int pos) {
  if(height == 0) {
    return pos == K;
  }
  if(~dp[height][pos]) return dp[height][pos];
  int ret = 0;
  for(int i = 0; i < (1 << (W - 1)); i++) {
    vector< int > ex;
    for(int j = 0; j < W - 1; j++) {
      if((i >> j) & 1) ex.emplace_back(j);
    }
    auto f = false;
    for(int j = 1; j < ex.size(); j++) {
      if(ex[j - 1] + 1 == ex[j]) f = true;
    }
    if(f) continue;

    int curpos = pos;
    for(int j = 0; j < ex.size(); j++) {
      if(ex[j] == curpos) {
        curpos++;
        break;
      }
      if(ex[j] + 1 == curpos) {
        curpos--;
        break;
      }
    }
    (ret += rec(height - 1, curpos)) %= mod;
  }
  return dp[height][pos] = ret;

}

int main() {
  cin >> H >> W >> K;
  --K;
  memset(dp, -1, sizeof(dp));
  cout << rec(H, 0) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
vi arr[26];
bool f[26];

bool  check(){
	bool is=false;
	for(int i=0;i<26;++i){
		// cout<<f[i]<<" ";
		is=is||f[i];
	}
	return is;
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	string s,t;
	cin>>s>>t;
	for(int i=0;i<t.size();++i){
		f[t[i]-'a']=true;
	}
	for(int i=0;i<s.size();++i){
		arr[s[i]-'a'].pb(i);
		f[s[i]-'a']=false;
	}
	if(check())
		cout<<-1<<endl;
	else{
		ll c=1;
		int curr=-1;
		for(int i=0;i<t.size();++i){
			vi :: iterator itr=upper_bound(arr[t[i]-'a'].begin(),arr[t[i]-'a'].end(),curr);
			// cout<<"->"<<temp<<" ";
			if(itr==arr[t[i]-'a'].end()){
				c++;
				curr=arr[t[i]-'a'][0];
			}
			else
				curr=*itr;
			// cout<<curr<<endl;

		}
		cout<<c*s.size()-(s.size()-curr-1)<<endl;
	}


}

Measured memory_bytes: 1216
import numpy as np
N = int(input())
A = list(map(int, input().split()))
M = 10**9+7

A = np.array(A, np.int64)
a1 = A.sum() % M
a1_sq = a1**2 % M
a2 = (A**2 % M).sum() % M
diff = (a1_sq - a2) % M

if diff % 2 == 0:
    print(diff // 2)
else:
    res = (diff + M) // 2 % M
    print(res)




Measured memory_bytes: 50096
N = int(input())

for h in range(1,3501):
    for w in range(h,3501):
        if (4 * h * w - N * w - N * h) > 0 and N * h * w % (4 * h * w - N * w - N * h) == 0:
            n = N * h * w // (4 * h * w - N * w - N * h)
            print(h, w, n)
            quit()
        else:
            continue


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define N 100009
using namespace std;

int n,m,tot,d[N],a[N],b[N],fa[N],fst[N],pnt[N<<1],nxt[N<<1];
bool flag,vis[N];
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
void gg(){ puts("No"); exit(0); }
int getfa(int x){ return x==fa[x]?x:fa[x]=getfa(fa[x]); }
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
void dfs(int x,int p){
	int i,y; if (vis[x]){ flag=1; return; }
	vis[x]=1;
	//cerr<<"X:"<<x<<'\n';
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
	//	cerr<<x<<"->"<<y<<'\n';
		if (y!=p) dfs(y,x);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int i,x,y;
	for (i=1; i<=m; i++){
		scanf("%d%d",&x,&y);
		d[x]++; d[y]++;
		a[i]=x; b[i]=y;
	}
	for (i=1; i<=n; i++) if (d[i]&1) gg();
	int tmp=0;
	for (i=1; i<=n; i++){
		tmp+=d[i]-2>>1;
		if (tmp>2){ puts("Yes"); return 0; }
		if (d[i]==6){ puts("Yes"); return 0; }
	}
	if (tmp==2){
		for (i=1; i<=n; i++) if (d[i]==4) break;
		int now=i;
		for (i++; i<=n; i++) if (d[i]==4) break;
		int sta=i;
	//	cerr<<now<<' '<<sta<<'\n';
		for (i=1; i<=m; i++){
			if (a[i]==now || b[i]==now) continue;
			add(a[i],b[i]); add(b[i],a[i]);
		}
		dfs(sta,0);
		puts(flag?"Yes":"No"); return 0;
	}
	gg();	
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int a,b;
int main(){
	cin >> a >> b;
	if(a<10 and b<10)cout << a*b;
	else cout << "-1";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N,M,K,size=0,number=0,a;
vector<bool> seen;
vector<vector<ll>> Friend;
vector<vector<ll>> Block;
vector<ll> sizeofgraph;
queue<ll> que;
vector<ll> allque;
vector<ll> rock;
ll dfs(ll from,ll count){
  count=size+1;
  //cout<<from<<" "<<count<<endl;
  size=count;
  que.push(from);
  seen.at(from-1)=true;
  for(ll i=0;i<(ll)Friend.at(from-1).size();i++){
    if(seen.at(Friend.at(from-1).at(i)-1)==false){dfs(Friend.at(from-1).at(i),count);}
  }
  return size;
}
ll binary_search(ll key) {
  ll left=0,right=allque.size()-1;
  while (right >= left) {
    ll mid=left+(right-left)/2;
    if (allque.at(mid) == key) return mid;
        else if (allque.at(mid) > key) right = mid - 1;
        else if (allque.at(mid) < key) left = mid + 1;
    }
    return -1;
}
int main() {
  cin>>N>>M>>K;
  Friend.resize(N);
  rock.resize(N);
  Block.resize(N);
  seen.resize(N);
  sizeofgraph.resize(N);
  allque.resize(N);
  for(ll i=0;i<M;i++){
    ll a,b;
    cin>>a>>b;
    Friend.at(a-1).push_back(b);
    Friend.at(b-1).push_back(a);
  }
  for(ll i=0;i<N;i++){allque.at(i)=i+1;}
  while(!allque.empty()){
    number++;
    size=0;
    a=dfs(allque.at(0),0);
    while(!que.empty()){
      sizeofgraph.at(que.front()-1)=a;
      rock.at(que.front()-1)=number;
      allque.erase(allque.begin()+binary_search(que.front()));
      que.pop();
    }
  }
  for(ll i=0;i<K;i++){
    ll c,d;
    cin>>c>>d;
    if(rock.at(c-1)==rock.at(d-1)){
      Block.at(c-1).push_back(d);
      Block.at(d-1).push_back(c);
    }
  }
  for(ll i=0;i<N;i++){
    cout<<(ll)sizeofgraph.at(i)-(ll)1-(ll)Friend.at(i).size()-(ll)Block.at(i).size()<<" ";
  }
}

Measured memory_bytes: 15552
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

using namespace::std;

int main(void){
  int a;

  cin >> a;

  int res;
  if(a<105)res=0;
  else if(a==105)res=1;
  else{
    res=1;
    for(int i=107;i<=a;i+=2){
      int cnt=2;

      for(int j=2;j<=i/2;j++){
        if(i%j == 0) cnt++;
      }
      if(cnt == 8)res++;
    }
  }

  cout << res<< endl;
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string str = Console.ReadLine ();
            int ans = 0;
            int count = 0;
            for (int i = 0; i < 3; i++)
            {
                if (str[i] == 'S')
                {
                    if (count > ans) ans = count;
                    count = 0;
                }
                else
                {
                    count++;
                }
            }
            Console.Write (Math.Max (ans, count));
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 25956
#include <iostream>

using namespace std;

int main()
{
	int n, i, j = 0;
	string str;
    
    cin >> n;
    cin >> str;
    
	for(i = 0 ; i < 10000 ; i++){
      if(str[i] != NULL){
		j++;
        }
	}
	
	for(i = 0 ; i < j ; i++){
	    str[i] = str[i] + n;
      if(str[i] >= 91){
        str[i] = str[i] - 26;
      }
	}
  	
  	
    cout << str << endl;
    
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#define oo 0x3f3f3f3f
#define long long long

using namespace std;
//using namespace __gnu_cxx;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> arr(n);
    set<pair<int, int>> isBlack;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
        isBlack.insert({arr[i].first, arr[i].second});
    }

    vector<long> ans(10);
    ans[0] = 1ll * (h - 2) * (w - 2);
    set<pair<int, int>> vis;
    for (int i = 0; i < n; ++i) {
        for (int x = max(1, arr[i].first - 2); x <= arr[i].first; ++x) {
            for (int y = max(1, arr[i].second - 2); y <= arr[i].second; ++y) {
                if (x + 2 > h || y + 2 > w)
                    continue;
                if (!vis.insert({x, y}).second)
                    continue;
                int cnt = 0;
                for (int a = x; a <= x + 2; ++a) {
                    for (int b = y; b <= y + 2; ++b) {
                        if (isBlack.count({a, b})) {
                            ++cnt;
                        }
                    }
                }
//                cout << x << ' ' << y << ' ' << cnt << '\n';
                ++ans[cnt];
                --ans[0];
            }
        }
    }

    for (int i = 0; i < 10; ++i) {
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 50912
n = gets.chomp.to_i
hash = {}
['S','H','C','D'].each do |suit|
  for rank in 1..13
    key = suit + " " + rank.to_s
    hash[key] =false
  end
end

n.times do
  card = gets.chomp
  hash[card] = true
end
hash.select{|key,val|
puts key if !val
}

Measured memory_bytes: 8628
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans=3;
  if(a==b)
    ans--;
  if(a==c)
    ans--;
  if(b==c)
    ans--;
  if(!ans)
    ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;

struct complex
{
	double num,inum;
	complex(double A=0.0,double B=0.0){num=A,inum=B;}
};
complex operator !(const complex &A){return complex(A.num,-A.inum);}
complex operator +(const complex &A,const complex &B){return complex(A.num+B.num,A.inum+B.inum);}
complex operator -(const complex &A,const complex &B){return complex(A.num-B.num,A.inum-B.inum);}
complex operator *(const complex &A,const complex &B){return complex(A.num*B.num-A.inum*B.inum,A.num*B.inum+A.inum*B.num);}
struct Fast_Fourier_Transform
{
	#define size 140005
	#define pi 3.141592653589793238462643383
	
	int N,rev[size];
	complex *W,w[2][size];
	
	void prepare(int n)
	{
		if(N==n)return;
		int i,k,x,y;N=n;
		for(i=0;i<n;++i)
		{
			for(x=i,y=0,k=1;k<n;x>>=1,k<<=1)(y<<=1)|=x&1;
			rev[i]=y;
		}
		for(i=0;i<n;++i)
		{
			w[0][i]=complex(cos(2*pi*i/n),sin(2*pi*i/n));
			w[1][i]=complex(cos(2*pi*i/n),-sin(2*pi*i/n));
		}
	}
	void work(complex *A,int n)
	{
		if(n==1)return;
		int i,j,k,l,t;
		complex x,y;
		for(i=0;i<n;++i)if(i<rev[i])swap(A[i],A[rev[i]]);
		for(i=1;i<n;i<<=1)
		for(j=0,t=n/(i<<1);j<n;j+=i<<1)
		for(k=l=0;k<i;++k,l+=t)
		{
			x=W[l]*A[j+k+i];
			y=A[j+k];
			A[j+k]=y+x;
			A[j+k+i]=y-x;
		}
	}
	
	void DFT(complex *A,int n){prepare(n);W=w[0];work(A,n);}
	void IDFT(complex *A,int n)
	{
		prepare(n);W=w[1];work(A,n);
		for(int i=0;i<n;++i)A[i].num/=n,A[i].inum/=n;
	}
	
	#undef size
	#undef pi
}FFT;

void mult(int n,int *a,int *b,int *c,int p)
{
	int i,j,k;
	static complex f[300005],g[300005],t[300005],r[300005];
	for(i=0;i<n;++i)
	{
		f[i]=complex(a[i]>>15,a[i]&32767);
		g[i]=complex(b[i]>>15,b[i]&32767);
	}
	FFT.DFT(f,n);FFT.DFT(g,n);
	for(i=0;i<n;++i)
	{
		int j=i?n-i:0;
		t[i]=( (f[i]+!f[j])*(!g[j]-g[i]) + (!f[j]-f[i])*(g[i]+!g[j]) )*(complex){0,0.25};
		r[i]=(!f[j]-f[i])*(!g[j]-g[i])*(complex){-0.25,0} +(complex){0,0.25}*(f[i]+!f[j])*(g[i]+!g[j]);
	}
	FFT.IDFT(t,n);FFT.IDFT(r,n);
	for(i=0;i<n;++i)c[i]=( (((long long)(t[i].num+0.5))%p<<15) + (long long)(r[i].num+0.5) + (((long long)(r[i].inum+0.5))%p<<30) )%p; 
}

int N,n,m,a,b,i,j,k,ans;
int f[100005],g[100005],fac[100005],fac_inv[100005];
char A[100005],B[100005];

#include <string.h>
#define p 998244353

int Power(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=(long long)a*a%p)if(b&1)ans=(long long)ans*a%p;
	return ans;
}

int main()
{
	scanf("%s",A+1);n=strlen(A+1);
	scanf("%s",B+1);
	for(i=1;i<=n;++i)
	if(A[i]=='1')
	{
		if(B[i]=='1')++a;
		else ++b;
	}
	for(fac[0]=i=1;i<=n;++i)fac[i]=(long long)fac[i-1]*i%p;
	for(i=0;i<=n;++i)fac_inv[i]=Power(fac[i],p-2);
	
	m=a+b;
	for(i=0;i<=a;++i)g[i]=(long long)fac_inv[i+1]%p;
	f[0]=1;
	for(N=1;N<=a;N<<=1);N<<=1;
	for(k=b;k;k>>=1)
	{
		if(k&1)mult(N,f,g,f,p);
		mult(N,g,g,g,p);
		for(i=a+1;i<N;++i)f[i]=g[i]=0;
	}
	
	for(i=0;i<=a;++i)ans=(ans+(long long)f[i]%p)%p;
	
	ans=(long long)ans*fac[m]%p*fac[b]%p*fac[a]%p;
	printf("%d\n",ans);
}

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

class Main {

    void solve(){

	Scanner sc = new Scanner( System.in );
	int n = sc.nextInt() + 1;
	int c = sc.nextInt();

	int total_p = 0;
	for ( int i=0; i<c; ++i ) {
	    total_p += sc.nextInt();
	}

	int p = total_p/n;
	if ( total_p%n != 0 ) ++p;
	
	System.out.println( p );
    }

    public static void main( String[] a ) {new Main().solve(); }
}



Measured memory_bytes: 26316
import sys
A, B = map(int, input().split())
A_, B_ = A, B
counta, countb = 1, 1
while True:
    if A == B:
        print(A)
        sys.exit()
    elif A > B:
        countb += 1
        B = B_ * countb
    elif B > A:
        counta += 1
        A = A_ * counta


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
cnt_four = cnt_two = 0

for i in a:
    if i%4 == 0:
        cnt_four += 1
    elif i%4 == 2:
        cnt_two += 1
cnt_odd = len(a) - cnt_four - cnt_two

if cnt_two >= 1:
    cnt_odd += 1

if cnt_four >= cnt_odd - 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n,m,x;
    cin>>n>>m>>x;
    int c[n],a[n][m];
    rep(i,n){
        rep(j,m+1){
            if(j==0) cin>>c[i];
            else{
                cin>>a[i][j-1];
            }
        }
    }

    int ans=INF;
    for(int bit=0;bit<(1<<n);bit++){
        bool ok=true;;
        int tmp=0;
        vector<int> b(m,0);
        rep(i,n){
            if(bit & (1<<i)){
                rep(j,m) b[j]+=a[i][j];
                tmp+=c[i];
            }
        }
        rep(i,m){
            if(b[i]<x) ok=false;
        }
        if(ok) ans=min(ans,tmp);
    }

    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
}



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

using namespace std;

int main(int argc, char *argv[]) {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> g(H, vector<char>(W));
    vector<pair<int, int>> parr;

    char cur;
    map<int, int> m;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> g[i][j];
            if (g[i][j] == '#') {
                parr.push_back(make_pair(i, j));
            }
        }
    }


    for (auto& p: parr) {
        int h = p.first;
        int w = p.second;


        //  隣を塗る
        vector<int> hd = {-1, 1, 0, 0};
        vector<int> wd = {0, 0, -1, 1};

        for (int k = 0; k < 4; k++) {
            int new_h = h + hd[k];
            int new_w = w + wd[k];

            if (new_h >= 0 && new_h < H
             && new_w >= 0 && new_w < W
             && (g[h][w] == '#' || g[h][w] == 'Z')
             && (g[new_h][new_w] == '#' || g[new_h][new_w] == 'Z')) {

                g[h][w] = 'Z';
                g[new_h][new_w] = 'Z';
            }
        }
    }

    bool ok(true);
    for (int l = 0; l < H; l++) {
        for (int m = 0; m < W; m++) {
            if (g[l][m] == '#') {
                ok = false;
            }
        }
    }

    cout << ((ok) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char S[105];

int main(){

	int N;

	scanf("%d",&N);
	scanf("%s",S);

	int i;

	int ans=0;
	int x=0;

	for(i=0;i<N;i++){
		if(S[i]=='I'){x++;}
		else{x--;}
		if(ans<x){ans=x;}
	}
	if(ans<x){ans=x;}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=3005,mod=1e9+7,inv2=5e8+4;
int n,Q,a[N],f[N][N],ans,p;
int main(){
	scanf("%d%d",&n,&Q);
	rep (i,1,n) scanf("%d",&a[i]);
	rep (i,1,n) rep (j,1,n) f[i][j]=a[i]>a[j];
	p=1;
	while (Q--){
		int x,y; scanf("%d%d",&x,&y); p=(p+p)%mod;
		if (x>y) swap(x,y); if (x==y) continue;
		rep (i,1,n) if (x!=i&&y!=i){
			int v=(f[x][i]+f[y][i])%mod;
			f[x][i]=f[y][i]=(ll)v*inv2%mod;
			v=(f[i][x]+f[i][y])%mod;
			f[i][x]=f[i][y]=(ll)v*inv2%mod;
		}
		int v=(f[x][y]+f[y][x])%mod;
		f[x][y]=f[y][x]=(ll)v*inv2%mod;
	}
	rep (i,1,n) rep (j,i+1,n) (ans+=f[i][j])%=mod;
	printf("%lld\n",(ll)ans*p%mod);
	return 0;
}

Measured memory_bytes: 35456
#include<iostream>

int main()
{
	int sin, sec, min, hour;
	std::cin >> sin;
	min = sin / 60;
	hour = sin / (60 * 60);
	min = min % 60;
	sec = sin % 60;
	std::cout << hour << ":" << min << ":" << sec << std::endl;

	return 0;
}

Measured memory_bytes: 1168
arr = Array.new(1000, false)
n = gets.to_i
sequence = ""
while line = gets
    sequence += line.chomp.split.join
end
0.upto(sequence.length - 1){|i|
    arr[sequence[i, 1].to_i] = true
    arr[sequence[i, 2].to_i] = true
    arr[sequence[i, 3].to_i] = true
}
puts arr.find_index{|x| x == false}


Measured memory_bytes: 8948
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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


void dfs(const string& A,const string& B,string C,int pos,int borrow,int K,string& res){

	if(K<0) return;

	if(pos == A.size()){
		reverse(C.begin(),C.end());
		res = max(res,C);
		//cout << res << endl;
		return;
	}
	if((A[pos]-'0') - borrow >= (B[pos]-'0')){
		C[pos] = ((A[pos]-'0') - borrow - (B[pos]-'0') + '0');
		if(C[pos] < '0' || C[pos] > '9') return;
		dfs(A,B,C,pos+1,0,K,res);
	}
	else if((A[pos]-'0') - borrow < (B[pos]-'0')){
		C[pos] = ((A[pos]-'0') - borrow + 10 - (B[pos]-'0') + '0');
		if(C[pos] < '0' || C[pos] > '9') return;
		dfs(A,B,C,pos+1,1,K,res);
		dfs(A,B,C,pos+1,0,K-1,res);
	}
}

int main(){
	char A[16],B[16];
	int K;
	while(~scanf("%s %s %d",A,B,&K)){
		string strA=A,strB=B;
		reverse(strA.begin(),strA.end());
		reverse(strB.begin(),strB.end());

		strA.size() > strB.size() 
			? strB.append(strA.size()-strB.size(),'0') : strA.append(strB.size()-strA.size(),'0');

		string strC;
		string res;
		strC.resize(max(strA.size(),strB.size()));
		dfs(strA,strB,strC,0,0,K,res);

		bool isok = false;
		for(int i=0;i<res.size();i++){
			if(res[i] != '0') isok = true;
			if(isok) cout << res[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int selectionSort(int A[],int N){
int minj,i,j,ans=0,node;
	for(i=0;i<N;i++){
	minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
			minj=j;
			}
		}
				node=A[i];
				A[i]=A[minj];
				A[minj]=node;
				if(i!=minj)
				ans++;
	}
	return ans;
}

main(){
	int ans,n,i;
	scanf("%d",&n);
	int A[n];
	for(i=0;i<n;i++)
	scanf("%d",&A[i]);
	ans=selectionSort(A,n);
	for(i=0;i<n;i++){
		if(i==n-1){
			printf("%d",A[i]);
			break;
		}
		printf("%d ",A[i]);
	}
	printf("\n%d\n",ans);
	return 0;
}



Measured memory_bytes: 3232
import scala.io.{StdIn => in}

object Main extends App {
  val mod = 2019L
  val Array(l, r) = in.readLine.split(" ").map(_.toLong)

  var res = Int.MaxValue + 1L
  for{
    i <- 0L until mod * 2
    if l + i < r
    j <- (i + 1L) until (i + 1L + mod * 2)
    if l + j <= r
  } {
    val v = ((l+i) * (l+j)) % mod
    if(res > v) res = v
  }

  val ans = res
  println(ans)
}

Measured memory_bytes: 112736
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

max_profit = -100  # M <= 100 -> min_profit is larger than -100
canditates = set(s_list)
for canditate in canditates:
    tmp_profit = s_list.count(canditate) - t_list.count(canditate)
    if tmp_profit > max_profit:
        max_profit = tmp_profit   
print(max(max_profit, 0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)
ll keta(ll n){
    ll res = 0;
    while(n > 0){
        res += n % 10;
        n /= 10;
    }
    return res;
}

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    vector<ll> num;
    rep(i,0,16){
        rep(k,1,150){
            if(i == 0 && k == 1) continue; 
            num.push_back(k * pow(10,i) - 1);
        }
    }
    sort(num.begin(), num.end());
    unique(num.begin(), num.end());
    // printa(num, num.size());
    vector<ll> ans;
    ll N = num.size();
    rep(i,0,N){
        // print(i);
        bool ok = true;
        rep(j,i+1,N){
            double d1 = (double)num[i] / (double)keta(num[i]);
            double d2 = (double)num[j] / (double)keta(num[j]);
            // print2(d1,d2);
            if(d1 > d2){
                ok = false;
            }
        }
        if(ok) ans.push_back(num[i]);
    }
    rep(i,0,K){
        print(ans[i]);
    }
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    F=[]
    for _ in range(N):
        F.append(list(map(int,input().split())))
    P=[]
    for _ in range(N):
        P.append(list(map(int,input().split())))
    ans=-INF
    for i in range(1,2**10):
        tmp=0
        l=[0]*N
        for j in range(10):
            if (i>>j)&1:
                for k in range(N):
                    l[k]+=F[k][j]
        for k in range(N):
            tmp+=P[k][l[k]]
        ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        String str1 = scan.next();
        String str2 = scan.next();

        int a = Integer.parseInt(str1);
        int b = Integer.parseInt(str2);

        if(a>b)
            System.out.println(a-1);
        else
            System.out.println(a);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ALL(V) V.begin(), V.end()
using namespace std;
//using ll = __int128_t;
using ll = int64_t;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;

/*
istream& operator >>(istream &s, ll &v) {
    int64_t a;
    s >> a;
    v = a;
    return s;
}

ostream& operator <<(ostream &s, ll v) {
    auto a = static_cast<int64_t>(v);
    s << a;
    return s;
}
*/

template <typename T>
class Bit{
    private:
        V<T> data;
        T identity_ele;

    public:

        Bit(ll size, T identity_ele) {
            ll newsize = 1;
            while(newsize < size)  newsize = newsize << 1;
            this->identity_ele = identity_ele;
            data = V<T>(newsize + 1, identity_ele);
        }

        /*
         * 0-origin
         */
        T sum(ll pos) {
            T ret = identity_ele;
            pos++;
            while(pos > 0) {
                ret += data[pos];
                pos -= pos & -pos;
            }
            return ret;
        }

        /*
         * 0-origin
         */
        void add(ll pos, T delta) {
            pos++;
            while(pos <= data.size()) {
                data[pos] += delta;
                pos += pos & -pos;
            }
        }
};

struct Ball {
    ll a, c;
};

const ll INF = 5e15;
VV<ll> dp(2010, V<ll>(2010, INF));
V<Ball> VB;
ll N;
V<ll> winv(2010), binv(2010);
VV<ll> lbcnt(2010, V<ll>(2010)), lwcnt(2010, V<ll>(2010));

void calc() {
    Bit<ll> BB(N + 20, 0), WB(N + 20, 0);
    for(const Ball &e : VB) {
        ll a = e.a, c = e.c;
        auto &B = (c == 0 ? WB : BB);
        auto &Bi = (c == 0 ? BB : WB);
        auto &cnt = (c == 0 ? lbcnt : lwcnt);
        auto &inv = (c == 0 ? winv : binv);
        B.add(a, 1);
        inv[a] = B.sum(N + 10) - B.sum(a);
        for(ll i = 0; i <= N; i++) cnt[a][i] = Bi.sum(i);
    }
}

int main() {
    cin >> N;
    V<Ball> v;
    V<ll> wv, bv;
    dp[0][0] = 0;
    for(ll i = 0; i < 2 * N; i++) {
        char c;
        ll a;
        cin >> c >> a;
        VB.push_back(Ball{a, c == 'B'});
        (c == 'W' ? wv : bv).push_back(a);
    }
    calc();
    for(ll i = 1; i <= 2 * N; i++) {
        for(ll w = 0; w <= N; w++) {
            ll b = i - w;
            if(!(0 <= w && w <= N &&
                 0 <= b && b <= N)) continue;
            ll val = dp[w][b];
            if(0 < w && w <= N) {
                ll tmp = dp[w - 1][b];
                tmp += winv[w];
                tmp += b - lbcnt[w][b];
                val = min(val, tmp);
            }
            if(0 < b && b <= N) {
                ll tmp = dp[w][b - 1];
                tmp += binv[b];
                tmp += w - lwcnt[b][w];
                val = min(val, tmp);
            }
            dp[w][b] = val;
        }
    }
    //for(ll i = 0; i <= N; i++) for(ll j = 0; j <= N; j++) cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
    cout << dp[N][N] << endl;
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/
bool can(vi a, vi b) {
    bool ret = 1;
    for(int i = 0; i < a.size(); ++i) {
        if (a[i] != b[i]) {
            ret = 0;
            break;
        }
    }
    return ret;
}
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    vi x(n); rep(i,n) x[i] = i+1;
    vi p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    int cnt = 0;
    int a = 0, b = 0;
    bool can1 = 0, can2 = 0;
    do {
        cnt++;
        //rep(i,n) cout << x[i] << (i==n-1? '\n':' ');
        bool can = 1;
        if(!can1) {
            for(int i = 0; i < x.size(); ++i) {
                if(x[i]!=p[i]) can = 0;
            }
            if(can) {
                a = cnt;
                can1 = 1;
            }
        }
        can = 1;
        if(!can2) {
            for(int i = 0; i < x.size(); ++i) {
                if(x[i]!=q[i]) can = 0;
            }
            if(can) {
                b = cnt;
                can2 = 1;
            }
        }
    } while (next_permutation(all(x)));
    //cout << a << '\n';
    cout << abs(a-b) << endl; 
}

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

int main() {
    int N,ans=0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (1<=i && i<10) {
            ans++;
        }
        else if (100<=i && i<1000) {
            ans++;
        }
        else if (10000<=i && i<100000) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(void){
	int n,a[10000],min,max;
	long long sum;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	min=a[0];
	max=a[0];
	sum=a[0];
	for(int i=1;i<n;i++){
		if(min>a[i]) min=a[i];
		if(max<a[i]) max=a[i];
		sum=sum+a[i];
	}
	cout<<min<<" "<<max<<" "<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 233;
int a[maxn],vis[maxn],tot = 0;int n;
bool check(int x){
	int cnt = 0,id = 0;
	for(int i=1;i<=n;i++)
		if((a[i]&(1<<x))==0){
			cnt++;
			id = vis[i];
		}
//	cout<<"!"<<cnt<<endl;
	if(cnt==n)return 1;
	if(cnt!=n/3)return 0;
	if(id==0)tot++;
	for(int i=1;i<=n;i++)
		if((a[i]&(1<<x))==0){
//			cout<<"!"<<i<<" "<<vis[i]<<" "<<id<<endl; 
			if(vis[i]!=id)return 0;
			if(vis[i]==0)vis[i] = tot;
		}
	return 1;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ok = 1;
	for(int i=1;i<=n;i++)if(a[i])ok = 0;
	if(ok){
		puts("Yes");
		return 0;
	}
	if(n%3){
		puts("No");
		return 0;
	}
	
	for(int i=0;i<30;i++)
		if(!check(i)){
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
} 

Measured memory_bytes: 1024
//debuging wasebo555's solution

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll=long long;
int main(){
    int n;
    cin >> n;
    ll a[n+1],b[n];
    ll temp, prev=0;
    ll total=0;
    for(int i=0; i<n+1; ++i){
        cin >> a[i];
        total += a[i];
    }
    for(int i=0; i<n; ++i) cin >> b[i];
    for(int i=0; i<n; ++i){
        temp = a[i] - b[i];
        if(temp>=0){
            a[i] = temp;
        }
        else if(temp<0){
            a[i] = 0;
            a[i+1] += temp;
            if(a[i+1]<0) a[i+1] = 0;
        }
        // cout << temp << " ";
    }
    temp = 0;
    for(int i=0; i<n+1; ++i){
        temp += a[i];
        // cout << a[i] << " ";
    }
    // cout << endl;
    cout << total - temp << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000

int main(void){
  
  int C[MAX];
  int n;
  int i,j;
  int s;
  int *A,*B;
  
  scanf("%d",&n);

  s = sizeof(int)*n + 1;
    
  A = malloc(s);
  B = malloc(s);
  
  for(i = 0;i < MAX;i++){
    C[i] = 0;
  }
    
  for(i = 0;i < n;i++){
    scanf("%d",&A[i+1]);
    C[ A[i+1] ]++;
  }

  for(i = 1;i <= MAX;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j = 1;j <= n;j++){
    B[ C[A[j]] ] = A[j];
    C[A[j]]--;
  }

  for(i = 1;i <= n;i++){
    if(i != 1){
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");

  free(A);
  free(B);

  return 0;
}
      



Measured memory_bytes: 17104
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<string>
using namespace std;
int ans=-1,tot=0;
char ch[15];
int main()
{
	cin>>ch;
	for(register int i=0;i<10;i++)
	{
		if((ch[i]=='A')||(ch[i]=='G')||(ch[i]=='C')||(ch[i]=='T'))
		{
			tot++;
			ans=max(ans,tot);
		}
		else
		{
			tot=0;
			ans=max(ans,tot);
		}
	}
	cout<<ans;
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(M);
    vector<ll> D(M);

    REP(i, N){
        cin >> A[i] >> B[i];
    }
    REP(i, M){
        cin >> C[i] >> D[i];
    }

    REP(i, N){
        ll mindis = LINF;
        ll point = 0;
        REP(j, M){
            ll dis;
            dis = abs(A[i]-C[j]) + abs(B[i]-D[j]);
            if(dis < mindis){
                mindis = dis;
                point = j;
            }
        }
        cout << point+1 << endl;
    }
    return 0;
}

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

int main(){

	int A,B;
	int ans = -1;

	std::cin >> A >> B;

	for(int i = 1; i < 10000; i++){
		int c_8 = i*0.08;
		int c_10 = i*0.1;
		if(c_8 == A && c_10 == B){
			ans = i;
			break;
		}
	}

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


Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())
kaku = abs(6*m-30*h-0.5*m)
if kaku >= 180:
    kaku = 360 - kaku

cos = math.cos(kaku*math.pi/180)

tmp = a**2+b**2-2*a*b*cos

print(math.sqrt(tmp))

Measured memory_bytes: 9500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _012_DP_Practice
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var N = Convert.ToInt32(Console.ReadLine());
            var A = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(N * N - A);
        }
    }
}

Measured memory_bytes: 13268
#!venv/bin/python

#N = [ int(x) for x in input().split() ]
#S = input()

from collections import defaultdict 

N = int(input())
K = []
bridge = defaultdict(list)
for n in range(N-1):
    k = [ int(x) for x in input().split() ]
    K.append(k)
    bridge[k[0]].append([k[1], k[2]])
    bridge[k[1]].append([k[0], k[2]])

color = [ None for i in range(N + 1)]

queue = []
queue.append(1)
color[1] = 1


while queue:
    point = queue.pop()
    for b in bridge[point]:
        if not color[b[0]]:
            queue.append(b[0])
            if b[1] % 2 == 0:
                color[b[0]] = color[point]
            else:
                color[b[0]] = color[point] * -1

ans = []
for c in color[1:]:
    if c == 1:
        ans.append("1")
    else:
        ans.append("0")
print("\n".join(ans))

Measured memory_bytes: 63392
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX_N 55
#define ll long long

ll N, K;

int compress(vector<ll>& x1, vector<ll>& x2,vector<ll>& xs) {
	for (int i = 0; i < N;i++) {
		xs.push_back(x1[i]);
		xs.push_back(x2[i]);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (int i = 0; i < N;i++) {
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size();
}

int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	cin >> N >> K;
	vector<ll> X1(N), X2(N), Y1(N), Y2(N), D1(N), D2(N);
	vector<ll> xs, ys, ds;
	for (int i = 0; i < N;i++) {
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
	}
	ll X = compress(X1, X2, xs);
	ll Y = compress(Y1, Y2, ys);
	ll D = compress(D1, D2, ds);

	ll ans = 0;

	vector<vector<vector<ll>>> m(X, vector<vector<ll>>(Y, vector<ll>(D, 0)));
	for (int i = 0; i < N;i++) {
		for (int x = X1[i] + 1; x <= X2[i]; x++) {
			for (int y = Y1[i] + 1; y <= Y2[i]; y++) {
				for (int d = D1[i] + 1; d <= D2[i]; d++) {
					m[x][y][d]++;
				}
			}
		}
	}

	for (int x = 1; x < X; x++) {
		for (int y = 1; y < Y;y++) {
			for (int d = 1; d < D;d++) {
				if (m[x][y][d] >= K) {
					ll a_x, a_y, a_d;
					a_x = xs[x] - xs[x - 1];
					a_y = ys[y] - ys[y - 1];
					a_d = ds[d] - ds[d - 1];

					ans += a_x * a_y * a_d;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 10980
n=int(input())
As = input().split()

dic = {}
for a in As:
  if a not in dic:
    dic[a] = 0
  dic[a] += 1

tmp = 0
for k, v in dic.items():
  if v > 1:
    tmp += v * (v-1)/2

ans = []
for a in As:
  if dic[a] > 1:
    div = dic[a] * (dic[a] - 1) / 2
    kakeru = (dic[a]-1) * (dic[a]-2)/2
    ans.append(int(tmp - div + kakeru))
  else:
    ans.append(int(tmp))
for a in ans:
  print(a)

Measured memory_bytes: 32160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=60;
int n;
ll k;
vvi a;

int main(){
	cin>>n>>k;
	a=vvi(M,vi(n));
	for(int i=0;i<n;i++){
		cin>>a[0][i];
		a[0][i]--;
	}
	for(int i=1;i<M;i++) for(int j=0;j<n;j++) a[i][j]=a[i-1][a[i-1][j]];
	int x=0;
	for(ll i=0;i<M;i++) if(k&1LL<<i) x=a[i][x];
	cout<<x+1<<endl;
}

Measured memory_bytes: 51048
solve2 n 1 sum d = (2 * sum + 1, 2*d)
solve2 n k sum d 
    | n < k     = solve2 n      next_k  (2 * sum)                (2 * d)
    | otherwise = solve2 (k-1)  next_k ((2 * sum) + n - (k - 1)) (2 * d) -- k - 1 < n 
    where
        next_k = div (k + mod k 2) 2


solve :: [Int] -> Double 
solve (n:k:_) =
    (fromIntegral s) / (fromIntegral d2)
    where
        (s, d) = solve2 n k 0 1
        d2 = div (d * n ) 2


main = interact $ show.solve.map read.words


Measured memory_bytes: 508