akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadInts();

            if (a.Sum() <= 21)
            {
                WriteLine("win");
            }
            else
            {
                WriteLine("bust");
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <deque>
using namespace std;
int main(void){
    int n;
    int A[200000];
    deque<int> q;
    
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> A[i];
    }
    
    if(n % 2 == 0){
        for(int i = 0;i < n;i++){
            if(i % 2 == 0){
                q.push_back(A[i]);
            }else{
                q.push_front(A[i]);
            }
        }
    }else{
        for(int i = 0;i < n;i++){
            if(i % 2 == 1){
                q.push_back(A[i]);
            }else{
                q.push_front(A[i]);
            }
        }
    }
    
    deque<int>::iterator it = q.begin();
    
    for(it;it != q.end();it++){
        cout << *it << " ";
    }
    return 0;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int no_of_elements;
    scanf("%d", &no_of_elements);

    vector <int> element(no_of_elements + 1, 0);
    for(int i = 1; i <= no_of_elements; i++)
        scanf("%d", &element[i]);

    int no_of_swaps = 0;
    for(int i = 1; i <= no_of_elements; i++)
    {
        if(element[i] == i)
        {
            no_of_swaps++;
            i++;
        }
    }

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


Measured memory_bytes: 640
H,W=map(int,input().split())

a=[list(map(str,input().split())) for i in range(H)]
for i in range(H):
    a[i]=list(a[i][0])
flag=True
for i in range(H):
    for j in range(W):
        if a[H-1-i][j]!='.':
            flag=False
            break
    if flag:
        del(a[H-1-i])
    flag=True
for i in range(W):
    for j in range(len(a)):
        if a[j][W-1-i]!='.':
            flag=False
            break
    if flag:
        for j in range(len(a)):
            del(a[j][W-1-i])
    flag=True

for aaa in a:
    print("".join(aaa))

Measured memory_bytes: 9096
#include <iostream>
#include <stdio.h>
using namespace std;
  
int main(){
  int a,b,c,d,n,count = 0;
  while(scanf("%d",&n)!=EOF){
      
    count=0;
    for(a = 0;a <= 9;a++){
    for(b = 0;b <= 9;b++){
      for(c = 0;c <= 9;c++){
    for(d = 0;d <= 9;d++){
      if((a+b+c+d) == n)count++;
    }
      }
    }
    }
    cout << count <<endl;
  }
  return 0;
}


Measured memory_bytes: 3124
x,k,d=map(int,input().split())

x=abs(x)

saisho=x//d

if(k<saisho):
    print(x-k*d)
else:
    nokori=k-saisho
    if(nokori%2==0):
        print(x-saisho*d)
    else:
        print(d*(saisho+1)-x)

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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
int n;
ll a[maxn];
ll cnt[maxn];
ll way[maxn], way2[maxn], sum;

//check T
void solve()
{
	cin >> n;
  rep(i, 1, n+1) cnt[i] = 0;
  rep(i, 1, n+1) cin >> a[i], cnt[a[i]]++;
  rep(i, 1, n+1) way[i] = 0, way2[i] = 0;
  sum = 0ll;
  rep(i, 1, n+1) if(cnt[i] > 1) way[i] = cnt[i] *(cnt[i] -1)/2, way2[i] = (cnt[i] -1)*(cnt[i] -2)/2, sum+=way[i];
  //cout << sum << endl;
  rep(i, 1, n+1)
  {
    cout << sum - way[a[i]] + way2[a[i]] << " \n"[i==n];
  }

  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


Measured memory_bytes: 8832
#include <iostream>

//

using namespace std;

int main(){
    char c;
    cin >> c;

    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;    
    } else{
        cout << "consonant" << endl;    
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	string s;
	cin >> s;
	int a[26]={};
	for(int i=0; i<4; i++){
		a[s[i]-'A']++;
	}
	for(int i=0; i<26; i++){
		if(a[i]%2 || a[i]==4){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int a[29], b[29], r[29], d[29];
vector<pair<int, int> > av, bv;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (i % 2) swap(a[i], b[i]);
	}
	int ans = 1000000000;
	for (int i = 0; i < (1 << n); i++) {
		int t = i, c = 0;
		while (t) {
			t -= (t & (-t)); c++;
		}
		if (c != (n + 1) / 2) continue;
		av.clear(); bv.clear();
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) av.push_back(make_pair(a[j], j));
			else bv.push_back(make_pair(b[j], j));
		}
		sort(av.begin(), av.end());
		sort(bv.begin(), bv.end());
		bool f = true;
		for (int j = 0; j < n; j++) {
			if (j % 2) { r[j] = bv[j / 2].second; d[j] = bv[j / 2].first; }
			else { r[j] = av[j / 2].second; d[j] = av[j / 2].first; }
			if (j > 0 && d[j] < d[j - 1]) {
				f = false;
				break;
			}
		}
		if (!f) continue;
		int s = 0;
		for (int j = 0; j < n; j++)
			for (int k = j + 1; k < n; k++)
				if (r[j] > r[k])
					s++;
		ans = min(ans, s);
	}
	if (ans == 1000000000) cout << -1 << '\n';
	else cout << ans << '\n';
	return 0;
}	

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll


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

    int now=1;
    int N,a[210000];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    for(int i=0;i<N;i++){
        if(now==a[i]) now++;
    }
    if(now==1) cout<<-1<<endl;
    else cout<<N-(now-1)<<endl;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long  N,K,cnt=0,a,b;
    cin >> N >> K;
    long long d[K], A[K+1], sunuke[N+1]={};

    for (int i = 1; i<= K; i++) {
        cin >> a;
        for (int n = 1; n<=a; n++) {
            cin >> b;
            sunuke[b] = 1;
        }
    }

    for (int i =1; i<=N;i++) {
        if(sunuke[i] != 1){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3632
import sys
input = lambda: sys.stdin.readline().rstrip()
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    X[a-1].append(b-1)
    X[b-1].append(a-1)

def col(n, E):
    C = [-1] * n
    c = 0
    for i in range(n):
        if C[i] >= 0: continue
        Q = [i]
        C[i] = c
        while Q:
            x = Q.pop()
            for y in E[x]:
                if C[y] == -1:
                    C[y] = C[x]
                    Q.append(y)
        c += 1
    return C

Y = [0] * N
for i in col(N, X):
    Y[i] += 1
print(max(Y))

Measured memory_bytes: 104572
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1
ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) 

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

int main() {
		
	string s; cin >> s;
	string ans = "";
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') ans += "0";
		if (s[i] == '1') ans += "1";
		if (s[i] == 'B') {
			if(ans.size() != 0)	ans.erase(ans.size() - 1);
		}
	}
		
	cout << ans << endl;
	return 0;
}

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

signed main() {
	int x, y;
	cin >> x >> y;
	
	if (abs(x - y) <= 1) {
		cout << "Brown" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main (String [] args){
		Scanner javain = new Scanner(System.in);
		int a, b;
		a = javain.nextInt();
		b = javain.nextInt();
		System.out.println((a * b) + " " + (a * 2 + b * 2));
		
	}
}

Measured memory_bytes: 26100
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	int n; cin >> n;
	vector<pair<pair<int,int>,int>> p(n);
	REP(i,n){
		cin >> p[i].first.first >> p[i].first.second;
		p[i].second=i;
	}
	VI k, ans(n);
	sort(ALL(p));
	int m=n;
	REP(i,n){
		m=min(m,p[i].first.second);
		k.push_back(p[i].second);
		if(m==n-i){
			int an=k.size();
			for(auto s:k){
				ans[s]=an;
			}
			while(!k.empty()){
				k.pop_back();
			}
		}
	}
	REP(i,n){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 9196
S = input()
T = input()
ls, lt = len(S), len(T)    

ans = 'UNRESTORABLE'
for i in range(ls-lt+1):
    for j in range(lt):
      if S[i+j] not in (T[j], '?'):
        break       
    else:
      ans = (S[:i]+T+S[i+lt:]).replace('?','a')
   
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<pair<Int, Int>> P(N);
    for (int i = 0; i < N; i++) cin >> P[i].first >> P[i].second;
    sort(begin(P), end(P));
    P.erase(unique(begin(P), end(P)), end(P));
    sort(rbegin(P), rend(P));
    multiset<Int> A, B;
    for (auto [x, y] : P) {
        A.insert(-x-y);
        B.insert(-x+y);
    }
    Int ans = 0;
    for (int i = 0; i < (int)P.size() - 1; i++) {
        auto [x, y] = P[i];
        A.erase(A.find(-x-y));
        B.erase(B.find(-x+y));
        ans = max(ans, x + y + *prev(end(A)));
        ans = max(ans, x - y + *prev(end(B)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25116
#coding: UTF-8

buf = list(str(input()))
for i in range(len(buf)):
    if buf[i].isupper() == True:
        buf[i] = buf[i].lower()
        buf_changed = "".join(buf)
    elif buf[i].islower() == True:
        buf[i] = buf[i].upper()
        buf_changed = "".join(buf)

print(buf_changed)


Measured memory_bytes: 5568
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"sort"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		hr := make([]entry, 0)
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			first, _ := strconv.Atoi(buf[0])
			second, _ := strconv.Atoi(buf[1])
			mt := entry{first, second}
			hr = append(hr, mt)
		}
		scanner.Scan()
		m, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < m; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			first, _ := strconv.Atoi(buf[0])
			second, _ := strconv.Atoi(buf[1])
			mt := entry{first, second}
			hr = append(hr, mt)
		}
		sort.Sort(ByFirst(hr))
		fmt.Println(LIS(hr))
	}
}

type entry struct {
	first, second int
}

type ByFirst []entry

func(f ByFirst) Len() int {
	return len(f)
}

func (f ByFirst) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

func (f ByFirst) Less(i, j int) bool {
	return f[i].first < f[j].first
}

func LIS(hr []entry) int {
	n := len(hr)
	lis := make([]int, n)
	lis[n-1] = 1
	for i := n-2; i > -1; i-- {
		m := 0
		for j := i+1; j < n; j++ {
			if hr[i].first < hr[j].first && hr[i].second < hr[j].second && lis[j] > m {
				m = lis[j]
			}
		}
		lis[i] = m+1
	}
	return lis[0]
}


Measured memory_bytes: 1188
def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        exit()
    ans = 1
    for a in A:
        ans *= a
        if ans >= 10 ** 18 + 1:
            print(-1)
            exit()
    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
	int A,B,C,D,ab,cd;
	cin >> A >> B >> C >> D;
	ab=A*B;
	cd=C*D;
	if (ab>=cd) {
		cout << ab;
	}else{
		cout << cd;
	}
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [m] <- readInt
  put $ 24 + (24 - m)


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
using namespace std;
 
/*
It's been a long day without you, my friend
And I'll tell you all about it when I see you again
We've come a long way from where we began
Oh I'll tell you all about it when I see you again
When I see you again
When I see you again
*/
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;
 
const int mod = 1e9+7;
 
int sod(int n){int sum =0;while(n > 0){sum += n %10;n /= 10;}return sum;}
 
int dig(int n){if(n==0) return 1;int cnt =0;while(n > 0){n /= 10;cnt++;}return cnt;}
 
int divs(int n){int cnt = 0;for(int x=1;x*x<=n;x++){if(n % x == 0){cnt++;if(n/x != x)cnt++;}}return cnt;}
 
int isprime(int n){if(n < 2)return false;for(int x=2;x*x<=n;x++)if(n % x == 0) return false;return true;}
 
int power(int x,unsigned int y,int p=mod) {int res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
 
const int inf = 1e18;

bool pal(string s){int l = 0 , r = s.size()-1;while(l < r){if(s[l++] != s[r--])return false;}return true;}



int32_t main(){
    FAST;

    int n;  cin >> n;

    int ans = inf;

    for(int x=1;x*x<=n;x++){
        if(n % x == 0){
            int row = x;
            int col = n / x;

            int cost = row - 1 + col -1;

            ans = min(ans , cost); 

        }
    }

    cout << ans;

    return 0;
}
 
 
 
// const int N = 1e6;
// bool prime[N+3];
// void sieve(){
 
//   memset(prime , true , sizeof prime );
 
//   prime[0] = false , prime[1] = false;
//   prime[2] = true;
 
//   for(int x=2;x*x<=N;x++){
//     if(prime[x] == true){
//       for(int i=x*x;i<=N;i+=x)
//         prime[i] = false;
//     }
//   }
 
// } 


// const int N = 1e6+50;
// int spf[N+11];
 
// void SPF(){
 
// 	spf[1] = 1; 
  
//     for (int i = 2; i <= N; i++) 
//     { 
//         if (spf[i] == 0) 
//         { 
//             spf[i] = i; 
  
//             for (int j = 2*i; j <= N; j += i) 
//                 if (spf[j] == 0) 
//                    spf[j] = i; 
//         } 
//     } 
// }
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 15;
int a[N][2];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int w;
        cin >> w;
        while (w--) {
            int x, y;
            cin >> x >> y;
            --x;
            a[i][y] |= 1<<x;
        }
    }
    int ans = 0;
    for (int ho = 1; ho < (1<<n); ++ho) {
        int c[2] = {0, ho};
        int vis = 0;
        bool ok = 1;
        while (vis != c[1]) {
            int i = vis ^ c[1];
            i = __lg(i & -i);
            vis ^= 1<<i;
            if ((c[0] & a[i][1]) || (c[1] & a[i][0])) {
                ok = 0;
                break;
            }
            c[0] |= a[i][0];
            c[1] |= a[i][1];
        }
        //cerr << ho << ' ' << ok << endl;
        if (ok)
            ans = max(ans, __builtin_popcount(c[1]));
    } 
    cout << ans << endl;
}


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(){
    string s;
    cin>>s;
    set<char>st;
    rep(i,s.size()){
        st.insert(s[i]);
    }
    char unit[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    string abc(unit,end(unit));
    char mi = 'z';
    int cnt=0;
    for(int i = 0; i < abc.size();i++){
        decltype(st)::iterator it = st.find(abc[i]);
        if(it != st.end()){//見つかった場合
            cnt++; //cnt=abc.size()ならNone
        }else{
            mi = min(mi,abc[i]);
        }
    }
    if(cnt==abc.size()){
        cout<<"None"<<endl;
    }else{
        cout<<mi<<endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  vector<int> X(200000, 0);
  
  int x = 0;
  
  rep(i, 200000) {
    char y = '0';
    cin >> y;
    X.at(i) = (int)(y);
    if(X.at(i) != 0) {
      x += X.at(i);
    }
  }
  x -= 9600000;
  if(x%9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3864
/************************************************
*Author        :  xzj213
*Created Time  :  2019.10.27.20:18
*Mail          :  xzj213@qq.com
*Problem       :  D
************************************************/
#include <bits/stdc++.h>
using namespace std;
const double k=3.14159265358494;
double a,b,x;
int read() {
    int x=0,f=1;
    char ch=getchar();
    while(ch>57 || ch<48){if(ch==45)f=-1;ch=getchar();}
    while(ch<=57 && ch>=48){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int main() {
	cin>>a>>b>>x;
	x/=a;
	if(a*b>x*2){
		a=x/b*2;
		printf("%.8f",atan(b/a)*180/k);
	}
	else {
		x=a*b-x;
		b=x/a*2;
		printf("%.8f",atan(b/a)*180/k);
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll k=(b*b-a*a)/(2*b-2*a);
	if(abs(a-k)==abs(b-k)) cout<<k;
	else cout<<"IMPOSSIBLE";
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
const int T = 1000000001;
int main() {
	string s;
	cin >> s;
	set<char> st;
	for (int i = 0; i < 3; i++)st.insert(s[i]);
	if (st.size() == 2) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

vector<int> G;
int m;
int cnt3;

void insertsort2(vector<int> &v, int N, int g) {
    for(int i = g; i < N; i++) {
        int w = v[i];
        int j = i - g;
        while (j >= 0 && v[j] > w) {
            v[j+g] = v[j];
            j -= g;
            cnt3++;
        }
        v[j+g] = w;
    }
}

void shellsort(vector<int> &v, int N) {
    cnt3 = 0;
    REP(i,m) {
        insertsort2(v, N, G[i]);
    }
}


int main() {
    int N;
    cin >> N;
    vector<int> v;
    REP(i,N) {
        int j;
        cin >> j;
        v.push_back(j);
    }
   
    m = (int)log2(v.size()) + 1;
    int l = 1;
    REP(i,m) {
        G.push_back(l);
        l *= 2;
    }
    reverse(G.begin(), G.end());
    shellsort(v, N);
    cout << m << endl;
    REP(i,G.size()-1) {
        cout << G[i] << " ";
    }
    cout << G[G.size()-1] << endl;
    cout << cnt3 << endl;
    REP(i,v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5936
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	switch s {
	case "SUN":
		fmt.Print(7)
	case "MON":
		fmt.Print(6)
	case "TUE":
		fmt.Print(5)
	case "WED":
		fmt.Print(4)
	case "THU":
		fmt.Print(3)
	case "FRI":
		fmt.Print(2)
	case "SAT":
		fmt.Print(1)
	}
}


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

int main(){
  int m1,d1;
  cin>>m1>>d1;
  int m2,d2;
  cin>>m2>>d2;
  if(m2-m1==1){
    cout<<"1"<<endl;
  }else{
    cout<<"0"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
//#define local

using namespace std;

const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;

int a[maxn];
int n, x;

int gcd(int a, int b) {
    return b==0 ? a:gcd(b, a%b);
}

int main() {
#ifdef local
    if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
#endif
    scanf("%d%d", &n, &x);
    int d;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (a[i] > x)
            a[i] -= x;
        else if (a[i] < x)
            a[i] = x-a[i];
        else continue;
        if (i == 0) d = a[i];
        d = gcd(d, a[i]);
    }
    printf("%d\n", d);
#ifdef local
    fclose(stdin);
#endif
    return 0;
}











Measured memory_bytes: 640
#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 N = 3e4;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	int n;
	cin >> n;
	if (n == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	if (n == 4) {
		cout << "2 5 20 63" << endl;
		return 0;
	}
	vector<int> ans = {2, 8, 14, 3, 9};
	int p2 = 14 + 6;
	int p3 = 9 + 6;
	int p4 = 4;
	int p6 = 6;
	while ((int)ans.size() + 3 <= n && p2 + 12 <= N) {
		ans.push_back(p2);
		p2 += 6;
		ans.push_back(p2);
		p2 += 6;
		ans.push_back(p2);
		p2 += 6;	
	}
	while ((int)ans.size() + 3 <= n && p4 + 12 <= N) {
		ans.push_back(p4);
		p4 += 6;
		ans.push_back(p4);
		p4 += 6;
		ans.push_back(p4);
		p4 += 6;	
	}
	while ((int)ans.size() + 2 <= n && p3 + 6 <= N) {
		ans.push_back(p3);
		p3 += 6;
		ans.push_back(p3);
		p3 += 6;
	}
	while ((int)ans.size() + 2 <= n && p2 <= N && p4 <= N) {
		ans.push_back(p2);
		p2 += 6;
		ans.push_back(p4);
		p4 += 6;
	}
	while ((int)ans.size() + 1 <= n && p6 <= N) {
		ans.push_back(p6);
		p6 += 6;
	}
	cerr << "sz: " << ans.size() << endl;
	cerr << p2 << ' ' << p3 << ' ' << p4 << ' ' << p6 << endl;
	assert((int)ans.size() == n);
	int s = 0;
	for (auto t : ans) {
		s += t;
	}
	for (auto t : ans) {
		assert(t <= N);
		#ifdef LOCAL
		assert(gcd(t, s) > 1);
		#endif
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i + 1 < n; i++) {
		assert(ans[i] < ans[i + 1]);
	}
	for (auto t : ans) {
		cout << t << ' ';
	} 
	cout << endl;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "Yes\n";
string no = "No\n";

int main() {
	string s;
	cin>>s;
	ll n = s.size(), ans = 0;
	for(int i=0;i<n;i++) {
		ans += (s[i] - '0');
		ans = ans%9;
	}
	if(ans == 0) {
		cout<<yes;
	} else {
		cout<<no;
	}
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<a-b+1<<endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/dp/tasks/dp_g
import sys
sys.setrecursionlimit(10**7)


class DAG:
    def __init__(self, n):
        # n: num of vertices
        self.n = n
        self.adj = [[] for _ in range(n)]

    def addEdge(self, parent, child):
        self.adj[parent].append(child)

    def dfs(self, node):
        ans = 0
        for child in self.adj[node]:
            ans = max(ans, 1 + self.dfs(child))
        return ans

    def dfsWithMemo(self, node, memo, visited):
        if(visited[node]):
            return memo[node]
        visited[node] = True
        for child in self.adj[node]:
            memo[node] = max(
                memo[node], 1 + self.dfsWithMemo(child, memo, visited))
        return memo[node]

    def dfsWithDp(self, node, dp, visited):
        if(visited[node]):
            return dp[node]
        visited[node] = True
        for child in self.adj[node]:
            if not visited[child]:
                self.dfsWithDp(child, dp, visited)
            dp[node] = max(dp[node], 1 + self.dfsWithDp(child, dp, visited))
        return dp[node]

    # o(n^2) solution
    def findLongestPathNaive(self):
        ans = 0
        for i in range(self.n):
            ans = max(ans, self.dfs(i))
        return ans

    # o(n) solution
    def findLongestPathWithMemo(self):
        visited = [False] * self.n
        memo = [0] * self.n
        ans = 0
        for i in range(self.n):
            ans = max(ans, self.dfsWithMemo(i, memo, visited))
        return ans

    # O(n) solution
    def findLongestPathWithDp(self):
        visited = [False] * self.n
        dp = [0] * self.n  # dp[i] := longest path starting from vertex i
        ans = 0
        for i in range(self.n):
            ans = max(ans, self.dfsWithDp(i, dp, visited))
        return ans


def main():
    N, M = map(int, input().split())
    dag = DAG(N)
    for _ in range(M):
        parent, child = map(lambda i: int(i) - 1, input().split())
        dag.addEdge(parent, child)
    # print(dag.findLongestPathNaive())
    print(dag.findLongestPathWithMemo())
    # print(dag.findLongestPathWithDp())


main()


Measured memory_bytes: 64360
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long tmp;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            tmp = i;
            //cout << "#" << i;
        }
    }
    tmp = n / tmp;
    int ans = 0;
    while(tmp>0){
        tmp /= 10;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N;
    string S;
    map<string, ll> T;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S;
        sort(S.begin(), S.end());
        T[S]++;
    }
    ll ans = 0;
    for(auto& b : T){
        ll a = b.second;
        ans += (a) * (a - 1) / 2; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
import math


def solve(A, B, H, M):
    h = (360 / 12) * H + (360 / 12 / 60) * M
    m = (360 / 60) * M
    oa = (A * math.sin(math.radians(h)), A * math.cos(math.radians(h)))
    ob = (B * math.sin(math.radians(m)), B * math.cos(math.radians(m)))

    x = oa[0] - ob[0]
    y = oa[1] - ob[1]
    return (x ** 2 + y ** 2) ** 0.5


if __name__ == "__main__":
    A, B, H, M = tuple(map(int, input().split(" ")))
    print(solve(A, B, H, M))


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

int main() {
  int S, W;
  cin >> S >> W;
  if (S <= W) {
    cout << "unsafe" << endl;
  }
  else {
    cout << "safe" << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    char s;
    cin >> s;
     if (isupper(s)) {
         cout << 'A' << endl;
         return 0;
     }
     cout << 'a' << endl;
}

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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
    
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        int sum = 0;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum + C > 0){
            ans++;
        }
    }
    
    // output
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
'use strict'

function topological_sort(nodes_count, in_count, outs){
  let start_nodes = Array.from(Array(nodes_count+1).keys()).filter(x => in_count[x]==0)
  start_nodes.shift()

  let result = [];
  let from = start_nodes.shift();
  while(from != undefined){
    result.push(from);
    for(let out_node of outs[from]){
      in_count[out_node]--;
      if(in_count[out_node]==0){ start_nodes.push(out_node); }
    }
    from = start_nodes.shift();
  }

  return result;
}

function main(input){
  const lines = input.split('\n');
  const NM = lines.shift().split(' ').map(x => parseInt(x));
  const N = NM[0];
  const M = NM[1];
  const XY = []
  for(var i=0;i<M;i++){
    let xy = lines.shift().split(' ').map(x => parseInt(x));
    XY.push(xy);
  }

  let ins = [];
  let outs = [];
  let in_count = []
  for(var i=0;i<N+1;i++){
    ins.push([]);
    outs.push([]);
  }

  for(var i=0;i<M;i++){
    let x = XY[i][0];
    let y = XY[i][1];
    ins[y].push(x);
    outs[x].push(y)
  }
  in_count = ins.map(x => x.length)

//  console.log(ins);
//  console.log(outs);
//  console.log(in_count);

  let topological_nodes = topological_sort(N, in_count, outs);
//  console.log(topological_nodes);

//  console.log('---');
  let dp=Array(N+1).fill(0);
//  console.log(dp);
  for(let current of topological_nodes){
//    console.log( [current, ins[current], ins[current].map(x => dp[x])] );
    dp[current] = Math.max(...ins[current].map(x => dp[x]+1).concat(0) )
  }
//  console.log(dp);
//  console.log('---');


  let result = Math.max(...dp);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 93524
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll dp[401][401];

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    vector<ll> S(N+1);
    rep(i,401){
        rep(j,401){
            dp[i][j] = 1e15;
        }
    }

    rep(i,N){ 
        cin >> a[i];
        S[i+1] = a[i] + S[i];
        dp[i][i] = 0;
    }

    reps(area,1,N){
        rep(i,N-area){
                if(area == 1) dp[i][i+area] = a[i] + a[i+area];
                else{
                    reps(j,i,i+area){
                        dp[i][i+area] = min(dp[i][i+area],
                                            dp[i][j] + dp[j+1][i+area] + 
                                            (S[j+1]-S[i]) + (S[i+area+1]-S[j+1])); 
                    }
                }
        }
    }

    cout << dp[0][N-1] << endl;
    return 0;
}


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

int main(){
  int h, w, n;
  vector<int> a, b;
  map<pair<int, int>, int> m;
  int dx[9] = {0,-1,0,1,1,1,0,-1,-1};
  int dy[9] = {0,-1,-1,-1,0,1,1,1,0};
  unsigned long long int res[10] = {};
  int x, y, k, count=0;

  cin >> h >> w >> n;
  a.resize(n);
  b.resize(n);
  for(int i=0; i<n; ++i){
    cin >> b[i] >> a[i];

    for(k=0; k<9; ++k){
      x=a[i]+dx[k];
      y=b[i]+dy[k];

      if(x>=1 && x<=w && y>=1 && y<=h){
	auto itr = m.find(make_pair(x,y));
	if(itr != m.end()){
	  itr->second++;
	}else{
	  m[make_pair(x,y)]=1;
	}
      }
    }
  }

  for(auto itr=m.begin(); itr!=m.end(); ++itr){
    pair<int,int> p = itr->first;

    if(p.first!=1 && p.first!=w && p.second!=1 && p.second!=h){
      res[itr->second]++;
      count++;
    }
  }

  res[0] = (unsigned long long int)(h-2)*(w-2)-count;

  for(int i=0; i<10; ++i){
    cout << res[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 57216
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	int x=(a[n-1])/2;
	int y=(a[n-1]+1)/2;
	int c=0, d=0;
	for(int i=0; a[i]<=x; i++){
		c=a[i];
	}
	for(int i=n-1; a[i]>=y; i--){
		d=a[i];
	}
	cout << a[n-1] << " "<< (x-c<=d-y? c: d);
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define A 7
#define B 6
#define C 5
#define O 0

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

struct node *root;
struct node *NIL;

struct node *find(struct node *,int);
void insert(int);
void inorder(struct node *);
void preorder(struct node *);

int main(){

  int n,i,j,x;
  
  int c=0,Cn[10],tmp=0;

  struct node *t;
  char *com,*comI = "insert",*comP = "print";

  com = (char*)malloc(A*sizeof(char));  

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'f'){
      scanf("%d", &x);
      t = find(root, x);
      if(t != NIL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
      else if(strncmp(com,comI,B)==O){
	scanf("%d",&x);
	insert(x);
      }
      else if(strncmp(com,comP,C)==O){

	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }

    return 0;
  }

struct node *find(struct node *u, int k){
  while (u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){

  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y -> right = z;
    }
  }
}

void inorder(struct node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
 
  inorder(u->right);
}

void preorder(struct node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 20484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int n, m;
map<int, int> mp;

int main() {
    cin >> n;
    rep(i, n) {
        int d;
        cin >> d;
        mp[d]++;
    }
    cin >> m;
    rep(i, m) {
        int t;
        cin >> t;
        if(mp[t] > 0) mp[t]--;
        else {cout << "NO" << endl; END;}
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
// TEMPLATE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i=(a);(i)<(b);(i)++)
#define REP(i, n) for (int i=0;(i)<(n);(i)++)
#define REPS(i, n) for (int i=1;(i)<=(n);(i)++)
#define RREP(i, n) for (int i=(x-1);(i)>=0;(i)--)
#define RREPS(i, n) for (int i=n;(i)>0;(i)--)
#define len(x) ((int)(x).size())
#define print(x) (cout<<(x)<<"\n")

// LIBRARY

// SOLVE
signed main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, W; cin>>N>>W;
    vvi dp(N+1, vector<int>(W+1));

    FOR(i, 1, W+1) dp[0][i] = 0;
    FOR(i, 1, N+1) {
        int v, w; cin>>v>>w;
        FOR(j, 1, W+1) {
            if (w>j) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v);
        }
    }
    print(dp[N][W]);
}


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

int isPrime(int);

int main()
{
  int n, data[10000], k = 0, i, key;

  /*??\??????????????°????±????*/
  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &data[i]);

  for(i = 0; i < n; i++){
    key = isPrime(data[i]);
    if(key == 1)
      k++;
  }
  printf("%d\n", k);
  return 0;
}

int isPrime(int x)
{
  int i;
  if(x == 2)
    return 1;

  if(x < 2 || x % 2 == 0)
    return 0;

  i = 3;
  
  while(i <= sqrt(x)){
    if(x % i == 0)
      return 0;
    i += 2;
  }
  return 1;
}

Measured memory_bytes: 628
//
// Created by Myabu on 2020/01/22.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


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

    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }else{
        cout<<(a+b)/2+1<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    int answer = 0;
    for(int i = a;i <= b;i++){
        string s = to_string(i);
        if(s[0]==s[4] && s[1] == s[3])
            answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        writer.println((long) n * (n - 1) / 2);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21716
N = int(input())
a = ['z']
for i in range(25):
    a.append(chr(0x61 + i))
l = []
for i in range(20):
    x = N % 26
    l.append(a[x])
    N = N // 26
    if x == 0:
        N -= 1
    if N == 0:
        break

print("".join(reversed(l)))

Measured memory_bytes: 9208
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){

    string s;
    cin >> s;
    if(s == "Sunny")cout << "Cloudy"<< endl;
    if(s == "Cloudy")cout << "Rainy" << endl;
    if(s == "Rainy")cout << "Sunny" <<endl;
    return 0;
}

Measured memory_bytes: 256