akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

getMin [] _ = Nothing
getMin _ [] = Nothing
getMin ee@(e:es) oo@(o:os) 
  | e == o = do
    let a = getMin ee os
    let b = getMin es oo
    if all isNothing [a, b] then Nothing 
    else if all isJust [a,b] then minimum <$> sequence [a, b]
    else head $ filter isJust [a, b]
  | True = Just . foldr1 (+) $ map snd [e, o]
main = do
  l <- getI
  inps <- getIs
  let len = div l 2
  let [em, om] = map (M.toList >>> sortOn snd) $ makeEO len [M.empty, M.empty] inps :: [[(Int, Int)]]
  putStrLn . show . maybe len id $ getMin em om
  where
    mapInit len Nothing = Just $ len - 1 
    mapInit len (Just a) = Just $ a - 1
    makeEO _ now [] = now
    makeEO len [e, o] (x:y:xs) = makeEO len [M.alter (mapInit len) x e, M.alter (mapInit len) y o] xs


Measured memory_bytes: 50556
#include <algorithm>
#include <iostream>
using namespace std;
 
int main(void) {
  int n, k;
  cin >> n, cin >> k;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i]; 
  }
  
  sort(p,p+n);
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];   
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
using System;
class Program
{
    static void Main(string[] args)
    {
        int k = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        if (s.Length <= k)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine(s.Substring(0, k) + "...");
        }
    }
}


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

N = int(input())
H = list(map(int, input().split()))

dp = [float('inf') for _ in range(N+1)]
dp[1] = 0
dp[2] = abs(H[0]-H[1])

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

print(dp[N])


Measured memory_bytes: 20708
#include<stdio.h>
#include<string.h>

char list[100][11], p = 0; 
int check(char*s){
  int i;
  for (i = 0; i < p; i++){
    if(strcmp(s, list[i]) == 0){
      return 0;
    }
  }
  strcpy(list[p++], s);
  return 1;
}

int main(){
  int N, len, flag = 1;
  char W[100][11];
  
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%s", W[i]);
    if(i > 0){
      if(W[i][0] != W[i - 1][len - 1]){
        flag = 0;
      }
    }
    len = strlen(W[i]);
    if(check(W[i]) == 0){
      flag = 0;
    }
  }
  
  if(flag == 1){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

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


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

  int num;
  for(int i = 0;i <= S.size()-8;i++) {
    if(S.substr(i,8) == "FESTIVAL") num = i;
  }
  
  for(int i = 0;i < num;i++) {
    cout << S.at(i);
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = 0
y = 0

for i in range(n-1):
    if a[i+1] - a[i] == 1:
        y = a[i]
        x += c[y-1]

print(x+sum(b))

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

int main(){
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  
  int ans = max({a1, a2, a3}) - min({a1, a2, a3});
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php
  list($n, $t) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $min = [];
  $min[0] = $a[0];
  $maxsa = 0;
  $cnt = 0;
  for ($i=1; $i<$n; $i++) {
    $sa = $a[$i]-$min[$i-1];
    if($maxsa < $sa){
      $maxsa = $sa;
      $cnt = 1;
    }
    else if($maxsa == $sa){
      $cnt++;
    }
//    echo $a[$i]." ".$min[$i-1]." ".$sa." ".$maxsa.PHP_EOL;
    $min[$i] = min($a[$i], $min[$i-1]);
  }

  echo $cnt;

Measured memory_bytes: 27964
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
string str[n];
for(int i=0;i<n;i++)
    cin>>str[i];
int mod=pow(10,9)+7;
int dp[n+1][m+1]={};
dp[0][1]=1;
for(int i=1;i<=n;i++)
{
    for(int j=1;j<=m;j++)
    {
        if(str[i-1][j-1]=='.')
        {
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
}
int ans=dp[n][m];
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9088
import sys
input = sys.stdin.readline

N, A = [int(x) for x in input().split()]
x = [int(x) - A for x in input().split()]

dp = [[0] * 5001 for _ in range(N + 1)]
dp[0][0 + 2500] = 1

for i in range(1, N + 1):
    for j in range(-2500, 2501):
        if 5000 >= j + 2500 - x[i - 1] >= 0:
            dp[i][j + 2500] = dp[i - 1][j + 2500 - x[i - 1]] + dp[i - 1][j + 2500]
        else:
            dp[i][j + 2500] = dp[i - 1][j + 2500]

print(dp[N][0 + 2500] - 1)

Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef string::iterator State;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;


bool checker(bool a, bool b, bool c, bool d, State &itr) {
    //cerr << *itr << endl;
    if(*itr == '0') {
        itr++;
        return false;
    }
    if(*itr == '1') {
        itr++;
        return true;
    }
    if(*itr == 'a') {
        itr++;
        return a;
    }
    if(*itr == 'b') {
        itr++;
        return b;
    }
    if(*itr == 'c') {
        itr++;
        return c;
    }
    if(*itr == 'd') {
        itr++;
        return d;
    }
    if(*itr == '-') {
        itr++;
        return !checker(a, b, c, d, itr);
    }
    if(*itr == '(') {
        itr++;
        bool l = checker(a, b, c, d, itr);
        char ope = *itr;
        itr++;
        bool r = checker(a, b, c, d, itr);
        itr++;
        if(ope == '^') return r ^ l;
        else return r and l;
    }
}

vector<string> eq[17];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    eq[1].push_back("0");
    eq[1].push_back("1");
    eq[1].push_back("a");
    eq[1].push_back("b");
    eq[1].push_back("c");
    eq[1].push_back("d");
    for(int now = 2; now <= 16; now++) {
        for(int j = 0; j < eq[now-1].size(); j++) {
            if(eq[now-1][j][0] == '-') continue;
            eq[now].push_back("-" + eq[now-1][j]);
        }
        for(int l = 1; l <= now - 4; l++) {
            int r = now - l - 3;
            for(int i = 0; i < eq[l].size(); i++) {
                for(int j = 0; j < eq[r].size(); j++) {
                    eq[now].push_back("(" + eq[l][i] + "*" + eq[r][j] + ")");
                    eq[now].push_back("(" + eq[l][i] + "^" + eq[r][j] + ")");
                }
            }
        }
    }
    while(true) {
        string S;
        cin >> S;
        if(S == ".") break;
        bool nowbool[17];
        for(int i = 0; i < 16; i++) {
            auto itr = S.begin();
            nowbool[i] = checker(i&1, i&2,i&4,i&8,itr);
        }
        int ans = 0;
        while(true) {
            ans++;
            bool clear = false;
            for(int i = 0; i < eq[ans].size(); i++) {
                bool nowclear = true;
                for(int j = 0; j < 16; j++) {
                    auto itr = eq[ans][i].begin();
                    if(nowbool[j] != checker(j&1, j&2, j&4, j&8, itr)) {
                        nowclear = false;
                        break;
                    }
                }
                if(nowclear) {
                    clear = true;
                    break;
                }
            }
            if(clear) break;
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s, t;
    cin >> s >> t;
    string p = "";
    for(int i=0;i<s.size();i++){
        p += t[i];
    }
    if(p==s){
        cout << "Yes\n";
    }
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3660
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

int main()
{
	lolo A, B;
	cin >> A >> B;
	if (A >= 13) cout << B << endl;
	else if (A >= 6) cout << B / 2 << endl;
	else cout << 0 << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AApplePie {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a,p;in>>a>>p;
	    out<<(a*3+p)/2<<endl;

	}
};


int main() {
	AApplePie solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	while(cin>>n,n){
	    int total=0;
		vi b(n);
		vector<vector<pii>> edge(n);
		range(i,1,n) {cin>>b[i];b[i]--;}
		range(i,1,n) {
		    int c; cin>>c; total+=c;
		    edge[i].emplace_back(b[i],c);
		    edge[b[i]].emplace_back(i,c);
		}

		int s,g;
		vi cost(n,1);
		priority_queue<pair<int,int>> q;
		q.emplace(0,0);
		while(!q.empty()){
		    int p,c; tie(c,p)=q.top(); q.pop();
		    if(cost[p]!=1)  continue;
		    cost[p]=c;
		    s=p;
		    for(auto e:edge[p]) if(edge[e.first].size()!=1){
		        if(cost[e.first]==1)q.emplace(c-e.second,e.first);
		    }
		}
		fill(all(cost),1);
		q.emplace(0,s);
		while(!q.empty()){
		    int p,c; tie(c,p)=q.top(); q.pop();
		    if(cost[p]!=1)  continue;
		    cost[p]=c;
		    g=p;
		    for(auto e:edge[p]) if(edge[e.first].size()!=1){
		        if(cost[e.first]==1)q.emplace(c-e.second,e.first);
		    }
		}
		
		int ans=total;
		rep(i,n){
		    if(edge[i].size()==1)ans-=edge[i][0].second;
		}
		cout<<ans*2+total+cost[g]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3140
from math import gcd
from functools import reduce


def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 1
    histogram = [0] * MAX_A
    for x in array:
        histogram[int(x)] += 1

    for divider in range(2, MAX_A):
        count = sum(histogram[divider::divider])
        if count > 1:
            break
    else:
        return 'pairwise coprime'

    gcd_total = reduce(gcd, array)
    if gcd_total == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 133416
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];
        int count = 0;

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            if (h[i] >= K) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 47720
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
const ll mod2= 998244353;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }



int main(){
    ll n,k,ans=0;
    cin>>n;
    rep(i,0,n)cout<<"ACL";
   
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int n, m;
vector<string> a;
vector<string> b;
bool matching(int tate, int yoko) {
  bool ret = true;
  REP(i, m) {
    REP(j, m) {
      if (a[tate + i][yoko + j] != b[i][j]) {
        ret = false;
        break;
      }
    }
  }

  return ret;
}

int main() {
  cin >> n >> m;
  REP(i, n) {
    string s;
    cin >> s;
    a.push_back(s);
  }
  REP(i, m) {
    string s;
    cin >> s;
    b.push_back(s);
  }

  string ans = "No";

  REP(i, n - m + 1) {
    REP(j, n - m + 1) {
      if (matching(i, j)) {
        ans = "Yes";
        break;
      }
    }
    if (ans == "Yes") {
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    map<char, int> m;
    string a,b,c;
    cin>>a;
    for(char c:a) {
    	m[c] = 1;
    }
    for(int i = 0; i < 26; ++i) {
    	if(m[(char) ('a'+i)]!=1) {
    		cout<<a<<(char) ('a'+i)<<endl;
    		return 0;
    	}
    }
    c = a;
    b = a;
    sort(b.begin(), b.end());
    next_permutation(a.begin(), a.end());
    string temp = a;
    while(a>c) {
    	temp = a;
    	a.pop_back();
    	//cout<<a<<endl;
    }
    if(temp > c) {
    	cout<<temp<<endl;
    	return 0;
    }
    if(a==b) {
    	cout<<-1<<endl;
    	return 0;
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N, M;
    scan(N, M);

    vector<pair<int, char>> x(M);
    for (auto &&i : x) {
        int a;
        scan(a, i.second);
        i.first = a - 1;
    }

    for (size_t i = 0; i < 1000; i++) {
        string s = std::to_string(i);
        bool f   = true;
        for (auto &&i : x) {
            if (N <= i.first) {
                f = false;
            }
            if (s[i.first] != i.second) {
                f = false;
            }
        }
        if (f && (int)s.size() == N) {
            print(i);
            exit(0);
        }
    }
    print(-1);

    return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W = map(int,input().split())
Grid = [list(input()) for _ in range(H)]
lis = [[0]*W for _ in range(H)]
lis[0][0] = 1
M = 10**9+7

for i in range(H):
    for j in range(W):
        if i != H-1 and Grid[i+1][j] == ".":
            lis[i+1][j] += lis[i][j]%M
        if j != W-1 and Grid[i][j+1] == ".":
            lis[i][j+1] += lis[i][j]%M

print(lis[H-1][W-1] % M)


Measured memory_bytes: 88944
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef vector<int>V;
int MIN[55],idx,sum,idx2,ans;
int n,m,a[55][55];
vector<int> dp[55];
int count(vector<int> &a){
  int cnt = 0;
  int n = a.size();
  for(int i=0;i<n-1;i++){
    if(a[i] != a[i+1]) cnt++;
  }
  return cnt;
}

V chmin(V &a,V b){
  if(count(a) != count(b)) return a = count(a) < count(b)? a:b;
  int n =min(a.size(),b.size());
  for(int i=0;i<n;i++) if(a[i]!=b[i]) return a = a[i]<b[i]? a:b;
  return a;
}

/*int chmin(PV &a, PV b){
  if(a.first != b.first) {
    int res = a.first > b.first;
    a = a.first < b.first? a:b;
    return res;
  }
  
  if(count(a.second) != count(b.second)){
    int res = count(a.second) > count(b.second);
    a = count(a.second) < count(b.second)? a:b;
    return  res;
  }
  
  int n = a.second.size();
  for(int i=0;i<n;i++){
    if(a.second[i] != b.second[i]){
      int res = a.second[i] > b.second[i];
      a = a.second[i] < b.second[i]? a:b;
      return res;
    }
  }
  return 0;
  }*/
int main(){
  r(i,54){
    r(j,55)dp[i+1].push_back(j);
  }
  r(i,55)MIN[i]=1e8;
  cin>>n>>m;
  r(i,n){
    r(j,m){
      cin>>a[i][j];
      MIN[j]=min(MIN[j],a[i][j]);
    }
  }
  r(i,m)ans+=MIN[i];
  r(o,55){
  r(i,n){
    r(j,m){
      int pre=j;
      while(j<m&&MIN[j]==a[i][j])j++;
      for(int k=pre;k<j;k++){
	V v=dp[k];
	for(int l=k+1;l<=j;l++){
	  v.push_back(i);
	  chmin(dp[l],v);
	}
      }
      //if(pre!=j)while(pre<j)dp[pre][j]=max(dp[pre][j],-i),pre++;
    }
  }}
  
  cout<<ans<<' '<<count(dp[m])<<endl;
  r(i,m){
    cout<<dp[m][i]+1<<endl;
  }
}



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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0; i<H; i++){
    cin >> S.at(i);
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S.at(i).at(j)=='#'){
        int p=0;
        if(i!=0){
          if(S.at(i-1).at(j)=='#'){
            p=1;
          }
        }
        if(i!=H-1){
          if(S.at(i+1).at(j)=='#'){
            p=1;
          }
        }
        if(j!=0){
          if(S.at(i).at(j-1)=='#'){
            p=1;
          }
        }
        if(j!=W-1){
          if(S.at(i).at(j+1)=='#'){
            p=1;
          }
        }
        if(p==0){
          cout << "No" << endl;
          goto finish;
        }
      }
    }
  }
  cout << "Yes" << endl;
finish: H=0;
}

Measured memory_bytes: 256
N = int(input())
Hlist = [int(i) for i in input().split()]
currentstep = 0
maxstep = 0
prevvalue = 0
for H in Hlist:
    if H <= prevvalue:
        currentstep += 1
        if maxstep <= currentstep:
            maxstep = currentstep
    else:
        currentstep = 0
    prevvalue = H

print(maxstep)



Measured memory_bytes: 14252
n,m,k=map(int,input().split())
als=list(map(int,input().split()))
bls=list(map(int,input().split()))

mx_a=0
c=0
ai = 0
for i,a in enumerate(als):
    if mx_a+a<=k:
        mx_a+=a
        c+=1
    else:
        break
    ai+=1

available_als=als[:ai]
available_als.reverse()

k -= mx_a
bi=0
for i,b in enumerate(bls):
    if b<=k:
        k-=b
        c+=1
    else:
        bi = i
        break

max_c=c
for a in available_als:
    c-=1
    k+=a
    while True:
        try:
            b = bls[bi]
            if b<=k:
                c+=1
                k-=b
                bi+=1
            else:
                if c>max_c:
                    max_c=c
                break
        except:
            if c>max_c:
                max_c=c
            break
print(max_c)


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f(i,n) for(ll i=0;i<n;i++)
#define fi(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF LLONG_MAX
#define ALL(a) a.begin(),a.end()
#define MAX 200005

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    f(i,n)cin>>a[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    fi(i,2,n)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    //f(i,n)cout<<dp[i]<<' ';
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
import Text.Printf

sd :: [Double] -> Double
sd nums = abs $ sqrt sigma2
  where
    n      = fromIntegral $ length nums :: Double
    ave    = (sum nums) / n
    sigma2 = (sum $ map (\s -> (s - ave)^^2) nums) / n

main :: IO ()
main = do
    n <- getLine
    if n == "0"
        then
            return ()
        else do
            nums <- getLine >>= return . map (\x -> read x :: Double) . words
            printf "%.5f\n" $ sd nums
            main



Measured memory_bytes: 5092
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int a[1000];
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++)cin >> a[i];
		sort(a, n);
		int ans = inf;
		for (int i = 1; i < n; i++) {
			ans = min(ans, a[i] - a[i - 1]);
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const ld    pi  = acos(-1);

typedef pair<int,int>   ii;

ld  t[N];

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

    cout << fixed << setprecision(10);

    int n;  cin >> n;
    int L;  cin >> L;

    for(int i = 0 ; i < n ; ++i)    {
        int x;  cin >> x;

        t[i] = 1.0 * x / L;
    }
    ld  ansx = 0;
    ld  ansy = 0;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 1 ; j < n ; ++j)    {
        ld  Ratio = t[i] + t[(i + j) % n];

        if (i + j >= n)
            Ratio += 1;

        ld  x = cos(pi * Ratio);
        ld  y = sin(pi * Ratio);

        ansx += x * (n - j - 1);
        ansy += y * (n - j - 1);
    }
    for(int i = 0 ; i < 3 ; ++i)
        ansx /= (n - i),
        ansy /= (n - i);

    cout << ansx * 6 << " ";
    cout << ansy * 6 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5 + 7);
const int nAlpha = 'z' - 'a' + 1;
const int mod = int(1e9 + 7);

unordered_map<int, int> minf;
int f, sumxor, n;
string s;

int Get(int x) {
    if(minf.count(x)) return minf[x];
    return N;
}

void Update(int x, int f) {
    if(minf.count(x)) minf[x] = min(minf[x], f);
    else minf[x] = f;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> s; n = int(s.size());
    s = ' ' + s; minf[0] = 0;
    for(int i = 1; i <= n; ++i) {
        s[i] -= 'a';
        sumxor ^= (1 << s[i]);
        f = min(Get(sumxor) + 1, f + 1);
        for(int j = 0; j < nAlpha; ++j) f = min(f, Get(sumxor ^ (1 << j)) + 1);
        Update(sumxor, f);
    }
    cout << f;
}


Measured memory_bytes: 8716
n,m = (int(x) for x in input().split())
k = [0]*n
a = []
for i in range(n):
    tmp =  input().split()
    k[i] = int(tmp.pop(0))
    a.append(tmp)
# ここまで入力

# 以下　何人が各種類を好物としているのか配列に入れてカウント
species = [0]*m
for i in range(n):
    for j in range(k[i]):
        species[int(a[i][j])-1] += 1

ans = 0
# 好みとした人がn人ならば答えのカウントを増やす
for i in species:
    if i == n:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, M = LI()
uv = LIR(M)
S, T = LI()
S, T = S-1, T-1

utov = [[] for i in range(N)]

for u, v in uv:
    utov[u-1].append(v-1)


ken1 = deque()
ken2 = deque()
pa = deque()

ken1_used = [False]*N
ken2_used = [False]*N
pa_used = [False]*N

pa.append(S)
pa_used[S] = True

ans = -1

while ken1 or ken2 or pa:
    ans += 1

    while ken1:
        u = ken1.popleft()
        for v in utov[u]:
            if (not ken2_used[v]):
                ken2_used[v] = True
                ken2.append(v)

    while ken2:
        u = ken2.popleft()
        for v in utov[u]:
            if (not pa_used[v]):
                if (v==T):
                    print(ans)
                    quit()
                pa_used[v] = True
                pa.append(v)    

    while pa:
        u = pa.popleft()
        for v in utov[u]:
            if (not ken1_used[v]):
                ken1_used[v] = True
                ken1.append(v)

print(-1)




"""
kenken = []

def bfs(s):
    ret = []
    bfs_map = [-1]*N
    q = deque()
    q.append(s)
    bfs_map[s] = 0
    while q:
        u = q.popleft()
        for v in utov[u]:
            if (edge[u][v] > 0) and (bfs_map[u] > bfs_map[v]):
                bfs_map[v] = bfs_map[u] + 1
                if (bfs_map[v] == 3):
                    ret.append(v)
                else:
                    q.append(v)
    return ret

for i in range(N):
    ret = bfs(i)
    kenken.append(ret)

kenkenedge = [[0]*N for i in range(N)]
for u, vs in enumerate(kenken):
    for v in vs:
        kenkenedge[u][v] = 1

def bfs_dist(S, T):
    bfs_map = [-1]*N
    q = deque()
    q.append(S)
    bfs_map[S] = 0
    while q:
        u = q.popleft()
        for v in kenken[u]:
            if (kenkenedge[u][v] > 0) and (bfs_map[u] > bfs_map[v]):
                bfs_map[v] = bfs_map[u] + 1
                if (v==T):
                    return bfs_map[T]
                else:
                    q.append(v)
    return -1

print(bfs_dist(S, T))
"""

Measured memory_bytes: 40856
n,k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)+[0]
a = [10**18]*(n+2)
a[0] = 0

(n-1).times{|i|
  1.upto(k){|j|
    a[i+j] = a[i]+(h[i]-h[i+j]).abs if i+j < n && a[i+j] > a[i]+(h[i]-h[i+j]).abs
  }
}

p a[n-1]

Measured memory_bytes: 9612
#include <iostream>

using namespace std;

int main(void)
{
    int N, M;
    int k[11];
    int s[11][11];
    int p[11];
    int way[11];
    int wayNum = 0;
    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
        {
            cin >> s[i][j];
        }
    }

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

    for (int bit = 0; bit < (1 << N); bit++)
    {
        for (int j = 0; j < N; j++)
        {
            way[j] = 0;
        }

        for (int j = 0; j < N; j++)
        {
            if (bit & (1 << j))
            {
                way[j] = 1;
            }
        }

        bool allOn = true;
        for (int w = 0; w < M; w++)
        {
            int switchSum = 0;
            for (int o = 0; o < k[w]; o++)
            {
                if (way[s[w][o]-1] == 1)
                    switchSum++;
            }
            if(switchSum%2!=p[w])
            {
                allOn=false;
                break;
            }
        }

        if(allOn)wayNum++;
    }

    cout << wayNum << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s = sc.next();
        char[] alpha = {'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'};        
        char[] c = new char[s.length()];
        
        for(int i=0; i<s.length(); i++){
            c[i] = s.charAt(i);
            int flg = 0;
            
            for(int j=0; j<26; j++){
                if(c[i]==alpha[j] && flg==0){
                    if(j+n<26){
                        //System.out.print(c[i]);
                        c[i] = alpha[j+n];
                    }else if(j+n>=26){
                        //System.out.print(c[i]);
                        c[i] = alpha[j+n-26];
                    }
                    flg=1;
                }
            }
            System.out.print(c[i]);
        }
        
        //System.out.println();
    }
}

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

const int maxn = 2 * 1e5 + 10;
int a[maxn];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	vector<int> nums;
	for (int i = n; i >= 1; i -= 2) {
		nums.push_back(a[i]);
	}
	for (int i = n % 2 == 0 ? 1 : 2; i <= n; i += 2) {
		nums.push_back(a[i]);
	}
	for (int i = 0; i < nums.size(); i++) {
		if (i > 0) cout << " ";
		cout << nums[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <random>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#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


using namespace std;

#ifdef LOCAL
static struct __timestamper {
    string what;
    __timestamper(const char* what) : what(what){};
    __timestamper(const string& what) : what(what){};
    ~__timestamper(){
        TIMESTAMPf("%s", what.data());
    }
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double dbl;

int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    while (cin >> n) {
        vector<pair<int, int>> v;

        for (int i = 0; i < n; i++) {
            double d;
            cin >> d;
            ll a = d;
            ll b = (d - a) * 1e9 + 0.5;
            // (a*1e9+b)/1e9
            ll x = a * (ll)1e9 + b;
            int p2 = 0, p5 = 0;
            while (x % 2 == 0) x /= 2, p2++;
            while (x % 5 == 0) x /= 5, p5++;
            p2 -= 9;
            p5 -= 9;
            v.emplace_back(p2, p5);
        }
        map<pair<int, int>, int> mp;
        for (auto o : v) mp[o]++;

        vector<pair<pair<int, int>, int>> vct;
        for (auto it : mp) vct.emplace_back(it);

        ll ans = 0;
        for (int i = 0; i < (int)vct.size(); i++) {
            if (vct[i].first.first >= 0 && vct[i].first.second >= 0) {
                ans += 1LL * vct[i].second * (vct[i].second - 1) / 2;
            }
            for (int j = i + 1; j < (int)vct.size(); j++) {
                if (vct[i].first.first + vct[j].first.first >= 0 &&
                vct[i].first.second + vct[j].first.second >= 0) {
                    ans += 1LL * vct[i].second * vct[j].second;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 5400
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin >> n;
	int d[n];
	for(int i = 0; i < n; i++) cin >> d[i];
	int flg = 1, cnt = 0;
	while(flg){
		flg = 0;
		for(int i = n - 1; i > 0; i--){
			if(d[i] < d[i - 1]){
				swap(d[i], d[i - 1]);
				cnt++;
				flg = 1;
			}
		}
	}
	for(int i = 0; i < n - 1; i++) cout << d[i] << ' ';
	cout << d[n - 1] << endl;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin() (a).end()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

template<class T = int>
T in() { T x; cin >> x; return x; }

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a[5], k;
  for (int i = 0; i < 5; i++) {
    a[i] = in();
  }
  k = in();
  if (a[4] - a[0] > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    cout << (1800 * M + 100 * N) * pow(2, M) << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b){
	    printf("a < b\n");
    }
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
}

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

class dice
{
	public:
		int face[6];
		void rotate(char c);
		void rotw();
		void rots();
		void rotn();
		void rote();
};

void dice::rotate(char c){
	     if(c=='S') rots();
	else if(c=='W') rotw();
	else if(c=='E') rote();
	else if(c=='N') rotn();
}

void dice::rotw(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[2]; t[2] = face[5]; t[3] = face[0]; t[5] = face[3];
	for(int i=0;i<6;i++) face[i] = t[i];
}
void dice::rots(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[4]; t[1] = face[0]; t[4] = face[5]; t[5] = face[1];
	for(int i=0;i<6;i++) face[i] = t[i];
}
void dice::rotn(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[1]; t[1] = face[5]; t[4] = face[0]; t[5] = face[4];
	for(int i=0;i<6;i++) face[i] = t[i];
}
void dice::rote(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[3]; t[2] = face[0]; t[3] = face[5]; t[5] = face[2];
	for(int i=0;i<6;i++) face[i] = t[i];
}

bool check(dice d,dice e){
	dice f;
	for(int i=0;i<6;i++) cin >> d.face[i];
	for(int i=0;i<6;i++) cin >> e.face[i];
	for(int i=0;i<6;i++){
		for(int j=0;j<4;j++){
			f = d;
			     if(i==1) f.rotn();
			else if(i==2) f.rotw();
			else if(i==3) f.rote();
			else if(i==4) f.rots();
			else if(i==5) {f.rotw();f.rotw();}
			f.rotn();
			for(int k=0;k<j;k++) f.rotw();
			f.rots();
			int x = 0;
			for(int k=0;k<6;k++) if(f.face[k]==e.face[k]) x++;
			if(x==6) return true;
		}
	}
	return false;
}

int main(){
	int n;
	cin >> n;
	dice a[n];
	for(int i=0;i<n;i++){
		for(int j=0;j<6;j++) cin >> a[i].face[j];
	}
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(check(a[i],a[j])){ cout << "No" << endl; return 0; }
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,a,m,r,temp;
	
	scanf("%d%d",&h,&a);
	m=0;
	if(h<=0)
	{
		printf("%d\n",h);
	}
	else
	{
		while(h>0){
		
		h=h-a;
		m++;
	}
	}
	
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
a={}
if m>n:
  print('NO')
else:
  for i in range(n):
    if d[i] not in a:
      a[d[i]]=1
    else:
      a[d[i]]+=1
  for i in range(m):
    if t[i] in a:
      a[t[i]]-=1
      if a[t[i]]==0:
        del a[t[i]]
    else:
      print('NO')
      exit()
  print('YES')

Measured memory_bytes: 41816
#include <iostream>

int main(int argc, char**argv)
{
    int a = 0;
    std::cin >> a;
    int b = 0;
    std::cin >> b;
    int t = 0;
    std::cin >> t;

    int count = 0;
    while (t + 0.5 > a) {
        t -= a;
        count += b;
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private int n;
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		Main main = new Main();
		main.n = main.sc.nextInt();
		main.print();
	}
	public void print() {
		print(0);
	}
	private void print(int i) {
		if (i != n) {
			int a = sc.nextInt();
			print(i + 1);
			System.out.print(i == 0 ? a + "\n" : a + " ");
		}
	}
}


Measured memory_bytes: 26400
from fractions import gcd
 
N = int(input())
A = list(map(int, input().split()))
 
L = [0] * (N+1)
R = [0] * (N+1)
 
L[0] = 0
R[-1] = 0
 
for i in range(len(A)):
    L[i] = gcd(L[i-1], A[i])
    
for i in reversed(range(len(A))):
    R[i] = gcd(R[i+1], A[i])
    
ans = 0    
 
for i in range(N):
    ans = max(ans, gcd(L[i-1], R[i+1]))
    
print(ans)

Measured memory_bytes: 16144
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    var state = -1
    val up = 0
    val down = 1
    var c = -1L
    var count = 1
    a.forEach {
        when {
            c == -1L -> {
                c = it
            }
            state == -1 -> {
                if (c > it) {
                    state = down
                } else if (c < it) {
                    state = up
                }
                c = it
            }
            else -> {
                if (state == up && c > it) {
                    state = -1
                    count++
                } else if (state == down && c < it) {
                    state = -1
                    count++
                }
                c = it
            }
        }
    }
    println(count.toString())
}

Measured memory_bytes: 53792
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[200005]={},cnt=0,b[200005]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[i]=a[i];
    cnt+=a[i];
  }
  sort(a,a+n);
  for(int i=0; i<n; i++) {
    if(b[i]==a[n-1]) {
      cout << a[n-2] << endl;
    }
    else {
      cout << a[n-1] << endl;
    }
  }
}

Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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; }

using pll = pair<long long, long long>;

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


	cout << r*r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; i++) cin >> h[i];

    vector<int64> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i=2; i<n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }

    debug(dp);
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408