akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int x, a;
bool flag[3][100];

int main() {
	int i;
	
	cin >> n;
	cin >> x; rep(i, x) { cin >> a; flag[0][a-1] = true; }
	cin >> x; rep(i, x) { cin >> a; flag[1][a-1] = true; }
	cin >> x; rep(i, x) { cin >> a; flag[2][a-1] = true; }
	int ans = 0;
	rep(i, n) {
		if ((!flag[0][i] && flag[2][i]) || (flag[1][i] && flag[2][i])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws IOException{
               BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));	
		int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int sum = 0;
		for(int i = 0;i<5;i++){
			sum += list[i];
		}
		System.out.println(15-sum);		
	}
}


Measured memory_bytes: 34260
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100100
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;


int main(void){
	int n, h; cin >> h >> n;
	vector<lpair> ab(n);
	rep(i, n){
		cin >> ab[i].first >> ab[i].second;
	}

	//static ll dp[300][SIZE];// dp[技][ダメージ] = コスト
	//fill(dp[0], dp[300], INF);
	//dp[0][0] = 0;
	static ll dp[SIZE];
	fill(dp, dp+SIZE, INF);
	dp[0] = 0;
	rep(i, n){
		rep(j, h+1){
			//dp[0][j+ab[i].first] = min(dp[0][j+ab[i].first], dp[0][j]+ab[i].second);
			dp[j+ab[i].first] = min(dp[j+ab[i].first], dp[j]+ab[i].second);

		}
	}
	//rep(i, n){
	//	rep(j, h+1){
	//		if(dp[i][j] != INF){
	//			dp[i][j+ab[i].first] = min(dp[i][j+ab[i].first], dp[i][j]+ab[i].second);
	//			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
	//			dp[i+1][j+ab[i].first] = min(dp[i+1][j+ab[i].first], dp[i][j]+ab[i].second);
	//			//cout << dp[i+1][j+ab[i].first];
	//		}
	//	}
	//}

	ans = INF;
	rep2(i, h, SIZE){
		ans = min(ans, dp[i]);
	}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

template<typename Monoid,typename F>
struct SegmentTree{
	int sz;
	vector<Monoid> node;
	const F op;//演算
	const Monoid e;//単位元
	SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
		sz=1;
		while(sz<n) sz*=2;
		node.assign(2*sz,e);
	}
	void build(const vector<Monoid> &v){
		int n=v.size();
		for(int i=0;i<n;i++) node[i+sz-1]=v[i];
		for(int i=sz-2;i>=0;i--) node[i]=op(node[2*i+1],node[2*i+2]);
	}
	void update(int k,const Monoid &x){
		k+=sz-1;
		node[k]=x;
		while(k>0){
			k=(k-1)/2;
			node[k]=op(node[2*k+1],node[2*k+2]);
		}
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=sz;
		if(r<=a || b<=l) return e;
		if(a<=l && r<=b) return node[k];
		else{
			Monoid vl=query(a,b,2*k+1,l,(l+r)/2);
			Monoid vr=query(a,b,2*k+2,(l+r)/2,r);
			return op(vl,vr);
		}
	}
	Monoid operator[](const int &k)const{
		return node[k+sz-1];
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	string s;
	cin>>s;
	auto op=[](int a,int b){return min(a,b);};
	SegmentTree<int,decltype(op)> seg(3*n,op,INF);
	vector<int> dp(3*n,INF);
	dp[n]=0;
	seg.build(dp);
	for(int i=n-1;i>=0;i--){
		if(s[i]=='1') continue;
		int now=seg.query(i+1,i+m+1);
		if(now==INF) continue;
		dp[i]=now+1;
		seg.update(i,dp[i]);
	}
	if(dp[0]==INF){
		cout<<-1<<endl;
		return 0;
	}
	vector<int> ans;
	int ind=0,now=dp[0];
	FOR(i,1,n+1){
		if(dp[i]==now-1){
			ans.push_back(i-ind);
			ind=i;
			now--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
double p;
vector<int> G[15];
double dp[1<<14];
double po[101];

int main(void){
	scanf("%d%d%lf",&n,&m,&p);
	p/=100.0;
	po[0]=1.0;
	for(int i=1;i<100;i++){
		po[i]=po[i-1]*p;
	}
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=1;i<(1<<n);i++){
		double val=1.0;
		int j=i-1;
		j=j&i;
		while(j>0){
			int di=i-j;
			if(di<j){
				int cnt=0;
				for(int k=0;k<n;k++){
					if(di>>k & 1){
						for(int l=0;l<G[k].size();l++){
							int v=G[k][l];
							if(j>>v & 1)cnt++;
						}
					}
				}
				val-=dp[j]*po[cnt];
			}
			j=j-1;
			j=j&i;
		}
		dp[i]=val;
		//printf("%d %.2f\n",i,dp[i]);
	}
	printf("%.9f\n",dp[(1<<n)-1]);
	return 0;
} 


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

int main() {
  int n;
  cin >> n;
  vector <double> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  double sum = a[0];
  for (int i = 1; i < n; ++i)
    sum = (sum + a[i]) / 2;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
h = [0] + list(map(int,input().split()))

dp = [None for _ in range(N+1)]
dp[1] = 0
dp[2] = abs(h[2] - h[1])

for i in range(3,N+1):
    jump1 = dp[i-1] + abs(h[i] - h[i-1])
    jump2 = dp[i-2] + abs(h[i] - h[i-2])
    dp[i] = min(jump1,jump2)
    
print(dp[N])

Measured memory_bytes: 13928
use std::collections;
use whiteread::parse_line;

fn main() {
    let k: usize = parse_line().unwrap();
    let mut s = collections::HashSet::new();
    let mut x = 7 % k;
    let mut i = 1;
    for i in 1.. {
        if s.contains(&x) {
            println!("{}", -1);
            return;
        }
        if x == 0 {
            println!("{}", i);
            return;
        }
        s.insert(x);
        x = (x * 10 + 7) % k
    }
}


Measured memory_bytes: 29764
import Control.Applicative( (<$>))
import Data.Map 
import qualified Data.Map as M
import Data.IntMap
import qualified Data.IntMap as IM
import Data.List
import qualified Data.List as L
import Data.ByteString.Char8
import qualified Data.ByteString.Char8 as C8
import Data.Maybe( fromJust)


main = do
    let
	readBS2Int = fst . fromJust . C8.readInt
	readLine2Ints = Prelude.map readBS2Int . C8.words <$> C8.getLine

    n_ <- readLn::IO Int
    as_ <- readLine2Ints
    let
	intCounts::[Int] -> IntMap Int
	intCounts = L.foldl' (\m k->IM.insertWith (+) k 1 m)
							IM.empty
	counter = IM.toAscList $ intCounts as_

	proc mx [(i,c)]		    = c
	proc mx [(i1,c1),(i2,c2)]
	  | i1==i2-1		    = c1+c2
	  | otherwise		    = max c1 c2
	proc mx [(i1,c1),(i2,c2),(i3,c3)]
	  | i1==i2-1 && i2+1==i3    = max mx (c1+c2+c3)
	  | i1==i2-1		    = max mx (c1+c2)
	  |	i2+1==i3	    = max mx (c2+c3)
	  | otherwise		    = max mx c2
	proc mx ((i1,c1):tl@((i2,c2):(i3,c3):as))
	  | i1==i2-1 && i2+1==i3    = proc (max mx (c1+c2+c3)) tl
	  | i1==i2-1		    = proc (max mx (c1+c2)) tl
	  |	i2+1==i3	    = proc (max mx (c2+c3)) tl
	  | otherwise		    = proc (max mx c2) tl
	proc' [(i1,c1),(i2,c2),(i3,c3)]
	  | i1==i2-1 && i2+1==i3    = c1+c2+c3
	  | i1==i2-1		    = c1+c2
	  |	i2+1==i3	    = c2+c3
	  | otherwise		    = L.maximum [c1,c2,c3]
    
    print $ if 3 == L.length counter
	    then proc' counter
	    else proc 0 counter


Measured memory_bytes: 18812
n=int(input())
h=list(map(int,input().split()))
ok=True
for i in range(n-1):
    if h[i+1]-h[i]==0:
        pass
    elif h[i+1]-h[i]==1:
        h[i+1]=h[i]
    elif h[i+1]-h[i]>1:
        h[i+1]-=1
    else :
        ok=False        
print("Yes" if ok else "No")

Measured memory_bytes: 15020
def main():
    import math
    import sys

    input = sys.stdin.readline

    n = int(input())
    c_1 = 0
    c_2 = 0
    c_3 = 0

    for i in range(n):
        for j in range(i,n):
            for k in range(j,n):
                if i == j and j == k:
                    c_1  += i+1
                elif i != j and j != k and k != i:
                    c_2 += math.gcd(math.gcd(i+1,j+1),k+1)
                else:
                    c_3 += math.gcd(i+1,k+1)

    print(c_1 + c_2 * 6 + c_3 * 3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9132
#include <iostream>

using namespace std;

int main()
{
    long long int n,z;
    z=0;
    cin >> n;
    if( n%2==0 )
    {
        long long int i=10;
        while(i<=n)
        {
           z+=(n/i);
           i= i*5;
        }
    }

    cout << z << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    int n; cin >> n;
    vector<int> p(n);
    ll ans = 0;
    rep(i, n) cin >> p[i];

    sort(all(p));
    rep(i, n-1) ans+=p[i];
    cout << ans+p[n-1]/2 << endl;

    return 0;
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int maxAB = min(A, B);
    vector<int> C;
    int count = 0;
    for (int i = 1; i <= maxAB; i++)
    {
        if ((A % i == 0) && (B % i == 0))
        {
            C.push_back(i);
        }
    }
    sort(C.begin(), C.end(), greater<int>());
    for (int i = 0; i < C.size(); i++)
    {
        if (i + 1 == K)
        {
            cout << C[i] << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
    ll N;cin>>N;
    cout<<N*(N-1)/2;
}


Measured memory_bytes: 256
# 遅い…？
import queue as que

from collections import deque 

def main():
    h, w = map(int, input().split())

    ahw = [input() for _ in range(h)]

    board = [[0]*w for _ in range(h)]

    q = deque()
    q.append((-1,-1))
#    q = [(-1,-1)]
    
    for hi in range(h):
        for wi in range(w):
            if ahw[hi][wi] == '#':

                board[hi][wi] = 1
                
                q.append((hi,wi) )

#    print(q)
#    print(board)
    if len(q) == h*w+1:
        print(0)
        return 
    

    def exec(h_,w_):
        if board[h_][w_] == 0:
            q.append((h_,w_))
            board[h_][w_] = 1
   
           
    ans = 0
    while q:
        t = q.popleft()
#        print(t)
        th = t[0]; tw = t[1]

        if th == tw and tw == -1:
            if not q:
                break

            q.append((-1,-1))
            ans += 1
            continue

        if 0<th:
            exec(th-1, tw)
        if th+1 <h:
            exec(th+1, tw)
        if 0<tw:
            exec(th, tw-1)
        if tw +1 <w:
            exec(th, tw+1)

    print(ans-1)

main()

Measured memory_bytes: 107756
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		TreeSet<Integer> ts = new TreeSet<>();
		Integer[] num = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
		ts.addAll(Arrays.asList(num));
		for (int i = 0; i < k; i++) {
			ts.remove(sc.nextInt());
		}
		Integer[] sel = new Integer[ts.size()];
		ts.toArray(sel);
		Arrays.sort(sel);
		int pay = 0;
		for (int g = 0; g < sel.length; g++) {
			StringBuilder sb = new StringBuilder();
			sb.append(sel[g]);
			String s = sb.toString();
			if (s.length() > 0) {
				pay = Integer.parseInt(s);
				if (pay >= n) {
					System.out.println(pay);
					return;
				}//if Block
			}//if Block
		}//for Block
		for (int h = 0; h < sel.length; h++) {
			for (int g = 0; g < sel.length; g++) {
				StringBuilder sb = new StringBuilder();
				sb.append(sel[h]).append(sel[g]);
				String s = sb.toString();
				if (s.length() > 0) {
					pay = Integer.parseInt(s);
					if (pay >= n) {
						System.out.println(pay);
						return;
					}//if Block
				}//if Block
			}//for Block
		}//for Block
		for (int j = 0; j < sel.length; j++) {
			for (int h = 0; h < sel.length; h++) {
				for (int g = 0; g < sel.length; g++) {
					StringBuilder sb = new StringBuilder();
					sb.append(sel[j]).append(sel[h]).append(sel[g]);
					String s = sb.toString();
					if (s.length() > 0) {
						pay = Integer.parseInt(s);
						if (pay >= n) {
							System.out.println(pay);
							return;
						}//if Block
					}//if Block
				}//for Block
			}//for Block
		}//for Block
		for (int i = 0; i < sel.length; i++) {
			for (int j = 0; j < sel.length; j++) {
				for (int h = 0; h < sel.length; h++) {
					for (int g = 0; g < sel.length; g++) {
						StringBuilder sb = new StringBuilder();
						sb.append(sel[i]).append(sel[j]).append(sel[h]).append(sel[g]);
						String s = sb.toString();
						if (s.length() > 0) {
							pay = Integer.parseInt(s);
							if (pay >= n) {
								System.out.println(pay);
								return;
							}//if Block
						}//if Block
					}//for Block
				}//for Block
			}//for Block
		}//for Block
		for (int r = 0; r < sel.length; r++) {
			for (int i = 0; i < sel.length; i++) {
				for (int j = 0; j < sel.length; j++) {
					for (int h = 0; h < sel.length; h++) {
						for (int g = 0; g < sel.length; g++) {
							StringBuilder sb = new StringBuilder();
							sb.append(sel[r]).append(sel[i]).append(sel[j]).append(sel[h]).append(sel[g]);
							String s = sb.toString();
							if (s.length() > 0) {
								pay = Integer.parseInt(s);
								if (pay >= n) {
									System.out.println(pay);
									return;
								}//if Block
							}//if Block
						}//for Block
					}//for Block
				}//for Block
			}//for Block
		}//for Block
	}//method Block
}//class Block

Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include <float.h>
#include<stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int A, B;

    cin >> A >> B;        
    printf("%d %d %5f\n", A/B , A%B, double(A)/double(B));
    return 0;

}


Measured memory_bytes: 3212
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
struct aa {
	int now;
	long long int height;
	long long int time;

};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time-l.height> r.time-r.height;
	}
};
int main() {
	int N, M, X; cin >> N >> M >> X;
	vector<long long int>memos(N,1e17);
	vector<long long int>hs(N);
	for (int i = 0; i < N; ++i) {
		cin >> hs[i];
	}
	vector<vector<pair<int, int>>>edges(N);
	for (int i = 0; i < M; ++i) {
		int a, b, c; cin >> a >> b >> c; a--; b--;
		edges[a].push_back(make_pair(b, c));
		edges[b].push_back(make_pair(a, c));
	}
	priority_queue<aa, vector<aa>, Compare>que;
	que.push(aa{ 0,X,X });
	memos[0] = 0;
	long long int ans = -1;
	while (!que.empty()) {
		aa atop(que.top());
		que.pop();
		const long long int nowh = atop.height;
		const long long int nowt = atop.time;
		const long long int now = atop.now;
		if (now == N - 1) {
			ans = nowt + (hs[N - 1] - nowh);
			break;
		}
		for (auto e : edges[now]) {
			const int next = e.first;
			if (e.second > hs[now])continue;
			else {
				if (nowh >= e.second) {
					if (nowh - e.second <= hs[next]) {
						const  long long int nexth = nowh - e.second;
						const long long  int nextt = nowt + e.second;

						if (memos[next] > nextt - nexth) {
							memos[next] = nextt - nexth;
							que.push(aa{ next,nexth,nextt });
						}
					}
					else {
						const  long long int nexth = hs[next];
						const  long long int nextt = nowt + (nowh-hs[next]);

						if (memos[next] > nextt - nexth) {
							memos[next] = nextt - nexth;
							que.push(aa{ next,nexth,nextt });
						}
					}
				}
				else {
					const  long long int nexth = 0;
					const  long long int nextt = nowt+2*e.second-nowh;

					if (memos[next] > nextt - nexth) {
						memos[next] = nextt - nexth;
						que.push(aa{ next,nexth,nextt });
					}
				}
			}
		}
	}
	if (ans != -1) {

		cout << ans - X << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 17108
#include <stdio.h>
#include <string>
using namespace std;
char val[101];
int main() {
	int N;
	scanf("%d", &N);
	scanf("%s", val);
	string str(val);
	int num = 0;
	string f = "";
	string e = "";
	for (int i = 0; i < N; i++) {
		if (val[i] == '(') {
			num++;
		}
		else {
			num--;
		}
		if (num < 0) {
			f += "(";
			num++;
		}
	}
	for (int i = 0; i < num; i++) {
		e += ")";
	}
	string ans = f + str + e;
	printf("%s", ans.c_str());
	return 0;
}

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

const int N = 1e5;
int a[N],b[N],check[N];
map<int,int> mp;

signed main(){

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

  sort(b,b+n);
  int ans = 0;
  for(int i = 0; i < n; i++){
    int cost = 0,u = i,m = 1e9;
    int j = 0;
    for(; !check[u]; j++){
      m = min(m,a[u]);
      cost += a[u];
      check[u] = 1;
      u = mp[b[u]];
    }
    if(j >= 2){
      ans += min(cost+m+(j+1)*b[0],cost+(j-2)*m);
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  char x, y;
  cin >> x >> y;

  if(x > y) cout << '>' << endl;
  else if(x < y) cout << '<' << endl;
  else cout << '=' << endl;
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define F0R(x,y) for(int x=0;x<y;x++)
#define F0R1(x,y) for(int x=1;x<y;x++)

#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize
#define puts(x) cout<<x<<"\n"

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

void setIO(string y) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((y+".in").c_str(),"r",stdin);
  freopen((y+".out").c_str(),"w",stdout);
}

int h, x;

int main () {
  cin >> x;
  h += x/500*1000;
  x -= x/500*500;
  h += x/5*5;
  puts(h);
}




Measured memory_bytes: 256
#include <cstdio>
const int N=100005;
int fst[N],f[N],tot=0;
struct Edge{
	int to,nxt;
}e[N*2];
void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}
void dfs(int x,int fa){
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=fa){
			dfs(y,x);
			f[x]^=f[y]+1;
		}
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	dfs(1,0);
	if (f[1]) printf("Alice\n");
		else printf("Bob\n");
}

Measured memory_bytes: 7168
#include <iostream>
#include <map>
#include <string>
#define int long long
using namespace std;
map<string, int>m;
int n, a, k; string s;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> s;
		if (!a) {
			cin >> k;
			m[s] = k;
		}
		else cout << m[s] << endl;
	}
}


Measured memory_bytes: 27700
#include<stdio.h>
int w,a,b;
int main(){
	scanf("%d %d %d",&w,&a,&b);
	if(a>b){
		int c=b;
		b=a;
		a=c;
	}
	if(w+a<b)
		printf("%d",b-w-a);
	else
		printf("%d",0);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int n;
int graph[100][100];
int d[100];
int f[100];
int now=0;
int k[100];
bool beg[106];
void dfs(int p)
{
    
   beg[p-1]=true;
 //  cout<<“p”<< p<<endl;
   //if(d[p-1]==-1)
   d[p-1]=now;
  // cout<<“now “<<now<<endl;
   if(k[p-1]==0)
   {
       now++;
       f[p-1]=now;
   }
   else
   {
       for(int i=0;i<k[p-1];i++)
       {
           if(beg[graph[p-1][i]-1]==false)
           {
               now++;
               dfs(graph[p-1][i]);
           }
       }
       now++;
       f[p-1]=now;
   }
}
int main(){
   cin>>n;
   for(int i=0;i<n;i++)
   {
       beg[i]=false;
       d[i]=-1;
       f[i]=-1;
       int number;
       cin>>number;
       cin>>k[i];
       for(int j=0;j<k[i];j++)
           cin>>graph[i][j];
   }
   now=0;
   for(int i=0;i<n;i++)
   {
       if(beg[i]==false)
       {
           now++;
           dfs(i+1);
       }
   }
   for(int i=0;i<n;i++)
   {
       cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
   }
   return 0;
}



Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	struct P
	{
		public int i, j;
		public P(int _i, int _j) { i = _i; j = _j; }
		public bool IsInRange => 0 <= i && i < h && 0 <= j && j < w;
		public P[] Nexts() => new[] { new P(i, j - 1), new P(i, j + 1), new P(i - 1, j), new P(i + 1, j) };
	}

	static int h, w;
	static string[] c;

	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var z = read();
		h = z[0]; w = z[1];
		c = new int[h].Select(_ => Console.ReadLine()).ToArray();

		var M = 0;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (c[i][j] == '.')
					M = Math.Max(M, Search(new P(i, j)));
		Console.WriteLine(M);
	}

	static int Search(P sp)
	{
		var u = new int[h, w];
		var q = new Queue<P>();
		u[sp.i, sp.j] = 1;
		q.Enqueue(sp);

		var M = 0;
		while (q.Any())
		{
			var p = q.Dequeue();
			foreach (var x in p.Nexts())
			{
				if (!x.IsInRange || u[x.i, x.j] > 0 || c[x.i][x.j] == '#') continue;
				M = u[x.i, x.j] = u[p.i, p.j] + 1;
				q.Enqueue(x);
			}
		}
		return M - 1;
	}
}


Measured memory_bytes: 17604
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

char s[4];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
d25="Christmas"
d24="Christmas Eve"
d23="Christmas Eve Eve"
d22="Christmas Eve Eve Eve"
d=int(input())
if d==23:
    print(d23)
elif d==24:
    print(d24)
elif d==24:
    print(d24)
elif d==22:
    print(d22)
else:
    print(d25)

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;
int func( int pattern, int N, int M, int X, vector <int> &cost, vector <vector <int> > &skill ){
	vector <int> experience( N, 0 );
	int pay = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			pay += cost[ bit ];
			rep( i, 0, M )
			experience[ i ] += skill[ bit ][ i ];
		}
	}
	rep( i, 0, M ){
		if (experience[i] < X){
			return k_mod;
		}
	}
	return pay;
}
int main( void ){
	// initialize();
	int N, M, X;
	cin >> N >> M >> X;
	vector <int> cost( N );
	vector <vector <int> > skill( N, vector <int>( M ));
	rep( i, 0, N ){
		cin >> cost[ i ];
		rep( j, 0, M ){
			cin >> skill[ i ][ j ];
		}
	}
	int minimum = k_mod;
	int lim = pow( 2, N );
	rep( i, 0, lim ){
		minimum = min( minimum, func( i, N, M, X, cost, skill ));
	}
	cout << (( minimum != k_mod ) ? minimum : ( -1 )) << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int INF = 1e9 + 239;

int dpmin[1 << 26];

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

	vector<int> cnt(26);
	fill(dpmin, dpmin + (1 << 26), INF);
	string s;
	cin >> s;
	int cm = 0;
	dpmin[cm] = 0;
	int n = (int)s.size();
	vector<int> dp(n);
	for (int i = 0; i < n; i++) {
		char t = s[i];
		cm ^= (1 << (t - 'a'));
		int cdp = INF;
		cdp = dpmin[cm];
		for (int j = 0; j < 26; j++) {
			cdp = min(cdp, dpmin[cm ^ (1 << j)]);
		}
		cdp++;
		dpmin[cm] = min(dpmin[cm], cdp);
		dp[i] = cdp;
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 263572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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 V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int H,W; cin >> H >> W;
    vector<vector<char>> A(H,vector<char>(W));
    for(auto& vec:A) for(auto& in:vec) cin >> in;

    vector<vector<int>> dist(H,vector<int>(W,INF));
    queue<pii> q;
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            if(A[i][j] == '#'){
                dist[i][j] = 0;
                q.emplace(i,j);
            }
        }
    }
    int dir[4] = {1,0,-1,0};

    while(q.size()){
        int h,w; tie(h,w) = q.front(); q.pop();

        for(int k = 0; k < 4;k++){
            int nh = h + dir[k];
            int nw = w + dir[k^1];

            if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if(dist[nh][nw] > dist[h][w] + 1){
                dist[nh][nw] = dist[h][w] + 1;
                q.emplace(nh,nw);
            }
        }
    }
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            res = max(res,(ll)dist[i][j]);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 16068
s = input()

if s.count('C') != 1:
    print('WA')
    exit()

if s[0]=='A':
    s = s.lstrip('A')
    if 'C' in s[1:-1]:
        s = s.replace('C', '')
        if s.islower() == True:
            print('AC')
            exit()

print('WA')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (auto i=0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for (auto i=0; i < n; ++i) {
        cout << s[i];
    }
    
    cout << endl;
}

Measured memory_bytes: 256
def abc060_c():
    n, T = map(int, input().split())
    t = list(map(int, input().split()))
    total = 0
    for i in range(n - 1):
        criteria = t[i + 1] - t[i]
        if criteria < T:
            total += criteria
        else:
            total += T
    total += T
    print(total)


abc060_c()

Measured memory_bytes: 25200
use std::io::stdin;

fn main() {
    let mut ab = String::new();
    stdin().read_line(&mut ab).unwrap();
    let ab: Vec<usize> = ab.trim().split_whitespace().flat_map(str::parse).collect();
    let (a, b) = (ab[0], ab[1]);
    println!("{}", match (a % 2, b % 2, ((b - a) / 2) % 2) {
        (0, 0, 0) => b,
        (0, 0, 1) => 1 ^ b,
        (0, 1, 0) => 1,
        (0, 1, 1) => 1 ^ 1,
        (1, 0, 0) => a ^ b,
        (1, 0, 1) => 1 ^ a ^ b,
        (1, 1, 0) => a,
        (1, 1, 1) => a ^ 1,
        _ => panic!(),
    });
}


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




int main() {
 long long N;
  cin>>N;
 if(N>=64){
   cout<<64;
 }
  else if(N>=32){
   cout<<32;
 }
  else if(N>=16){
   cout<<16;
 }
  else if(N>=8){
   cout<<8;
 }
  else if(N>=4){
   cout<<4;
 }
  else if(N>=2){
   cout<<2;
 }
  else{
    cout<<1;
  }

  
  
 
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int n=getInt();
		int in[]=INS(n).toArray();
		
		int c=0;
		for(int i=0;i<n-1;++i) if(i>=0){
			if(in[i]==i+1) {
				int buf=in[i];
				in[i]=in[i+1];
				in[i+1]=buf;
				--i;
				++c;
			}
		}
		if(in[n-1]==n)
			++c;
		System.out.println(c);
	}
}

Measured memory_bytes: 49984
#include <iostream>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	int n;
	while(cin >> n) {
		if(n == -1) break;
		int N = 0;
		while((int)pow(4,N) <= n) N++;
		N--;
		while(N > 0) {
			cout << n / (int)pow(4,N);
			n -= (n / (int)pow(4,N)) * (int)pow(4,N);
			N--;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main()
{
    int S;
    int h, m, s;

    scanf("%d", &S);
    h = S / 3600;
    S %= 3600;
    m = S / 60;
    s = S % 60;

    printf("%d:%d:%d\n", h, m, s);

    return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	double n, k;
	cin >> n >> k;
	double p = 0;
	for (int i = 1; i <= n; i++) {
		int tmp = i;
		int count = 0;
		while (tmp < k) {
			tmp *= 2;
			count++;
		}
		p += (1.0 / n) * (pow((1.0 / 2.0), count));
	}
	cout << fixed << setprecision(12) << p << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int H, W;
    cin >> H >> W;
    // 各々の頂点からの最短経路を計算することができる
    int dist[10][10];
    // 経路距離の初期値を無限大に近い値に設定する
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            dist[i][j] = 999999;        
        }
    }
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> dist[i][j];
        }
    }
    vector <vector<int>> walls(H, vector<int>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> walls[i][j];
        }
    }
    // 最短経路計算
    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
    // 必要となる合計コストを格納する変数
    int sum_cost = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            // cout << walls[i][j] << endl;
            if((walls[i][j] == -1) || (walls[i][j] == 1)){
                continue;
            }else{
                sum_cost += dist[walls[i][j]][1];
            }
        }
    }
    cout << sum_cost << endl;
}

Measured memory_bytes: 384
import java.util.*;
     
    public class Main{
      
     public static void main(String[] args){  
     
     Scanner sc = new Scanner(System.in);
       
       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();
       
       if((a==b&&b!=c) || (a==c&&b!=c) || (b==c&&c!=a)){
         
        System.out.print("Yes");
       }else{
         
       System.out.print("No");
       }
     }
     }

Measured memory_bytes: 22868
#! /usr/bin/env python3

n = int(input())
p = [int(input()) for _ in range(n)]

pos = [0 for _ in range(n+1)]

for i in range(n):
    pos[p[i]] = i

longest = 1
current = 1

for q in range(1, n + 1 - 1):
    if pos[q] < pos[q + 1]:
        current += 1
    else:
        if current > longest:
            longest = current
        current = 1

if current > longest:
    longest = current

print(n - longest)


Measured memory_bytes: 18968
#include <iostream>
#include <sstream>
#include <iterator>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <cmath>

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")

using namespace std;

//ABC055B - Training Camp
//give up
int Main() {
	static const char EMPTY = '.';
	static const char BLACK = '#';
	int N;
	long ans = 1;
	long div = (int)pow(10, 9) + 7;

	cin >> N;
	int i;
	for (i = 1;i <= N;i++) {
		ans *= i;
		ans %= div;
	}
	ans %= div;


	cout << ans;

	return 0;
}


int main()
{
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
// int main() {
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//     cout << fixed << setprecision(10);
//
// }
template<typename A>
struct WeightedUnionFind
{
    vector<int> par, sz;
    vector<A> data; // data[x]: diff from root to x
    WeightedUnionFind(int n, A e=0) :
        par(n), sz(n, 1), data(n, e) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        int r = root(par[x]);
        data[x] += data[par[x]];
        return par[x] = r;
    }
    A weight(int x) {
        root(x);
        return data[x];
    }
    A diff(int x, int y) {
        // diff from x to y
        return data[y] - data[x];
    }
    void merge(int x, int y, A w) {
        // merge so that "diff from x to y" will be w.
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y), w = -w;
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;
        data[y] = w;
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
int main() {
    int N, M;
    cin >> N >> M;
    WeightedUnionFind<int> uf(N);
    while (M--) {
        int A, B, C, D;
        cin >> A >> B >> C;
        if (A == 0) {
            cin >> D;
            uf.merge(B, C, D);
        } else {
            if (uf.root(B) == uf.root(C)) {
                cout << uf.diff(B, C) << endl;
            } else {
                cout << "?" << endl;
            }
        }
    }
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define MOD 998244353
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

/*
    BIT: Binary Indexed Tree (1-indexed)
*/
class BIT {
    private:
        ll N;
        vector<ll> bit;

    public:
        BIT(ll n, ll initial_value);
        void add(ll i, ll x);
        ll sum(ll i);
};

BIT::BIT(ll n, ll initial_value) {
    N = n;
    bit.resize(N + 1, initial_value);
}

// i番目 (1-indexed) の要素にxを加える
void BIT::add(ll i, ll x) {
    while (i <= N) {
        bit[i] += x;
        bit[i] %= MOD;
        i += i & -i;
    }
}

// 区間[1, i] (1-indexed) の要素の和を求める
ll BIT::sum(ll i) {
    ll ans = 0;
    while (i > 0) {
        ans += bit[i];
        ans %= MOD;
        i -= i & -i;
    }
    return ans;
}

int main() {
  
  ll N, K;
  cin >> N >> K;
  vector<ll> L(K), R(K);
  rep(i,K) cin >> L[i] >> R[i];

  BIT tree(N, 0);
  tree.add(1, 1);
  for (ll i = 2; i <= N; i++) {
    rep(j,K) {
      if (L[j] >= i) continue;
      ll from = max(i - R[j], 1ll);
      ll to = i - L[j];
      ll s = tree.sum(to) - tree.sum(from - 1) + MOD;
      s %= MOD;
      tree.add(i, s);
    }
  }

  ll ans = tree.sum(N) - tree.sum(N - 1) + MOD;
  ans %= MOD;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4844
n = int(input())
A = list(map(int,input().split()))

ans = float('inf')

cA = A[:]
cs = 0
cnt = 0
for i, a in enumerate(cA):
    if i%2 == 0: #ここまでの累積和が正
        if cs + a > 0:
            cs += a
        else:
            cA[i] += 1-(cs+a)
            cnt += 1-(cs+a)
            cs = 1
    else:
        if cs + a < 0:
            cs += a
        else:
            cA[i] += -1-(cs+a)
            cnt += abs(-1-(cs+a))
            cs = -1
ans = min(ans,cnt)

cA = A[:]
cs = 0
cnt = 0
for i, a in enumerate(cA):
    if i%2 == 1: #ここまでの累積和が正
        if cs + a > 0:
            cs += a
        else:
            cA[i] += 1-(cs+a)
            cnt += 1-(cs+a)
            cs = 1
    else:
        if cs + a < 0:
            cs += a
        else:
            cA[i] += -1-(cs+a)
            cnt += abs(-1-(cs+a))
            cs = -1
ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 14332
from heapq import heapify, heappop, heappush

n, k = list(map(int, input().split()))
ppp = list(map(int, input().split()))

increases = [int(p1 < p2) for p1, p2 in zip(ppp, ppp[1:])]
h = k - 1
tmp = sum(increases[:h])
duplicated = [0] * n
first_ascending = True
for i, q in enumerate(increases[h:], start=h):
    tmp += q - increases[i - h]
    if tmp == h:
        if first_ascending:
            first_ascending = False
        else:
            duplicated[i + 1] = 1

state = [1] * k + [0] * (n - k)
ans = 1
minq = ppp[:k]
maxq = [-p for p in ppp[:k]]
heapify(minq)
heapify(maxq)

# print(duplicated)

for i, p in enumerate(ppp[k:], start=k):
    l = ppp[i - k]

    if l == minq[0] and p > -maxq[0]:
        pass
    elif duplicated[i] == 1:
        pass
    else:
        ans += 1
    state[l] = 2
    state[p] = 1
    while state[minq[0]] == 2:
        heappop(minq)
    while state[-maxq[0]] == 2:
        heappop(maxq)
    heappush(minq, p)
    heappush(maxq, -p)
    # print(i, p, ans)
    # print(state)
    # print(minq)
    # print(maxq)

print(ans)


Measured memory_bytes: 29756
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll cnt[ll(1e6)] = {};

int main() {
    
    
    ll n,m;
    cin >> n >> m;
    for (ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    int flag = 0;
    for (ll i=0;i<=n;i++){
        if(cnt[i]%2 == 1){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
}

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

int main(){
  string s, t, u; cin >> s >> t >> u;
  char dif = 'A' - 'a';
  cout << (char)(s[0] + dif) << (char)(t[0] + dif) << (char)(u[0] + dif);
}

Measured memory_bytes: 256
k=int(input())


if k%2==0 or k%5==0:
    print(-1)
    exit(0)

d={}

x=7
i=1
while True:
    if x%k==0:
        print(i)
        exit(0)

    x=(10*x + 7)%k
    if x not in d:
        d[x]=1
    else:
        print(-1)
        exit(0)


    i+=1
    




Measured memory_bytes: 92604
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int wrong = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] != i + 1) wrong++;
  }
  if (wrong == 0 || wrong == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static char[] a;
    static char[] b;
    static int[][] dp;
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws InterruptedException {
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            solve();
        }
    }

    static void solve() {
        a = sc.next().toCharArray();
        b = sc.next().toCharArray();
        dp = new int[a.length + 1][b.length + 1];
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < b.length; j++) {
                dp[i+1][j+1] = a[i] == b[j] ? dp[i][j] + 1 : Math.max(dp[i+1][j], dp[i][j+1]);
            }
        }
        System.out.println(dp[a.length][b.length]);
    }
}



Measured memory_bytes: 72804
import bisect
N = int(input())
A = list(sorted(list(map(int,input().split()))))
B = list(map(int,input().split()))
C = list(sorted(list(map(int,input().split()))))
ans = 0
for b in B:
    ans +=(bisect.bisect_right(A,b-1))*(N-bisect.bisect_left(C,b+1))
print(ans)

Measured memory_bytes: 29132