akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    set<pair<int,int>> S;
    rep(i,M) {
        int a, b; cin >> a >> b;
        a--, b--;
        if (a > b) swap(a,b);
        S.insert({a,b});
    }
    for (auto [a,b] : S) {
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<vector<int>> F;
    set<int> used;
    ll ma = 0;
    rep(i,N) {
        if (used.count(i) > 0) continue;
        vector<int> f;
        f.push_back(i);
        used.insert(i);
        stack<int> st;
        st.push(i);
        while (!st.empty()) {
            int i = st.top(); st.pop();
            for (auto x : G[i]) {
                if (used.count(x) > 0) continue;
                f.push_back(x);
                used.insert(x);
                st.push(x);
            }
        }
        F.push_back(f);
        if (ma < f.size()) ma = f.size();
    }

    cout << ma << endl;

}


Measured memory_bytes: 34484
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    string S; cin >> S;
    if (S[S.size() - 1] == 's')cout << S << "es" << endl;
    else cout << S << "s" << endl;
}



Measured memory_bytes: 3620
//https://atcoder.jp/contests/abc166/tasks/abc166_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<static_cast<ll>(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
  ll N,K; cin>>N>>K;
  vector<ll> s(N+1);
  FOR(i,1,K+1){
    ll d; cin>>d;
    FOR(j,1,d+1){
      ll a; cin>>a;
      s.at(a)++;
    }
  }
  ll ans=0;
  FOR(i,1,s.size()){
    if(s.at(i)==0){
      ++ans;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
S = input()

right = [[0 for _ in range(10)] for _ in range(N + 1)]
left = [[0 for _ in range(10)] for _ in range(N + 1)]
C = [[[0 for _ in range(10)] for _ in range(10)] for _ in range(10)]

for i in range(N - 1):
    for j in range(10):
        right[i + 1][j] += right[i][j]
    right[i + 1][int(S[i])] += 1

for i in range(N - 1, 0, -1):
    for j in range(10):
        left[i][j] += left[i + 1][j]
    left[i][int(S[i])] += 1

for i in range(1, N - 1):
    for a in range(10):
        for b in range(10):
            if right[i][a] != 0 and left[i + 1][b] != 0:
                C[a][int(S[i])][b] += 1

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if C[i][j][k] != 0:
                res += 1

print(res)


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

#define DIV 1000000007

long long X,Y;

long long kaidan[10000000];

void kaical(long long n){
	kaidan[0] = 1;
	for(long long i = 1; i < n; i++){
		kaidan[i] = kaidan[i-1] * i;
		kaidan[i] %= DIV;
	}
}

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

//nCk
long long combination(long long n, long long k){
	if(n == 0 && k == 0)return 1;
	if(n < k || n < 0)return 0;
	long long n_kai = kaidan[n];
	long long k_kai = kaidan[k];
	long long nmk_kai = kaidan[n-k];

	long long ans = n_kai * modpow(k_kai, DIV - 2);
	ans %= DIV;
	ans *= modpow(nmk_kai, DIV-2);
	ans %= DIV;
	return ans;
}


int main(){
	cin >> X >> Y;
	kaical(X+Y);
	long long ans = 0;
	//i + 1, j + 2に動く回数をnum1,  i+2, j+1に動く回数をnum2とする
	for(long long num1 = 0; num1 <= X; num1++){
		long long x1 = num1;
		long long y1 = num1*2;
		long long x2 = X - x1;
		long long y2 = Y - y1;
		long long num2 = y2;
		if(num2*2 == x2){
			ans += combination(num1+num2, num1);
			ans %= DIV;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 16640
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    return gcd(b, a % b)

ans = L[0]
for i in range(1, N):
    p = gcd(ans, L[i])
    ans = ans * L[i] // p

print(ans)

Measured memory_bytes: 3444
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll n,m; cin >> n >>m;
        ll L[m+1], R[m+1];
        for(int i = 0; i<m; i++){
            cin >> L[i] >> R[i];
        }
        sort(L,L+m);
        sort(R,R+m);
        ll X = L[m-1];
        ll Y = R[0];
        ll ans =Y-X+1;
        cout<<(ans<=0 ? 0: ans)<<endl;

return 0;
}




Measured memory_bytes: 1792
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
h = [0 for i in range(N)]
for i in range(N):
    h[i] = int(input())

h.sort()
ans = mod
for i in range(N - K + 1):
    # print(h[i+K - 1] , h[i])
    ans = min(ans, h[i + K - 1] - h[i])
print(ans)

Measured memory_bytes: 15088
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;

  for (uint i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (S[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def debug(k,v) puts "#{k}: #{v}" end
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end #Using .sort.reverse instead decreases Exec Time but increases Memory Usage
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
#sumはつかえない

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end 


N,A,B,C = gsmi

def calc(v, ls)
	cost = (0..2).map do |i|
		if v.count(i)==0
			return 5000
		else
			(v.count(i)-1)*10
		end
	end
	cost = sum(cost)
	abc = [-A,-B,-C]
	(0...N).each do |i|
		abc[v[i]] += ls[i] if v[i]!=3
	end
	abc.inject(cost){|ret,n| ret+n.abs}
end

def dfs(depth, v, ls)
	return calc(v, ls) if depth == 0
	(0..3).map do |i|
		v[depth-1] = i
		dfs(depth-1, v, ls)
	end.min
end


ls = []
N.times do
	ls << gi
end

puts dfs(N, []*N, ls)

Measured memory_bytes: 1788
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#define ll long long
#define sf scanf
#define pf printf
using namespace std;
const ll mod=1e9+9;


int main(){
	int t;
	cin>>t;
	if(t>=30) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    vector<bool> broken(N+1);
    REP(i, M){
        int a;cin>>a;
        broken[a]=true;
    }
    constexpr ll mod=1e9+7;
    vector<ll> dp(N+1);
    dp[0]=1;
    REP(i,N) if(!broken[i+1]){
        dp[i+1]+=dp[i];
        if(i>0) dp[i+1]+=dp[i-1];
        dp[i+1]%=mod;
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 1024
from collections import defaultdict

n=int(input())
A_list = list(map(int,input().split()))

d = defaultdict(int)
ans = 0

for i, a in enumerate(A_list, 1):
    d[i+a] += 1

for i, a in enumerate(A_list, 1):
    ans += d[i-a]

print(ans)

Measured memory_bytes: 61464
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var A = input[1].split(" ").map(i => BigInt(i));
  A.sort();
  var ans = 1n;
  for(var i=0;i<N;i++){
    ans = ans * A[i];
    if(ans > 1000000000000000000n){
      ans = -1;
      break;
    }else if(ans === 0n){
      break;
    }
  }
  ans = ans.toString();

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 60148
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();
	
	int a, b;
	cin >> a >> b;
	if (a > b && b != 1)
		cout << "Alice" << endl;
	else if (b > a && a != 1)
		cout << "Bob" << endl;
	else if (a == 1&&b!=1)
		cout << "Alice" << endl;
	else if (b == 1&&a!=1)
		cout << "Bob" << endl;
	else if (a==b)
		cout << "Draw"<<endl;
	
}

Measured memory_bytes: 3568
#include"bits/stdc++.h"
#include <iostream>
#include <vector>


using namespace std;


int main(){
	
	int N,W;

	cin >> N >> W ;

	vector<vector<int> > dp(N+1, vector<int>(W+1));
	
	vector<int> v(N);
	vector<int> w(N);

	for(int i = 0; i <N; i++){
		cin >> v[i] >> w[i];
	}


	for(int i = 1; i <= N; i++){
		for(int j= 1; j <= W; j++){
			if(j<w[i-1]){
				dp[i][j] = dp[i-1][j];
			}
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-w[i-1]] +v[i-1]);
			}

		}
	}
	
	cout << dp[N][W] << endl;

	return 0;
}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	cout<<(n/k+(n%k))-(n/k)<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <numeric>
using namespace std;
int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

int main(){
    int n,x,ans;
    cin >> n >> x;
    vector<int>  a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = abs(a[i]-x);
    }  
    if(n == 1){
        cout << b[0] << endl;
    }else{
    ans = gcd(b[0],b[1]);
    for(int i = 2; i < n; i++){
        ans = gcd(b[i],ans);
    }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};

bool operator< ( const State& a, const State& b) {
	return a.enemy < b.enemy;
}

bool operator> ( const State& a, const State& b) {
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

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

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, vector<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll K;
    cin>>K;
    for(ll i=0;i<K;i++){
        cout<<"ACL";
    }
    cout<<endl;
}

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

int main(void)
{
  string sign;
  int takahashi = 0;
  cin >> sign;
  for (int i = 0; i < (int)sign.size(); i++) {
    takahashi += sign[i] == '+' ? 1 : -1;
  }
  cout << takahashi;
}

Measured memory_bytes: 256
#include <stdio.h>

#define WIDTH 12
#define HEIGHT 12

void del( int, int );

char field[ WIDTH + 2 ][ HEIGHT + 2 ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int x, y, island;

	while ( ungetc( getchar(), stdin ) != EOF ) {
		for ( y = 1; y <= HEIGHT; y++ )
			for ( x = 1; x <= WIDTH; x++ )
				scanf( "%c ", field[ x ] + y );

		island = 0;
		for ( y = 1; y <= HEIGHT; y++ )
			for ( x = 1; x <= WIDTH; x++ )
				if ( field[ x ][ y ] == '1' ) {
					del( x, y );
					island++;
				}

		printf( "%d\n", island );
	}

	return 0;
}

void del( int x, int y ) {
	int i;

	field[ x ][ y ] = '0';

	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( field[ nx ][ ny ] == '1' )
			del( nx, ny );
	}
}

Measured memory_bytes: 548
/*  ex5_3
    B30095    */
#include <stdio.h>
#include <stdlib.h>
#define MAX_HEIGHT 100
#define MAX_WIDTH 100

 
int main(void){
    int height, width, isRowEmpty, isColEmpty, i, j;
    char matrix[MAX_HEIGHT][MAX_WIDTH];
    
    scanf("%d %d", &height, &width);

    for(i = 0; i < height; i++){
        for(j = 0; j < width; j++){
            scanf(" %c", &(matrix[i][j]));
        }
    }


    // substitue empty rows with whitespaces
    for(i = 0; i < height; i ++){
        isRowEmpty = 1;
        
        // check if the row is empty
        for(j = 0; j < width; j++){
            if(matrix[i][j] == '#') {
                isRowEmpty = 0;
            }
        }

        // fill in empty rows with whitespaces
        if(isRowEmpty){
            for(j = 0; j < width; j++){
                matrix[i][j] = ' ';
            }
        }
    }

    // substitue empty columns with whitespaces
    for(j = 0; j < width; j ++){
        isColEmpty = 1;
        
        // check if the column is empty
        for(i = 0; i < height; i++){
            if(matrix[i][j] == '#') {
                isColEmpty = 0;
            }
        }

        // fill in empty columns with whitespaces
        if(isColEmpty){
            for(i = 0; i < height; i++){
                matrix[i][j] = ' ';
            }
        }
    }


    // print compressed result
    for(i = 0; i < height; i++){
        isRowEmpty = 1;

        for(j = 0; j < width; j++){
            if(matrix[i][j] == '#') isRowEmpty = 0;
            if(matrix[i][j] != ' ') printf("%c", matrix[i][j]);
            
        }

        if(!isRowEmpty) printf("\n");  // new line should not be printed when the row is empty
    }

    return 0;
}


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

string s;

int a, b;

int ans;

int main(void){
  // Here your code !
  scanf("%d %d", &a, &b);

  if (b >= a) ans = a;
  else ans = a - 1;

  printf("%d\n", ans);
  return 0;
}


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

int main(void)
{
    string S;
    cin >> S;
    int len = S.size();
    int keylen = 7;

    bool clear = false;
    for(int i = 0; i < keylen; i++){
        string t = S.substr(0,i) + S.substr(len - (keylen - i));
        if(t == "keyence"){
            clear = true;
            break;
        }
    }

    if(clear){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

struct BIT {
    int n;
    vector<int> bit; // 1-indexd

    BIT(int sz) {
        bit.resize(sz + 1);
        n = sz;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

class ESnukeLine {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;

        vector<vector<P>> v(M + 1);
        REP(i, N) {
            int l, r;
            cin >> l >> r;
            v[r - l + 1].push_back({l, r});
        }

        BIT bit(1e5 + 5);

        int num = N;
        FOR(d, 1, M) {
            if (d > 1) {
                for (auto kv : v[d - 1]) {
                    bit.add(kv.first, 1);
                    bit.add(kv.second + 1, -1);
                    num--;
                }
            }

            int res = num;
            int cur = d;
            while (cur <= M) {
                res += bit.sum(cur);
                cur += d;
            }
            cout << res << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ESnukeLine solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;
const double PAI = acos(-1);
constexpr long double eps = 1e-9;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    vector<ll> A(n),B(n);
    for(int i=0;i<n;++i){
        ll a,b;
        cin>>a>>b;
        v[i] = {a,b};
        A[i] = a;
        B[i] = b;
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(n%2 != 0){
        ll opa = A[n/2];
        ll opb = B[n/2];
        cout << opb - opa +1 << endl;
    }else {
        ll opa = A[n/2-1] + A[n/2];
        ll opb = B[n/2-1] + B[n/2];
        cout << opb - opa + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 9536
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

int main()
{
	int a; cin >> a;
	int b; cin >> b;

	if (b % a == 0)
		cout << a + b;
	else
		cout << b - a;
}


Measured memory_bytes: 256
A,B,H,M = list(map(int,input().split()))

import math
#得られる三角形の中心の角度を求める
M_rad = (2*math.pi/60)*M
H_rad = (2*math.pi/12)*(H + 1/60*M)
rad = abs(H_rad - M_rad)

#三角形が成立する条件
#長針と短針が被ったとき
if math.degrees(M_rad)-0.1 < math.degrees(H_rad) < math.degrees(M_rad)+0.1:
  print(abs(A-B))
  exit()
#長針と短針が180度の時
elif 180-0.1 < math.degrees(rad) < 180+0.1:
  print(abs(A+B))
  exit()
else:
  #二項定理
  C = math.sqrt(abs(A*A + B*B - 2*A*B*math.cos(rad)))
  print(abs(C))


Measured memory_bytes: 9356
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e6+10;

int main() {
    LL n,k;
    cin>>n>>k;
    LL a=n%k;
    LL b=abs(a-k);
    cout<<min(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np
 
line = input().split()
D = int(line[0])
N = int(line[1])
 
if D == 0:
    if N == 100:
        print(N+1)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print((N+1)*100)
    else:
        print(N*100)
else :
    if N == 100:
        print((N+1)*10000)
    else:
        print(N*10000)
        

Measured memory_bytes: 21412
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll x,y;
    cin>>x;
    ll ans=1e9;
    string s;
    for (int i=1;i<=sqrtl(x);i++){
        if (x%i==0){
            y=x/i;
            s=to_string(y);
            ll m=s.length();
            ans=min(ans,m);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        long[][] dp = new long[3000][N+1];
        dp[0][0] =1;
        for (int i=0;i<N;i++) {
            int x = sc.nextInt();
            long[][] arr = new long[3000][N+1];
            for (int k=0;k<N+1;k++) {
                for (int j=0;j<3000;j++) {
                    arr[j][k] = dp[j][k];
                }
            }
            for (int k=0;k<N;k++) {
                for (int j=0;j<2600;j++) {
                    // dp[j+x][k+1] += dp[j][k];
                    arr[j+x][k+1] += dp[j][k];
                }
            }
            for (int k=0;k<N+1;k++) {
                for (int j=0;j<3000;j++) {
                    dp[j][k] = arr[j][k];
                }
            }
            // long[] arr = new long[3000];
            // for (int j=0;j<2600;j++) {
            //     arr[j] += dp[j];
            //     arr[j+x] += dp[j];
            // }
            // for (int j=0;j<3000;j++) {
            //     dp[j] = arr[j];
            // }
        }
        long ans = 0L;
        for (int i=1;i<3000;i++) {
            // if (i%A==0) ans+=dp[i];
            for (int j=1;j<N+1;j++) {
                if (j*A==i) ans += dp[i][j];
            }
        }
        for (int i=0;i<30;i++) {
            StringBuilder sb = new StringBuilder();
            for (int j=0;j<N;j++) {
                sb.append(dp[i][j]);
                sb.append(" ");
            }
            // System.out.println(sb);
        }
        // System.out.println(Arrays.toString(Arrays.copyOf(dp, 50)));
        System.out.println(ans);
    }
}

Measured memory_bytes: 61624
#include<cstdio>

const int mx=1e5;
int hil[mx+5];
bool hh[mx+5]={0};
int main(){
	int n, m;
	scanf("%d %d",&n, &m);
	for(int i =1;i<=n;i++){
		scanf("%d",&hil[i]);
	}
	
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d %d",&a, &b);
		if(hil[a] > hil[b]) hh[b]=1;
		else if(hil[a] < hil[b]) hh[a]=1;
		else {
			hh[a] = 1;
			hh[b] = 1;
		}
	}
	int answer=0;
	for(int i =1;i<=n;i++){
		if(hh[i]==0) answer++; 
	}
	
	
	printf("%d",answer);
	return 0;
}

Measured memory_bytes: 2216
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	int M = max(A, max(B, C));
	int ans = A + B + C - M;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 305
using namespace std;

int n, m, l, r, ans, md, a[N][N], k[N], cnt[N];
bool w, h, z[N];
int main()
{
	int i, j, t;
//	freopen ("input.txt", "r", stdin);
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			scanf ("%d", &a[i][j]);
		}
	}
	l = 1;
	r = n + 1;
	while (l < r) {
		md = (l + r) / 2;
		w = true;
		for (i = 1; i <= n; i++) k[i] = 1;
		for (i = 1; i <= m; i++) z[i] = false;
		while (1) {
			h = true;
			for (i = 1; i <= m; i++) cnt[i] = 0;
			for (i = 1; i <= n; i++) {
				t = a[i][k[i]];
				cnt[t]++;
				if (cnt[t] > md || z[t]) h = false;
			}
			if (h) break;
			for (i = 1; i <= n; i++) {
				t = a[i][k[i]];
				if (cnt[t] > md || z[t]) {
					z[t] = true;
					k[i]++;
					if (k[i] > m) {
						w = false;
						break;
					}
				}
			}
			if (!w) break;
		}
		if (!w) {
			l = md + 1;
		} else {
			r = md;
			ans = md;
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll a,b,k;
	cin>>a>>b>>k;
	if(a >= k){
		a -= k;
	}
	else{
		k -= a;
		a = 0;
		b -= k;
		if(b<0)
			b=0;
	}		

	cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
      cin >> s[i];
    }
    sort(s.begin(),s.end());

    vector<string> ans;
    ans.push_back(s[0]);

    int Max = 1, count = 1;
    rep(i,n-1){
        if (s[i]==s[i+1]) {
            ++count;
            if (Max < count) {
                ans.clear();
                Max = count;
            }
        } else {
            count = 1;
        }

        if (Max==count) {
            ans.push_back(s[i+1]);
        }
    }

    sort(ans.begin(),ans.end());
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
    
}


Measured memory_bytes: 13168
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    string s;
    cin >> s;
    
    if(s[0]==s[1]){
        if(s[2]==s[3]&&s[2]!=s[1]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(s[0]==s[2]){
        if(s[1]==s[3]&&s[1]!=s[2]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(s[0]==s[3]){
        if(s[1]==s[2]&&s[1]!=s[0]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
	return 0;
}



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

using namespace std;

static const int maxn = 1e5 + 5;

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);



      int len;
      cin >> len;
      string s;
      cin >> s;
      int ans = 1;
      for (int i = 1; i < len; i++)
      {
            if (s[i] != s[i - 1]) ++ans;
      }
      cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	string s[3];
	int ans=0;
	
	cin>>s[0];
	cin>>s[1];
	cin>>s[2];
	cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int dp[41][500][500];
int main()
{
	int num, ma, mb;
	scanf("%d%d%d", &num, &ma, &mb);
	for (int i = 0; i <= num; i++)for (int j = 0; j <= 400; j++)for (int k = 0; k <= 400; k++)dp[i][j][k] = 1000000000;
	dp[0][0][0] = 0;
	for (int i = 0; i < num; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		for (int j = 0; j <= 400; j++)for (int k = 0; k <= 400; k++)dp[i + 1][j + za][k + zb] = min(dp[i + 1][j + za][k + zb], dp[i][j][k] + zc);
		for (int j = 0; j <= 400; j++)for (int k = 0; k <= 400; k++)dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
	}
	int mini = 1000000000;
	for (int i = 1; i*ma <= 400 && i*mb <= 400; i++)mini = min(mini, dp[num][i*ma][i*mb]);
	if (mini == 1000000000)printf("-1\n");
	else printf("%d\n", mini);
}

Measured memory_bytes: 39552
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

int main() {
	ll x;
	cin >> x;
	if (x==7 || x==5 || x==3){cout << "YES"<< endl;}
	else {cout << "NO" << endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int w , h;
    cin >> h >> w;

    vector<string> s;
    s.resize(h);

    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    vector<bool> fh(h), fw(w);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if ( s[i][j] == '#' ) {
                fh[i] = true;
                fw[j] = true;
            }
        }
        
    }
    
    
    for (int i = 0; i < h; i++) {
        int c = 0;
        for (int j = 0; j < w; j++){
            if (fw[j]&&fh[i]) {
                cout << s[i][j];
                c++;
            }
        }
        if (c >0 ) cout << endl;
    }    
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ans = 0
for switch in range(2 ** N):
    for i, ksi in enumerate(ks):
        ki = ksi[0]
        si = ksi[1:]
        #
        cnt = 0
        for j, sij in enumerate(si):
            cnt += (switch >> (sij - 1)) & 1
        #
        if cnt % 2 != p[i]:
            break
        else:
            continue
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
    int N, X, Y;
    scanf("%d %d %d", &N, &X, &Y);
    std::vector <int> count;
    for (int i = 0; i < N; i++) {
        count.push_back(0);
    }
    for (int i = 1; i < N; i++) {
        for (int j = i + 1; j < N + 1; j++) {
            count[std::min({abs(i - j),
                            abs(X - i) + 1 + abs(j - Y),
                            abs(Y - i) + 1 + abs(j - X)})] += 1;
        }
    }
    for (int i = 1; i < N; i++) {
        printf("%d\n", count[i]);
    }
}

Measured memory_bytes: 384
def main():
    n, x, y = map(int, input().split())
    count = {}
    for i in range(1, n):
        count[i] = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            dist = min(j - i, 1 + abs(y - j) + abs(x - i))
            count[dist] += 1
    for i in range(1, n):
        print(count[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	string a,b;
	int ans=0;
	for(int i=1;i<s.size()-1;i++){
		int c[26]={},d[26]={};
		a=s.substr(0,i);
		b=s.substr(i,s.size()-a.size());
		for(int j=0;j<a.size();j++){
			c[a[j]-'a']++;
		}
		for(int j=0;j<b.size();j++){
			d[b[j]-'a']++;
		}
		int cnt=0;
		for(int i=0;i<26;i++){
			if(c[i]>0&&d[i]>0)cnt++;
		}
		if(cnt>ans)ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
(defun read-string () ;スペース区切りstring入力
  (let* ((str (read-line)))
    (labels ((instring (instring-str rt)
               (let* ((pos (position #\Space instring-str :test #'char=)))
                 (if pos
                     (instring (subseq instring-str (1+ pos))
                               (cons (subseq instring-str 0 pos) rt))
                     (cons instring-str rt)))))
      (reverse (instring str nil)))))
(let* ((n (read-string))
       (m (cons (read) (read)))
       (f (read-line)))
  (format t "~A ~A" (if (string= f (first n))
                        (1- (car m)) (car m))
          (if (string= f (second n))
              (1- (cdr m)) (cdr m))))


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

#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define eb emplace_back

int n;
int a[111];
int b[111];

int main() {
	fast;

	cin >> n;

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

	int ans = 0;
	for(int i=1; i<=n; i++) {
		ans += min(b[i-1], b[i]);
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

/**
* @brief ある整数の階乗を求める
*/
class Factorial
{
public:
    /**
    * @fn int getFactorial(int target)
    * @brief パラメータの階乗を取得する
    * @param[in] target ターゲット
    * @return int 階乗
    */
    long long getFactorial(int target) const;

private:
    /**
    * @fn int calc(int target)
    * @brief 階乗を計算する
    * @param[in] target ターゲット
    * @return int 階乗
    */
    long long calc(int target) const;
};

/**
* @brief コントロール
*/
class Control
{
public:
    /**
    * @fn  bool executeEx() const
    * @brief １つの整数を読み込み、その整数の階乗を出力する
    * @return bool 入力範囲内ならtrueを、そうでなければfalseを返す
    */
    bool executeEx() const;

private:
    /**
    * @fn bool check(int target) const
    * @brief 入力範囲をチェックする
    * @param[in] target チェック対象
    * @return bool 入力範囲内ならtrueを、そうでなければfalseを返す
    */
    bool check(int target) const;

    /**
    * @fn void read(int& data)
    * @brief 標準入力から読み込む
    * @param[out] data 入力整数
    */
    void read(int& data) const;

    /**
    * @fn void write(int target) const
    * @brief 標準出力に書き込む
    * @param[in] target 出力対象
    */
    void write(long long target) const;
};

long long Factorial::getFactorial(int target) const
{
    return calc(target);
}

long long Factorial::calc(int target) const
{
    if (1 >= target)
        return 1;

    return target * calc(target - 1);
}

bool Control::executeEx() const
{
    int input = 0;
    long long output = 0;

    read(input);

    if (!check(input))
        return false;

    output = Factorial().getFactorial(input);

    write(output);

    return true;;
}

bool Control::check(int target) const
{
    static const int Min = 1;
    static const int Max = 20;

    if (Min > target || Max < target)
        return false;

    return true;
}

void Control::read(int& data) const
{
    std::cin >> data;
}

void Control::write(long long target) const
{
    std::cout << target << std::endl;
}

/**
* @fn int main()
* @brief エントリポイント
*/
int main()
{
    if (!Control().executeEx())
        return 1;
}



Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n ; cin >> n;
  int ac, wa, tle, re;
  ac = wa = tle = re = 0;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    if(s == "AC"){
      ac++;
    }
    else if(s == "WA"){
      wa++;
    }
    else if(s == "TLE"){
      tle++;
    }
    else if(s == "RE"){
      re++;
    }

  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3660
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let aa = get!(String).split_whitespace().map(|i| i.parse::<i32>().unwrap()).enumerate().collect::<Vec<_>>();
    let mut bb = Vec::new();
    let mut cc = Vec::new();
    for (i, a) in aa.into_iter() {
        if i%2 == 1 {
            bb.push(a);
        } else {
            cc.push(a);
        }
    }
    let res = if n%2 == 0 {
        bb.reverse();
        [bb, cc]
    } else {
        cc.reverse();
        [cc, bb] 
    };
    println!("{}", res.concat().into_iter().map(|i| i.to_string()).collect::<Vec<_>>().join(" "));
}

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

int main() {
	int N = 0, X = 0, D = 0, ans = 0;
	cin >> N >> X;
	int L;
	for (int i = 0; i < N +1; i++) {
		cin >> L;
		if (D > X)
			break;
		D += L;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll const mod=1e9+7;
double const pi=acos(-1);
int s[105];
int main()
{
	int n,k;
	cin>>n>>k;
	int sum=0;
	while(k--)
	{
		int d;
		cin>>d;
		int x;
		for(int i=0;i<d;i++)
		{
			cin>>x;
			s[x]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(s[i]==0)
			sum++;
	}
	cout<<sum<<endl;
	
	
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
  double r, s, x;
  cin >> r;

  s = r * r * 3.141592653589;
  x = 2 * r * 3.141592653589;

  printf("%lf %lf", s, x);
  return 0;
}


Measured memory_bytes: 3284
# https://atcoder.jp/contests/abc051/tasks/abc051_b

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

# initialize
ans = 0

# logic: 全探索: 基本形
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            ans += 1
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

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

		int[] x, y, z;
		int swap;
		
		int n = scan.nextInt();
		x = new int[n];
		y = new int[n];
		z = new int[n];
		
		for(int i = 0; i < n; i++){
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
			z[i] = scan.nextInt();
		}
		
		for(int i = 0; i < n; i++){
			if(x[i]*x[i] + y[i]*y[i] == z[i]*z[i] ||
			   x[i]*x[i] + z[i]*z[i] == y[i]*y[i] ||
			   z[i]*z[i] + y[i]*y[i] == x[i]*x[i]) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 33624
int main (void){
  int a,b;
  scanf("%d%d",&a,&b);
  int ab[b];
  int ba[a];
  for(int i=0;i<b;i++){
    ab[i]=a;
  }
  for(int i=0;i<a;i++){
    ba[i]=b;
  }
  if(a<b){
    for(int i=0;i<b;i++){
      printf("%d",ab[i]);  
    }
  }else{
    for(int i=0;i<a;i++){
      printf("%d",ba[i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main(void){
    int a,b,d,r;
    double f;
    int max=pow(10,9);
    
    scanf("%d %d",&a,&b);
    
    if(a<1||max<a||b<1||max<b){
        printf("error\n");
        return 0;
    }
    
    d=a/b;
    r=a%b;
    f=(double)a/b;
    
    printf("%d %d %lf\n",d,r,f);
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    rep(i,n){
        bool ok = true;
        rep(j,n){
            if(s[j] != t[(i+j)%n]) ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int pre = 0;
    int post = 0;

    int level = 0;
    for (char c : S) {
        if (c == '(') {
            ++level;
        } else {
            --level;
            if (level < 0) {
                ++pre;
                ++level;
            }
        }
    }

    post = level;

    cout << string(pre, '(') << S << string(post, ')') << '\n';

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[] for i in range(n)]
b = [0 for j in range(m)]
for i in range(n):
    a[i] = list(map(int, input().split()))
for j in range(m):
    b[j] = int(input())
for row in range(n):
    tmp = 0
    for col in range(m):
        tmp += a[row][col] * b[col]
    print(tmp)



Measured memory_bytes: 6024