akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>

using ll = long long;

using namespace std;

int main() {
    while (true) {
        int r, n; cin >> r >> n;
        if (r == 0) break;
        int height[40] = {0};
        int heightl[40] = {0};
        int heightr[40] = {0};
        for (int i=0, xl, xr, h; i<n; i++) {
            cin >> xl >> xr >> h;
            heightl[xl+20] = max(heightl[xl+20], h);
            heightr[xr+20] = max(heightr[xr+20], h);
            for (int x=xl+1; x<xr; x++) {
                height[x + 20] = max(height[x + 20], h);
            }
        }
        double ans = 100;
        for (int x=-r; x<=r; x++) {
            int h;
            if (x == -r) h = max(height[x + 20], heightl[x + 20]);
            else if (x == r)  h = max(height[x + 20], heightr[x + 20]);
            else h = min(max(height[x + 20], heightl[x + 20]), max(height[x + 20], heightr[x + 20]));
            ans = min(ans, (double)h - (sqrt(r*r - x*x) - r));
        }
        cout << setprecision(15) << fixed << ans << '\n';
    }
    return 0;
}


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

#define pb push_back

#define ll long long

// download zambak book volume 1 phisics pdf free download

#define ft first

#define sd second

using namespace std;

const int N = 5050 ;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = k;
    for ( int i = 0; i < n - 1; i++ ) {
        ans *= k - 1;
    }
    cout << ans;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    l = LI()
    s = sum(l)
    m = max(l)
    if 2*m < s:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include<stdio.h>

int n,A[50];

int solve(int,int);

int main(){
  int q,M,i;

  scanf("%d",&n);  
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;

  res=solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}


Measured memory_bytes: 2108
N,K = map(int,input().split())
A = list(map(int,input().split()))
hoge = [[]for i in range(200001)]
for i in range(N):
    hoge[A[i]].append(i)
NEXT = [-1]*N
for i in hoge:
    for j in range(-len(i),0):
        NEXT[i[j]] = i[j+1]
i = 1
p = 0
while i < K:
    #print(i,p)
    if NEXT[p] <= p:
        i += 1
    if NEXT[p] == N-1:
        i += 1
    p = (NEXT[p]+1)%N
    if p == 0:
        i = (K//(i-1))*(i-1)+1
while p < N:
    if NEXT[p] <= p:
        print(A[p],end = " ")
        p += 1
    else:
        p = NEXT[p]+1
print()

Measured memory_bytes: 103376
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#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 < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int x;
    cin >> x;
    cout << x * x * x << endl;
}


Measured memory_bytes: 3100
ringstr = raw_input()
matchstr = raw_input()

ringstrlen = len(ringstr)
matchstrlen = len(matchstr)
x = 0 # match length
y = 0 # ring length
hitflag = False
finflag = False
while True:
    if x == matchstrlen:
        print "Yes"
        break
    if y == ringstrlen:
        y=0
        finflag =True
    if matchstr[x]==ringstr[y]:
        x+=1
        if not hitflag:
            tmpy = y
            hitflag = True
        y+=1
    else:
        if hitflag:
            hitflag = False
            if finflag:
                print "No"
                break
            x=0
            y=tmpy+1
            continue
        else:
            if y == ringstrlen-1:
                print "No"
                break
            y+=1

Measured memory_bytes: 6460
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int main(){
	int n,m;
	cin>>n>>m;
	cout<<n-m+1<<endl;
	return 0;
}

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

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

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  int count=0;
  int res;
  int MINX=vec.at(0);
  int MAXX=vec.at(N-1); 
  for (int i = MINX; i < MAXX+1; i++) {
    int X=0;
    for (int j = 0; j < N; j++) {
      X+=(i-vec.at(j))*(i-vec.at(j));
    }
    if (i==MINX) count=X;
    else count=min(count,X); 
  }

  cout << count << endl;
} 

Measured memory_bytes: 256
N = int( input())
A = list( map( int, input().split()))
zero = 0
ni = 0
yon = 0
for a in A:
    if a%2 == 1:
        zero += 1
    elif not a%4 == 0:
        ni += 1
    else:
        yon += 1
if ni == 0:
    if yon + 1 >= zero:
        print('Yes')
    else:
        print('No')
else:
    if yon >= zero:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14252
// The Secret Number
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1126

#include<iostream>
#include<vector>

using namespace std;

int W, H;
vector<string> matrix;
vector<vector<string>> memo;

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

inline bool is_out_of_range(int x, int y) {
    return (x < 0 || x >= W || y < 0 || y >= H);
}

string cmp(string a, string b) {
    if (a.size() > b.size()) return a;
    if (a.size() < b.size()) return b;
    return max(a, b);
}

string dfs(int x, int y) {
    if (is_out_of_range(x, y)) return "";
    if (!isdigit(matrix[y][x])) return "";
    if (memo[y][x] != "") return memo[y][x];

    string res = "";
    for (int d = 0; d < 2; ++d) {
        res = cmp(res, matrix[y][x] + dfs(x + dx[d], y + dy[d]));
    }
    memo[y][x] = res;
    return res;
}

int main() {
    while (cin >> W >> H && W) {
        matrix = vector<string>(H, ""); 
        memo.assign(H, vector<string>(W, ""));
        for (int h = 0; h < H; ++h) {
            cin >> matrix[h];
        }

        string ans = "";
        for (int y = 0; y < H; ++y) {
            for (int x = 0; x < W; ++x) {
                if (matrix[y][x] == '0' || !isdigit(matrix[y][x])) continue;
                ans = cmp(ans, dfs(x, y));
            }
        }

        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	int n, a, b; cin >> n >> a >> b;
	int p[n];
	int p1 = 0, p2 = 0, p3 = 0;
	for(int i = 0; i < n; ++i) cin >> p[i];
	for(int i = 0; i < n; ++i){
		if(p[i] <= a) p1++;
		else if(p[i] <= b) p2++;
		else p3++;
	}
	cout << min(p1, min(p2, p3)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
int main(){
    Int N, T;
    cin >> N >> T;
    constexpr Int inf = (1e18);
    vector<vector<Int>>dp(N + 1,vector<Int>(3000 * 3,-inf));
    using tp = tuple<Int,Int>;
    vector<tp>data;
    for(int i = 0; i < N; ++i){
        int a,b; cin >> a >> b;
        data.emplace_back(a,b);
    }
    sort(data.begin(), data.end() , [](tp a, tp b){
        int c,d,e,f; tie(c,d) = a; tie(e,f) = b;
        if(c == e){
            return d > f;
        } else {
            return c < e;
        }
    });
    dp[0][0] = 0;
    for(int i = 0; i + 1 < dp.size(); ++i){
        Int a,b; tie(a,b) = data[i];
        for(int j = 0; j < dp[i].size(); ++j){
             cmax(dp[i + 1][j], dp[i][j]);
            if(dp[i][j] == -inf or j >= T) continue;
            if(j + a < dp[i+1].size()){
                cmax(dp[i + 1][j + a], dp[i][j] + b);
            }
        }
    }
    cout << *max_element(dp.back().begin(),dp.back().end()) << endl;
}




Measured memory_bytes: 211456
import sys
input=sys.stdin.readline
import heapq
n,m=map(int,input().split())

D=[0]
P=[]
ans=float("inf")

for i in range(m):
  l,r,c=map(int,input().split())
  P.append((l,r,c))
P.sort(key=lambda x:x[0])
heapq.heappush(D,0*10**15+1)
for l,r,c in P:
  while D:
    ld=heapq.heappop(D)
    dd=ld//(10**15)
    ll=ld%(10**15)
    if ll<l:
      continue
    else:
      break
  if ll>=l:
    heapq.heappush(D,r+(dd+c)*10**15)
  heapq.heappush(D,ll+dd*10**15)
while D:
  ld=heapq.heappop(D)
  dd=ld//(10**15)
  ll=ld%(10**15)
  if ll==n:
    ans=min(ans,dd)
print(-1 if ans==float("inf") else ans)


  

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n); rep(i, n) cin >> a[i] >> b[i];
    vector<vector<int>> c(100100);
    rep(i, n) {
        c[a[i]].push_back(b[i]);
    }

    ll ans = 0;
    priority_queue<int> pq;
    for (int i = m-1; i >= 0; --i) {
        for (auto x: c[m-i]) pq.push(x);
        if (!pq.empty()) {
            ans += pq.top(); pq.pop();
        }
    }

    cout << ans << endl;



    return 0;
}


    


Measured memory_bytes: 6400
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,k;
    cin>>a>>b>>k;
    for(int i=100;i>=0;i--){
        if(a%i==0 && b%i==0)--k;
        if(k==0){cout<<i;return 0;}
    }
}


Measured memory_bytes: 3644
import java.util.Scanner;

class Main {

	public static final double PI = 3.14159;

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int r = stdIn.nextInt();
		final double one = 1 * 1 * PI;
		final double s = r * r * PI;
		System.out.println((int)(s / one));
	}
	
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
#include<numeric>
#include<queue>
using namespace std;

long long int mod = 1000000007;
vector<bool> isPrime(long long int n){
  vector<bool> prime(n+1, true);
  prime[0] = false;
  prime[1] = false;
  for(long long int i=2; i<=sqrt(n); i++){
    if( !prime[i] ) continue;
    for(long long int j=i*2; j<=n; j+=i){
      prime[j] = false;
    }
  }
  return prime;
}
int main(void) {

  vector<bool> p = isPrime(2000000);
  long long int a, d, n;
  while(cin >> a >> d >> n){
    if( a == 0 ) break;

    while( n != 0 ){
      if( p[ a ] ) n--;
      if( n == 0 ) cout << a << endl;
      a += d;
    }

  }


  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int ma = (n-1)*(n-2)/2;
    if(ma<k) cout<<-1<<endl;
    else{
        vector<P> res;
        for(int i=1;i<n;i++) res.push_back({i,n});
        int rem = ma - k;
        int ci=1,cj=2;
        for(int k=0;k<rem;k++){
            res.push_back({ci,cj});
            ++cj;
            if(cj==n){
                ++ci;
                cj=ci+1;
            }
        }
        cout<<res.size()<<endl;
        for(auto p:res) cout<<p.first<<" "<<p.second<<endl;
    }

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
vector<int>graph[100001];
set<pair<int,int>>st;
char arr[1001][1001];
bool visit[1001][1001];
void dfs(int x,int y,int n,int m){
	
}
signed main(){
	FAST
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int dp[n][k+1],pr[n][k+1];
	sort(arr,arr+n);
	for(int i=0;i<n;i++){
		dp[i][0]=1;
		pr[i][0]=1;
	}
	for(int i=1;i<=k;i++){
		if(i<=arr[0]){
			dp[0][i]=1;
		}
		else{
			dp[0][i]=0;
		}
		pr[0][i]=(pr[0][i-1]+dp[0][i])%mod;
		//cout<<pr[0][i]<<" ";
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(j-arr[i]<=0){
				dp[i][j]=pr[i-1][j];
			}
			else{
				dp[i][j]=(pr[i-1][j]-pr[i-1][j-arr[i]-1]+mod)%mod;
			}
			dp[i][j]%=mod;
			pr[i][j]=(pr[i][j-1]+dp[i][j])%mod;
		}
	}
//	for(int i=0;i<n;i++){
//		for(int j=0;j<=k;j++){
//			cout<<pr[i][j]<<" ";
//		}
//		cout<<endl;
//	}
//	for(int i=0;i<n;i++){
//		for(int j=0;j<=k;j++){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	cout<<dp[n-1][k];
}

Measured memory_bytes: 160640
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> ppiii;

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s;
    cin >> s;
    if(s[s.length() - 1] == 's') cout << s + "es" << endl;
    else cout << s + "s" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#define  M   2000001

void counting_sort(int a[], int b[], int n);
void print_data(int data[], int array_length);

int work_data[M-1];

int count[M+1];

int main(int argc, char **argv)
{
  int i,N,src_data[M];
    scanf("%d",&N);
    for(i=0;i<N;i++){
      scanf("%d",&src_data[i]);
    }
    counting_sort(src_data, work_data, N);
    print_data(work_data, N);
    return 0;
}

void counting_sort(int a[], int b[], int n)
{
    int  i;
    for (i = 0; i <= M; i++)
        count[i] = 0;

    for (i = 0; i < n; i++)
        count[a[i]]++;

    for (i = 0; i < M; i++) {
        count[i+1] += count[i];
    }

    for (i = n - 1; i >= 0; i--) {
        b[--count[a[i]]] = a[i];
    }
}

void print_data(int data[], int array_length)
{
    int i;
    for (i = 0; i < array_length-1; i++) {
        printf("%d ", data[i]);
    }
    printf("%d",data[array_length-1]);
    printf("\n");
}


Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
int main(void){
	int a,b;
	cin>>a>>b;
	print(ceil((a+b)/2.0));

	return 0;
}


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

int main(){
	char arr[4];
	cin>>arr;
	int k=0;
	int count=0;
	for(int i=0;i<3;i++){
		if(arr[i]=='R')
			count++;
		else 
		{
			k=max(k,count);
			count=0;
		}
	}
	k=max(k,count);
	cout<<k;
}

Measured memory_bytes: 3504
unittest
{
	assert( [ "2 60", "10 10", "100 100" ].solve == 110 );
	assert( [ "3 60", "10 10", "10 20", "10 30" ].solve == 60 );
	assert( [ "3 60", "30 10", "30 20", "30 30" ].solve == 50 );
	assert( [ "10 100", "15 23", "20 18", "13 17", "24 12", "18 29", "19 27", "23 21", "18 20", "27 15", "22 25" ].solve == 145 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto t = 0L;
	input.front.formattedRead!"%s %s"( n, t );
	auto abs = new long[ 2 ][ n ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	
	// dp[ i番目の料理 ][ 経過した時間 ][ ラストオーダー済フラグ ] = おいしさの合計
	auto dp = new long[][][]( 1 + n, t, 2 );
	foreach( i, ab; abs )
	{
		foreach( j; 0L .. t )
		{
			// 食べない
			dp[ i + 1 ][ j ][ 0 ] = max( dp[ i + 1 ][ j ][ 0 ], dp[ i ][ j ][ 0 ] );
			dp[ i + 1 ][ j ][ 1 ] = max( dp[ i + 1 ][ j ][ 1 ], dp[ i ][ j ][ 1 ] );
			
			// 食べる
			auto jj = j + ab[ 0 ];
			if( jj < t )
			{
				dp[ i + 1 ][ jj ][ 0 ] = max( dp[ i + 1 ][ jj ][ 0 ], dp[ i ][ j ][ 0 ] + ab[ 1 ] );
				dp[ i + 1 ][ jj ][ 1 ] = max( dp[ i + 1 ][ jj ][ 1 ], dp[ i ][ j ][ 1 ] + ab[ 1 ] );
			}
			
			// 最後に食べる
			dp[ i + 1 ][ j ][ 1 ] = max( dp[ i + 1 ][ j ][ 1 ], dp[ i ][ j ][ 0 ] + ab[ 1 ] );
		}
	}
	return dp[ $ - 1 ][ $ - 1 ].reduce!max;
}


Measured memory_bytes: 437800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    int x, y; cin >> x >> y;

    deque<int> X, Y;
    bool even = true;
    int cnt = 0;
    FOR(i, 0, n) {
        if (s[i] == 'F')++cnt;
        else {
            if (even)X.push_back(cnt);
            else Y.push_back(cnt);
            cnt = 0;
            even ^= true;
        }
    }
    if (even)X.push_back(cnt);
    else Y.push_back(cnt);
    cnt = 0;
    even ^= true;

    int nx = X.front(), ny = 0;
    X.pop_front();
    int xsize = X.size(), ysize = Y.size();
    vector<vector<bool>> xdp(xsize + 1, vector<bool>(16010, false));
    vector<vector<bool>> ydp(ysize + 1, vector<bool>(16010, false));
    xdp[0][nx + 8000] = true;
    ydp[0][ny + 8000] = true;
    FOR(i, 0, xsize)FOR(j, 0, 16010) {
        if (xdp[i][j]) {
            xdp[i + 1][j + X[i]] = true;
            xdp[i + 1][j - X[i]] = true;
        }
    }
    FOR(i, 0, ysize)FOR(j, 0, 16010) {
        if (ydp[i][j]) {
            ydp[i + 1][j + Y[i]] = true;
            ydp[i + 1][j - Y[i]] = true;
        }
    }

    cout << (xdp[xsize][x + 8000] && ydp[ysize][y + 8000] ? "Yes\n" : "No\n");
}


Measured memory_bytes: 16256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int N;
  cin >> N;
  int ans = 0;
  FOR(i,0,N){
    int s, f;
    cin >> s >> f;
    if(!(b <= s || a >= f)) ans = 1;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    double A, B;
    double H, M;
    cin >> A >> B >> H >> M;
    double miji = H*30 + M/2;
    double naga = M*6;
    double kakudo = abs(miji-naga);
    kakudo = min(kakudo, 360-kakudo);
    double rad = kakudo*(PI/180);
    double ans = sqrt(A*A + B*B - 2*A*B*cos(rad));
    PRINTD(ans, 18);
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define fi first
#define sc second
vector<int>vec;
int n,m,x;
int main(){
	cin >> n >> m >> x;
	rep(i,x){
		int a,b; cin >> a >> b;
		a = n+1-a;
		if(b <= m) a += m+1-b;
		else a += b-m;
		vec.pb(a);
	}
	sort(vec.begin(),vec.end());
	int ans = 0;
	rep(i,vec.size()) ans = max(ans,vec[i]+(int)(vec.size())-1-i);
	cout << ans << endl;
}



Measured memory_bytes: 4788
def mochi(d):
    d.sort(reverse=True)
    before = 101
    cnt = 0
    for n in d:
        if n >= before:
            continue
        before = n
        cnt += 1
    return cnt

n = int(input())
d = []
for i in range(n):
    d.append(int(input()))
print(mochi(d))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

long long N,M;
cin>>N>>M;
long long t=M/N;
for(long long i=t;i>0;i--){
    long long res=M-i*N;
    if(res%i==0){
        cout<<i<<endl;
        break;
    }
}
 return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int N;
    long sum = 0;
    cin >> N;
    for(int i = 0; i < N + 1; i++){
        if(i%3 != 0 && i%5 != 0) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
char a[100][100], b[50][50]; 
int main() {
  int n,m;
  cin >> n >> m;
  rep(i,n) rep(j,n) cin >> a[i][j];
  rep(i,m) rep(j,m) cin >> b[i][j];

  for (int i = 0; m+i <= n; i++)
  {
    for (int j = 0; m+j <= n; j++) //(i,j)からスタートして比較する
    {
      bool ok = true;
      rep(k,m) rep(l,m) {
        if (b[k][l] != a[k+i][l+j]) {ok = false; continue;}
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    
  }
  
  cout << "No" << endl;
  return 0;
  
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n),psum(n+1);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    psum[i+1] = psum[i]+a[i];
  }
  vector<vector<ll>> first(n,vector<ll>(n));
  for(int i = 0; i < n; ++i) first[i][i] = a[i];
  for(int l = 1; l < n; ++l){
    for(int i = 0; i+l < n; ++i){
      ll val1 = a[i] + (psum[i+l+1]-psum[i+1]-first[i+1][i+l]);
      ll val2 = a[i+l] + (psum[i+l]-psum[i]-first[i][i+l-1]);
      first[i][i+l] = max(val1,val2);
    }
  }
  cout << 2*first[0][n-1] - psum[n];
  return 0;
}

Measured memory_bytes: 73652
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    //double a;
    int x,y;
};
vector<P> v[510];

int a,b,c,i,k,d,n,p,m,e,dy[15]={0,0,-1,1},dx[15]={-1,1};
int l[15010];
int o[13013];
int dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[1021600];
int j[40040];
queue<int> q;
queue<int> q1;
stack<int> s,s1;
//queue<P> q;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,long long > p;
string r;
//char r[1000310];
//char r1[1000222];
bool as(P a,P b)
{
    return max(a.x,-a.x)<max(b.x,-b.x);
}





int f(int a)
{
    if(j[a]==a) return a;
    return j[a]=f(j[a]);
}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;k+=m-n+1,t++)
        scanf("%d %d",&n,&m);
    printf("%d",k);
}



Measured memory_bytes: 256
import java.io.*;

class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strarr = str.split(" ");
        
        int num1 = Integer.parseInt(strarr[0]);
        int num2 = Integer.parseInt(strarr[1]);
        System.out.println(num1*num2 + " " + (num1+num2)*2);
    }
    
}


Measured memory_bytes: 24208
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>

using namespace std;

#define spc " "
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;
typedef tuple<int, int, int, int> tup;

ll divc(ll a, ll b){ //割り算(切り上げ)
    return (a + b - 1) / b;
}

//------------------------------------------------------------------------------

int main(){
    ll n;
    cin >> n;
    
    ll mi = 10000;
    for(int i = 0; i < n - 2; i++){
        ll t = n % 1000;
        n /= 10;
        mi = min(mi, abs(t - 753));
    }

    cout << mi << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				Integer H = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer W = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				if (H == 0 && W == 0) {
					return;
				}
				for (int i = 0; i < H; i++) {
					int amari;
					amari = i - i / 2 * 2 == 0 ? 0 : 1;
					for (int j = 0; j < W; j++) {
						if (j - j / 2 * 2 + amari == 1) {
							System.out.print(".");
						}
						else {
							System.out.print("#");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 31536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N;
    cin >> N;
    priority_queue<double, vector<double>, greater<double> >Q;
    for(ll i = 0; i < N; i++){
        double v;
        cin >> v;
        Q.push(v);
    }
    while(Q.size() > 1){
        double x = Q.top(); Q.pop();
        double y = Q.top(); Q.pop();
        Q.push((x + y) * 0.5);
    }
    printf("%.9f\n", Q.top());

    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from math import sqrt
from sys import stdin
input = stdin.buffer.readline

def main():
    xs, ys, xt, yt = map(int, input().split())
    n = int(input())

    xyr = [(0, 0, 0)] * (n+2)
    xyr[0] = (xs, ys, 0)
    xyr[1] = (xt, yt, 0)
    for i in range(2, n+2):
        x, y, r = map(int, input().split())
        xyr[i] = (x, y, r)

    # dijkstra
    heap = []
    heappush(heap, (0.0, 0))
    seen = [-1] * (n+2)
    yet = set(range(n+2))
    while True:
        time, ind = heappop(heap)

        if ind == 1:
            print(time)
            break

        if seen[ind] == -1:
            seen[ind] = time
            yet.remove(ind)
            x, y, r = xyr[ind]
            for i in yet:
                xi, yi, ri = xyr[i]
                heappush(heap, (max(sqrt((x-xi)*(x-xi)+(y-yi)*(y-yi))-r-ri, 0.0)+time, i))

main()

Measured memory_bytes: 131672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    while(!(A % 2) && !(B % 2) && !(C % 2)) {
        int tmpA = A, tmpB = B, tmpC = C;
        A = (tmpB + tmpC) / 2;
        B = (tmpA + tmpC) / 2;
        C = (tmpA + tmpB) / 2;
        ++ans;
        if(ans > 500000) A = 1, ans = -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w;
while(1){

cin >>h>>w;

if(h==0&&w==0){
break;
}

else{

for(int i=0;i<h;i++){

for(int  j=0;j<w;j++){

cout <<"#";

}
cout <<endl;

}

cout <<endl;

}

}

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   int a,b;
   cin>>a>>b;
   if(1<=a && a<=9 && 1<=b && b<=9) cout<<a*b<<endl;
   else cout<<-1<<endl;
   
    return 0;
}

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

int main(){
  vector<int> a(4);
  rep(i,4) cin >> a[i];
  
  int dif = 1e9;
  for (int s = 0; s < (1 << 4); s++) {
    if (__builtin_popcount(s) != 2) continue;
    int c = 0, d = 0;
    for (int i = 0; i < 4; i++) {
      if (s & (1 << i)) c += a[i];
      else d += a[i];
    } 
    if (abs(c - d) < dif) {
      dif = abs(c - d);
    }
  }
  cout << dif << endl;
  return 0;
} 


Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int A, B, C; cin >> A >> B >> C;
    int K; cin >> K;
    
    bool ok1 = false;

    while(true) {
        if (K > 0 and A >= B) {
            B *= 2;
            K--;
        }
        if (A < B) {
            ok1 = true;
            break;
        }
        if (K == 0) {
            break;
        }
    }

    if (!ok1) {
        cout << "No" << endl;
        return 0;
    }

    bool ok2 = false;

    while(true) {
        if (K > 0 and B >= C) {
            C *= 2;
            K--;
        }
        if (B < C) {
            ok2 = true;
            break;
        }
        if (K == 0) {
            break;
        }
    }

    if (!ok2) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int S3[1024];

int main()
{
	rep (S, 1024 ){
		int stat = 0;
		rep (j, 10 ) if (S & (1<<j) ) {
			stat ^= 1<<j;
			if (j > 0 ) stat ^= 1<<(j-1);
			if (j < 9 ) stat ^= 1<<(j+1);
		} // end rep
		S3[S] = stat;
	} // end rep
	int T; scanf ("%d", &T );
	while (T--){
		int org[10] = {};
		rep (i, 10 ) rep (j, 10 ){
			int tmp; scanf ("%d", &tmp );
			org[i] |= tmp<<j;
		} // end rep
		
		int ans = -1;
		rep (S, 1024 ){
			int grid[10];
			rep (i, 10 ) grid[i] = org[i];
		
			grid[0] ^= S3[S];
			grid[1] ^= S;
			for (int i = 1; i < 10; i++ ){
				int pttn = grid[i-1];
				grid[i-1] = 0;
				grid[i] ^= S3[pttn];
				if (i < 9 ) grid[i+1]^=pttn;
			} // end if
			if (grid[9] == 0 ){
				ans = S; break;
			} // end if
		} // end rep
	
		rep (j, 10 ) printf ("%d%c", !!(ans&(1<<j)), j<9 ? ' ' :'\n' );
		org[0] ^= S3[ans];
		org[1] ^= ans;
		for (int i = 1; i < 10; i++ ){
			int pttn = org[i-1];
			org[i-1] = 0;
			org[i] ^= S3[pttn];
			if (i < 10 ) org[i+1]^=pttn;
			rep (j, 10 ) printf ("%d%c", !!(pttn&(1<<j)), j<9 ? ' ' : '\n' ); 
		} // end for
	} // end while

	return 0;
}

Measured memory_bytes: 1192
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

mod = 10**9+7

pl = 0
zr = 0
mn = 0

a.sort()

for i in range(n):
    if a[i] == 0:
        zr += 1
    elif a[i] > 0:
        pl += 1
    elif a[i] < 0:
        mn += 1

hugo = 0
        
if zr == 0 and pl == 0 and k % 2 == 1:
    hugo = 3#mn
elif zr >= 1 and pl == 0 and k % 2 == 1:
    hugo = 2#zr
else:
    hugo = 1#pl

ans = 1
tmp_ans = 1
    
if hugo == 3:
    for i in range(k):
        ans *= a[mn-1-i]
        ans %= mod
    print(ans%mod)
elif hugo == 2:
    print(0)
else:
    if mn == 0:
        for i in range(k):
            tmp_ans *= a[n-1-i]
            tmp_ans %= mod
        print(tmp_ans)
    else:
        tmp = k
        pl_num = 0
        mn_num = 0
        if tmp % 2 == 1:
            tmp -= 1
            pl_num += 1
            tmp_ans = a[n-1]
        while tmp > 0:
            if tmp >= 2:
                tmp -= 2
                tmp_p_seki = 0
                tmp_m_seki = 0
                if pl_num+1 <= pl:
                    tmp_p_seki = a[n-1-pl_num]*a[n-1-pl_num-1]
                if mn_num+1 <= mn:
                    tmp_m_seki = a[mn_num+0]*a[mn_num+1]
                if tmp_p_seki > tmp_m_seki:
                    tmp_seki = tmp_p_seki
                    pl_num += 2
                elif tmp_p_seki == 0 and tmp_m_seki == 0:
                    tmp_seki = 0
                else:
                    tmp_seki = tmp_m_seki
                    mn_num += 2
            tmp_ans *= tmp_seki
            tmp_ans %= mod
                    
            
        print(tmp_ans%mod)

Measured memory_bytes: 31756
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a{1,3,5,7,8,10,12};
    vector<int> b{4,6,9,11},c{2};
    int q,w,x=0,y=0,z=0;
    cin>>q>>w;
    if(q==2&&w==2);
    for(int i=0;i<7;i++){
      if(q==a[i]||w==a[i]) x++;
      if(q==b[i]||w==b[i]) y++;
      if(q==2||w==2) z++;
    }
    if(x==2||y==2||z==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
#a = int(input())
 
k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
'''
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
'''
 
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])
#print(a+pow(a,2)+pow(a,3))

for i in range(k):
    print("ACL", end='')

Measured memory_bytes: 9152
#include<iostream>
using namespace std;
int main(){
  long n,maxe,mine,a;
  cin>>n;
  maxe=0;
  mine=10000000000;
  for(int i=0;i<n;i++){
    cin>>a;
    mine = min(a,mine);
    maxe = max(a,maxe);
  };
  cout<<abs(maxe-mine)<<endl;
}


Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#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;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    char c;
    cin>>c;
    c++;
    cout<<c<<endl;
	return 0;
}


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

int main() {
  
  string o,e;
  cin >> o >> e;
  
  if ( o.size() - e.size() == 0 ){
    for ( int i = 0; i < o.size(); i++){
      cout << o[i] << e[i];
    }
    cout << endl;
  }else{
    for ( int i = 0; i < e.size(); i++){
      cout << o[i] << e[i];
    }
    cout << o[o.size()-1] << endl;
  }
   
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s = buf;

  for (size_t i = 1; i < s.length(); ++i)
    if (s[i-1] == s[i])
      return !printf("%zu %zu\n", i, i+1);

  for (size_t i = 1; i+1 < s.length(); ++i)
    if (s[i-1] == s[i+1])
      return !printf("%zu %zu\n", i, i+2);

  puts("-1 -1");
}


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

int main(){
    string s;
    cin>>s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i)==',')
        {
            s.at(i) = ' ';
        }
        
    }
    cout<<s<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int k,n;
   cin>>k>>n;
   int a[n],sum=0;
   for(int i=0;i<n;i++){
     cin>>a[i];
   
   }
     for(int i=1;i<n;i++){
     sum=max(sum,abs(a[i]-a[i-1]));
    
   }
   sum=max(sum,abs(k-(a[n-1]-a[0])));
   cout<<k-sum;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using i64 = long long;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    std::vector<i64> ds;
    i64 px;
    std::cin >> px;
    for (int i = 1; i < n; i++) {
        i64 nx;
        std::cin >> nx;
        ds.push_back(nx - px);
        px = nx;
    }

    std::vector<i64> co(n + 1), left(n + 1), right(n + 1);
    left[0] = right[n] = 1;
    for (int i = 1; i <= n; i++) {
        left[i] = left[i - 1] * i % mod;
        right[n - i] = right[n - i + 1] * (n - i) % mod;
    }
    for (int i = 1; i < n; i++) co[i] = (co[i - 1] + left[i - 1] * right[i + 1]) % mod;

    i64 ret = 0;
    for (int i = 0; i < n - 1; i++) ret = (ret + ds[i] * co[i + 1] % mod) % mod;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long k, n;
int main() {
    cin >> k >> n;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    long long mincost = 1e18;
    for(int i = 0; i < n; ++i) {
        long long start, goal;
        if(i != 0) {
            start = a.at(i);
            goal = k + a.at(i-1);
        }else {
            start = a.at(i);
            goal = a.at(n-1);
        }

        chmin(mincost, goal-start);
    }
    cout << mincost << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            String s = in.next();
            int K = in.nextInt();

            NavigableSet<String> substrSet = new TreeSet<>();

            for (int l = 1; l <= K; l++) {
                for (int i = 0; i + l <= s.length(); i++) {
                    String substr = s.substring(i, i + l);
                    substrSet.add(substr);
                }
            }

            String ans = "";
            for (int i = 0; i < K; i++) ans = substrSet.pollFirst();
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

Measured memory_bytes: 25256