akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 105

struct Edge{
	Edge(int arg_to,ll arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to;
	ll dist;
};

struct Info{
	Info(int arg_from,int arg_to,ll arg_dist){
		from = arg_from;
		to = arg_to;
		dist = arg_dist;
	}

	int from,to;
	ll dist;
};


int N,M,num_case;
int start,goal;
int pre_node[SIZE];
bool is_inf[SIZE],visited[SIZE];
ll MAX;
ll dp[SIZE],work[SIZE];
ll add_hp[SIZE][SIZE];
vector<Edge> G[SIZE];
vector<Info> info;

bool calc(int edge_id){

	dp[info[edge_id].to] = min(MAX,dp[info[edge_id].from]+info[edge_id].dist);
	pre_node[info[edge_id].to] = info[edge_id].from;

	vector<int> vec;
	vec.push_back(info[edge_id].to);

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

		visited[i] = false;
	}

	int current = info[edge_id].to,pre;
	visited[current] = true;

	while(true){

		pre = pre_node[current];
		if(pre == -1){

			return true;
		}
		if(visited[pre])break;
		visited[pre] = true;
		vec.push_back(pre);

		current = pre;
	}

	if(pre != info[edge_id].to)return true;

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

		work[i] = -HUGE_NUM;
	}

	ll tmp = dp[vec[0]];
	work[vec[0]] = tmp;
	ll maximum = tmp;

	reverse(vec.begin(),vec.end());

	for(int i = 0; i < vec.size()-1; i++){

		tmp += add_hp[vec[i]][vec[i+1]];
		if(tmp > MAX){

			tmp = MAX;
		}
		maximum = max(maximum,tmp);
		work[vec[i+1]] = tmp;
	}

	for(int i = 0; i < vec.size(); i++){

		if(work[vec[i]] == maximum){

			dp[vec[i]] = MAX;
		}
	}

	return true;
}

void func(){

	info.clear();

	for(int i = 0; i < N; i++){
		G[i].clear();
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){

			add_hp[i][k] = -HUGE_NUM;
		}
	}

	int from,to;
	ll dist;

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

		scanf("%d %d %lld",&from,&to,&dist);
		add_hp[from][to] = max(add_hp[from][to],dist);
	}

	scanf("%d %d %lld",&start,&goal,&MAX);

	for(int from = 0; from < N; from++){
		if(from == goal)continue;
		for(int to = 0; to < N; to++){
			if(add_hp[from][to] == -HUGE_NUM)continue;

			G[from].push_back(Edge(to,add_hp[from][to]));
			info.push_back(Info(from,to,add_hp[from][to]));
		}
	}

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

		dp[i] = -HUGE_NUM;
		pre_node[i] = -1;
	}
	dp[start] = MAX;

	bool FLG = true;

	while(FLG){

		FLG = false;

		for(int i = 0; i < info.size(); i++){
			if(dp[info[i].from] <= 0 || dp[info[i].from]+info[i].dist <= 0 ||
					min(MAX,dp[info[i].from]+info[i].dist) <= dp[info[i].to])continue;

			FLG |= calc(i);
		}

		if(!FLG)break;
	}


	printf("Case %d: ",num_case);

	if(dp[goal] == -HUGE_NUM){

		printf("GAME OVER\n");

	}else{

		printf("%lld\n",dp[goal]);
	}
}

int main(){

	num_case = 1;

	while(true){

		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
		num_case++;
	}

	return 0;
}



Measured memory_bytes: 3308
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

#define INF 2147483647
#define EPS 1e-12

using namespace std;

typedef long double T;

struct PT{
	T x, y;
	PT(T x = 0, T y = 0) : x(x), y(y){}
	PT(const PT& p) : x(p.x), y(p.y){}
	
	PT operator+(const PT& p) const{
		return PT(x + p.x, y + p.y);
	}
	PT operator-(const PT& p) const{
		return PT(x - p.x, y - p.y);
	}
	PT operator*(T c) const{
		return PT(x * c, y * c);
	}
	PT operator/(T c) const{
		return PT(x / c, y / c);
	}
};

T dot(PT p, PT q){
	return p.x*q.x + p.y*q.y;
}

T dist2(PT p, PT q){
	return dot(p-q, p-q);
}

T cross(PT p, PT q){
	return p.x * q.y - p.y * q.x;
}

ostream &operator << (ostream &os, const PT& p){
	os << fixed << setprecision(9) << p.x << " " << p.y;
}

PT RotateCCW90(PT p) {
	return PT(-p.y, p.x);
}

/*
vector <PT> CircleLineIntersection(PT a, PT b, PT c, T r) {
	vector <PT> ret;
	b = b-a;
	a = a-c;
	T A = dot(b, b);
	T B = dot(a, b);
	T C = dot(a, a) - r*r;
	T D = B*B - A*C;
	if (D < -EPS) return ret;
		ret.push_back(c+a+b*(-B+sqrt(D+EPS))/A);
	if (D > EPS)
		ret.push_back(c+a+b*(-B-sqrt(D))/A);
	return ret;
}
*/

vector <PT> CircleCircleIntersection(PT a, PT b, T r, T R) {
	vector <PT> ret;
	T d = sqrt(dist2(a, b));
	if (d > r+R || d+min(r, R) < max(r, R)) return ret;
	T x = (d*d-R*R+r*r)/(2*d);
	T y = sqrt(r*r-x*x);
	PT v = (b-a)/d;
	ret.push_back(a+v*x + RotateCCW90(v)*y);
	if (y > 0)
		ret.push_back(a+v*x - RotateCCW90(v)*y);
	return ret;
}



int main(){
	int cx[2], cy[2], r[2];
	
	
	vector<PT> ans;
	
	for(int i = 0; i < 2; i++){
		cin >> cx[i] >> cy[i] >> r[i];
	}
	
	
	ans = CircleCircleIntersection(PT(cx[0], cy[0]), PT(cx[1], cy[1]), r[0], r[1]);
	
	if(ans.size() == 1){
		cout << ans[0] << " " << ans[0] << endl;
	}
	else{
		if(ans[0].x == ans[1].x){
			if(ans[0].y < ans[1].y)
				cout << ans[0] << " " << ans[1];
			else 
				cout << ans[1] << " " << ans[0];
		}
		else{
			if(ans[0].x < ans[1].x)
				cout << ans[0] << " " << ans[1];
			else 
				cout << ans[1] << " " << ans[0];
		}
	}
	cout << endl;

	
	return 0;
}

Measured memory_bytes: 3276
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

// (num ^ x) % mod
LL pow_mod(LL num, LL x, LL mod)
{
	LL res = 1;
	while (x > 0)
	{
		if (x & 1)
		{
			res = (res * num) % mod;
		}
		num = (num * num) % mod;
		x >>= 1;
	}
	return res;
}

const LL mod = 1000000007;
std::vector<LL>A;
std::vector<std::vector<LL>>memo;

LL dp(LL i, LL j)
{
	if (i == A.size()) return (j == 5 ? 1 : 0);
	if (memo[i][j] != -1) return memo[i][j];
	LL res = 0;
	if (A[i] == -1)
	{
		for (LL k = 0; k <= 9; ++k) (res += dp(i + 1, (j + k * pow_mod(10, i, 13)) % 13)) %= mod;
	}
	else res = dp(i + 1, (j + A[i] * pow_mod(10, i, 13)) % 13);
	return memo[i][j] = res;
}

int main()
{
	std::string S;
	in >> S;

	rep(i, S.length())
	{
		if (S[i] == '?') A.push_back(-1);
		else A.push_back(S[i] - '0');
	}
	std::reverse(A.begin(), A.end());

	memo.resize(S.length(), std::vector<LL>(13, -1));
	out << dp(0, 0) << std::endl;
}


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

class Guidebook {
public:
  string s;
  int p;
  int i;

  bool operator <(const Guidebook& a) const {
    return s == a.s ? p < a.p : s > a.s;
  }
};

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

  priority_queue<Guidebook> pq;

  for (int i = 1; i <= n; i++) {
    string s;
    int p;
    cin >> s >> p;
    pq.push({s, p, i});
  }

  while (!pq.empty()) {
    cout << pq.top().i << endl;
    pq.pop();
  }
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#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 all(c) c.begin(),c.end()

int main()
{
	string S;
	cin >> S;
 	int w;
	cin >> w;
	string ans;
	for (int i = 0; i < (int)S.length(); i += w) {
		ans += S[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  sort(A.begin(), A.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < K; i++){
    ans += A[i];
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
/**
  @file c.cpp
  @title C - Attack Survival
  @url https://atcoder.jp/contests/abc141/tasks/abc141_c
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  LL N, K, Q;
  cin >> N >> K >> Q;
  map<LL, int> m;
  LL tmpA;
  REP(i, Q) {
    cin >> tmpA;
    m[tmpA - 1]++;
  }

  REP(i, N) {
    if (K + m[i] - Q > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6912
N, x = gets.split.map(&:to_i)
#N, x = 2000, 1000
as = gets.split.map(&:to_i)
#as = N.times.to_a

min = as.dup
ans = as.inject(:+)
(1...N).each do |i|
    result = i * x
    N.times do |j|
        min[j] = as[(j-i)%N] if min[j] > as[(j-i)%N]
        result += min[j]
    end
    ans = result if ans > result
end

puts ans

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

#define PB emplace_back

using namespace std;

const int N = 5e5+100;

int par[N], h[N];

int fat(int x) {
    while(x != par[x]) x = par[x];
    return x;
}

void add(int u, int v) {
    u = fat(u);
    v = fat(v);
    if(u != v) {
        //if(h[u] > h[v]) swap(u, v);
        //h[u] = max(h[u], h[v] + 1);
        par[v] = u;
    }
}

int main () {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, m;
    cin >> n >> m;
    iota(par, par + n , 0);
    while(m--) {
        int t, u1, u2;
        cin >> t >> u1 >> u2;
        if(t) cout << (fat(u1) == fat(u2)) << '\n';
        else add(u1, u2);
    }
}


Measured memory_bytes: 4296
n=input()
digit=len(n)
n=int(n)
ans=0

if digit%2==0:
    for i in range(digit//2):
        ans*=100
        ans+=9
else:
    for i in range(digit//2):
        ans*=100
        ans+=9
    ans+=n-10**(digit-1)+1

print(ans)




Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	vll a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	vll sub(n);
	rep(i,n) sub[i] = b[i]-a[i];
	SORT(sub);
	ll lack = 0;
	int ans = 0;
	rep(i,n){
		if(sub[i]>0){
			lack += sub[i];
			ans++;
		}
	}
	if(lack<=0) ans = 0;
	else{
		rep(i,n){
			if(sub[i]>=0){ ans = -1; break; }
			else{		
				lack += sub[i];
				ans++;
				if(lack<=0) break;	
			}
		}
	}
	out(ans);
}




Measured memory_bytes: 2560
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn . show $ solve (init s)

solve :: String -> Int
solve s = if odd l then solve (init s) else (if take (div l 2) s == drop (div l 2) s then l else solve (take (l-2) s))
    where
        l = length s



Measured memory_bytes: 892
#include<iostream>

using namespace std;

int main()
{
  int n;cin >> n;
  if(n%10 == 3){
    cout << "bon";
  }
  else if(n%10==0||n%10==6||n%10==1||n%10==8){
      cout << "pon";
  }
  else{
      cout << "hon";
  }
  
  return 0;
}

Measured memory_bytes: 3600
func main() {
    let NMX = readLine()!.split(separator: " ").map {Int($0)!}
    let (N, M, X) = (NMX[0], NMX[1], NMX[2])
    var ithBook = [[Int]]()
    for _ in 0..<N {
        ithBook.append(readLine()!.split(separator: " ").map {Int($0)!})
    }
    let possibility = 1 << N
    var lowestCost = Int.max
    for i in 0..<possibility {
        var cost = 0
        var understangs = [Int](repeating: 0, count: M)
        for j in 0..<N {
            if ((i >> j) & 1) == 1 {
                cost += ithBook[j][0]
                for k in 0..<M {
                    understangs[k] += ithBook[j][k+1]
                }
            }
        }
        if understangs.allSatisfy({$0 >= X}) {
            lowestCost = min(lowestCost, cost)
        }
    }
    print(lowestCost == Int.max ? -1 : lowestCost)
}

main()


Measured memory_bytes: 8316
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
rl = lambda: map(int, input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7


N,Q=rl()
TT = []
now = set()
for _ in range(N):
    s,t,x = rl()
    TT.append((s-x-0.5,1,x))
    TT.append((t-x-0.5,-1,x))
for i in range(Q):
    d = ri()
    TT.append((d,0,i))


TT.sort()
mx = INF
mx_f = False
ans = [-1]*Q
for st,w,x in TT:
    if w > 0:
        now.add(x)
        if mx > x:
            mx = x
            mx_f = True
    elif w < 0:
        now.remove(x)
        if mx == x:
            mx_f = False
    elif len(now) > 0:
        if not mx_f:
            mx = min(now)
            mx_f = True
        ans[x] = mx
print(*ans,sep='\n')

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

using namespace std;
using ll = long long;

int main() {
    ll A, B, N;
    ll x;

    cin >> A >> B >> N;
    x = (B - 1 <= N) ? B - 1 : N;

    cout << A * x / B - x / B * A << endl;

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,P;
  long long answer=-1000000007;
  cin>>N>>K;
  vector<int> NV(N);
  vector<int> C(N);
  for(int i=0;i<N;i++){
    cin>>P;
    NV.at(i)=P-1;
  }
  for(int i=0;i<N;i++){
    cin>>C.at(i);
  }
  for(int i=0;i<N;i++){
    int roop=0,v1=i;
    long long roopValue=0,answerI=0;
    vector<int> visited1(N,0);
    while(visited1.at(v1)==0){
      visited1.at(v1)=1;
      v1=NV.at(v1);
      roop++;
      roopValue+=C.at(v1);
    }
    if(roopValue>0){
      if(K/roop==0){
        answerI=C.at(NV.at(i));
        int v2=i,count=1;
        long long memo=0;
        while(count<=min(roop,K)){
          count++;
          v2=NV.at(v2);
          memo+=C.at(v2);
          answerI=max(answerI,memo);
        }
      }
      else{
        answerI=(K/roop-1)*roopValue;
        int remain=K%roop+roop,v2=i,count=1;
        long long memo=answerI;
        if(K/roop==1 && remain==roop){
          answerI+=C.at(NV.at(i));
        }
        while(count<=remain){
          count++;
          v2=NV.at(v2);
          memo+=C.at(v2);
          answerI=max(answerI,memo);
        }
      }
    }
    else if(roopValue<0){
      answerI=C.at(NV.at(i));
      int v2=i,count=1;
      long long memo=0;
      while(count<=min(roop,K)){
        count++;
        v2=NV.at(v2);
        memo+=C.at(v2);
        answerI=max(answerI,memo);
      }
    }
    answer=max(answer,answerI);
  }
  cout<<answer<<endl;
}


Measured memory_bytes: 3652
function main(input) {
  var H = input[0].split(" ")[0]-0;
  var N = input[0].split(" ")[1]-0;
  var sum = input[1].split(" ").map(v=>v-0).reduce((a,b)=>a+b);

  console.log(sum>=H?"Yes":"No");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double PI = acos(-1);
const double EPS = 1e-9; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
// #define LE(n,m) ((n) < (m) + EPS)
#define LE(n,m) ((n) - (m) < EPS)
// #define GE(n,m) ((n) + EPS > (m))
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
// !!! 誤差に注意 !!! (掛け算したものとかなり小さいものを比べているので)
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 点pから円aへの接線の接点
VP tangentPoints(Point a, double ar, Point p) {
  VP ps;
  double sin = ar / abs(p-a);
  if (!LE(sin, 1)) return ps;  // ここでNaNも弾かれる
  double t = PI/2 - asin(min(sin, (double)1.0));
  ps.push_back(                 a + (p-a)*polar(sin, t));
  if (!EQ(sin, 1)) ps.push_back(a + (p-a)*polar(sin, -t));
  return ps;
}

int main(){
    double x,y,theta,w;
    cin >>x >>y >>theta >>w;

    Point p(x,y);
    theta = theta/360*2*PI;
    w = w/360*2*PI;

    p = p*polar(1.0,-theta);
    theta = 0;

    double alpha = acos(p.X/abs(p));
    if(p.Y<0) alpha = 2*PI - alpha;

    bool rev = (p.Y<0);

    double R = abs(p);

    auto valid = [&](double v){
        double r = v/w;
        for(Point tp:tangentPoints(Point(0,0),r,p)){
            double z = acos(tp.X/abs(tp));
            if(tp.Y<0) z = 2*PI - z;

            if(z-alpha>PI){
                if(!rev) continue;
            }
            else if(alpha-z>PI){
                if(rev) continue;
            }
            else{
                if(rev && z-alpha>0) continue;
                if(!rev && z-alpha<0) continue;
            }

            double diff = z;
            if(rev) diff = 2*PI - z;

            double limit_time = diff/w;

            double t = abs(p-tp)/v;
            if(LE(t,limit_time)) return true;
        }
        return false;
    };

    double ng=0, ok=R*w;
    rep(loop,100){
        double mid = (ng+ok)/2;
        if(valid(mid)) ok = mid;
        else ng = mid;
    }
    printf("%.10f\n", ng);
    return 0;
}



Measured memory_bytes: 3652
S = input()

if S[0] != 'A':
    print('WA')
    exit()
elif S[2:-1].count('C') != 1:
    print('WA')
    exit()
else:
    S = S.replace('A', '')
    S = S.replace('C', '')
    if S != S.lower():
        print('WA')
        exit()

print('AC')


Measured memory_bytes: 38512
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <cmath>
using namespace std;

struct point{
    int x, y, alt;
};

int main(){
    int n, h, pos, count = 0;
    point a[100];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i].x >> a[i].y >> a[i].alt;
        if(a[i].alt!=0){
            pos = i;
        }
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            h = a[pos].alt + abs(a[pos].x-i) + abs(a[pos].y-j);
            for(int k=0;k<n;k++){
                if((h-abs(a[k].x-i)-abs(a[k].y-j))==a[k].alt){
                    count ++;
                }
                else if((h-abs(a[k].x-i)-abs(a[k].y-j))<0&&a[k].alt==0){
                    count ++;
                }
            }
            if(count==n){
                cout << i << " " << j << " " << h;
                break;
            }
            count = 0;
        }
        if(count==n){
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
def resolve():
    n = int(input())
    s = list(input() for _ in range(n))
    m = int(input())
    t = list(input() for _ in range(m))
    words = set(s)
    ans = []
    for w in words:
        ans.append(s.count(w) - t.count(w))
    print(max(ans) if max(ans) > 0 else 0)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main() {
	
	string s;
	cin >> s;
	bool ans = false;
	if (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2))ans = true;
	else if (s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1))ans = true;
	else if (s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1))ans = true;

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
def gcd(a,b):
    while b: a,b = b,a%b
    return a

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

def main():
    n=int(input())
    t=1
    for i in range(n):
        t=lcm(int(input()),t)

    print(t)

main()


Measured memory_bytes: 2940
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{
	speed
	int n;cin>>n;
	map<int,int> mp;
	bool bl=1;
	for (int i = 0; i < n; ++i)
	{
		int tmp;cin>>tmp;
		if(mp[tmp]>0){bl=0;}
		++mp[tmp];
	}
	if(bl){cout<<"YES";}
	else{cout<<"NO";}
}

Measured memory_bytes: 12800
function Main(input) {
  var ans = Math.floor(input);
  var flag = true;
  var yesKosu = 1;

  while (flag) {
    var yesLine = 100;
    yesLine *= yesKosu;
    if (ans < yesLine) {
      console.log('0');
      flag = false;
      break;
    }
    if (ans >= yesLine && ans <= yesLine + yesKosu * 5) {
      console.log('1');
      flag = false;
      break;
    }
    yesKosu++;
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  string s; cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
}

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

ans = 0

if n < 9:
    ans = n
elif n >= 9 and n < 100:
    ans = 9
elif n >= 100 and n < 999:
    ans = 9 + (n - 100 + 1)
elif n >= 999 and n < 10000:
    ans = 9 + 900
elif n >= 10000 and n < 99999:
    ans = 9 + 900 + (n - 10000 + 1)
else:
    ans = 9 + 900 + 90000

print(ans)

Measured memory_bytes: 3064
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut a: Vec<Vec<i32>> = (0..h).map(|_| (0..w).map(|_| read()).collect()).collect();

    let mut s = String::new();
    ;
    let mut count = 0;

    for i in 0..h {
        for j in 0..w - 1 {
            if a[i][j] % 2 == 1 {
                a[i][j] -= 1;
                a[i][j + 1] += 1;
                s += &format!("{} {} {} {}\n", i + 1, j + 1, i + 1, j + 2);
                count += 1;
            }
        }
    }
    for i in 0..h - 1 {
        if a[i][w - 1] % 2 == 1 {
            a[i][w - 1] -= 1;
            a[i + 1][w - 1] += 1;
            s += &format!("{} {} {} {}\n", i + 1, w, i + 2, w);
            count += 1;
        }
    }

    println!("{}\n{}", count, s);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 10364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll n,d;

void init(){
	cin>>n>>d;
}

int main(void){
	init();
	cout<<(n+2*d)/(2*d+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

edge = Array.new(n+1) {[]}
m.times do
    u, v = gets.split.map(&:to_i)
    edge[u] << v
end

s, t = gets.split.map(&:to_i)

visit = Array.new(n+1){Array.new(3)}
visit[s][0] = 0
que = [[s, 0]]

while x = que.shift
    now, x = x
    y = (x + 1) % 3

    edge[now].each do |z|
        next if visit[z][y]
        visit[z][y] = visit[now][x] + 1
        que << [z, y]
    end
end

puts visit[t][0] ? visit[t][0] / 3 : -1

Measured memory_bytes: 18428
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

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


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
unsigned long long int iremono[100001], koware[100001];
unsigned long long int iremono2[100001], check[100001],xpo[10000001],ypo[10000001],hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
vector<pair<long long int, long long int>>pairs;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char re;
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
bool qw = false, er = false, ty = false,ui=false;
int main() {
	cin >> a>>b;
	cout << (a * 3 + b) / 2 << endl;
}


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

using namespace std;

const int maxn = 1e5 + 30;

vector<int> adj[maxn];
bool vs[maxn];

int main(){
  int n; cin >> n;
  int m; cin >> m;
  int starta = -1;
  int startb = -1;
  for(int e=0;e<m;e++){
    int a,b; cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    starta = a;
    startb = b;
  }
  int a = starta; int b = startb;
  vs[a] = true;
  vs[b] = true;
  deque<int> ans;
  ans.push_back(a);
  ans.push_back(b);
  while(true){
    int v = ans.back();
    bool success = false;
    for(int u : adj[v]){
      if(vs[u]) continue;
      vs[u] = true;
      ans.push_back(u);
      success = true;
      break;
    }
    if(!success) break;
  }
  while(true){
    int v = ans.front();
    bool success = false;
    for(int u : adj[v]){
      if(vs[u]) continue;
      vs[u] = true;
      ans.push_front(u);
      success = true;
      break;
    }
    if(!success) break;
  }
  cout << ans.size() << "\n";
  for(int e : ans){
    cout << e << " ";
  }
  cout << "\n";
}


Measured memory_bytes: 6784
s = int(input())

def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

a=[]
a.append(s)
for m in range(2,1000001):
    x = f(a[m-2])
    if x in a:
        ans = m
        break
    else:
        a.append(x)

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x = sc.nextDouble();
		double money = 100;
		double answer = 0;
		while(money < x) {
			answer++;
			money = Math.floor(money * ((double)101 /(double)100));
		}

		System.out.println((int)answer);
	}
}

Measured memory_bytes: 28912
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N;
    cin >> N;
    string s;
    cin >> s;
    rep(i, s.size()){
        char c = s[i];
        rep(j, N){
            if(c == 'Z')c = 'A';
            else c++;
        }
        cout << c;
    }
    cout << endl;

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >>C >>D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
  	cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

int main() {
  int N, l, r, sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


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


int main() {
  string S;
  cin >> S;
  long l = S.size();
  long sum = 0;
  for (long tmp = 0; tmp < (1 << (l - 1)); tmp++) {
    long t;
    t = S.at(0) - '0';
    for (long i = 0; i < l - 1  ; i++) {
      if ((tmp >>  l - 1 - i - 1 ) & 1) {        
        sum += t;
        t = S.at(i + 1) - '0';
        
      }
      else {
        t = t*10;
        t += S.at(i + 1) - '0';

        
      }
    }
    sum += t;
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k, n; cin >> k >> n;
    cout << n + (k < 10 ? 100 * (10 - k) : 0) << "\n";
    return 0;
}

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

int main(void){
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	for(int i = 0; i < n; ++i){
		int a;
		cin >> a;
		q.push(a);
	}
	for(int i = 0; i < m; ++i){
		int a = q.top();
		q.pop();
		q.push(a/2);
	}
	long long ans = 0;
	for(int i = 0; i < n; ++i){
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

/*

ABC136E

Author : AyumuKasuga

Greedy, Number Theory

*/

#define MXN 505
int N;
ll K;
ll A[MXN], S;
vector<ll> F;
ll AM[MXN];
ll ps[MXN];

ll chk(ll G)
{
    ll SM=0;
    ll rtn=(1LL<<60);
    FOR(i,1,N)
    {
        AM[i]=A[i]%G;
        SM+=AM[i];
    }
    sort( AM+1,AM+N+1 );
    rtn=G*N-SM;
    ll cur=0;
    FOR(i,1,N)
    {
        cur+=AM[i];
        rtn=min( rtn, max(cur, G*(N-i)-(SM-cur)) );
    }
    return rtn;
}

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

    cin>>N>>K;
    FOR(i,1,N)
    {
        cin>>A[i];
        S+=A[i];
    }
    for(ll i = 1; i*i<=S; i++)
    {
        if( S%i==0 )
        {
            F.pb(i);
            ll j = S/i;
            if(i!=j)F.pb(j);
        }
    }
    sort(ALL(F),greater<ll>());
    int fs = SZ(F);
    FOR(i,0,fs-1)
    {
        if( chk(F[i])<=K )
        {
            cout<<F[i]<<'\n';
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque
K = int(input())
if K <= 9: ans = K
cnt = 9
dq = deque(list(range(1, 10)))

while cnt <= K:
    d = dq.popleft()
    for i in [-1, 0, 1]:
        if d % 10 == 0 and i == -1:continue
        if d % 10 == 9 and i == 1:continue
        dq.append(d * 10 + d % 10 + i)
        cnt += 1
        if cnt == K:
            ans = d * 10 + d % 10 + i
            break
        
print(ans)

Measured memory_bytes: 6056
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	long T, X;
	cin >> T >> X;

	double ans = 0.0;
	ans = (double)T / (double)X;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

bool rev(const int &a, const int &b){
    return (a > b);
}

int X,Y,A,B,C;
const int maxabc = 100001;
int p[maxabc],q[maxabc],r[maxabc];

int main(){
    cin >> X >> Y >> A >> B >> C;
    rep(i,A)cin >>p[i];
    rep(i,B)cin >> q[i];
    rep(i,C)cin >> r[i];
    sort(p, p+A, rev);
    sort(q, q+B, rev);
    sort(r, r+C, rev);
    deque<int> d1;
    vector<int> v(0);
    rep(i,X){
        v.push_back(p[i]);
    }
    rep(i,Y){
        v.push_back(q[i]);
    }
    
    sort(v.begin(),v.end());

    rep(i,v.size()) {
        d1.push_back(v[i]);
    }

    rep(i,C) {
        if(d1.front() < r[i]){
            d1.pop_front();
            d1.push_back(r[i]);
        } else {
            break;
        }
    }

    ll ans = 0;
    int len = (int)d1.size();
    rep(i,len) {
        ans += d1.front();
        d1.pop_front();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5960
q = int(raw_input())
for _ in xrange(q):
  x0,y0,x1,y1,x2,y2,x3,y3 = map(float, raw_input().split())
  ta = (x2 - x3) * (y0 - y2) + (y2 - y3) * (x2 - x0)
  tb = (x2 - x3) * (y1 - y2) + (y2 - y3) * (x2 - x1)
  tc = (x0 - x1) * (y2 - y0) + (y0 - y1) * (x0 - x2)
  td = (x0 - x1) * (y3 - y0) + (y0 - y1) * (x0 - x3)

  if tc * td <= 0 and ta * tb <= 0:
    if tc * td == 0 and ta * tb == 0:
      outer1 = (x2 - x0) * (x2 - x1) + (y2 - y0) * (y2 - y1)
      outer2 = (x3 - x0) * (x3 - x1) + (y3 - y0) * (y3 - y1)
      outer3 = (x0 - x2) * (x0 - x3) + (y0 - y2) * (y0 - y3)
      outer4 = (x1 - x2) * (x1 - x3) + (y1 - y2) * (y1 - y3)
      if outer1 <= 0 or outer2 <= 0 or outer3 <= 0 or outer4 <= 0:
        print 1
      else:
        print 0
    else:
      print 1
  else:
    print 0

Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,a[3500],dp[3050][3050][3],sum;
long long f(int l,int r,int ran)
{
    if(l>r)return 0;
    if(dp[l][r][ran]!=-1)return dp[l][r][ran];
    long long mx;
    if(ran==0)
    {
        mx=0;
        mx=max(f(l,r-1,1)+a[r],f(l+1,r,1)+a[l]);
    }
    else
    {
        mx=1e18;
        mx=min(f(l,r-1,0)-a[r],f(l+1,r,0)-a[l]);
    }
    return dp[l][r][ran]=mx;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    cout<<f(0,n-1,0);
}


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

int main() {
	
	int r,c,i,j,sum,SUM;
	int A[100][100];

	cin>>r>>c;
	
	for( i=0 ; i<r ; i++){
		sum=0;
		for( j=0 ; j<c ; j++){
			cin>>A[i][j];
			sum=sum+A[i][j];
			cout<<A[i][j]<<" ";
		}
		cout<<sum<<endl;
		SUM+=sum;
	}
	
	for( j=0 ; j<c ; j++){
		sum=0;
		for( i=0 ; i<r ; i++){
			
			sum=sum+A[i][j];
			
		}
		cout<<sum<<" ";
	}
	cout<<SUM<<endl;
	
	return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;

    int x=__gcd(n,m);
    int N=n/x,M=m/x;
    for (int i=0;i<x;i++)
        if (s[N*i]!=t[M*i]) return cout<<-1<<endl,0;
    cout<<n*1ll*m/__gcd(n,m)<<endl;
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define zad tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld%lld",&x,&y)
#define in3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define out(x) printf("%lld",x)
#define outspace(x) printf("%lld ",x)
#define outln(x) printf("%lld\n",x)
#define ll long long
#define ld long double
#define pb push_back
#define p push
#define mkp make_pair
#define ff first
#define PLL pair<ll,ll>
#define PSS pair<string,string>
#define ss second
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> >
#define all(x) x.begin(),x.end()
#define F(i,a,b) for(ll i=a;i<b;i++)
#define RF(i,a,b) for(ll i=a;i>b;i--)
#define mset(a,b) memset((a),(b),sizeof((a)))
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007
#define RMOD 998244353
#define INF 10000000000000000
#define MINF LONG_LONG_MIN
#define MAXF LONG_LONG_MAX
const ll N=200007;
#define OuterLoop ll t;scanf("%lld",&t);while(t--)
#define lcm(a,b) a*b/(__gcd(a,b))
//v =  vector< vector<ll> >(n+1);
//v.assign(n+1,vector<ll>()); this way we can assign anything.
bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i+=6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}
ll n,k;
vector<ll> v;
vector<ll> dp(N,-1);

ll dynamic(ll src)
{
    if(dp[src]!=-1) return dp[src];
    if(src>=n) return dp[src]=0;
    ll cnt=N,cnt1;
    cnt = abs(v[src]-v[src+1])+dynamic(src+1);
    for(ll i=2;i<=k;i++)
    {
        if(src+i<=n) cnt=min(cnt,abs(v[src]-v[src+i])+dynamic(src+i));
    }
    
    //cout << src << "--" << cnt << "--" << cnt1 << "\n";
    return dp[src]=cnt;
}

int main()
{  
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
      cin >> n >> k;
      v = vector<ll>(n+1);
      for(ll i=1;i<=n;i++) cin>>v[i];
    }
    cout << dynamic(1);
    //for(ll i=1;i<=n;i++) cout<<dp[i]<<" ";
}

Measured memory_bytes: 11904
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N, K;
    cin >> N >> K;
    cout << (N % K == 0 ? 0 : 1) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3544
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
multiset<ll> r;
multiset<ll> g;
cin>>x>>y>>a>>b>>c;
for(int i=0;i<a;i++)
{
    cin>>temp;
    r.insert(temp);
}
for(int i=0;i<b;i++)
{
    cin>>temp;
    g.insert(temp);
}
while(r.size()>x)
r.erase(r.begin());
while(g.size()>y)
g.erase(g.begin());
while(g.size())
{r.insert(*g.begin());
g.erase(g.begin());}
for(int i=0;i<c;i++)
{cin>>temp;
r.insert(temp);}
ll ans=0;
vector<ll> ansv;
while(r.size())
{
    ansv.pb(*r.begin());
    r.erase(r.begin());
}
sort(ansv.begin(),ansv.end(),greater<>());
for(int i=0;i<x+y;i++)
ans+=ansv[i];
cout<<ans;
return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 19060
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll K, A, B;
	cin >> K >> A >> B;

	auto ans = 0ll;
	if (A + 2 < B && K >= A + 1)
	{
		ans = A;
		K -= A - 1;
		ans += (K / 2) * (B - A);
		if (K % 2 > 0)
		{
			++ans;
		}
	}
	else
	{
		ans = K + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    queue<pair<int, short> > que;
    short full = 0;
    for (int i = 0; i < n; i++) {
        full <<= 1;
        full |= 1;
    }
    unordered_map<int, vector<int> > mp;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        mp[a].push_back(b);
        mp[b].push_back(a);
        if (a == 0) {
            que.push(pair<int, short>(b, 1));
        }
    }

    int count = 0;
    while (!que.empty()) {
        pair<int, short> p = que.front();
        que.pop();
        short now = p.second;
        short next = (1 << p.first) | now;
        if (next == full) {
            count++;
        } else if (next != now) {
            for (int x: mp[p.first]) {
                que.push(pair<int, short>(x, next));
            }
        }
    }
    cout << count << endl;
    return 0;
}


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

int main(void){
    int N,M;
    cin >> N >> M;
    vector<bool> vec(N,false);
    vector<int> pe(N,0);

    int an=0,pn=0;
    for(int i=0;i<M;i++){
        int p; string s;
        cin >> p >> s;
        if(!vec[p-1]){
            if(s=="AC"){
                vec[p-1] = true;
                an++;
            }else{
                pe[p-1]++;
            }
        }
    }

    for(int i=0;i<N;i++) if(vec[i]) pn += pe[i];
    cout << an << " " << pn << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int n = 0;
    cin >> n;
    int a = 0;
    bool flag = true;

    for(int i = 0;i < n;i++){
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                flag = false;
                break;
            }
        }
    }

    if(flag){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

			int i;

			String str = sc.nextLine();

			char chArray[] = new char[str.length()];

			for(i = 0; i < str.length(); i++) {

				chArray[i] = str.charAt(i);

			}

			for(i = 0; i < str.length(); i++) {

				if(Character.isUpperCase(chArray[i])) {

					chArray[i] = Character.toLowerCase(chArray[i]);

				} else if(Character.isLowerCase(chArray[i])) {

					chArray[i] = Character.toUpperCase(chArray[i]);

				}

			}

			for(i = 0; i < str.length(); i++) {

				System.out.print(chArray[i]);

			}
			System.out.println();

	}
}

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

bool p[1000001];

void sieve(){
    for(int i=0;i<1000001;i++)p[i] = true;
    p[0] = p[1] = false;
    for(int i=2;i<1000001;i++){
        if(p[i]){
            for(int j=2*i;j<1000001;j+=i)p[j] = false;
        }
    }
}

int main(){
    int n, x;
    sieve();

    while(1){
        cin>>n>>x;
        if(!n && !x)break;
        bool dp[1000001]= {false};
        int dish[31];
        for(int i=0;i<n;i++){
            cin>>dish[i];
            dp[dish[i]] = true;
        }
    
        for(int i=0;i<n;i++){
            for(int j=0;j<=1000000;j++){
                if(dp[j] && j+dish[i] <= 1000000)
                    dp[j+dish[i]] = true;
            }
        }
    
        int max=0;
        for(int i=0;i<=x;i++){
            if(dp[i] && p[i])max = i;
        }

        if(max) cout<<max<<endl;
        else cout<<"NA"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3120