akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a[11]={};
	FOR(i,0,6)cin>>a[i];
	int f=0;
	if(a[4]-a[0]>a[5])f=1;
	if(f){
		cout<<":(";
	}else{
		cout<<"Yay!";
	}
    return 0;
}


Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int MD = 1000000007;
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] aa = new int[n];
		int[] bb = new int[m];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		for (int j = 0; j < m; j++)
			bb[j] = sc.nextInt();
		int[][] dp = new int[n + 1][m + 1];
		dp[0][0] = 1;
		for (int i = 0; i <= n; i++)
			for (int j = 0; j <= m; j++)
				if (i == 0 && j == 0)
					dp[i][j] = 1;
				else {
					int x = 0;
					if (i > 0)
						x = (x + dp[i - 1][j]) % MD;
					if (j > 0)
						x = (x + dp[i][j - 1]) % MD;
					if (i > 0 && j > 0 && aa[i - 1] != bb[j - 1])
						x = (x - dp[i - 1][j - 1]) % MD;
					dp[i][j] = x;
				}
		int ans = dp[n][m];
		if (ans < 0)
			ans += MD;
		println(ans);
	}
}


Measured memory_bytes: 65336
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
	string s,t;cin>>s>>t;
	int c=0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]){
			c++;
		}
	}
	
	cout<<c<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if (a1 + a2 + a3 >= 22){
        cout << "bust";
    }else{
        cout << "win";
    }
    return 0;
}


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

const int maxn = 2005;
const int maxm = 4e6 + 5;
const int mod = 1e9 + 7;

long long numer[maxm];
long long denom[maxm];

int f[maxn][maxn];

void add(int &a, int b) {
    a = (a + b) % mod;
}

int C(int n, int k) {
    if(k > n) return 0;
    return numer[n] * denom[k] % mod * denom[n - k] % mod;
}

int main() {
    numer[0] = denom[0] = denom[1] = 1;
    for(int i = 1; i < maxm; ++ i) numer[i] = numer[i - 1] * i % mod;
    for(int i = 2; i < maxm; ++ i) denom[i] = - (mod / i) * denom[mod % i] % mod + mod;
    for(int i = 2; i < maxm; ++ i) denom[i] = denom[i] * denom[i - 1] % mod;

    int n, k; cin >> n >> k;
    if(k == 1) return puts("1"), 0;

    f[0][0] = 1;
    for(int i = 0; i <= n; ++ i) for(int j = 0; j <= i; ++ j) if(f[i][j]) {
        // add another white ball to the end
        add(f[i + 1][j], f[i][j]);

        // take away 1 white ball
        if(j < i) {
            // choosing a color to fill in
            long long cur = 1ll * f[i][j] * (n - j) % mod;
            cur = 1ll * cur * C(n * k - i - j - 1 - j * (k - 2), k - 2) % mod;
            add(f[i][j + 1], cur);
        }
    }
    cout << f[n][n] << endl;
}


Measured memory_bytes: 77568
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n; cin >> n;
    int cnt = 0;
    map<string, int> s;
    for(int i = 0; i < n; i++){
        string name;
        cin >> name;
        s[name]++;
        cnt = max(cnt, s[name]);
    }

    for(auto mp: s){
        if(mp.second == cnt) cout << mp.first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216
// atcoder/abc071/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    set<char> vis(s.begin(), s.end());
    string t = "None";
    for (char c = 'a'; c <= 'z'; ++c) {
      if (!vis.count(c)) {
        t = string(1, c);
        break ;
      }
    }
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        k: chars,
        d: usize
    }
    let k_digits = k.into_iter().map(|c| (c as u8 - b'0') as usize).collect::<Vec<_>>();
    let n = k_digits.len();
    let mut dp = vec_md![0u64;n+1;d;2];
    dp[0][0][0] = 1;
    for i in 0..n {
        for j in 0..d {
            for less in 0..2 {
                for z in 0..(if less == 0 {k_digits[i]+1} else {10}) {
                    dp[i+1][(j + z) % d][less | (z < k_digits[i]) as usize]
                        += dp[i][j][less];
                    dp[i+1][(j + z) % d][less | (z < k_digits[i]) as usize]
                        %= M;
                }
            }
        }
    }
    let mut ret = dp[n][0][0] + dp[n][0][1];
    ret %= M;
    println!("{}", sub_mod(ret, 1, M));
}

#[allow(dead_code)]
fn sub_mod(a: u64, b: u64, m: u64) -> u64 {
    let mut tmp = (a as i64 - b as i64) % m as i64;
    if tmp < 0 {
        tmp += m as i64;
    }
    tmp as u64
}

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

int main() {
  string S,T,U;
  int A,B;

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if(U==S) cout << A-1 <<" "<< B << endl;
  if(U==T) cout << A <<" "<< B-1 << endl;
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, m;

int main () {

    cin >> n >> m;
    cout << ((n-m)*100 + m*1900)*(1<<m);

    return 0;
}


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

int main()
{
  int64_t N, A, B, t = 1;
  cin >> N >> A >> B;
  while (A > 0 && B <= N)
  {
    if (t % 2)
    {
      if (A + 1 == B)
        A--;
      else
        A++;
    }
    else
    {
      if (B - 1 == A)
        B++;
      else
        B--;
    }
    t++;
  }
  cout << ((t % 2) ? "Alice" : "Borys") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;


string s;
int vec[30];
signed main(){
    cin>>s;
    for(int i=0;i<(int)s.size();i++){
        vec[s[i]-'a']++;
    }

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(abs(vec[i]-vec[j])>=2){
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<"YES"<<endl;
    return 0;
}   

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
  public static void main(String[] args) throws IOException {
  	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	int x = Integer.parseInt(br.readLine());
  	int result = x * x * x ;
  	System.out.println(result);
 }		
}

Measured memory_bytes: 24404
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if (4 * h * n - N * n - N * h) != 0:
            w = (N * h * n)/(4 * h * n - N * n - N * h)
            if w == w // 1 and w > 0:
                w = int(w)
                print(h, n, w)
                exit()

Measured memory_bytes: 42636
N,K=map(int,input().split())
S=input()
arr=[]
ans=0
prev,cnt=S[0],1
for i in range(1,N):
    if S[i]!=prev:
        arr.append(cnt)
        ans+=(cnt-1)
        prev=S[i]
        cnt=1
    else:
        cnt+=1
arr.append(cnt)
ans+=(cnt-1)

if len(arr)//2 <= K:
    print(N-1)
else:
    print(ans+2*K)


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
    int n;
    vector<int> hotel;
    int max = 0, ans = 0;

    cin >> n;
    REP(i, n){
        int tmp;
        cin >> tmp;
        hotel.pb(tmp);
    }

    REP(i,n){
        if(hotel[i] >= max){
            max = hotel[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int x;
signed main(){
    cin>>x;
    for(int h=1;h<=3500;h++){
        for(int n=h;n<=3500;n++){
            int m=x*h*n,c=4*h*n-x*h-x*n;
            if(m>0&&c>0&&m>=c&&m%c==0){
                cout<<h<<" "<<n<<" "<<m/c<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import sys

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A,B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]

N = int(input())
ans = 0
for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>i_i;
int main() {
int N;
cin>>N;
vector<int>A(N);
for(int i=0;i<N;i++)cin>>A.at(i);

int sum=0;
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			sum+=A.at(i)*A.at(j);
		}
	}									
	cout<<sum<<endl;
	return 0;
}

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

taro = 0
hanako = 0

for i in range(n):
    buf = input().split()
    if buf[0] > buf[1]:
        taro += 3
    elif buf[0] < buf[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print("%d %d" % (taro, hanako))



Measured memory_bytes: 5600
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner $ = new Scanner(System.in);
		int a = $.nextInt(), b = $.nextInt(), c = $.nextInt();
		if ((a < c && c < b) || (a > c && c > b))	System.out.println("Yes");
		else System.out.println("No");
		/*
		3 8 5 -> Yes
		7 3 1 -> No
		10 2 4 -> Yes
		31 41 59 -> No
		*/
	}
}


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

def main():
    X,Y,Z = map(int, input().split())
    
    # 初期化
    boxA = X
    boxB = Y
    boxC = Z

    # 操作1
    exchange1 = exchangeNum(boxA,boxB)
    boxA = exchange1[0]
    boxB = exchange1[1]

    # 操作2
    exchange1 = exchangeNum(boxA,boxC)
    boxA = exchange1[0]
    boxC = exchange1[1]

    print('{} {} {}'.format(boxA,boxB,boxC))

def exchangeNum(left,right):
    left_value = right
    right_value = left
    return (left_value,right_value)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
class UnionFind:
    def __init__(self, size: int):
        self.parent = [-1 for _ in range(size)]

    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size(px) > self.size(py):
            px, py = py, px
        self.parent[py] += self.parent[px]
        self.parent[px] = py
        return

    def find(self, x: int) -> int:
        if self.parent[x] < 0:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def size(self, x):
        return -self.parent[self.find(x)]

    def is_same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)


def main():
    # input
    N, M = map(int, input().split())
    A, B = [], []

    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a-1)
        B.append(b-1)

    # solve
    # ref: http://drken1215.hatenablog.com/entry/2019/03/03/224600
    # ref: https://atcoder.jp/contests/abc120/submissions/4450601
    uf = UnionFind(N)
    ans = [N*(N-1)//2]
    for i in range(M-1, 0, -1):
        p1 = uf.find(A[i])
        p2 = uf.find(B[i])
        if p1 != p2:
            ans.append(ans[-1] - uf.size(p1)*uf.size(p2))
        else:
            ans.append(ans[-1])
        uf.unite(p1, p2)
    return ans


print(*list(reversed(main())), sep="\n")


Measured memory_bytes: 15768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    ans += min(n, m / 2);
    if (ans * 2 < m) {
        ll left = m - ans * 2;
        ans += left / 4;
    }

    Cout(ans);

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<long> el(n,0);
    for(int i = 0; i < n; i++)
        cin >> el[i];
        
    sort(el.begin(), el.end());
    int nC = -1;
    nC = el[n-1];
    int k = -1;
    int cK = nC/2;
    for(int i = 0; i < n; i++)
        if (abs(el[i]-cK) <= abs(k-cK) && el[i] != nC)
            k = el[i];
            
    cout << nC << " " << k << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int a,b;

int main(){
	cin>>a>>b;
	if(a>b)swap(a,b);
	if(a==1&&b==2){
		cout<<3<<endl;
	}else if(a==2&&b==3){
		cout<<1<<endl;
	}else{
		cout<<2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, Q = [int(a) for a in input().split(" ")]
S = str(input())
LRs = [[int(s) for s in input().split(" ")] for i in range(Q)]
left = [0]*len(S)
for i in range(1,len(S)):
    left[i] = left[i-1]+1 if S[i-1:i+1]=="AC" else left[i-1]
for l, r in LRs:
    l, r = l-1, r-1
    print(left[r]-left[l])

Measured memory_bytes: 24456
hlist = []
wlist = []

while(1):
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break

    hlist.append(h)
    wlist.append(w)

for h, w in zip(hlist, wlist):
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7012
#include <stdio.h>
#include <string.h>
#define MAX 100
int main(){    
int n;    
int t_point=0, h_point=0;    
char tarou[MAX], hanako[MAX];    
scanf("%d", &n);    
for(;n>0;n--){        
scanf(" %s %s", tarou, hanako);        
if(strcmp(tarou, hanako)>0){            
t_point+=3;        
}
else if(strcmp(tarou, hanako)==0){            
t_point+=1;            h_point+=1;        
}
else if(strcmp(tarou, hanako)<0){            
h_point+=3;        
}    
}    
printf("%d %d\n", t_point, h_point);    
return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
int main()
{
    char ch;
    long long int A, B;
    scanf("%lld %c %lld", &A, &ch, &B);
    if(ch=='+')
    {
        printf("%lld", A+B);
    }
    else if(ch=='-')
    {
        printf("%lld", A-B);
    }
    return 0;
}


Measured memory_bytes: 128
import math
import pprint
import fractions
import collections
import itertools
N,M=map(int,input().split())
H=list(map(int,input().split()))
tree=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
l=[1]*N
for i in range(N):
    flag=1
    for j in tree[i]:
        if H[i]<=H[j]:
            flag=0
    l[i]=flag
print(sum(l))






Measured memory_bytes: 95552
N,W=map(int,input().split())
G=[]
for i in range(N):
    G.append(tuple(map(int,input().split())))


dp=[[-float('inf')]*(W+1) for i in range(N+1)]
for i in range(W+1):
    dp[0][i]=0
for i in range(1,N+1):
    dp[i][0]=0

for i in range(1,N+1):
    v,w=G[i-1]
    for j in range(W+1):
        dp[i][j]=dp[i-1][j]
        if j>=w:
            dp[i][j]=max(dp[i][j],dp[i-1][j-w]+v,dp[i][j-w]+v)

print(dp[N][W])



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

typedef long long ll;
typedef long double ld;
#define ii pair <int, int>
#define MP make_pair
#define endl "\n"
#define PB push_back
#define F first 
#define int long long 
#define S second
#define rise_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;
#define all(v) v.begin(), v.end()
#define sz(a) signed((a).size())
#define forn(i,n) for(int i = 0; i < int(n); i++)
#define ford(i,n) for(int i = int(n) - 1; i >= 0; i--)

int b[12];
int a[12][12];
signed main()
{	
	rise_up
    int t=1; //cin>>t; 
    while(t--){
		int n, m , p; cin>>n>>m>>p;
		for(int i=0; i<n; i++){
			cin>>b[i];
			for(int j=0; j<m; j++){
				cin>>a[i][j];
			}
		}
		int ans=INT_MAX;
		for(int i=0; i <= pow(2, 12); i++){
			int d[12]={};
			int x = i; int c=0;
			while(x){
				d[c] = x%2;
				x/=2;c++;
			} int z[m+1]={};
			int cost=0;
			for(int j=0; j<12; j++){
				if(d[j]){cost+=b[j];
					for(int k=0; k<m; k++){
						z[k] += a[j][k];
					}
				}
			}
			int f=1;
			for(int k=0; k<m; k++){
				if(z[k] < p){
					f=0; break;
				}
			}
			if(f) ans = min(cost, ans);
		}
		if(ans == INT_MAX) ans = -1;
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3644
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
S = input()
A = list(digits)

ans = 0
for x in product(A, repeat=3):
	i = 0
	for y in S:
		if y == x[i]:
			if i == 2:
				ans += 1
				break
			else:
				i += 1

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 200001

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string str;
    cin >> str;
    int n = str.size();
    string temp = "keyence";
    int l = 0, r = n - 1;
    while (l < 7 && str[l++] == temp[l - 1]) {

    }
    if (temp[6] != str[6]) {
        l--;
    }
    if (l != 7) {
        l -= 2;
        int j = 6;
        while (j >= 0 && str[r--] == temp[j--]) {

        }
        //cout << l << " " << j << endl;
        if (!(l >= j)) {
            cout << "NO" << endl;
            return 0;
        }
        else {
            cout << "YES" << endl;
        }
    }
    else {
        cout << "YES" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

bucket = Array.new(10_001, 0)
gets
gets.split(' ').each do |str|
  i = str.to_i
  bucket[i] += 1
end
sorted = []
bucket.each_with_index do |x, k|
  x.times do
    sorted << k
  end
end
puts sorted.join(' ')



Measured memory_bytes: 137368
#include <stdio.h>
int main(){
int n,p[10000];
scanf("%d",&n);
int i=0;
int max=0;
int sum=0;

for(i=0; i<n; i++){
scanf("%d",&p[i]);
sum+=p[i];
if(max<p[i]) max=p[i];

}

printf("%d",sum-max/2);


return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2019  # type: int


def solve(L: int, R: int):
    lmod = L % MOD
    rmod = R % MOD
    if R-L > MOD:
        # すべて使えるので、0
        print(0)
        return
    elif rmod < lmod:
        # 0を使える
        print(0)
        return
    else:
        # 2019よりも小さいから、全探索が間に合う
        m = +INF
        for i in range(lmod, rmod+1):
            for j in range(i+1, rmod+1):
                curr = (i*j) % MOD
                if curr < m:
                    m = curr
                    # print(i, j, curr)
        print(m)
        return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import math
import itertools

N = int(input())

line = list(map(int, input().split(" ")))
line_set = set(line)
dic = {}

for num in line_set:
    cnt = line.count(num)
    dic[num] = cnt
    
pattern = list(itertools.combinations(line_set, 3))

sum_ = 0
for lis in pattern:
    a, b, c = lis
    if a + b > c and b + c > a and a + c > b:
        sum_ += dic[a]*dic[b]*dic[c]
print(sum_)

Measured memory_bytes: 20480
#include<stdio.h>
#define N_MAX 105
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define inf 100000000
#define nil -1

int A[N_MAX][N_MAX];

void prim(int n)
{
  int d[N_MAX];
  int pi[N_MAX], color[N_MAX];
  int i, k, minv, u;
  int ans=0;

  for(i=0; i<n; i++){
    d[i] = inf;
    pi[i] = nil;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = inf;
    u=nil;

    for(i=0; i<n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u=i;
	minv = d[i];
      }
    }

    if(u == nil) break;

    color[u] = BLACK;

    for(k=0; k<n; k++){
      if(color[k] != BLACK && A[u][k] != nil){
	if(d[k] > A[u][k]){
	  d[k] = A[u][k];
	  pi[k] = u;
	  color[k] = GRAY;
	}
      }
    }
  }
  
  for(i=0; i<n; i++){
    if(pi[i] != nil){
      ans+=A[i][pi[i]];
    }
  }
  
  printf("%d\n", ans); 
}

    
    

int main()
{
  int n;
  int i, j;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d", &A[i][j]);
    }
  }

  prim(n);

  return 0;
}

Measured memory_bytes: 640
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  const N = Number(inp.shift())
  inp = inp[0].split(' ').map(n => Number(n));
  let ans = inp[0]
  for (let i = 1; i < N; i++) {
    if (i === N - 1) {
      ans += inp[i - 1]
    } else {
      ans += Math.min(inp[i], inp[i-1])
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

//Grid
public class Main{

	int r, c, si, sj, ti, tj;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	int[][] dist, mem;
	int MOD = 100000007, INF = 1<<28;
	
	int get(int i, int j){
		if(mem[i][j]!=-1)return mem[i][j];
		int res = 0;
		for(int k=0;k<4;k++){
			int ni = (i+d[k][0]+r)%r, nj = (j+d[k][1]+c)%c;
			if(dist[ni][nj] < dist[i][j])res+=get(ni, nj);
		}
		return mem[i][j] = res%MOD;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		r = sc.nextInt(); c = sc.nextInt(); si = sc.nextInt(); sj = sc.nextInt(); ti = sc.nextInt(); tj = sc.nextInt();
		dist = new int[r][c];
		for(int[]a:dist)Arrays.fill(a, INF);
		Queue<int[]> q = new LinkedList<int[]>();
		dist[si][sj] = 0;
		q.add(new int[]{si, sj});
		while(!q.isEmpty()){
			int[] V = q.poll();
			for(int k=0;k<4;k++){
				int ni = (V[0]+d[k][0]+r)%r, nj = (V[1]+d[k][1]+c)%c;
				if(dist[ni][nj]==INF){
					dist[ni][nj] = dist[V[0]][V[1]]+1;
					q.add(new int[]{ni, nj});
				}
			}
		}
		mem = new int[r][c];
		for(int[]a:mem)Arrays.fill(a, -1);
		mem[si][sj] = 1;
		System.out.println(get(ti, tj));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    
    string t;
    rep(i,0,n){
        if(s[i]!='x') t+=s[i];
    }
    string u=t;
    reverse(all(u));
    if(u!=t){
        cout<<-1<<endl;
        return 0;
    }
    
    vector<int> vec;
    int cnt=0;
    rep(i,0,n){
        if(s[i]=='x') cnt++;
        else{
            vec.push_back(cnt);
            cnt=0;
        }
    }
    vec.push_back(cnt);
    
    //for(int x:vec) cout<<x<<endl;
    
    int ans=0;
    int m=vec.size();
    rep(i,0,m/2){
        ans+=abs(vec[i]-vec[m-1-i]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1148
# -*- coding: utf-8 -*-

N = int(input())

a = int(N/1000)
x = N % 1000
b = int(x/100)
x = x % 100
c = int(x/10)
x = x % 10
d = x

tmp = [0 for i in range(8)]
tmp2 = ['{}+{}+{}+{}'.format(a, b, c, d), '{}+{}+{}-{}'.format(a, b, c, d),
        '{}+{}-{}+{}'.format(a, b, c, d), '{}+{}-{}-{}'.format(a, b, c, d),
        '{}-{}+{}+{}'.format(a, b, c, d), '{}-{}+{}-{}'.format(a, b, c, d),
        '{}-{}-{}+{}'.format(a, b, c, d), '{}-{}-{}-{}'.format(a, b, c, d)]

tmp[0] = a + b + c + d
tmp[1] = a + b + c - d
tmp[2] = a + b - c + d
tmp[3] = a + b - c - d
tmp[4] = a - b + c + d
tmp[5] = a - b + c - d
tmp[6] = a - b - c + d
tmp[7] = a - b - c - d

for i in range(8):
    if(tmp[i] == 7):
        x = i
        break

print(str(tmp2[i])+'=7')


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int i = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		sc.close();
		int aa = 0;
		if(i % a != 0) aa++;
		ou.println(aa);
		ou.flush();
	}
}

Measured memory_bytes: 35316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
int par[100001];
vi adj[100001];
int dp[100001];
 
void dfs(int u)
{
	vi vec;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		dfs(v);
		vec.pb(dp[v]);
	}
	sort(vec.begin(),vec.end());
	dp[u] = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int t = vec[i];
		if(dp[u]<t+1) dp[u]=t+1;
		else
		{
			dp[u]++;
		}
	}
	//cerr<<u<<' '<<dp[u]<<'\n';
}
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i = 1; i < n; i++) 
	{
		cin>>par[i];
		par[i]--;
		adj[par[i]].pb(i);
	}
	dfs(0);
	cout<<dp[0]<<'\n';
}

Measured memory_bytes: 14336
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


int main(){
    int n,k;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;

    string t;
    cin >> t;

    for(int i = 0; i+k < t.size(); i++){
        if(t[i] == t[i+k]){
            t[i+k] = 'o';
        }
    }
    map<char, int> mp;
    REP(i,t.size()){
        mp[t[i]] ++;
    }

    ll ans = 0;
    ans += mp['r'] * p;
    ans += mp['s'] * r;
    ans += mp['p'] * s;

    cout << ans << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll n,k;cin>>n>>k;
    if(2*(k-1)+1<=n){
        cout<<"YES"<<"\n";
    }else{
        cout<<"NO"<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int N;
    cin >> N;

    int count = 0;
    for (int a = 1; a <= N; a++) {
        for (int b = 1; b <= N; b++) {
            if (a * b < N) {
                count++;
            } else {
                break;
            }
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, A; cin >> H >> A;
  if(H % A != 0){
    cout << H / A + 1 << endl;
  }else{
    cout << H / A << endl;
  }
}

Measured memory_bytes: 256
import Control.Applicative

data Dice = Dice [Int] deriving (Show)

roll :: Dice -> Char -> Dice
roll (Dice [top, front, right, left, back, bottom]) 'N' = Dice [front, bottom, right, left, top, back]
roll (Dice [top, front, right, left, back, bottom]) 'S' = Dice [back, top, right, left, bottom, front]
roll (Dice [top, front, right, left, back, bottom]) 'E' = Dice [left, front, top, bottom, back, right]
roll (Dice [top, front, right, left, back, bottom]) 'W' = Dice [right, front, bottom, top, back, left]

turn1 :: Dice -> Dice
turn1 (Dice [top, front, right, left, back, bottom]) = Dice [top, right, back, front, left, bottom]
turn2 = turn1 . turn1
turn3 = turn2 . turn1

turnAll :: [Dice] -> [Dice]
turnAll dices =  [id, turn1, turn2, turn3] <*> dices

dices :: Dice -> [Dice]
dices dice = [dice
             , toFF dice
             , toW dice
             , toE dice
             , toFF (toW dice)
             , toFF (toE dice)
             ]

toW = flip roll 'S'
toE = flip roll 'E'
toFF = toW . toW

solve :: [Dice] -> [Int] -> Maybe Int
solve [] _                     = Nothing
solve ((Dice (x:y:z:_)):rest) [top, front]
    | top == x && front == y = Just z
    | otherwise              = solve rest [top, front]

main :: IO ()
main = do
    init <- Dice . map read . words <$> getLine
    getLine
    let diceall = turnAll . dices $ init
    qs <- map (map ri . words) . lines <$> getContents
    mapM_ putStrLn $ map pmaybe $ map (solve diceall) qs
        where ri :: String -> Int
              ri = read
              pmaybe :: Maybe Int -> String
              pmaybe Nothing  = "Nothing"
              pmaybe (Just n) = show n


Measured memory_bytes: 3996
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


x,a=input_list()
if x<a:
    print(0)

else:
    print(10)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int R; cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    }else if(R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int A, B;
  string S;
  cin >> A >> B >> S;

  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '-') {
      if (i != A) {
        cout << "No" << endl;
        return;
      }
    } else if (i == A) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;

}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;

int main(){
    int n,t,d;
    scanf("%d %d", &n, &t);
    ll stages[n];
    rep(n) scanf("%lld", &stages[i]);
    sort(stages, stages+n);

    ll ans = 1LL;
    rep(n){
        (ans *= ((ll)i+1LL- (ll)(lower_bound(stages, stages+n, stages[i]-t) - stages)) % MOD) %= MOD;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4004
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int x, y, z, e, ans;

    while (cin >> e) {
        if (!e) { break; }
        z = 0; ans = e;

        for (int z = 0; z*z*z <= e; z++) {
            for (int y = 0; y*y + z*z*z <= e; y++) {
                x = e - y*y - z*z*z;
                ans = min(ans, x+y+z);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    A.sort()

    B = [0] * (A[-1] + 1)

    ans = 0
    for i, a in enumerate(A):
        if B[a] == 1:
            continue
        for aa in range(a, A[-1] + 1, a):
            B[aa] = 1

        if i != len(A) - 1 and A[i] == A[i + 1]:
            continue

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31408
#include <bits/stdc++.h>
using namespace std;
vector<int> dx= {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
const int INF=100000000;

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int m=max(h,w);
    cout<<((n-1)/m)+1<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ifstream f("C.in");
ofstream g("C.out");
int N,M,K;
int R[10],C[10],tot=0;
string A[10];

int Comp(int a,int b)
{
    int add=0;

    int dima=log2(a)+1,dimb=log2(b)+1;
    vector < int > V1,V2;

    for(int i=dima;i>=0;i--)
    if( ( a & (1<<i) ) > 0 )
    {
        V1.push_back(i);
        add+=R[i];
    }

    for(int i=dimb;i>=0;i--)
    if( ( b & (1<<i) ) > 0 )
    {
        V2.push_back(i);
        add+=C[i];
    }
    for(int i=0;i<V1.size();i++)
    for(int j=0;j<V2.size();j++)
    {
        int row=V1[i],col=V2[j];
        if(A[row][col]=='#') add--;
    }
    return add;
}

int main()
{

    cin>>N>>M>>K;

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

    for(int i=0;i<N;i++)
    {
        R[i]=0+(A[i][0]=='#');
        for(int j=1;j<M;j++)
        R[i]=R[i]+(A[i][j]=='#');
        tot+=R[i];
    }
    for(int j=0;j<M;j++)
    {
        C[j]=0+(A[0][j]=='#');
        for(int i=1;i<N;i++)
        C[j]=C[j]+(A[i][j]=='#');
    }

    int ans=0;

    for(int a=0;a<(1<<N);a++)
    for(int b=0;b<(1<<M);b++)
    {
        int erase_el=Comp(a,b);
        if(tot-erase_el==K) ans++;
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 3868
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp"
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
using ll = long long;

template <typename T>
void ch_min(T &left, T right)
{
  if (left > right)
  {
    left = right;
  }
}

// ----- WarshallFloyd -----

template <typename T>
void WarshallFloyd(vector<vector<T>> &V, T infinity = numeric_limits<T>::max())
{
  // It is valid to apply this method for
  //  - a directed/undirected graph,
  //  - a graph whose edge may be negative.
  //    - Negative cycle can be detected by V[i][i] < 0 if we initialize V[i][i] = 0.
  auto N{static_cast<int>(V.size())};
  for (auto k{0}; k < N; ++k)
  {
    for (auto i{0}; i < N; ++i)
    {
      for (auto j{0}; j < N; ++j)
      {
        if (V[i][k] == infinity || V[k][j] == infinity)
        {
          continue;
        }
        ch_min(V[i][j], V[i][k] + V[k][j]);
      }
    }
  }
}

// ----- main -----

template <typename T>
constexpr T Infty() { return numeric_limits<T>::max(); }

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<ll>> D(N, vector<ll>(N, Infty<ll>()));
  for (auto i{0}; i < M; ++i)
  {
    int A, B;
    ll C;
    cin >> A >> B >> C;
    D[A][B] = C;
  }
  for (auto i{0}; i < N; ++i)
  {
    D[i][i] = 0;
  }
  WarshallFloyd(D);
  for (auto i{0}; i < N; ++i)
  {
    if (D[i][i] < 0)
    {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  for (auto i{0}; i < N; ++i)
  {
    for (auto j{0}; j < N; ++j)
    {
      cout << (D[i][j] == Infty<ll>() ? "INF" : to_string(D[i][j]));
      if (j < N - 1)
      {
        cout << " ";
      }
      else
      {
        cout << endl;
      }
    }
  }
}



Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<len;j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256