akhauriyash/Code-Regression huggingface dataset:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    if N % 10 in [2, 4, 5, 7, 9]:
        print('hon')
    elif N % 10 in [0, 1, 6, 8]:
        print('pon')
    else:
        print('bon')


if __name__ == "__main__":
    main()


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N),B(N);
    vector<vector<int64_t>> BA(N,vector<int64_t>(2));
    for ( int64_t i = 0; i < N; ++i){
        cin >> A.at(i) >> B.at(i);
        BA.at(i).at(0) = B.at(i);
        BA.at(i).at(1) = A.at(i);
    }
    
    sort(BA.begin(),BA.end());
    
    int64_t t = 0;
    bool flg = true;
    for ( int64_t i = 0; i < N; ++i){
        t += BA.at(i).at(1);
        if ( t > BA.at(i).at(0) ) {
            flg = false;
        }
    }
    
    if ( flg ) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}



Measured memory_bytes: 14336
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n =int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

L = range(n)
from itertools import combinations

ans = INF = 1000000
for I in combinations(L,n//2): #偶数番目を決め打ち全探索
    even = [(a[i] if i%2 else b[i], i) for i in I]
    odd  = [(b[i] if i%2 else a[i], i) for i in range(n) if i not in I]
    
    odd.sort()
    even.sort()
    ok = 1
    #偶数番目と奇数番目をマージしたとき、ソートされているか確認
    for i in range(n//2):
        if odd[i][0] > even[i][0]:
            ok = 0
            break
    for i in range(1,n-n//2):
        if even[i-1][0] > odd[i][0]:
            ok = 0
            break
    
    if ok:
        res = [0]*n
        for i in range(n//2):
            res[2*i+1] = even[i][1]
        for i in range(n-n//2):
            res[2*i] = odd[i][1]
        
        #転倒数の計算
        cnt = 0        
        for i in range(n):
            for j in range(i+1,n):
                if res[i] > res[j]: cnt += 1
        ans = min(ans,cnt)


if ans == INF: print(-1)
else: print(ans)
        
        
        

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,n1,n2,x1,i,j;
    cin>>a>>b;
    n1=a/2019;
    x1=n1*2019;
    n2=b/2019;
    if(n1!=n2)
    {
        cout<<0<<endl;
        return 0;
    }
    ll mini=INT_MAX;
        for(i=a;i<=b;i++)
    {
        for(j=i+1;j<=b;j++)
        {
            mini=min((i*j)%2019,mini);
        }
    }
    cout<<mini<<endl;
    return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
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...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int x,y,z,k;

main(){
	cin>>x>>y>>z>>k;
	vint a(x),b(y),c(z);
	rep(i,x)cin>>a[i];
	rep(i,y)cin>>b[i];
	rep(i,z)cin>>c[i];
	vint t;
	fh(p,a){
		fh(q,b){
			t.pb(p+q);
		}
	}
	sort(rall(t));
	vint ans;
	rep(i,min(k,(int)t.size())){
		rep(j,z){
			ans.pb(t[i]+c[j]);
		}
	}
	sort(rall(ans));
	rep(i,k)dump(ans[i]);
}




Measured memory_bytes: 43112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcorder111Console {
    class Program {
        static void Main(string[] args) {
            string str = Console.ReadLine();
            string[] s = str.Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            if (c <= (b / a)) {
                Console.WriteLine(c);
            }
            else {
                Console.WriteLine(b / a);
            } 
        }
    }
}

Measured memory_bytes: 13140
use proconio::input;

fn calc(dp: &mut Vec<Vec<Vec<f64>>>, n: usize, i: usize, j: usize, k: usize) -> f64 {
    if dp[i][j][k] > 0.0 {
        dp[i][j][k]
    } else if i == 0 && j == 0 && k == 0 {
        0.0
    } else {
        let r = n as f64
            + if i > 0 { calc(dp, n, i - 1, j, k) * (i as f64) } else { 0.0 }
            + if j > 0 { calc(dp, n, i + 1, j - 1, k) * (j as f64) } else { 0.0 }
            + if k > 0 { calc(dp, n, i, j + 1, k - 1) * (k as f64) } else { 0.0 };
        dp[i][j][k] = r / ((i + j + k) as f64);
        dp[i][j][k]
    }
}

fn main() {
    input! {
        n: usize,
    }
    let mut ijk = [0usize; 3];
    for _ in 0..n {
        input! {
            a: usize,
        }
        ijk[a - 1] += 1;
    }
    let mut dp = vec![vec![vec![-1.0f64; n + 1]; n + 1]; n + 1];

    println!("{}", calc(&mut dp, n, ijk[0], ijk[1], ijk[2]));
}


Measured memory_bytes: 218008
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

ll modpow(ll m, ll n) {
  if(n==0) return 1;
  else if(n%2==0) return modpow(m, n/2)*modpow(m, n/2)%MOD;
  else return m*modpow(m, n-1)%MOD;
}

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

  ll n;
  cin >> n;
  cout << ((modpow(10, n) - 2 * modpow(9, n) + modpow(8, n)) % MOD + MOD) % MOD << newl;
  return 0;
}

Measured memory_bytes: 3648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lucasr
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATakoyaki solver = new ATakoyaki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATakoyaki {
        public void solve(int testNumber, MyScanner sc, PrintWriter out) {
            int N = sc.nextInt();
            int X = sc.nextInt();
            int T = sc.nextInt();
            out.println((N + X - 1) / X * T);
        }

    }

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer tokenizer;

        public MyScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 32848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c = 300000;
	    int d = 300000;

	    for(int i=0;i<b.length;i++)
	    	if(b[i].equals("A")){
	    		c = i;
	    	break;
	    	}
	    	else
	    		continue;
	    
	    	for(int j=b.length-1;j>=0;j--)
		    	if(b[j].equals("Z")){
		    		d = j;
	    	break;}
		    	else
		    		continue;
		   
	    	
	    		d = d-c+1;
	    		System.out.println(d);
	    	
	    	
	    		
	    		
	    	
	    	
	    }
	    	

	}



Measured memory_bytes: 52676
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()

  if s[-7:]=='keyence':
    return 'YES'
  if s[:7]=='keyence':
    return 'YES'
  if s[0]=='k' and s[-6:]=='eyence':
    return 'YES'
  if s[:2]=='ke' and s[-5:]=='yence':
    return 'YES'
  if s[:3]=='key' and s[-4:]=='ence':
    return 'YES'
  if s[:4]=='keye' and s[-3:]=='nce':
    return 'YES'
  if s[:5]=='keyen' and s[-2:]=='ce':
    return 'YES'
  if s[:6]=='keyenc' and s[-1]=='e':
    return 'YES'
  return 'NO'

# main()
print(main())


Measured memory_bytes: 6060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll INF = 1e17;

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0, cnt = 0;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'B')
            ++cnt;
        else
            ans += cnt;
    }
    cout << ans;
    return 0;
}


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

int main()
{
  int n;
  int nb[11];
  cin >> n;
  int tmp = n;
  int sum = 0;
  rep(i, 11) nb[i] = 0;
  int i = 0;
  while(tmp > 0)
  {
	nb[i] = tmp % 10;
    tmp /= 10;
    i++;
  }
  int length = 0;
  while(nb[length] > 0) length++;
  rep(i, length)  sum += nb[i];
  if(n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    double N, K;
    cin >> N >> K;
    double ans = 0;

    repd(i, 1, N + 1)
    {
        double eq = N;
        if (i < K)
        {
            long double z = log(K / i) / log((double)2.0);
            eq = (N * pow(2, ceil(z)));
        }
        ans += ((double)1.0 / eq);
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long

int main(){

	ll N,T;
	ll t1 = 0, t2 = 0, ts = -1, sum = 0;

	scanf("%lld %lld",&N,&T);

	FOR(i,0,N){
		scanf("%lld",&t2);
		//if(ts == -1) ts = t2;
		if(t2 -t1 > T){
			sum += t1 + T - ts;
			ts = t2;
		}
		t1 = t2;
	}
	sum += t1 + T - ts;

	printf("%lld\n",sum-1);

}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	L, R, d := r.nextInt(), r.nextInt(), r.nextInt()

	fmt.Fprintln(stdout, R/d-(L-1)/d)
}


Measured memory_bytes: 1736
N = int(raw_input())
a = map(int,raw_input().split())

same_color_list = []
same=1

for i in range(N):
    if i != 0:
        if a[i] == a[i-1]:
            same+=1
        else:
            if same!=1:
                same_color_list.append(same)
                same=1
if same!=1:
    same_color_list.append(same)

count = 0
for same in same_color_list:
    count += same/2

print count

Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vii vector<ll>
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define pb push_back
#define ii pair<int,int>
#define iii pair<ll,ll>
#define MAX 10000000000000
#define pi 3.1415926535
typedef long long ll;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,W;
    cin>>n>>W;
    vii w(n), v(n);
    vector<vii> dp(n,vii(W+1,-1));
    f(i,0,n) cin>>w[i]>>v[i];
    dp[0][0] = 0;
    dp[0][w[0]] = v[0];

    f(i,1,n) {
        f(j,0,W+1) {
            if(j-w[i]>=0)
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    ll ans = -1;
    f(i,0,W+1)
        ans = max(ans, dp[n-1][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 79488
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		HashMap<String,Integer> map =new HashMap<>();
		int N=sc.nextInt();
		
		for(int i=0;i<N;i++) {
			String d=sc.next();
			
			if(map.containsKey(d)) {
				map.replace(d, map.get(d)+1);
			}else {
				map.put(d, 1);
			}
		}
		
		int M=sc.nextInt();
		boolean x=true;
		for(int i=0;i<M;i++) {
			String t=sc.next();
			if(map.containsKey(t)) {
				if(map.get(t)==1)map.remove(t);
				else map.replace(t, map.get(t)-1);
			}else {
				x=false;
				break;
			}
		}
		if(x)p("YES");
		else p("NO");
		
		
	}
	
}
	


Measured memory_bytes: 94624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    int l = S.size();
    for(int i=0;i<l;i++){
        if(i%2 == 0 && S[i] == 'L'){
            cout << "No" << endl;
            return 0;
        }
        if(i%2 != 0 && S[i] == 'R'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

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

int main( int argc, char *argv[] )
{
char S0[ 110 ];
char S1[ 110 ];
int iLen0;
int iLen1;

	// 入力
	cin >> S0;
	cin >> S1;

	iLen0 = strlen( S0 );
	iLen1 = strlen( S1 );

	// 比較
	if( iLen0 > iLen1 )
		cout << "GREATER" << endl;
	else if( iLen0 < iLen1 )
		cout << "LESS" << endl;
	else
	{
		if( (string) S0 > (string) S1 )
			cout << "GREATER" << endl;
		else if( (string) S0 < (string) S1 )
			cout << "LESS" << endl;
		else
			cout << "EQUAL" << endl;
	}

	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(void){
    // Your code here!
    int n;
    int x;
    cin >> n;
    cin >> x;
    int* m = new int[n];
    int min = x;
    for(int i = 0; i < n; i++){
        cin >> m[i];
        x = x - m[i];
        if(m[i] < min){
            min = m[i];
        }
    }
    int count = n + (x / min);
    cout << count;
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    vector<vector<char>> board(100, vector<char>(100));
    REP(h, 50){
        fill(board[h].begin(), board[h].end(), '.');
    }
    REP(h, 50){
        fill(board[h + 50].begin(), board[h + 50].end(), '#');
    }
    --A;
    --B;
    REP(b, B){
        board[(b / 50) * 2][(b % 50) * 2] = '#';
    }
    REP(a, A){
        board[(a / 50) * 2 + 51][(a % 50) * 2] = '.';
    }
    cout << "100 100" << endl;
    REP(h, 100){
        REP(w, 100){
            cout << board[h][w];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int h =sc.nextInt(),w=sc.nextInt();
			if(h==0 && w==0) {
				break;
			}
			String s1="";
			String s2="";
			for(int i=0; i<w;i++) {
				if(i%2==0) {
					s1 +="#";
					s2 +=".";
				}else {
					s1 +=".";
					s2 +="#";
				}
			}

			for(int i=0; i<h; i++) {
				if(i%2==0) {
					System.out.println(s1);
				}else {
					System.out.println(s2);
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 27776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int64_t MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	vector<int64_t> current(4, 0);
	current[0] = 1;
	for (int i = 0; i < s.length(); ++i) {
		char c = s[i];
		vector<int64_t> next(4, 0);
		if (c == 'A') {
			next[0] = current[0];
			next[1] = (current[1] + current[0])%MOD;
			next[2] = current[2];
			next[3] = current[3];
		}
		else if (c == 'B') {
			next[0] = current[0];
			next[1] = current[1];
			next[2] = (current[2] + current[1])%MOD;
			next[3] = current[3];
		}
		else if (c == 'C') {
			next[0] = current[0];
			next[1] = current[1];
			next[2] = current[2];
			next[3] = (current[3] + current[2])%MOD;
		}else{
			next[0] = (current[0]*3)%MOD;
			next[1] = ((current[1]*3)%MOD + current[0])%MOD;
			next[2] = ((current[2]*3)%MOD + current[1])%MOD;
			next[3] = ((current[3]*3)%MOD + current[2])%MOD;
		}
		current = next;
	}
	cout << current[3] << endl;
	return 0;
}

Measured memory_bytes: 512
import math
PI = 3.14159265358979
a,b,h,m = map(int, input().split())
sh = 30 * h + m * 0.5
lo = 6 * m
rad = abs(sh - lo) * PI / 180
r = (a * a + b * b - 2 * a * b * math.cos(rad)) ** .5
print(r)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

int n;
vi v;

void f(int l,int x)
{
        if(357<=x&&x<=n)v.push_back(x);
        if(l<0)
        {
                return;
        }else
        {
                f(l-1,x*10+3);
                f(l-1,x*10+5);
                f(l-1,x*10+7);
        }
}

main()
{
        cin>>n;
        int l=to_string(n).size();
        f(l,0);

        int ans=0;
        each(it,v)
        {
                string s=to_string(it);
                bool is3=false,is5=false,is7=false;
                bool flag=true;
                each(it,s)
                {
                        if(it=='3')is3=true;
                        else if(it=='5')is5=true;
                        else if(it=='7')is7=true;
                        else flag=false;
                }
                if(is3&&is5&&is7)ans+=flag;
        }
        cout<<ans<<endl;
}


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

int main(){
	int a,b,c,x,y;	cin>>a>>b>>c>>x>>y;
	int twin=min(a+b, c*2);
	long long ans=0;

	while(min(x,y)>0){
		ans+=twin;
		x--;
		y--;
	}
	
	if(x>0){
		ans += min(a*x, c*2*x);
	}else if(y>0){
		ans += min(b*y, c*2*y);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
s=input()
if len(s)==2:
    print(["-1 -1","1 2"][s[0]==s[1]])
    exit()
x=len(s)
for i in range(x-2):
    chk=[s[i],s[i+1],s[i+2]]
    chk.sort()
    if chk[0]==chk[1] or chk[1]==chk[2]:
        print(i+1,i+3)
        exit()
print("-1 -1")

Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#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(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.length();
    int ans[n+1];
    rep(i,n+1) ans[i] = 0;

    // if (s[0]=='<')
    // {
    //     ans[0] = 0;
    //     ans[1] = 1;
    // }
    bool chokuzen = false;
    rep(i,n)
    {
        if (s[i]=='<')
        {
            if (chokuzen==false)
            {
                ans[i] = 0;
                ans[i+1] = 1;
            }
            else
            {
                ans[i+1] = ans[i]+1;
            }
            chokuzen = true;
        }
        else
        {
            chokuzen = false;
        }
    }
    chokuzen = false;
    rREP(i, n-1, 0)
    {
        if (s[i]=='>')
        {
            if (chokuzen==false)
            {
                ans[i+1] = 0;
                ans[i] = max(ans[i], 1);
            }
            else
            {
                ans[i] = max(ans[i], ans[i+1]+1);
            }
            chokuzen = true;
        }
        else
        {
            chokuzen = false;
        }
    }

    // rep(i,n+1)
    // {
    //     cout << ans[i] << " ";
    // }
    // cout << endl;
    ll ans_num = 0;
    rep(i,n+1)
    {
        ans_num += ans[i];
    }
    cout << ans_num << endl;
}




Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
int main () {
  vector<long long> S(4);
  cin >> S.at(0) >> S.at(1) >> S.at(2) >> S.at(3);
  long long ans = 0;
  long long count = 0;
  for(int i = 0; i < 2; i++) {
    for(int j = 2; j < 4; j++) {
    count = S.at(i) * S.at(j);
      if(i == 0 && j == 2) {
        count = S.at(i) * S.at(j);
        ans = count;
      }
      else {
        count = S.at(i) * S.at(j);
        ans = max(ans, count);
      }
      count = 0;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int, int> pi;

int N;
vector<pi> A;

int main(void) {
	cin >> N;
	A.resize(N + 1);
	A[0] = make_pair(0, 0);

	for (int i = 1; i <= N; ++i) {
		int a;
		cin >> a;
		A[i] = make_pair(a, i);
	}
	sort(A.begin(), A.end());

	for (int i = 1; i <= N; ++i)
		cout << A[i].second << ((i == N) ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

int n;
int ni[200],di[200];
int x[200]={0},y[200]={0};
int mx[4]={-1,0,1,0};
int my[4]={0,-1,0,1};
int max,mix,may,miy;

int main(void){
  int i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=1;i<n;i++)scanf("%d%d",&ni[i],&di[i]);
    max=0;
    mix=0;
    may=0;
    miy=0;
    for(i=1;i<n;i++){
      x[i]=x[ni[i]]+mx[di[i]];
      y[i]=y[ni[i]]+my[di[i]];
      if(x[i]>max)max=x[i];
      if(x[i]<mix)mix=x[i];
      if(y[i]>may)may=y[i];
      if(y[i]<miy)miy=y[i];
    }
    printf("%d %d\n",max-mix+1,may-miy+1);
  }
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 1, n)
    {
        if (a[i - 1] > a[i])
        {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3892
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using pii = pair<int, int>;

#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define out(v) cout<<v<<"\n"

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

  long long a[N];
  rep(i, N) cin >> a[i];
  int max_index = max_element(all(a, N)) - a,
      min_index = min_element(all(a, N)) - a;
  vector<pii> ans;
  if (a[max_index] * a[min_index] < 0) {
    // 絶対値がデカイほうを全部に足してやって符号を揃える
    int base = (abs(a[max_index]) > abs(a[min_index]) ? max_index : min_index);
    rep(i, N) {
      if (i == base)
        continue;
      a[i] += a[base];
      ans.push_back(pii(i, base));
    }
    a[base] += a[base];
    ans.push_back(pii(base, base));
  }
  if (a[min_index] >= 0) {
    // すべて非負
    rep(i, N-1) {
      if (a[i] > a[i+1]) {
        a[i+1] += a[max_index];
        ans.push_back(pii(i+1, max_index));
        max_index = i + 1;
      }
    }
  } else {
    rrep(i, N-2) {
      if (a[i] > a[i+1]) {
        a[i] += a[min_index];
        ans.push_back(pii(i, min_index));
        min_index = i;
      }
    }
  }
  int m = ans.size();
  out(m);
  rep(i, m) {
    out(ans[i].second + 1 << " " << ans[i].first + 1);
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> PII;
#define MOD (1000000007ll)

priority_queue< ll, vector<ll>, greater<ll> > pq;

int main(void){
	ll t[123456],ans,tmp,n,k,i;
	cin >> n >> k;
	for(i=0ll; i<n; i++){
		cin >> t[i];
	}
	for(i=1ll; i<n; i++){
		pq.push(t[i]-t[i-1]-1ll);
	}
	ans = n;
	while(n > k){
		tmp = pq.top();
		pq.pop();
		ans += tmp;
		n--;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i==0){
            cout<<A[i];
        }
        else{
            cout<<" "<<A[i];
        }
    }
    cout<<endl;
    for(int i=1;i<=N-1;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
            A[j+1]=v;
        }
        for(int i=0;i<N;i++){
            if(i==0){
                cout<<A[i];
            }
            else{
            cout<<" "<<A[i];
            }
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3092
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
typedef pair < int , int > Pi;
int main(){
  int n;
  Pi a[20];
  cin >> n;
  for(int i = 0 ; i < n ; i++ ){
    cin >> a[i].second >> a[i].first;
    a[i].second = -a[i].second;
  }
  sort( a, a + n);
  Pi *itr = max_element(a, a + n);
  cout << -(*itr).second << " " << (*itr).first << endl;
}

Measured memory_bytes: 1168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> hList = new ArrayList<>();
        for (int i = 0; i < n; i++){
            int h = sc.nextInt();
            hList.add(h);
        }

        Collections.sort(hList, Comparator.reverseOrder());

        int answer = hList.get(0);

        for (int i = 0; i < n - k + 1; i++){
            int sabun = hList.get(i) - hList.get(i + k - 1);
            if (sabun < answer){
                answer = sabun;
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 61652
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a[3][3],c[3][3],n;
    for(int i=0;i<3;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        for(int j=0;j<3;j++)c[i][j]=0;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(a[i][j]==b){
                    c[i][j]=1;
                    if((c[i][0]==c[i][1]&&c[i][0]==c[i][2])||(c[0][j]==c[1][j]&&c[0][j]==c[2][j])){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    if(c[1][1]==1&&((c[0][0]==c[1][1]&&c[0][0]==c[2][2])||(c[0][2]==c[1][1]&&c[0][2]==c[2][0]))){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


struct UnionFind{
    vector<ll> par;
    UnionFind(ll n) : par(n, -1){}
    

    int root(int x){
        if(par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    bool same(int a, int b){
        return root(a)==root(b);
    }
    void unite(int a, int b){
        int x=root(a), y=root(b);
        if(same(x, y)) return;
        if(y<x) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
    int size(int x){
        return -par[root(x)];
    }

};


int main(){
    ll n, m;   cin >> n >> m;
    vector<pair<ll, ll>> g(m);
    REP(i, m){
        ll a, b;    cin >> a >> b;
        a--, b--;
        g[i] = {a, b};
    }
    UnionFind bridge = UnionFind(n);
    ll res=n*(n-1)/2;
    vector<ll> ans(m);
    REPD(i, m){
        ll a=g[i].first, b=g[i].second;
        ans[i] = res;
        if(!bridge.same(a, b)){
            res -= bridge.size(a)*bridge.size(b);
            bridge.unite(a, b);
        }
    }
    REP(i, m) cout << ans[i] << endl;
    

}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[100005],b[100005],c[100005];
vector<ll>d;
ll bit[400005],bit1[400005];
void upd(ll i)
{
	while(i<=400000)
	{
		bit[i]++;
		i+=(i&-i);
	}
}
void upd1(ll i,ll x)
{
	while(i<=400000)
	{
		bit1[i]+=x;
		i+=(i&-i);
	}
}
ll sum(ll i)
{
	ll an=0;
	while(i>0)
	{
		an+=bit[i];
		i-=(i&-i);
	}
	return an;
}
ll sum1(ll i)
{
	ll an=0;
	while(i>0)
	{
		an+=bit1[i];
		i-=(i&-i);
	}
	return an;
}
int main() {
 
slld(n);
for(int i=1;i<=n;i++)
slld(a[i]),d.pb(a[i]);
for(int i=1;i<=n;i++)
slld(b[i]),d.pb(b[i]);
for(int i=1;i<=n;i++)
slld(c[i]),d.pb(c[i]);
sort(d.begin(),d.end());
for(int i=1;i<=n;i++)
{
	ll j=lower_bound(d.begin(), d.end(),a[i])-d.begin()+1;
	a[i]=j;
	j=lower_bound(d.begin(), d.end(),b[i])-d.begin()+1;
	b[i]=j;
	j=lower_bound(d.begin(), d.end(),c[i])-d.begin()+1;
	c[i]=j;
}
for(int i=1;i<=n;i++)
	upd(a[i]);
for(int i=1;i<=n;i++)
{
	ll x=sum(b[i]-1);
	upd1(b[i],x);
}
ll ans=0;
for(int i=1;i<=n;i++)
	ans+=sum1(c[i]-1);
plld(ans);
	return 0;
           }



Measured memory_bytes: 12908
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}


int main(void){
	int n; cin >> n;
	cout << (n-1)/2 << endl;
	


    return 0;
}













Measured memory_bytes: 256
n,t=map(int,input().split())
dp=[[-1 for j in range(2)] for i in range(t+1)]
dp[0][0]=0
d=[]
for i in range(n):
    d.append(list(map(int,input().split())))
d.sort()
for i in range(n):
    for j in range(t,-1,-1):
        for k in range(1,-1,-1):
            if k==0:
                if dp[j][k]>=0 and j+d[i][0]<t:
                    dp[j+d[i][0]][k]=max(dp[j+d[i][0]][k],dp[j][k]+d[i][1])
            if k==1:
                if dp[j][0]>=0:
                    dp[j][k]=max(dp[j][k],dp[j][0]+d[i][1])
ans=0
for i in range(t+1):
    for j in range(2):
        ans=max(ans,dp[i][j])
print(ans)


Measured memory_bytes: 49112
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin>>n>>k;
  if(n*500>=k)
    cout<<"Yes\n";
  else
  {
    cout<<"No\n";
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), m = sc.nextInt();
        int[] dist = new int[n+1];
        for(int i=2; i<=n; i++) dist[i] += dist[i-1] + sc.nextInt();
        int ans = 0;
        int pos = 1;
        for(int i=0; i<m; i++){
            int a = sc.nextInt();
            int np = pos + a;
            ans += dist[Math.max(pos, np)] - dist[Math.min(pos, np)];
            ans %= 100000;
            pos = np;
        }
        System.out.println(ans);
    }

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



        

Measured memory_bytes: 94508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,a,b,res;
  cin >> n;
  
  res = 1000000000000;
  
  
  for(long i = 2;i<=sqrt(n) ;++i){
   
    if(n % i == 0){
      a = n/i;
    
    if ( res > a+i-2){
      res = a+i-2;
    }
    else if ( res == a+i-2){
      break;
    }
    }
  }
  if(a<1) res = n-1;
  
    cout << res << endl;
}

Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
arr = gets.chomp.split(" ").map(&:to_i)
arr = arr.unshift(0)
arr = arr.map(&:to_i)
start = 1
#p a
while k > 0
  if k[0] == 1
    start =arr[start] 
  end

  arr = Array.new(n+1){|i| arr[arr[i]]}
  #p k
  k = k >> 1
end
puts start


Measured memory_bytes: 83336
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;


int main()
{
    int n;
    cin >> n;
    for (int i = 1; i < 10; ++i)
    {
        int j = n / i;
        if (j > 0 && j < 10 && i * j == n)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;
#define INF (1LL<<60)

int n, cut[5000][5000];
Int a[5000], s[5000], dp[5000][5000];

int main() {
    cin >> n;
    rep (i, n) cin >> a[i];
    rep (i, n) s[i+1] = s[i] + a[i];
    rep (w, n) if (w > 0) rep (i, n-w) {
        const int j = i+w+1;
        if (w == 1) {
            cut[i][j] = i+1;
            dp[i][j] = dp[i][i+1] + dp[j-1][j];
        }
        else {
            dp[i][j] = INF;
            for (int k = cut[i][j-1]; k <= cut[i+1][j]; k++) {
                if (dp[i][j] > dp[i][k]+dp[k][j]) {
                    dp[i][j] = dp[i][k]+dp[k][j];
                    cut[i][j] = k;
                }
            }
        }
        dp[i][j] += s[j] - s[i];
    }
    cout << dp[0][n] << endl;
    return 0;
}

Measured memory_bytes: 238524
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  string s;cin>>s;
  int red=0;
  rep(i,n){
    if(s[i]=='R')red++;
    else red--;
  }
  //cout<<red<<endl;
  //cout<<s<<endl;
  if(red>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

LL G[N][N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            scanf("%lld",&G[i][j]);

    bool flag=false;
    LL res=0;
    for(int i=1;i<=n&&!flag;i++){
        for(int j=i+1;j<=n&&!flag;j++){
            bool flag2=false;
            for(int k=1;k<=n&&!flag;k++){
                if(G[i][k]+G[k][j]<G[i][j])
                    flag=true;
                else{
                    if(i!=k&&j!=k&&G[i][j]==G[i][k]+G[k][j])
                        flag2=true;
                }
            }
            if(!flag2)
                res+=G[i][j];
        }
    }

    if(flag)
        printf("-1\n");
    else
        printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 3968
from collections import OrderedDict
def solve():
    n = int(input())
    if n >= 52:
        return
    m = OrderedDict()
    for c in "SHCD":
        for i in range(1, 14):
            m[c + " " + str(i)] = 0
    for _ in range(n):
        del m[input()]
    print(*m.keys(), sep="\n")
solve()



Measured memory_bytes: 6000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int N;
    double ans, x;
    string u;
    cin >> N;
    lpn(i, N)
    {
        cin >> x >> u;
        ans += (u== "JPY" ? x : x * 380000.0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll x, y = 100;
    cin >> x;
    ll ans = 0;
    while (y < x) {
        y += y/ 100;
        ans++;
    }
    write(ans);
}

Measured memory_bytes: 3648
#include<cstdio>

int main(){
	char word[12];
	char eot[12] = "END_OF_TEXT";
	int i = 1;
	int count = 0;
	char c;
	bool b;

	word[0] = ' ';

	scanf("%c", &c);
	while(c - 10){
		if(96 < c && c < 123){
			word[i] = c - 32;
		}else{
			word[i] = c;
		}
		i++;
		scanf("%c", &c);
	}
	word[i] = ' ';
	i++;

	int j = 0, k = 0;

	c = ' ';
	char t = 'a';

	while(true){
		if(96 < c && c < 123){
			c -= 32;
			b = false;
		}else{
			if(c == '\n'){
				c = ' ';
			}
			b = true;
		}

		if(!(t == c && t == ' ')){
			if(word[j] == c){
				j++;
				if(j == i){
					count++;
					j = 1;
				}
			}else{
				j = 0;
			}

			if(eot[k] == c && b){
				k++;
				if(k == 11 ){
					printf("%d\n", count);
					return 0;
				}
			}else{
				k = 0;
			}
		}
		t = c;
		scanf("%c", &c);
	}
	return 0;
}

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

int main()
{
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(A, A + N);

    int mx = A[N-1];
    int cmp[mx + 1]; // cmp[i] := 配列Aに要素iが何個含まれるか
    fill(cmp, cmp + mx + 1, 0);
    for(int i = 0; i < N; ++i) cmp[A[i]]++;
    /*
    for(int i = 0; i < N; ++i) cout << A[i] << " ";
    cout << endl;
    for(int i = 0; i <= mx; ++i) cout << cmp[i] << " ";
    cout << endl;
    */
    int res = 0;
    for(int i = 0; i <= mx; ++i) {
        int j = i-1, k = i+1;
        int tmp = cmp[i];
        if(0 <= j ) tmp += cmp[j];
        if(k <= mx) tmp += cmp[k];
        if(res < tmp) res = tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024