akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int H, A, B;
  cin >> H >> A >> B;
  int cnt = 0;
  for(int i=A; i<=B; ++i) {
    if(H % i == 0) ++cnt;
  }
  cout << cnt << endl;
}




Measured memory_bytes: 3096
class SegmentTree():
    def __init__(self,arr,func=min,ie=2**63):
        self.n = 2**(len(arr)-1).bit_length()
        self.ie = ie
        self.func = func
        self.tree = [ie for _ in range(2*self.n)]
        for i in range(len(arr)):
            self.tree[self.n+i-1] = arr[i]
        for i in range(self.n-1)[::-1]:
            self.tree[i] = func(self.tree[2*i+1],self.tree[2*i+2])

    def set(self,index,x):
        index += self.n-1
        tree = self.tree
        func = self.func
        tree[index] = x
        while index:
            index = (index-1)//2
            tree[index] = func(tree[2*index+1],tree[2*index+2])

    def query(self,left,right):
        ie = self.ie
        tree = self.tree
        func = self.func
        if right <= left:
            return ie
        left += self.n-1
        right += self.n-2
        tmp_l = self.ie
        tmp_r = self.ie
        while right-left>1:
            if left & 1 == 0:
                tmp_l = func(tmp_l,tree[left])
            if right & 1 == 1:
                tmp_r = func(tree[right],tmp_r)
                right -= 1
            left = left//2
            right = (right-1)//2
        if left == right:
            tmp_l = func(tmp_l,tree[left])
        else:
            tmp_l = func(func(tmp_l,tree[left]),tree[right])
        return func(tmp_l,tmp_r)

import sys
input = sys.stdin.readline

N = int(input())
S = input()
Q = int(input())

A = []
for i in range(N):
    A.append(set([ord(S[i])-97]))

def func(x,y):
    return x|y
ie = set()

st = SegmentTree(A,func,ie)

ans = []

for _ in range(Q):
    q,x,y = input().split()
    q = int(q)
    if q == 1:
        st.set(int(x)-1,set([ord(y)-97]))
    else:
        ans.append(len(st.query(int(x)-1,int(y))))

print('\n'.join(map(str,ans)))

Measured memory_bytes: 488260
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    sc.close();

//    BigInteger lcm = Arrays.stream(A)
//        .mapToObj(BigInteger::valueOf)
//        .reduce(BigInteger.ONE, (a, b) -> a.divide(a.gcd(b)).multiply(b));

    BigInteger lcm = BigInteger.ONE;
    for (int i = 0; i < N; i++) {
      BigInteger a = BigInteger.valueOf(A[i]);
      lcm = lcm.divide(lcm.gcd(a)).multiply(a);
    }
    
    
//    Map<Integer, Integer> lcm = new HashMap<>();
//    for (int ai : A)
//      for (Map.Entry<Integer, Integer> fAi : f(ai).entrySet())
//        lcm.put(fAi.getKey(), Math.max(lcm.getOrDefault(fAi.getKey(), 0), fAi.getValue()));

    long mod = 1000000007;

//    long modLcm = 1;
//    for (Map.Entry<Integer, Integer> lcm_p : lcm.entrySet())
//      modLcm = (modLcm * modPow(lcm_p.getKey(), lcm_p.getValue(), mod)) % mod;

    long modLcm = lcm.remainder(BigInteger.valueOf(mod)).longValue();

    long ans = 0;
    for (int ai : A)
      ans = (ans + modDiv(modLcm, ai, mod)) % mod;

    System.out.println(ans);
  }

  private static long modDiv(long a, long b, long mod) {
    return (a % mod) * modInv(b, mod) % mod;
  }

  private static long modInv(long x, long mod) {
    return modPow(x, mod - 2, mod);
  }

  private static long modPow(long b, long e, long mod) {
    long ans = 1;
    long x = b % mod;
    for (long y = e; y != 0; y >>= 1) {
      if ((y & 1) == 1) ans = (ans * x) % mod;
      x = (x * x) % mod;
    }
    return ans;
  }
}

Measured memory_bytes: 152944
public class Main {
	public static void main(String[] age){
		String input = new java.util.Scanner(System.in).nextLine();
		String[] arrayinput = input.split(" ");
		int a = Integer.parseInt(arrayinput[0]);
		int b = Integer.parseInt(arrayinput[1]);
		int c = Integer.parseInt(arrayinput[2]);
		int z=0;
		if(a<b) z++;
		if(b<c) z++;
		if(z == 2){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

int main() {
    int s;
    int count =0;
    cin >>s;
    map<int,int>mp;
    while(true){
        mp[s]++;
        count ++;
        if(mp[s]==2) {
            cout << count <<endl;
            break;
        }
        if(s%2==0)s/=2;
        else s=3*s+1;
    }
}


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

int main() {
	int a,b,c;
	cin >>a>>b>>c;
	if(a<=b && b<=c && a<=c){
		cout<< a << " " << b << " " << c <<endl;
	}
	else if(a<=c && c<=b && a<=b){
		cout<< a << " " << c << " " << b <<endl;
	}
	else if(b<=a && a<=c && b<=c){
		cout<< b << " " << a << " " << c <<endl;
	}
	else if(b<=c && c<=a && b<=a){
		cout<< b << " " << c << " " << a <<endl;
	}
	else if(c<=a && a<=b && c<=b){
		cout<< c << " " << a << " " << b <<endl;
	}
	else if(c<=b && b<=a && c<=a){
		cout<< c << " " << b << " " << a <<endl;
	}
}

Measured memory_bytes: 3076
use std::io::*;
use std::str::FromStr;

fn main() {
    let n:u32 = read();
    let k:u32 = read();

    println!("{}", k * (k - 1).pow(n - 1));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

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

int a[MAX_N][MAX_N];
P s,t;
int opt;
int n,m;

void dfs(P p,int cnt,map<P,int>& mp)
{
    if(cnt == 10){
        return;
    }
    cnt++;
    rep(i,4){
        P cor = p;
        if(cor.first + dx[i] < 0 || cor.first + dx[i] >= n || cor.second + dy[i] < 0 || cor.second + dy[i] >= m){
            continue;
        }
        if(mp[P(cor.first + dx[i],cor.second + dy[i])] == 1){
            continue;
        }
        while(1){
            cor.first += dx[i],cor.second += dy[i];
            if(cor == t){
                if(opt > cnt){
                    opt = cnt;
                }
                break;
            }
            if(cor.first < 0 || cor.first >= n || cor.second < 0 || cor.second >= m){
                break;
            }
            if(mp[cor] == 1){
                mp[cor] = 0;
                dfs(P(cor.first-dx[i],cor.second-dy[i]),cnt,mp);
                mp[cor] = 1;
                break;
            }
        }
    }
    return;
}

int main()
{
    while(1){
        scanf("%d%d",&m,&n);
        if(n == 0 && m == 0){
            break;
        }
        map<P,int> mp;
        opt = INF;
    	rep(i,n){
            rep(j,m){
                scanf("%d",&a[i][j]);
                if(a[i][j] == 1){
                    mp[P(i,j)] = 1;
                }
                if(a[i][j] == 2){
                    s = P(i,j);
                }
                if(a[i][j] == 3){
                    t = P(i,j);
                }
            }
    	}
        dfs(s,0,mp);
        if(opt == INF){
            printf("-1\n");
        }else{
            printf("%d\n",opt);
        }
    }
	return 0;
}

Measured memory_bytes: 3184
/*
Author: CNYALI_LK
LANG: C++
PROG: C.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int f[10101],g[10101];
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int a,b,c,d,e,F,G;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&F);
	f[0]=1;
	g[0]=1;
	f[a]=1;
	for(int i=a+1;i<=b;++i)if(f[i-a])f[i]=1;
	f[b]=1;
	for(int i=b+1;i<=F;++i){
		f[i]=f[i-a]|f[i-b];
	}
	g[c]=1;
	for(int i=c+1;i<=d;++i)g[i]=g[i-c];
	g[d]=1;
	for(int i=d+1;i<=F;++i)g[i]=g[i-c]|g[i-d];
	G=F/100;
	int fa=a*100,fb=0;
	for(int i=1;i<=G;++i){
		for(int j=1;j<=F;++j){
			if(!f[i]||!g[j])continue;
			if(i*100+j>F||i*e<j)break;
			if((i*100+j)*fb<fa*j){
				fb=j;
				fa=i*100+j;
			}
		}
	}
	printf("%d %d\n",fa,fb);
	return 0;
}



Measured memory_bytes: 256
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

typedef struct {
	int top;
	int front;
	int right; 
	int left; 
	int back;
	int bottom;	
} dice_type;

void move(char direction, dice_type* p_dt);

int main(int argc, char* argv[])
{
	int i;
	dice_type dice;
	char movement[101];
	
	cin >> dice.top;
	cin >> dice.front;
	cin >> dice.right;
	cin >> dice.left;
	cin >> dice.back;
	cin >> dice.bottom;
	cin >> movement;

	for (i = 0; movement[i]; i++) {
		move(movement[i], &dice);
	}
	cout << dice.top << endl;

	return 0;
}

void move(char direction, dice_type* p_dt) {
	dice_type d = *p_dt;

	switch (direction) {
	case 'S':
		p_dt->top = d.back;
		p_dt->front = d.top; 
		p_dt->back = d.bottom;
		p_dt->bottom = d.front; 
		break;
	case 'N':
		p_dt->top = d.front;
		p_dt->front = d.bottom; 
		p_dt->back = d.top;
		p_dt->bottom = d.back;
		break;
	case 'E':
		p_dt->top = d.left;
		p_dt->right = d.top; 
		p_dt->left = d.bottom; 
		p_dt->bottom = d.right;
		break;
	case 'W':
		p_dt->top = d.right;
		p_dt->right = d.bottom; 
		p_dt->left = d.top; 
		p_dt->bottom = d.left;
		break;
	}
}

Measured memory_bytes: 3088
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)*}
    };
}

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input!{
        m: usize,
        k: usize
    }
    if 1 << m < k + 1 {
        println!("-1");
        return;
    }
    let mut d = 0;
    while 1 << d <= k {
        d += 1;
    }
    if k == 0 {
        print!("0 0");
        for i in 1..1 << m {
            print!(" {} {}", i, i);
        }
        println!("");
    } else if k == 1 && m < 2 {
        println!("-1");
    } else {
        print!("0");
        for i in 1..1 << m {
            if i == k {
                continue;
            }
            print!(" {}", i);
        }
        print!(" {}", k);
        for i in (1..1 << m).rev() {
            if i == k {
                continue;
            }
            print!(" {}", i);
        }
        println!(" 0 {}", k);
    }
}


Measured memory_bytes: 5884
package main

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

func main() {
	io, flush := NewIO()
	defer flush()
	n, k := io.ScanInt(), io.ScanInt()
	p := io.ScanFloat64s(n)
	expNums := make([]float64, n)
	for i, e := range p {
		expNums[i] = ((e + 1.0) * e / 2.0) / e
	}
	var max float64
	for i := 0; i < k; i++ {
		max += expNums[i]
	}
	left := expNums[0]
	curExp := max
	for i := k; i < n; i++ {
		curExp = curExp - left + expNums[i]
		if max < curExp {
			max = curExp
		}
		left = expNums[i-k+1]
	}
	io.Println(max)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 7936
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007


def main():

    N = int(input())
    d = dict()

    for i in range(N):
        s = input()
        if not s in d:
            d[s] = 1
        else:
            d[s] += 1

    d = sorted(d.items(), key=lambda x: x[1], reverse=True)

    l = -1
    ans = []
    for k, v in d:
        if v < l:
            break
        else:
            l = v
            ans.append(k)

    # print(d)
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;

int main() {
    string S1, S2;
    cin >> n >> m;
    vl A;
    rep(i, m) {
        cin >> x;
        A.push_back(x);
    }

    vl dp(n + 1, INF);
    rep(i, n + 1) {
        if (i == 0) dp[i] = 0;
        rep(j, m) {
            if (i >= A[j]) chmin(dp[i], dp[i - A[j]] + 1);
        }
    }

    cout << dp[n] << endl;
}



Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {
	public static void main(String[] arg){

		/*Scanner = テキスト入力を扱うためのクラス
		 *キーボードからの入力を受けつける場合は
		 *System.inを使って下記のように記述
		 */
		Scanner scan = new Scanner(System.in);

		//Caseナンバーを指定するための前準備
		int i = 1;

		/*while(true)で無限ループをセット
		 *int x = scan.nextInt(); xに値を入れてる
		 *そして一回ずつ表示させ0の時にbreakさせてる。
		 */
		while(true){
		int x = scan.nextInt();
		if ( x == 0 ) break;

		//最後は表示させる。あとCaseナンバーの加算をしてます。
		System.out.println("Case" + " " + i + ":" + " " + x);
		i = i+1;
		}



	}
}

Measured memory_bytes: 33028
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	string s;
	cin>>s;
	int b=0,e=1;
	ll ans = 0;
	while(b < s.size()){
		if(b+1 < s.size() && s[b] != s[b+1]){
			ans++;
			b++;
		}else if(b+1 == s.size()){
			ans++;
			b++;
		}else{
			if(b+2 == s.size()){
				ans++;
				b++;b++;
				break;
			}else{
				ans++;ans++;
				b++;b++;b++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  int ans = 0;
  int h;
  for(int i=0;i<N;++i){
    cin>>h;
    if(h>=K) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3572
import           Control.Applicative
import           Control.Monad
import           Data.List

type Dice = [Int]

leq :: Dice -> Dice -> Bool
leq [] [] = True
leq (x:xs) (y:ys)
    | x < y = True
    | x > y = False
    | otherwise = leq xs ys

minDice:: Dice -> Dice -> Dice
minDice d1 d2
    | leq d1 d2 = d1
    | otherwise = d2

rotate:: Dice -> Char -> Dice
rotate [u,f,r,l,b,d] 'E' = [l,f,u,d,b,r]
rotate [u,f,r,l,b,d] 'N' = [f,d,r,l,u,b]
rotate [u,f,r,l,b,d] 'S' = [b,u,r,l,d,f]
rotate [u,f,r,l,b,d] 'W' = [r,f,d,u,b,l]
rotate xs _              = xs

search :: [Dice]->[Dice]->Dice
search dices searched
  | null dices =  foldl1 minDice searched
  | otherwise = search next (searched ++ dices)
  where
    next = filter (`notElem` searched) [rotate d opt | d <-dices, opt<-"ENSW" ]

main :: IO ()
main = do
  num <- getLine
  dices <- replicateM (read num) (map (read::String->Int) . words <$> getLine)
  let ds = [search [d] [] | d <-dices]
  putStrLn $ if length ds == length (nub ds) then "Yes" else "No"


Measured memory_bytes: 4184
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a * 10 + b * 2 + c == X // 50:
                cnt += 1
print(cnt)

Measured memory_bytes: 9156
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <stack>
using namespace std;

#define INF 1e18
#define int long long



signed main() {
    string s; cin >> s;

    string substr4 = s.substr(0, 4);
    string substr8 = s.substr(4, 8);
    string ans = substr4 + " " + substr8;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    int N, ans = 0;
    cin >> N;
    vector<int> L(2 * N);
    cin >> L;
    sort(L.begin(), L.end());
    REP(i, N) ans += L[i * 2];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
using namespace std;
using ll =long long;
int main() {
	string S;
	cin >> S;
	int N;
	N = S.size();
	bool t=true;
	for (int i = 0; i < (N - 1) / 2; i++) {
		if (S[i] != S[N - 1 - i]) {
			cout << "No";
				return 0;
		}
	}
	for (int i = 0; i < (N - 1) / 4; i++) {

		if (S[i] != S[(N - 1)/2-1 - i]) {
			cout << "No";
			return 0;
		}

	}
	cout << "Yes";

}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

class union_find{
	private:
	vector<int> parent,rank,gs;
    int size;
	public:
    int count_group;
    union_find()=default;
    union_find(int n){ init(n); }
    void init(int n){
		size=n;
		count_group=n;
		parent.resize(size);
		rank.assign(size,0);
        gs.assign(size,1);
		for(int i=0; i<size; ++i) parent[i]=i;
	}
	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
            gs[y]+=gs[x];
		} else {
			parent[y]=x;
            gs[x]+=gs[y];
			if(rank[x]==rank[y]) ++rank[x];
		}
		--count_group;
	}
	bool is_same_group(int x,int y){
		return find(x)==find(y);
	}
    int group_size(int x){
        return gs[find(x)];
    };
};

void solve(){
    int n,k,l;
    cin >> n >> k >> l;

    union_find uf1(n),uf2(n);
    rep(i,0,k){
        int p,q;
        cin >> p >> q;
        --p;
        --q;
        uf1.unite(p,q);
    }
    rep(i,0,l){
        int r,s;
        cin >> r >> s;
        --r;
        --s;
        uf2.unite(r,s);
    }

    map<pair<int,int>,int> count;
    rep(i,0,n){
        ++count[make_pair(uf1.find(i),uf2.find(i))];
    }
    rep(i,0,n){
        cout << count[make_pair(uf1.find(i),uf2.find(i))];
        if(i==n-1) cout << endl;
        else cout << " " ;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 16640
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	string A, B, C;
	cin >> A >> B >> C;

	if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
li = []
for i in range(H):
    li.append(list(input()))

class tree:
    def __init__(self):
        self.num = 0
        self.borw = 0
li2 = [[tree() for i in range(W)]for j in range(H)]
for i in range(H):
    for j in range(W):
        if li[i][j] == "#":
            li2[i][j].borw = 1
        else:
            li2[i][j].borw = 0
for i in range(H):
    for j in range(W):
        numA = 0
        numB = 0
        if i == 0 and j == 0:
            li2[i][j].num = 0
            if li2[i][j].borw == 1:
                li2[i][j].num = 1
        else:
            if i == 0:
                li2[i][j].num = li2[i][j-1].num
                if li2[i][j-1].borw == 0 and li2[i][j].borw == 1:
                    li2[i][j].num += 1
            if j == 0:
                li2[i][j].num = li2[i-1][j].num
                if li2[i-1][j].borw == 0 and li2[i][j].borw == 1:
                    li2[i][j].num += 1
            if i != 0 and j != 0:
                numA = li2[i][j-1].num
                if li2[i][j-1].borw == 0 and li2[i][j].borw == 1:
                    numA += 1
                numB = li2[i-1][j].num
                if li2[i-1][j].borw == 0 and li2[i][j].borw == 1:
                    numB += 1
                li2[i][j].num = min(numA, numB)

print(li2[H-1][W-1].num)

Measured memory_bytes: 45296
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<String>();
  let mut done = false;

  let alf = "abcdefghijklmnopqrstuvwyxz";

  for i in alf.chars() {
    if !x.contains(i) {
      done = true;
      println!("{}", i);
      break;
    }
  }

  if !done {
    println!("None");
  }
}



Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();


        int[] p = new int[a];
        for (int i = 0; i < a; i++) {
            p[i] = sc.nextInt();
        }

        int[] q = new int[b];
        for (int i = 0; i < b; i++) {
            q[i] = sc.nextInt();
        }

        int[] r = new int[c];
        for (int i = 0; i < c; i++) {
            r[i] = sc.nextInt();
        }

        PriorityQueue<Integer> que = new PriorityQueue<>();
        Arrays.sort(p);
        for (int i = 0; i < x; i++) {
            que.add(p[a - 1 - i]);
        }

        Arrays.sort(q);
        for (int i = 0; i < y; i++) {
            que.add(q[b - 1 - i]);
        }

        for (int i = 0; i < c; i++) {
            if (!que.isEmpty() && r[i] > que.peek()) {
                que.poll();
                que.add(r[i]);
            }
        }

        long ans = 0;
        while (!que.isEmpty()) {
            ans += que.poll();
        }

        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    Arrays.sort(s);
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 22100
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc152_a.cpp
 * time   : Sat May  2 18:58:39 2020
 * quest  : A - AC or WA
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m, n;
  cin >> n >> m;
  cout << ((m == n) ? "Yes\n" : "No\n");
  return 0;
}


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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n;	cin >> n;
	ll a[n];
	ll ans = 0;
	ll sum = 0;
	REP(i, n){
		cin >> a[i];
		sum += a[i];
	}

	REP(i, n){
		sum -= a[i];
		ans += sum % MOD * a[i];
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5100
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int n,A,B,a,b,c,N,ans=1e9,L;
vector<PP> v,u;
map<P,int> mp,mp2;
int gcd(int x,int y){
    if(x==0&&y==0)return 1;
    if(y==0)return x;
    return gcd(y,x%y);
}
int main(void){
    cin>>n>>A>>B;
    for(int i=0;i<n-n/2;i++){
        cin>>a>>b>>c;
        v.push_back({{a,b},c});
    }
    for(int i=0;i<n/2;i++){
        cin>>a>>b>>c;
        u.push_back({{a,b},c});
    }
    N=n-n/2;
    for(int i=0;i<(1<<N);i++){
        a=0,b=0,c=0;
        for(int j=0;j<N;j++){
            if(((i>>j)&1)==1){
                a+=v[j].F.F;
                b+=v[j].F.S;
                c+=v[j].S;
            }
        }
        /*L=gcd(a,b);
        a/=L;
        b/=L;*/
        if(mp[{a,b}]==0)mp[{a,b}]=c;
        else mp[{a,b}]=min(mp[{a,b}],c);
    }
    
    
    N=n/2;
    for(int i=0;i<(1<<N);i++){
        a=0,b=0,c=0;
        for(int j=0;j<N;j++){
            if(((i>>j)&1)==1){
                a+=u[j].F.F;
                b+=u[j].F.S;
                c+=u[j].S;
            }
        }
        /*L=gcd(a,b);
        a/=L;
        b/=L;*/
        if(mp2[{a,b}]==0)mp2[{a,b}]=c;
        else mp2[{a,b}]=min(mp2[{a,b}],c);
    }
    v={};
    u={};
    for(auto x:mp){
        v.push_back({x.F,x.S});
    }
    for(auto x:mp2){
        u.push_back({x.F,x.S});
    }
    for(auto x:v){
        for(auto y:u){
            a=b=c=0;
            a=x.F.F+y.F.F;
            b=x.F.S+y.F.S;
            c=x.S+y.S;
            L=gcd(a,b);
            a/=L;
            b/=L;
            //cout<<a<<b<<endl;
            if(a==A&&b==B)ans=min(ans,c);
        }
    }
    if(ans==1e9)cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int n, w[101000], pv;
long long S[101000], MM, SS;
char op[101000];
int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        S[i] = S[i-1] + w[i];
        if(i==n)break;
        scanf("%s",op+i);
    }
    for(i=1;i<=n;i++)if(op[i]=='-')MM += w[i+1];
    for(i=1;i<=n;i++){
        if(op[i]=='-'){
            if(!pv){
                pv = i;
                continue;
            }
            if(MM > S[i] - S[pv] + SS)MM = S[i] - S[pv] + SS;
            SS += w[pv+1];
            pv = i;
        }
    }
    printf("%lld\n",S[n] - MM*2);
}

Measured memory_bytes: 1408
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll ff[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, r, s, p, ans = 0;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    map<char, ll> f;
    f['r'] = p;
    f['p'] = s;
    f['s'] = r;
    for (ll i = 0; i < n; i++)
        if (i < k || t[i - k] != t[i] || !ff[i - k])
            ans += f[t[i]], ff[i] = 1;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1232
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> x >> y;
  rep(i, x + 1) {
    rep(j, x + 1) {
      if (i + j != x) continue;
      ll as = 2 * i + 4 * j;
      if (as == y) {
        Cout("Yes");
        return 0;
      }
    }
  }
  Cout("No");
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  if(N == 2) {
    cout << "-1" << endl;
    return 0;
  }
  if(N == 3) {
    cout << "aa." << endl;
    cout << "..b" << endl;
    cout << "..b" << endl;
    return 0;
  }
  map<int, vector<const char*>> mp;
  mp[4] = {
      "aabd",
      "ccbd",
      "efgg",
      "efhh"
      };
  mp[5] = {
      "aabbc",
      "de..c",
      "de..f",
      "j.hhf",
      "jiigg"
      };
  mp[6] = {
      "abcc..",
      "abdd..",
      "..efgg",
      "..efhh",
      "kk..ij",
      "ll..ij"
      };
  mp[7] = {
      "aabbcc.",
      "dd.ee.f",
      "..g..hf",
      "..g..hi",
      "jj.kk.i",
      "..l..mn",
      "..l..mn"
      };
  vector<string> ans(N, string(N, '.'));
  i64 now = 0;
  while(N > 0) {
    i64 next = 0;
    if(mp.count(N)) {
      next = N;
    }
    else {
      next = 4;
    }
    auto& vec = mp[next];
    rep(i,0,next) {
      rep(j,0,next) {
        ans[i + now][j + now] = vec[i][j];
      }
    }
    N -= next;
    now += next;
  }
  rep(i,0,ans.size()) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

template <class RandomIt>
size_t isort(RandomIt first, RandomIt last, ptrdiff_t g) {
    /* Insertion sort */
    using T=typename RandomIt::value_type;
    size_t count_=0;
    for (RandomIt it=first+g; it<last; ++it) {
        T v=*it;
        RandomIt it2;
        for (it2=it-g; it2>=first&&v<*it2; it2-=g) {
            it2[g] = it2[0];
            ++count_;
        }
        it2[g] = v;
    }
    return count_;
}

template <class RandomIt>
size_t shsort(RandomIt first, RandomIt last) {
    /* Shell sort */
    size_t count_=0, m=last-first;

    vector<ptrdiff_t> g; g.push_back(1);
    for (size_t h=4; h<=m; ++(h*=3))
        g.push_back(h);

    reverse(g.begin(), g.end());

    printf("%zu\n", g.size());
    for (size_t i=0; i<g.size(); ++i) {
        printf("%zu%c", g[i], i<g.size()-1? ' ':'\n');
        count_ += isort(first, last, g[i]);
    }

    return count_;
}

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<int> A(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &A[i]);

    size_t t=shsort(A.begin(), A.end());

    printf("%zu\n", t);
    for (size_t i=0; i<N; ++i)
        printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 6300
#include <iostream>
using namespace std;
int main(void){
    int n,a[100]={0};
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    cout<<a[n-1];
    for(int i=1; i<n; i++){
        int j=(n-1)-i;
        cout<<" "<<a [j];
    }
    cout<<endl;
    
}



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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d",&n);
  cout << 3 * pow(n,2);
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
#define check cnt=0;for(j=0;j<6;j++)if(d[q][j]==d[r][j])cnt++;
#define m tmp=d[r][1];d[r][1]=d[r][3];d[r][3]=d[r][4];d[r][4]=d[r][2];d[r][2]=tmp;
#define y tmp=d[r][0];d[r][0]=d[r][3];d[r][3]=d[r][5];d[r][5]=d[r][2];d[r][2]=tmp;
  
bool same(int d[][6],int q,int r){
 int tmp,cnt,j,a=1,i,k;
 check
   if(cnt==6)a=0;
  
 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    m
   }
   check
   if(cnt==6)break;
   tmp=d[r][0];
   d[r][0]=d[r][1];
   d[r][1]=d[r][5];
   d[r][5]=d[r][4];
   d[r][4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   m
  }
  if(cnt==6)break;
  y y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   m
  }
  a=0;
 }
  
 if(cnt==6)return true;
 return false;
}

int main(){
 int n,judge=0;
 cin >> n;
 int d[n][6];
  
 for(int i=0;i<n;i++){
  for(int j=0;j<6;j++){
   cin >> d[i][j] ;
  }
 }
  
 for(int q=0;q<n-1;q++){
  for(int r=q+1;r<n;r++){
  if(same(d,q,r))judge++;
  }
 }

 if(judge>0)cout << "No" << endl ;
 else cout << "Yes" << endl ;
  
 return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

int r, s, p;

int calc(string a, int sz){
  int sum=0, ch=0;
  rep(i, sz){
    if(ch!=0) ch = 0;
    else {
    if(i!=sz-1){
      if(a.at(i)==a.at(i+1)) ch=1;
    if(a.at(i)=='r') sum+=p;
    else if(a.at(i)=='s') sum+=r;
    else if(a.at(i)=='p') sum+=s;
      
    }
    else if(a.at(i)=='r') sum+=p;
    else if(a.at(i)=='s') sum+=r;
    else if(a.at(i)=='p') sum+=s;
  }
    //cout << sum << endl;
  }
  //ch = 0;
  return sum;
}

int main(){
  int n, k, i, j, sum=0; string t;
  cin >> n >> k >> r >> s >> p >> t;
  string a=""; int sz, e;
  for(i=0; i<k; i++){
    j = i;
    while(j<n){
      a += t.at(j);
      j += k;
    }
    sz = a.size();
    //cout << sz << endl;
    e = calc(a, sz);
    //cout << e << endl;
    sum += e; 
    a = "";
  }
  cout << sum << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    bool res = false;
    while(n>0){
        if(n %10 == 7){
            res =true;
            break;
        }
        n /= 10;
    }
    if(res) cout<<"Yes";
    else cout<<"No";
    

    return 0;
}


Measured memory_bytes: 3132
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,q;
    cin>>n>>q;
    int t=0;
    rep(i,q){
        int y,k;
        cin>>y>>k;
        if(y){
            t+=k;
        }
        else{
            if((k+t)%n==0)cout<<n<<endl;
            else cout<<(k+t)%n<<endl;
        }
    }
}


Measured memory_bytes: 3208
<?php
$n=trim(fgets(STDIN));
for($i=0;$i<$n;$i++){
  list($a,$b,$c)=explode(' ',trim(fgets(STDIN)));
  if($b<$a){$d=$a;$a=$b;$b=$d;}
  if($c<$b){$d=$b;$b=$c;$c=$d;}
  $e=$a*$a+$b*$b-$c*$c;
  echo (!$e)?'YES':'NO',PHP_EOL;
}

Measured memory_bytes: 15392
#include <stdio.h>

int main(void) 
{
  int a,b;
    
  scanf("%d%d",&a,&b);
  
  int c = a * b;
   
  if (c % 2 == 0) {
    printf("Even");
  }
      
  else {
    printf("Odd");
  }
}

Measured memory_bytes: 128
N=int(input())
if N%2==0:
	print(int((N-2)*N/2))
	for i in range(N):
		for j in range(i+1,N):
			if  (i+j+2 != N+1):
				print(i+1,j+1)
else:
	print(int((N-3)*(N-1)/2)+(N-1))
	for i in range(N-1):
		for j in range(i+1,N-1):
			if  (i+j+2 != N):
				print(i+1,j+1)
		print(i+1,N)


Measured memory_bytes: 3612
const main = () => {
  const xab = getParams()
      , x = xab[0]
      , a = xab[1]
      , b = xab[2];
  console.log(solve(x, a, b));
};

const getParams = () =>
  getStdin().split('\n').map(Number);

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = (x, a, b) =>
  (x - a) % b;

main();


Measured memory_bytes: 21064
N = int(input())
S = input()
L=['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']
A = []
 
for c in S:
  i = L.index(c)
  A.append(L[(i + N)%26])
  
print(''.join(A))


Measured memory_bytes: 39408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		String s = sc.next();
		String x = "";
		for(int i = 0; i < s.length(); i++)
		{
			if(i == k - 1)
				x += (char)(s.charAt(i) + 32);
			else
				x += s.charAt(i);
		}
		
		System.out.println(x);
	}
}


Measured memory_bytes: 21844