akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

	ll n,k;
  cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	int l = 0,r = 1000000001;
	while (r > l + 1) {
	  int mid= (l+r) /2;

		int cutN = 0;
		rep(i, n) {
		  cutN += (a[i]-1) / mid;
			if (cutN > k) break;
		}

		//cerr << mid << " " << cutN << endl;

		if (cutN <= k) r = mid;
		else l = mid;
	}

	cout << r << endl;
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k)
    cout << ":(";
  else if (d - a > k || e - b > k)
    cout << ":(";
  else if (c - a > k || d - b > k || e - c > k)
    cout << ":(";
  else if (b - a > k || c - b > k || d - c > k || e - d > k)
    cout << ":(";
  else
    cout << "Yay!";
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a, b, ans;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}

Measured memory_bytes: 3500
import sys
s = input()
n = len(s)
l = (n - 1) // 2
s1 = s[:l]
s2 = s[l+1:][::-1]
if s1 != s2:
    print('No')
    sys.exit()
if s1 != s1[::-1] or s2 != s2[::-1]:
    print('No')
    sys.exit()
print('Yes')

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

int A500;
int B100;
int C50;
int X;

void input() {
    cin >> A500;
    cin >> B100;
    cin >> C50;
    cin >> X;
}

int main() {
    input();
    int cnt = 0;

    for(int Ai=0;Ai <= A500;Ai++){
        for(int Bi=0;Bi <= B100;Bi++){
            for(int Ci=0;Ci <= C50;Ci++){
                if(Ai * 500 + Bi * 100 + Ci * 50 == X){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


int n, x;
int a[100005];
signed main() {
	cin >> n >> x;
	rep(i, n)cin >> a[i];
	int ans = -1;
	rep(i, n - 1) {
		if (a[i] + a[i + 1] >= x) {
			ans = i + 1;
			break;
		}
	}
	if (ans == -1) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		REP(i, ans) {
			cout << i << endl;
		}
		for (int i = n - 1; i > ans; i--) {
			cout << i << endl;
		}
		cout << ans << endl;
	}
	endre;
}


Measured memory_bytes: 1536
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  string x;
  cin >> x;
  string ans = "No";
  if (x[1] == x[0] && x[2] == x[0])
    ans = "Yes";
  if (x[1] == x[2] && x[2] == x[3])
    ans = "Yes";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(s) {
  var answer = 0;

  const half = Math.ceil(s.length / 2);
  for (var i = half; i < s.length; i++) {
    if (s[s.length - i - 1] !== s[i]) {
      answer++;
    }
  }

  //出力
  console.log(answer);
}

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

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<ll>> a(n,vector<ll>(m,0));
    vector<vector<ll>> b(m,vector<ll>(l,0));
    vector<vector<ll>> c(n,vector<ll>(l,0));
    rep(i,n) {
        rep(j,m) {
            cin >> a[i][j];
        }
    }
    rep(i,m) {
        rep(j,l) {
            cin >> b[i][j];
        }
    }
    rep(i,n) {
        rep(j,l) {
            ll sum = 0;
            rep(k,m) {
                sum += a[i][k]*b[k][j];
            }
            c[i][j] = sum;
        }
    }
    rep(i,n) {
        rep(j,l) {
            if (j) {
                cout << " ";
            }
            cout << c[i][j];
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3248
#include<stdio.h>
#include<stdlib.h>

int main(){
  int h,w,k;
  scanf("%d%d%d\n",&h,&w,&k);
  char c[h][w];//character
  int ou[h][w];//output
  char st[h];//strawberry in each row
  int no=1; //block no.
  int fir=0; //first element in row?

  //copy elements
  for(int i=0;i<h;i++){
    st[i]=0;
    for(int j=0;j<w;j++){
      scanf("%c",&c[i][j]);
      if(c[i][j]=='#'){
	st[i]+=1;}}
    if(i==h-1) break;
    scanf("\n");
  }

  int n=0;
  while(st[n]==0){
    n++;}
   for(int i=n;i<h;i++){
     fir=0;
     
     //if there is no strawberry
     if(st[i]==0){
       for(int l=0;l<w;l++){
	 ou[i][l]=ou[i-1][l];}
       continue;}
     //
     for(int j=0;j<w;j++){
       //if there was a strawberry
       if(c[i][j]=='#'){
	 //if first
	 if(fir==0){
	   fir=1;}
	 else{
	   no+=1;}}
       ou[i][j]=no;}
     
     no+=1;}

   for(int m=n-1;m>=0;m--){
     for(int j=0;j<w;j++){
       ou[m][j]=ou[m+1][j];}}

   for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
       printf("%d ",ou[i][j]);}
     printf("\n");}
  
  return 0;
}


Measured memory_bytes: 1152
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<char> v(S.begin(), S.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() << endl;
}

Measured memory_bytes: 512
N = int(input())
L = list(map(int,input().split()))

ans = True

for i in L:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            ans = False
            break

if  ans:
    print("APPROVED")
else:
    print("DENIED")

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

const int INF = INT_MAX;

signed main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> matrix(n,vector<int>(n,INF));
    vector<intpair> edges(m);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        matrix[a][b] = 1;
        matrix[b][a] = 1;
        edges[i] = {a, b};
    }
    rep(i,n) matrix[i][i] = 0;
    
    int ans = 0;
    rep(e,m){
        auto t = matrix;
        t[edges[e].first][edges[e].second] = INF;
        t[edges[e].second][edges[e].first] = INF;
        rep(k,n)rep(i,n)rep(j,n){
            t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
        }
        if(t[edges[e].first][edges[e].second] == INF) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    lli r,g,b,n;
    lli ans = 0;
    cin >> r >> g >> b >> n;
    rep(i,n+1)rep(j,n+1){
        lli rem = n - i * r - j * g;
        if(rem < 0){
            continue;
        }
        if(rem % b == 0)
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 

const ll MOD = 1e9 + 7;
int N;
string P = "ACGT";
vector<map<string, ll>> dp;

ll dfs(int n, string res) {
    if (res.size() >= 3 && (
        (res[n - 3] == 'A' && res[n - 2] == 'G' && res[n - 1] == 'C') ||
        (res[n - 3] == 'A' && res[n - 2] == 'C' && res[n - 1] == 'G') ||
        (res[n - 3] == 'G' && res[n - 2] == 'A' && res[n - 1] == 'C'))) return 0;

    if (res.size() >= 4 && (
        (res[n - 4] == 'A' && res[n - 2] == 'G' && res[n - 1] == 'C') ||
        (res[n - 4] == 'A' && res[n - 3] == 'G' && res[n - 1] == 'C'))) return 0;

    if (n >= N) return 1;    

    assert(n == res.size());
    if (n >= 4) {
        string last4 = res.substr(n - 4, 4);
        if (dp[n].count(last4) > 0) return dp[n][last4];
    }

    ll ret = 0;
    REP(i, 4) {
        ret += dfs(n + 1, res+P[i]);
        ret %= MOD;
    }

    if (n >= 4) {
        string last4 = res.substr(n - 4, 4);
        dp[n][last4] = ret;
    }

    return ret;
}

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


    cin >> N;

    dp = vector<map<string, ll>>(N + 1);

    ll ans = dfs(0, "");

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n,m,a,b, k, sum = 0, d, w, h;
	long long dp[200005] = {}, memo[200005] = {};
	string str,str2;
	cin >> a>>b>>k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			a = a / 2;
			b += a;
		}
		else {
			b /= 2;
			a += b;
		}
	}
	cout << a << " " << b;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    s, w = MI()

    if w >= s:
        print('unsafe')
    else:
        print('safe')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9188
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
count = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      if x == (500 * i) + (100 * j) + (50 * k)
        count += 1
      end
    end
  end
end

puts count

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

struct lst
{
    private:
        int n;
        vector<ll>node;

    public:
        lst(int sz)
        {
            n=1; while (n<sz) n*=2;
            node.resize(2*n-1, 0);
        }
        void update(int k, int v)
        {
            int p=n+k-1;
            while(p>0)
            {
                node[p]+=v;
                p=(p-1)/2;
            }
            node[p]+=v;
        }

        ll get(int qa, int qb, int k=0, int l=0, int r=-1)
        {
            if(r<0) r=n-1;
            if(qb<l || qa>r) return 0;
            if(qa<=l && r<=qb) return node[k];
            else
            {
                int m=(l+r)/2;
                ll ls=get(qa, qb, 2*k+1, l, m);
                ll lr=get(qa, qb, 2*k+2, m+1, r);
                return ls+lr;
            }
        }
};

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    lst tree=lst(n);
    for(int i=0; i<q; i++)
    {
        int com, x, y;
        scanf("%d %d %d", &com, &x, &y);
        if(com)
            printf("%lld\n", tree.get(x-1, y-1));
        else
            tree.update(x-1, y);
    }
    return 0;
}


Measured memory_bytes: 4936
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const long MOD = 1'000'000'007;

int main() {
	long n, k; cin >> n >> k;
	long ans = 0;
	for (long i = k; i <= n+1; i++) {
		long min = i * (i - 1) / 2;
		long max = i * (n * 2 - i + 1) / 2;
		ans += (max - min + 1) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3152
flag=0
while flag==0:
    a,b=[int(i) for i in input().split()]
    if a==0 and b==0:
        flag=1
        break
    else:
        print("#"*b)
        for i in range(a-2):
            print("#",end="")
            print("."*(b-2),end="")
            print("#")
        print("#"*b)
    print("")

Measured memory_bytes: 7648
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void) {
	string s;
	int n;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			++ans;
		}
	}
	cout << ans;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int n;
   cin >> n;
   deque<int> A;
   rep(i, n) {
     int tmp;
     cin >> tmp;
     if (i % 2 == 0) A.push_front(tmp);
     else A.push_back(tmp);
   }

   if (n % 2 == 0) reverse(A.begin(), A.end());

   rep(i, n - 1) cout << A.at(i) << " ";
   cout << A.at(n - 1) << endl;
 }


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    char c; cin >> c;
    int i = c - 'A';
    if (i < 30) cout << "A" << endl;
    else cout << "a" << endl;
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]

numlist = [0] * int(1e5 + 5)
for t in a:
    numlist[t] += 1
ans = sum(a)

for b, c in bc:
    ans += numlist[b] * (c-b)
    print(ans)
    numlist[c] += numlist[b]
    numlist[b] = 0



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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s.size() % 2 == 0) {
    s.erase(s.size() - 2);
  } else {
    s.erase(s.size() - 1);
  }

  int len = 0;
  while (s.size() > 0) {
    int mid = s.size() / 2;
    string t = s.substr(0, mid);
    t += t;

    if (s == t) {
      len = s.size();
      break;
    }

    s.erase(s.size() - 2);
  }
  cout << len << endl;

  return 0;
}


Measured memory_bytes: 3236
w,h,n = map(int,input().split())
g = [[0]*w for i in range(h)]
for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        for p in range(x):
            for q in range(h):
                g[q][p] = 1
    elif a==2:
        for p in range(x,w):
            for q in range(h):
                g[q][p] = 1
    elif a==3:
        for p in range(w):
            for q in range(y):
                g[q][p] = 1
    else:
        for p in range(w):
            for q in range(y,h):
                g[q][p] = 1
cnt = 0
for i in range(h):
    cnt += g[i].count(0)
print(cnt)


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int N;
  cin >> N;
  if(N==1) {
    cout << "Hello World" << endl;
  }
  if(N==2){
    int A,B;
    cin >>A>>B;
    cout << A+B << endl;
  }
}      
      

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

#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;


int main() {
	FASTIO
	string s;
	cin>>s;
	ll n = s.size();
	ll x=  0;
	for(int i = 0 ; i < n ;i++){
		x = (x * 10 + s[i] - '0') % 9;
	}
	if(!x){
		cout<<"Yes"<<endl;
	}else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3748
def main():
    X = input()
    X = int(X)

    if X < 100:
        ans = 0
    else:
        X = str(X)
        under2 = int(X[-2] + X[-1])
        X = int(X)
        if under2 <= 5:
            ans = 1
        else:
            cnt = 0
            while under2 > 5:
                under2 -= 5
                cnt += 1
            cnt += 1

            if X >= cnt * 100:
                ans = 1
            else:
                ans = 0
    
    print(ans)

if __name__ == '__main__':
    main()



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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    map <int, int> m;
    set <int> s;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        m[x]++;
        s.insert(x);
    }
    for (set <int>:: iterator it = s.begin(); it != s.end(); it++) {
        int x = *it;
        if (m[x] > x)
                res += m[x] - x;
        else if (m[x]< x)
                res += m[x];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9216
s = input()
q = int(input())
for i in range(q):
    t = input().split()
    if t[0] == 'print':
        print(s[int(t[1]):int(t[2]) + 1])
    if t[0] == 'reverse':
        temp = s[int(t[1]):int(t[2]) + 1]
        s = s[:int(t[1])] + temp[::-1] + s[int(t[2]) + 1:]
    if t[0] == 'replace':
        s = s[:int(t[1])] + t[3] + s[int(t[2]) + 1:]


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n 
#define pl(n) cout<<n<<" "
const int N=2e5+2;
const int inf=(int)(1e19+10LL);
int n,m,q,ans=0;
Vl a,b,c,d;
void dfs(Vl arr){
 if(arr.size()==n+1){
 	int now=0;
 	for(int i=0;i<q;i++){
 		if(arr[b[i]]-arr[a[i]]==c[i])now+=d[i];
 	}
 	ans=max(ans,now);
 	return;
 }
 arr.pb(arr.back());
 while(arr.back()<=m){
 	dfs(arr);
 	arr.back()++;
 }
}

void solve()
{
 sl(n);sl(m);sl(q);
 a=b=c=d=vector<int>(q);
 for(int i=0;i<q;i++){
 	sl(a[i]);sl(b[i]);sl(c[i]);sl(d[i]);
 }
 dfs(vector<int>(1,1));
 cout<<ans<<endl;
 
}

signed main(){
  int test=1;
// sl(test);
 while(test--){
 	solve();
 }
 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb       push_back
#define conv(a)  bitset<30>(a).to_string() ;
#define mxpq     priority_queue <int>
#define mnpq     priority_queue<int,vector<int>,greater<int>>
#define S(v)     sort(v.begin(),v.end())
#define RS(v)    sort(v.rbegin(),v.rend())
#define print    printf("%.16f\n", ans)
#define inf      LLONG_MAX
#define mini     LLONG_MIN
#define T        int tc;cin>>tc;while(tc--)
#define int      long long 
#define MAXN     10000001
#define M        1000000007
#define fio      cin.sync_with_stdio(false) ; cin.tie(0);cout.tie(0) ;
#define endl     "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;


void Xarr(){
     
         int n ; cin>>n ;
         double d=3.14159 ;
         cout<<2*n*d<<endl ;

} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int32_t main(){
 
    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    #ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif
    
    cout << setprecision(9) << fixed;
     clock_t z = clock();
     
     Xarr();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;

}

Measured memory_bytes: 3804
#include <iostream>
#include <math.h>
#define MAX_P 20
 
using namespace std;
 
/*〜概要〜
  binary_numにより，人iが正しいかどうかをtrue_personに格納する．
  例えば，i=20回目のループを考える．
  20は2進数で00101(左から数える)であり，これは
  人1が嘘つき，人2が嘘つき，人3は正直，人4は嘘つき，人5は正直
  であることを示しており，それをi=0からi=2^N-1まで繰り返すことにより
  全パターンを探索することができる．
*/
 
//引数numを2進数に直して配列true_personに左から格納する
void binary_num(int num, int N, int true_person[]){
  int i=1;
  while(num != 0){
    true_person[i] = num%2;
    i++;
    num /= 2;
  }
}
 
 
//true_person配列を参照することで，正直者の人数を返す関数
int honest_count(int true_person[], int N){
  int count = 0;
  for(int i=1; i<=N; i++)
    if(true_person[i] == 1)
      count++;
  return count;
}
 
 
int check(int x[MAX_P][MAX_P], int y[MAX_P][MAX_P], int A[],
		 int N, int true_person[]){
  int i, j;
  for(i=1; i<=N; i++){
    if(true_person[i] == 1){
      for(j=1; j<=A[i]; j++){
	if(y[i][j] != true_person[ x[i][j] ]){
	  return -1;
	}
      }
    }
  }
  int honest_num = honest_count(true_person, N);;
  return honest_num;
}
 
 
int main(void){
  int N, i, j;
  cin >> N;
  int A[N];
  int x[MAX_P][MAX_P], y[MAX_P][MAX_P];
  for(i=1; i<=N; i++){ //入力
    cin >> A[i];
    for(j=1; j<=A[i]; j++)
      cin >> x[i][j] >> y[i][j];
  }
 
  //人iが正しいかどうか(正しいなら1，そうでないなら0)
  int true_person[MAX_P];
  
  /*binary_numにより，人iが正しいかどうかをtrue_personに格納する．
    例えば，i=20回目のループを考える．
    20は2進数で00101(左から数える)であり，これは
    人1が嘘つき，人2が嘘つき，人3は正直，人4は嘘つき，人5は正直
    であることを示しており，それをi=0からi=2^N-1まで繰り返すことにより
    全パターンを探索することができる．
   */
  int count_max = 0;
  int count;
  for(i=0; i<pow(2, N); i++){
    binary_num(i, N, true_person);    
    count = check(x, y, A, N, true_person);
    if(count_max < count)
      count_max = count;
  }
 
  cout << count_max << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>A(N),F(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> F[i];
    }
    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    int l = -1,r = INF;
    while (l+1 < r) {
        int mid = (l+r)/2;
        int cnt = 0;
        for(int i = 0; i < N; i++) {
            if(mid == 0) {
                cnt += max(0LL,A[i]-F[i]);
                continue;
            }
            cnt += max(0LL,A[i]-mid/F[i]);
        }
        if(cnt <= K) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
    #define int ll
    int n, x, t;
    cin >> n >> x >> t;
    cout << t*((n+x-1)/x) <<endl;
    // ここに処理を記述
    // コンパイル時はエイリアス「gpp」--> c++17でコンパイル

}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);//小数点の桁数

    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main(){
    int N;
    cin >> N;
    set<int> mochi;

    for(int i = 0; i < N; i++){
        int buffer;
        cin >> buffer;
        mochi.insert(buffer);
    }

    cout << mochi.size() << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 101010, M = N + N;
int n;
int a[N], b[N];
int c[M];
ll m;
void upd(int x) {
	x += N;
	for(; x < M; x += x & -x)
		c[x]++;
}
int qry(int x) {
	x += N;
	int res = 0;
	for(; x; x -= x & -x)
		res += c[x];
	return res;
}
bool gao(int x) {
	rep(i, 1, n + 1) b[i] = a[i] >= x ? 1 : -1;
	rep(i, 1, n + 1) b[i] += b[i - 1];
	ll cnt = 0;
	memset(c, 0, sizeof(c));
	upd(0);
	rep(i, 1, n + 1) {
		cnt += qry(b[i]);
		upd(b[i]);
	}
	return cnt >= (m + 1) / 2;
}
int main(){
	scanf("%d", &n);
	rep(i, 1, n + 1) scanf("%d", a + i);
	int lo = 1, hi = 1e9 + 1;
	m = 1ll * n * (n + 1) / 2;
	while(lo + 1 < hi) {
		int mid = lo + hi >> 1;
		gao(mid) ? lo = mid : hi = mid;
	}
	printf("%d\n", lo);
	return 0;
}


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


int main(){
  int a,b;
  cin>>a >>b;
  if(a*b%2==1){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

}

Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,m,p;
  int player[101];
  while(true){
    int ans;
    cin >> n >> m >> p;
    if(n==0) break;
    int voter=0;
    for(int i=1;i<=n;i++){
      int x;
      cin >> x;
      player[i] = x;
      voter += x;
    }
    if(player[m]==0) ans=0;
    else ans = voter*(100-p)/player[m];
    cout << ans  << endl;
  }
}

Measured memory_bytes: 3052
#include <stdio.h>

void push(int v);
int pop();

int stack[1024];
int head = 0;

int main(void)
{
	int t;
	
	while (scanf("%d", &t) != EOF){
		if (t == 0){
			printf("%d\n", pop());
		}
		else {
			push(t);
		}
	}
	
	return (0);
}

void push(int v)
{
	stack[head] = v;
	head++;
}

int pop()
{
	head--;
	return (stack[head]);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = (int)1e6 + 34;
//const ll INF = (ll)1e18 + 41;
const int INF = (int)1e9 + 41;
const ll MD = (ll)1e9 + 7;

int dp[N];
void solve() {
    int x;
    cin >> x;
    if (x < 4 || x == 5 || x == 6 || x == 9 || x == 10 || x == 13 || x == 17) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

int main() {
#ifdef MADE_BY_SERT
    freopen("a.in", "r", stdin);
    solve();
    solve();
#endif // MADE_BY_SERT
    solve();
}


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

int main() {
  ll l;
  cin >> l;
  double a;
  a = l;
  
  cout << fixed << setprecision(10);
  cout << a*a*a / 27 << endl;
}

Measured memory_bytes: 3672
import java.util.*; 
import java.io.*;

public class Main {	
	static int dp[][] = new int[3005][3006]; 
	static String ans = "";
	public static int lcs(char p[] , char s[] , int n , int m) {
		if(n == 0 || m == 0) 
			return 0; 
		
		if(dp[n][m] != -1) return dp[n][m];
		
		else if(p[n-1] == s[m-1]) {
			return dp[n][m] = 1 + lcs(p , s , n-1 , m-1);
		}
			 
		int temp1 = lcs(p , s , n-1 , m);
		int temp2 = lcs(p , s , n , m-1); 
		return dp[n][m] = Math.max(temp1, temp2); 
	}
	public static void pr(char p[] , char s[] ,int n , int m) {
		if(n<=0 || m <= 0)
			return;
		if(p[n-1] == s[m-1]) {
			ans = p[n-1] + ans; 
			pr(p,s,n-1,m-1); 
		}
		else if(dp[n-1][m] > dp[n][m-1])
			pr(p,s,n-1,m); 
		else
			pr(p,s,n,m-1); 
	}
	public static void solve(InputReader in) {
		char p[] = in.readString().toCharArray(); 
		char s[] = in.readString().toCharArray(); 
		int n = p.length , m = s.length; 
		for(int i = 0; i<3005; i++) {
			for(int j = 0; j<3006; j++) {
				dp[i][j] = -1; 
			}
		}
		lcs(p,s,n,m); 
		pr(p,s,n,m);
		System.out.println(ans); 
	}
	
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in); 
		int t = 1; 
		while(t-- > 0) {
			solve(in); 
		}
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
     
     public String next() {
		return readString();
	}
    
     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 87680
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=10000+10;
const int maxm=100000+10;
int n,m;
struct node
{
    char s[20];
    bool operator <(const node& rhs)const
    {
        return strcmp(s,rhs.s)<0;
    }
};
map<node,int> mp;
struct Edge
{
    node u,v;
    bool flag;
}e[maxm];
vector<int> G[maxn];
int pre[maxn],low[maxn];
int dfs_clock;
void tarjan(int u,int fa)
{
    low[u]=pre[u]=++dfs_clock;
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        if(v==fa) continue;
        if(!pre[v])
        {
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
        }
        else low[u] = min(low[u],pre[v]);
    }
}
int main()
{
    
        int id=0;
        scanf("%d%d",&n,&m);
        mp.clear();
        dfs_clock=0;
        memset(pre,0,sizeof(pre));
        for(int i=1;i<=n;i++) G[i].clear();
        for(int i=0;i<m;i++)
        {
            e[i].flag=false;
            scanf("%s%s",e[i].u.s,e[i].v.s);
            if(mp.find(e[i].u)==mp.end()) mp[e[i].u]= ++id;
            if(mp.find(e[i].v)==mp.end()) mp[e[i].v]= ++id;
            int x = mp[e[i].u], y=mp[e[i].v];
            G[x].push_back(y);
            G[y].push_back(x);
        }
        tarjan(1,-1);
        bool ok=true;
        for(int i=1;i<=n;i++)if(!pre[i])
        {
            ok=false;
            break;
        }
        if(!ok) printf("0\n");
        else
        {
            int ans=0;
            for(int i=0;i<m;i++)
            {
                int u=mp[e[i].u], v=mp[e[i].v];
                if(low[u]>pre[v]||low[v]>pre[u]) e[i].flag=true,ans++;
            }
            printf("%d\n",ans);
        }
    return 0;
}



Measured memory_bytes: 512
n = gets.to_i
station = (n - 1).times.map { gets.split.map(&:to_i) }
(n - 1).times do |i|
  total = 0
  station[i..-1].each do |c, s, f|
    total = s if total < s
    total = ((total - 1) / f + 1) * f
    total += c
  end
  puts total
end
puts 0


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for (int i=0; i < (n); i++)
int main(){
  int a,b,c,d,sum=0;
  cin>>a>>b>>c>>d;
  r(i,a+1)r(j,b+1)r(k,c+1)if(i*500+j*100+k*50==d)sum++;
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        for (int i = 1; i <= b; i++) {
            if (a * i % b == c) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int n,m;
	char sh[55][55];
	int d[9][2]={
		{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}
	};
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",sh[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(sh[i][j]=='.')
			{
				int s=0;
				for(int k=0;k<8;k++)
				{
					int x=i+d[k][0],y=j+d[k][1];
					if(x<n&&y<m)
					{
						if(sh[x][y]=='#')s++;
					}
				}
				sh[i][j]=s+48+'\0';
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		printf("%s\n",sh[i]);
	}
	
	return 0;
}

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

ll S;
int A,B,K;

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

	for(int i=A;i<=B;i++){
		if(i%K==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
}

Measured memory_bytes: 3596
h, w = map(int, input().split())
matrix = [[x for x in input()] for y in range(h)]

def check_surround(matrix, x, y):
    if matrix[x][y] == '#':
        return '#'
    else:
        tmp = []
        tmp += check_index(matrix, x-1, y-1)
        tmp += check_index(matrix, x, y-1)
        tmp += check_index(matrix, x+1, y-1)
        tmp += check_index(matrix, x-1, y)
        tmp += check_index(matrix, x+1, y)
        tmp += check_index(matrix, x-1, y+1)
        tmp += check_index(matrix, x, y+1)
        tmp += check_index(matrix, x+1, y+1)
        return str(str(tmp).count('#'))

def check_index(matrix, x, y):
    if x > -1 and y > -1:
        try:
            return matrix[x][y]
        except:
            return str(0)
    else:
        return str(0)

for ri in range(h):
    s = ''
    for ni in range(w):
        s += check_surround(matrix, ri, ni)
    print(s)

Measured memory_bytes: 3064
N = int(input())
N_List = list(map(int,input().split()))
ans = 0
cans = 0
for i in range(1,N):
    if N_List[i] <= N_List[i-1]:
        cans += 1
    if cans > ans:
        ans = cans
    if N_List[i] > N_List[i-1]:
        cans = 0
    
print(ans)

Measured memory_bytes: 20624
N =int(input())
a = list(map(int, input().split()))

for i in range(N):
    a[i] = a[i] - i - 1
a.sort()

b = a[(N - 1) // 2]

for i in range(N):
    a[i] = abs(a[i] - b)

print(sum(a))


Measured memory_bytes: 25196
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	ll N, K, S;
	cin >> N >> K >> S;
	vector<ll> A;
	if(N==K)
	{
	    rep(i, N) A.push_back(S);
	}
	else if(S<=100000)
	{
		rep(i, K) A.push_back(S);
		rep(i, N-K) A.push_back(S+1);
	}
	else
	{
		if(S%2==0)
		{
			rep(i, K+1) A.push_back(S/2);
			rep(i, N-K-1) A.push_back(S/2-1);
		}
		else
		{
			rep(i, K+1)
			{
				if(i%2==0) A.push_back(S/2);
				else A.push_back(S/2-1);
			}
			rep(i, N-K-1) A.push_back(S/2-3);
		}
	}

	rep(i, N)
	{
		if(i!=0) cout << " ";
		cout << A.at(i);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2292
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string s;
    cin >> s;
    ll K;
    cin >> K;
    set<string> v;
    rep(i, s.size()) {
        for(ll j = 1; j <= K; j++) {
            if (i+j > s.size()) continue;
            string tmp = s.substr(i, j);
            v.insert(tmp);
        }
    }
    vector<string> vec(all(v));
    print(vec[K-1]);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
    long N;
    std::cin >> N;
    long temp=std::pow(2,60);
    for(long i=1; i<=std::ceil(std::sqrt(N)); i++){
        if(N%i==0){
            if(temp>((N/i)+i)-2){
                temp = (N/i)+i-2;
            }
        }
    }
    std::cout << temp << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxx 1e9

void solve()
{
 int m,n,k,i,j,i2,j2;
    int ans=0;
    cin>>m>>n>>k;
    char a[m][n];
    for(i=0;i<m;i++)
    {
     for(j=0;j<n;j++)
     {
      cin>>a[i][j];   
     }
    }
    for(i=0;i<(1<<m);i++)
    {
     for(j=0;j<(1<<n);j++)
     {
      int cnt=0;   
         for(i2=0;i2<m;i2++)
         {
          for(j2=0;j2<n;j2++)
          {
           if((i>>i2&1)&&(j>>j2&1)&&a[i2][j2]=='#')cnt++;  
          }
         }
         if(cnt==k)ans++;
     }
    }
    cout<<ans<<endl;
}

int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
    
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define int long long

int calc(vector<int> &a)
{
   int res=0;
   int N=a.size();
   for(int i=0;i<N-1;i++){
      res+=abs(a[i]-a[i+1]);
   }
   return res;
}

signed main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());

   if(N%2==0){
      vector<int> b(N);
      for(int i=0;i<N/2;i++){
         b[i*2]=a[N/2+i];
         b[i*2+1]=a[i];
      }
      cout<<calc(b)<<endl;
   }else{
      vector<int> b(N);
      b[N-1]=a[N/2];
      for(int i=0;i<N/2;i++){
         b[i*2]=a[N/2+1+i];
         b[i*2+1]=a[i];
      }
      int ans=calc(b);
      b[N-1]=a[N/2];
      for(int i=0;i<N/2;i++){
         b[i*2]=a[N/2-1-i];
         b[i*2+1]=a[N/2+1+i];
      }
      ans=max(ans,calc(b));
      cout<<ans<<endl;
   }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(x) cout<<#x<<":";cout<<x<<endl;
#define debugs(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 60;
ll a[N];
ll n;
ll cnt;

int main() {
	//freopen("in.txt","r",stdin);
	cnt = 0;
	scanf("%lld",&n);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	sort(a,a+n);
	while(a[n-1] >= n) {
		ll tmp = a[n-1]/ n;
		cnt += tmp;
		a[n - 1] -= tmp * n;
		for(int i=0;i<n-1;i++)a[i] += tmp;
		sort(a,a+n);
	}	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int k,a,b;
int main()
{
	scanf("%d%d%d",&k,&a,&b);
	if(a-a%k+k<=b||a%k==0||b%k==0){
	    puts("OK");
	}else{
	    puts("NG");
	}
	return 0;
}

Measured memory_bytes: 1640