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

int findMinCost(vector < int > &heights, int n, vector < int > &dp) {
  if (n < 2) {
    return 0;
  }

  if (dp[n] != -1) {
    return dp[n];
  }

  int minCost = INT_MAX;

  if (n > 1) {
    minCost = min((abs(heights[n - 1] - heights[n - 2]) + findMinCost(heights, n - 1, dp)), minCost);
  }

  if (n > 2) {
    minCost = min((abs(heights[n - 1] - heights[n - 3]) + findMinCost(heights, n - 2, dp)), minCost);
  }

  dp[n] = minCost;
  return dp[n];
}

int minCost(vector < int > &heights) {
  int n = heights.size();
  vector < int > dp(n + 1, -1);
  dp[0] = 0;

  return findMinCost(heights, n, dp);
}

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

  cout<<minCost(heights)<<endl;

  return 0;
}


Measured memory_bytes: 11884
//
    //  main.cpp
    //  study_c++
    //
    //  Created by Hisaki Kobayashi on 2020/03/31.
    //  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
    //

    #include <iostream>
    #include <stdio.h>
    #include <string>
//    #include <bits/stdc++.h>
#include <bits/stdc++.h>

    using namespace std;

    int main(int argc, const char * argv[]) {
        long long A,B,C,X,Y;
        cin >> A >> B >> C >> X >> Y;
        long long k;
        long long sum=10000000000000,temp=0;
        for(k=0;k<=max(X,Y);k++){
            temp = 2*k*C +max(0LL,(X-k))*A +max(0LL,Y-k)*B;
            sum = min(sum,temp);
        }
        cout << sum << endl;

    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> adj[100005];


int main()
{
    int n;
    cin>>n;
    
    int h[n+1];
    for (int i = 1; i<=n; i++)
        cin>>h[i];
        
    int dp[n+1];
    memset (dp, 0, sizeof(dp));
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    
    int sum = 0;
    
    for (int i = 3; i<=n; i++)
    {
        dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n];
    
    return 0;
}


Measured memory_bytes: 3328
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n:usize,a:[usize;n]}

    use std::collections::HashMap;

    let mut l = HashMap::<isize, usize>::new();
    let mut r = HashMap::<isize, usize>::new();

    for i in 0..n as isize {
        *(l.entry(i - a[i as usize] as isize).or_insert(0)) += 1;
        *(r.entry(i + a[i as usize] as isize).or_insert(0)) += 1;
    }

    let mut count = 0;
    for (key, val) in l.iter() {
        count += val * r.get(key).unwrap_or(&0);
    }

    println!("{}", count);
}


Measured memory_bytes: 16040
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int ketahikaku(string n){
   bool flg = 0;
   if((n[2] == n[1]) && (n[1] == n[0])) flg = 1; 
   return flg;
}

int main(){
   int n;
   cin >> n;
   for(int i = n;i<=999;i++){
      string n_num = to_string(i);
   if( ketahikaku(n_num)) {
      cout << i << endl;
      break;
      }
   }

   return 0;
}

Measured memory_bytes: 256
//#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, s.length()) {  //足し算でやっていけばよい
    int x = s[i] - 'A';
    x = (x + n) % 26;
    putchar('A' + x);
  }

  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0
def f(x):
    b=0
    for i in a:
        b+=(x-i)**2
    return b
if sum(a)%n==0:
    ans=f(sum(a)//n)
else:
    ans=f(round(sum(a)/n))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(void){
    int n,m;
    int a,b;
    set<int> f,e;
    cin>>n>>m;

    rep(i,m){
        cin>>a>>b;
        if(a == 1)f.insert(b);
        if(b == n)e.insert(a);
    }
    bool c = false;

    rep(i,n-1){
        //cout<<i<<"> "<<(f.find(i+1) != f.end())<<" "<<(e.find(i+1) != e.end())<<endl;
        c = c || (f.find(i+1) != f.end() && e.find(i+1) != e.end());
    }
    cout<<(c?"POSSIBLE":"IMPOSSIBLE")<<endl;


}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n;
	cin >> n;
	if(n%2==1) cout << n*2 << endl;
	else cout << n << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    int c = Integer.parseInt(a + b);
    for(int i = 1; i * i < 100101; i++) {
      if(c == i * i) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}



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

bool dfs(vector<vector<pair<int, long long>>>& Tree, vector<long long>& X, vector<int>& Visited, int now) {
	bool ans = true;
	for (auto p : Tree[now]) {
		int v = p.first, d = p.second;
		if (Visited[v]) {
			ans &= (X[v] == X[now] + d);
			continue;
		}
		Visited[v] = 1;
		X[v] = X[now] + d;
		ans &= dfs(Tree, X, Visited, v);
	}
	return ans;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<pair<int, long long>>> Tree(N);
	for (int i = 0; i < M; i++) {
		int L, R;
		long long D;
		cin >> L >> R >> D;
		Tree[L - 1].push_back({ R - 1,D });
		Tree[R - 1].push_back({ L - 1,-D });
	}
	vector<int> Visited(N);
	vector<long long> X(N);
	int now = 0;
	bool IsOK = true;
	while (now < N) {
		Visited[now] = 1;
		IsOK = dfs(Tree, X, Visited, now);
		if (!IsOK) break;
		while (now < N && Visited[now]) now++;
	}
	if (!IsOK) {
		cout << "No" << endl;
		return 0;
	}
	long long MIN = 1000000000ll, MAX = 0ll;
	for (long long x : X) {
		MIN = min(MIN, x);
		MAX = max(MAX, x);
	}
	cout << (MAX - MIN < 1000000000ll ? "Yes" : "No") << endl;
}


Measured memory_bytes: 21724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max({a * c, a * d, b * c, b * d});
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll mx = max({a*c, a*d, b*c, b*d});

    if (a <= 0 && 0 <= b) mx = max(mx, 0LL);
    if (c <= 0 && 0 <= d) mx = max(mx, 0LL);
    cout << mx << '\n';
}


Measured memory_bytes: 3648
n = int(input())
li = list(map(int,input().split()))

liodd = li[::2]
lieven = li[1::2]
if len(lieven) == len(liodd):
  for i in reversed(lieven):
    print(i,end=" ")
  for i in liodd:
    print(i,end=" ")
else:
  for i in reversed(liodd):
    print(i,end=" ")
  for i in lieven:
    print(i,end=" ")

Measured memory_bytes: 26180
void main() {
    int[] tmp = readln.split.to!(int[]);
    int x = tmp[0], a = tmp[1], b = tmp[2];
    if (a - b >= 0) {
        "delicious".writeln;
    } else if (a - b + x >= 0) {
        "safe".writeln;
    } else {
        "dangerous".writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <stdio.h>
int p[92][92],ans;
void step(int x,int y,int n){
    p[x][y]=0;
    if (n>ans) {
        ans=n;
    }
    if (p[x+1][y]==1) {
        step(x+1, y,n+1);
    }
    if (p[x-1][y]==1) {
        step(x-1, y,n+1);
    }
    if (p[x][y+1]==1) {
        step(x, y+1,n+1);
    }
    if (p[x][y-1]==1) {
        step(x, y-1,n+1);
    }
    p[x][y]=1;
}
int main(){
    while (1) {
        int m,n;
        scanf("%d%d",&m,&n);
        if (m==0&&n==0) {
            return 0;
        }
        int i,j;
        ans=0;
        for (i=0; i<n+2; i++) {
            for (j=0; j<m+2; j++) {
                if (i==0||j==0||i==n+1||j==m+1) {
                    p[j][i]=0;
                }else{
                    scanf("%d",&p[j][i]);
                }
            }
        }
        for (i=1; i<=n; i++) {
            for (j=1; j<=m; j++) {
                if (p[j][i]==1) {
                    step(j,i,1);
                }
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 628
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;
typedef pair<double, double> Point;
/** Problem0079 : Area of Polygon **/
int main()
{
	vector<Point> points;
	double x, y; char c;
	while (cin>>x>>c>>y) {
		points.push_back(Point(x, y));
	}
	points.push_back(Point(points[0].first, points[0].second));
					
	double S=0;
	for (int i=0; i<points.size(); i++) {
		S += fabs(points[i].first*points[i+1].second - points[i+1].first*points[i].second);
	}
	printf("%.6f\n", S/2);
}

Measured memory_bytes: 1244
from bisect import bisect_left

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
for i in range(q):
    idx = bisect_left(S, T[i])
    if idx == n:
        continue
    if S[idx] == T[i]:
        cnt += 1
print(cnt)


Measured memory_bytes: 16736
# solution
import io

nim, mike = [int(_) for _ in input().split()]
WV = [[int(_) for _ in input().split()] for _ in range(nim)]
qwe = {}
qwe[0] = 0
for weight, value in WV:
    dp_old = qwe.copy()
    for k, v in dp_old.items():
        if k + weight <= mike:
            qwe[k + weight] = max(qwe.get(k + weight, 0), v + value)
ans = 0
for k, v in qwe.items():
    ans = max(ans, v)
print(ans)


Measured memory_bytes: 3716
#include <stdio.h>

int main(int argc, char** argv)
{
	int W, H, x, y, r;
	int num[3];

	scanf("%d", &W);
	scanf("%d", &H);
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &r);

	if ((x >= r && x <= W - r) && (y >= r && y <= H - r)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
use std::io::Read;


fn main(){
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    s.pop();

    match s.as_str() {
        "Sunny" => println!("Cloudy"),
        "Cloudy" => println!("Rainy"),
        "Rainy" => println!("Sunny"),
        _ => (),
    }
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc065/tasks/arc076_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

using ti = tuple<int, int, int>;

// グラフ用のテンプレート
// https://ei1333.github.io/luzhiled/snippets/graph/template.html
template <typename T> struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

// 素集合データ構造(Union-Find)
// https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) { return (-data[find(k)]); }
};

// 最小全域木(Kruskal)
// https://ei1333.github.io/luzhiled/snippets/graph/kruskal.html
template <typename T> T kruskal(Edges<T> &edges, int V) {
    sort(begin(edges), end(edges),
         [](const edge<T> &a, const edge<T> &b) { return (a.cost < b.cost); });
    UnionFind tree(V);
    T ret = 0;
    for (auto &e : edges) {
        if (tree.unite(e.src, e.to))
            ret += e.cost;
    }
    return (ret);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ti> A(N);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        A[i] = tie(i, a, b);
    }
    Edges<int> edges;

    // X座標が小さい順に辺を繋げる
    sort(ALL(A), [](const ti &a, const ti &b) {
        // X座標で昇順ソート
        return get<1>(a) < get<1>(b);
    });
    REP(i, N - 1) {
        int from_id, from_x, from_y, to_id, to_x, to_y;
        tie(from_id, from_x, from_y) = A[i];
        tie(to_id, to_x, to_y) = A[i + 1];
        edges.emplace_back(from_id, to_id, to_x - from_x);
    }

    // Y座標が小さい順に辺を繋げる
    sort(ALL(A), [](const ti &a, const ti &b) {
        // Y座標で昇順ソート
        return get<2>(a) < get<2>(b);
    });
    REP(i, N - 1) {
        int from_id, from_x, from_y, to_id, to_x, to_y;
        tie(from_id, from_x, from_y) = A[i];
        tie(to_id, to_x, to_y) = A[i + 1];
        edges.emplace_back(from_id, to_id, to_y - from_y);
    }
    // 最小全域木を求める
    cout << kruskal(edges, N) << endl;

    return 0;
}


Measured memory_bytes: 11828
N=int(input())
R=[[int(i) for i in input().split()] for i in range(N)]
B=[[int(i) for i in input().split()] for i in range(N)]
List=[[] for i in range(N)]
count=[0]*N
unpaired=[True]*N

for i,r in enumerate(R):
  for j,b in enumerate(B):
    if b[0]>r[0] and b[1]>r[1]:
      List[i].append(j)
      count[j]+=1    
List.sort(key=lambda x:len(x))

ans=0
for l in List:
  k=float("inf")
  p=-1
  for j in l:
    if unpaired[j]:
      if k>count[j]:
        k=count[j]
        p=j
      count[j]-=1
  if p>=0:
    ans+=1
    unpaired[p]=False
print(ans)
  

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
typedef long long ll;

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

    ll ans;
    if (K%2) {
        ll odd = N/K;
        ans = odd*odd*odd;
    } else {
        ll odd = (N + K/2)/K ;
        ll even = N/K;
        ans = odd*odd*odd + even*even*even;
    }

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

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

using namespace std;


int a, b ,a_ , b_;

int c[13] = { 2,3,4,5,6,7,8,9,10,11,12,13,1 };



int main()
{
	cin >> a >> b;

	for (int i = 0;i < 13 ;i++)
	{
		if (c[i] == a)
		{
			a_ = i;
		}
		if (c[i] == b)
		{
			b_ = i;
		}
	}
	if (a_ < b_)
	{
		cout << "Bob" << endl;
	}
	else if (a_ > b_)
	{
		cout << "Alice" << endl;
	}
	else
	{
		cout << "Draw" << endl;
	}



	//system("pause");

}


Measured memory_bytes: 256
import bisect
import sys


N = int(input())
a = list(map(int, input().split()))
to = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)
del u, v

ans = [-1] * N


def dfs(v, dp):
    # dp は参照渡し
    if len(dp) == 0 or a[v] > dp[-1]:
        dp.append(a[v])
        back = -1
    else:
        pos = bisect.bisect_left(dp, a[v])
        back = dp[pos]
        dp[pos] = a[v]
    ans[v] = len(dp)

    for u in to[v]:
        if ans[u] == -1:
            dfs(u, dp)
    if back == -1:
        dp.pop()
    else:
        dp[pos] = back


sys.setrecursionlimit(10 ** 6)
dfs(0, [])


for an in ans:
    print(an)


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

int main(){
  int count = 0;
  string W,T;
  
  cin >> W;
  while(1){
    cin >> T;
    if(T == "END_OF_TEXT") break;
    transform(T.begin(), T.end(), T.begin(), ::tolower);
    if(W == T) count++;
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace  std;

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }
  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }

  ~StPnt() { }
};

void fnInput(int &rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv( const StPnt &cnroPnt1, const StPnt &cnroPnt2, vector<StPnt> &rvoRtnPnt)
{
  rvoRtnPnt[0] = cnroPnt1;
  rvoRtnPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  rvoRtnPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  rvoRtnPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  rvoRtnPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  rvoRtnPnt[2].m_nx =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * cos(M_PI / 3) 
                     - (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * sin(M_PI / 3);
  rvoRtnPnt[2].m_nx += rvoRtnPnt[1].m_nx;
  rvoRtnPnt[2].m_ny =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * sin(M_PI / 3)
                     + (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * cos(M_PI / 3);
  rvoRtnPnt[2].m_ny += rvoRtnPnt[1].m_ny;

  rvoRtnPnt[4] = cnroPnt2;
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>> &rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(7);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt(5);

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>> &cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

Measured memory_bytes: 1392
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
use ordered_float::NotNan;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn solve(a: &Vec<usize>, k: usize, x: f64) -> bool {
    let mut cut = 0;
    for &a in a.iter() {
        cut += (a as f64 / x - 1.0).ceil() as usize;
    }
    k >= cut
}

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let a = sc.read_vec::<usize>(n);

    let mut ng = 0.0;
    let mut ok = 1e10;
    for _ in 0..100 {
        let x = (ng + ok) / 2.0;
        if solve(&a, k, x) {
            ok = x;
        } else {
            ng = x;
        }
    }
    println!("{}", ((ok + ng) / 2.0).ceil() as usize);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 3048
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define rr int
using namespace std;
typedef long long ll;
inline ll read() {
    char i = getchar();
    ll f = 1, res = 0;
    while (i < '0' || i > '9') {
        if (i == '-') f = -1;
        i = getchar();
    }
    while (i >= '0' && i <= '9') {
        res = res * 10 + i - '0';
        i = getchar();
    }
    return f * res;
}
int n /*n个商店*/, m /*d∈[1,m]*/;
const int N = 3e5 + 50;
struct zk {
    int l, r, len;
    bool operator<(const zk &A) const { return len < A.len; }
} a[N];
struct bittree {
    int c[N];
    inline int lowbit(int x) {
        return x & (-x);
    }
    inline void add(int pos, int x) {
        while (pos < N) {
            c[pos] += x;
            pos += lowbit(pos); 
        }
    }
    inline int sum(int pos) {
        int res = 0;
        while (pos > 0) {
            res += c[pos];
            pos -= lowbit(pos);
        }
        return res;
    }
    inline int query(int d) {
        int res = 0;
        int now = d;
        while (now <= m) {
            res += sum(now);
            now += d;
        }
        return res;
    }
} C;
int main() {
    n = read(), m = read();
    for (rr i = 1; i <= n; ++i) {
        a[i].l = read();
        a[i].r = read();
        a[i].len = (a[i].r - a[i].l + 1);
    }
    sort(a + 1, a + 1 + n);
    int now = 0;
    for (rr d = 1; d <= m; ++d) {
        while (a[now + 1].len < d && now < n) {
            ++now;
            C.add(a[now].l, 1);
            C.add(a[now].r + 1, -1);
        }
        int ans = (n - now);
        ans += C.query(d);
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int main(){
    int m, f, r;

    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1)
            break;
        int sum = m + f;
        if(m == -1 || f == -1){
            cout << "F" << endl;
        }else if(sum >= 80){
            cout << "A" << endl;
        }else if(sum >= 65 && sum < 80){
            cout << "B" << endl;
        }else if((sum >= 50 && sum < 65) || (sum >= 30 && sum < 50 && r >= 50)){
            cout << "C" << endl;
        }else if(sum >= 30 && sum < 50){
            cout << "D" << endl;
        }else{
            cout << "F" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3088
import math
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
opr = sum(B)-sum(A)
cnt = 0
for i in range(N):
    if(B[i]>A[i]):
        cnt += math.ceil((B[i]-A[i])/2)
if(cnt>opr):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 4596
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char str1[] = sc.next().toCharArray();
        char str2[] = sc.next().toCharArray();
        int dp[][] = new int[str1.length+1][str2.length+1];
        for( int i = 1 ; i <= str1.length ; i++ ){
            for( int j = 1 ; j <= str2.length ; j++ ){
                if ( str1[i-1] == str2[j-1] ){
                    dp[i][j] = 1 + dp[i-1][j-1];
                } else {
                    dp[i][j]  = Math.max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
              int i = str1.length , j = str2.length;
        StringBuffer ans = new StringBuffer("");
        while(i>0 && j>0){
            if(dp[i-1][j] == dp[i][j]){
                i--;
                continue;
            } else {
                if(dp[i][j-1] == dp[i][j]){
                    j--;
                    continue;
                }
                if(dp[i][j] == 1+dp[i-1][j-1]){
                    ans.append(str1[i-1]);
                    i--;
                    j--;
                }
            }
        }
        System.out.println(ans.reverse().toString());
    }
}

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

int main() {
	int repeat;
	cin >> repeat;
	int num;
	int total=0;
	int max=0;
	int old=0;

	while (repeat--) {
		cin >> num;
		old = max;
		
		if (num >= max) {
			max = num;
		}
		if (old!=max) {
			total += old;
		}
		else {
			total+=num;
		}
		
	}

	if (max<total) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    vector<ll> A(N+2);
    REPS(i,N){
        cin >>A.at(i);
    }

    A.at(0) = 0;
    A.at(N + 1) = 0;

    vector<ll> t1(N+1);
    ll sum = 0;
    REP(i, N + 1)
    {
        t1.at(i) = abs(A.at(i) - A.at(i + 1));
        sum += t1.at(i);
    }

    vector<ll> t2(N);
    REP(i,N){
        t2.at(i) = abs(A.at(i) - A.at(i + 2));
    }

    REPS(i,N){
        cout << sum - t1.at(i - 1) - t1.at(i) + t2.at(i - 1) << endl;
    }
}


Measured memory_bytes: 5448
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M,A[1000],i,j,k;

double R;

int main()
{
cin>> R;

R*=2.*3.14159265;

cout <<R;





}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end());

const int MOD = 1000000007;
const int INF = INT_MAX;



int main()
{

    int c[3][3];
    for (int i=0; i < 3; i++){
        for (int j=0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    int flag = 0;
    for (int i=0; i <= 100; i++){
        for (int j=0; j <= 100; j++){
            for (int k=0; k <= 100; k++){
                if (c[0][0]-i == c[1][0]-j && c[1][0]-j == c[2][0]-k &&
                    c[0][1]-i == c[1][1]-j && c[1][1]-j == c[2][1]-k &&
                    c[0][2]-i == c[1][2]-j && c[1][2]-j == c[2][2]-k){
                        flag = 1;
                        break;
                    }
            }
        }
    }

    if (flag == 0){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }


    



    return 0;
}




//              g++ -std=c++1z  

Measured memory_bytes: 256
s = input()
S = len(s)
k = int(input())

se = set()

def string(now,num):
    if now+num == s or num == k:
        return
    se.add(s[now:now+num+1])
    num += 1
    return string(now,num)

for i in range(S):
    string(i,0)

se = list(se)
se.sort()

print(se[k-1])

Measured memory_bytes: 4464
import sys
input = sys.stdin.readline

s=input().split()
s=list(s[0])
length=len(s)
ans=0
for i in range(length):
    cnt=0
    for j in range(i, length):
        if s[j]=="A"or s[j]=="C"or s[j]=="G"or s[j]=="T":
            cnt+=1
        else:
            break
        ans=max(ans,cnt)
#ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 38256
import math
N,M,K=map(int,input().split())
mod=998244353
ans=0
d=[1]+[1]
e=[0]+[1]
f=[0]+[1]

for i in range(2,N+1):
  d += [d[i-1]*i%mod]
  e += [ e[mod % i] * (mod - int(mod / i)) % mod]
  f += [ f[i-1]*e[i]%mod]
def combinations_count(n, r):
  if r==n or r==0:
    return 1
  return d[n] * f[n-r] * f[r]%mod

for i in range(K+1):
  l=M*pow(M-1,N-1-i,mod)%mod
  ans+=l*combinations_count(N-1,i)%mod
  ans%=mod
print(ans)

Measured memory_bytes: 95880
#include <iostream>
#include <map>
#include <vector>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <queue>

using namespace std;
#define int long long
#define double long double
#define LINF ~(1LL<<63)
#define fst first
#define snd second
#define fr(s,n,i) for(int i=s;i<n;i++)
#define fr_(s,n,i) for(int i=s;i>=n;i--)
#define srt(v) sort(v.begin(), v.end());
#define rev(v) reverse(v.begin(), v.end());
#define upr(v, aim, ind) int ind; ind=(int)distance(v.begin(), upper_bound(v.begin(),v.end(), aim));
#define sz(v) (int)v.size()
#define ers(v, i) v.erase(v.begin() + i)
#define last(v) v[sz(v) - 1]
#define swp(v, i, j) int buf = v[j]; v[j] = v[i]; v[i] = buf;
#define shout(a) cout << a << endl;
#define dshout(a) printf("%.16Lf\n", a);
#define pr pair<int, int>
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vd vector<double>
#define vdd vector<vd>
#define mx(a, b) a = max(a, b);
#define mn(a, b) a = min(a, b);
#define mulM(a,b,c) a = a * b % c;
#define squM(a,b) a = a * a % b;
#define mpr(a,b) make_pair(a,b);
#define iinp(a) int a; cin >> a;
#define sinp(a) string a; cin >> a;
#define dinp(a) double a; cin >> a;
#define ios() ios_base::sync_with_stdio(0);cin.tie(0);

int MOD = 1000000007;

int powM(int base, int exp){
    int ret = 1;
    int buf = base;
    while(exp > 0){
        if(exp & 1){
            ret *= buf;
        }
        squM(buf, MOD)
        exp >>= 1;
    }
    return ret;
}
int combM(int a, int b){
    if(b == 0){
        return 1;
    }
    if(a-b < b){
        return combM(a, a-b);
    }
    int ans = 1;
    fr(1,b+1,i){
        ans *= a + 1 - i;
        ans /= i;
    }
    return ans;
}
void solve();
signed main() {
    ios()
    solve();
    return 0;
}






int cntCost(int left, int right){
  if(right < 0){
    return cntCost(abs(right), abs(left));
  } else if(left >= 0){
    return (right+left)*(right-left+1) / 2;
  } else {
    return cntCost(0, abs(left)) + cntCost(0,right);
  }
}
void solve(){
  iinp(K)iinp(S)
  if(S > K*3){
    shout(0)
  }
  int cnt = 0;
  fr(0,K+1,i){
    fr(0,K+1,j){
      if(S - i - j <= K && S >= i+ j){
        cnt++;
      }
    }
  }
  shout(cnt)
}



Measured memory_bytes: 256
import itertools
import collections
import math

n,m = map(int,input().split())
a = list(map(int,input().split()))
ac = [0]
ac += list(itertools.accumulate(a))

re = [i % m for i in ac]
c = collections.Counter(re)

ans = 0
for v in c.values():
    if v >= 2:
        ans += (math.factorial(v)//math.factorial(v-2))//(math.factorial(2))
print(ans)

Measured memory_bytes: 18856
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
class RMQ {
#define RMQ_MAX ((1ll<<60)-1)
public:
	RMQ(int n) {
		_n=1;
		while(_n<n) _n*=2;
		_dat.resize(2*_n-1);
		for(int i=0;i<2*_n-1;++i) _dat[i]=(RMQ_MAX);
	}
	int size() {
		return _n;
	}
	void update(int k,long long a) {
		k+=_n-1;
		_dat[k]=a;
		while(k>0) {
			k=(k-1)/2;
			_dat[k]=min(_dat[k*2+1],_dat[k*2+2]);
		}
	}
	// return the minimum number in [a,b)
	// external call should be written like query(a,b,0,0,_n)
	ll query(int a,int b,int k=0,int l=0,int r=-1) {
		if(r==-1) r=_n;
		if(r<=a||b<=l) return RMQ_MAX;
		if(a<=l&&r<=b) return _dat[k];
		else {
			ll vl=query(a,b,k*2+1,l,(l+r)/2);
			ll vr=query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
private:
	int _n;
	vector<ll> _dat;
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x;
	cin>>n>>x;
	vector<ll> a(n);
	RMQ rmq(n);
	REP(i,n) {
		ll a;
		cin>>a;
		rmq.update(i,a);
	}
	ll ret=INF*INF;
	REP(i,n+1) {
		ll cost=x*i;
		REP(j,n) {
			ll c=INF*INF;
			c=min(c,rmq.query(max(0ll,j-i),j+1));
			if(j-i<0) c=min(c,rmq.query(n-(i-j),n));
			cost+=c;
		}
		ret=min(ret,cost);
	}
	cout<<ret<<endl;
}


Measured memory_bytes: 256
N,L = [ int(it) for it in input().split() ]

li = []
for i in range(N):
  li.append(L+i)
  
su = sum(li)
d = 10000000000000
s = 0
for i in range(N):
  if ( abs( su - li[i] - su)<d ):
    d = abs(su - li[i] - su)
    s = su - li[i]
print ( s )

Measured memory_bytes: 38256
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	_, _, M := scanInt(), scanInt(), scanInt()
	h, w := make([]int, M), make([]int, M)
	he, we := map[int]int{}, map[int]int{}

	ext := map[pair]bool{}
	for i := 0; i < M; i++ {
		h[i] = scanInt() - 1
		w[i] = scanInt() - 1
		he[h[i]] = -1
		we[w[i]] = -1
		ext[pair{h[i], w[i]}] = true
	}

	hx := []int{}
	wx := []int{}
	for x := range he {
		hx = append(hx, x)
	}
	for x := range we {
		wx = append(wx, x)
	}
	sort.Ints(hx)
	sort.Ints(wx)
	for i := 0; i < len(hx); i++ {
		he[hx[i]] = i
	}
	for i := 0; i < len(wx); i++ {
		we[wx[i]] = i
	}

	hc := make([]int, len(hx))
	wc := make([]int, len(wx))

	for i := 0; i < M; i++ {
		x := he[h[i]]
		y := we[w[i]]
		hc[x]++
		wc[y]++
	}

	ans := 0
	ma := 0
	idh := 0
	for i := 0; i < len(hx); i++ {
		if ma < hc[i] {
			ma = hc[i]
			idh = i
		}
	}

	for i := 0; i < len(wx); i++ {
		t := ma + wc[i]
		if ext[pair{hx[idh], wx[i]}] {
			t--
		}
		ans = max(ans, t)
	}

	ma = 0
	idw := 0
	for i := 0; i < len(wx); i++ {
		if ma < wc[i] {
			ma = wc[i]
			idw = i
		}
	}

	for i := 0; i < len(hx); i++ {
		t := ma + hc[i]
		if ext[pair{hx[i], wx[idw]}] {
			t--
		}
		ans = max(ans, t)
	}
	fmt.Fprintln(wr, ans)

}

type pair struct{ a, b int }


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

int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans.at(a - 1) = i + 1;
  }
  for(int i = 0; i < N; i++) {
    cout << ans.at(i) << " ";
  }
  cout << endl;
}

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

int main(){
  int A,B,C,D; cin >> A >> B >> C >> D;
  while(A>0&&C>0){
    A-=D;
    C-=B;
  }
  if(C<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
// IlyM
 
#include <bits/stdc++.h>
 
#define sz(x) ((int)((x).size()))
#define all(x) x.begin(),x.end()
#define ll long long
#define mp make_pair
#define pb push_back
#define se second
#define fi first
#define ms(a,b) memset(a,b,sizeof(a)) 
#define trav(a,b) for(auto a:b)

using namespace std;
 
const int N=1e5+5,mod=1e9+7,MOD=0;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int n,a[N],dp[N],k;
int main()
{
    // ifstream fin ("problem.in"); ofstream fout ("problem.out");
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<n;i++) dp[i]=mod;
	for (int i=n-1;i>=1;i--) for (int j=i;j<min(n+1,i+k+1);j++) dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
	cout<<dp[1];
    return 0;
}
 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x;
  R x;
  ll d=__gcd(360LL,x);
  pr(360/d);
}

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


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

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int ans=0;
  if(h>=w){
    if(n%h==0){
      ans=n/h;
    }else{
      ans=(n/h)+1;
    }
  }else{
    if(n%w==0){
      ans=n/w;
    }else{
      ans=(n/w)+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program {

    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int n = int.Parse( values[ 0 ] );
        int m = int.Parse( values[ 1 ] );
        int l = int.Parse( values[ 2 ] );

        var A = new long[ n, m ];
        var B = new long[ m, l ];

        for( int i = 0; i < n; ++i ) {
            input = Console.ReadLine();
            values = input.Split( ' ' );

            for( int j = 0; j < m; ++j ) {
                A[ i, j ] = long.Parse( values[ j ] );
            }
        }
        for( int i = 0; i < m; ++i ) {
            input = Console.ReadLine();
            values = input.Split( ' ' );

            for( int j = 0; j < l; ++j ) {
                B[ i, j ] = long.Parse( values[ j ] );
            }
        }

        for( int i = 0; i < n; ++i ) {
            for( int j = 0; j < l; ++j ) {
                long sum = 0;
                for( int k = 0; k < m; ++k ) {
                    sum += A[ i, k ] * B[ k, j ];
                }
                Console.Write( sum );
                if( j != l - 1 ) { Console.Write( ' ' ); }
            }
            Console.WriteLine();
        }

        return 0;
    }

}

Measured memory_bytes: 17884
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
pair<ll,ll> p[200200];
const ll maxval = 1e9;
ll segtree[600600], lazy[600600];
void build(int idx, int l, int r)
{
    if(l == r)
    {
        segtree[idx] = p[l].second;
        return;
    }
    int mid = (l+r) / 2;
    build(idx*2, l, mid);
    build(idx*2+1, mid+1, r);
    segtree[idx] = segtree[idx*2] + segtree[idx*2+1];
}
void update(int idx, int l, int r, int kiri, int kanan, ll val)
{
    if(lazy[idx] != 0)
    {
        segtree[idx] += lazy[idx]*(r-l+1);
        segtree[idx] = min(segtree[idx], maxval);
        if(l != r)
        {
            lazy[idx*2] += lazy[idx];
            lazy[idx*2] = min(lazy[idx*2], maxval);
            lazy[idx*2+1] += lazy[idx];
            lazy[idx*2+1] = min(lazy[idx*2], maxval);
        }
        lazy[idx] = 0;
    }
    if(l > kanan || r < kiri) return;
    if(l >= kiri && r <= kanan)
    {
        segtree[idx] += val*(r-l+1);
        segtree[idx] = min(segtree[idx], maxval);
        if(l != r)
        {
            lazy[idx*2] += val;
            lazy[idx*2] = min(lazy[idx*2], maxval);
            lazy[idx*2+1] +=val;
            lazy[idx*2+1] = min(lazy[idx*2], maxval);
        }
        return;
    }
    int mid = (l+r) / 2;
    update(idx*2, l, mid, kiri, kanan, val);
    update(idx*2+1, mid+1, r, kiri, kanan, val);
    segtree[idx] = segtree[idx*2] + segtree[idx*2+1];
}
ll query(int idx, int l, int r, int kiri, int kanan)
{
    if(lazy[idx] != 0)
    {
        segtree[idx] += lazy[idx]*(r-l+1);
        segtree[idx] = min(segtree[idx], maxval);
        if(l != r)
        {
            lazy[idx*2] += lazy[idx];
            lazy[idx*2] = min(lazy[idx*2], maxval);
            lazy[idx*2+1] += lazy[idx];
            lazy[idx*2+1] = min(lazy[idx*2], maxval);
        }
        lazy[idx] = 0;
    }
    if(l > kanan || r < kiri) return 0;
    if(l >= kiri && r <= kanan) return segtree[idx];
    int mid = (l+r) / 2;
    ll sum = query(idx*2, l, mid, kiri, kanan) + query(idx*2+1, mid+1, r, kiri, kanan);
    return sum;
}
vector<ll> vi;
int main()
{
    int n,i,j,x,y,k,ans,curr,temp,m,s;
    int tc;
    ll a,d;
    cin >> n >> d >> a;
    for(i=1;i<=n;i++)
    {
        ll xx, hp;
        scanf("%lld %lld",&xx,&hp);
        p[i] = {xx, hp};
        vi.push_back(xx);
    }
    sort(p+1, p+n+1);
    sort(vi.begin(), vi.end());
    build(1, 1, n);
    ll chaeng = 0;
    for(i=1;i<=n;i++)
    {
        ll now = p[i].first;
        ll hp = query(1, 1, n, i, i);
        if(hp <= 0) continue;
        int idx = lower_bound(vi.begin(), vi.end(), now + 2*d) - vi.begin();
        idx++;
        if(idx > n) idx = n;
        if(p[idx].first > now+2*d) idx--;
        ll need = ceil(hp / (double) a);
        chaeng += need;
        update(1, 1, n, i, idx, -1LL*a*need);
    }
    cout << chaeng << endl;
    return 0;
}


Measured memory_bytes: 14448
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
using namespace std;
ll a,b,t;
int32_t main(){
cin>>a;
cin>>b;
cin>>t;
cout<<(t/a)*b;
}


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll N, W, K;
ll dp[105][10];

vector<string> possib;


void cal_possib(){
	rep(i, 1 << W){
		string ans = "";
		rep(j, W){
			if(i & (1 << j)){
				ans+= '1';
			}
			else ans += '0';
		}

		bool flag = true;
		rep(j, ans.size()){
			if(j == 0) continue;
			else if(ans[j] == '0') continue;
			else if(ans[j] == ans[j-1]){
				flag = false;
				break;
			}
		}
		if(flag){
			possib.pb(ans);
		}
	}

}


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

	cin >> N >> W >> K ;
	W--;
	cal_possib();

	rep(i, W){
		dp[0][i] = 0;
	}

	dp[0][0] = 1;

	rep(i, N+1){
		rep(k, possib.size()){
			ll temp[10];
			rep(j, 10) temp[j] = dp[i][j];

			rep(j, possib[k].size()){
				if(possib[k][j] == '1'){
					swap(temp[j], temp[j+1]);
				}
			}
			rep(j, 10){
				dp[i+1][j] += temp[j];
				dp[i+1][j] %= MOD;
			}
		}
	}


	cout << dp[N][K-1] << endl;



	// A[h][x]; // 縦からh列目を通過した直後に左からx本目の縦棒にいる場合の数

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


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

using namespace std;

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

using ll = long long;
using P = pair<string,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){
    int x;
    cin >> x;

    if(x){
        cout << 0 << "\n";
    }else{
        cout << 1 << "\n";
    }



    return 0;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	string s;
	cin >> s;
	vector<char> res = {};
	for (auto& c: s) {
		if (c == 'B') {
			if (res.size() > 0) {
				res.pop_back();
			}
		} else {
			res.push_back(c);
		}
	}
	for (auto& c: res) {
		cout << c;
	}
	cout << endl;
}


Measured memory_bytes: 256