akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public 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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        private static final long INF = (long) 1e18;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[][] cost = new int[n + 1][n + 1];
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= n; ++j) {
                    if (i != j) cost[i][j] = in.nextInt();
                }
            }
            long[][] best = new long[n + 1][n + 1];
            long[] suffix = new long[n + 1];
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j < i; ++j) {
                    suffix[j] += cost[i][j];
                }
            }
            for (long[] x : best) Arrays.fill(x, INF);
            best[0][0] = 0;
            for (int a = 1; a <= n; ++a) {
                long inside = 0;
                for (int j = 1; j < a; ++j) {
                    suffix[j] -= cost[a][j];
                }
                for (int b = a - 1; b >= 0; --b) {
                    long outside = 0;
                    for (int c = b; c >= 0; --c) {
                        if (best[b][c] < INF) {
                            best[a][b] = Math.min(best[a][b], best[b][c] + outside + inside);
                        }
                        outside += suffix[c];
                    }
                    for (int c = a; c > b; --c) {
                        inside += cost[b][c];
                    }
                }
            }
            long res = INF;
            for (int a = 1; a <= n; ++a) {
                res = Math.min(res, best[n][a]);
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 45512
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
#define println std::cout << std::endl;
using LL = long long;
#define lrt rt << 1
#define rrt rt << 1 | 1
#define lson l, m, lrt
#define rson m + 1, r, rrt
const int N = 3e5 + 2;
int mx[N * 5];

void update(int p, int val, int l, int r, int rt) {
	mx[rt] = std::max(mx[rt], val);
	if (l == r) return;
	int m = (l + r) >> 1;
	if (p > m) update(p, val, rson);
	else update(p, val, lson);
}
int query(int L, int R, int l, int r, int rt) {
	if (L <= l && R >= r) return mx[rt];
	int m = (l + r) >> 1;
	int ans = 0;
	if (L <= m) ans = std::max(ans, query(L, R, lson));
	if (R > m) ans = std::max(ans, query(L, R, rson));
	return ans;
}
int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n, k;
	std::cin >> n >> k;
	for (int i = 0, x; i < n; ++i) {
		std::cin >> x;
		++x;
		int now = query(x - k, x + k, 1, N, 1);
		update(x, now + 1, 1, N, 1);
	}
	print(mx[1]);
	return 0;
}

Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using Grid = vector<vector<int>>;
using vi = vector<int>;

int main() {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> t;
    t.reserve(N);
    rep(i, N) {
        string s;
        int p;
        cin >> s >> p;
        t.emplace_back(s, -p, i + 1);
    }
    sort(t.begin(), t.end());
    rep(i, N) cout << get<2>(t[i]) << endl;
}

Measured memory_bytes: 3604
package main

import (
	"fmt"
)

func main() {
	var d int
	fmt.Scan(&d)

	s := ""
	switch d {
	case 22:
		s = "Christmas Eve Eve Eve"
	case 23:
		s = "Christmas Eve Eve"
	case 24:
		s = "Christmas Eve"
	case 25:
		s = "Christmas"
	}
	fmt.Println(s)
}


Measured memory_bytes: 1768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<vector<bool>> grid;
vector<vector<ll>> table;
ll A,B;

bool movable(ll sx,ll sy,ll gx,ll gy){
  if(sx<0||sx>=A||sy<0||sy>=B) return false;
  if(gx<0||gx>=A||gy<0||gy>=B) return false;
  
  if(grid.at(sy).at(sx)) return false;
  if(grid.at(gy).at(gx)) return false;
  
  return true;
}

ll dp(ll x,ll y){
  if(x==0&&y==0) return 1;
  if(table.at(y).at(x)>-1) return table.at(y).at(x);
  
  table.at(y).at(x)=0;
  if(movable(x-1,y,x,y)) table.at(y).at(x)+=dp(x-1,y);
  if(movable(x,y-1,x,y)) table.at(y).at(x)+=dp(x,y-1);
  
  return table.at(y).at(x);
}

int main()
{
  while(true){
    cin>>A>>B; if(A==0&&B==0) break; 
    grid=vector<vector<bool>>(B,vector<bool>(A,false));
    ll N; cin>>N;
    rep(i,N){
      ll x,y; cin>>x>>y; x--; y--;
      grid.at(y).at(x)=true;
    }
    
    //dp
    table=vector<vector<ll>>(B,vector<ll>(A,-1)); 
    
    cout<<dp(A-1,B-1)<<endl;
    /*
    rep(y,B){
      rep(x,A){
        if(x!=0) cout<<" ";
        cout<<table.at(y).at(x);
      }
      cout<<endl;
    }
    */
  }
  return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
int a[6];

int main() {
	rep(i,1,4)read(a[i]);sort(a+1,a+4+1);
	printf("%s\n",(a[1]==1&&a[2]==4&&a[3]==7&&a[4]==9)?"YES":"NO");
	return 0;
}

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

int ans,l;
char s[15];

int main(void){
	scanf("%s",s);
	l=strlen(s);
	for(int i=0;i<l;i++)
	if(s[i]=='o')ans++;
	ans+=15-l;
	if(ans>=8)printf("YES");
	else printf("NO");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
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;
typedef pair<int, int> P;

int main() {
    int r, d, x; cin >> r >> d >> x;
    rep(i, 10) {
        x = r*x-d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
typedef long long LL;
#define int LL
int readint(){
	int x=0,f=1;char s=getchar();
	#define sc (s=getchar())
	while(s<'0'||s>'9'){
		if(s=='-')
			f=-1;
		sc;
	}
	while(s>='0'&&s<='9'){
		x=(x<<3)+(x<<1)+(s^48);
		sc;
	}
	#undef sc
	return x*f;
}
signed main(){
	int x=readint();
	double be=100,nian=0;
	while(be<x){
		nian++,be=floor(1.0*be*1.01);
	}
	cout<<nian;
	return 0;
}

Measured memory_bytes: 3788
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    ans = 1
    for i in d.keys():
        ans *= d[i]+1
        ans %= mod
    print(ans-1)
#B
def B():
    n = I()
    c = IR(n)
    v = [[i+1] for i in range(n-1)]
    v.append([])
    d = defaultdict(deque)
    for i in range(n):
        d[c[i]].append(i)
    for i in d.keys():
        x = None
        while d[i]:
            y = d[i].popleft()
            if x != None and y != x+1:
                v[x].append(y)
            x = y
    path = [0]*(n)
    path[0] = 1
    q = [0]
    for x in range(n-1):
        for y in v[x]:
            path[y] += path[x]
            path[y] %= mod
    print(path[-1])
#C
def C():
    sys.setrecursionlimit(100000)
    n,a,b = LI()
    def dfs(l,q,f):
        if len(l) == po2[n]:
            if l[-1] == b:
                print("YES")
                print(*l)
                quit()
        x = l[-1]
        m = -1
        k = -1
        for i in po2[:-1]:
            y = x^i
            if f[y] > m:
                m = f[y]
                k = y
        if m != -1:
            for i in po2[:-1]:
                y = x^i
                if f[y] == m:
                    q.append(y)
            for y in q:
                dfs(l+[y],[],f[:y]+[-1]+f[y+1:])
    po2 = [1]*(n+1)
    for i in range(1,n+1):
        po2[i] = po2[i-1]*2
    ans = [a]
    f = [0]*po2[n]
    for i in range(po2[n]):
        k = b^i
        c = 0
        while k > 0:
            c += k%2
            k//= 2
        f[i] = c
    if not f[a] in [1,3,5,7,9,11,13,15,17,19]:
        print("NO")
        quit()
    f[a] = -1
    l = [a]
    dfs(l,[],f)
    print("NO")
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


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

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#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 ALL(a) (a).begin(), (a).end()

using namespace std;

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

  const int n = 3;
  int a, b;
  cin >> a >> b;

  if( a % n == 0 || b % n == 0 || (a + b) % n == 0) {
    cout << "Possible";
  }
  else {
    cout << "Impossible";
  }

  cout << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
//セグ木

class segment{
public:
	long long int *tree;
	long long int u;
	int height,treeSize,dataSize;
	segment(long long int length,long long int unit){
		long long int pre = 1;
		height=1;
		u=unit;
		
		while(pre<length){
			pre*=2;
			height++;
		}
		
		treeSize = pre*2-1;
		dataSize = pre;
		tree = new long long int[treeSize];
		
		for(int i=0;i<dataSize;i++)set(i,unit);
		construct();

	}
	void replace(long long int index, long long int value){
		tree[treeSize-dataSize+index]=value;
		index=treeSize-dataSize+index+1;
		while(index>0){
			index/=2;
			tree[index-1]=f(tree[index*2-1],tree[index*2]);
		}
	}
	long long int result(long long int l,long long int r){return result(l,r,0,1<<(height-1),0);}
	long long int result(long long int l,long long int r,int s,int len,long long int ind){
		if(l==r)return get(l);
		else if(l==s && r==s+len-1)return tree[ind];
		len/=2;
		
		long long int res=u;
		long long int L=s,R=s+len-1;
		if(!(r<L || R<l))res=f(result(max(L,l),min(R,r),L,len,ind*2+1),res);
		L+=len;R+=len;
		if(!(r<L || R<l))res=f(result(max(L,l),min(R,r),L,len,ind*2+2),res);
		return res;
	}
	
	void construct(){for(int i=treeSize-2;i>0;i-=2)tree[i/2]=f(tree[i],tree[i+1]);}
	void set(long long int index, long long int value){tree[treeSize-dataSize+index]=value;}
	long long int get(long long int index){return tree[treeSize-dataSize+index];}
	
	long long int f(long long int a,long long int b){
		return max(a,b);
	}//親の決定式
};

int main(){
	int N,K,A;
	cin>>N>>K;
	segment seg(300001,0);
	seg.construct();
	
	for(int i=0;i<N;i++){
		cin>>A;
		seg.replace(A,seg.result(max(A-K,0),min(A+K,300000))+1);
	}
	cout<<seg.result(0,300000);
	return 0;
}

Measured memory_bytes: 11788
<?php
//入力受け取り
$input = trim(fgets(STDIN));
//空白区切の入力を整数値にして、配列$ary に格納。
$ary = sscanf($input, "%d %d %d");

//小さい順で並び替え
if ($ary[0] > $ary[1]) {
    list($ary[0], $ary[1]) = [$ary[1], $ary[0]];
}
if ($ary[1] > $ary[2]) {
    list($ary[1], $ary[2]) = [$ary[2], $ary[1]];
}
if ($ary[0] > $ary[1]) {
    list($ary[0], $ary[1]) = [$ary[1], $ary[0]];
}

echo $ary[0]." ".$ary[1]." ".$ary[2]."\n";


Measured memory_bytes: 9240
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  vi a(n); rep(i,n) cin >> a[i];

  int mx = 0, gcd = a[0];
  rep(i,n){
    chmax(mx,a[i]);
    chmin(gcd,__gcd(gcd,a[i]));
  }
  if(k <= mx && k%gcd == 0) cout << "POSSIBLE";
  else cout << "IMPOSSIBLE";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace  std;

struct StDtl
{
  int m_nLeft;

  StDtl(int nLeft) :
    m_nLeft(nLeft)
  { }
};

struct StSum
{
  int m_nLeft;
  int m_nRight;
  int m_nArea;

  StSum(int nLeft, int nRight, int nArea) :
    m_nLeft(nLeft), m_nRight(nRight), m_nArea(nArea)
  { }
};

void fnCroSecSet(stack<StDtl> &rskStDtl, vector<StSum> &rvoSum, int &rnTotalArea)
{
  string sCrossSect;
  cin >> sCrossSect;

  for (int i = 0; i < sCrossSect.size(); i++)
  {
    if (sCrossSect[i] == '\\')
    {
      StDtl oDtl(i);
      rskStDtl.push(oDtl);
    }
    else if (sCrossSect[i] == '/')
    {
      if (rskStDtl.size() > 0)
      {
        int nLeft = rskStDtl.top().m_nLeft; rskStDtl.pop();
        int nSum = i - nLeft; 
        rnTotalArea += nSum;

        while (rvoSum.size()  &&
               nLeft < rvoSum.back().m_nLeft  &&
               rvoSum.back().m_nRight < i       )
        {
          nSum += rvoSum.back().m_nArea;
          rvoSum.pop_back();
        }
        StSum oSum(nLeft, i, nSum);
        rvoSum.push_back(oSum);
      }
      else;
    }
  }
}

void  fnCroSecGet(const vector<StSum> &cnrvoSum, int nTotalArea)
{
  cout << nTotalArea << endl;
  cout << cnrvoSum.size();
  if (cnrvoSum.size() > 0)
  {
    cout << " ";
    for (auto itvoSum = begin(cnrvoSum); itvoSum != end(cnrvoSum); ++itvoSum)
    {
      if (itvoSum != begin(cnrvoSum)) cout << " ";
      cout << itvoSum->m_nArea;
    }
  }
  cout << endl;
}

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

  stack<StDtl> skStDtl;
  vector<StSum> voSum;
  int iTtlAra = 0;

  fnCroSecSet(skStDtl, voSum, iTtlAra);
  fnCroSecGet(voSum, iTtlAra);

  return 0;
}

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

using namespace std;

#define ll long long int

int main()
{
  ll n;
  cin>>n;
  vector< ll > a(n+1),b(n);
  for(int i = 0;i<=n;i++) cin>>a[i];
  for(int i = 0;i<n;i++) cin>>b[i];
  ll counter = 0,c;
  for(int i=0;i<n;i++)
  {
    c = min(a[i],b[i]);
    b[i] -= c;
    a[i] -= c;
    counter += c;
    c = min(a[i+1],b[i]);
    a[i+1] -= c;
    b[i] -= c;
    counter += c;
  }
  cout<<counter<<endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		int num1 = 0;
		int num2 = 0;
		int num3 = 0;
		int ans = 0;

//a,b,cがすべて等しい．
		num1 = K*(K+1) / 2;

//a,b,cのうち2つが等しい．
		for (int a = 1; a < K; a++) {
			for (int b = a+1; b < K+1; b++) {
				num2 += gcd2(a, b);
			}
		}


//a,b,cがすべて異なる．
		for (int a = 1; a < K-1; a++) {
			for (int b = a+1; b < K; b++) {
				for (int c = b+1; c < K+1; c++) {
					num3 += gcd3(a, b, c);
				}
			}
		}

		ans = num1 + num2*6 + num3*6;

		System.out.println(ans);
	}

	public static int gcd2(int x, int y) {
		int i = x;

		while (i > 1) {
			if (x%i == 0 && y%i == 0) {
				break;
			}
			i--;
		}

		return i;
	}

	public static int gcd3(int x, int y, int z) {
		int i = x;

		while (i > 1) {
			if (x%i == 0 && y%i == 0 && z%i == 0) {
				break;
			}
			i--;
		}

		return i;
	}

}

Measured memory_bytes: 35884
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); //入力
		int targetNumber = sc.nextInt();  //ターゲットの数字
		int max_dividing = 0; //今までの中で一番割る回数が多かった回数
		int max_number = 1; //今までの中で一番割る回数が多かった数字


		for(int i = 1; i <= targetNumber; i++) { //一つ一つの数字について、まとめる。
			int ExTargetNumber = i;
			int manyOfdividing = 0; //それぞれの数字の割る回数を格納
			while(true) { //一つ一つの数字に対して、割る回数を計算し、暫定の最大割る回数の数字を格納
				if(ExTargetNumber % 2 == 0 && ExTargetNumber >0){
					ExTargetNumber = ExTargetNumber / 2;
					manyOfdividing++;
				}else {
					if(max_dividing < manyOfdividing) {
						max_dividing = manyOfdividing;
						max_number = i;
					}
					break;
				}
			}
		}
		System.out.println(max_number);
	}
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(void){
    int n,b,f,r,p,i;
    int a[5][4][11]={};
    scanf("%d\n",&n);
    for(i=1;i<=n;i++){
        scanf("%d %d %d %d\n",&b,&f,&r,&p);
        a[b][f][r]+=p;
    }
    for(b=1;b<=4;b++){
        for(f=1;f<=3;f++){
            for(r=1;r<=10;r++){
                printf(" %d",a[b][f][r]);
            }
            printf("\n");
        }
        //#???20?????¨???
        if(b<=3){
            for(i=0;i<20;i++){
                printf("#");
            }
            printf("\n");
        }
    }
    return 0; /*0?????????*/
}

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

int arr[100010];
int dp[100010];

int main (){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	dp[1] = 0;
	dp[2] = abs(arr[1] - arr[2]);
	
	for(int i = 3; i <= n; i++){
		dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);
	}
	
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int n;
ll a[MN],mul,lim;
int main(){
	mul=1;scanf("%d",&n);
	lim=1000000000000000000ll;
	for(reg int i=1;i<=n;i++)scanf("%lld",a+i);
	for(reg int i=1;i<=n;i++)if(!a[i])return 0*puts("0");
	for(reg int i=1;i<=n;i++){
		if(lim/a[i]<mul)return 0*puts("-1");
		mul*=a[i];
	}
	printf("%lld\n",mul);
	return 0;
}

Measured memory_bytes: 4572
A, B, K = map(int, input().split())
center = (A + B) // 2

max_limit = A + K - 1
min_limit = B - K + 1

end_n = center if center <= max_limit else max_limit
for i in range(A, end_n + 1):
    print(i)
        
begin_n = center + 1 if center + 1 >= min_limit else min_limit
for i in range(begin_n, B + 1):
    print(i)

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

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

    string S;
    cin >> S;

    int ans = N;
    char prev = '0';

    for (int i = 0; i < N; ++i) {
        if (S[i] != prev) --ans;
        prev = S[i];
    }

    ans = min(N - 1, ans + K * 2);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import bisect
def ifprime(n):
    for i in range(3,int(n**0.5)+1):
        if n%i==0:return(False)
    return(True)
prime_list=[2,3]
while 1:
    try:
        n=int(input())
        if n>prime_list[-1]+1:
            for i in range(prime_list[-1]+2,n+1,2):
                if ifprime(i):prime_list.append(i)
        x=bisect.bisect_left(prime_list,n+1)    
        print(x)
    except:break


Measured memory_bytes: 8720
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for(int i = 0; i < N; i ++){
		for(int j = 0; j < D; j ++){
			cin >> X[i][j];
		}
	}
	ll ddist, dist, ans = 0;
	for(int i = 0; i < N - 1; i ++){
	for(int j = i + 1; j < N; j ++){
		ddist = 0;
		for(int k = 0; k < D; k ++){
			ddist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
		}
		dist = sqrt(ddist);
		if(ddist == dist * dist){
			ans ++;
		}
	}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


int main(){
 
    while(true) {
        int n;
        cin>>n;
        if(n==0)break;
        
        int ans=0;
        for(int i=1;i<n;i++){
            int t=n;
            for(int j=i;j>0;j--){
                t-=j;
                if(t==0)ans++;
            }
        }
        
        cout<<ans<<endl;
        
    }
    return 0;
}

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

int main() {
  int h,w,cnt=0;
  bool dots=false;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  vector<int> hh(0);
  vector<int> ww(0);
  rep(i,h)rep(j,w) cin >> a[i][j];
  rep(i,h){
    cnt=0;
    rep(j,w){
      if(a[i][j]=='.') cnt++; 
    }
    if(cnt==w) hh.push_back(i);
  }
  rep(j,w){
    cnt=0;
    rep(i,h){
      if(a[i][j]=='.') cnt++;
    }
    if(cnt==h) ww.push_back(j);
  }
  rep(i,h){
    if(find(hh.begin(), hh.end(),i)==hh.end()){
      rep(j,w){
        if(find(ww.begin(), ww.end(),j)==ww.end()){
          cout << a[i][j];
        }
      }
      cout << "\n";
    }
  }
  
}  

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto H = aryread();
    long ans;
    long i;
    while (i < N)
    {
        if (H[i] == 0)
        {
            i++;
            continue;
        }
        long j = i;
        while (j < N && H[j] != 0)
            j++;
        long c = H[i .. j].reduce!min();
        ans += c;
        H[i .. j][] -= c;
    }
    writeln(ans);
}


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

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  
  int ans = 0;
  for (int i=A ; i<=B ; i++){
    if (i%K == 0){
      ans = 1;
      break;
    }
  }
  
  if (ans == 1)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}

Measured memory_bytes: 3592
p=input().split()
a=int(p[1])
b=int(p[0])
i=1
while i<=b:
    if(a==0 or b==0):
        print(max(a,b))
        break
    elif((a*i)%b==0):
        print(a*i)
        break
    i+=1



    

Measured memory_bytes: 40400
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

bool ask(const vector<uint>& index) {
	cout << "?" << " ";
	for(uint i=0; i<index.size(); i++) {
		cout << index[i] + 1 << " ";
	}
	cout << endl;
	string ans;
	cin >> ans;
	cout << flush;

	if(ans == "-1") {
		exit(-1);
	}
	return (ans == "Red");
}

int main() {

	uint N;
	cin >> N;

	uint low = 0;
	uint high = N;
	vector<uint> id(N);
	iota(id.begin(), id.end(), 0);
	bool low_c = ask(id);
	bool high_c = !low_c;
	uint mid = (low + high) / 2;

	while(low < high) {
		mid = (low + high) / 2;
		iota(id.begin(), id.end(), mid);
		bool mid_c = ask(id);

		if (mid_c == high_c) {
			high = mid;
		} else {
			low = mid + 1;
		}
	}

	uint dpoint = low;
	// cout << "dpoint : " << dpoint << endl;
	vector<uint> ball_color(N * 2);
	ball_color[dpoint-1] = low_c;
	ball_color[dpoint+N-1] = high_c;

	// cout << "outer part 1" << endl;
	iota(id.begin(), id.end()-1, dpoint);
	for(uint i=0; i<dpoint-1; i++) {
		id[N-1] = i;
		ball_color[i] = ask(id);
	}

	// cout << "outer part 2" << endl;
	for(uint i=dpoint+N; i<2*N; i++) {
		id[N-1] = i;
		ball_color[i] = ask(id);
	}

	// cout << "inner part" << endl;
	iota(id.begin(), id.begin()+dpoint-1, 0);
	iota(id.begin()+dpoint-1, id.end()-1, dpoint+N);
	for(uint i=dpoint; i<dpoint+N-1; i++) {
		id[N-1] = i;
		ball_color[i] = ask(id);
	}

	cout << "! ";
	for(uint i=0; i<N*2; i++) {
		char color = ball_color[i] ? 'R' : 'B';
		cout << color;
	}

	return 0;
}


Measured memory_bytes: 724
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;

vector<ll> fac;
vector<ll> ifac;

ll binmodulo(ll x, ll y){
    x%=mod;
    if(!x) return 0;
    ll res = 1;
    while(y){
        if(y&1){
            res = res*x%mod;
        }
        y/=2;
        x = x*x%mod;
    }
    return res;
}

void precompute(int n){
    fac.resize(n+1,1);
    ifac.resize(n+1);
    for(int i =2; i <=n; i++){
        fac[i] = i*fac[i-1]%mod;
    }
    ifac[n] = binmodulo(fac[n], mod-2);
    for(int i = n-1; i>=0; i--){
        ifac[i] = (i+1)*ifac[i+1]%mod;
    }
}

ll ncr(ll n, ll r){
    return fac[n]*ifac[n-r]%mod*ifac[r]%mod;
}

int main(){
    Shazam;
    ll n,k; cin>>n>>k;
    precompute( n );
    for(int i = 1 ; i <=k; i++){
        if(n-k+1<i){cout<<0<<endl; continue;}
        cout<<ncr(k-1,i-1)*ncr(n-k+1,i)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
n, p = [int(w) for w in input().split()]


if n == 1:
    ans = p
else:
    ans = 1
    i = 2
    while i <= int(p ** (1 / n)):
        while (p / ans ** n) % i ** n == 0 and (p / ans ** n) > 0:
            ans *= i
        i += 1
print(ans)


Measured memory_bytes: 9364
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;  // 番兵

// keyを持つ最初の要素を見つけて返す
Node* listSearch(int key){
  Node *cur = nil->next;  // 番兵の次の要素から辿る
  while (cur!=nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

// 初期化
void init(){
  nil = (Node *)malloc(sizeof(Node));  // 動的にメモリを確保
  nil->next = nil;
  nil->prev = nil;
}


void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if (cur==nil) break;
    if (isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur -> next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if (t==nil) return;  // tが番兵の場合は処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  // 検索したノードを削除
  deleteNode(listSearch(key));
}

// 先頭に要素を追加する
void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  x->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size=0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i=0; i<n; i++){
    scanf("%s %d", com, &key);
    if (com[0]=='i'){
      insert(key);
      np++;
      size++;
    }else if(com[0]=='d'){
      if(strlen(com)>6){
        if (com[6]=='F') deleteFirst();
        else if(com[6]=='L') deleteLast();
      }else{
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 36992
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}


int n;
P v[225816],segtree[816225];

void init(int i, int l, int r){
	if(r-l>1){
		init(i*2+1,l,(l+r)/2);
		init(i*2+2,(l+r)/2,r);
		segtree[i] = max(segtree[i*2+1],segtree[i*2+2]);
	}else{
		segtree[i] = P(v[l].second,l);
	}
}

P query(int a, int b, int i, int l, int r){
	if(r<=a || b<=l){
		return P(-INFLL,-1ll);
	}else if(a<=l && r<=b){
		return segtree[i];
	}else{
		return max(query(a,b,i*2+1,l,(l+r)/2),query(a,b,i*2+2,(l+r)/2,r));
	}
}

bool done[225816][2];
ll memo[225816][2];

ll solve(int i, int st){
	int j;
	if(done[i][st]){
		return memo[i][st];
	}
	done[i][st] = true;
	if(i==n-1){
		return memo[i][st] = 1ll;
	}
	if(st){
		j = (int)(lower_bound(v,v+n,P(v[i].second,-INFLL))-v); --j;
		if(i==j){
			memo[i][st] = (solve(i+1,0)+solve(i+1,1))%MOD;
		}else{
			j = query(i+1,j+1,0,0,n).second;
			memo[i][st] = solve(j,1);
		}
	}else{
		memo[i][st] = (solve(i+1,0)+solve(i+1,1))%MOD;
	}
	return memo[i][st];
}

int main(void){
	int i;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> v[i].first >> v[i].second;
		v[i].second += v[i].first;
	}
	sort(v,v+n); init(0,0,n);
	cout << (solve(0,0)+solve(0,1))%MOD << endl;
	return 0;
}


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

 int main() {
   string S, T;
   cin >> S >> T;

   vector<int> Scnt(26, 0), Tcnt(26, 0);

   rep(i, 0, S.length()) {
     Scnt.at(S.at(i) - 'a')++;
     Tcnt.at(T.at(i) - 'a')++;
   }

   string ans = "Yes";

   rep(i, 0, S.length()) {
     if (Scnt.at(S.at(i) - 'a') != Tcnt.at(T.at(i) - 'a')) {
       ans = "No";
       break;
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 776
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;
map<int,int>q;
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    LL s=0,count=0;
    int x;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        s+=x;
        q[s%m]++;
        count+=q[s%m]-1;
        if(s%m==0)
            count++;
    }
    printf("%lld\n",count);
    return 0;
}


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

const int MAX = 111;

int h, w, n, a, p;
int grid[MAX * MAX];

int main() {

    scanf("%d%d%d", &h, &w, &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        while (a--)
            grid[p++] = i  + 1;
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            printf("%d ", grid[w * i + ((i & 1) ? w - j - 1 : j)]);
        puts("");
    }

    return 0;
}


Measured memory_bytes: 384
import queue

n,m=map(int,input().split())
fromto=[list(map(int,input().split()))for _ in range(n+m-1)]
m += n-1
fr = [[]for _ in range(n+1)]
to = [0]*(n+1)
ans = [0]*(n+1)
for f,t in fromto:
    fr[f].append(t)
    to[t]+=1
for i in range(1,n+1):
    if to[i] is 0:
        root = i
q=queue.Queue()
q.put(root)
while not q.empty():
    now = q.get()
    for nex in fr[now]:
        to[nex] -= 1
        if to[nex] is 0:
            ans[nex] = now
            q.put(nex)

for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 39224
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a;
    cin >> a;
    
    if(a%2!=0)
    {
        cout << a*2;
    }
    else
    {
        cout << a;
    }
}


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

int main()
{
	int N;
	std::string S;
	std::cin >> N >> S;
	int limit{1 << N};
	std::vector<std::pair<std::string, std::string>> former(limit);
	for (int i{}; i < limit; i++)
	{
		for (int j{}; j < N; j++)
			if (i >> j & 1)
				former[i].first += S[j];
		for (int j{N - 1}; j >= 0; j--)
			if (~i >> j & 1)
				former[i].second += S[j];
	}
	std::sort(former.begin(), former.end());

	long long count{};
	for (int i{}; i < limit; i++)
	{
		std::pair<std::string, std::string> tmp;
		for (int j{}; j < N; j++)
			if (i >> j & 1)
				tmp.first += S[2 * N - 1 - j];
		for (int j{N - 1}; j >= 0; j--)
			if (~i >> j & 1)
				tmp.second += S[2 * N - 1 - j];
		count += std::upper_bound(former.begin(), former.end(), tmp) - std::lower_bound(former.begin(), former.end(), tmp);
	}
	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 35840
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

namespace {
	int cnt, m;
	vector<int> G;

	void InsertionSort(vector<int>& A, int n, int g)
	{
		for (int i = g; i < n; ++i)
		{
			int v = A[i];
			int j = i - g;

			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}

			A[j + g] = v;
		}
	}

	void ShellSort(vector<int>& A, int n)
	{
		cnt = 0;
		G.push_back(1);
		for (int i = 1; i <= n; ++i)
		{
			int g = pow(4, i) + 3 * pow(2, i - 1) + 1;
			if (g <= n) G.push_back(g);
			else { m = i; break; }
		}

		for (int i = m - 1; i >= 0; --i)
			InsertionSort(A, n, G[i]);
	}
}

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

	vector<int> A(n, 0);
	for (int i = 0; i < n; ++i)
		cin >> A[i];

	ShellSort(A, n);

	cout << m << endl;
	for (int i = m - 1; i >= 0; --i) {
		cout << G[i];
		i != 0 ? cout << " " : cout << endl;
	}
	cout << cnt << endl;
	for (int i = 0; i < n; ++i)
		cout << A[i] << endl;

	return 0;
}

Measured memory_bytes: 4896
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int N,a,b,t=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		t += (b - a + 1);
	}
	cout << t << endl;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i ++) {
    string a, b;
    cin >> a >> b;
    int alen = a.length();
    int blen = b.length();
    int maxlen = max(alen, blen);
    vector<int> a_vec(maxlen, 0);
    vector<int> b_vec(maxlen, 0);
    vector<int> c_vec(maxlen + 1, 0); // carry
    vector<int> r_vec; // result
    for (int i = 0; i < alen; i ++) {
      a_vec[alen - i - 1] = (a[i] - '0');
    }
    for (int i = 0; i < blen; i ++) {
      b_vec[blen - i - 1] = (b[i] - '0');
    }
    for (int i = 0; i < maxlen; i ++) {
      c_vec[i + 1] = (a_vec[i] + b_vec[i] + c_vec[i]) / 10;
      r_vec.insert(r_vec.begin(), (a_vec[i] + b_vec[i] + c_vec[i]) % 10);
      if (i == maxlen - 1 && c_vec[maxlen] != 0) {
        r_vec.insert(r_vec.begin(), c_vec[maxlen]);
      }
    }
    if (alen > 80 || blen > 80 || r_vec.size() > 80) {
      cout << "overflow" << endl;
      continue;
    }
    for (auto itr = r_vec.begin(); itr != r_vec.end(); ++itr) {
      cout << *itr;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
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; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

ll gcd(ll a, ll b){
    while(b!=0){
        ll tmp = a;
        a = b;
        b = tmp%a;
    }
    return a;
}
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll A, B;
    cin >> A>> B;
    ll d = gcd(A, B);
    ll res = (A/d) * B;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
    ll n,m;cin>>n>>m;
    vector<ll>G[n];
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll>seen(n,-1);
    queue<ll>que;
    que.push(0);
    while(!que.empty()){
        ll u=que.front();
        que.pop();
        for(auto v:G[u]){
            if(seen[v]==-1){
                que.push(v);
                seen[v]=u;
            }
        }
    }
    bool isOK=true;
    for(int i=1;i<n;i++){
        if(seen[i]==-1)isOK=false;
    }
    if(!isOK)cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        for(int i=1;i<n;i++){
            cout<<seen[i]+1<<endl;
        }
    }
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 12844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int A,B,M;cin>>A>>B>>M;
    int amin=100000,bmin=100000;
    vector<int> a(A),b(B),c(M);
    rep(i,A){cin>>a[i];amin=min(amin,a[i]);}
    rep(i,B){cin>>b[i];bmin=min(bmin,b[i]);}
    int ans = amin+bmin;
    rep(i,M){
        int x,y,c;cin>>x>>y>>c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    co(ans);
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main(){
    int N;
    scanf("%d",&N);
    int p[N];
    for(int i=0; i<N; i++){
        scanf("%d",&p[i]);
    }
    int count = 0;
    for(int j=1;j<N-1;j++){
        if((p[j-1]<p[j])&&(p[j]<p[j+1])){
            count++;
        }
        else if((p[j-1]>p[j])&&(p[j]>p[j+1])){
            count++;
        }
    }
    printf("%d\n",count);
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, k; cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int h; cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    
    String src;
    int n;
    int[] d;
    
    
    
    Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
    
    d = new int[n];
    
    
    for (int i = 0; i < n; i++) {
      d[i] = sc.nextInt();
    }
    
    int sum = 0;
    
    for (int i = 0; i < n; i++) {
      for (int j = i+1; j < n; j++) {
        sum += d[i] * d[j];
      }
    }
    
    
    System.out.println(sum);
    
    return;
  }
}

    
    
    

Measured memory_bytes: 21716
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);CIN(T);
    int ins = -1;
    int mi = -1e9;
    int co = 1e9;
    REP(a,N){
        CIN(C);CIN(t);
        if(T >= t){
            if(co >= C){
                co = C;
                ins = a;
            }
        }
    }
    if(ins == -1){
        COUT("TLE");
        return 0;
    }
    COUT(co);
    //CIN(a);
    //CIN(b);
    //CIN(c);
    //SCIN(str);

    return 0;
}


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

using namespace std;

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

typedef long long ll;

ll mod = 1000000007LL;
ll sum[63][2], A[300010];

ll modmultiply(ll a,ll b,ll c) {
  ll x = 0,y = a%c; 
  while(b > 0) {
    if(b%2 == 1) x = (x+y)%c; 
    y = (y*2)%c;
    b /= 2; 
  }
  return x%c;
}


inline void update(int i, int cost) {
  rep(j,61) {
    int key = 0;
    if( A[i] & (1LL<<j) ) key = 1;
    sum[j][key] += cost;
  }
}

int main() {
  
  int n;
  cin >> n;
  rep(i,n) cin >> A[i];

  rep(i,n) update(i, +1);

  ll ans = 0;
  rep(i,n-1) {
    update(i, -1);
    rep(j,61) {
      int key = 0;
      if( A[i] & (1LL<<j) ) key = 1;
      key = ( ( key == 1 ) ? 0 : 1 );
      ll cost = ( sum[j][key] * ( (1LL<<j) % mod ) );
      //ll cost = modmultiply(sum[j][key], (1LL<<j), mod);
      ( ans += cost ) %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5856