akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.*;

public class Main{
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		while (true) {
			int W = sc.nextInt();
			int n = sc.nextInt();
			if (W == 0 && n == 0)
				break;
			long[] accum = new long[n + 1];
			int[] x = new int[n];
			for (int i = 0; i < n; ++i) {
				x[i] = sc.nextInt();
			}
			for (int i = 0; i < n; ++i) {
				accum[i + 1] = accum[i] + x[i];
			}
			int lack = 0;
			int gap = 1;
			outer: for (int i = 15; i >= -1; --i) {
				int ngap = gap + (i >= 0 ? (1 << i) : 0);
				int[] vis = new int[n + 1];
				vis[0] = 1;
				vis[1] = -1;
				for (int j = 0; j < n; ++j) {
					vis[j] += (j > 0 ? vis[j - 1] : 0);
					if (vis[j] > 0) {
						if (accum[n] - accum[j] + (n - j - 1) <= W) {
							continue outer;
						}
						int left = j;
						int right = n;
						while (right - left > 1) {
							int middle = (right + left) / 2;
							if (accum[middle] - accum[j] + (middle - j - 1) <= W) {
								left = middle;
							} else {
								right = middle;
							}
						}
						int dmax = left;

						left = j;
						right = n;
						while (right - left > 1) {
							int middle = (right + left) / 2;
							if (W <= accum[middle] - accum[j] + (long) ngap * (middle - j - 1)) {
								right = middle;
							} else {
								left = middle;
							}
						}
						int dmin = right;
						
						if (dmin > dmax)
							continue;
						++vis[dmin];
						--vis[dmax + 1];
					}
				}
				++lack;
				gap = ngap;
			}
			if (lack > 0)
				++gap;
			pw.println(gap);
		}
		pw.close();
		sc.close();
	}

	
	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 163256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	s := make([]int, N)
	for i := 1; i < N; i++ {
		if i-A[i] >= 0 {
			s[i-A[i]]++
		}
	}
	ans := 0
	for i := 0; i < N; i++ {
		if i+A[i] < N {
			ans += s[i+A[i]]
			//fmt.Println(i+1, ans)
		}
	}
	fmt.Println(ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
    while(1){
        int v[5];
        char name='A';
        int n=0;
        for(int i=0;i<5;i++){
            v[i]=0;
            for(int j=0;j<2;j++){
                int t;cin>>t;
                v[i]+=t;
            }
            if(v[i]==0) return 0;
            if(v[i]>n){
                n=v[i];
                name=i+'A';
            }
        }
        cout<<name<<" "<<n<<endl;
    }
}

Measured memory_bytes: 1160
import java.util.*;
 
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        for (int i = 0; i < S.length()-1; i++) {
            for (int j = i; j < S.length(); j++) {
                String s = S.substring(0, i) + S.substring(j, S.length());
                if (s.equals("keyence")) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define write(x) printf("%d\n", x)
using namespace std;
typedef long long ll;
template <typename T>
void read(T &x)
{
	x = 0;
	char c;
	while (!isdigit(c = getchar()));
	do
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
	}while (isdigit(c = getchar()));
}
int a[100005];
int sum;
int main()
{
	int h, n;
	read(h);read(n);
	for (int i = 0;i < n;++i)
		read(a[i]), sum += a[i];
	if (sum >= h) puts("Yes");
	else puts("No");
	return 0;
}



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

#define ff               first
#define ss               second
#define mp               make_pair
#define pb               push_back
#define pii              pair<int,int>
#define vi               vector<int> 
#define mii              map<int,int>
#define setbits(x)       __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod              1000000007
#define inf              1e18
#define endl             "\n"

void h_code()
{
 #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
 #endif
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void l_code()
{
 #ifndef ONLINE_JUDGE
     cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
 #endif
}
const int N=100005;

inline int startNum(int n)
{   int ans=0;
    while(n)
    {
        ans=n%10;
        n=n/10;
    }
    return ans;
}

int main() {
 //   h_code();
    int t=1;
    
    while(t--)
    {
        int n,cnt1=0,cnt2=0,cnt=0;
         cin>>n;
         for(int i=1;i<=9;i++)
         {
             for(int j=1;j<=9;j++)
             {  cnt1=0;cnt2=0;
                for(int k=1;k<=n;k++)
                {   
                    if(startNum(k)==i  && k%10==j)
                         cnt1++; 
                    if(startNum(k)==j && k%10==i)
                        cnt2++;                    
                }
                cnt+=cnt1*cnt2;
             }
             // cout<<"\nTime Elapsed: "<<i<<"bbb" << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
         }
         cout<<cnt;
    }
  //  l_code();
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

void solve()
{
    ll n,m;
    cin>>n>>m;

    ll ans=min(n,m/2);
    ans+=(m-2*ans)/4;

    cout<<ans<<'\n';
    return;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int R,G,B,n,ans=0;
  cin >> R >> G >> B >> n;
  for(int r=0;r<=n;r++){
    for(int g = 0;g<=n;g++){
      if((n - R*r - G*g )%B == 0 && n - R*r - G*g >= 0){
        ans++;
        //cout << r << g << "\n";
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int n = Integer.parseInt(str[0]);
            int m = Integer.parseInt(str[1]);
            String a[] = new String[n];
            for (int i = 0; i < n; i++) {
                a[i] = br.readLine();
            }
            String b[] = new String[m];
            for (int i = 0; i < m; i++) {
                b[i] = br.readLine();
            }

            boolean yesFlag = false;
            for (int i = 0; i < n; i++) {
                if (yesFlag) {
                    break;
                }
                if (n - i < m) {
                    break;
                }
                for (int j = 0; j < n; j++) {
                    if (yesFlag) {
                        break;
                    }
                    if (n - j < m) {
                        break;
                    }
                    String tmp = a[i].substring(j, j + m);
                    boolean flag = true;
                    if (tmp.equals(b[0])) {
                        for (int k = 1; k < m; k++) {
                            String tmp2 = a[i + k].substring(j, j + m);
                            if (!tmp2.equals(b[k])) {
                                flag = false;
                                break;
                            }
                        }
                        if (flag) {
                            System.out.println("Yes");
                            yesFlag = true;
                        }
                    }
                }
            }
            if (!yesFlag) {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		ll h, n;
		cin>>h>>n;
		ll curr = 0;
		ll sum = 0;
		REP(i,n)
		{
			cin>>curr;
			sum+=curr;
		}
		if(h-sum<=0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}

Measured memory_bytes: 256
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
string s;
cin>>s;
int sum=0;
for(auto &x:s)
sum+=(x-'0');
if(sum%9==0)
cout<<"Yes";
else
{
cout<<"No";
}

}
int main()
{
//code
fastio
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}

Measured memory_bytes: 3732
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            final List<Long> numList = Arrays.stream(args.get(0).split(" ")).map(Long::valueOf).collect(toList());
            final Long x = numList.get(0);
            final Long y = numList.get(1);
            if (x == 1) {
                if (y == 1) {
                    System.out.println(1);
                } else {
                    System.out.println(y - 2);
                }
            } else if (y == 1) {
                System.out.println(x - 2);
            } else {
                System.out.println((x - 2) * (y - 2));
            }
        };
    }

}


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

int n,m;

void test() {

	cin >> n;
	cout << n + n*n + n*n*n;
}

signed main() {

	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	#endif
	test();
	return 0;

}

Measured memory_bytes: 3632
package main

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

func main() {
	s := []byte(nextLine())
	exists := make([]int, 'z'-'a'+1)
	for _, v := range s {
		exists[v-'a']++
	}
	for i, v := range exists {
		if v == 0 {
			fmt.Printf("%c\n", i+'a')
			return
		}
	}
	fmt.Println("None")

}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>


int main(void){
  long x,y;
  scanf("%ld %ld",&x,&y);
  if(x%y==0){
    printf("-1");
  }else{
    for(long i=1;i<10000000000;i++){
      if((x*i)%y!=0){
        printf("%ld",x*i);
        break;
      }
    }
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
char s[10000];
long long n,k,l,r,last,ans;
long long ask(long long x){
    return x/2ll;
}
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    scanf("%lld",&k);
    l=1;
    while(s[l]==s[l+1]) l++;
    if(l==n) return printf("%lld",ask(n*k)),0;
    r=n;
    while(s[r]==s[r-1]) r--;
    last=l+1;
    for(int i=l+1;i<r;i++){
	if(s[i]!=s[i-1]){
	    ans+=ask(i-last);
	    last=i;
	}
    }
    ans+=ask(r-last);
    //printf("%lld %lld %lld",l,r,ans);
    ans=ans*k;
    if(s[1]==s[n]) ans=ans+ask(l)+ask(n-r+1)+1ll*ask(n-r+1+l)*(k-1);
    else ans=ans+(ask(l)+ask(n-r+1))*k;
    printf("%lld",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll x, y;
	cin >> x >> y;
	ll ans = abs(abs(x) - abs(y));
	if(x < y) {
		if(x < 0 && 0 < y) ans++;
	}
	else {
		if(y <= 0 && 0 <= x) ans++;
		else ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let AS =
        Array.init N (fun _ ->
            Array.init (read int) (fun _ -> reads int)
        )

    // 全探索
    let xss =
        let f xs = [0 :: xs; 1 :: xs]
        List.fold (<<) id (List.replicate N (List.collect f)) [[]]

    let f xs =
        let xs = List.toArray xs
        let mutable b = true
        Array.iteri (fun i ys ->
            if xs.[i] = 1 then
                for [|x; y|] in ys do
                    if xs.[x-1] <> y then
                        b <- false
        ) AS
        b

    List.filter f xss
    |> List.map List.sum
    |> List.max
    |> printfn "%i"

    0

Measured memory_bytes: 25000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long

using namespace std;


int main(void){
  ll s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   ll k;
   cin >> k;
   cout << s[k-1] << endl;
   return 0;
}


Measured memory_bytes: 256
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "Draw" << endl;
		return 0;
	}
	if (a == 1) {
		cout << "Alice" << endl;
		return 0;
	}
	else if (b == 1) {
		cout << "Bob" << endl;
		return 0;
	}
	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 998244353
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return sol;
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a * b;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
}


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

using namespace std;
using ll = long long;

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

  string s;
  cin >> s;

  queue<string> q;
  q.push("");
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    if (t == s) {
      cout << "YES" << endl;
      return 0;
    }
    if (t.size() >= s.size())
      continue;

    if (s.substr(t.size(), 5) == "dream")
      q.push(t + "dream");
    if (s.substr(t.size(), 7) == "dreamer")
      q.push(t + "dreamer");
    if (s.substr(t.size(), 5) == "erase")
      q.push(t + "erase");
    if (s.substr(t.size(), 6) == "eraser")
      q.push(t + "eraser");
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 4020
import math
A = [int(input()) for _ in range(5)]
B = list(A)
Mini = 10 ** 5
for i in range(5):
    count = 0
    for j in range(5):
        if i == j : continue
        B[j] = B[j]/10
        B[j] = math.ceil(B[j]) * 10
        count += B[j]
    count += A[i]
    Mini = min(Mini,count)

print(Mini)
    


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

int n, f[26], tmp[26];
vector<string> s;
int main() {
	fill(f, f+26, INT_MAX);
	cin >> n;
	s.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> s[i];
		fill(tmp, tmp+26, 0);
		for(char c: s[i]) tmp[c-'a']++;
		for(int k = 0; k < 26; k++) f[k] = min(tmp[k], f[k]);
	}
	for(int k = 0; k < 26; k++) {
		if(!f[k] || f[k] == INT_MAX) continue;
		for(int i = 0; i < f[k]; i++) cout << char('a'+k);
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii <pair<ll,ll>>
using namespace std;

void solve()
{
    ll a,b;
    cin >> a >> b;
    ll avg=(a+b)/2;
    if((a+b)%2 !=0)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
        cout << avg << endl;
}

int main()
{
     solve();
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int A,B,T;
    cin >> A >> B >> T;
    int count=0;
    FOR(i,1,T+1){
        if(i%A==0){
            //cout << i << endl;
            count+=B;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
using namespace std;


#define min(a, b) ((a) < (b) ? (a) : (b))

int N;
const int MAX_N = 110;
const int INF = 0x3fffffff;
int A[MAX_N];
int B[MAX_N];
int dp[MAX_N][MAX_N];

void init() {
    for(int i = 0; i < N; ++i)
        scanf("%d%d",&A[i], &B[i]);
    for(int i = 0 ;i < N; ++i)
        for(int j = 0; j < N; ++j)
            dp[i][j] = INF;
    for(int i = 0; i < N; ++i)
        dp[i][i] = 0;
}

int solve() {
    for(int k = 1; k < N; ++k) {
        for(int i = 0; i < N - k; ++i) {
            for(int j = i; j < i + k; ++j) {
                int sz = A[i] * B[j] * B[i + k];
                dp[i][i + k] = min(dp[i][i + k],dp[i][j] + dp[j+1][i + k] + sz);
            }
        }
    }
    // for(int i = 0; i < N; ++i) {                                                                                                                                              
    //  for(int j = 0; j < N; ++j)                                                                                                                                               
    //      printf("%d ", dp[i][j]);                                                                                                                                             
    //  printf("\n");                                                                                                                                                            
    // }                                                                                                                                                                         
    return dp[0][N - 1];
}

int main() {
    while(scanf("%d",&N) == 1) {
        init();
        printf("%d\n", solve());
    }
    return 0;
}

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

void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}


int main()
{
	go();
	int n;cin>>n;
	if(n>=30)
		cout << "Yes" <<"\n";
	else
		cout << "No" <<"\n";
}

Measured memory_bytes: 3592
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int num[] = new int[3];
		if(a < b) {
			num[0] = a;
			num[1] = b;
			if(c < a) {
				num[0] = c;
				num[1] = a;
				num[2] = b;
			}
			else if(c < b) {
				num[1] = c;
				num[2] = b;
			}
			else num[2] = c;
		}
		else {
			num[0] = b;
			num[1] = a;
			if(c < b) {
				num[0] = c;
				num[1] = b;
				num[2] = a;
			}
			else if(c < a) {
				num[1] = c;
				num[2] = a;
			}
			else num[2] = c;
		}
		System.out.printf("%d %d %d\n",num[0],num[1],num[2]);
		sc.close();
	}
}


Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=998244353ll;
const int N=200005;

int main(){
	ll a,b;
	scanf("%lld",&a);
	b=(1000000000000000000ll-a)%1000000000ll;
	printf("0 0 1000000000 %lld 1 %lld\n",b,(a+b)/1000000000ll);
	return 0;
}

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


int main() {
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    double t;
    cin >> a >> b >> t;

    int cnt = 0;
    int st = a;

    while(st<= t+0.5){
        cnt+=b;
        st+= a;
    }

    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 100000
#define WEIGHT 10000

int check(long long mid, int n, int k, int weight[]){
	int i=0;
	long long tmp;
	
	for(int j=0;j<k;j++){
		tmp=0;
		while(tmp+weight[i]<=mid){
			tmp+=weight[i];
			i++;
			if(i==n)return n;
		}
	}
	return i;
}

int main(){
    int t;
	int track;
	int weight[M];
	long long left=0,right=M*WEIGHT,mid;
	int tmp;
	
	scanf("%d %d",&t,&track);
	
	for(int i=0;i<t;i++){
		scanf("%d",&weight[i]);
	}
	
	while(right-left>1){
		mid=(left+right)/2;
		tmp=check(mid,t,track,weight);
		if(tmp>=t){
			right=mid;
		}else{
			left=mid;
		}
	}
	
	tmp=right;
	
	printf("%d\n",tmp);
	
    return 0;
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T, X;
    cin >> T >> X;
    cout << setprecision(12) << 1.0 * T / X << '\n';
    return(0);
}

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

#define int long long

int modpow(int x, int y, int z) { int a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
int min(const int &a, const int &b) { return a < b ? a : b; }

const int M = 998244353;
int a[300];
int d[45310];
int e[45310];

signed main() {
  int n;
  scanf("%lld", &n);
  int sum = 0;
  d[0] = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    for (int t = min(45000, sum); t >= 0; --t) {
      d[t + a[i]] += d[t] * 2 % M;
    }
    sum += a[i];
  }
  int ans = modpow(3, n, M);
  for (int t = 0; t <= sum / 2; ++t) {
    ans = (ans - d[t] * 3) % M;
  }
  if ((sum & 1) == 0) {
    int u = 0;
    e[0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int t = min(sum / 2, u + 1); t >= 0; --t) {
        int *p = e + t + a[i];
        *p += e[t];
        if (*p >= M) *p -= M;
      }
      u += a[i];
    }
    ans = (ans + e[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%lld", ans);
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nd = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var n = nd[0];
            var d = nd[1];
            var sss = new int[n,d];
            for(var i=0;i<n;i++)
            {
                var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                for(var j=0;j<d;j++)
                {
                    sss[i,j] = s[j];
                }
            }
            var dist = new List<double>();
            for(var i=0;i<n-1;i++)
            {
                for(var j=i+1; j<n;j++)
                {
                    double ddd = 0;
                    for (var k=0;k<d;k++)
                    {
                        ddd += Math.Pow(Math.Abs(sss[i, k] - sss[j, k]),2);
                    }
                    dist.Add(ddd);
                }
            }
            var count = 0;
            for(var i=0;i<dist.Count;i++)
            {
                double x = Math.Sqrt((double)dist[i]);
                if(x==(int)x)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b)
        cout << c << "\n";
    else if (b == c)
        cout << a << "\n";
    else
        cout << b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (6 <= a && a <= 12) {
    ans = b / 2;
  } else if (13 <= a) {
    ans = b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
moves = [tuple(map(int, input().split())) for _ in range(K)]
MOD = 998244353

DP = [0 for _ in range(N+1)]
DP[0] = 1
DP_sum = [0 for _ in range(N+1)]
DP_sum[0] = 1

#print(moves)

for n in range(1,N+1):
  for l,r in moves:
    if n-l >= 0:
      DP[n] += DP_sum[n-l]
      if n-r-1 >= 0:
        DP[n] -= DP_sum[n-r-1]
    DP[n] %= MOD
  DP_sum[n] = (DP_sum[n-1] + DP[n]) % MOD
  #print(DP)
  #print(DP_sum)
  
print(DP[N-1] % MOD)
  


Measured memory_bytes: 94468
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
P=get.join("")
Q=get.join("")
all=(1..N).to_a.permutation(N).to_a
ans=[]
all.each do|arr|
    ans.push(arr.join(""))
end
ans.sort!
puts (ans.index(Q)-ans.index(P)).abs

Measured memory_bytes: 18392
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
long long n,m,i,j,x[1005],y[1005],s=1,a[45],zhi[45],cnt=0,cnt2;
map<long long,char> mp;
void prt(long long t1,long long t2,long long yy)
{
	if (yy==0)
	{
		if (t1||t2)
		{
			puts("-1");
			exit(0);
		}
		return;
	}
	if (abs(t1)>abs(t2))
	{
		if (t1<0)
		{
			a[yy]=-1;
			t1+=zhi[yy];
		}
		else
		{
			a[yy]=1;
			t1-=zhi[yy];
		}
	}
	else
	{
		if (t2<0)
		{
			a[yy]=-2;
			t2+=zhi[yy];
		}
		else
		{
			a[yy]=2;
			t2-=zhi[yy];
		}
	}
	prt(t1,t2,yy-1);
}
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
		if (i!=1)
		{
			if (((x[i]+y[i]-x[1]-y[1])%2+2)&1)
			{
				puts("-1");
				return 0;
			}
		}
	}
	mp[2]='U';
	mp[-2]='D';
	mp[1]='R';
	mp[-1]='L';
	if ((((x[1]+y[1])%2+2)%2)==0)
	{
		cnt=1;
		zhi[1]=1;
	}
	for (i=1;i<=20;i++)
	{
		zhi[++cnt]=s;
		if (i!=20) zhi[++cnt]=s;
		/*if (i!=1)*/ s*=3;
	}
	cout<<cnt<<endl;
	for (i=1;i<=cnt;i++)
	{
		cout<<zhi[i];if (i!=cnt) cout<<' ';
	}
	cout<<endl;
	for (i=1;i<=n;i++)
	{
		memset(a,0,sizeof(a));prt(x[i],y[i],cnt);for (j=1;j<=cnt;j++) cout<<mp[a[j]];
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/**
  @date Time-stamp: <2019-04-20 21:46:20 tagashira>
  @file a.cpp
  @brief https://tenka1-2019-beginner.contest.atcoder.jp/tasks/tenka1_2019_a
**/

#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  int A, B, C;
  cin >> A >> B >> C;

  if (C - A > 0 && B - C > 0) {
    cout << "Yes"
         << "\n";
  } else if (C - B > 0 && A - C > 0) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>   //A - Rounding

int main(){

    int x,a;
    int ans;
    scanf("%d %d",&x,&a);

    if(x>=0 && x>=a){
        ans = 10;
    }else{
        ans = 0;
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    String s=sc.next();
    if(a>=3200){
      System.out.println(s);
    }else{
      System.out.println("red");
    }
  }
}


Measured memory_bytes: 21844
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [d, n] <- readInts
  print $ solve d n

solve :: Int -> Int -> Int
solve d n = 
  (if n == 100 then 101 else n) * (foldr (const (* 100)) 1 [1 .. d])

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


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

#define int long long
#define rep(i,a,b) for(int i = a; i < b; i++)

int n,m;
int table[9][9];
int win[9];
int lose[9];
int ans;


void rec(int i=0, int j=0) {
    if (i == n && j == 0) {
        ans += 1;
        return;
    }
    int ni,nj;
    ni = i;
    nj = j + 1;

    if (nj > n-1) {
        ni = i + 1;
        nj = 0 ;
    }

    if (table[i][j] == 0) {
        if (i == j) return rec(ni, nj);

        if (win[i] + 1 <= n/2 && lose[j] + 1 <= n/2) {
            table[i][j] = 1;
            table[j][i] = -1;
            win[i] += 1;
            lose[j] +=1;
            rec(ni, nj);
            table[i][j] = 0;
            table[j][i] = 0;
            win[i] += -1;
            lose[j] += -1;
        }

        if (lose[i] + 1 <= n/2 && win[j] + 1 <= n/2) {
            table[i][j] = -1;
            table[j][i] = 1;
            lose[i] += 1;
            win[j] += 1;
            rec(ni, nj);
            table[i][j] = 0;
            table[j][i] = 0;
            lose[i] += -1;
            win[j] += -1;
        }
    }
    else {
        if (table[i][j] == 1) {
            if (win[i] <= n/2 && lose[j] <= n/2) {
                return rec(ni, nj);
            }
        }
        if (table[i][j] == -1) {
            if (lose[i] <= n/2 && win[j] <= n/2) {
                return rec(ni, nj);
            }
        }
    }
    return;
}

signed main() {
    while (true) {
        cin >> n;
        if(n==0) break;
        cin >> m;
        rep(i,0,n) rep(j,0,n) table[i][j] = 0;
        rep(i,0,n) win[i] = 0;
        rep(i,0,n) lose[i] = 0;
        rep(i,0,m) {
            int x,y;
            cin >> x >> y;
            x -= 1;
            y -= 1;
            table[x][y] = 1;
            table[y][x] = -1;
            win[x] += 1;
            lose[y] += 1;
        }

        ans = 0;

        rec();

        cout << ans << endl;
    }
}


Measured memory_bytes: 3104
route=""
#p "u"*3
st = gets.split(" ").map(&:to_i)
u_1 = st[3]-st[1]
r_1 = st[2]-st[0]
d_1 = u_1
l_1 = r_1
route += "U"*u_1 + "R"*r_1 + "D"*d_1 + "L"*l_1
l_2 = 1
u_2 = u_1 + 1
r_2 = r_1 + 1
d_2 = 1
route += "L"*l_2 + "U"*u_2 + "R"*r_2 + "D"*d_2

r_3 = 1
d_3 = u_2
l_3 = r_2
u_3 = 1
route+= "R"*r_3 + "D"*d_3 + "L"*l_3 + "U"*u_3

print(route, "\n")

Measured memory_bytes: 1916
def selectionSort(A, N):
    swap_count = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            swap_count += 1
    return swap_count

n = int(input())
A = list(map(int, input().split()))
count = selectionSort(A, n)
print(*A)
print(count)

Measured memory_bytes: 7744
from collections import Counter

def prime_fact(n):
    P = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            P.append(i)
            n //= i
    if n != 1:
        P.append(n)
    return P
  
n = int(input())
cnt = Counter(prime_fact(n))
#print(cnt)

ans = 0
for c in cnt.values():
    tmp = 1
    while c >= tmp:
        c -= tmp
        ans += 1
        tmp += 1
        
print(ans)

Measured memory_bytes: 9568
#include <iostream>
#include <vector>

using namespace std;
using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  vi diff;
  rep(i, N) {
    int p; in(p);
    if (p == i+1)
      diff.push_back(i);
  }
  int ans = 0;
  iter(it, diff) {
    if (*it + 1 == *(it+1)) {
      ++it;
    }
    ++ans;
  }
  out(ans);

  return 0;
}


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    int n,i,j;
    n = s.size();
    
    bool ok = false;
    for(i = 0; i < n; i++){
        for(j = 0; j <= n - i; j++){
            string t = s;
            t.erase(i,j);
            if(t == "keyence") ok = true;
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
H, W, D = map( int, input().split())
A = [ list( map( int, input().split())) for _ in range(H)]
P = [(0,0)]*(H*W+1)
for i in range(H):
    for j in range(W):
        P[A[i][j]] = (i,j)
d = [0]*(H*W+1)
for i in range(D+1,H*W+1):
    d[i] = d[i-D] + abs(P[i][0] - P[i-D][0]) + abs(P[i][1] - P[i-D][1])
Q = int( input())
for _ in range(Q):
    L, R = map( int, input().split())
    print(d[R]-d[L])

Measured memory_bytes: 17972
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
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;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int h;
  cin >> h;

  int ans = 0, cnt = 1;
  while(h){
    ans += cnt;
    cnt*=2;
    h /= 2;
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
	int  n, m;
	char c;
	//0:S 1:H 2:C 3:D
	int trump[4][13];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			trump[i][j] = 0;
		}
	}

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> c;
		cin >> m;
		if(c == 'S')	trump[0][m-1] = 1;
		else if(c == 'H')	trump[1][m-1] = 1;
		else if(c == 'C')	trump[2][m-1] = 1;
		else if(c == 'D')	trump[3][m-1] = 1;
	}

	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			if(trump[i][j] != 1){
				if(i == 0)	cout << 'S' << " " << j+1 << endl;
				else if(i == 1)	cout << 'H' << " " << j+1 << endl;
				else if(i == 2)	cout << 'C' << " " << j+1 << endl;
				else if(i == 3)	cout << 'D' << " " << j+1 << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    mod = 2019
    l, r = map(int, input().split())
    l_div = l // mod
    if mod * (l_div + 2) < r:
        print(0)
        quit()
    elif mod * (l_div + 1) < r:
        print(1)
        quit()
    ans = 2020
    r_mod_1 = r % mod + 1
    for i in range(l % mod, r_mod_1):
        for j in range(i+1, r_mod_1):
            ij_mod = i * j % mod
            if ans > ij_mod:
                ans = ij_mod
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
from itertools import combinations
import bisect

import sys
input = sys.stdin.readline

def solve(a):
    ans = 0
    for a1, a2, a3 in combinations(a,3):
        a_max = max(a1,a2,a3)
        if a1 + a2 + a3 > 2*a_max and a1 != a2 and a1 != a3 and a2 != a3:
            ans += 1
    print(ans)



            

def main():
    n = int(input())
    a = list(map(int,input().split()))
    solve(a)


if __name__ == "__main__":
    main()

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int q; cin >> q;
    set<int> S;
    rep(i,q){
        int query; cin >> query;
        if(query == 0){
            int x; cin >> x;
            S.insert(x);
            cout << S.size() << endl;
        }else if(query == 1){
            int x; cin >> x;
            cout << S.count(x) << endl;
        }
        
    }
}


Measured memory_bytes: 12452