akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

#define MAX 200005
using namespace std;

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

    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n) cin >> a[i];
    ll gp[n],gs[n];
    gp[0]=a[0];
    rep(i,1,n) {
        gp[i]=__gcd(gp[i-1],a[i]);
    }
    gs[n-1]=a[n-1];
    for(ll i=n-2;i>=0;i--) {
        gs[i]=__gcd(gs[i+1],a[i]);
    }

    ll ans=max(gp[n-2],gs[1]);
    rep(i,1,n-1) {
        ans=max(ans,__gcd(gp[i-1],gs[i+1]));
    }
    ret(ans);
}  

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      int c=0;
      for (String s : line)
        seqS[c++] = Integer.parseInt(s);

      int q = Integer.parseInt(br.readLine());
      line = br.readLine().split(" ");
      
      int cnt=0;
      for (String ref : line) {
        if( isExistSeachByBinary(seqS, Integer.parseInt(ref)) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] > ref ) right = mid;
      else if(tar[mid] < ref ) left = mid + 1;
      else return true;
    }

    return false;
  }
}


Measured memory_bytes: 51816
=begin
  －－－－－－－－－－－－－－
  n = ループ回数
  A = 数列
  ans = 分割回数(答)
  pre = 前回の数値(A[i-1])
  vec = 前回の不等号 (< == 1 , > == -1)
  －－－－－－－－－－－－－－
  1: 一つ前の数値と比べる
  2: A[i-1] 小なり A[i] の場合 
    2.1: vec が 1 ならそのまま
    2.2: vec が -1 なら ans += 1 vec = 0
  3: A[i-1] 大なり A[i] の場合
    3.1: vec が -1 ならそのまま
    3.2: vec が 1　なら ans += 1 vec = 0
  4: A[i] イコール A[i+1]　なら nil
  5: pre = A[i]
=end

n = gets.to_i
A = gets.split.map(&:to_i)

pre = A.first
vec = 0
ans = 0

A[1..-1].each{|v|
  if pre < v
    if vec == -1
      ans += 1
      vec = 0
    else
      vec = 1
    end
  elsif pre > v
    if vec == 1
      ans += 1
      vec = 0
    else
      vec = -1
    end
  else
    nil
  end
  pre = v
}

puts ans + 1

Measured memory_bytes: 8452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  char x;
  cin >> x;
  if(x=='a'||x=='i'||x=='u'||x=='e'||x=='o'){cout << "vowel" << endl;}
  else{cout << "consonant" << endl;}
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		boolean[] devided = new boolean[200000];
		ans = 0;

		for (int i = 2; i <= 100100; i++) {
			if (devided[i]) {

				continue;
			}
			if (i >= X) {
				ans = i;
				break;
			}
			for (int j = i; j < 200000; j += i) {
				devided[j] = true;
			}
		}
		System.out.println(ans);
	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}


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


int main(){
	int n,sum=0;
	cin>>n;
	int jem[n+1],cos[n+1];
	for(int i=1;i<=n;i++){
		cin>>jem[i];
	}
	for(int i=1;i<=n;i++){
		cin>>cos[i];
	}
	for(int i=1;i<=n;i++){
		if(jem[i]-cos[i]>0)
		sum+=jem[i]-cos[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void){
  int n,a,b;
 
  while(cin >> n,n){

    int A=0,B=0;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b)A+=a+b;
      else if(a<b)B+=a+b;
      else A+=a,B+=b;
    }
    cout << A <<" "<< B << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
d = [input().split() for i in range(n)]
total = 0

for i in range(n):
    if  len(set(d[i])) == len(d[i]):
        if total >=3:
            total +=0
        else:
            total = 0
    else:
        total += 1

if total >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define fifo ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define ll long long int
#define w(t) ll t; cin>>t; while(t--)
#define pb push_back
#define vll vector<long long int>
#define vi vector<int>
#define mp make_pair
/*
ll GCD(ll a,ll b)
{
	if(b==0)
	return a;
	else
	return GCD(b,a%b);
}


ll x,y,d;       //d is gcd x and y are coefficients
void exten_euclid(ll a,ll b)
{	ll temp;
	if(b==0)
	{
		d=a;
		x=1;
		y=0;	
	}
	else
	{
		exten_euclid(b,a%b);
		temp=x;
		x=y;
		y=temp-(a/b)*y;	
	}
return;
}

ll fastModExp(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		res=(res*a)%m;
	a=(a*a)%m;
	b=b>>1;	
	}
return res;
}


bool isPrime(ll n) {
	if(n==1)
      return false;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;               //O(root(N))
        }
    }
    return true;
}

vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

/*************FACTORIZE IN 0(LOG(N)) PROVIDED N IS INTEGER**************

int minPrime[100000];

void modified_sieve(int n){
for (int i = 2; i * i <= n; ++i) {
    if (minPrime[i] == 0) {         //If i is prime
        for (int j = i * i; j <= n; j += i) {
            if (minPrime[j] == 0) {
                minPrime[j] = i;
            }
        }
    }
}
for (int i = 2; i <= n; ++i) {
    if (minPrime[i] == 0) {
        minPrime[i] = i;
    }
}
}

vector<int> factorize(int n) {
    vector<int> res;
    while (n != 1) {
        res.push_back(minPrime[n]);
        n /= minPrime[n];
    }
    return res;
}

/*************************************************
void sieve(int N) {
        bool isPrime[N+1];
        for(int i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }


*/
ll binomialCoeff(ll n, ll k)  
{  
    ll res = 1;  
  
    // Since C(n, k) = C(n, n-k)  
    if ( k > n - k )  
        k = n - k;  
  
    // Calculate value of  
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
}  


int main()
{
fifo;
ll n,m,a=0,b=0;
cin>>n>>m;
if(n>1){
a=binomialCoeff(n,2);
}
if(m>1){
b=binomialCoeff(m,2);
}
cout<<a+b;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s, t;
  in(s);
  t = "2019/04/30";
  if(s == t){
    out("Heisei");
    memi;
    return 0;
  }
  rep(i, s.size()){
    if(s[i] < t[i]){
      out("Heisei");
      break;
    }
    if(s[i] > t[i]){
      out("TBD");
      break;
    }
  }
  memi;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############
x1,y1,x2,y2 = inputIL()


def super(X,Y):
  return nCr(X+Y+2,X+1)-1


A = super(x2,y2)
B = super(x2,y1-1)
C = super(x1-1,y2) 
D = super(x1-1,y1-1) 
print((A-B-C+D)%MOD)


Measured memory_bytes: 139616
package main

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

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

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	x, y := nextInt(), nextInt()
	if y%2 == 1 {
		fmt.Println("No")
		return
	}
	if x*2 > y || x*4 < y {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1772
def main():
    s=input()
    t=input()
    dp=[[0]*(len(t)+1) for _ in range(len(s)+1)]
    for i in range(1,len(s)+1):
        for j in range(1,len(t)+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
    i=len(s)
    j=len(t)
    result=[]
    while i!=0 and j!=0:
        if dp[i][j]==dp[i-1][j]:
            i-=1
        elif dp[i][j]==dp[i][j-1]:
            j-=1
        elif dp[i][j]==dp[i-1][j-1]+1:
            result.append(s[i-1])
            i-=1
            j-=1
    s="".join(result)
    s=s[::-1]
    print(s)
if __name__=="__main__":
    main()

Measured memory_bytes: 111452
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n; long long a[100], M = 0, m = 1000000000;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m = min(m, a[i]);
        M = max(M, a[i]);
    }
    cout << M - m << endl;
}


Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 1

[A,P] = inpl()
print((3*A+P)//2)

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int X, A, B;
    cin >> X >> A >> B;
    
    int ans = X - A;
    
    while (ans >= B) {
        ans -= B;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int h,w;
  for (int i = 0;; i++) {
    cin>>h>>w;
    if (h==0 && w==0) break;
    else {
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if ((i+j)%2==0) cout<<"#";
          else cout<<".";
        }
        cout<<endl;
      }
      cout<<endl;
    }
  }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi w(n);
	rep(i, n) cin >> w[i];
	int ans = inf, sum = accumulate(all(w), 0), sum2 = 0;
	rep(i, n){
		sum -= w[i];
		sum2 += w[i];
		ans = min(ans, abs(sum - sum2));
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N;cin>>N;
    stack<long> numbers;
    int count=0;
    int maximum=0;
    long a;cin>>a;
    for(int i=0;i<N-1;i++){
        long b;cin>>b;
        if(b<=a){
            count++;
            a=b;
        }else{
            maximum=max(maximum,count);
            a=b;
          count=0;
        }
      if(i==N-2)maximum=max(maximum,count);
    }
    cout<<maximum<<endl;
}

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

using namespace std;

int const nmax = 100;
int v[1 + nmax];

int main() {

  int n, k, p = 1;
  cin >> n >> k;
  for(int i = 1;i <= n;i++){
    p = min(p * 2, p + k);
  }
  cout << p;
  return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
int N;
ll ar[200000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> ar[i], ar[i] -= i;
	sort(ar, ar + N);
	ll center = ar[N / 2];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += abs(ar[i] - center);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
    boost;
    ll n,i,j,x;
    ll a,b;
    cin>>a>>b;
    ll ans=(a*b)/__gcd(a,b);
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    ll N,W;
    cin>>N>>W;
    vector<ll> w(200),v(200);
    rep(i,N) cin>>w.at(i)>>v.at(i);
    
    vector<vector<ll>> dp(110,vector<ll>(100010,0)); //dp[i][j]->i個目まで,重量j以下における価値の総和のmax,
    rep(i,N){
        rep(j,W+1){
            if(j>=w.at(i)) dp.at(i+1).at(j)=max((dp.at(i).at(j)),(dp.at(i).at(j-w.at(i))+v.at(i)));
            else dp.at(i+1).at(j)=dp.at(i).at(j);
        }
    }
    
    cout<<dp.at(N).at(W)<<endl;
        
}


Measured memory_bytes: 87296
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static String input;
    public static void main(String[] args) {
        while(read()){

        }

    }

    static boolean read(){
        if(sc.hasNextInt())return false;
        input = sc.next();
        solveFirstGame();
        for(int i = 1; i < 3; i++){
            input = sc.next();
            solveFirstGame();
        }
        return true;
    }

    static void solveFirstGame(){
        int A = 0, B = 0;
        for(int i = 1; i < input.length(); i++){
            if(input.charAt(i) == 'A')A++;
            if(input.charAt(i) == 'B')B++;
        }
        if(A > B){
            A++;
        }else{
            B++;
        }
        System.out.println(A + " " + B);
    }

    static void solve(){
        int A = 0, B = 0;

        System.out.println(A + " " + B);

    }

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  string s;cin >> s;
  vector<bool> _0(10,false);
  vector<bool> _1(100,false);
  vector<bool> _2(1000,false);
  rep(i,N){
    int num = s[i] - '0';
    rep(j,100) if(_1[j]) _2[10*j+num] = true;
    rep(j,10) if(_0[j]) _1[10*j+num] = true;
    _0[num] = true;
  }
  int count = 0;
  rep(j,1000)if(_2[j]) ++count;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin >> x;
    
    if(x < 1200){
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
}


Measured memory_bytes: 3600
# ?????\?????????????????°??????
import sys

def print_data(data):
    last_index = len(data) - 1
    
    for idx, item in enumerate(data):
        print(item, end='')
        if idx != last_index:
            print(' ', end='')

    print('')
        
def main():
    n = int(sys.stdin.readline().strip())
    data = [int(i) for i in sys.stdin.readline().strip().split(' ')]
    print_data(data)
    
    for i in range(1, n):
        v = data[i]
        j = i - 1

        while j >= 0 and data[j] > v:
            data[j+1] = data[j]
            j -= 1

        data[j+1] = v
        print_data(data)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    map<int,int>mp;
    mp[a]=1;
    mp[b]=1;
    mp[c]=1;
    mp[d]=1;
    mp[e]=1;
    for(int i=1; i<=5; i++){
        if(mp[i]!=1){
          cout<<i<<"\n";
          break;
        }
    }
}


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

int main() {

  string S;
  cin >> S;
  
  if(S.at(0) != S.at(1) && S.at(0) != S.at(2) && S.at(1) != S.at(2)) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  
}

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

int main(){
  int h1, h2, m1, m2, k;
  int t1, t2;
  int time;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  t1 = h1 * 60 + m1;
  t2 = h2 * 60 + m2;

  time = t2 - t1;


  if (time <= k) cout << "0" << endl;
  else{
    time -= k;
    cout << time << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
import sys
from functools import lru_cache

sys.setrecursionlimit(10**3)

import math

n = 0
k = 0

def format_input(filename = None):
	global n
	global k
	if filename == None:
		n = list(map(int, input().split())).pop()
		k = list(map(int, input().split())).pop()

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 10**100)
		k = rng(1, 3)

@lru_cache(maxsize=None)
def comb_rec(n, k, digits):
	if digits < k - 1:
		return 0
	if k == 0:
		return 1
	if digits == 0:
		return n
	top = n // 10 ** digits
	if top == 0:
		combination = comb_rec(n, k, digits - 1)
	elif top == 1:
		combination = comb_rec(n - 10 ** digits, k - 1, digits - 1)
		combination += comb_rec(10 ** digits - 1, k, digits - 1)
	else:
		combination = comb_rec(n - top * 10 ** digits, k - 1, digits - 1)
		combination += (top - 1) * comb_rec(10 ** digits - 1, k - 1, digits - 1)
		combination += comb_rec(10 ** digits - 1, k, digits - 1)
	return combination


def get_answer():
	digits = math.floor(math.log10(n))
	answer = comb_rec(n, k, digits)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


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

long long dp[3001][3001][2];

long long solve(vector<int> &arr, int i, int j, int turn){

    if(i>j)
        return 0;
    
    if(dp[i][j][turn] != -1)
        return dp[i][j][turn];

    if(turn == 1){
        return dp[i][j][turn] = max(arr[i] + solve(arr,i+1,j,0) , arr[j] + solve(arr,i,j-1,0));
    }
    else
        return dp[i][j][turn] = min(solve(arr,i+1,j,1) , solve(arr,i,j-1,1));
    
}

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

    vector<int> arr(n+1);
    memset(dp,-1,sizeof dp);

    long long sum = 0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        sum += arr[i];
    }

    long long x = solve(arr,1,n,1);
    long long y = sum - x;

    cout<<x-y;

    return 0;
}


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

now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
nums =[]

for i in range(n):
    if s[i] == str(now):
        cnt += 1
    else:
        nums.append(cnt)
        now ^= 1    #見る値の切り替え
        cnt = 1

if cnt != 0:
    nums.append(cnt)

if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * k + 1
ans = 0
left = 0
right = 0
tmp = 0

for i in range(len(nums))[::2]:
    next_left = i
    next_right = min(i+add, len(nums))
    # 尺取法
    while next_left > left:
        tmp -= nums[left]
        left += 1
    while next_right > right:
        tmp += nums[right]
        right += 1
    ans = max(tmp,ans)

print(ans)


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

#undef INT_MIN
#undef INT_MAX
#define LL long long
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775807
#define LL_MAX 9223372036854775807

int N,W;
pair<int,int> b[100];
int w[105],v[105];
LL dp[105][100100];
/*
long long solve(int now, int wlim){
	if(wlim < 0) return LL_MIN;
	if(now == N) return 0;
	if(dp[now][wlim] != -1) return dp[now][wlim];
	return dp[now][wlim] = max( solve(now+1, wlim) , solve(now+1, wlim-b[now].first) + b[now].second );
}
*/
int main(){
	cin >> N >> W;
	for(int i = 0; i<N; i++){
		for(int j=0; j<=W; j++){
			dp[i][j]=-1;
		}
	}
	for(int i=0; i<N; i++){
		int we,va;
		cin >> we >> va;
		b[i]=make_pair(we,va);
	}
	for(int i = 0; i <= W; i++) dp[N][i] = 0;

	for(int i = N-1; i >= 0; i--){
		for(int j = W; j >= 0; j--){
			dp[i][j] = dp[i+1][j];//not serect i
			if(j-b[i].first >= 0){
				dp[i][j]= max( dp[i][j], dp[i+1][j-b[i].first] + b[i].second );
			}
		}
	}
	
	cout << dp[0][W] << endl;
	return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


vector<int> divisor;
vector<int> extended_eratosthenes(int n){
    vector<int> arr(n,1);
    divisor[0] = 1;
    divisor[1] = 1;
	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
            divisor[i] = i;
			for(int j = 2; i * j < n; j++){
				arr[i*j] = 0;
                if(divisor[i*j] == -1){
                    divisor[i*j] = i;
                }
			}
		}
	}
    return arr;
}

int calculate_gcd(int a, int b){
    if(a<b){swap(a,b);}
    if(b<1){return 0;}
    int r;
    while((r = a%b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int num = 1000005;
    divisor.resize(num);
    for(int i = 0; i < num; i++){
        divisor[i] = -1;
    }
    extended_eratosthenes(num);
    for(int i = 0; i < num; i++){
        if(divisor[i] == -1){
            divisor[i] = i;
        }
    }

    vector<int> used(num, -1);
    bool is_pairwise_coprime = true;
    for(int i = 0; i < n; i++){
        int idx = a[i];
        while(divisor[idx] != 1){
            if(used[divisor[idx]] != -1 && used[divisor[idx]] != i){is_pairwise_coprime = false;}
            used[divisor[idx]] = i;
            idx /= divisor[idx];
        }
    }

    int s = a[0];
    for(int i = 0; i < n; i++){
        s = calculate_gcd(s, a[i]);
    }
    bool is_setwise_coprime = true;
    if(s != 1){
        is_setwise_coprime = false;
    }

    if(is_pairwise_coprime){
        cout << "pairwise coprime" << endl;
    }else if(is_setwise_coprime){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }


    return 0;
}


Measured memory_bytes: 14968
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int k;
   int a, b;
   cin >> k >> a >> b;
   for(int i = a;i <= b;i++) {
       if(i%k==0) {
           cout << "OK" << endl;
           return 0;
       }
   }
   cout << "NG" << endl;
}

Measured memory_bytes: 3668
package main

import (
	"fmt"
	"unicode/utf8"
	// "sort"
	//"regexp"
)

var s string

func main() {
	fmt.Scan(&s)
	length := utf8.RuneCountInString(s)
	m := map[string]int{}
	for i := 0; i < length; i++ {
		m[s[i:i+1]] = m[s[i:i+1]] + 1
	}
	for _, v := range m {
		if v > 1 {
			fmt.Print("no")
			return
		}
	}
	fmt.Println("yes")
}


Measured memory_bytes: 1836
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

using P = pair<int, int>;
#define fi first
#define se second
const size_t N = 6E2 + 5;

int n, m;
vector<P> g[N][N];
bool ok[N][N];
int col[N][N];

void dfs(int i, int j, int c = 1) {
    if (!ok[i][j]) return;
    if (col[i][j]) {
        assert(col[i][j] == c);
        return;
    }
    col[i][j] = c;
    for (auto &pr : g[i][j]) {
        dfs(pr.fi, pr.se, c ^ 3);
    }
}

vector<P> doit(const vector<P> &vc) {
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= m; ++j) {
            g[i][j].clear();
            col[i][j] = 0;
            for (auto &p : vc) {
                for (int di = -1; di <= 1; di += 2) {
                    for (int dj = -1; dj <= 1; dj += 2) {
                        int ti = i + di * p.fi;
                        int tj = j + dj * p.se;
                        if (1 <= ti && ti <= m && 1 <= tj && tj <= m) {
                            g[i][j].emplace_back(ti, tj);
                        }
                    }
                }
            }
        }
    }
    int cnt[3] = {0, 0, 0};
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (ok[i][j]) {
                if (!col[i][j]) {
                    dfs(i, j);
                }
                ++cnt[col[i][j]];
            }
        }
    }
    int c = 1 + (cnt[2] > cnt[1]);
    vector<P> ret;
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (col[i][j] == c) {
                ret.emplace_back(i, j);
            }
        }
    }
    return ret;
}

vector<P> get_vc(int d) {
    vector<P> vc;
    for (int i = 0; i <= m && i * i <= d; ++i) {
        int j = round(sqrt(d - i * i));
        if (i * i + j * j == d) {
            vc.emplace_back(i, j);
        }
    }
    return vc;
}

int main() {
    n = read();
    m = n << 1;

    for (int i = 1; i <= m; ++i) {
        fill(ok[i] + 1, ok[i] + m + 1, 1);
    }
    vector<P> coor = doit(get_vc(read()));
    memset(ok, 0, sizeof ok);
    for (auto &p : coor) {
        ok[p.fi][p.se] = true;
    }
    coor = doit(get_vc(read()));
    coor.resize(n * n);
    for (auto &p : coor) {
        printf("%d %d\n", p.fi - 1, p.se - 1);
    }
    return 0;
}


Measured memory_bytes: 117104
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int count = 0;
	static int[] selectedNum = new int[3];
	static int n;
	static int x;
	
	static void saiki(int index) {
		if (index == selectedNum.length) {
			int sum = 0;
			for (int num : selectedNum) {
				sum += num;
			}
			
			if (sum == x) {
				count++;
			}
			return;
		}
		
		int startNum = 1;
		
		if (index != 0) {
			startNum = selectedNum[index-1] + 1;
		}
		
		for (int i = startNum; i <= n; i++) {
			selectedNum[index] = i;
			saiki(index + 1);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> answers = new ArrayList<Integer>(); 
		
		while (true) {
			n = scan.nextInt();
			x = scan.nextInt();

			if (n == 0 && x == 0) {
				break;
			}
			
			count = 0;
			saiki(0);
			answers.add(count);
		}

		for (Integer ans : answers) {
			System.out.println(ans);
		}
		
		scan.close();
	}

}

Measured memory_bytes: 20032
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;
    cin >> n;
    int x = n%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9){
        cout << "hon" << endl;
    }else if(x==3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

string alpha="abcdefghijklmnopqrstuvwxyz";

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

  string s;
  int K;
  cin>>s>>K;
  for(int i=0;i<s.size();i++){
    int num=(int)(s[i]-'a');
    if(i==s.size()-1){
      num+=K;
      num%=alpha.size();
      s[i]=(char)('a'+num);
    }
    else if(s[i]=='a')continue;
    else if(K>=alpha.size()-num)s[i]='a',K-=(alpha.size()-num);
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}

const int INF=1e18;
const int MOD=1e9+7;
const int MAX=300001;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

void add(int &x, int y){
    x += y;
    x %= MOD;
}

int h, w, a, b, ans;

signed main(){
	COMinit();
    cin >> h >> w >> a >> b;
    for(int i = b+1;i<=w;i++) add(ans, COM(i-1+h-a-1,i-1)*COM(w-i+a-1,a-1));
    cout << ans << '\n';
}

Measured memory_bytes: 7296
#include<stdio.h>
int map[17][17][17][17];
int dp[17][17];
int p;
int gx,gy;
int ax,ay,bx,by;
int i,j,k,l;
int Tc,tc;
int main(){
  scanf("%d",&Tc);
  for(tc=0;tc<Tc;tc++){

    for(i=0;i<17;i++)
      for(j=0;j<17;j++)
	for(k=0;k<17;k++)
	  for(l=0;l<17;l++)
	    map[i][j][k][l]=0;



    scanf("%d %d",&gx,&gy);
    gx++;
    gy++;
    scanf("%d",&p);
	
    for(i=0;i<p;i++){
      scanf("%d %d %d %d",&ax,&ay,&bx,&by);
      ax++;
      ay++;
      bx++;
      by++;
      map[ax][ay][bx][by]=1;
      map[bx][by][ax][ay]=1;
    }

    for(i=1;i<=gx;i++){
      for(j=1;j<=gy;j++){
	if(i==1&&j==1){
	  dp[i][j]=1;
	}else{
	  dp[i][j]=0;
	  if(map[i][j][i-1][j]==0)dp[i][j]+=dp[i-1][j];
	  if(map[i][j][i][j-1]==0)dp[i][j]+=dp[i][j-1];
	}
      }
    }

    if(dp[gx][gy]==0){
      printf("Miserable Hokusai!\n");
    }else{
      printf("%d\n",dp[gx][gy]);
    }

  }
}

Measured memory_bytes: 1368
#include <stdio.h>

int main()
{
    int l, r;
    // int i, j;
    long i, j;
    long ijmod;
    long min =2019;

    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%d %d", &l, &r);

    if((r -l)/673 >= 1){ //2019 = 673 / 3
        // printf("673 must included.\n");
        printf("%d", 0);
    }else{
        for (i = l; i <= r-1; i++){
            for (j = i+1; j <= r; j++){
                // ijmod = ((long)i * j) % 2019;
                ijmod = (i * j) % 2019;
                if (min > ijmod){
                    // printf("i = %d j = %d : change %d -> %ld\n", i, j ,min, ijmod);
                    min = ijmod;
                }
            }
        }
        printf("%ld", min);
    }
    //printf("%ld", min);
}

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

int main () {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> adj(3*N);

  rep(i,M) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    adj[u].push_back(v+N);
    adj[u+N].push_back(v+2*N);
    adj[u+2*N].push_back(v);
  }

  int S, T;
  cin >> S >> T;
  S--; T--;

  vector<int> dist(3*N, -3);
  dist[S] = 0;

  queue<int> q;
  q.push(S);

  while(!q.empty()) {
    int u = q.front(); q.pop();
    for(auto v: adj[u]) {
      if(dist[v] != -3) continue;
      dist[v] = dist[u] + 1;
      q.push(v);
    }
  }

  cout << dist[T] / 3 << endl;

  return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n;
vstr ans;
string alpha = "abcdefghijklmn";
void dfs(string s, int d, int id) {
    if (d >= n) {
        ans.push_back(s);
        return;
    }
    rep(i, id+2) dfs(s + alpha[i], d+1, max(i, id));
}

int main() {
    cin >> n;
    dfs("a", 1, 0);
    for (string s : ans) cout << s << endl;
    return 0;
}

Measured memory_bytes: 7796
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var readData = long.Parse(Console.ReadLine());
            if(readData >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
                
        }
    }
}


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

int main(){
  int N,A;
  cin >> N;
  cin >> A;
  int remainder = N % 500;
  if(remainder == 0){
    cout << "Yes" << endl;
  }else if(remainder <= A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main()
{
	int N, X = 0, Y = 0;
  int V[20], C[20];
	
	cin >> N;
  
  	
	
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	
	for (int i = 0; i < N; i++) {
		if (V[i] > C[i]) {
			X += V[i];
			Y += C[i];
		}
	}
	
	cout << X - Y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N, M;
vector<vector<int>> G;
int DP[100000];
int solve(int v){
    if (DP[v] != -1) return DP[v];
    if (G[v].size() == 0) {
        DP[v] = 0;
        return 0;
    }
    int res = 0;
    for (auto & u : G[v]){
        chmax(res, 1 + solve(u));
    }
    DP[v] = res;
    return res;
}
int main() {
    cin >> N;
    cin >> M;
    G.assign(N, vector<int>());
    REP(i, N) {
        DP[i] = -1;
    }
    REP(i, M) {
        int x, y;
        cin >> x;cin >> y;
        G[x-1].push_back(y-1);
    }
    int ans = 0;
    REP(i, N) {
        chmax(ans, solve(i));
    }
    cout << ans;
}

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

int main() {
  int n; cin >> n;
  vector<P> p(n);
  rep(i,n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());
  ll t = 0;
  rep(i,n) {
    t += p[i].second;
    if (t > p[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n+2);
    a[0] = 0;
    rep(i, n) cin >> a[i+1];
    a[n+1] = 0;
    ll sum = 0;
    rep(i, n+1) {
        sum += abs(a[i+1] - a[i]);
    }
    //cout << sum << endl;
    for (int i = 1; i <= n; ++i) {
        cout << sum - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3956
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

const MOD: usize = 1_000_000_007;

#[fastout]
fn solve() {
    input!{
        n: usize, l: usize,
        mut s_vec: [String; n],
    }
    s_vec.sort();
    println!("{}", s_vec.join(""));
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2148