akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  [n,x] <- getInts
  as <- getInts
  let
    cost :: Z -> [Z] -> Z
    cost k bs = k*x + sum bs
    bss = take n $ iterate foo as
    ans = minimum $ zipWith cost [0..] bss
  print ans
  

foo :: [Z] -> [Z]
foo as = zipWith min as (tail as ++ [head as])

 
type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "YES"
yesNo False = "NO"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 1148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = LI()
    s = sum(a)
    if s >= n:
        return "Yes"

    return "No"


print(main())





Measured memory_bytes: 16552
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

//I imitated Ant Book version 1: P.84.

int n,q,com,x,y;
int rank[10000],parent[10000];

int find(int x){
	if(x == parent[x])return x;
	else{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x,int y){
	return find(x) == find(y);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);

	if(x == y)return;

	if(rank[x] < rank[y]){
		parent[x] = y;
	}else{
		parent[y] = x;
		if(rank[x] == rank[y])rank[x]++;
	}
}

int main(){

	scanf("%d %d",&n,&q);

	for(int i = 0; i < n; i++){
		rank[i] = 0;
		parent[i] = i;
	}

	for(int i = 0; i < q; i++){
		scanf("%d %d %d",&com,&x,&y);

		if(com == 1){
			if(isSame(x,y))printf("1\n");
			else{
				printf("0\n");
			}
		}else{
			if(isSame(x,y))continue;

			unite(x,y);
		}
	}

	return 0;
}



Measured memory_bytes: 2680
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) { a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
	int N; cin >> N;
	double A[N];

	double ans = 0;
	for(int i=0; i<N; i++){
		cin >> A[i];
		ans += 1/A[i];
	}

	cout
		<< scientific
		<< 1/ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
 
using namespace std;
 
int main(){
    char S[4] = {'S', 'H', 'C', 'D'};
    bool cards[4][13]; // s, h, c, d
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            cards[i][j] = false;
        }
    }
    int n;
    scanf("%d", &n);
    int r;
    char c;
    for(int i = 0; i < n; ++i){
        scanf("\n%c %d", &c, &r);
        for(int j = 0; j < 4; ++j){
            if(S[j] == c){
                cards[j][r - 1] = true;
            }
        }
    }
 
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(!cards[i][j]) printf("%c %d\n", S[i], j + 1);
        }
    }
 
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] arr = sc.nextLine().split(" ");
		int a =Integer.parseInt(arr[0]);
		int b = Integer.parseInt(arr[1]);
		sc.close();

		int diff = b-a;
		int bTowerHight = (1+diff)*diff/2;
		System.out.println(bTowerHight-b);
	}
}


Measured memory_bytes: 23764
#include<cstdio>
#include<vector>
#define pu push_back
#define po pop_back
const int mod=1000000007;
int N,p[200010][19],dep[200010];
int lca(int i,int j){
	int k;
	if(dep[i]>dep[j])k=i,i=j,j=k;
	for(k=19;k--;)if(dep[i]-dep[j]>>k&1)j=p[j][k];
	for(k=19;k--;)if(p[i][k]!=p[j][k])i=p[i][k],j=p[j][k];
	if(i!=j)i=*p[i];
	return i;
}
struct edge{int to;edge*next;}E[400010],*ne=E,*first[200010];
void link(int u,int v){*ne=(edge){v,first[u]};first[u]=ne++;}
struct item{
	int id,f,g,pro;
	void mer(const item&x){
		f=(1ll*f*(x.g-x.f+mod)+1ll*x.f*pro)%mod;
		g=1ll*g*x.g%mod;
		pro=1ll*pro*(x.g-x.f+mod)%mod;
	}
};
std::vector<item>S[200010];
void dfs(int i){
	int d=dep[i],j=S[d].size()-1;
	if(j<0)S[d].pu((item){i,1,2,1});
	else{
		int a=lca(i,S[d][j].id);
		for(;j&&S[d][j-1].id>=a;j--)S[d][j-1].mer(S[d][j]),S[d].po();
		if(S[d][j].id!=a){
			S[d][j].pro=(S[d][j].g-S[d][j].f+mod)%mod;
		}
		S[d][j].id=a;
		S[d].pu((item){i,1,2,1});
	}
	for(edge*e=first[i];e;e=e->next)dfs(e->to);
}
int dc[200010],pw2[200010];
int main(){
	scanf("%d",&N);
	for(int i=*dc=*pw2=1;i<=N;i++){
		scanf("%d",p[i]);
		for(int j=1;j<19;j++)p[i][j]=p[p[i][j-1]][j-1];
		dep[i]=dep[*p[i]]+1;
		link(*p[i],i);
		dc[dep[i]]++;
		pw2[i]=pw2[i-1]*2%mod;
	}
	dfs(0);
	int ans=0;
	for(int d=0;d<=N;d++)if(S[d].size()){
		int j=S[d].size()-1;
		for(;j;j--)S[d][j-1].mer(S[d][j]),S[d].po();
		ans=(ans+1ll*S[d][0].f*pw2[N+1-dc[d]])%mod;
	}
	printf("%d\n",ans);
}

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

int main() {
	int N, a;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> a;
		vec.at(i) = a;
	}
	sort(vec.begin(), vec.end());
	cout << vec.at(N - 1) - vec.at(0) << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long


int main() {
	int k, x;
	cin >> k >> x;
	bool flag = false;
	for (int i = -1000000; i < 1000001; i++) {
		if (abs(i - x) < k) {
			if (flag) {
				cout << " ";
			}
			cout << i;
			flag = true;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll LINF = (ll) 4e18;
int main() {
    int n, k;
    cin >> n >> k;
    ll x[n];
    ll ans = LINF;
    for (int i = 0; i < n; ++i) cin >> x[i];
    for (int l = 0, r = k - 1; r < n; ++l, ++r) {
        ans = min(ans, abs(x[l]) + (x[r] - x[l]));
        ans = min(ans, abs(x[r]) + (x[r] - x[l]));
    }
    cout << ans << endl;
    return 0;
}



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


using namespace std;
double pi=3.14159265358979323846264338;


inline void ex(){cout<<"Yes"<<endl;exit(0);}
long long a,b,c,d;


long long n,k;
bool ok[1000001];
long long arr[11][3];
long long arr2[200001][11];
long long arr3[200001];
const long long N=998244353;
long long calc(long long a,long long b){
	long long cnt=1;
	while(b%a==0){
		b=b/a;
		cnt++;
	}
	return cnt;
}
long long ca(long long x){
	for(long long i=0;i<k;i++){
		if(x<=arr[i][1])return i;
	}
	return k;
}
long long T(long long t){
	if(t<0)return t+N;
	else return t%N;
}
int main(){
	cin>>n>>k;
	vector<pair<long long,long long>>v;
	for(int i=0;i<k;i++){cin>>arr[i][0]>>arr[i][1];v.push_back(make_pair(arr[i][0],arr[i][1]));}
	sort(v.begin(),v.end());
	for(int i=0;i<k;i++)arr[i][0]=v[i].first,arr[i][1]=v[i].second;
	//arr3[arr[0][0]+1]=1;
	arr3[1]=1;
	for(long long i=1;i<=n;i++){
		a=ca(i);
		for(long long j=0;j<a;j++){
			arr3[i]+=arr2[i-arr[j][1]][j];
			arr3[i]=T(arr3[i]);
			
		}
		if(a!=k){
			arr3[i]+=arr2[1][a];arr3[i]=T(arr3[i]);
			arr2[1][a]+=arr3[max(0LL,i-arr[a][0]+1)];
			arr2[1][a]=T(arr2[1][a]);
			//cout<<i<<" "<<a<<" "<<arr2[1][a]<<endl;
		}
		for(int j=0;j<a;j++){
			arr2[i+1-arr[j][1]][j]=arr2[i-arr[j][1]][j];
			arr2[i+1-arr[j][1]][j]+=arr3[i-arr[j][0]+1];
			arr2[i+1-arr[j][1]][j]=T(arr2[i+1-arr[j][1]][j]);
			arr2[i+1-arr[j][1]][j]-=arr3[i-arr[j][1]];
			arr2[i+1-arr[j][1]][j]=T(arr2[i+1-arr[j][1]][j]);
		}
	}
	//for(int i=1;i<n;i++)cout<<arr3[i]<<endl;
	cout<<arr3[n]<<endl;
		
	return 0;
			
}

Measured memory_bytes: 21840
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
   	int n, m, x;
   	cin >> n >> m >> x;
   	int a[m + 1], b[n + 1] = {};
   	for (int i = 0 ; i < m ; i++) cin >> a[i], b[a[i]] = 1;
   	int c = 0, d = 0;
   	for (int i = x ; i <= n ; i++) if (b[i]) c++;
   	for (int i = x ; i >= 1 ; i--) if (b[i]) d++;
   	cout << min(c, d);
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    if (a.back() == b[0] and b.back() == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>


using namespace std;

long long n, d, x, s, mn = pow(10, 9), a[100005];


int main () {
    cin >> a[1] >> a[2] >> a[3];
    sort(a + 1, a + 4);
    if ( (a[1] == a[2] && a[2] != a[3]) || (a[2] == a[3] && a[1] != a[2]) ) {
        cout << "Yes";
    }
    else {
        cout <<"No";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//This code is written by Itst
using namespace std;

inline int read(){
	int a = 0;
	char c = getchar();
	bool f = 0;
	while(!isdigit(c)){
		if(c == '-')
			f = 1;
		c = getchar();
	}
	while(isdigit(c)){
		a = (a << 3) + (a << 1) + (c ^ '0');
		c = getchar();
	}
	return f ? -a : a;
}

const int MOD = 1e9 + 7;
struct ys{
	int l , r , num;
	bool operator <(const ys b)const{
		return r < b.r;
	}
}now[310];
int dp[310][310];
int N , M , P;

int main(){
	N = read();
	M = read();
	P = 1;
	for(int i = 1 ; i <= M ; ++i){
		now[i].l = read();
		now[i].r = read();
		now[i].num = read();
		if(now[i].l == 1 && now[i].r == 1){
			if(now[i].num != 1){
				puts("0");
				return 0;
			}
			--i;
			--M;
		}
	}
	sort(now + 1 , now + M + 1);
	dp[0][0] = 3;
	for(int i = 2 ; i <= N ; ++i){
		for(int j = 0 ; j < i - 1 ; ++j)
			for(int k = j ; k < i - 1 ; ++k){
				(dp[j][i - 1] += dp[j][k]) %= MOD;
				(dp[k][i - 1] += dp[j][k]) %= MOD;
			}
		int P1 = P;
		while(P1 <= M && now[P1].r == i)
			++P1;
		for(int j = 0 ; j <= i - 1 ; ++j)
			for(int k = j ; k <= i - 1 ; ++k)
				if(dp[j][k]){
					bool f = 1;
					for(int q = P ; f && q < P1 ; ++q)
						f = (j >= now[q].l) + (k >= now[q].l) + 1 == now[q].num;
					if(!f)
						dp[j][k] = 0;
				}
		P = P1;
	}
	int sum = 0;
	for(int i = 0 ; i < N ; ++i)
		for(int j = i ; j < N ; ++j)
			(sum += dp[i][j]) %= MOD;
	cout << sum;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <complex>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long double ld;
typedef complex<ld> P;

const ld EPS = 1e-8;

struct C{
  P c;
  ld r;
  C(P c_,ld r_):c(c_),r(r_){}
  C(ld l1,ld l2, ld l3):c(l1,l2),r(l3){}
};

void search(vector<char>& opt, int bits, const vector<C>& cs, const vector<int>& clr, const vector<vector<bool>>& t,int n) {
  vector<vector<int>> ebl(4);
  REP(i,n) {
    if(((bits>>i)&1)==0)continue;
    bool fr = true;
    REP(j,i){
      if(((bits>>j)&1)==0)continue;
      if(t[i][j]) {
        fr=false;
        break;
      }
    }
    if(fr){
      ebl[clr[i]].push_back(i);
    }
  }
  char mx_ebl = 0;
  REP(i,4){
    if(ebl[i].size() < 2) continue;
    int m=ebl[i].size();
    REP(j,m)REP(k,j){
      int ij = ebl[i][j];
      int ik = ebl[i][k];
      int nb = (bits & ~(1 << ij)) & ~(1 << ik);
      if(opt[nb] < 0) {
        search(opt, nb, cs,clr,t,n);
      }
      mx_ebl = max(mx_ebl, char(opt[nb] + 2));
    }
  }
  opt[bits] = mx_ebl;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if(!n) break;
    vector<C> cs;
    vector<int> clr;
    REP(i,n) {
      ld x,y,r;
      int c;
      cin>>x>>y>>r>>c;
      --c;
      cs.emplace_back(x,y,r);
      clr.push_back(c);
    }
    vector<vector<bool>> t(n,vector<bool>(n,false));
    REP(i,n)REP(j,i){
      if(norm(cs[i].c-cs[j].c) + EPS < (cs[i].r+cs[j].r)*(cs[i].r+cs[j].r)) {
        t[i][j] = true;
      }
    }
    vector<char> opt(1<<n, -1);
    search(opt,(1<<n)-1,cs,clr,t,n);
    int o = opt[(1<<n)-1];
    cout << o << endl;
  }
  return 0;
}

Measured memory_bytes: 17664
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
 
int main()  {

  int  A,B,K;
  std::cin >> A >> B >> K;
  int cnt;
  std::vector<int> L(1000);
  cnt = 0;
  int j;
  j=1;
  for(int i=1;i<101;i++){
	if(A%i==0 && B%i==0){
		L[j]=i;
		j++;
	}
  }

  printf("%d\n",L[j-K]);
/*
  for(int i=1;i<101;i++){  
  	 printf("%d\n",L[i]);
  }
*/	
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static Properties pps = System.getProperties();
	static boolean dbg = true;

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		//setOut();
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		System.out.println((a*3+b)/2);
	

		
	}






	private static String solve(int[] a, int[] b) {
		// TODO Auto-generated method stub
		Arrays.sort(b);
	
		int sum=0;
		for(int i=0;i<a[1];i++) {
			sum+=b[a[1]-1]-b[i];
		}
		int min=sum;
		min=Math.min(min, sum);
	
		int j=0;
		for(int i=a[1];i<a[0];i++) {
	
			sum=sum-(b[i-1]-b[j])+(b[i]-b[i-1])*(a[1]-1);
			++j;
			
			min=Math.min(min, sum);
		}
		return ""+min;
		
	}






	private static void setOut() throws FileNotFoundException {
		sc = new Scanner(new FileInputStream("in.txt"));
		System.setOut(new PrintStream(new FileOutputStream("out.txt")));
		
	}






	private static void out(List<Integer> l) {
		// TODO Auto-generated method stub
		for (int i : l)
			System.out.println(i);

	}

	private static void out(int[] b) {
		// TODO Auto-generated method stub
		for (int i : b)
			System.out.println(i);

	}

	public static void out(String str) {

		if (dbg)
			System.out.println(str);
	}

	public static void out(int str) {

		if (dbg)
			System.out.println(str);
	}

	public static int ni() {

		return sc.nextInt();

	}

	public static String ns() {

		return sc.nextLine();
	}

	public static int[] ni(int k) {
		int[] res = new int[k];
		for (int i = 0; i < k; i++)
			res[i] = sc.nextInt();
		sc.nextLine();
		return res;
	}

	public static String[] ns(int k) {
		String[] res = new String[k];
		for (int i = 0; i < k; i++)
			res[i] = sc.nextLine();
		return res;
	}

	public static int[][] ni(int a, int b) {
		int[][] res = new int[a][b];
		for (int i = 0; i < a; i++)
			for (int j = 0; j < b; j++)
				res[i][j] = sc.nextInt();
		sc.nextLine();
		return res;
	}
}


Measured memory_bytes: 21844
a, b, c, d = map(int, input().split())

f = 0
while (1):
    c -= b
    if c <= 0:
        f = 1
        break
    else:
        pass

    a -= d
    if a <= 0:
        f = 2
        break
    else:
        pass

if f == 1:
    print('Yes')
elif f == 2:
    print('No')
else:
    pass


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int n, k, i, j, x, p[5005], c[5005];
i64 ans = numeric_limits<i64>::min(), a[5005], b[5005];
int main() {
    scanf("%d%d", &n, &k);
    for (i = 1; i <= n; ++i)
        scanf("%d", &p[i]);
    for (i = 1; i <= n; ++i)
        scanf("%d", &c[i]);
    for (i = 1; i <= n; ++i) {
        for (j = 1, x = p[i]; j <= k; ++j, x = p[x]) {
            a[j] = a[j - 1] + c[x];
            b[j] = max(b[j - 1], a[j]);
            ans = max(ans, a[j]);
            if (j == k)
                break;
            if (x == i) {
                ans = max(ans, a[j] * (k / j) + b[k % j]);
                ans = max(ans, a[j] * (k / j - 1) + b[j]);
                break;
            }
        }
    }
    printf("%lld", ans);
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s,t;

int main(){
  cin >> s >> t;
  cout << t << s << "\n";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, s, l, h float64
	fmt.Scan(&a, &b, &c)
	s = a * b * math.Sin(math.Pi * c / 180) / 2
	l = a + b + math.Sqrt(math.Pow(a, 2) + math.Pow(b, 2) - 2 * a * b *math.Cos(math.Pi * c / 180))
	h = s / a * 2
	fmt.Printf("%f\n", s)
	fmt.Printf("%f\n", l)
	fmt.Printf("%f\n", h)
}


Measured memory_bytes: 1152
#include <string>
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>

typedef std::pair<int, int> P;

using namespace std;

const int INF = 1001001001;

template<typename T>
void maxe(T& a, T b){ a = max(a, b); }

P dp[110][110 * 1000];

int main()
{
	int n;
	
	while (scanf("%d", &n) && n){
		for (int i = 0; i < 110; i++){
			for (int j = 0; j < 110 * 1000; j++){
				dp[i][j] = P(0, -INF);
			}
		}
		P ans;
		dp[0][0] = P(0, 0);
		for (int i = 0; i < n; i++){
			int p;
			scanf("%d", &p);
			for (int j = 0; j < 110 * 1000; j++){
				if (dp[i][j].second == -INF) continue;
				maxe(dp[i + 1][j], dp[i][j]);
				int x = (1000 - p % 1000) % 1000;
				if (j + x % 500 < 110 * 1000){
					maxe(dp[i + 1][j + x % 500], P(dp[i][j].first + x / 500, dp[i][j].second - p));
				}
				if (j >= 500 - x && j - 500 + x < 110 * 1000) maxe(dp[i + 1][j - 500 + x], P(dp[i][j].first + 1, dp[i][j].second - p));
			}
			maxe(ans, *max_element(dp[i + 1], dp[i + 1] + 110 * 1000));
		}
		printf("%d %d\n", ans.first, -ans.second);
	}
	
	return (0);
}


Measured memory_bytes: 97728
#include<bits/stdc++.h>
using namespace std;
long long work(int a,int b,int c)
{
    if(a>b)
    {
        return 0;
    }
    long long sum=0;
    for(int i=a;i<=b;i++)
    {
        sum+=(1<<i)*pow(10,c+a-i);
    }
    return sum;
}
int main()
{
    string a;
    cin>>a;
    long long ans=0;
    for(int i=0;i<a.length();i++)
    {
        ans+=((int)a[i]-48)*((1<<i)*pow(10,a.length()-i-1)+work(i,a.length()-2,a.length()-i-2));
    }
    cout<<ans;
    return 0;
}  

Measured memory_bytes: 256
import itertools

n, k = map(int, input().split())
d = [0]*k
a = []
for i in range(k):
    d[i] = int(input())
    sn = list(map(int, input().split()))
    a.append(sn)
res = itertools.chain(*a)
res = list(res)
res_s = list(set(res))
print(n - len(res_s))

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

int N;
const int MAX_N = 2.0e5 + 100;
int A[MAX_N];

vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}
 
int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int M = 0;
    int ans[N];
    int box[N];
    for (int i = 0; i < N; i++) box[i] = 0;

    for (int i = N-1; i >= 0; i--) {
        if (i > N/2) {
            ans[i] = A[i];
            if (A[i] % 2 == 1) {
                M++;
                box[i]++;
                vector<int> div = divisor(i+1);
                for (int j = 0; j < div.size(); j++) {
                    box[div[j] - 1]++;
                }
            }            
        }
        else {
            if ((box[i] % 2 == 1) xor (A[i] == 1)) {
                ans[i] = 1;
                M++;
                box[i]++;
                vector<int> div = divisor(i+1);
                for (int j = 0; j < div.size(); j++) {
                    box[div[j] - 1]++;
                }
            }
            else {
                ans[i] = 0;
            }
        }
    }

    cout << M << endl;
    for (int i = 0; i < N; i++) {
        if (ans[i] == 1) cout << i+1 << " ";
    }
    cout << endl;



    return 0;
}


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

int x, a, b, temp;

void solve() {
    cin >> x >> a >> b;
    x -= a;
    temp = x / b;
    x -= b * temp;
    cout << x << "\n";
}

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

Measured memory_bytes: 3576
#include<iostream>
#include<map>
using namespace std;
int main()
{
  int A,N,ans;
  bool f;
  while(cin>>A,A){
    map<int,int>m;
    f=false;
    for(int i=0;i<A;i++){
      cin>>N;
      m[N]++;
      if(m[N]>A/2){
	f=true;
	ans=N;
      }
    }
    if(f)cout<<ans<<endl;
    else puts("NO COLOR");
  }
}

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

using namespace std;

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

  long N,K; cin>>N>>K;
  vector<long> A(N); for (auto& a : A) cin>>a;
  vector<long> F(N); for (auto& f : F) cin>>f;

  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), [](auto l, auto r) {return l > r;});

  long asum = 0;
  for (auto a : A) asum += a;
  if (asum <= K) {
    cout << 0 << endl;
    return 0;
  }
  auto cap = asum - K;

  long ans = 0;
  long l = 0, r = 10e12;
  while (l <= r) {
    auto c = (l+r)/2;
    auto ccap = cap;
    long res = 0;
    for (int i = N-1; i >= 0; i--) {
      auto d = min(min(c/F[i], ccap), A[i]);
      res = max(d*F[i], res);
      ccap -= d;
      if (ccap == 0)
        break;
    }
    if (ccap == 0) {
      ans = res;
      r = c-1;
    } else {
      l = c+1;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n, z, w;
  cin >> n >> z >> w;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  if(n == 1){
    cout << abs(a[n - 1] - w) << endl;
  }
  else{
    cout << max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])) << endl;
  }

  return 0;
}

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

int main() {
    //0以上b以下の整数でxで割り切れる整数の個数はb/x
   long long a,b,x;
   cin >> a >> b >> x;
   long long ans = b/x -(a-1)/x;
   if(a== 0) cout << b/x + 1 << endl;//0はどんなxでも割り切れる
   else cout << ans << endl;
}

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

from itertools import permutations

class Graph:
    def __init__(self, n_nodes):
        self.adj = [set() for i in range(n_nodes)]

    def add_edge(self, a1, b1):
        self.adj[a1 - 1].add(b1)
        self.adj[b1 - 1].add(a1)

    def are_adj(self, a1, b1):
        return b1 in self.adj[a1 - 1]

def main():
    n, m = map(int, input().split())
    gr = Graph(n)
    for i in range(m):
        a, b = map(int, input().split())
        gr.add_edge(a, b)
    paths = all_permutations_from_one(n)
    cnt = 0
    for p in paths:
        if is_possible(p, gr):
            cnt += 1
    print(cnt)

def all_permutations_from_one(n):
    perms_2_n = list(permutations(range(2, n + 1)))
    perms_1_n = [(1,) + p2n for p2n in perms_2_n]
    return perms_1_n

def is_possible(path, gr):
    l = len(path)
    flag = True
    for i in range(l - 1):
        a, b = path[i:i + 2]
        if not gr.are_adj(a, b):
            flag = False
    return flag

main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n" 
#define insert it
#define lb lowerbound
#define up upperbound
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7,siz = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;
 
void test(){
	int a,k;
	cin >> a >> k;
	vector<int>v(a);
	f(i,0,a){
		cin >> v[i];
	}
	vector<int>pre(a+1,0);
	f(i,0,a){
		if(!i){
			pre[i] = v[i];
		}
		else{
			pre[i] += pre[i-1] + v[i];
		}
	}
	int p = pre[k-1];
	f(i,k,a){
		int s = pre[i] - pre[i-k];
		if(s > p){
			cout << "Yes" << el;
		}
		else
			cout << "No" << el;
		p = s;
	}
}  
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    f(i,0,tt) test();   
    return 0;
}

// a,k = map(int,input().split())
// lis = list(map(input().split()))
// p = []
// for i in range(len(a)):
// 	p.append(1)

// for i in range(len(a)):
// 	if i == 0:
// 		p[i] = a[i]
// 	else:
// 		p[i] = p[i-1]*a[i]

// pre = p[k-1]
// for i in range(len(a)):
// 	p1 = p[i]/p[i-k]
// 	if p1 >= pre:

Measured memory_bytes: 6252
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a,b;
int main()
{
	int i,j;
	scanf("%d",&a);
	for(i=1;i<=9;i++)
	{
		if(a%i==0)
		{
			b=a/i;
			if(0<=b&&b<=9)
			{
				printf("Yes\n");
				return 0;
			}
		}
	} 
    printf("No\n");
//	if(a<=9&&b<=9) printf("%d\n",a*b);
//	else printf("-1\n");
	return 0;
}

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

int main()
{
    int D;
    cin >> D;
    if (D == 25)
    {
        cout << "Christmas" << endl;
    }
    else if (D == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256
import bisect

n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


while m > 0:
    a.sort()
    m -= 1
    a[-1] = a[-1] // 2
    for i in range(n-1)[::-1]:
        if m == 0:
            break
        if a[i] > a[-1]:
            m -= 1
            a[i] = a[i] // 2
        else:
            break

ans = sum(a)
print(ans)


Measured memory_bytes: 14480
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int solve(double N, double K) {
    return 1 + int(floor(log(N)/log(K)));
}

int main()
{
    std::cout<<std::fixed<<std::setprecision(10);
    
    double N, K;
    cin >> N >> K;

    cout << solve(N, K) << endl;

    return 0;
}


Measured memory_bytes: 640
/*
OOO +2のみ
OOE +1 1回
OEE +1 1回
EEE +2のみ


*/


#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int ABC[3];
    for (int i=0; i<3; ++i) cin >> ABC[i];
    
    int ans = 0;

    if (ABC[0]%2==0 && ABC[1]%2==0 && ABC[2]%2==1){ //1
        ++ABC[0];
        ++ABC[1];
        ans = 1;
    }
    if (ABC[0]%2==0 && ABC[1]%2==1 && ABC[2]%2==0){ //2
        ++ABC[0];
        ++ABC[2];
        ans = 1;
    }
    if (ABC[0]%2==1 && ABC[1]%2==0 && ABC[2]%2==0){ //3
        ++ABC[1];
        ++ABC[2];
        ans = 1;
    }
    
    if (ABC[0]%2==1 && ABC[1]%2==1 && ABC[2]%2==0){ //4
        ++ABC[0];
        ++ABC[1];
        ans = 1;
    }
    if (ABC[0]%2==1 && ABC[1]%2==0 && ABC[2]%2==1){ //5
        ++ABC[0];
        ++ABC[2];
        ans = 1;
    }
    if (ABC[0]%2==0 && ABC[1]%2==1 && ABC[2]%2==1){ //6
        ++ABC[1];
        ++ABC[2];
        ans = 1;
    }
    
    
    sort(ABC, ABC+3);
    
    ans += (ABC[2] - ABC[0]) / 2;
    ans += (ABC[2] - ABC[1]) / 2;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
int n;
std::cin >> n;
std::vector<int> a(n + 1,0);
std::vector<int> dis;
int sum = 0;
int div = 0;
for(int i = 1; i < n + 1; i++){
    int temp;
    std::cin >> temp;
    a[i] = temp;
    sum += temp;
    div += i;
}
int t = sum / div;
for(int i = 1; i < n; i++){
    dis.push_back(a[i + 1] - a[i] - t);
}
dis.push_back(a[1] - a[n] - t);
if(sum % div != 0){
    std::cout << "NO" << std::endl;
} else {
    int flag = 0;
    int counter = 0;
    for(int i = 0; i < n; i++){
        if(dis[i] > 0 || abs(dis[i]) % n != 0){
            flag = 1;
        }
        counter += abs(dis[i]) / n;
    }   
    if(flag == 0 && counter <= t){
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#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() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (s == u) cout << a - 1 << " " << b << endl;
  else cout << a << " " << b - 1 << endl;
}

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

int main() {
  string s;
  long long int k;
  cin >> s >> k;

  int index = 101;
  int number = 1;
  for(int i=0;i<s.size();i++) {
    if(s[i] != '1') {
      index = i;
      number = s[i] - '0';
      break;
    }
  }

  if(k-1 < index) {
    cout << 1 << endl;
  } else {
    cout << number << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

ll dp[101][2][5] = {};

ll f(string s, int K){
    int n = s.length();
    for(int i = 0; i < n; i++){
        // success
        for(int j = 0; j < 2; j++){
            for(int k = 0; k <= K; k++){
                if(dp[i][j][k] == 0)    continue;
                for(int val = 0; val < 10; val++){
                    if(j==0 && val > s[i]-'0')  break;
                    if(k==0 && val != 0)    continue;
                    int ni = i+1;
                    int nj = j | (val < s[i]-'0');
                    int nk = val!=0 ? k-1 : k;
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
        // start
        for(int val = 1; val < 10; val++){
            if(i == 0 && val > s[i]-'0')    break;
            int less = !(i==0 && s[i]-'0'==val);
            dp[i+1][less][K-1]++;
        }
    }
    ll ret = 0;
    for(int j = 0; j < 2; j++){
        ret += dp[n][j][0];
    }
    return ret;
}

int main(){
    string s;
    int k;
    cin >> s >> k;
    cout << f(s, k) << endl;
    return 0;
}

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

int main(void)
{
  int num;
  char *str1;
  char *str2;

  scanf("%d\n", &num);

  str1 = (char*)malloc(sizeof(char) * num);
  str2 = (char*)malloc(sizeof(char) * num);

  for(int i = 0; i < num; i++){
	scanf("%c", &str1[i]);
  }
  char dummy;
  scanf("%c", &dummy);
  for(int i = 0; i < num; i++){
	scanf("%c", &str2[i]);
  }
  
  int i = 0;

  for(int i = 0; i < num; i++){
    printf("%c", str1[i]);
    printf("%c" , str2[i]);
  }

  free(str1);
  free(str2);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

char str[5];
char sign[3];

int op3(int n) {
	if (n+str[3]==7) {sign[2]='+'; return 1;}
	if (n-str[3]==7) {sign[2]='-'; return 1;}
	return 0;
}

int op2(int n) {
	if (op3(n+str[2])) {sign[1]='+'; return 1;}
	if (op3(n-str[2])) {sign[1]='-'; return 1;}
	return 0;
}

int op1() {
	if (op2(str[0]+str[1])) {sign[0]='+'; return 1;}
	if (op2(str[0]-str[1])) {sign[0]='-'; return 1;}
	return 0;
}

int main() {
	scanf("%s",str);
	str[0]-='0';
	str[1]-='0';
	str[2]-='0';
	str[3]-='0';
	
	op1();
	
	printf("%d%c%d%c%d%c%d=7\n",str[0],sign[0],str[1],sign[1],str[2],sign[2],str[3]);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>



int main()
{
	
	int A,B,sum,mult,sub;
	
	scanf("%d %d", &A, &B);
	
	sum = A + B;
	mult = A * B;
	sub = A - B;
	
	if (sum > mult && sum > sub){
		printf("%d", sum);
	}
	else if(mult > sum && mult > sub){
		printf("%d", mult);
	}
	else if(sub > sum && sub > mult){
		printf("%d", sub);
	}
	else{
		printf("%d", sum);
	}

	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

int a[120]={0};
int x;
int MAX=0;

int main(){
	while(cin>>x){
		a[x]++;
	}
	rep(i,101){
		MAX = max(MAX,a[i]);
	}
	rep(i,101){
		if(a[i] == MAX){
			cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
n = gets.to_i
a = Array.new(n){gets.split.map(&:to_i)}
cnt = 0
sum = 0
n.times do |i|
  cnt = (sum + a[n - i - 1][0]) % a[n - i - 1][1] == 0 ? 0 : a[n - i - 1][1] - (sum + a[n - i - 1][0]) % a[n - i - 1][1]
  sum += cnt
end
puts sum

Measured memory_bytes: 9596
#include<stdio.h>
main(){
  int tmp[31],tmp1;
  int i,w,n,a,b;
  for(i=1;i<=30;i++)tmp[i]=i;

  scanf("%d %d",&w,&n);
  for(i=0;i<n;i++){
    scanf("%d,%d",&a,&b);
    tmp1=tmp[a];
    tmp[a]=tmp[b];
    tmp[b]=tmp1;
  }
  for(i=1;i<=w;i++){
  printf("%d\n",tmp[i]);
  }
  return 0;
}



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

using namespace std;

int main(){
    int N, Y;

    cin >> N >> Y;


    int n = 0;
    int y = 0;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i ; j++){
            y = 1000*i + 5000*j + 10000*(N-i-j);
            if( y == Y ){
                printf("%d %d %d\n", N-i-j, j, i);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");
    return 0;
}


    


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

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

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

int main() {
  int N;
  cin >> N;
  double a, b;
  vector<double> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  a = vec.at(0);
  for (int i=1; i<N; i++){
    b = vec.at(i);
    a = (double)((a + b)/2.0);
    } 
  cout << a << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n, q, a[10000] = {}, b[500] = {}, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] == b[i]) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3132
A,B,C,D = map(int,input().split())
if A<C:
    if A<B<=C<D:
        print(0)
    elif A<=C<B<D:
        print(B-C)
    elif A<=C<D<=B:
        print(D-C)
else:
    if C<D<=A<B:
        print(0)
    elif C<=A<D<B:
        print(D-A)
    elif C<=A<B<=D:
        print(B-A)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
num_dict = {}
for i in A:
    if i in num_dict.keys():
        num_dict[i] += 1
    else:
        num_dict[i] = 1
ok = 0
for i in num_dict.values():
    if i >= 2:
        print('NO')
        ok = 1
        break
if ok == 0:
    print('YES')

Measured memory_bytes: 33612
#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
#define endl "\n"

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 T> ostream& operator<<(ostream& s,const multiset<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 EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
int main(){
   int n;
   cin >>n;
   long long x[n]={},min,d=-1000000000;
   for(int i=0;i<n;i++){
    cin >>x[i];
    if(i ==0) min =x[0];
    else
   { if((x[i]-min)>d) d=x[i]-min;
       if(x[i]<min) min =x[i];}
   }
   cout <<d<<"\n";
	return 0;
}



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

int main() {
    int N;
    cin>>N;
    vector<vector<int>> A;
    vector<int> a0;
    vector<int> a1;
    
    for (int i=0; i<N; i++) {
        int a;
        cin>>a;
        a0.push_back(a);
    }
    A.push_back(a0);
    
    for (int i=0; i<N; i++) {
        int a;
        cin>>a;
        a1.push_back(a);
    }
    A.push_back(a1);
    int max=0;
    
    for (int i=0; i<N; i++) {
        
        int maxx=0;
        for (int j=0; j<N+1; j++) {
            if(i<j){
               maxx=maxx+A[1][j-1];
            }else{
                maxx=maxx+A[0][j];
            }
        }
        if(maxx>max){
            max=maxx;
        }
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  char d,e;
  
  cin>>a>>d>>b>>e>>c;
  
 if(b<=4)
   cout<<"Heisei";
  else 
    cout<<"TBD";
  
  return 0;
  
}
         


Measured memory_bytes: 3596
N=int(input())
A=list(map(int,input().split()))
a=b=c=0
for i in sorted(A)[::-1]:
    c+=1
    if a==i:break
    a=i
B=sorted(A)[:-c:]
c=0
d=len(B)
for i in B[::-1]:
    c+=1
    if b==i:break
    b=i
    if c==d:b=0
print(a*b)

Measured memory_bytes: 14252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p){
  os << "{" << p.first << "," << p.second << "} ";
  return os;
}

int main() {
  int N, M, Q; cin >> N >> M >> Q;
  map<int, map<int, int>> m;
  for (int i = 0; i < M; ++i) {
    int L, R; cin >> L >> R;
    m[L][R]++;
  }

  LL table[501][501] = {};
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      table[i][j] = table[i-1][j] + table[i][j-1] - table[i-1][j-1];
      table[i][j] += m[i][j];
      if (DEBUG)
        cout << table[i][j] << " ";
    }
    if (DEBUG)
      cout << endl;
  }

  for (int i = 0; i < Q; ++i) {
    int p, q; cin >> p >> q;
    cout << table[q][q] - table[q][p-1] - table[p-1][q] + table[p-1][p-1] << endl;
  }
}


Measured memory_bytes: 14592
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		String b = stdIn.next();
		String c = stdIn.next();
		
		
		if ((a.charAt(a.length()-1)) == b.charAt(0) && ((b.charAt(b.length()-1)) == c.charAt(0))) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,A,B;

//解法
void solve() {

	cout << min(A, B) << " ";


	if (A + B >= N) {
		cout << (A + B) - N;
	}
	else {
		cout << 0;
	}

	return;
}

int main() {
	//入力

	cin >> N>>A>>B;

	solve();
	cout << 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 a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		int ans = a - 1;
		if(a <= b)ans++;
		System.out.println(ans);
	}

}


Measured memory_bytes: 20820
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d", a * b);

  return 0;
}


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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
int N, H[MAX];

int main(){
    cin >> N;
    rep(i, N) cin >> H[i];

    rep(i, N){
        if(i == 0){
            H[i]--;
            continue;
        }
        
        if(H[i - 1] < H[i]) H[i]--;
    }

    bool ans = true;
    rep(i, N - 1){
        if(H[i] > H[i + 1]) ans = false;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std; 
// Binary indexed tree supporting binary search.
 
 
#define x first
#define y second
 
#define forn(i, n) for(int i = 0; i < int(n); ++i)
 
typedef pair<int, int> pii;
//#define forn(i, a,b) for (int i = (int) a; i <= (int) b; ++i)

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    long long X;
    cin>>X;
    long long st = 100;
    int tt=0;
    while(st<X){
    	st = (long long) (((double) 1.01) * st);
    	tt++;
	}
	cout<<tt<<endl;
	return 0;	
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<iomanip>

void Main();
int main()
{
	std::cin.sync_with_stdio(false);
	std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
	Main();
}

void Main()
{
	int N, K;
	std::cin >> N >> K;
	std::vector<int> vec(K);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
	do
	{
		auto v = N;
		while (v)
		{
			if (std::binary_search(vec.begin(), vec.end(), v % 10))
				goto next;
			v /= 10;
		}
		std::cout << N << std::endl;
		return;
	next:;
	} while (++N);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
int d[101010];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &d[i + 1]);
	int ans = 0;
	for (int i = 0; i < num + 1; i++)ans += abs(d[i + 1] - d[i]);
	for (int i = 1; i <= num; i++)
	{
		printf("%d\n", ans - abs(d[i] - d[i - 1]) - abs(d[i + 1] - d[i]) + abs(d[i + 1] - d[i - 1]));
	}
}

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

using namespace std;


struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

typedef vector<LL> V;
typedef vector<V> VV;

const LL MOD=1e9+7;

// a x + b y = gcd(a, b)
// O(log (a+b) )
LL extgcd(LL a, LL b, LL &x, LL &y) {
    LL g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

// mを法とするaの逆元
// O(log a)
LL invMod(LL a) {
    LL x, y;
    if (extgcd(a, MOD, x, y) == 1)return (x + MOD) % MOD;
    else
        return 0; // unsolvable
}
//a^n (mod MOD)
//O(log a)
LL pow_mod(LL a,LL n){
	LL res=1;
	LL b=1;
	while(n>=b){
		if(n&b)
		res=(res*a)%MOD;
		a=(a*a)%MOD;
		b<<=1;
	}
	return res;
}

int main(){
    int N;
    cin>>N;
    //if(N>300)return -1;
    string s;
    cin>>s;
    int m=s.size();
    V dp(N+1,0);
    dp[0]=1;
    for(int i=0;i<N;i++){
        V nxt(N+1,0);
        for(int l=0;l<=i;l++){
            (nxt[l+1]+=2*dp[l])%=MOD;
            (nxt[max(l-1,0)]+=dp[l])%=MOD;
        }
        swap(dp,nxt);
    }
    cout<<dp[m]*invMod(pow_mod(2,m))%MOD<<endl;

    return 0;
}


Measured memory_bytes: 384
I=->{gets.split.map &:to_i}
N,Q=I[]
A=[1,c=1,1,*[0]*(N-2),1]
Q.times{
	a,b=I[]
	A[a],A[b]=A[b],A[a]
	c = c==a ? b : c==b ? a : c
	A[c-1]=A[c+1]=1
}
p A.reduce(:+)-2

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll x=max(a,b);
  if(c%x==0){cout<<c/x<<endl;}
  else{cout<<c/x+1<<endl;}
}

Measured memory_bytes: 256