akhauriyash/Code-Regression huggingface dataset:
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 512
#define M 32
#define K (1048576*3)
#define T 1024

int c[M];
int s[N][M];
int t[N];
int l[M];
int sc;

const int n = 365, m = 26;

int count()
{
    int ct = 0;
    memset(l,-1,sizeof(l));
    int res = 0;
    for(int i=0;i<n;++i)
    {
        ct += sc;
        ct -= (i-l[t[i]]) * c[t[i]];
        l[t[i]] = i;
        res += s[i][t[i]];
        res -= ct;
    }
    return res;
}

int main()
{
    int d;
    scanf("%d", &d);
    assert(d == 365);
    for(int i=0;i<m;++i) scanf("%d", &c[i]), sc += c[i];
    for(int i=0;i<n;++i)for(int j=0;j<m;++j) scanf("%d", &s[i][j]);
    for(int i=0;i<n;++i) t[i] = rand() % m;
    int val = count();
    //dbg_pri("poi 1: %d\n", val);
#ifdef DBG
    int ca=0, cb=0;
#endif //DBG
    for(int i=0;i<K;++i)
    {
        int x = rand()%n, k = rand()%m;
        int pre_t = t[x];
        t[x] = k;
        int nxt_v = count();
        if(nxt_v >= val || rand() <= (int)(exp((double)(nxt_v-val)/T)*((lli)RAND_MAX+1)))
        {
#ifdef DBG
            (nxt_v < val ? ca : cb) ++;
#endif //DBG
            val = nxt_v;
            //dbg_pri("poi 2: %d %d\n", i, val);
        }
        else t[x] = pre_t;
    }
    for(int i=0;i<n;++i) printf("%d\n", t[i]+1);
    dbg_pri("poi 3: %d %d %d\n", val, ca, cb);
    return 0;
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    map<int, long long> M;
    for (int i = -3982; i <= 3982; i++) {
        M[i] = 1ll * i * i * i * i * i;
    }
    long long n;
    cin >> n;
    for (auto p1: M) {
        for (auto p2: M) {
            if (p1.second - p2.second == n) {
                cout << p1.first << " " << p2.first << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, M;

int main() {
	cin >> N >> M;
	cout << ((M * 1900 + (N - M) * 100)<<M) << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n,a;

int main(){
	cin>>n>>a;
  n%=500;
  if(n<=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
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

main = do
  [n] <- readInt
  d <- readInt
  print $ solve n d

solve n d = ans
  where
    ds = sort d
    (a, b) = (ds !! (n `div` 2 - 1), ds !! (n `div` 2))
    ans = length [a + 1,a + 2 .. b ]

Measured memory_bytes: 16764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

int func(string s, string t) {
	int ans = 0;
	for (char c = 'a'; c <= 'z'; c++) {
		bool founds = false, foundt = false;
		for (int i = 0; i < s.length(); i++) {
			if (s[i] == c) {
				founds = true;
			}
		}
		for (int i = 0; i < t.length(); i++) {
			if (t[i] == c) {
				foundt = true;
			}
		}
		if (founds && foundt)  ans++;
	}
	return ans;
}

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

	int n;
	string s;
	cin >> n >> s;

	int ans = 0;
	for (int i = 0; i <= n; i++) {
		int t = func(s.substr(0, i), s.substr(i));
		ans = max(t, ans);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#ABC169 B-Multiplication2
class Calc():
  def multi(self,x,y):
    x, y, sign, rslt = str(x)+".", str(y)+".",1 ,""
    if x[0]=="-":
      sign*=-1
      x=x[1:]
    if y[0]=="-":
      sign*=-1
      y=y[1:]
    x,y=x.split("."),y.split(".")
    x2 = [int(x[1][-i-1]) for i in range(len(x[1]))] + [int(x[0][-i-1]) for i in range(len(x[0]))]
    y2 = [int(y[1][-i-1]) for i in range(len(y[1]))] + [int(y[0][-i-1]) for i in range(len(y[0]))]
    sum=[0]*(len(x2)+len(y2))
    for i, p in enumerate(y2):
      for j, q in enumerate(x2):
        K=i+j
        sum[K]+=p*q
        while sum[K]>9:
          sum[K+1], sum[K] = sum[K+1] + int(sum[K]/10) , sum[K]%10
          K+=1
    for i in range(len(sum)): rslt+=str(sum[-i-1])
    dclen=len(x[1])+len(y[1])
    if dclen>0: rslt=rslt[:len(rslt)-dclen]+"."+rslt[len(rslt)-dclen:len(rslt)]
    for i in range(len(rslt)):
      if rslt[i]=="0" and (rslt[i+1] if i<len(rslt)-1 else ".")!="." : continue
      else:
        rslt=rslt[max(i,0):]
        break
    return ("-" if sign==-1 else "")+rslt
  
  def max_2(self,x,y):
    X,Y=x,y
    x, y, rslt = str(x)+".", str(y)+".", ""
    if x[0]=="-" and y[0]!="-": return Y
    if x[0]!="-" and y[0]=="-": return X
    if x[0]=="-" and y[0]=="-": return #(略)
    x,y=x.split("."),y.split(".")
    size0,size1 = max(len(x[0]),len(y[0])), max(len(x[1]),len(y[1]))
    x[0],y[0] = "0"*( size0 - len(x[0]) ) + x[0] , "0"*( size0 - len(y[0]) ) + y[0]
    x[1],y[1] = x[1] + "0"*( size1 - len(x[1]) ) , y[1] + "0"*( size1 - len(y[1]) )
    for s in [0,1]:
      for i in range( size0 if s==0 else size1 ):
        p,q=int(x[s][i]),int(y[s][i])
        if p==q: continue
        elif p>q: return X
        elif p<q: return Y
    return X

N=int(input())
A=input().split()
R,lim="1","1"+"0"*17+"1"
if "0" in A: print(0)
else:
  for i in range(N): 
    R=Calc().multi(R,A[i])
    if Calc().max_2(lim,R)==R:
      print(-1)
      break
  else:
    print(R)

Measured memory_bytes: 19816
def is_square_root_naive(n):
    m = int(n**.5)
    if abs(m*m - n) < 1e-6:
      print('Yes')
    else:
      print('No')
    
a,b = map(int, input().split())
c_str = str(a) + str(b)
c = int(c_str)
#print(c)
is_square_root_naive(c)

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



int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int ans = 0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int t = n-i*r-j*g;
			if(t >= 0 && t % b == 0){
				ans++;
			}
		}
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            Integer v = map.get(k);
            if (v == null) {
                v = 0;
            }
            map.put(k, ++v);
        }
        if (map.keySet().size() > 3) {
            System.out.println("No");
            return;
        }
        if (map.keySet().size() == 3) {
            if (n % 3 != 0) {
                System.out.println("No");
                return;
            }
            Integer[] array = map.keySet().toArray(new Integer[0]);
            Arrays.sort(array);
            int v = array[0] ^ array[1];
            if (v != array[2]) {
                System.out.println("No");
                return;
            }
            int limit = n / 3;
            if (map.get(array[0]).equals(map.get(array[1]))
                    && map.get(array[1]).equals(map.get(array[2]))
                    && map.get(array[0]) == limit
            ) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
        if (map.keySet().size() == 2) {
            if (n % 3 != 0) {
                System.out.println("No");
                return;
            }
            Integer[] array = map.keySet().toArray(new Integer[0]);
            Arrays.sort(array);
            if (array[0] != 0) {
                System.out.println("No");
                return;
            }
            int limit = n / 3;
            System.out.println(map.get(0) == limit ? "Yes" : "No");
        }
        if (map.keySet().size() == 1) {
            System.out.println(map.get(0) == null ? "No" : "Yes");
        }
    }
}

Measured memory_bytes: 59396
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define mod 1000000007
#define inf 999999999

int main(){
  int n,k;
  cin >> n >> k;
  int x[110];
  rep(i,n) cin >> x[i];
  int ans = 0;
  rep(i,n){
    ans += min(x[i],abs(x[i]-k))*2;
  }
  cout << ans << 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++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    n = n/3;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_c

"""
import sys
from sys import stdin
from collections import namedtuple
from math import ceil
input = stdin.readline


def solve(trains, N):
    arrives = []

    for i in range(N-1):
        arrives.append(0)
        for j in range(len(arrives)):
            t = arrives[j] - trains[i].S
            dt = max(trains[i].S, (trains[i].S + ceil(t/trains[i].F)*trains[i].F ))
            arrives[j] = dt + trains[i].C

    arrives.append(0)
    return arrives


T = namedtuple('T', ['C', 'S', 'F'])
def main(args):
    trains = []
    N = int(input())
    for _ in range(N-1):
        c, s, f = map(int, input().split())
        trains.append(T(c, s, f))
    ans = solve(trains, N)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(){
    int n, ary[(int)2e+5];
    cin >> n;
    vector<ll> cnt(n+1);
    rep(i, n){
        cin >> ary[i];
        cnt[ary[i]]++;
    }
    ll tmp = 0;
    rep(i, n+1){
        tmp += cnt[i] * (cnt[i]-1) / 2;
    }
    rep(i, n){
        ll ans = tmp;
        ll x = cnt[ary[i]];
        ans -= x * (x-1) / 2;
        ans += (x-1) * (x-2) / 2;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int A, B, M;
    cin >> A >> B >> M;
    int a[100000];
    int b[100000];
    int minA = 1000000;
    int minB = 1000000;
    for (int i = 0; i < A; i++)
    {
        cin >> a[i];
        if (a[i] < minA)
        {
            minA = a[i];
        }
    }
    for (int i = 0; i < B; i++)
    {
        cin >> b[i];

        if (b[i] < minB)
        {
            minB = b[i];
        }
    }

    res = minA + minB;
    for (int i = 0; i < M; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        res = min(res, a[x] + b[y] - c);
    }

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

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static final int MAXNUM = 1000000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] tetra = new int[200];
		int m = 0;
		for(int i=1;i<200;i++) {
			tetra[i] = i * (i+1) * (i+2) / 6;
			if (tetra[i] > MAXNUM) {
				m = i;
				break;
			}
		}
		int[] dp1 = new int[MAXNUM+1];
		int[] dp2 = new int[MAXNUM+1];
		Arrays.fill(dp1, Integer.MAX_VALUE);
		Arrays.fill(dp2, Integer.MAX_VALUE);
		dp1[0] = dp2[0] = 0;
		for(int i=1;i<=MAXNUM;i++) {
			for(int j=1;j<m;j++) {
				if (i - tetra[j] < 0) {
					break;
				}
				dp1[i] = Math.min(dp1[i],dp1[i-tetra[j]]+1);
				if ((tetra[j]&1)==1) {
					dp2[i] = Math.min(dp2[i],dp2[i-tetra[j]]+1);
				}
			}
		}
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			System.out.println(dp1[n] + " " + dp2[n]);
		}
	}

}

Measured memory_bytes: 29244
import heapq

N, M = map(int, input().split())
jobs = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    if a not in jobs.keys():
        jobs[a] = []
    jobs[a].append(b)

ans = 0
canditates = []
for a in range(1, M+1):
    if a in jobs.keys():
        for b in jobs[a]:
            heapq.heappush(canditates, -b)
    else:
        if not canditates:
            continue
    ans += heapq.heappop(canditates) * (-1)

print(ans)

Measured memory_bytes: 27344
n = int(input())
a = list(map(int, input().split()))
b = [0]
for i in range(n):
    b.append(b[i]+a[i])
b.sort()
cnt = 0
ans = 0
for i in range(n):
    if b[i] == b[i+1]:
        cnt += 1
    else:
        ans += cnt*(cnt+1)//2
        cnt = 0
ans += cnt*(cnt+1)//2
print(ans)


Measured memory_bytes: 27260
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <functional>

using namespace std;

#define F first
#define S second
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << ": "; for (auto& xxxx: a) cerr << xxxx << " "; cerr << endl;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
typedef long double dbl;
typedef long long ll;
const int N = -1;
const ll INF = 1.01e9;
typedef vector<int> vi;



int main(){
#ifdef HOME 
    assert(freopen("in", "r", stdin));
#endif
    ll a, b, c;
    cin >> a >> b >> c;
    set<vector<ll>> q; 

    int answer = 0;
    while (true) {
        if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            ll A = a / 2 + b / 2;
            ll B = a / 2 + c / 2;
            ll C = b / 2 + c / 2;
            a = A;
            b = B;
            c = C;
            vector<ll> tmp = {a, b, c};
            answer++;
            if (q.count(tmp)) {
                puts("-1");
                return 0;
            }
            q.insert(tmp);
        }
        else {
            break;

        }
    }

    cout << answer << endl;
    
    
#ifdef HOME 
    epr("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
#endif
    return 0;
}



Measured memory_bytes: 764
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"def s(s):\n"
"  f=[1]*-~n\n"
"  f[s]=0\n"
"  q=deque([(s,0)])\n"
"  while q:\n"
"    t,c=q.popleft()\n"
"    for v in e[t]:\n"
"      if f[v]:\n"
"        f[v]=0\n"
"        q.append((v,c+1))\n"
"  return t,c\n"
"n,*t=map(int,open(0).read().split())\n"
"e=[[]for _ in range(n+1)]\n"
"for a,b in zip(t[::2],t[1::2]):\n"
"  e[a].append(b)\n"
"  e[b].append(a)\n"
"print('SFeicrosntd'[s(s(1)[0])[1]%3!=1::2])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 61332
a = [list(map(int, input().split())) for _ in range(3)]
n=int(input())
l = [int(input()) for _ in range(n)] 

for i in range(3):
    for j in range(3):
        if a[i][j] in l:
            a[i][j]=0

if a[0][0]+a[0][1]+a[0][2]==0 or a[1][0]+a[1][1]+a[1][2]==0 or a[2][0]+a[2][1]+a[2][2]==0:
    print('Yes')
    exit()

if a[0][0]+a[1][0]+a[2][0]==0 or a[0][1]+a[1][1]+a[2][1]==0 or a[0][2]+a[1][2]+a[2][2]==0:
    print('Yes')    
    exit()

if a[0][0]+a[1][1]+a[2][2]==0 or a[0][2]+a[1][1]+a[2][0]==0 :
    print('Yes')    
    exit()

print('No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;}

int n;
const int maxn=100;
ll dp[maxn][4][4][4];
const ll MOD=1e9+7;

bool pro(ll a,ll b,ll c,ll d){
    if(a==0&&b==2&&c==1)return true;
    if(a==0&&b==1&&c==2)return true;
    if(a==2&&b==0&&c==1)return true;
    if(a==0&&c==2&&d==1)return true;
    if(a==0&&b==2&&d==1)return true;
    return false;
}

char p(ll a){
    if(a==0)return 'A';
    if(a==1)return 'C';
    if(a==2)return 'G';
    if(a==3)return 'T';
    return 'K';
}
int main(){
    cin >> n;
    REP(j,4)REP(k,4)REP(l,4)dp[2][j][k][l]=1;
    dp[2][0][2][1] = 0;
    dp[2][0][1][2] = 0;
    dp[2][2][0][1] = 0;
    
    FOR(i,3,n){
        REP(j,4){
            REP(k,4){
                REP(l,4){
                    REP(m,4){
                        if(pro(j,k,l,4))continue;
                        if(pro(k,l,m,4))continue;
                        if(pro(j,k,l,m))continue;
                        dp[i][k][l][m]+=dp[i-1][j][k][l];
                        dp[i][k][l][m]%=MOD;
                    }
                }
            }
        }
    }
    ll res = 0;
    REP(j,4){
        REP(k,4){
            REP(l,4){
                res+=dp[n-1][j][k][l];
                res%=MOD;
            }
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

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

    cout << "No" << endl;
    return 0;

}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define rep(i,a,b)  for( i=a;i<=b;i++)
#define re(i,a,b)  for( i=a;i>=b;i--)
#define pie  2 * acos(0.0)
using namespace std;
void solve();
int main()
{
	
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
 //cin >> T;
 while(T--)
 {solve();
}	 
}
void solve()
{
    string s,t;int i,f=0;
    cin>>s;
    cin>>t;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        f++;
    }
    cout<<f;
}


Measured memory_bytes: 3880
#include <iostream>
#include <string>
using namespace std;
int main(){
  char s[4];
  for(int i = 0; i < 4; i++){
    cin >> s[i];
  }
  for(int j = 0; j < 3; j++){
    if(s[j] == s[j+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

ll all[51], pat[51];

ll search(ll N, ll X) {
  if (all[N] == X) {
    return pat[N];
  }
  
  ll ans = 0;
  // 一枚目
  X--;

  // 下
  if (X > 0) {
    ll l = min(X, all[N - 1]);
    ans += search(N - 1, l);
    X -= l;
  }
  
  // 中
  if (X > 0) {
    X--;
    ans++;
  }
  
  // 上
  if (X > 0) {
    ll l = min(X, all[N - 1]);
    ans += search(N - 1, l);
    X -= l;
  }
  
  return ans;
}

int main() {
  ll N, X;
  cin >> N >> X;
  
  all[0] = 1;
  pat[0] = 1;
  for (int i = 1; i < 50; i++) {
    all[i] = all[i - 1] * 2 + 3;
    pat[i] = pat[i - 1] * 2 + 1;
  }
  
  cout << search(N, X) << endl;
  return 0;
}


Measured memory_bytes: 256
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    for j in range(i+1,n):
        cnt=0
        for k in range(d):
            cnt+=(x[i][k]-x[j][k])**2
        if (cnt**0.5).is_integer() and cnt!=0:
            ans+=1
print(ans) 

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


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

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int main() {
	int n; cin >> n;
	int p[30];

	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		vector<int> v;
		v.push_back(p[i]);
		v.push_back(p[i-1]);
		v.push_back(p[i+1]);
		sort(v.begin(), v.end());
		if (v[1] == p[i]) { ans++; }
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int s=0;
    int m=0;
    int h=0;
    scanf("%d",&s);
    if(s>=0&&s<86400){
        if(s>59) {
            m=(int)s/60;
            s=s%60;
            if(m>59){
                h=(int)m/60;
                m=m%60;
            }
        }
        
        printf("%d:%d:%d\n",h,m,s);
    }
    return 0;
}

Measured memory_bytes: 592
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int h, w;
string s[8];

int main(){
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  int x = 0, y = 0;
  while (s[x][y] == '#'){
    s[x][y] = '.';
    if (x + 1 < h && s[x + 1][y] == '#') x++;
    else if (y + 1 < w && s[x][y + 1] == '#') y++;
  }
  bool f = true;
  rep(i, h) rep(j, w) f &= s[i][j] == '.';
  cout << (f ? "Possible\n" : "Impossible\n");
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int A, B, C, D;    
            cin >> A >> B >> C >> D;
                if(A >= B && B >= C){
                    if(A -B <= D && B - C <= D){
                        cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                    }
                }else if(A >= C && C >= B){
                    if(A - C <= D){
                        cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                    }
                }else if(B >= A && A >= C){
                    if(A - C <= D){
                        cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                    }
                }else if(B >= C && C >= A){
                    if(C - A <= D){
                        cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                    }
                }else if(C >= A && A >= B){
                    if(C - A <= D){
                        cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                    }
                }else if(C >= B && B >= A){
                    if(C - B <= D && B - A <= D){
                        cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                    }
                }else{}
    return 0;}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(M)]
G = [[] for _ in range(N+1)]
for a,b in AB:  
  G[a].append(b)
  G[b].append(a)
color = [None]*(N+1)  
# 二部グラフ判定
def dfs(v, c):
  color[v] = c
  for e in G[v]:
    if color[e] == None:
      color[e] = 1 - color[v]
      dfs(e, c^1)
dfs(1, 0)      
bl = all(color[a] != color[b] for a, b in AB)      
# ans
if bl:
  # 二部グラフ
  x = sum(color[1:])
  y = N-x
  print(x*y-M)
else:
  # 完全グラフ
  print(N*(N-1)//2-M)

Measured memory_bytes: 55780
N, W = map(int, input().split(' '))

import collections
w_v_pairs = collections.defaultdict(list)
for _ in range(N):
    w, v = map(int, input().split(' '))
    w_v_pairs[w].append(v)


for w in w_v_pairs.keys():
    w_v_pairs[w].sort(reverse=True)

ans = 0
weights = list(w_v_pairs.keys())
buf = [(W, 0, 0)]
while len(buf) != 0:
    rest_w, i_weights, v = buf.pop()
    ans = max(ans, v)

    if i_weights < len(weights):
        buf.append((rest_w, i_weights + 1, v))

        w = weights[i_weights]
        values = w_v_pairs[w]
        j = 0
        while j < len(values):
            rest_w -= w
            if rest_w < 0:
                break
            else:
                v += values[j]
                buf.append((rest_w, i_weights+1, v))
                j += 1



# print(w_v_pairs)
print(ans)



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

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

  long double x;
  cin>>x;
  long double yy=100; 
  for(int i=1;i<100000;i++)
  {
    yy*=(1.01);
    yy=floor(yy);
    if(x<=yy)
    {
      cout<<i;
      return 0;
    }
  }
}

Measured memory_bytes: 3740
import fractions

n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))
if n>=2:
    ans=t[0]*t[1]//(fractions.gcd(t[0],t[1]))
    for i in range(2,n):
        ans=ans*t[i]//(fractions.gcd(ans,t[i]))
    print(ans)
else:
    print(t[0])


Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) {
    ll res = 1;    x = x % p;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y = y>>1;    x = (x*x) % p;
    } return res;
}

int main()
{
    Imposter

    ll x,y;
    cin>>x>>y;
    if(2*x<=y and y%2==0 and y<=4*x)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void solve()
{
   int l,r,d,m=1,ct=0;
   cin>>l>>r>>d;
   for (int i = 1; i <=r ; ++i)
   {
     m=i*d;
     if(m>=l&&m<=r)
      ct++;
   }
  cout<<ct;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Pranab
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {solve();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

   return 0;
}

Measured memory_bytes: 3772
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long lint;
const int N=1e5+2;
int n,hx[N];
lint dp[N][3];

template <class T> inline void apx(T &x,const T y){
	if(x<y) x=y;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("b.in","r",stdin);
#endif
	memset(dp,-3,sizeof(dp));
	n=nxi();
	hx[1]=nxi();
	for(int i=2;i<=n;++i){
		char c;
		while((c=getchar())!='+'&&c!='-');
		hx[i]=nxi();
		if(c=='-') hx[i]=-hx[i];
	}
	dp[0][0]=0;
	for(int i=0;i<n;++i){
		apx(dp[i][1],dp[i][2]);
		apx(dp[i][0],dp[i][1]);
		for(int j=0;j<=2;++j){
			if(dp[i][j]<-1e16) continue;
			const lint tp=dp[i][j]+(j&1?-hx[i+1]:hx[i+1]);
			apx(dp[i+1][j],tp);
			if(hx[i+1]<0&&j<2){
				apx(dp[i+1][j+1],tp);
			}
		}
	}
//	for(int i=0;i<=n;++i){
//		for(int j=0;j<3;++j){
//			printf("%lld ",dp[i][j]);
//		}
//		puts("");
//	}
	lint ans=-1e16;
	for(int i=0;i<3;++i){
		apx(ans,dp[n][i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    int N;
    cin >> N;
    for (int i = 0;i<11;i++){
        if (N <= i*1000) {
            cout << i*1000-N << endl;
            break;
        } 
    }
        
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

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

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,m,p;
    string s;
    cin >> n >> m;
    int ac=0,wa=0;
    vector<bool> AC(n,false);
    vector<int> WA(n,0);
    rep(i,m){
        cin >> p >> s;
        if(s=="WA") WA[p-1]++;
        if(s=="AC" && !AC[p-1]){
            //falseのとき
            ac++;
            AC[p-1]=true;
            wa+=WA[p-1];
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 640
N=map(int,input().split())
a=[int(x) for x in input().split()]
x=a[0]
y=sum(a[1:])
min=abs(x-y)
tmpmin=min
for i in range(1,len(a)-1):
    x+=a[i]
    y-=a[i]
    tmpmin=abs(x-y)
    if tmpmin<min:
        min=tmpmin
print(min)

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int n;

    std::cin >> n;

    ll ans = 0, prev = 0;

    rep(i, n)
    {
        ll a;
        std::cin >> a;
        if (a < prev)
            ans += prev - a;
        prev = std::max(a, prev);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == '?'){
            S.at(i) = 'D';
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3748
import java.util.*;

class Main{
    public static void main(String[] args) {       
         Scanner stdIn = new Scanner(System.in);
         char c[] = stdIn.next().toCharArray();
         String ans = "Yes";
         for(int i = 0; i < c.length; i++){
             if(c[i] == ((i+1) % 2 == 1 ? 'L' : 'R')){
                ans = "No";
                break;
             }
         }
         System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;



int main()
{

    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string ans="";
    for(ll i=0; i<n; i++)
    {
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans<<nn;




}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    vector<int> tmp = A;
    sort(tmp.begin()+1, tmp.end(), greater<int>());
    for(int i = 1; i <= N; ++i){
        if(tmp[1] == A[i]) cout << tmp[2] << endl;
        else cout << tmp[1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4704
#include <iostream>
#include <stdlib.h>
#include <string.h>

using namespace std;

int prime(long n);

int main()
{
    long n;
    cin>>n;
    /*if(n==2 || n==3)
    {
        cout<<n;
        return 0;
    }*/
    while(1)
    {
        if(prime(n))
        {
            cout<<n;
            break;
        }
        else
        {
            if(n%2)
        {
            n+=2;
        }
        else
            n++;
        }
    }

    return 0;
}
int prime(long n)
{
    long i;
    int flag=1;
    for(i=2;i<=(n/2);i++)
    {
        if(!(n%i))
        {
            flag=0;
            break;
        }
    }
    return flag;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; ++i) {
    int score = i;
    int cnt = 0;
    while (score <= k - 1) {
      score *= 2;
      cnt++;
    }
    int d = 1;
    for (int j = 0; j < cnt; ++j) {
      d *= 2;
    }
    ans += (1.0 / (double)n) * (1.0 / (double)d);
  }
  printf("%.20f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define FOR(i, l, r) for(int i = (l); i <= (r); i++)
#define REP(i, l, r) for(int i = (l); i != (r); i++)
#define DFR(i, l, r) for(int i = (l); i >= (r); i--)
#define DRP(i, l, r) for(int i = (l); i != (r); i--)

using namespace std;

#define DEBUG(arg...) fprintf(stderr, arg)

namespace FI {
    const int SIZE = 1 << 18 | 1;
    char buf[SIZE], *front, *back;

    void Char(char &c) {
	if(front == back) back = (front = buf) + fread(buf, 1, SIZE, stdin);
	c = (front == back) ? (char)EOF : *front++;
    }

    template<typename T> void Num(T & x) {
	char c; int f = 1;
	for(Char(c); c > '9' || c < '0'; Char(c)) if(c == '-') f = -1;
	for(x = 0; c >= '0' && c <= '9'; Char(c)) x = (x << 3) + (x << 1) + c - '0';
	x *= f;
    }
}

typedef long long LL;
const int maxn = 100000 + 47;
const int mod = 1e9 + 7;

int n, ans = 1, num[100];
char str[maxn];

int main() {
    scanf("%d%s", &n, str + 1);
    FOR(i, 1, n) num[str[i] - 'a']++;
    REP(i, 0, 26) ans = 1LL * ans * (num[i] + 1) % mod;
    printf("%d\n", (ans - 1 + mod) % mod);
}


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

using namespace std;

const int INF = 1e9 + 5;

int main(){

  int N, K;

  cin >> N >> K;

  int h[N];
  vector <int> dp(N,INF); //guarda o menor custo para chegar na pedra i

  for(int i=0;i<N;i++)
    cin >> h[i];

  dp[0] = 0;

   for(int i=0;i<N;i++){
     for(int j=i+1;j<=i+K;j++){
       if(j < N){
         dp[j] = min(dp[j],dp[i] + abs(h[i]-h[j]));
       }
     }
   }

   cout << dp[N-1] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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 (a>b) { a=b; return 1; } return 0; }



int main() {
    int N; cin>>N;
    vector<int> A(N),B(N);
    vector<int> diff(N);
    ll need=0ll;
    int cnt=0;

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

    for (int i = 0; i < N; ++i) {
        cin>>B[i];
        diff[i]=A[i]-B[i];
        if(diff[i]<0) ++cnt;
        need-=min(0ll,(ll)diff[i]);
    }

    sort(diff.rbegin(),diff.rend());
    int ans=0;
    while(need>0ll){
        if(diff[ans]<0){
            cout<<-1<<endl;
            return 0;
        }
        need-=(ll)diff[ans];
        ++ans;
    }

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


Measured memory_bytes: 1408
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int H = Integer.parseInt(S[0]);
    int W = Integer.parseInt(S[1]);
    char[][] pic = new char[H+2][W+2];
    String T = "";
    for(int i = 0; i < H+2; i++){
      if(!(i == 0 || i == H+1)){
        T = sc.nextLine();
      }
      for(int j = 0; j < W+2; j++){
        if(j == W+1){
          System.out.println("#");
        }else if(i == 0 || i == H+1 || j == 0){
          System.out.print("#");
        }else{
          System.out.print(T.charAt(j-1));
        }
      }
    }
  }
}

Measured memory_bytes: 25220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

vector<vector<int>> graph;
vector<int> ans(200010);

void dfs(int n, int p) {
	if (p != -1) ans[n] += ans[p];
	for (int i : graph[n]) {
		if (i != p) dfs(i, n);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	
	int n, q;
	cin >> n >> q;
	graph.resize(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0, -1);
	rep(i, n) cout << ans[i] << ' ';
	cout << '\n';
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
#ifdef kvutxdy
    freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/test/input.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H, N;
    cin >> H >> N;
    ll sum = 0LL;
    for (int i = 0; i < N; ++i) {
        ll x;
        cin >> x;
        sum += x;
    }
    cout << (sum >= H ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256