akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
typedef long long ll;
const int O = 2048, M = 4000, MX = 4096, N = 200064, MOD = 1000000007;
inline void inc(int &a) {if (a >= MOD) a -= MOD;}
inline ll inv(ll x) {
	ll s = 1;
	for (int k=MOD-2; k; k>>=1, x=x*x%MOD)
		if (k&1) s=s*x%MOD;
	return s;
}

int f[MX][MX], A[N], B[N];
ll fac[MX*2], ifac[MX];

int main() {
	fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
	for (int i = 2; i <= 2*M; i++)
		fac[i] = fac[i-1] * i %MOD;
	ifac[M] = inv(fac[M]);
	for (int i = M; i > 2; i--)
		ifac[i-1] = ifac[i] * i %MOD;
	int n, a, b, mx = 0;
	ll ans = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d",&a,&b);
		ans = (ans - fac[a+b<<1] * ifac[a<<1] %MOD * ifac[b<<1]) %MOD;
		f[O-a][O-b]++;
		if (a > mx) mx = a;
		if (b > mx) mx = b;
		A[i] = a; B[i] = b;
	}
	for (int i = O-mx; i <= O+mx; i++)
		for (int j = O-mx; j <= O+mx; j++)
			inc(f[i][j] += f[i][j-1] + f[i-1][j]);
	while (n--) ans += f[O+A[n]][O+B[n]];
	ans = ans %MOD * ((MOD+1)/2) %MOD;
	printf("%lld\n",ans<MOD ? ans : ans+MOD);
	return 0;
}

Measured memory_bytes: 66176
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
	multiset<int> cpp; 
	int q, com, o, r;
	scanf("%d", &q);

	while (q--)
	{

		scanf("%d%d", &com, &o);
		switch (com)
		{
		case 0:
			cpp.insert(o);
			printf("%d\n", cpp.size());
			break;

		case 1:
			printf("%d\n", cpp.count(o));
			break;

		case 2:
			cpp.erase(o);
			break;
		case 3:
			scanf("%d", &r);
			set<int>::iterator prev = cpp.lower_bound(o);
			set<int>::iterator next = cpp.upper_bound(r);
			while (prev != next)    
			{
				printf("%d\n", *prev);
				prev++;
			}
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 11924
a,b,k = (int(i) for i in input().split())
for i in range(k):
    if(i%2==0):
        if(a%2==1):
            a -=1
        b += a/2
        a /= 2
    else:
        if(b%2==1):
            b -= 1
        a += b/2
        b /= 2
print(int(a),int(b))

Measured memory_bytes: 3060
<?php

fscanf(STDIN, "%d", $num);
$bit = decbin(abs($num));
$bstr = array_reverse(str_split($bit));

$buff = 0;
foreach($bstr as $n => $value){
    if($buff > 0){
        if($value == 1){
            $bstr[$n] = 0;
            $value = 0;
        }else{
            $bstr[$n] = 1;
            $value = 1;
            $buff--;
        }
    }
    if(((($num < 0) && ($n % 2 == 0))|| (($num >= 0) && $n % 2 == 1)) && $value == 1){
        $buff += 1;
    }
    $last = $n;
}


while($buff > 0){
    if(((($num < 0) && ($last % 2 == 1))|| (($num >= 0) && $last % 2 == 0))){
        $bstr[] = 1;
    }else{
        $bstr[] = 1;
        $buff--;
    }
    $last++;
}


echo implode("", array_reverse($bstr));


Measured memory_bytes: 5240
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N;
  cin >> N;
  map<string, int> m;

  rep (i, N) {
    string s;
    cin >> s;
    if(m.count(s) == 0) {
      m.insert(make_pair(s, 1));
    } else {
      int preValue = m.at(s);
      m.erase(s);
      m.insert(make_pair(s, preValue + 1));
    }
  }

  int M;
  cin >> M;

  rep (i, M) {
    string s;
    cin >> s;
    if(m.count(s) == 0) {
      m.insert(make_pair(s, -1));
    } else {
      int preValue = m.at(s);
      m.erase(s);
      m.insert(make_pair(s, preValue - 1));
    }
  }

  int maxValue = 0;
  for (auto pair : m){
    // DEBUG(pair.second);
    maxValue = max(maxValue, pair.second);
  }

  cout << maxValue << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, t; cin >> a >> b >> t;
  cout << t/a*b << endk;
  return 0;
}


Measured memory_bytes: 3648
# coding: utf-8
# Your code here!
import sys,math
(A,B,H,M) = map(int,input().split())
print(A,B,H,M,file=sys.stderr)

# 2針の回転角度
rad1 = H*(30) + M*(0.5)
rad2 = M*(6)

# 内角
rad = abs(rad1 - rad2)
ans = 0

# 対辺の長さ
if rad == 180:
    ans = A+B
else:
    #rad = rad % 180
    ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(rad)))

print(rad1,rad2,rad,ans,file=sys.stderr)
print(ans)


Measured memory_bytes: 9512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (N, i) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ans = N - i + 1;

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28136
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        // 主処理
        int result = (int) Math.ceil(n / 2.0);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	char s[100];
	cin>>s;
	int k = strlen(s);
	for(int i = 0; i < k-8; i++)
		cout<<s[i];
	cout<<endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define pii pair<int, int>
#define pb push_back
#define pli pair<ll, int>
#define pil pair<int, ll>
#define clr(a, x) memset(a, x, sizeof(a))

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TREE tree<pli, null_type, greater<pli>, rb_tree_tag, tree_order_statistics_node_update>
TREE T;
*/

int a, p;
int main() {
	scanf("%d%d", &a, &p);
	printf("%d\n", (a * 3 + p) / 2);
	return 0;
}



Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	ans := 0

	var f func(a int)
	f = func (a int) {
		e := a*10
		e3,e5,e7 := e+3,e+5,e+7
		if n >= e3 {
			if check(e3) { ans++ }
			f(e3)
		}
		if n >= e5 {
			if check(e5) { ans++ }
			f(e5)
		}
		if n >= e7 {
			if check(e7) { ans++ }
			f(e7)
		}
	}

	f(3)
	f(5)
	f(7)

	fmt.Println(ans)
}

func check(a int) bool {
	c3,c5,c7 := 0,0,0
	for a != 0 {
		switch a%10 {
		case 3:
			c3++
		case 5:
			c5++
		case 7:
			c7++
		}
		a /= 10
	}
	if c3>0&&c5>0&&c7>0 {
		return true
	}
	return false
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root, NIL;

void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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

void inorder(Node a){
  if ( a == NIL ) return;
  inorder(a->left);
  printf(" %d", a->key);
  inorder(a->right);
}

void preorder(Node a){
  if ( a == NIL ) return;
  printf(" %d", a->key);
  preorder(a->left);
  preorder(a->right);
}


int main(){
  int i,n,k;
  char c[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( strcmp(c, "insert") == 0 ){
      scanf("%d", &k);
      insert(k);
    } else if ( strcmp(c, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 25228
N=int(input())
H=list(map(int,input().split()))
min = 1e12
success = True
for i in range(N):
    if H[N-1-i] <= min + 1:
        if H[N-1-i] < min:
            min = H[N-1-i]
    else:
        success = False
        break
print('Yes' if success else 'No')


Measured memory_bytes: 85316
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=str(input())

rec=[]
ans=0

def win(hand):
    if hand=='r':
        return ['p',P]
    elif hand=='s':
        return ['r',R]
    else:
        return ['s',S]

def gap(hand):
    if hand=='r':
        return 's'
    elif hand=='s':
        return 'p'
    else:
        return 'r'


for i in range(N):
    win_hand=win(T[i])[0]
    win_point=win(T[i])[1]
    same_hand=T[i]
    if 0<=i<=K-1:
        rec.append(win_hand)
        ans+=win_point
    else:
        if win_hand!=rec[i-K]:
            rec.append(win_hand)
            ans+=win_point
        else:
            if N-K-1<i<=N-1:
                rec.append(same_hand)#不要
            else:
                next_win_hand=win(T[i+K])[0]
                rec.append(gap(next_win_hand))

    #print(ans)

#print(rec)
print(ans)




Measured memory_bytes: 4212
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}

fn main() {
    let mut input : Vec<i32> = rd_vec();
    input.sort();
    let answer = (input[2] * 10) + input[1] + input[0];
    println!("{}", answer);
}


Measured memory_bytes: 4352
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.LongStream;

import javax.swing.Spring;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        String[] s = nstrs(N);
        Map<String, Long> count = new HashMap<>();
        for (String e: s) {
            String sorted = sort(e);
            if (!count.containsKey(sorted)) {
                count.put(sorted, 1L);
            } else {
                count.put(sorted, count.get(sorted) + 1L);
            }
        }
        
        long ans = 0;
        for (Entry<String, Long> e: count.entrySet()) {
            long p = e.getValue();
            ans += p * (p-1) / 2;
        }
        so.println(ans);
    }
    
    private static String sort(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        return String.valueOf(c);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 54504
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
#define prv(i)((i+n-1)%n)
#define nxt(i)((i+1)%n)

int b[100000];
int n; string s;

bool bfs(int a, int m, int c) {
	memset(b, -1, sizeof(b));
	b[prv(0)] = a; b[0] = m; b[nxt(0)] = c;
	queue<int>que; que.push(prv(0)); que.push(nxt(0));
	while (!que.empty()) {
		int p = que.front(); que.pop();
		if (b[p]) {//本当
			if (~b[prv(p)] && !~b[nxt(p)]) {
				if (s[p] == 'o')b[nxt(p)] = b[prv(p)];
				else b[nxt(p)] = !b[prv(p)];
				que.push(nxt(p));
			}
			if (~b[nxt(p)] && !~b[prv(p)]) {
				if (s[p] == 'o')b[prv(p)] = b[nxt(p)];
				else b[prv(p)] = !b[nxt(p)];
				que.push(prv(p));
			}
		}
		else {//うそ
			if (~b[prv(p)] && !~b[nxt(p)]) {
				if (s[p] == 'o')b[nxt(p)] = !b[prv(p)];
				else b[nxt(p)] = b[prv(p)];
				que.push(nxt(p));
			}
			if (~b[nxt(p)] && !~b[prv(p)]) {
				if (s[p] == 'o')b[prv(p)] = !b[nxt(p)];
				else b[prv(p)] = b[nxt(p)];
				que.push(prv(p));
			}
		}
	}
	rep(i, n) {
		if (b[i]) {
			if (!((s[i] == 'o'&&b[prv(i)] == b[nxt(i)]) || (s[i] == 'x'&&b[prv(i)] != b[nxt(i)])))return false;
		}
		else {
			if (!((s[i] == 'o'&&b[prv(i)] != b[nxt(i)]) || (s[i] == 'x'&&b[prv(i)] == b[nxt(i)])))return false;
		}
	}
	return true;
}
signed main() {
	cin >> n >> s;
	rep(i, 2)rep(j, 2)rep(k, 2) {
		if (bfs(i, j, k)) {
			rep(t, n) {
				if (b[t])printf("S");
				else printf("W");
			}
			printf("\n"); return 0;
		}
	}
	puts("-1");
}

Measured memory_bytes: 896
# return x where
#   (when trueside<falseside)
#     [trueside,falseside) and yield(x)==true and (yield(x+tol)==false or falseside <= x+tol)
#   (when falseside<trueside)
#     (falseside,trueside] and yield(x)==true and (yield(x-tol)==false or x-tol <= falseside) 
# if trueside and falseside and tol is integer then do integer binary search
# note: neither yield(trueside) nor yield(falseside) were not called
def bsearch(trueside,falseside,tol=10**(-9))
    ok,ng=trueside,falseside
    div=tol.is_a?(Integer) ? 2 : 2.0
    while((ok-ng).abs>tol) do
        mid=(ng+ok)/div
        if(yield(mid))
            ok=mid
        else
            ng=mid
        end
    end
    return ok
end

def bsearch_int(trueside,falseside,&block)
    return bsearch(trueside,falseside,1,&block)
end


N,A,B=gets.split.map(&:to_i)
H=N.times.map{gets.to_i}
AMB=A-B

p bsearch_int(10**9,0){|i|
    count=0
    ib=i*B
    H.each do |h|
        h-=ib
        next if h<=0
        count+=(h+AMB-1)/AMB
    end
    count<=i
}





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

int main() {
    int n;
    cin >> n;
    
    int a=0, w=0, t=0, r=0;

    string s;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s=="AC") a++;
        else if(s=="WA") w++;
        else if(s=="TLE") t++;
        else if(s=="RE") r++;
    }
    
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

Measured memory_bytes: 3604
using System;

namespace ABC065B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            int[] next = new int[N + 1];
            bool[] visited = new bool[N + 1];

            for (int i = 1; i <= N; i++)
            {
                next[i] = Int32.Parse(Console.ReadLine());
            }

            int cur = 1;
            int res = 0;

            while (cur != 2)
            {
                if (visited[cur])
                {
                    res = -1;
                    break;
                }
                res++;
                visited[cur] = true;
                cur = next[cur];
            }

 
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 15200
/* ----------------------------
 * ABC 91 D カンニングして解答
 * ---------------------------- */
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

// digit は0始まり.
bool isBitOn(int target, int digit);
// digit 以下のビットを取得する
int getUnderBits(int target, int digit);
// digit だけ bit が立ったマスクを取得する
int getOnMask(int digit);
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	// ソート
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	// 回答編
	int ans = 0;
	
	// 余裕をもって、c を n の4倍の大きさで用意する
	// 使用するのは 0 ~ 3n-1
	vector<int> c(4*n);
	// 0 <= (a, b) < pow(2, 28)
	for(int i = 0; i < 29; i++){
		// c のn-1番目までを更新してソート
		for(int j = 0; j < n; j++){
			c[j] = getUnderBits(b[j], i);
		}
		sort(c.begin(), c.begin() + n);
		// c の n番目から　2n-1 番目までを更新
		for(int j = 0; j < 2*n; j++){
			c[n+j] = c[j] + getOnMask(i + 1);
		}
		// total の用意
		long long total = 0;
		for(int j = 0; j < n; j++){
			// a の i 桁以下を用意
			int y = getUnderBits(a[j], i);
			// 和が範囲内に収まる要素の数を数える
			total += lower_bound(c.begin(), c.begin() + 3 * n, (4<<i)-y)
					- lower_bound(c.begin(), c.begin() + 3 * n, (3<<i)-y);
		}
		// total が奇数であれば ans のこの桁を立てる
		// 1 を奇数個 xor すると 1
		// , 1 を偶数個 xor すると 0
		if(total%2) ans += getOnMask(i);
	}
	
	cout << ans << endl;
	return 0;
}
// digit は0始まり.
bool isBitOn(int target, int digit){
	return target & (1 << digit);
}
// digit 以下のビットを取得する
int getUnderBits(int target, int digit){
	// i.e.
	// getUnderBits(0b11111111, 3)
	// returns     0b00001111
	return target & ((1 << (digit + 1)) - 1);
}
// digit だけ bit が立ったマスクを取得する
int getOnMask(int digit){
	return 1 << digit;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void){
    int H,W,i,j;

    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(i==1||i==H||j==1||j==W)
                    putchar('#');
                else
                    putchar('.');
            }
            puts("");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 588
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
import collections
import math
import itertools
import heapq as hq

s = input()
sr = s[::-1]
l = len(s)
cnt=0
for i in range(l):
    if s[i] != sr[i]:
        cnt+=1
print(cnt//2)


Measured memory_bytes: 9416
#include<iostream>
#include<cstdio>
using namespace std;
int w[100],m[51]={0};
int x,y,z=0,r=0;
int main()
{
	cin>>x>>y;
	for(int i=0;i<x;i++)
    {
    	cin>>w[i];
    	m[w[i]]++;
    }
    	for(int i=50;i>0;i--)
    	{
    		if(m[i]!=0&&r<y)  {
    			m[i]--;
    			z+=i;
				i++;
				r++;
    		}
    	}
    cout<<z<<endl;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, d; cin >> n >> d;
    int x[10][20];
    int ans = 0;
    REP(i, n) {
        REP(k, d) cin >> x[i][k];
    }
    REP(i, n - 1) {
        FOR(k, i + 1, n) {
            double sum = 0;
            REP(l, d) sum += (x[i][l] - x[k][l]) * (x[i][l] - x[k][l]);
            if (ceil(sqrt(sum)) == floor(sqrt(sum))) ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int x,y;
int calc(int pp){
  int p = 0;
  for(int i = 1 ; i < 1000 ; i++){
    if(i*(100+x)/100 == pp){
      p = i;
      break;
    }
  }
  return p*(100+y)/100;
}

int main(){
  int s;
  while(cin >> x >> y >> s,(x|y|s)){
    int max = 0;
    for(int i = 1 ; i <= s/2 ; i++){
      max = std::max(max,calc(i)+calc(s-i));
    }
    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

int32_t main(){
    int n, x;
    cin >>n >>x;
    if(x == 1 or x == 2* n - 1)
        return cout <<"No" <<endl, false;
    cout <<"Yes" <<endl;
    int pt = 2;
    for(int i = 0; i < n - 2; i ++){
        if(pt == x)
            pt ++;
        cout <<pt <<' ';
        pt ++;
    }
    cout <<1 <<' ' <<x <<' ' <<2* n - 1 <<' ';
    for(int i = 0; i < n - 2; i ++){
        if(pt == x)
            pt ++;
        cout <<pt <<' ';
        pt ++;
    }
    return false;
}


Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
  int i, j, n, m, min, x=0, a[100];

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

  for(i=0; i<n; i++)
    {
      min=i;
      for(j=i; j<n; j++)
	{
	  if(a[j]<a[min])
	    min = j;
	}
      if(min != i)
	{
	  m = a[i];
	  a[i] = a[min];
	  a[min] = m;
	  x++;
	}
    }
  
  for(i=0; i<n; i++)
    {
      printf("%d", a[i]);
      if(i+1<n) printf(" ");
    }
  printf("\n%d\n", x);
      
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
 
int N;
vector< int > A;
int64 dp[2000][2000];
inline int NEXT(int a){ return((a + 1) % N); }
inline int PREV(int a){ return((a + N - 1) % N); }
 
inline int64 rec(int left, int right, bool flag) {
  if(left == right) return(flag ? 0 : A[left]);
  if(~dp[left][right]) return(dp[left][right]);
  int64 ret = 0;
  if(flag) {
    if(A[left] < A[right]) ret = rec( left, NEXT(right), false);
    else ret = rec(PREV(left), right, false);
  } else {
    ret = max( rec(PREV(left), right, true) + A[left], rec(left, NEXT(right), true) + A[right]);
  }
  return(dp[left][right] = ret);
}
 
 
int main()
{
  fill_n( *dp, 2000 * 2000, -1);
 
  cin >> N;
  A.resize(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    ret = max( ret, rec( PREV(i), NEXT(i), true) + A[i]);
  }
  cout << ret << endl;
 
  return(0);
}

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

void solve() 
{ 
int  n;
cin>>n;
cout<<n*n*n;
}
 

int main(){

		solve();
		cout<<endl;		
}
		

	

		

 



Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int a[200003];
int main()
{
	int i, k, n, b, c;
	while (cin >>k>>n)
	{
		cin >> a[0]>> a[1];
		b = a[1] - a[0];
		for (i = 2; i < n; i++)
		{
			cin >> a[i];
			c = a[i] - a[i - 1];
			if (c > b)
				b = c;
		}
		a[0] += k;
		c = a[0] - a[n - 1];
		if (c > b)
			b = c;
		k -= b;
		cout << k << '\n';
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[100001], N, h[100001];

int thunder(int ind){
    if(ind==N){
        return 0;
    }
    if(ind==(N-1)){
        return abs(h[N-1]-h[ind-1]);
    }
    if(dp[ind] != -1){
        return dp[ind];
    }
    int tmp = min(abs(h[ind]-h[ind-1])+thunder(ind+1), abs(h[ind+1]-h[ind-1])+thunder(ind+2));
    return dp[ind]=tmp;
}

signed main(){
    memset(dp, -1, sizeof(dp));
    cin>>N;
    for(int i=0; i < N; i++){
        cin>>h[i];
    }
    cout<<thunder(1)<<endl;
    return 0;
}


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

ll N;
int cnt = 0;

void dfs(ll x, int a, int b, int c) {
  if (x > N) return;
  if (a >= 1 && b >= 1 && c >= 1) cnt++;
  dfs(10 * x + 3, a + 1, b, c);
  dfs(10 * x + 5, a, b + 1, c);
  dfs(10 * x + 7, a, b, c + 1);
}

int main() {
  cin >> N;
  dfs(0, 0, 0, 0);
  cout << cnt << endl;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ul N,i,ans;
vector<ul> T;

ul gcd(ul a,ul b) {
  if(b==0) return a;
  return gcd(b,a%b);
}

inline void solve(){
  IN(N);
  T.resize(N);
  REP(i,N){
    IN(T[i]);
    if(i==0)ans=T[i];
    else ans=T[i]/gcd(ans,T[i])*ans;
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 384
import sys
n = sys.stdin.readline()
a = list(map(int, sys.stdin.readline().split()))
ans = "APPROVED"
for i in a:
  if i%2==0:
    if i%3==0:
      continue
    elif i%5==0:
      continue
    else:
      ans = "DENIED"
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
ll h,w;
cin>>h>>w;
graph g1(10);
rep(i,10){
rep(j,10){
ll a; cin>>a;
g1.add_edge(i,j,a);
}
}
ll b[10]={};
ll a[h][w]={};
rep(i,h){
rep(j,w){
cin>>a[i][j];
b[a[i][j]]++;}}
ll ca = 0;
rep(i,10){
g1.dijkstra(i);
ca += g1.d[1]*b[i];
}
cout << ca << endl;}


Measured memory_bytes: 3896
n,k=map(int,input().split())
d=dict()
for i in range(n):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=b
  else:
    d[a]+=b
d=list(d.items())
d.sort()
cnt=0
for i in range(n):
  if cnt+d[i][1]<k:
    cnt+=d[i][1]
  else:
    print(d[i][0])
    exit()

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(T, name, beginValue, endCondValue) \
  for (T name = beginValue; name < endCondValue; ++name)

// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);

int main(){
  int r, c;
  cin >> r >> c;
  VECTOR_DIM2(int, data, r, c, 0) // 表の行数rと列数c、r × c の要素を持つ表
  REP(int, i, 0, r) {
    REP(int, j, 0, c) {
      cin >> data[i][j];
    }
  }

  VECTOR_DIM1(int, colTotals, c+1, 0);
  REP(int, i, 0, r + 1) {
    int rowTotal = 0;
    if (i < r) {
      REP(int, j, 0, c + 1) {
        if (j < c) {
          rowTotal += data[i][j];
          colTotals[j] += data[i][j];
          cout << data[i][j] << " ";
        } else {
          colTotals[j] += rowTotal;
          cout << rowTotal << endl;
        }
      }
    } else {
      int rowTotal = 0;
      REP(int, j, 0, c + 1) {
        if (j < c) {
          rowTotal += colTotals[j];
          cout << colTotals[j] << " ";
        } else {
          cout << rowTotal << endl;
        }
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3204
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N = input()
l = len(N)
if l == 1:
    print(N)
    exit()
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)


Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n, k; cin >> n >> k;
    int A[n], B[n];
    for (int i = 0; i < n; i++) cin >> A[i] >> B[i];
    long long ans = 0;
    for (int i = 0; i < n; i++) if ((A[i] | k) == k) ans += B[i];
    for (int e = 1; e <= k; e *= 2) {
        if ((e & k) == 0) continue;
        int target = (k - e) | (e - 1);
        long long sum = 0;
        for (int i = 0; i < n; i++) if ((A[i] | target) == target) sum += B[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
h1, m1, h2, m2, k = map(int, input().split())

h3, m3 = divmod(k, 60)

dh = h2 - h3
dm = m2 - m3
if dm < 0:
    dh -= 1
    dm = 60 + dm



ah = dh - h1
am = dm - m1
if am < 0:
    ah -= 1
    am = 60 + am

ans = ah * 60 + am
print(ans)

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

int main(){
  int n,b,d=0,j=0;
  cin >> n;
  vector <int> a(n);
  vector <int> c(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  while(j<n){
    cin >> b;
    d += b;
    j++;
  }
  for(int i=0; i<n-1; i++){
    cin >> c[i];
  }
  for(int i=0; i<n-1; i++){
      if(a.at(i+1)==a.at(i)+1){
        d += c[a[i]-1];
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, a: "List[int]"):
    t = 1
    c = 0
    for i in range(N):
        if a[i] != t:
            c += 1
        else:
            t += 1

    if t == 1:
        print(-1)
    else:
        print(c)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

int main(){
	int x;
	cin>>x;
	
	if(x>=400&&x<=599)
	    cout<<8;
	else if(x>=600&&x<=799)
	    cout<<7;
	else if(x>=800&&x<=999)
	    cout<<6;
	else if(x>=1000&&x<=1199)
	    cout<<5;
	else if(x>=1200&&x<=1399)
	     cout<<4;
    else if(x>=1400&&x<=1599)
         cout<<3;
    else if(x>=1600&&x<=1799)
         cout<<2;
    else
         cout<<1;
        
    return 0;
} 

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<pair<int, int>> xy(N);
    int x, y;
    for(int i = 0; i < N; i++){
        cin >> x >> y;
        xy[i] = make_pair(x, y);
    }

    if(N == 1){
        cout << 1 << endl;
        return 0;
    }

    int ans = 1000000;
    sort(xy.begin(), xy.end());
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int p = xy[j].first - xy[i].first;
            int q = xy[j].second - xy[i].second;

            int cost = 0;
            vector<bool> check(N, false);
            for(int k = 0; k < N; k++){
                if(check[k]){
                    continue;
                }
                cost++;
                check[k] = true;
                int nextX = xy[k].first + p;
                int nextY = xy[k].second + q;
                for(int r = k; r < N; r++){
                    auto temp = xy[r];
                    if(temp.first == nextX && temp.second == nextY){
                        check[r] = true;
                        nextX += p;
                        nextY += q;
                    }
                }
            }

            ans = min(ans, cost);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP priority_queue
#define heap(T) priority_queue<T,vector<T>,greater<T> > 
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=500005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
const int BufferSize=1<<25;
char buffer[BufferSize],*Bufferhead,*Buffertail;
int Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T> inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,s[N],t[N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		if(x==1) s[y]=1;
		if(y==n) t[x]=1;
	}
	for(int i=2;i<n;i++)
		if(s[i]&&t[i]){puts("POSSIBLE");return 0;}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 3200
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if (b < a) {
      for (int i = 0; i < a; i++) {
        System.out.print(b);
      }
    } else {
      for (int j = 0; j < b; j++) {
        System.out.print(a);
      }
    }
  }
}

Measured memory_bytes: 21716
m=10**9+7
f=max
r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()))
	s=-1
	i=j=1
	while j<=x and i+j<=y:
		i,j=j,i+j
		s+=1
	if x==1 or y<3:print(1,x*y%m)
	else:
		a=f(0,(y-j)//i+1)+f(0,(x-j)//i+1)
		i=j=1
		for c in r(s):
			k,l=j,i+j*2
			for _ in r(s-c):k,l=l,k+l
			if x>=k:a+=f(0,(y-l)//k+1)
			if y>=k:a+=f(0,(x-l)//k+1)
			i,j=j,i+j
		print(s+1,a%m)

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

using namespace std;

typedef long long ll;

ll n,m;
ll y[200];

bool solve(){
	cin >> n;
	if(n == 0)return false;
	ll x[200];
	for(int i=0;i<n;i++){
		cin >> x[i];
	}
	char s[200];
	cin >> s;
	m = strlen(s);
	int num = 0;
	for(int i=0;i<m;i++){
		if(s[i] >= 'a'){
			num = s[i] - 71;
		}else{
			num = s[i] - 65;
		}
		if(num - x[i%n] >= 0){
			cout << (char)(y[num - x[i%n]]);
		}else{
			cout << (char)(y[num - x[i%n] + 52]);
		}
	}
	cout << endl;
	return true;

}

int main(){
	for(int i=0;i<26;i++){
		y[i] = 65 + i;
	}
	for(int i=26;i<52;i++){
		y[i] = 97 + i - 26;
	}
	while(solve()){}
}


Measured memory_bytes: 3084
//     _/    _/  _/                        _/                
//    _/    _/      _/_/_/      _/_/_/  _/_/_/_/    _/_/_/   
//   _/_/_/_/  _/  _/    _/  _/    _/    _/      _/    _/    
//  _/    _/  _/  _/    _/  _/    _/    _/      _/    _/     
// _/    _/  _/  _/    _/    _/_/_/      _/_/    _/_/_/ 
// C++ Conpetitive Programming Template 
// Ver 1.1 (codename: Hinata)
// Last Modified : 2019-05-28
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    ll N;cin >> N;
    out(180 * (N - 2));
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, Ans1 = 0, Ans2 = 0, Ans = 0;cin >> N;
map<ll, ll> M;

rep(i, 0, N){
    ll a;cin >> a;
    M[a]++;
}

for(auto x : M ){

    if(x.second >= 4)Ans = x.first*x.first;
  
    if(x.second >= 2 && Ans2 <= Ans1){Ans2 = x.first;continue;}

    if(x.second >= 2 && Ans2 > Ans1){Ans1 = x.first;continue;}


}

cout << max(Ans, Ans1*Ans2);

}


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

int b()
{
    int n, k;
    std::cin >> n >> k;
    
    std::vector<bool> ans(n, true);
    
    for(int i = 0; i < k; i++)
    {
        int d = 0;
        std::cin >> d;
        for(int k = 0; k < d; k++)
        {
            int p;
            std::cin >> p;
            ans[p - 1] = false;
        }
    }
    
    int num = 0;
    for(int i = 0; i < n; i++)
    {
        if(ans[i] == true)
        {
            num++;
        }
    }
    
    std::cout << num << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    b();
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i=0; i<n; i++) scanf("%d", a+i);
  bool check = true;
  for (int i=0; i<n; i++) {
    if (a[i]%2 != 0)
      continue;
    if (a[i]%3 == 0 || a[i]%5 == 0)
      continue;
    check = false;
    break;
  }
  if (check) printf("APPROVED\n");
  else printf("DENIED\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
#define rep(i,s,n)for(ll i = s;i<n;i++)

char s[Z];
int main() {
	cin >> s;

	ll i = 0;
	ll c[26] = {};
	while (*(s + i)) c[*(s + i++) - 'a']++;

	i = 0;
	bool exist = true;
	while (i < 26) exist &= (c[i++] <= 1);

	cout << (exist ? "yes" : "no") << endl;

	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

if n == 1:
  print(0)
  exit()

happy = n
for i in range(n-1):
  if s[i] == 'R' and s[i+1] == 'L':
    happy -= 2

if s[0] == 'L':
  happy -= 1
if s[-1] == 'R':
  happy -= 1

print(min(n-1, happy + 2 * k))

Measured memory_bytes: 39408
# ABC112B - Time Limit Exceeded
import sys
input = sys.stdin.readline

def main():
    n, t = tuple(map(int, input().rstrip().split()))
    data = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    match = {i[0] for i in data if i[1] <= t}
    if match == set():
        print("TLE")
    else:
        print(min(match))


if __name__ == "__main__":
    main()

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int X[55];
//! [i枚目までの中で][j枚選んで][和をkにする]=組み合わせの数
ll dp[55][55][2505];

int main()
{
    int N, A;
    cin >> N >> A;
    REP(i, N)
    {
        cin >> X[i];
    }
    dp[0][0][0] = 1;
    FOR(i, N + 1, 1)
    {
        REP(j, i + 1)
        {
            REP(k, 2505)
            {
                dp[i][j][k] = dp[i - 1][j][k];
                if (k - X[i - 1] >= 0 && j > 0)
                {
                    dp[i][j][k] += dp[i - 1][j - 1][k - X[i - 1]];
                }
            }
        }
    }

    ll sum = 0;
    REP(i, N)
    {
        sum += dp[N][i + 1][(i + 1) * A];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 53504
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    vector<int> cnt(9, 0);
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        a /= 400;
        a = min(a, 8);
        ++ cnt[a];
    }

    int ans = 0;
    for(int i=0; i<8; ++i){
        if(cnt[i] > 0)
            ++ ans;
    }
    cout << max(1, ans) << ' ';

    ans += cnt[8];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define M 1000000007

using namespace std;

ll go(ll h[],ll l,ll r,ll dp[],ll k)
{
    if(l==r)
    return 0;
    else if(dp[l]!=-1)
    return dp[l];
    else
    {
        ll ans=INT_MAX;
        for(ll i=l+1;i<=l+k&&i<=r;++i)
        {
            ans=min(ans,abs(h[l]-h[i])+go(h,i,r,dp,k));
        }
        dp[l]=ans;
        return ans;
    }
}
int main() 
{
	IOS	
	ll n,k;
	cin>>n>>k;
	ll h[n];
	ll dp[n];
	memset(dp,-1,sizeof dp);
	for(ll i=0;i<n;++i)cin>>h[i];
	cout<<go(h,0,n-1,dp,k);
}

Measured memory_bytes: 11136