akhauriyash/Code-Regression huggingface dataset:
H,W=map(int,input().split())
a=[[] for _ in range(H)]

for i in range(H):
    a[i]=input()
    
ans=[[0]*W for _ in range(H)]

for i in range(H):
    if a[i]=="."*W:
        continue
    else:
        for j in range(W):
            if a[i][j]==".":
                ans[i][j]=1
            else:
                ans[i][j]=2

        
        
for j in range(W):
    if 2 in [row[j] for row in ans]:
        continue
    else:
        for i in range(H):
            ans[i][j]=0
        
for i in range(H):
    temp=""
    for j in range(W):
        if ans[i][j]==1:
            temp+="."
        elif ans[i][j]==2:
            temp+="#"
    if temp!="":
        print(temp)
        

Measured memory_bytes: 39536
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-11

#DP
L = int(input())
DP = [0 for i in range(5)]

def cost(a):
    if a:
        return [a, a%2, (a+1)%2, a%2, a]
    else:
        return [0, 2, 1, 2, 0]

for i in range(L):
    n = [min(DP[:i+1]) for i in range(5)]
    cos = cost(int(input()))
    DP[4] = n[4] + cos[4]
    DP[3] = n[3] + cos[3]
    DP[2] = n[2] + cos[2]
    DP[1] = n[1] + cos[1]
    DP[0] = n[0] + cos[0]

print(min(DP))

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<llP> mos(n);
  rep(i, n) cin >> mos[i].first >> mos[i].second;
  sort(ALL(mos));

  vector<ll> damage(n, 0);
  vector<ll> ex(n+1, 0);
  ll ans = 0;
  rep(i, n) {
    damage[i] -= ex[i];
    ll hp = mos[i].second - damage[i];
    hp = max(0ll, hp);
    
    damage[i] += (ll)ceil((double)hp / a) * a;

    ans += (ll)ceil((double)hp / a);
    ll x = mos[i].first;
    int index = distance(mos.begin(), upper_bound(ALL(mos), make_pair(x+2*d, INF64)));

    ex[index] += (ll)ceil((double)hp / a) * a;

    if(i < n-1) damage[i+1] += damage[i];
  }
  cout << ans << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int dp[5005][5005];

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  for (int i = n - 1; i >= 0; i--) {
    for (int j = n-1; j >= 0; j--) {
      if (s[i] != s[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1]+1;
    }
  }

  int ans = 0;
  rep(i, 0, n) {
    rep(j, 0, n) {
      if (i >= j) continue; // i < j;
      int now = min(dp[i][j], j-i);
      ans = max(ans, now);
    }
  }

  cout << ans << endl;

  return 0;
};


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

struct TPond
{
	int DownPoint;
	int Surface;
};

void ConstructPond(vector<TPond> &PondRow, stack<int> &DownPointRow, int InputCount)
{
	TPond Pond;
	Pond.DownPoint = DownPointRow.top();
	Pond.Surface = InputCount - DownPointRow.top();
	//????????´???????±????????????§???????±????????????????????????°?±?list???????????????
	//????????´???????±????????????§???????±????????????????????????°????????´???????±???????????????????
	if(!PondRow.empty() && Pond.DownPoint < PondRow.back().DownPoint){
		while(!PondRow.empty() && Pond.DownPoint < PondRow.back().DownPoint){
			Pond.Surface += PondRow.back().Surface;
			PondRow.pop_back();
		}
	}
	PondRow.push_back(Pond);
	DownPointRow.pop();
	return;
}

void Output(vector<TPond> PondRow)
{
	//?????¢???????±???????
	int SumOfSurface = 0;
	for(int i = 0; i < PondRow.size(); i++){SumOfSurface += PondRow[i].Surface;}
	//?????¢?????¨??°??¨?????????????????¢??????????????????
	cout << SumOfSurface << endl; 
	cout << PondRow.size();
	for(int i = 0; i < PondRow.size(); i++){cout << ' ' << PondRow[i].Surface;}
	cout << endl;
	return;
}

int main()
{
	//?±?(????????????????????°??¨??¢???????????±?????????)????????????list???????????????
	vector<TPond> PondRow;
	//????????????????????°????????????stack???????????????
	stack<int>   DownPointRow;
	//????????????????????°???????????????????????????????????°???????????????
	int InputCount = 0;
	while(true){
		//??????????????????????????\???????????\?????????
		char Input;
		cin >> Input;
		if(cin.good() == false){break;}
		InputCount += 1;
		//???????????\???????????????DownPointRow???????????????
		//???????????\????????????????????´?????????????????????????±?????§??????????
		if(Input == '\\'){
			DownPointRow.push(InputCount);
		}else if(Input == '/' && !DownPointRow.empty()){
			ConstructPond(PondRow, DownPointRow, InputCount);
		}
	}
	Output(PondRow);
	return 0;
}

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

using namespace std;

string p, q;
int s1[100002], s2[100002], t, a, b, c, d;

int main()
{
  cin >> p >> q >> t;
  int n = p.size();
  int m = q.size();
  p = '#' + p;
  q = '#' + q;
  for (int i = 1; i <= n; i++)
    if (p[i] == 'A')
      s1[i] = s1[i - 1] + 1;
    else
      s1[i] = s1[i - 1] + 2;
  for (int i = 1; i <= m; i++)
    if (q[i] == 'A')
      s2[i] = s2[i - 1] + 1;
    else
      s2[i] = s2[i - 1] + 2;
  while (t--) {
    cin >> a >> b >> c >> d;
    int r1 = (s1[b] - s1[a - 1]) % 3;
    int r2 = (s2[d] - s2[c - 1]) % 3;
    if (r1 != r2)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
  return 0;
}


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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 100 + 5;
const int INF = ~0U >> 2;
int main() {
    //freopen("c.in", "r", stdin);
    int n, a, sum = 0, minV = INF;
    cin >> n;
    rep(i,0,n) {
        cin >> a;
        sum += a;
        if(a % 10 != 0) minV = min(minV, a);
    }
    if(sum % 10 != 0) cout << sum << endl;
    else if(minV == INF) cout << 0 << endl;
    else cout << sum - minV << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (long double k) {
    return Point(x * k, y * k);
  }

  Point operator / (long double k) {
    return Point(x / k, y / k);
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

long double abs(Point p) {
  return sqrt(norm(p));
}

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int ccw(Point p0, Point p1, Point p2) {
  Point v1 = p1 - p0, v2 = p2 - p0;
  if (cross(v1, v2) > 0) return 1;
  else if (cross(v1, v2) < 0) return -1;
  else if (dot(v1, v2) < 0) return 2;
  else if (norm(v1) < norm(v2)) return -2;
  else return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

long double getDistanceLP(Point p1, Point p2, Point p3) {
  return fabs(cross(p2-p1, p3-p1) / abs(p2-p1));
}

long double getDistanceSP(Point p1, Point p2, Point p3) {
  if (dot(p2-p1, p3-p1) < 0) return abs(p3-p1);
  else if (dot(p1-p2, p3-p2) < 0) return abs(p3-p2);
  else return getDistanceLP(p1, p2, p3);
}

long double getDistanceTS(Point p1, Point p2, Point p3, Point p4) {
  if (intersect(p1, p2, p3, p4)) return 0;
  long double ans = INF;
  ans = min(ans, getDistanceSP(p1, p2, p3));
  ans = min(ans, getDistanceSP(p1, p2, p4));
  ans = min(ans, getDistanceSP(p3, p4, p1));
  ans = min(ans, getDistanceSP(p3, p4, p2));
  return ans;
}

int main() {
  int q;
  cin >> q;
  Point p0, p1, p2, p3;
  rep(i, q) {
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    cout << setprecision(15) << getDistanceTS(p0, p1, p2, p3) << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3280
function Main(input){
	input = input.split("\n");
  var N = input[0]*1;
  var t = 0;
  var x = 0;
  var y = 0;
  for(var i = 1; i <= N; i++){
  	var h = input[i].split(" ");
  	var nt = h[0]*1;
    var nx = h[1]*1;
    var ny = h[2]*1;
    
    var dt = nt - t;
    var dx = Math.abs(x-nx);
    var dy = Math.abs(y-ny);
    
    var amari = dt - dx - dy;
    
    if(amari < 0){
    	return "No";
    }
    if(amari % 2 != 0){
    	return "No";
    }
    
    t = nt;
    x = nx;
    y = ny;
  }
  return "Yes";
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

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

using namespace std;


void energy_drink_collector()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> ab(n);
  for (int i = 0; i < n; ++i) cin >> ab[i].first >> ab[i].second;

  sort(ab.begin(), ab.end());

  long long int total_fee = 0;
  for (int i = 0; i < n && m > 0; ++i)
  {
    total_fee += (long long int)ab[i].first * (long long int)min(m, ab[i].second);
    m -= min(m, ab[i].second);
  }

  cout << total_fee << "\n";
}


void get_AC()
{
  int n, q;
  string S;
  cin >> n >> q >> S;

  vector<int> cnt(n + 1);
  for (int i = 0; i < n; ++i)
  {
    if (i + 1 < n && S[i] == 'A' && S[i + 1] == 'C') cnt[i + 1] = cnt[i] + 1;
    else cnt[i + 1] = cnt[i];
  }

  for (int i = 0; i < q; ++i)
  {
    int l, r;
    cin >> l >> r;
    cout << cnt[r - 1] - cnt[l - 1] << "\n";
  }
}


void five_transportations()
{
  long long int n;
  cin >> n;
  long long int v_min = 1000000000000000, tmp;
  for (int i = 0; i < 5; ++i) 
  {
    cin >> tmp;
    v_min = min(v_min, tmp);
  }

  cout << (n - 1)/ v_min + 5;
}


int main()
{
  //energy_drink_collector();
  //get_AC();
  five_transportations();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
bool check(string s,char c){
  bool flag = true;
  for (int i(0);i<int(s.size());i++){
    if (s[i] != c){
      flag = false;
    }
  }
  return flag;
}

int main(){
  int N,M;
  cin>>N>>M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
  return 0;
}



Measured memory_bytes: 256
n = int(input())
mod_list = []
for i in range(n):
    a = input()
    dot = a.find('.')
    if dot < 0:
        num = int(a) * 1000000000
    elif dot == len(a) - 1:
        num = int(a[:dot]) * 1000000000
    else:
        rest = len(a) - 1 - dot
        num = int(a[:dot]) * 1000000000 + int(int(a[dot + 1:]) * pow(10, 9 - rest))
    mod2 = mod5 = 0
    while num % 2 == 0:
        num = num / 2
        mod2 += 1
    while num % 5 == 0:
        num = num / 5
        mod5 += 1
    mod_list.append((mod2, mod5))

raw_table = [[0 for j in range(50)] for i in range(50)]
for mod2, mod5 in mod_list:
    raw_table[mod2][mod5] += 1
dp_table = [[0 for j in range(50)] for i in range(50)]
for i in range(48, -1, -1):
    row_sum = raw_table[i][49]
    for j in range(48, -1, -1):
        row_sum += raw_table[i][j]
        dp_table[i][j] = dp_table[i + 1][j] + row_sum

count = 0
for mod2, mod5 in mod_list:
    need2 = max(18 - mod2, 0)
    need5 = max(18 - mod5, 0)
    count += dp_table[need2][need5]
    if need2 <= mod2 and need5 <= mod5:
        count -= 1
print(int(count / 2))


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

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

  int cnt = 0;
  for (int i = 0; i <= a; i ++) {
    for (int j = 0; j <= a; j ++) {
      int k = b - i - j;
      if (k >= 0 && k <= a) {
        cnt ++;
      }
    }
  }

  cout << cnt << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<long long> A(X), B(Y), C(Z);
  vector<long long> AB, ABC;
  for(int i = 0; i < X; ++i) cin >> A[i];
  for(int i = 0; i < Y; ++i) cin >> B[i];
  for(int i = 0; i < Z; ++i) cin >> C[i];
  sort(A.begin(), A.end(), greater<long long>()); // reverse(A.begin(), A.end());
  sort(B.begin(), B.end(), greater<long long>()); // reverse(B.begin(), B.end());
  sort(C.begin(), C.end(), greater<long long>()); // reverse(C.begin(), C.end());
  for(int i = 0; i < X; ++i) {
    for(int j = 0; j < Y; ++j) {
      AB.push_back(A[i] + B[j]);
    }
  }
  sort(AB.begin(), AB.end(), greater<long long>());
  for(int i = 0; i < min(3000, (int)AB.size()); ++i) {
    for(int j = 0; j < Z; ++j) {
      ABC.push_back(AB[i] + C[j]);
    }
  }
  sort(ABC.begin(), ABC.end(), greater<long long>());
  for(int i = 0; i < K; ++i) {
    cout << ABC[i] << endl;
  }

  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  int ans = 0;
  vector<int> flag(N);
  for (int i = 0; i < N - 1; i++) {
    if (!flag[i] && !flag[i + 1] && A[i] == i && A[i + 1] == i + 1) {
      ans++;
      flag[i] = flag[i + 1] = 1;
    }
  }

  for (int i = 0; i < N; i++) {
    if (!flag[i] && A[i] == i) {
      ans++;
    }
  }

  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

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

using namespace std;

int main() {

	string str; cin >> str;

	string input;

	for (char c : str) {

		if (c == '0' || c == '1') input += c;
		else{
		
			if (input.length() == 0) continue;

			input.erase(input.length() - 1, 1);
		
		}

	}

	cout << input;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    vstr ls = {"maerd", "remaerd", "esare", "resare"};
    string tmp = "";
    int l = 0;
    rrep(i, n) {
        tmp += s[i];
        l++;
        if (l > 7) {
            puts("NO");
            return 0;
        }
        rep(j, 4) {
            if (tmp == ls[j]) {
                tmp = "";
                l = 0;
            }
        }
    }
    if (l == 0) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	nums := map[string]int{}
	ans := 0
	for i := 0; i < n; i++ {
		fields := strings.Split(s[i], "")
		sort.Strings(fields)
		str := strings.Join(fields, "")
		ans += nums[str]
		nums[str]++
	}
	fmt.Println(ans)
}


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

int main() {
  int n, x, y, z;
  cin >> n;
  vector<int> t(n + 10, 0); // a == true += 1; b == true += 2; c == true += 4;
  cin >> x;
  vector<int> a(x);
  int i;
  for (i = 0; i < x; i++) {
    cin >> a[i];
    t[a[i]] += 1;
  }
  cin >> y;
  vector<int> b(y);
  for (i = 0; i < y; i++) {
    cin >> b[i];
    t[b[i]] += 2;
  }
  cin >> z;
  vector<int> c(z);
  for (i = 0; i < z; i++) {
    cin >> c[i];
    t[c[i]] += 4;
  }
  int result = 0;
  for (i = 0; i < t.size(); i++) {
    if (t[i] == 7 || t[i] == 6 || t[i] == 4) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3116
inputs = (gets).split(" ")
nn = inputs[0].to_i
xx = inputs[1].to_i

inputs = (gets).split(" ")
si = inputs.map{|istr| istr.to_i}
si.sort!

dp = []
=begin
例えばnn=1だったとき、黒板の文字は x mod s0 である。
ではdp[0,x] = x mod s0 にするかというと、それはいろいろ大変なことになる。
ところでdp[0,x]をよく眺めていると、0..s0-1という数列が循環していることに気付く。
なので dp[0,x]=x, dp[1,x]=dp[0,x%s0], ということにするといろいろ便利になる。
=end
dp[0] = Array.new(xx+1){|x| x}
#p dp[0]

# メモ空間のすべてを計算する必要はないが、アクセスする分は計算する必要がある
uq = [xx]
while true
    xa = uq.dup
    xa.each do |x|
      si.each do |s|
        uq << x.modulo(s)
      end
    end
    uq.uniq!
    #p uq
    break if uq.length == xa.length
end
xa = uq
xa.sort!.reverse!

# dp(i+1,x) = dp(i,x%s_i) + dp(i,x)
1.upto(nn) do |i|
  dp[i] = Array.new(xa.length){0} #とりあえず
  st = si[i-1]
  #1.upto(xx) do |x|
  # 全部やらないで先に計算したアクセスしそうな場所だけ計算する
  xa.each do |x|
    # 上記の説明＋実際に数列を書いてみるとこれに行きつく
    dp[i][x] = (dp[i-1][x]*(i-1) + dp[i-1][x.modulo(st)]).modulo(1000000007)
  end
  #p dp[i]
end

puts dp[nn][xx]

Measured memory_bytes: 159688
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ; 

int n , col[MAXN] ;
vector <pair <int , int>> g[MAXN] ;

void dfs(int v , int par = -1) {
	for ( auto u : g[v] )
		if ( u.X != par ) {
			if ( u.Y & 1 )
				col[u.X] = col[v] ^ 1 ;
			else
				col[u.X] = col[v] ;
			dfs(u.X , v) ;
		}
}

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n ;
	int v , u , w ;
	for ( int i = 1 ; i < n ; i ++ )
		 cin >> v >> u >> w , g[v].pb({u , w}) , g[u].pb({v , w}) ;
	dfs(1) ;
	for ( int i = 1 ; i <= n ; i ++ )
		cout << col[i] << " " ;
	cout << "\n" ;
}


Measured memory_bytes: 31744
#include<stdio.h>
#define N 36

struct card {
  int no;
  char mk;
};

int main(void)
{
  int n,i,j,mini,sf=0;
  struct card c[N],c1,c2[N],c3;
  scanf("%d",&n);
  for(i = 0; i < n; i++){ /* 入力 */
    scanf(" %c",&c[i].mk);
    scanf("%d",&c[i].no);
    c2[i] = c[i];
  }
  for(i = 0; i < n; i++){
    for(j = n-1; i < j; j--){
      if(c[j].no < c[j-1].no){ 
	c1 = c[j];
	c[j] = c[j-1];  /* バブルソート並び換え部分 */
	c[j-1] = c1;
      }
    }
  }


  for(i = 0; i < n-1; i++){ /* 出力 */
    printf("%c%d ",c[i].mk,c[i].no);
  }
  printf("%c%d\n",c[n-1].mk,c[n-1].no);
  printf("Stable\n");



  for(i = 0; i < n; i++){
    mini = i;
    for(j = i; j < n; j++){
      if(c2[j].no < c2[mini].no){ /* 選択ソート並び換え部分 */
	mini = j;
      }
    }
    if(mini != i){
	c3 = c2[i];
	c2[i] = c2[mini];
	c2[mini] = c3;
    }
  }

  for(i = 0; i < n-1; i++){ /* 出力 */
    printf("%c%d ",c2[i].mk,c2[i].no);
    if((c[i].mk != c2[i].mk))sf =1;
  }
  printf("%c%d\n",c2[n-1].mk,c2[n-1].no);
  if(sf == 0)printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a < b){
    printf("a < b\n");
  }else if (a > b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
    return 0;
}

Measured memory_bytes: 580
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

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


    
    
    int main(){
        int a,b,c;cin>>a>>b>>c;
        set<int>s{a,b,c};
        if(s.size() == 2)cout<<"Yes";
        else cout<<"No";
    }
    


Measured memory_bytes: 256
import math

def combinations_count(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))

n = int(input())
a = list(map(int,input().split()))
n_list = [0 for i in range(n)]
len_list = [0 for i in range(n)]

for i in range(n):
    n_list[a[i]-1] += 1

sum_len = 0

for i in range(n):
    if n_list[i] == 0:
        len_list[i] == 0
    elif n_list[i] == 1:
        len_list[i] == 1
    else:
        len_list[i] = combinations_count(n_list[i])
    sum_len += len_list[i]

for i in range(n):
    if len_list[a[i]-1] == 0:
        print(sum_len)
    elif len_list[a[i]-1] == 1 or len_list[a[i]-1] == 2:
        print(sum_len - 1)
    else:
        print(sum_len - (n_list[a[i]-1] - 1))


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

ll f(int n){
    return (ll)n*(n+1)/2;
}

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    // int cum[n+1];
    // cum[0] = 0;
    // rep(i,n)cum[i+1] = cum[i] + i+1;
    drep(i,1,n){
        ans += f(n/i)*i;
    }


    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct Edge{
    int to,id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v,int c=-1,int p=-1){
    int k=1;
    rep(i,g[v].size()){
        int u=g[v][i].to, ei=g[v][i].id;
        if(u==p) continue;
        if(k==c) k++;
        ans[ei]=k; k++;
        dfs(u,ans[ei],v);
    }
}

int main(){
    int n;
    cin>>n;
    g.resize(n);
    ans=vector<int>(n-1);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int mx=0;
    rep(i,n) mx=max(mx,(int(g[i].size())));
    cout<<mx<<endl;
    rep(i,n-1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, T;
    cin >> N >> T;

    int c, t;
    int cost = 1001;

    for (int i = 0; i < N; i++){
        cin >> c >> t;
        if (t <= T){
            cost = min(cost, c);
        }
    }

    if (cost <= 1000){
        cout << cost << endl;
    }
    else {
        cout << "TLE" << endl;
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

string s, t;

int main() {
  cin >> s >> t;
  rep(i, s.size()) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

typedef long long ll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    rep(i, N - 1) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    if (p[N - 1] == N) ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 640
#include<cmath>
#include<cstdio>
#include<cstring>
int n;
bool use[10];
int x[10],y[10];
int F(int n){
    if(n<=1) return 1;
    return F(n-1)*n;
}
double path(int i,int j){
    double t=0;
    t=((x[i]-x[j])*(x[i]-x[j]))+((y[i]-y[j])*(y[i]-y[j]));
    t=sqrt(t);
    return t;
}
double dfs(int k,int p){
    //printf("%d ",k);
    if(p>=n) return 0;
    double ans=0;
    for(int i=1;i<=n;i++){
        if(use[i]==false){
            use[i]=true;
            ans+=F(n-p-1)*path(k,i)+dfs(i,p+1);
            //printf("\n");
            use[i]=false;
        }
    }
    return ans;
}
int main(){
    memset(use,false,sizeof(use));
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);
    int m=1;
    double ans=0;
    for(int i=1;i<=n;i++){
        use[i]=true;
        ans+=dfs(i,1);
        use[i]=false;
    }
    m=F(n);
    ans/=m;
    printf("%.10lf",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
  int i,j,k,n,d1[200000],d2[200000],x,y;
  cin >> n;
  for(int i=0,x,y; i<n; i++)
  {
    cin>>x>>y;
	d1[i]=(x+y);
    d2[i]=(x-y);
  }
  sort(d1,d1+n);
  sort(d2,d2+n);
  cout<<max(d1[n-1]-d1[0],d2[n-1]-d2[0])<<endl;
}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<string> vec;
	int n,l;cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		string t;
		cin>>t;
		vec.push_back(t);

	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++)
	{
		cout<<vec[i];
	}
}

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

q = 0
while abs(x) > q**4:
  q += 1

deta = False
for A in range(-q, q+1):
  if deta:
    break
  for B in range(-q, q+1):
    if A**5 - B**5 == x:
      print(A,B)
      deta = True
      break

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
 
using namespace std;
 
const int MAX = 100000;
vector<int> num(MAX);
 
int main() {
    int n, k;

    while (cin>>n>>k, n||k) {
      int sum = 0;
      int ans = 0;

      for (int i = 0; i < n; i++) {
        cin >> num[i];
        if (i < k) { 
          sum += num[i]; 
          ans = sum; 
        }
        else { 
          sum = sum + num[i] - num[i-k]; 
          ans = max(ans, sum); 
        }
      }
      cout << ans << endl;
    }
 
  return 0;
}

Measured memory_bytes: 3064
#coding:utf-8
S = input()
st = set(S)
ans = 1e+9
for s in st:
  ls_strg = list(S.split(s))
  mx = 0
  for strg in ls_strg:
    mx = max(mx,len(strg))
  ans = min(mx, ans)
print (ans)


Measured memory_bytes: 2940
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 20;

int pen[maxN];
bool ac[maxN];

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	int sc = 0, pt = 0;
	while (m--)
	{
		int id;
		char buf[5];
		scanf ("%d%s", &id, buf);
		if (ac[id])
			continue;
		if (buf[0] == 'A')
		{
			sc++;
			pt += pen[id];
			ac[id] = true;
		}
		
		else
			pen[id]++;
	}
	
	printf("%d %d\n", sc, pt);
}

int main()
{
	int t;
	t = 1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;	
}


Measured memory_bytes: 768
import sys
sys.setrecursionlimit(pow(10, 6))
input = sys.stdin.readline

def dfs(i, d):
  visited[i] = True
  ans[i] = d + pp[i]
  for j in edges[i]:
    if not visited[j]:
      dfs(j, d + pp[i])

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
visited = [False for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)
pp = [0 for _ in range(n)]
for _ in range(q):
  p, x = map(int, input().split())
  pp[p-1] += x
dfs(0, 0)
print(*ans)


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int H, W, D, A[300][300];
int Q, L, R;
map<int, pii> A_i;
int c_sum[300 * 300 + 1];

int main() {
    cin >> H >> W >> D;
    REP(i, H) REP(j, W) {
        cin >> A[i][j];
        A_i[A[i][j]] = {i, j};
    }

    A_i[0] = A_i[D];
    REP(i, D) {
        for (int j = i + 1; j + D <= H * W; j += D) {
            int cur_x = A_i[j + D].first, cur_y = A_i[j + D].second;
            int pri_x = A_i[j].first,     pri_y = A_i[j].second;
            int cost = abs(cur_x - pri_x) + abs(cur_y - pri_y);
            c_sum[j + D] = c_sum[j] + cost;
        }
    }

    cin >> Q;
    REP(i, Q) {
        cin >> L >> R;
        cout << c_sum[R] - c_sum[L] << endl;
    }
    return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
  string s;
  string ans = "";

  cin >> s;
  size_t s_size = s.size();
  for (size_t i=0; i<s_size; i++) {
    if (i%2 == 0) {
      ans += s[i];
    }
  }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;
const int mod=1e9+7;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,p,ans=0; cin >> n;
    int a[n]; rep(i,0,n) cin >> a[i];
    sort(a,a+n);
    while(p<n){
        int cc=a[p],fre=0;
        while(p<n && a[p]==cc) p++,fre++;
        ans+=fre%2;
    }
    cout << ans << endl;
 }    


Measured memory_bytes: 768
# N = 5
# ARR = [2, 6, 1, 4, 5]

# N = 6
# ARR = [4, 1, 3, 1, 6, 2]
#
#
# N = 2
# ARR = [10000000, 10000000]

N = int(input())
ARR = list(map(int,input().split()))

def calculate(n,arr):

    dict = {}
    result = True
    for i in range(n):
        item = arr[i]
        if dict.get(item) == None:
            dict.__setitem__(item,True)
        else:
            result = False
            break
    if result == True:
        print("YES")
    else:
        print("NO")

calculate(N,ARR)


Measured memory_bytes: 32944
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
m = n//2
INF = 10**18
dp = [defaultdict(lambda: -INF) for _ in range(n+1)]
for i in range(1, n+1):
    L = i//2-1
    R = (i+1)//2+1
    for j in range(L, R):
        if j == 1:
            dp[i][j] = max(dp[i-1][j], A[i-1])
        elif 0 <= i-2 and 0 <= j <= m:
            dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+A[i-1])
print(dp[-1][m])


Measured memory_bytes: 186700
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, X, T = In.ints()

if N//X == N/X:
    Out.int(N//X * T)
else:
    Out.int((N//X+1) * T)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> a(N);
  vector<vector<int>> ans(H, vector<int>(W));
  for (int i = 0; i < N; i++) cin >> a[i];
  int k = 0;
  for (int i = 0; i < H; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < W; j++) {
        a[k]--;
        ans[i][j] = k + 1;
        if (a[k] == 0) {
          k++;
        }
      }
    } else {
      for (int j = W - 1; j >= 0; j--) {
        a[k]--;
        ans[i][j] = k + 1;
        if (a[k] == 0) {
          k++;
        }
      }
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}

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

int main(){
	for(int i=0;i<=2;i++){
		int a[6];
		for(int j=0;j<6;j++)scanf("%d",&a[j]);
		int x=a[0]*3600+a[1]*60+a[2];
		int y=a[3]*3600+a[4]*60+a[5];
		int res=y-x;
		int c=res/60;
		printf("%d %d %d\n",c/60,c%60,res%60);
	}
}

Measured memory_bytes: 1188
#include <stdio.h>

int w,h,x,y,r;

int main(void) {
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

if(x+r<=w && y+r<=h && x-r>=0 && y-r>=0){
  printf("Yes\n");
}
else{
  printf("No\n");
}
	return 0;

}



Measured memory_bytes: 2104
A,B,K = map(int, input().split())

ans = []

if A <= B:
    for i in range(1,B+1):
        if A % i == 0 and B % i ==0:
            ans.append(i)
else:
    for j in range(1,A+1):
        if A % j == 0 and B % j ==0:
            ans.append(j)

print(ans[-K])

Measured memory_bytes: 3060
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

VV<ll> edges;
V<ll> X;
bool ok = true;
const size_t SIZE = 5000;

PLL dfs(ll cur) {
    bitset<SIZE + 10> bs;
    bs.set(0, 1);
    ll sum = 0;
    for(ll nxt : edges[cur]) {
        ll a, b;
        tie(a, b) = dfs(nxt);
        if(!ok) return PLL();
        sum += a + b;
        bs = (bs << a) | (bs << b);
    }
    for(ll i = SIZE; 0<= i; i--) {
        if(!bs.test(i)) continue;
        if(X[cur] < i) continue;
        return PLL(X[cur], sum - i);
    }
    ok = false;
    return PLL();
}

int main() {
    ll N;
    cin >> N;
    X.resize(N);
    edges.resize(N);
    for(ll i = 1; i < N; i++) {
        ll c = i;
        ll p;
        cin >> p;
        edges[p - 1].push_back(c);
    }
    for(ll &e : X) cin >> e;
    dfs(0);
    if(!ok) cout << "IM";
    cout << "POSSIBLE" << endl;
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 N;
	cin >> N;
	vector<int64> b(N);
	REP(i, N) cin >> b[i];
	vector<int64> res;
	REP(i, N) {
		vector<int64> nb;
		for (int64 i = b.size()-1; i >= 0; i--) {
			if (b[i] == i+1) {
				res.push_back(i+1);
				REP(j, b.size()){
					if (j != i) nb.push_back(b[j]);
				}
				break;
			}
		}
		swap(nb, b);
	}
	if (res.size() < N) {
		cout << -1 << endl;
	} else {
		reverse(all(res));
		REP(i, N) {
			cout << res[i] << endl;
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif


typedef long long lint;

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

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



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

	lint a; cin >> a;
	coc(a < 1200, "ABC", "ARC");
	gc();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define bit_cnt(n) (__builtin_popcountll(n))
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
string s;
int n;
vector<pair<string,string> >cl;
map<pair<string,string>,ll>MP;
void dfs(int now,int depth,ll bit){
  if(depth==n){
    string red="";
    string blue="";
    if(now){
      for(int i=n;i<2*n;i++){
	if(bit&(1<<(i-n))){
	  red+=s[i];
	}else{
	  blue+=s[i];
	}	
      }
      reverse(ALL(blue));
      reverse(ALL(red));
      MP[mp(blue,red)]++;
    }else{
      for(int i=0;i<n;i++){
	if(bit&(1<<i))
	  red+=s[i];
	else
	  blue+=s[i];
      }
      cl.pb(mp(red,blue));
    
    }
    return;
  }
  dfs(now,depth+1,bit+(1<<depth));
  dfs(now,depth+1,bit);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  cin>>s;
  dfs(0,0,0);
  dfs(n,0,0);
  ll ans=0;
  for(int i=0;i<cl.size();i++){
    ans+=MP[cl[i]];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 91116
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int a, e, k, tmp;
  
  cin >> a >> tmp >> tmp >> tmp >> e >> k;
  
  int res = (e - a ) <= k;
  cout << (res ? "Yay!" : ":(");
  
  return 0;
  
}

Measured memory_bytes: 256