akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


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

Measured memory_bytes: 256
//俺のバカバカバカバカバカ！！うわああああああああああああああん！！
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
long long modpow(long long a, long long n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}
int main(void){
    int n,k;cin>>n>>k;
    ll dp[k+1];
    rep1(i,k)dp[i]=modpow(k/i,n);//gcd=iとなる組み合わせ
    ll res=0;
    for(int i=k;i>=1;i--){
        for(int j=2;i*j<=k;j++){
            dp[i]-=dp[i*j];
        }
        res+=dp[i]*i;
        res%=mod;
    }
    res=(res+mod)%mod;
    cout<<res<<endl;
}


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

int main()
{
  int min, max, tmp;
  long sum;
  int n;

  min = 1000000;
  max = -1000000;
  sum = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    if (tmp > max) max = tmp;
    if (tmp < min) min = tmp;
    sum += tmp;
  }
  cout << min << " " << max << " " << sum << endl;
  
  return 0;
}



Measured memory_bytes: 3116
package main

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

func main() {
	n, m := readI(), readI()
	acp := make(map[int]bool)
	ac := 0
	ngp := make(map[int]int)
	for i := 0; i < m; i++ {
		p, s := readI(), readS()
		if !acp[p] {
			if s == "AC" {
				acp[p] = true
				ac++
			} else {
				ngp[p]++
			}
		}
	}
	n = n + 1
	ng := 0
	for k := range acp {
		ng += ngp[k]
	}
	fmt.Println(ac, ng)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 8144
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 1001

void Main() {
  //自動整形防止用コメント
  int n;
  cin >> n;
  std::cout << n * n * n << std::endl;

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl c;
    cin >> c;
    intl d;
    cin >> d;
    intl cnt = 0;
    if(a >= b)cnt = b * c + (a - b) * d;
    else cnt = a * c;
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
	Scanner sc;
	int N;
	long M;
	int[] A;
	long[] s;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextLong();
		A = new int[N+1];
		for (int i = 1; i <= N; i++) A[i] = sc.nextInt();
		Arrays.sort(A, 1, N+1);
		for (int i = 0; i < N/2; i++) {
			int tmp = A[i+1]; A[i+1] = A[N-i]; A[N-i] = tmp;
		}
		s = new long[N+1];
		s[0] = A[0];
		for (int i = 1; i <= N; i++) s[i] = s[i-1] + A[i];
		System.out.println(binSearch());
	}
	
	private long[] ansOfSum(int sum) {
		long ans = 0;
		long cnt = 0;
		
		int b = N;
		for (int a = 1; a <= N; a++) {
			while (A[a] + A[b] < sum && b > 0) b--;
			if (b == 0) break;
			ans += (long)b*A[a] + s[b];
			cnt += b;
		}
		return new long[] { ans, cnt };
	}
	
	private long binSearch() {
		int l = 0;
		int r = 200000;
		long[] mv = null;
		
		while (l <= r) {
			int m = (l + r) >>> 1;
			mv = ansOfSum(m);
			
			if (mv[1] > M) l = m+1;
			else if (mv[1] < M) r = m-1;
			else {
				return mv[0];
			}
		}
		return mv[0] + (l-1)*(M-mv[1]);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 50952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n;
    cin >> n;
    if (n == 2) {
        ll a1, a2;
        cin >> a1 >> a2;
        cout << abs(a1-a2) << endl;
        cout << max(a1,a2) << " " << min(a1,a2) << endl;
        return 0;
    }
    vector<ll> plus, minus;
    rep(i,n){
        ll a;
        cin >> a;
        if (a > 0) plus.push_back(a);
        else minus.push_back(a);
    }
    sort(all(plus),greater<ll>());
    sort(all(minus),greater<ll>());
    vector<pair<int,int>> res;
    if (minus.empty()) {
        ll x = plus.back(); plus.pop_back();
        ll y = plus.back(); plus.pop_back();
        assert(x <= y);
        res.push_back({x,y});
        minus.push_back(x-y);
    }
    if (plus.empty()) {
        ll x = minus[0];
        ll y = minus[1];
        minus.erase(minus.begin(), minus.begin()+2);
        assert(x <= y);
        res.push_back({x,y});
        plus.push_back(x-y);
    }
    assert(!minus.empty() && !plus.empty());
    while (plus.size() > 1) {
        res.push_back({minus[0], plus.back()});
        minus[0] -= plus.back();
        plus.pop_back();
    }
    while (minus.size()) {
        res.push_back({plus[0], minus.back()});
        plus[0] -= minus.back();
        minus.pop_back();
    }
    assert(minus.empty() && plus.size() == 1);
    cout << plus[0] << endl;
    for (auto p : res) {
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}


Measured memory_bytes: 4340
#include <stdio.h>
void MRoy(){
    int a,b,Ans = 0;
    scanf("%d %d",&a,&b);
    if(b==1) {
        printf("0\n");
        return;
    }
    Ans = 1;
    int n = a;
    while(n<b){
        n+=a-1;
        Ans++;
    }
    printf("%d\n",Ans);
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main()
{
  int x, a;
  cin >> x >> a;
  int ans;
  if(x < a){
    ans = 0;
  } else{
    ans = 10;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import math

times = [input() for _ in range(5)]
mini = times[0]
for i, _ in enumerate(times):
    if i >= 4:
        break
    if int(_[-1]) != 0 and int(_[-1]) < int(mini[-1]):
        mini = _

times.remove(mini)

sums = sum([int(math.ceil(int(_)/10)*10) for _ in times])
sums += int(mini)
print(sums)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;++i)
	 {
	 	cin>>v[i];
	 }
	 cin>>m;
	for(int i=0;i<m;++i)
	{
		int p,x,k,sum=0;
		cin>>p>>x;
		k=v[p-1];
		v[p-1]=x;    
		    for(int j=0;j<n;++j)
	 {
	 	sum+=v[j];
	 }cout<<sum<<endl;
	v[p-1]=k;
	}

 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const int sz = 2e5+5;
int a[sz];

bool bs(int mid, int k)
{
    for(int x :a)
    {
        //how many cuts to get to less than mid?
        if(x<mid) continue;
        int cuts = (x+mid-1)/mid;
        k -= cuts-1;
    }
    return k >= 0;
}

void solve()
{
    int n, k;
    cin >> n >> k;

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

    int mn = 1, mx = 1e9 + 7;

    while(mn != mx)
    {
        int mid = (mn+mx)/2;
        if(bs(mid, k))
            mx = mid;
        else
            mn = mid+1;
    }
    cout << mn << endl;
}


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


Measured memory_bytes: 4368
import itertools
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
G = [list(map(int,input().split())) for i in range(N)]

colors = [[0 for c in range(C)] for p in range(3)]

for y in range(N):
    for x in range(N):
        c = G[y][x]-1
        colors[(x+y)%3][c] += 1

ans = float('inf')
for ptn in itertools.permutations(range(C),3):
    tmp = 0
    for p,ct in enumerate(ptn):
        for cf in range(C):
            tmp += D[cf][ct] * colors[p][cf]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 45916
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main() {
    long long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    long long k1, k2,k3;
    k1 = a * x + b * y;
    int t1,t2;
    if (x<y){
        t1 = x;
        t2 = y;
        x = t2;
        y = t1;
        t1 = a;
        t2 = b;
        a = t2;
        b = t1;
    }
    k2 = 2*c*y + (x-y)*a;
    k3 = x*2*c;
    cout << min(k1,min(k2,k3));
    return 0;
}

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

#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) FOR(i, 0, (n))
#define ALL(a) (a.begin(), a.end())
typedef vector<int> vi;

constexpr int INF = 1000000000;

int main() {
    int h,w;
    cin>>h>>w;
    vector<string> t(h);
    int pi, pj, hi, hj;
    vi si, sj;
    REP(i,h) {
        cin>>t[i];
        REP(j,w) {
            switch (t[i][j]) {
                case '@':
                pi = i;
                pj = j;
                break;
                case '%':
                hi = i;
                hj = j;
                break;
                case '$':
                si.push_back(i);
                sj.push_back(j);
            }
        }
    }
    vector<vi> dist(h, vi(w, INF));
    dist[hi][hj] = 0;
    queue<pair<int,int>> que;
    que.push(make_pair(hi, hj));
    while(!que.empty()) {
        int i, j;
        tie(i,j) = que.front();
        que.pop();
        int di[] = {1, 0, -1, 0};
        int dj[] = {0, 1, 0, -1};
        REP(k,4) {
            int ni = i + di[k];
            int nj = j + dj[k];
            if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            if (t[ni][nj] == '#') continue;
            if (dist[ni][nj] <= dist[i][j] + 1) continue;
            dist[ni][nj] = dist[i][j] + 1;
            que.push(make_pair(ni, nj));
        }
    }
    int pd = dist[pi][pj];
    bool valid = true;
    REP(i, si.size()) {
        if (dist[si[i]][sj[i]] <= pd) {
            valid = false;
        }
    }
    if (valid) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3436
import java.io.InputStreamReader;
import java.util.Scanner;

import static java.lang.Math.*;

public class Main{


    public static void main(String args[]){


        Scanner scan = new Scanner(System.in);

        Double x1 = Double.parseDouble(scan.next());
        Double y1 = Double.parseDouble(scan.next());
        Double r1 = Double.parseDouble(scan.next());

        Double x2 = Double.parseDouble(scan.next());
        Double y2 = Double.parseDouble(scan.next());
        Double r2 = Double.parseDouble(scan.next());

        if(r1 + r2 > sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) && max(r1, r2) - min(r1, r2) > sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))){
            System.out.println(0);
        }else if(r1 + r2 > sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)) && max(r1, r2) - min(r1, r2) == sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))){
            System.out.println(1);
        }else if(r1 + r2 > sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))){
            System.out.println(2);
        }else if(r1 + r2 == sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))){
            System.out.println(3);
        }else if(r1 + r2 < sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))){
            System.out.println(4);
        }




    }

}



Measured memory_bytes: 26324
#include <iostream>
#include <algorithm>
#define INF 1000000000
#define f first
#define s second
using namespace std;
typedef pair <int,pair <int,int> > P;
typedef long long ll;
int n,d,tree[4][(1<<19)];
P star[200001];

void update(int i,int flg,int x){
  i = i+(1<<18)-1;
  tree[flg][i] = x;
  while(i) {
    i = (i-1)/2;
    tree[flg][i] = max(tree[flg][i*2+1],tree[flg][i*2+2]);
  }
}

int find(int a,int b,int ima,int L,int R,int flg){
  if(R<=a || b<=L) return -INF;
  if(a<=L && R<=b) return tree[flg][ima];
  int M = (L+R)/2;
  return max(find(a,b,ima*2+1,L,M,flg),find(a,b,ima*2+2,M,R,flg));
}

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

  for(int i=0;i<n;i++)cin >> star[i].s.f >> star[i].s.s >> star[i].f;
  sort(star,star+n);  
  
  for(int i=0;i<4;i++) 
    for(int j=0;j<(1<<19);j++) tree[i][j] = -INF;
  
  for(int i=0;i<n;i++) {
    update(i,0,star[i].s.f); // max(x);
    update(i,1,star[i].s.s); // max(y);
    update(i,2,-star[i].s.f); // min(x);
    update(i,3,-star[i].s.s); // min(y);
  }

  long long S=0;
  int ima=0;
  for(int i=0;i<n;i++){
    while(ima!=n && star[ima].f-star[i].f <=d) ima++;
    ll maxx = find(i,ima,0,0,(1<<18),0);
    ll maxy = find(i,ima,0,0,(1<<18),1);
    ll minx = find(i,ima,0,0,(1<<18),2);
    ll miny = find(i,ima,0,0,(1<<18),3);
    S = max(S,((maxx+minx)*(maxy+miny)));
  }
  cout << S<<endl;
  return 0;
}

Measured memory_bytes: 11700
N = gets.to_i
R = N.times.map { gets.split.map(&:to_i) }.sort_by{|c| -c[2]}
def max(a,b); a > b ? a : b; end
def ans
  (0 .. 100).each do |cx|
    (0 .. 100).each do |cy|
      x0,y0,h0 = R[0]
      h_ = h0 + (cx - x0).abs + (cy - y0).abs
      next if h_ < 1  
      return [cx, cy, h_] if R.all?{|x,y,h| h == max(h_ - (cx - x).abs - (cy - y).abs, 0) }
    end
  end
end
puts ans.join(' ')

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

using namespace std;

int getMinCost (vector <int> &heights, int k) {
    int n = heights.size();
    if (n <= 1) {
        return 0;
    }
    vector <int> dp(n, INT_MAX);

    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = max(0, i - k); j < i; ++j) {
            int cost = abs(heights[i] - heights[j]);
            dp[i] = min(dp[i], cost + dp[j]);
        }
    }
    return dp.back();
}

int  main () {
    int n = 0, k = 0;
    scanf("%d%d", &n, &k);
    vector <int> heights(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &heights[i]);
    }
    printf("%d\n", getMinCost(heights, k));
    return 0;
}

Measured memory_bytes: 1024
n = int(input())

ret = False
cnt = 0
for i in range(n):
    d = list(map(int,input().split()))
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ret = True

if ret:
    print("Yes")
else:   
    print("No")


Measured memory_bytes: 9172
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    map<string,ll> count_map[2];

    string S;
    cin >> S;

    rep(si,S.size()){
        stmp = S.substr(si,1);
        ltmp = (si+1) % 2;
        count_map[ltmp][stmp]=1;
    }

    if(count_map[0]["R"]==0 && count_map[1]["L"]==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    

}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
vector<ll> C(26);
vector<vector<ll>> S;

ll change_evaluation(vector<ll>& T,ll day) {
  day -= 1;
  vector<ll> last(26, -1);
  vector<ll> next(26, T.size());
  ll old = T.at(day) - 1;
  for (ll i = 0; i < day; ++i) {
    last.at(T.at(i) - 1) = i;
  }
  for (ll i = T.size() - 1; i > day; --i) {
    next.at(T.at(i) - 1) =  i;
  }
  ll max_t = 0, max_score = -INF;
  for (ll t = 0; t < 26; ++t) {
    ll score = S.at(day).at(t) - S.at(day).at(old);
    score += (next.at(t) - day) * (day - last.at(t)) * C.at(t);
    score -= (next.at(old) - day) * (day - last.at(old)) * C.at(old);
    if (score > max_score) {
      max_score = score;
      max_t = t;
    }
  }
  return max_t;
}

ll evaluation(ll t, ll day, vector<ll>& last) {
  ll score = 0;
  score += S.at(day).at(t);
  for (ll j = 0; j < 26; ++j) {
    if (j == t) {
      continue;
    }
    score -= (day + 1 - last.at(j)) * C.at(j);
  }
  return score;
}

ll whole_evaluation(vector<ll>& T) {
  ll D = T.size();
  vector<ll> last(26, 0);
  ll score = 0;
  for (ll i = 0; i < D; ++i) {
    ll contest = T.at(i) - 1;
    last.at(contest) = i + 1;
    score += S.at(i).at(contest);
    for (ll j = 0; j < 26; ++j) {
      score -= (i + 1 - last.at(j)) * C.at(j);
    }
  }
  return score;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  //-----------input-------------
  ll D;
  cin >> D;
  vector<ll> T(D);
  S = vector<vector<ll>>(D, vector<ll>(26));
  for (ll i = 0; i < 26; ++i) {
    cin >> C.at(i);
  }
  for (ll i = 0; i < D; ++i) {
    for (ll j = 0; j < 26; ++j) {
      cin >> S.at(i).at(j);
    }
  }
  //--------------------------------------
  vector<ll> last(26, 0);
  for (ll day = 0; day < D; ++day) {
    ll max_contest = 0;
    ll max_score = -INF;
    for (ll contest = 0; contest < 26; ++contest) {
      ll temp_score = evaluation(contest, day, last);
      if (temp_score > max_score) {
        max_score = temp_score;
        max_contest = contest + 1;
      }
    }
    last.at(max_contest - 1) = day;
    T.at(day) = max_contest;
  }

  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand(1, T.size());
  uniform_int_distribution<> rand_evn(1, 26);
  double persent = 1.0003;
  double persent_now = 1;
  for (ll i = 0; i < 100000; ++i) {
    ll random = rand(mt);
    if (random / 3.65 < 30 / persent_now) {
      ll event = rand_evn(mt);
      T.at(random - 1) = event;
    }
    else {
      ll max_t = change_evaluation(T, random);
      // cout << max_t << " rand" << "\n";
      T.at(random - 1) = max_t + 1;
    }
    persent_now *= persent;
  }

  // ll score = whole_evaluation(T);
  // cout << score << "\n";

  for (ll i = 0; i < D; ++i) {
    cout << T.at(i) << "\n";
  }

  // vector<ll> ans = evaluation(C, S, T);
  // for (ll i = 0; i < ans.size(); ++i) {
  //   cout << ans.at(i) << "\n";
  // }
}


Measured memory_bytes: 3776
#include <cstdio>
#include <cctype>
using namespace std;
template <typename T> inline void read(T& ret) {
  int c = getchar(); ret = 0;
  while(!isdigit(c)) { c = getchar(); }
  while(isdigit(c)) { ret = ret * 10 + c - 48, c = getchar(); }
}
template <typename T, typename... Args> inline void read(T& ret, Args&... args) { read(ret), read(args...); }
int main() {
  int n; read(n); int sum = 0;
  while(n --) {
    int i; read(i);
    sum += i & 1;
  }
  printf("%s\n", sum & 1 ? "NO" : "YES");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

ll MOD = 1e9+7;
ll fastpow(ll a, ll n){  // a^n mod MOD
  if(n==0) return 1;
  if(n%2==0){
    ll t = fastpow(a, n/2);
    return t*t % MOD;
  }
  return a * fastpow(a, n-1) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K; cin >> N >> K;
  vector<ll> A(K+1, 0);
  for(ll i = K; i > 0; i--){
    A[i] = fastpow(K/i, N) % MOD;
    ll cnt = 2, tmp = cnt * i;
    while(tmp <= K){
      A[i] -= A[tmp];
      if(A[i] < 0) A[i] += MOD;
      cnt++;
      tmp = cnt * i;
    }
  }
  ll ans = 0;
  for(ll i = 1; i <= K; i++){
    ans = (ans + i*A[i]) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3996
import bisect

n=int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
ans = 0
for k in b:
    pos1 = bisect.bisect_left(a,k)
    pos2 = bisect.bisect_right(c,k)
    ans += (pos1*(n-pos2))
print(ans)
 



Measured memory_bytes: 23284
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  ll res = k;
  for(int i = 1; i < n; i++)res *= (k - 1);
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,ar[3],highest=0,i;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b){
        ar[0]=a-b;
    }
    else
        ar[0]=b-a;
    if(a>=c){
        ar[1]=a-c;
    }
    else
       ar[1]=c-a;
    if(b>=c){
        ar[2]=b-c;
    }
    else
        ar[2]=c-b;
    for(i=0;i<3;i++){
        if(ar[i]>=highest)
            highest=ar[i];

    }
    printf("%d\n",(ar[0]+ar[1]+ar[2])-highest);

    return 0;




}


Measured memory_bytes: 128
import java.util.*
import kotlin.math.*

fun main(args: Array<String>) {
    val (w, h, n) = readIntList()
    val c = List(n) { readIntList() }

    var lx = 0
    var rx = w
    var ly = 0
    var uy = h
    c.forEach { (x, y, a) ->
        when (a) {
            1 -> lx = max(lx, x)
            2 -> rx = min(rx, x)
            3 -> ly = max(ly, y)
            4 -> uy = min(uy, y)
        }
    }
    if (rx - lx <= 0 || uy - ly <= 0) {
        println(0)
        return
    }
    println((rx - lx) * (uy - ly))
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

public class Main {
    public static void main(String[] args) throws Exception {
        String line = readLine();
        String WA = "WA";
        String AC = "AC";

        if (line.startsWith("A")) {
            if (line.substring(0, 2).indexOf("C") != -1 || line.endsWith("C") ) {
                System.out.println(WA);
                return;
            }
            if (line.replace("C", "").length() != line.length() - 1) {
                System.out.println(WA);
                return;
            }

            String str1 = line.replace("A", "");
            String str2 = str1.replace("C", "");
            if (str2.equals(str2.toLowerCase())) {
                System.out.println(AC);
            } else {
                System.out.println(WA);
            }
        } else {
            System.out.println(WA);
        }
    }

    private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}
}

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

using namespace std;

typedef uint64_t ll;

int main(){
	ll n, k;
	cin >> n >> k;
	ll a[n];
	ll num[40] = {0};
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		ll jj = 1;
		for(int j = 0; j < 40; j++){
			if(a[i] & jj)num[j]++;
			jj*=2;
		}
	}
	ll ans = 0;
	ll kk = 0;
	ll jj = 1;
	for(int i = 0; i < 39; i++)jj*=2;
	for(int i = 39; i>=0; i--){
		if(num[i] < n-num[i]){
			if(jj <= k && kk+jj <= k)kk += jj;
		}
		jj/=2;
	}
	//cout << kk << endl;
	for(ll i = 0; i < n; i++)ans += kk^a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
a.sort()

is_p=[1 for i in range(10**6+1)]

for i in set(a):
  v=i
  if is_p[v]:
    for j in range(v+v,10**6+1,v):
      is_p[j]=0

c=Counter(a)

cnt=0
for i in a:
  if is_p[i]==1 and c[i]==1:
    cnt+=1

print(cnt)

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

using namespace std;

bool judge(int* a)
{
    int x[5] = {5, 7, 5, 7, 7};
    int i = 0;
    while(true)
    {
        if(i==5) return true;
        x[i] -= *a++;
        if(x[i]<0) return false;
        if(x[i]==0) i++;
    }
}

int main()
{
    int n;
    while(cin >> n, n)
    {
        int a[n];
        for(int i=0; i<n; i++)
        {
            string s;
            cin >> s;
            a[i] = s.size();
        }
        for(int i=0; i<n; i++)
        {
            if(judge(a+i))
            {
                cout << i+1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3000
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
 
int main()
{
 
    int  N;
    int  A[10];
    int  i;
    int  has=0;
  
 // 整数の入力
    scanf("%d", &N);
//    printf("%d\n",N);

  for(i = 0;i < 9 ;i++ ){
    A[i]=(N/((int)pow(10,i)) % 10);
//     printf("%d\n",A[i]);
     has = has + A[i];
//     printf("%d\n",has);
              }
  
   if ((N%has) == 0){
     printf("Yes\n");
   } else {
     printf("No\n");
   }
  
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    long double a,b,n,t;cin>>a>>b>>n;
    if((ll)b>(ll)n) t=n+1;
    else t=b;
    cout<<floor(a*(t-1)/b)<<endl;
}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <limits.h>
using namespace std;

int main(void){
    int n;
    long long a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    
    long long lgst = -1, lgst2 = -1;
    bool csn = false;
    for (int i = n - 1; i >= 0; i--) {
        if (csn) csn = false;
        else if (a[i] == a[i - 1]) {
            if (lgst == -1) {
                lgst = a[i];
                csn = true;
            }
            else {
                lgst2 = a[i];
                break;
            }
        }
    }
    
    if (lgst == -1 || lgst2 == -1) cout << 0 << endl;
    else cout << lgst * lgst2 << endl;
}


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

int n, k;
int l[50] = {0};

int main(){
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> l[i];
  sort(l,l+n);
  int ans = 0;
  for(int i = n-1; i > n-1-k; i--) ans+=l[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	    
	    
	    using namespace std;
	
	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod  1000000007
	    #define PI 3.141592653589793238462643383279
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	    

	ll d,x,y;
	void extendedEuclid(ll A, ll B) 
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p) 
	{ 
	    ll res = 1; 
	    x = x % p;
	    while (y > 0) 
	    {  // If y is odd, multiply x with result 
	        if (y & 1) 
	            res = (res*x) % p;
	            
	        y = y>>1; 
	        x = (x*x) % p;   
	    } 
	    return res; 
	} 



map<ll,ll> par,val;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;
		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
		par[y]=par[x];
}

int gcdExtended(int a, int b, int *x, int *y) 
{ 

    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    int x1, y1;
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1;
    return gcd; 
}  
int modInverse(int b, int m) 
{ 
    int x, y; 
    int g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
}
ll isPrime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}

int main()
{
	FAST;
	ll n,i,j,k;
	cin>>n;
	vector<pair<ll,ll> > a(n);
	for(i=0;i<n;i++)
	{
		cin>>a[i].ss>>a[i].ff;
	}
	sort(a.begin(),a.end());
	ll c=0;
	for(i=0;i<n;i++)
	{
		c+=a[i].ss;
		if(c>a[i].ff)
			return cout<<"No",0;
	}
	cout<<"Yes";
}

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

int main(){
    ll a, b; cin >> a >> b;
    ll tmp1, n;
    while(true){
        tmp1 = a;
        a = b;
        b = tmp1 % b;
        if(b == 0){
            n = a;
            break;
        }
    }

    ll ans = 1, cnt = 0;
    if(n % 2 == 0){
        ans++;
        while(n%2 == 0) n /= 2;
    }

    for (ll i = 3; i*i <= n; i+=2) {
        cnt = 0;
        if(n % i == 0){
            ans++;
            while (n%i == 0) n /= i;
        }
      	if(n == 1) break;
	}
    if(n != 1) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define mx 200005
inline int min(int x,int y){return x<y?x:y;}
inline int max(int x,int y){return x>y?x:y;}
int n,k,q,qz[mx],qp[mx],ans=2e9+5;
inline bool ck(int kl,int kr)
{
	int nl=0,nw=0,res=0;
	for(int i=1;i<=n;++i)
	{
		if(qz[i]>=kl&&qz[i]<=kr) ++nl,++nw;
		else if(qz[i]>kr) ++nl;
		else res+=max(0,min(nl-k+1,nw)),nl=nw=0;
	}
	res+=max(0,min(nl-k+1,nw)),nl=nw=0;
	return res>=q;
}
int main()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;++i)
		scanf("%d",&qz[i]),qp[i]=qz[i];
	sort(qp+1,qp+n+1);
	for(int i=1;i<=n;++i)
	{
		int l=i,r=n,mid;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(ck(qp[i],qp[mid])) ans=min(ans,qp[mid]-qp[i]),r=mid-1;
			else l=mid+1;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)

using namespace std;
/*
int main(){
    int64_t a , b , c , k , d, e;
    cin >> a >> b >> c >> k;
    rep( i , k){
        d = a;
        a = b + c;
        e = b;
        b = d  + c;
        c = e + a;
    }
    if ( abs( a - b) > pow( 10 , 18))
        cout << "Unfair" << endl;
    else cout << a - b << endl;
}
 */
int main(){
    int n, k;
    int64_t s;
    cin >> n >> k >> s;
    if ( s < pow( 10 , 9)){
        rep( i , n){
            if ( i <= k) cout << s << ' ';
            else cout << s + 1 << ' ';
        }
    }
    else{
        rep( i , n){
            if ( i <= k) cout << s << ' ';
            else cout << 1 << ' ';
        }
    }
    cout << endl;
    return 0;
    
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<deque>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
#define MOD 1000000007
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	stack<char> st;
	queue<char> qu;
	deque<char> deq;
	ll N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N;i++) {
		deq.push_back(S[i]);
	}
	for (int i = 0; i < N;i++) {
		if (S[i] == '(') {
			st.push(S[i]);
		}
		else if (S[i] == ')')
		{
			if (st.empty()) {
				deq.push_front('(');
			}
			else {
				char p = st.top();
				if (p == '(') {
					st.pop();
				}
			}
		}
	}
	while (!st.empty()) {
		st.pop();
		deq.push_back(')');
	}
	while (!deq.empty()) {
		cout << deq.front();
		deq.pop_front();
	}
}

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

using namespace std;

int main() {
	vector<int> h(10);
	for (int i = 0; i < 10; ++i) cin >> h[i];

	sort( h.begin(), h.end(), greater<int>() );

	cout << h[0] << endl;
	cout << h[1] << endl;
	cout << h[2] << endl;
}

Measured memory_bytes: 1208
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;
  auto dp = new int[](s.length+1);
  dp[0] = 0;
  dp[1] = 1;
  if (dp.length > 2) {
    if (s[0] == s[1]) {
      dp[2] = 1;
    } else {
      dp[2] = 2;
    }
  } 

  foreach (i; 3..s.length+1) {
    if (s[i-2] != s[i-1]) {
      dp[i] = dp[i-1] + 1;
    } else {
      dp[i] = max(dp[i-1], dp[i-3] + 2);
    }
  }
  //dp.writeln;
  dp[$-1].writeln;
} 


Measured memory_bytes: 3256
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
struct state {
	int sx, sy, cost;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int R, H[2], W[2], sx[2], sy[2], a[2][509][509], cnt[2], b[2][250009]; bool vis[509][509];
int dir[] = { 0, 1, 0, -1 };
int main() {
	while (scanf("%d", &R), R) {
		for (int i = 0; i < 2; i++) {
			scanf("%d%d%d%d", &W[i], &H[i], &sy[i], &sx[i]); sy[i]--, sx[i]--;
			for (int j = 0; j < H[i]; j++) {
				for (int k = 0; k < W[i]; k++) {
					reader(&a[i][j][k]);
				}
			}
			priority_queue<state> que; que.push(state{ sx[i], sy[i], -1 });
			memset(vis, 0, sizeof(vis));
			vis[sx[i]][sy[i]] = true; cnt[i] = 1;
			while (!que.empty()) {
				state u = que.top(); que.pop();
				b[i][cnt[i]++] = a[i][u.sx][u.sy];
				for (int j = 0; j < 4; j++) {
					int tx = u.sx + dir[j], ty = u.sy + dir[j ^ 1];
					if (0 <= tx && tx < H[i] && 0 <= ty && ty < W[i] && !vis[tx][ty]) {
						a[i][tx][ty] = max(a[i][tx][ty], a[i][u.sx][u.sy]);
						vis[tx][ty] = true;
						que.push(state{ tx, ty, -a[i][tx][ty] });
					}
				}
			}
		}
		int ret = 2000000009;
		for (int i = 0; i <= H[0] * W[0]; i++) {
			int z = max(R - i, 0);
			if (z > H[1] * W[1]) continue;
			ret = min(ret, b[0][i] + b[1][z]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 7240
#include <iostream>
#include <algorithm>
#include <cassert>


using namespace std;


int min(int b,int e,int array[],int n){
    
    assert(b<=n);
    assert(e<=n);
    
    int minp;
    minp=array[b];
    
    for(int i=b;i!=e;++i){
        minp=(minp<=array[i])?minp:array[i];
    }
    
    return minp;
}

int max(int b,int e,int array[],int n){
    int maxp;
    maxp=array[b];
    
    for(int i=b;i!=e;++i){
        maxp=(maxp>=array[i])?maxp:array[i];
    }
    
    return maxp;
}


int main(){
    int n;
    cin>>n;
    
    int array[n];
    
    for(int i=0;i!=n;++i){
        cin>>array[i];
    }
    
    int q;
    cin>>q;
    
    for(int i=0;i!=q;++i){
        int com,b,e;
        cin>>com>>b>>e;
        
        switch (com) {
            case 0:
                cout<<min(b,e,array,n)<<endl;
                break;
            case 1:
                cout<<max(b,e,array,n)<<endl;
                break;
        }
    }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  int a[9]={};
  for(int i=0;i<n;i++){
    int b;
    cin>>b;
    if(b<400)
      a[0]++;
    else if(b<800)
      a[1]++;
    else if(b<1200)
      a[2]++;
    else if(b<1600)
      a[3]++;
    else if(b<2000)
      a[4]++;
    else if(b<2400)
      a[5]++;
    else if(b<2800)
      a[6]++;
    else if(b<3200)
      a[7]++;
    else
      a[8]++;
    if(b<3200)
      c++;
  }
  if(c==0){
    cout<<"1 "<<a[8];
  }else{
    c=0;
    for(int i=0;i<8;i++){
      if(a[i]>0)
        c++;
    }
    cout<<c<<" "<<c+a[8];
  }
}

Measured memory_bytes: 256
# AOJ 0140 Bus Line
# Python3 2018.6.23 bal4u

for i in range(int(input())):
	s, e = map(int, input().split())
	a = []
	if s <= 5:
		if s > e: [a.append(i) for i in range(s, e-1, -1)]
		else: [a.append(i) for i in range(s, e+1)]
	elif s < e: [a.append(i) for i in range(s, e+1)]
	else:
		[a.append(i) for i in range(s, 10)]
		if e <= 5: [a.append(i) for i in range(5, e-1, -1)]
		else:
			[a.append(i) for i in range(5, 0, -1)]
			[a.append(i) for i in range(0, e+1)]
	print(*a)


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

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

  int n; cin >> n;
  int a[100010][3] = {};
  ll dp[100010][3] = {};
  rep(i, n) rep(j, 3) cin >> a[i][j];

  // i 日目:j は前日の活動, k は今日の活動
  rep(i, n) rep(j, 3) rep(k, 3) {
    if(j!=k) {
      chmax(dp[i+1][k], dp[i][j]+a[i][k]);
    }
  }
  ll res = 0;
  rep(i, 3) chmax(res, dp[n][i]);
  cout << res << '\n';
  return 0;
}


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

int main() {
  int N, W;
  cin >> N >> W;
  int w[N], v[N];
  for(int i=0; i<N; i++)
    cin >> w[i] >> v[i];
  /*chmax使うから最初全部に0入れとく。0行目だけ初期化とかじゃだめ
  v[i]が10^9まででそれがNの最大値の100個分足したらintだと足りない
  要素数(N+1)*(W+1)で足りるはずなのに余裕持って確保しとかないと変な値出た
  最初から起こりうる最大値プラス余裕持って確保しとく方が安心かも*/
  //long long dp[N+10][W+10]={0};
  long long dp[110][100100];
  
  /*i=0の時i=1の行埋めるからi<Nで良い
  むしろi<=Nだとdp[N+1]にアクセスしちゃってまずい
  余裕持ってdp確保してればどっちにしろ大丈夫*/
  for(int i=0; i<N; i++){
    for(int sum_w=0; sum_w<=W; sum_w++){
      /*w[i],v[i]に入ってるのはi+1番目の品物についての情報だから
      dp[i+1]の行に入れる。添字注意*/
      if(sum_w>=w[i])
        chmax(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
      //else あってもなくても大丈夫
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <algorithm>

int main(){
   int K, A, B;
   std::cin >> K;
   std::cin >> A >> B;
   bool flag = false;
   for(int i = A; i <= B; i++){
       if(i % K == 0){
           flag = true;
       }
   }
   if(flag){
       std::cout << "OK" << std::endl;
   }
   else{
       std::cout << "NG" << std::endl;
   }
}

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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

using mint = modint998244353;

struct monoid {
    mint sum, len;

    static monoid op(monoid lhs, monoid rhs) {
        return {lhs.sum + rhs.sum, lhs.len + rhs.len};
    }

    static monoid e() { return {0, 0}; }
};

struct op_monoid {
    mint a, b;

    static monoid mapping(op_monoid lhs, monoid rhs) {
        return {lhs.a * rhs.sum + lhs.b * rhs.len, rhs.len};
    }

    static op_monoid composition(op_monoid lhs, op_monoid rhs) {
        return {lhs.a * rhs.a, lhs.a * rhs.b + lhs.b};
    }

    static op_monoid id() { return {1, 0}; }
};

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    vector<monoid> a(n);
    rep(i, n) {
        int x;
        scanf("%d", &x);
        a[i] = {x, 1};
    }
    lazy_segtree<monoid, monoid::op, monoid::e, op_monoid, op_monoid::mapping,
                 op_monoid::composition, op_monoid::id>
        st(a);
    rep(_, q) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r, b, c;
            scanf("%d%d%d%d", &l, &r, &b, &c);
            st.apply(l, r, {b, c});
        } else {
            int l, r;
            scanf("%d%d", &l, &r);
            printf("%d\n", st.prod(l, r).sum.val());
        }
    }
}

Measured memory_bytes: 19268
import sys
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# S = str(input())
# T = str(input())
A0 = [int(n) for n in input().split()]
A1 = [int(n) for n in input().split()]

ans = 0
for c in range(N):
    tmp=0
    for n in range(N):
        if(c>n):
            tmp+=A0[n]
        elif(c==n):
            tmp+=A0[n]
            tmp+=A1[n]
        else:
            tmp+=A1[n]
    ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std ;
int main ()
{
    long double n, b;
    cin>>n>>b;
    if( (n != 0)||(b != 0))
        {
            if(n>b)
                cout <<"GREATER ";
            else if(n <b )
                cout <<"LESS ";
            else
                cout <<"EQUAL ";
        }
return 0 ;
}


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

int a,b,c;
int d=2;
int main(){
	scanf("%d %d %d\n",&a,&b,&c);
	if(a==b && a==c && b==c)d=1;
	if(a!=b && a!=c && b!=c)d=3;
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s;
    int n,k;
    cin >> n >> k;
    cin >> s;
    rep(i,n){
        if(i == k-1){
            int t = s[i]-'A';
            cout << char('a'+t);
        }else{
            cout << s[i];
        }
    }
    cout << endl;

}


Measured memory_bytes: 256