akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[11000];
int dp[110][4][3];
int main(){
	scanf("%s",in);
	int a;scanf("%d",&a);
	int n=strlen(in);
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=a;j++)for(int k=0;k<2;k++){
			for(int l=0;l<10;l++){
				int tj=j;
				int tk=k;
				if(l)tj++;
				if(tj>a)continue;
				if(k==0&&l>in[i]-'0')continue;
				if(l<in[i]-'0')tk=1;
				dp[i+1][tj][tk]+=dp[i][j][k];
			}
		}
	}
	printf("%d\n",dp[n][a][0]+dp[n][a][1]);
}

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

a = list(map(int,input().split()))

max = a[0]
min = a[0]
sum = a[0]

for i in range(1,n):
    if max < a[i]:
        max = a[i]
    elif min > a[i]:
        min = a[i]
    sum += a[i]
print(min,max,sum)


Measured memory_bytes: 6592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
ll RF(int n,ll x,vector<ll> a,vector<ll> p){
    if(n==0) return (x<=0) ? 0 : 1;
    else if(x<=1+a[n-1]) return RF(n-1,x-1,a,p);
    else return p[n-1]+1+RF(n-1,x-2-a[n-1],a,p);
}
int main(){
    int n;cin >> n;
    ll x;cin >> x;
    vector<ll> a(n+1),p(n+1);
    a[0]=1;
    p[0]=1;
    for(int i=0;i<n;i++){
        a[i+1]=2*a[i]+3;
        p[i+1]=2*p[i]+1;
    }
    cout << RF(n,x,a,p) << endl;
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<int> A(N);
   for (int i = 0; i < N; ++i) cin >> A[i];
   if (count(A.begin(), A.end(), N - 1) == N) {
      cout << "Yes\n";
      return 0;
   }
   int diff = *max_element(A.begin(), A.end());
   int only = 0;
   for (int i = 0; i < N; ++i) {
      if (A[i] < diff - 1) {
         cout << "No\n";
         return 0;
      } else if (A[i] == diff - 1) {
         ++only;
      } else assert(A[i] == diff);
   }
   if (only >= diff) {
      cout << "No\n";
      return 0;
   }
   int non_only = diff - only;
   if (non_only * 2 + only > N) {
      cout << "No\n";
      return 0;
   }
   cout << "Yes\n";
   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  int ans = 0;
  int memo = N + 1;
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
    if (P.at(i) < memo) {
      ans++;
      memo = P.at(i);
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
#define pll pair<ll,ll>

ll H,W,K;
vector<pll> ys[101010];
ll anum[101010];
ll dp[111][8];
ll i, j, k,l;
int main(){
    scanf("%lld%lld%lld",&H,&W,&K);

    dp[0][0] = 1;
    fornum(i,0,H){
        fornum(j,0,(1<<(W-1))){
            bool flag = false;
            fornum(k,0,W){
                if((j>>k&0b11)==0b11){
                    flag = true;
                }
            }
            if(flag)
                continue;
            fornum(k,0,W){
                if(0<k&&(j&(1<<(k-1)))){
                    dp[i + 1][k - 1] = (dp[i + 1][k - 1] + dp[i][k])%MOD;
                }else if(k<W-1&&(j&(1<<k))){
                    dp[i + 1][k + 1] = (dp[i + 1][k + 1] + dp[i][k])%MOD;
                }else{
                    dp[i + 1][k] = (dp[i + 1][k] + dp[i][k])%MOD;
                }
            }
            
        }
    }
    
    printf("%lld\n", dp[H][K - 1]);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,p,j=0;
    cin>>a>>b>>k;
    int ar[100];
    for(int i=1;i<=max(a,b);i++)
    {
        if(a%i==0 && b%i==0)
        {
            ar[j]=i;
            j++;
        }
    }
    sort(ar,ar+j,greater<int>());
    p=ar[k-1];
    cout<<p<<endl;
    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b)    for (int i = (a); i < (b); i++)
#define F0R(i, a)       for (int i = 0; i < (a); i++)
#define FORd(i, a, b)   for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a)      for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)      for (auto& a : x)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace __input {
    template<class T1, class T2> void re(pair<T1,T2>& p);
    template<class T> void re(vector<T>& a);
    template<class T, size_t SZ> void re(array<T,SZ>& a);

    template<class T> void re(T& x) { cin >> x; }
    void re(double& x) { string t; re(t); x = stod(t); }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) {
        re(first); re(rest...);
    }

    template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
    template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
    template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}
using namespace __input;

namespace __output {
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T, size_t SZ> void pr(const array<T,SZ>& x);
    template<class T> void pr(const vector<T>& x);
    template<class T> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);

    template<class T> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
        pr(first); pr(rest...);
    }

    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.f,", ",x.s,"}");
    }
    template<class T> void prContain(const T& x) {
        pr("{");
        bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0;
        pr("}");
    }
    template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    template<class T> void pr(const vector<T>& x) { prContain(x); }
    template<class T> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }

    void ps() { pr("\n"); }
    template<class Arg> void ps(const Arg& first) {
        pr(first); ps();
    }
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
        pr(first," "); ps(rest...);
    }
}
using namespace __output;

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

    int N, A, B; re(N, A, B);
    ps(min(A * N, B));

    return 0;
}



Measured memory_bytes: 892
import java.util.ArrayDeque;
import java.util.BitSet;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DY = { 1, 0, -1, 0 };
	static int[] DX = { 0, -1, 0, 1 };
	static int W, H;
	static char[][] mapL, mapR;
	static BitSet visited = new BitSet(1 << 24);
	static int[] q = new int[50 * 50 * 50 * 50];

	public static void main(String[] args) {
		while (true) {
			W = sc.nextInt();
			H = sc.nextInt();
			if (W == 0) break;
			mapL = new char[H][];
			mapR = new char[H][];
			for (int i = 0; i < H; ++i) {
				mapL[i] = sc.next().toCharArray();
				mapR[i] = sc.next().toCharArray();
			}
			System.out.println(solve() ? "Yes" : "No");
		}
	}

	static boolean solve() {
		boolean[] visited = new boolean[H * W * H * W];
		int pos = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (mapL[i][j] == 'L') {
					pos |= (i << 18) | (j << 12);
				}
				if (mapR[i][j] == 'R') {
					pos |= (i << 6) | j;
				}
			}
		}
		visited[posToIdx(pos)] = true;
		int qs = 0;
		int qe = 1;
		q[0] = pos;
		while (qs != qe) {
			int p = q[qs++];
			int y1 = p >> 18;
			int x1 = (p >> 12) & 0x3F;
			int y2 = (p >> 6) & 0x3F;
			int x2 = p & 0x3F;
			for (int i = 0; i < 4; ++i) {
				int ny1 = y1 + DY[i];
				int nx1 = x1 + DX[i];
				int ny2 = y2 + DY[i];
				int nx2 = x2 - DX[i];
				if (ny1 < 0 || H <= ny1 || nx1 < 0 || W <= nx1 || mapL[ny1][nx1] == '#') {
					ny1 = y1;
					nx1 = x1;
				}
				if (ny2 < 0 || H <= ny2 || nx2 < 0 || W <= nx2 || mapR[ny2][nx2] == '#') {
					ny2 = y2;
					nx2 = x2;
				}
				boolean goalL = mapL[ny1][nx1] == '%';
				boolean goalR = mapR[ny2][nx2] == '%';
				if (goalL && goalR) {
					return true;
				}
				if (!goalL && !goalR) {
					int np = (ny1 << 18) | (nx1 << 12) | (ny2 << 6) | nx2;
					int ni = posToIdx(np);
					if (!visited[ni]) {
						visited[ni] = true;
						q[qe++] = np;
					}
				}
			}
		}
		return false;
	}

	static int posToIdx(int p) {
		int y1 = p >> 18;
		int x1 = (p >> 12) & 0x3F;
		int y2 = (p >> 6) & 0x3F;
		int x2 = p & 0x3F;
		return (y1 * W + x1) * H * W + (y2 * W + x2);
	}

}

Measured memory_bytes: 85096
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main(){
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;

    let x = read::<i128>(s).unwrap();
    let k = read::<i128>(s).unwrap();
    let d = read::<i128>(s).unwrap();
	let  m: i128;
	if x.abs() > d * k {
		m = x.abs() - d*k;
	}
	else {
		let xk = x.abs() / d;
		if (k - xk) % 2 == 0 {
			m = x.abs() - xk*d;
		}
		else {
		    m = (x.abs() - (xk+1)*d).abs();
		}
	}
	println!("{}", m);
}


Measured memory_bytes: 2168
from itertools import accumulate
from bisect import bisect_right
def solve():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    a = [0] + list(accumulate(A))
    b = [0] + list(accumulate(B))

    ans = 0
    for i in range(N+1):
        if a[i] > K:
            break
        b_max = K - a[i]
        cnt = i + bisect_right(b,b_max) - 1
       
        ans = max(ans,cnt)
        
    print(ans)
    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 135060
def myfunc(op):
    if op:
        return "+"
    else:
        return "-"


a, b, c, d = [int(i) for i in list(input())]

for j in range(8):
    op = [[1, "+"]] * 3
    for i in range(3):
        if (j >> i) & 1:
            op[i] = [-1, "-"]
    if a + b * op[0][0] + c * op[1][0] + d * op[2][0] == 7:
        print(f"{a}{op[0][1]}{b}{op[1][1]}{c}{op[2][1]}{d}=7")
        exit()

Measured memory_bytes: 9132
import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Data.Array.IArray
import           Data.Array.IO
import           Data.Array.MArray
import           Data.Maybe

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

(!?) :: IOUArray Int Int -> Int -> IO (Maybe Int)
a !? i = do
    (_, t) <- getBounds a
    if i < 1 || t < i
        then return Nothing
        else Just <$> readArray a i

swap :: Int -> Int -> IOUArray Int Int -> IO ()
swap x y a = do
    vx <- readArray a x
    vy <- readArray a y
    writeArray a y vx
    writeArray a x vy

maxHeapify :: Int -> IOUArray Int Int -> IO ()
maxHeapify i a = do
    let l = i * 2
    let r = i * 2 + 1
    vi <- readArray a i
    mleft <- a !? l
    mright <- a !? r
    let t1 =
            case mleft of
                Nothing -> i
                Just vl
                    | vl > vi -> l
                    | otherwise -> i
    vt1 <- readArray a t1
    let t2 =
            case mright of
                Nothing -> t1
                Just vr
                    | vr > vt1 -> r
                    | otherwise -> t1
    when (t2 /= i) $ do
        swap i t2 a
        maxHeapify t2 a

buildMaxHeap :: IOUArray Int Int -> IO ()
buildMaxHeap a = do
    (_, e) <- getBounds a
    let e' = e `div` 2
    forM_ [e', e'-1 .. 1] $ \i -> do
        maxHeapify i a

main :: IO ()
main = do
    n <- readLn
    xs <- (-1 :) . fmap readi . B.words <$> B.getLine
    ary <- newListArray (0, n) xs :: IO (IOUArray Int Int)
    buildMaxHeap ary
    forM_ [1 .. n] $ \i -> do
        v <- readArray ary i
        putStr $ " " ++ show v
    putStrLn ""



Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;


signed main(){
    int A,B;cin >> A >> B;cout << A+B/2 << endl;
    return 0;
}   


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n; cin >> n;
	map<string, LL> mp;

	for (int i = 0; i < n; i++) {
		string tmp; cin >> tmp;

		sort(tmp.begin(), tmp.end());

		mp[tmp]++;
	}

	LL ans = 0;
	for (auto i : mp) {
		LL x = i.second*(i.second - 1)/2;

		ans += x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main() {
	long int n, b, max = -1000000, min = 1000000, sum = 0;
	scanf("%ld", &n);

	for (int i = 0; i < n; i++) {
		scanf("%ld", &b);
		sum += b;
		if (max < b) max = b;
		if (b < min) min = b;
	}

	printf("%ld %ld %ld\n", min, max, sum);


	return 0;
}


Measured memory_bytes: 2112
MOD = 10**9 + 7

N = 100010
binL = input().zfill(N)

dp = [[0]*2 for _ in range(N+1)]
dp[0][0] = 1
for i, Li in enumerate(binL):
    Li = int(Li)
    for j in range(2):
        for a, b in [(0,0), (0,1), (1,0)]:
            if j == 0 and a+b > Li: continue
            j2 = j or (a+b<Li)
            dp[i+1][j2] += dp[i][j]
            dp[i+1][j2] %= MOD

ans = sum(dp[-1]) % MOD
print(ans)


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int n, m, k;

int main()
{
  fastio;
  cin >> n >> m >> k;
  vector <vector <char>> c(n, vector <char> (m));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      cin >> c[i][j];
    }
  }
  int res = 0;
  for (int x = 0; x < (1 << n); x++){
    for (int y = 0; y < (1 << m); y++){
      int cnt = 0;
      for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
          if (x >> i & 1) continue;
          if (y >> j & 1) continue;
          cnt += (c[i][j] == '#');
        }
      }
      res += (cnt == k);  
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;
const int MAXN=100005;
int n;
vector<pair<int,int> > v[MAXN];
int color[MAXN];

void dfs(int no,int father)
{
	for (int i=0;i<v[no].size();i++){
		int u=v[no][i].first;
		int w=v[no][i].second%2;
		if (u!=father){
			color[u]=color[no]^w;
			dfs(u,no);
		}
	}
}

int main()
{
	cin>>n;
	for (int i=1;i<n;i++){
		int u,vv,c;
		cin>>u>>vv>>c;
		v[u].push_back({vv,c});
		v[vv].push_back({u,c});
	}

	dfs(1,-1);

	for (int i=1;i<=n;i++){
		cout<<color[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  ull n;
  cin >> n;
  string s;
  cin >> s;

  ull res = 0;
  for (ull i=2; i < n; i++) {
    if (s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C') {
      res++;
    }
  }

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


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

int main(void)
{
  char buf[200];
  char a[10], b[101], c[10];

  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%s %s %s", a, b, c);

  std::cout << "A" << b[0] << "C" << std::endl;

  return 0;
}

Measured memory_bytes: 3760
S = str(input())

fw = S[:2]
bw = S[2:]

MList=[]
MList = ['01','02','03','04','05','06','07','08','09','10','11','12']



if fw in MList and bw in MList :
    print('AMBIGUOUS')
elif fw in MList :
    print('MMYY')
elif bw in MList :
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
///////////////////////////////////////////// Template /////////////////////////////////////////////
#![allow(non_snake_case, unused)]
use std::collections::*;

//////////////////// missing functions in 1.15.1 ////////////////////
macro_rules! eprint {
	($($t:tt)*) => { {
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	} };
}
macro_rules! eprintln {
	($($t:tt)*) => { {
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	} };
}

//////////////////// useful functions ////////////////////
pub trait SetMin {
	fn setmin(&mut self, v: Self) -> bool;
}
impl<T> SetMin for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
}
pub trait SetMax {
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMax for T where T: PartialOrd {
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! debug {
	($($v: expr),*) => {
		$(eprint!("{} = {:?} ", stringify!($v), $v);)*
		eprintln!("@ {}:{}", file!(), line!());
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:ty),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

fn run() {
	let (N, M) = read!(usize, usize);
	let mut from = vec![false; N];
	let mut to = vec![false; N];
	for (a, b) in read!(usize, usize; M) {
		if a == 1 {
			to[b - 1] = true;
		}
		if b == N {
			from[a - 1] = true;
		}
	}
	if from.into_iter().zip(to.into_iter()).any(|(a, b)| a && b) {
		println!("POSSIBLE");
	} else {
		println!("IMPOSSIBLE");
	}
}


Measured memory_bytes: 13404
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int a,b;cin >> a >> b;
  cout << (a>=2*b?a-2*b:0) << endl;
}


Measured memory_bytes: 256
import math
import itertools
n = int(input())
d=[]
for i in range(n):
    a,b=map(int, input().split())
    d.append([a,b])
p = itertools.permutations(d, 2)
ans=0
for v in p:
    ans += math.sqrt((v[0][0]-v[1][0])**2 + (v[0][1]-v[1][1])**2)
print(ans/n)


Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SIZE(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) lower_bound(ALL(c),x)
#define UB(c,x) upper_bound(ALL(c),x)
#define COUNT(c,x) (int)(UB(c,x)-LB(c,x))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  vector<int> water, sugar;
  for (int i = 0; 100*A*i <= F; i++) {
    for (int j = 0; 100*A*i + 100*B*j <= F; j++) {
      water.push_back(100*A*i + 100*B*j);
    }
  }
  for (int i = 0; C*i <= F; i++) {
    for (int j = 0; C*i + D*j <= F; j++) {
      sugar.push_back(C*i + D*j);
    }
  }
  sort(water.begin(), water.end());
  water.erase(unique(water.begin(), water.end()), water.end());
  water.erase(water.begin());
  sort(sugar.begin(), sugar.end());
  sugar.erase(unique(sugar.begin(), sugar.end()), sugar.end());

  double max_conc = 0;
  int max_ws = 0, max_s = 0;
  EACH(i, water) {
    int w = *i;
    int idx = UB(sugar, min(F-w, (int)(w*E/100.0))) - sugar.begin();
    if (idx == 0) {
      continue;
    }
    int s = sugar[idx-1];
    double conc = (double)s / (w+s);
    if (max_conc <= conc) {
      max_conc = conc;
      max_ws = w + s;
      max_s = s;
    }
  }

  cout << max_ws << " " << max_s << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
const long long INF = 1LL << 60;
int N;
long long h[100010];
long long dp[100010];
int main()
{	
  int N; cin >> N;
  long long tmp1, tmp2;
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  for (int i = 0; i < 100010; i++){
    dp[i] = INF;
  }
  dp[0] = 0;
  for (int i = 1; i < N; i++){
    tmp1 = dp[i - 1] + abs(h[i] - h[i - 1]);
    if (dp[i] > tmp1){
      dp[i] = tmp1;
    }
    if (i > 1){
      tmp2 = dp[i - 2] + abs(h[i] - h[i - 2]);
      if (dp[i] > tmp2){
        dp[i] = tmp2;
      }
    }
  }
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<vector<ll>> dp(n+1, vector<ll>(13));  // dp[i+1][j] : 先頭i文字(iは0-index)を13で割った余りがjとなる場合の数のmodでの剰余

    dp[0][0] = 1LL;
    rep(i, n) {
        rep(j, 13) {
            if(s[i] != '?') {
                int num = s[i] - '0';
                dp[i+1][(10*j+num)%13] += dp[i][j]; 
                dp[i+1][(10*j+num)%13] %= mod;
            }
            else {
                rep(k, 10) {
                    dp[i+1][(10*j+k)%13] += dp[i][j];
                    dp[i+1][(10*j+k)%13] %= mod;
                }
            }
        }
    }

    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define int long long

using namespace std;

static const int INF = 1<<50;
static const int mod = 10007;

int n;
string str;
int mem[1001][8][8];

int cal(int day,int resp,int pp){
    int res=0;
    int temp;
    if(mem[day][resp][pp]!=0)return mem[day][resp][pp];
    if(day==n)return 1;
    if(str[day]=='J')temp=1;
    else if(str[day]=='O')temp=2;
    else if(str[day]=='I')temp=4;
    FOR(i,1,7){
        if(day==0){
            if((temp&i)&&i&1){
                res+=cal(day+1,temp,i)%mod;
            }
        }
        else if((pp&i)&&(temp&i)){
            res+=cal(day+1,temp,i)%mod;
        }
    }
    return mem[day][resp][pp]=res%mod;
}

signed main(){
    cin>>n;
    cin>>str;
    cout<<cal(0,0,0)<<endl;
}

Measured memory_bytes: 1776
#include <iostream>
#include <string>
#include <map>
#include <cstdlib>
#include <cctype>

using namespace std;

map<string, int> weight_table;

struct Result {
	int p, v;
};

#define PARSER_DECL(name) Result name (const string &s, int p)

PARSER_DECL(molecule);
PARSER_DECL(atom);
PARSER_DECL(number);

PARSER_DECL(molecule){
	Result r;
	if(s[p] == '('){
		r = molecule(s, p + 1);
		Result q = number(s, r.p + 1);
		r.v *= q.v;
		r.p = q.p;
	}else{
		r = atom(s, p);
		if(isdigit(s[r.p])){
			Result q = number(s, r.p);
			r.v *= q.v;
			r.p = q.p;
		}
	}
	while(r.p < s.size() && s[r.p] != ')'){
		Result q = molecule(s, r.p);
		r.v += q.v;
		r.p = q.p;
	}
	return r;
}
PARSER_DECL(atom){
	Result r;
	char name[3] = { 0 };
	name[0] = s[p++];
	if(islower(s[p])){ name[1] = s[p++]; }
	if(weight_table.find(string(name)) == weight_table.end()){ throw 0; }
	r.v = weight_table[string(name)];
	r.p = p;
	return r;
}
PARSER_DECL(number){
	Result r;
	char num[3] = { 0 };
	num[0] = s[p++];
	if(isdigit(s[p])){ num[1] = s[p++]; }
	r.v = atoi(num);
	r.p = p;
	return r;
}

int main(){
	string name;
	int weight;
	while(true){
		cin >> name;
		if(name == "END_OF_FIRST_PART"){ break; }
		cin >> weight;
		weight_table[name] = weight;
	}
	while(true){
		cin >> name;
		if(name == "0"){ break; }
		try {
			Result r = molecule(name, 0);
			cout << r.v << endl;
		}catch(...){
			cout << "UNKNOWN" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.fct = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.fct[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.fct[i + 1] = self.fct[i] * (i + 1) % mod
        self.inv[n] = pow(self.fct[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def fact(self, m):
        return self.fct[m]

    def invf(self, m):
        return self.inv[m]

    def perm(self, m, k):
        if m < k: return 0
        return self.fct[m] * self.inv[m - k] % self.mod

    def comb(self, m, k):
        if m < k: return 0
        return self.fct[m] * self.inv[k] * self.inv[m - k] % self.mod

MOD = 1000000007

N, M = map(int, input().split())

f = Factorial(M, MOD)

res = f.perm(M, N)

for k in range(1, N + 1):
    res -= (-1)**(k - 1) * f.comb(N, k) * f.perm(M - k, N - k)

res *= f.perm(M, N)
res %= MOD

print(res)

Measured memory_bytes: 48680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

ll tmp;
bool negative_cycle = false; // 閉路があればtrue
template<typename T>
vector<T> bellmanford(vector<vector<pair<ll,T>>> &G, ll start){
    const T inf = numeric_limits<T>::max();
    ll N = G.size();
    vector<T> dist(N, inf);
    dist[start] = 0;
    rep(i,N*2){
        rep(from,N){
            if (dist[from] == inf) continue;
            for(auto e:G[from]){
                ll to;T cost;
                tie(to, cost) = e;
                if(dist[to] > dist[from] + cost){
                    dist[to] = dist[from] + cost;
                    if (i >= N - 1){
                        negative_cycle = true; //閉路あり
                        dist[to] = -1e9;
                    }
                }
            }
        }
        if (i == N - 2) tmp = dist.back();
    }

    return dist;
}

int main() {
    init();
    ll N, M, P;
    cin >> N >> M >> P;
    vvc<pair<ll, ll>> G(N);
    rep(i,M){
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].eb(b, P-c);
    }

    vc<ll> C = bellmanford(G, 0);

    if(C.back()!=tmp){
        cout << -1 << endl;
        return 0;
    }
    cout << max(0ll, -C.back()) << endl;
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline
import collections


def main():
    N = int(input())
    S = [input().strip() for _ in range(N)]
    c = collections.Counter(S)
    print(len(c))


    
    
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 38916
// =========
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::process::exit;

const MOD: usize = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========
fn warshall_floyd(adjm: &mut Vec<Vec<Option<i64>>>) -> i64 {
    let n = adjm.len();
    let mut need = vec![vec![true; n]; n];
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if let (Some(dik), Some(djk)) = (adjm[i][k], adjm[k][j]) {
                    // 短くなったらだめ
                    if adjm[i][j].unwrap() > dik + djk {
                        // println!("{:?}", (i, j, k));
                        return -1;
                    } else if i != k && j != k && adjm[i][j].unwrap() == dik + djk {
                        need[i][j] = false;
                    }
                }
            }
        }
    }
    let mut res = 0;
    for i in 0..n {
        for j in i + 1..n {
            if need[i][j] {
                res += adjm[i][j].unwrap();
            }
        }
    }
    res
}
fn main() {
    input! {
        v: usize,
        adjm: [[i64;v];v],
    }
    let mut adjm = adjm
        .iter()
        .map(|v| v.iter().map(|e| Some(*e)).collect::<Vec<Option<i64>>>())
        .collect::<Vec<Vec<Option<i64>>>>();
    println!("{:?}", warshall_floyd(&mut adjm));
}

mod tests {
    use super::*;
    #[test]
    fn check() {}
}


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

int main()
{
    int N;
    cin >> N;
    int M = N;
    int x = 0;
    while (M / 10 != 0)
    {
        x += M % 10;
        M = M / 10;
    }
    x = x + M;

    if( N%x == 0 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    int N, M; cin >> N >> M;
    vi A(M), B(M);
    REP(i,M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    vvi es = vvi(N, vi(N));
    REP(i,M) {
        es[A[i]][B[i]] = 1;
        es[B[i]][A[i]] = 1;
    }
    
    int ans = 0;

    REP(i,M) {
        es[A[i]][B[i]] = 0;
        es[B[i]][A[i]] = 0;

        queue<int> que;
        que.push(0);
        vb vis = vb(N, false);
        while(!que.empty()) {
            int x = que.front(); que.pop();
            vis[x] = true;

            for(int nx = 0; nx<N; nx++) {
                if (es[x][nx] <= 0) continue;
                if (vis[nx]) continue;
                que.push(nx);
            }
        }

        REP(i,N) {
            if (!vis[i]) {
                ans++;
                break;
            }
        }

        es[A[i]][B[i]] = 1;
        es[B[i]][A[i]] = 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    //val n =
    readLine()      //!!.toInt()
    val rates = readLine()!!.split(" ").map(String::toInt)      // 1≤ai≤4800

    /** 400ごとなのでwhen不要
     * @return 0-8 */
    fun rank(rate: Int): Int {
        // 3600を超えた場合でも8
        return Math.min(rate / 400, 8)     //Kotlin1.1ならminOf()が使えるのに。
    }

    val ranks = rates.map(::rank)
    val rankerCounts = IntArray(9, { 0 }).apply {
        ranks.forEach { this[it]++ }
    }.toList()

    val colorCount = (0..7).count { rankerCounts[it] != 0 }
    val highRateCount = rankerCounts[8]
    // 全員3200以上ならcountは0だが、minは1
    val min = Math.max(1, colorCount)
    //「好きな色」は「8色の中から」ではなく「8色以外の色」も選べるという意味なのか...
    val max = colorCount + highRateCount

    println("$min $max")
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, k, dd;
  cin >> n >> k;
  set<int> d;
  for (int i = 0; i < 10; ++i) d.insert(i);
  rep(i, k) cin >> dd, d.erase(dd);

  int ans = n;
  bool flg = true;
  while (1) {
    string s = to_string(ans);
    flg = true;
    for (int i = 0; i < s.length(); ++i) {
      int nn = s[i] - '0';
      if (d.find(nn) == d.end()) {
        flg = false;
        break;
      }
    }
    if (flg) break;
    ans++;
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
use std::io;


/// https://beta.atcoder.jp/contests/agc018/tasks/agc018_a
fn main() {
    let (_n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let a = read::<usize>();

    let max = a.iter().max().unwrap();

    let gcd = a.iter()
        .fold(a[0], |x, &y| gcd(x, y));

    if k % gcd == 0 && k <= *max {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }

}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0{
        a
    } else {
        gcd(b, a % b)
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 6524
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    double r;
    cin >> r;
    print(2.0 * r * 3.14);

}



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

int main(){
    int n,q; cin>>n>>q;
    string s; cin>>s;
    int a[100010]={0};
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            a[i+1]++;
        }
    }
    for(int i=1;i<s.size();i++){
        a[i]+=a[i-1];
    }
    int l[100010],r[100010];
    for(int i=0;i<q;i++){
        cin>>l[i]>>r[i];
    }
    for(int i=0;i<q;i++){
        cout<<a[r[i]-1]-a[l[i]-1]<<endl;
    }
    return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            int M1 = int.Parse(L[0]);
            int D1 = int.Parse(L[1]);
            S = Console.ReadLine();
            L = S.Split(' ');
            int M2 = int.Parse(L[0]);
            int D2 = int.Parse(L[1]);

            if(D2 == 1)
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }

        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long  
#define PI 3.14159265358979323846
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb emplace_back
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define F first
#define S second
#define mod 1073741824
using namespace std;



int32_t main(){
	IOS
	int n, x, t;
	cin >> n >> x >> t;
	int ans = 0;
	while(n > 0){
		ans += t;
		n -= x;
	}
	cout << ans;
}																				

Measured memory_bytes: 3640