akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}

  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }

  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }

  const Edges &operator[](const int &i) const { return g[i]; }

  Graph toRootedTree(int r);
  std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const int &src, const int &inf);
  Matrix warshallFloyd(const int &inf);
  std::pair<Weight, Edges> prim(const int &r);
  template<typename UnionFind> std::pair<Weight, Edges> kruskal();
  Weight solveTSP(const int &inf);
};

std::pair<Weight, Edges> Graph::prim(const int &r = 0) {
  struct comp {
    bool operator()(const Edge &e, const Edge &f) const { return e.weight > f.weight; }
  };
  Edges tree;
  Weight total = 0;
  std::vector<int> vs(g.size());
  std::priority_queue<Edge, std::vector<Edge>, comp> q;
  q.emplace(-1, r, 0);
  while (q.size()) {
    Edge e = q.top();
    q.pop();
    if (vs[e.dst]) continue;
    vs[e.dst] = true;
    total += e.weight;
    if (e.src != -1) tree.emplace_back(e);
    for (auto &f : g[e.dst]) {
      if (!vs[f.dst]) q.emplace(f);
    }
  }
  return {total, tree};
}

main {
  int n;
  cin >> n;
  Graph g(n);
  rep(i, n) rep(j, n) {
    int a;
    cin >> a;
    if (a >= 0) g.addArc(i, j, a);
  }
  cout << g.prim().first << endl;
}

Measured memory_bytes: 3412
from itertools import permutations
import re


def main():
    s = input().replace('?', '.')
    t = input()

    for i in reversed(range(len(s) - len(t) + 1)):
        # print(s[i:i + len(t)])
        if re.search(s[i:i + len(t)], t):
            result = (s[:i] + t + s[i + len(t):]).replace('.', 'a')
            print(result)
            return

    print('UNRESTORABLE')

main()


Measured memory_bytes: 3188
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int f(int a,int k){
	if(a<k)return 0;
	if(a<2*k)return (a-k+1)%2;
	if(a%k==0)return a/k;
	int b=(a%k)/(1+a/k);
	b=max(1ll,b);
	return f(a-(1+a/k)*b,k);
}
signed main(){
	int n;
	cin>>n;
	int x=0;
	rep(i,n){
		int a,k;
		cin>>a>>k;
		x^=f(a,k);
	}
	
	if(!x)cout<<"Aoki"<<endl;
	else cout<<"Takahashi"<<endl;
}










Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
    int n, sum = 0;
    unordered_set<string> hash;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;

        if (hash.find(s) == hash.end()) {
            hash.insert(s);
            sum += 1;
        }
    }
    cout << sum << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 10 == 3 || i % 3 == 0 || (i / 10) % 10 == 3 ||
            (i / 100) % 10 == 3 || (i / 1000) % 10 == 3) {
            cout << " " << i;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#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 <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int r = rei();
	cout << 3*r*r << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll red[A], blue[B], green[C];
    for(int i = 0; i < A; i++) cin >> red[i];
    sort(red, red + A, greater<ll>());
    for(int i = 0; i < B; i++) cin >> blue[i];
    sort(blue, blue + B, greater<ll>());
    for(int i = 0; i < C; i++) cin >> green[i];
    sort(green, green + C, greater<ll>());

    ll ans = 0, N = X + Y, r = X - 1, b = Y - 1, g = 0;
    for(int i = 0; i < X; i++) ans += red[i];
    for(int i = 0; i < Y; i++) ans += blue[i];

    for(int i = 0; i < N && g < C; i++) {
        if(b < 0) {
            if(red[r] <= green[g]) {
                ans += green[g] - red[r];
                g++;
            }
            r--;
        } else if(r < 0) {
            if(blue[b] <= green[g]) {
                ans += green[g] - blue[b];
                g++;
            }
            b--;
        } else {
            if(min(red[r], blue[b]) <= green[g]) {
                ans += green[g] - min(red[r], blue[b]);
                g++;
            }
            if(red[r] >= blue[b])
                b--;
            else
                r--;
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 4; i++) {
        if ((a * b * i) % 2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

 int main(){
  cout << fixed << setprecision(12);
  int a, b;
  cin>>a>>b;

  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<<(double)a / b<<endl;

  return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        // if (N*100 % 108 == 0) {
        //         cout << N*100/108 << endl;
        // } else {
        //         cout << ":(" << endl;
        // }

        rep(i, 1, 50001) {
                if (i*108/100 == N) {
                        cout << i << endl;
                        return 0;
                }
        }
        cout << ":(" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int N, n;

char str[200][200];

void set_(int x, int y){
	if(x < 0 || y < 0 || x >= n || y >= n){
		return;
	}
	str[y][x] = ' ';
}

bool checker(int x, int y){
	if(x < 0 || y < 0 || x >= n || y >= n){
		return false;
	}
	if(str[y][x] == 'p'){
		return true;
	}
	return false;
}

bool set(int x, int y, int dx, int dy){
	if(x < 0 || y < 0 || x >= n || y >= n){
		return false;
	}
	if(str[y][x] != 'p'){
		return false;
	}
	str[y][x] = '#';
	if(dx != 0){
		if(checker(x - dx, y - 1)){
			set_(x - dx, y - 1);
		}
		if(checker(x - dx, y + 1)){
			set_(x - dx, y + 1);
		}
	}else{
		if(checker(x - 1, y - dy)){
			set_(x - 1, y - dy);
		}
		if(checker(x + 1, y - dy)){
			set_(x + 1, y - dy);
		}
	}
	if(!set(x + dx, y + dy, dx, dy)){
		if(dx > 0){
			dx = 0;
			dy = 1;
		}else if(dx < 0){
			dx = 0;
			dy = -1;
		}else if(dy > 0){
			dx = -1;
			dy = 0;
		}else{
			dx = 1;
			dy = 0;
		}
		set(x + dx, y + dy, dx, dy);
	}
	return true;
}

int main(){
	
	cin >> N;
	
	for(int loop = 0; loop < N; loop++){
		
		if(loop != 0){
			printf("\n");
		}
		
		cin >> n;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				str[i][j] = 'p';
			}
		}
		
		set(0, n - 1, 0, -1);
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(str[i][j] == 'p'){
					str[i][j] = ' ';
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				printf("%c", str[i][j]);
			}
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1452
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

d = 0
for i in range(n):
	t = min(b[i],a[i])
	d += t
	b[i] -= t
	t2 = min(a[i+1],b[i])
	d += t2
	a[i+1] -= t2
	
print(d)

Measured memory_bytes: 18624
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<int>m(101);
	for (int i = a; i < b; i++) {
		m[i]++;
	}
	for (int i = c; i < d; i++) {
		m[i]++;
	}
	int count = 0;
	for (int i = 0; i < 100; i++) {
		if (m[i] == 2) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;


void main()
{
	while (1) {
		auto x = readln.chomp.split.map!(to!int);
		if (!x[0]) break;
		auto area = new char[][](x[0], x[1]);
		foreach (i; 0..x[0]) {
			area[i] = readln.chomp.map!(to!char).array;
		}

		int cnt;

		void solve(int i, int j, char type) {
			area[i][j] = '.';
			foreach (a; iota(-1, 2, 2)) {
				if (i+a >= 0 && i+a < x[0]) {
					if (area[i+a][j] == type) solve(i+a, j, type);
				}
				if (j+a >= 0 && j+a < x[1]) {
					if (area[i][j+a] == type) solve(i, j+a, type);
				}
			}
		}

		foreach (i; 0..x[0]) {
			foreach (j; 0..x[1]) {
				if (area[i][j] == '.') continue;
				cnt++;
				solve(i, j, area[i][j]);
			}
		}
		cnt.writeln;
	}
}

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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];

    ll ans = 0;
    if (a >= b)
    {
        ans = (n - 1) * b;
        cout << ans << endl;
        return 0;
    }

    rep(i, n - 1)
    {
        if (a * (x[i + 1] - x[i]) > b)
            ans += b;
        else
            ans += a * (x[i + 1] - x[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
int N;
std::string S;

std::cin >> N;
std::getline(std::cin, S);
std::getline(std::cin, S);

int x = 0;
int max = x;

for (int i = 0; i < N; ++i){
if (S[i] == 'I'){
x += 1;
if (x > max){
max = x;
}
}
else {
x -= 1;
}
}

std::cout << max << std::endl;

return 0;
}

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

using namespace std;

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;

bool judge(ll n) {
    FOR(i, 1, 10) {
        FOR(j, 1, 10) {
            if (n == i * j) return true;
        }
    }
    return false;
}

int main() {
    ll n; io.scan(n);
    io.printl(judge(n) ? "Yes": "No");
}


Measured memory_bytes: 256
N, Y = gets.split(' ').map(&:to_i)
ans = [-1] * 3
0.upto(N) do |i|
  i.upto(N) do |j|
    if i * 10000 + (j - i) * 5000 + (N - j) * 1000 == Y
      ans = [i, j - i, N - j]
      break
    end
  end
  break if ans[0] != -1
end

puts ans.join(' ')

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
string s;
int ts,tt,ans;
int main(){
	cin>>s;
	if(s[0]=='S')
		ts++;
	else
		tt++;
	for(int i=1;i<(int)s.size();i++){
		if(s[i]!=s[i-1] && s[i]=='T'){
			tt=1;
		}
		else if(s[i]!=s[i-1] && s[i]=='S'){
			ans+=2*(min(ts,tt));
			if(ts>tt)
				ts=ts-tt+1;
			else
				ts=1;
			tt=0;
		}
		else if(s[i]=='S')
			ts++;
		else
			tt++;
	}
	ans+=2*(min(ts,tt));
	cout<<(int)s.size()-ans;
}


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

#define endl '\n'

typedef long long ll;

const ll oo = 0x3f3f3f3f3f3f3f3f;

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

	int n;
	cin >> n;

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

	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, oo));

	for(int l = 0; l < 2; ++l)
		for(int i = 0; i + l <= n; ++i)
			dp[i][i + l] = 0;

	for(int l = 2; l <= n; ++l)
		for(int i = 0; i + l <= n; ++i)
			for(int k = i + 1; k < i + l; ++k)
				dp[i][i + l] = min(dp[i][i + l],
								   dp[i][k] + dp[k][i + l] + (ll) v[k] * v[i] * v[i + l]);

	cout << dp[0][n] << endl;

    return 0;
}


Measured memory_bytes: 3196
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = {0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = {0, 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}
ll X[100010];
int main() {
	ll N, A, B; cin >> N >> A >> B;
	REP(i, N)cin >> X[i];
	ll ans = 0;
	REP(i, N - 1) {
		ans += min(B, (X[i + 1] - X[i])*A);
	}
	print(ans);
}

Measured memory_bytes: 1024
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,m,k,i,j;
	cin>>n>>m>>k;
	rep(i,m+1){
		rep(j, n+1){
			if(i*n+j*m-2*i*j==k){
				cout<<"Yes"<<endl;
			
			return 0;
		}
		}
	}
	cout<<"No"<<endl;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
	return y==0? x:gcd(y,x%y);
}
int main(){
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=n;j++)
			for(ll k=1;k<=n;k++){
				sum+=gcd(gcd(i,j),k);	
			}
	cout<<sum<<endl;
 } 

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0;
  //string s;
  cin >> a >> b;
  //vector<int> v(n), c(n);
  //if(1) {}
  //for(int i = 0; i < n; i++){}
  cout << ((a > b)? "safe" : "unsafe") << endl;
}

Measured memory_bytes: 3632
from collections import Counter
n = int(input())
l = list(map(int,input().split()))
a = Counter(l)
b = a.most_common()
c = []
for i,j in b:
    if j>=4:
        c.append(i)
        c.append(i)
    elif j>=2:c.append(i)
c.sort()
print(c[-1]*c[-2] if len(c)>=2 else 0)

Measured memory_bytes: 21668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef float fl;
typedef long long ll;
int n;
int a[101][101];

int main(){
    cin >> n;
    rep(i,n){
        int u, k; cin >> u >> k;
        rep(j,k){
            int l; cin >> l;
            a[i][l-1] = 1;
        }
    }
    
    rep(i,n){
        rep(j,n){
            if(j) cout << ' ';
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
/*
                                    Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
     
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
     
    #include <bits/stdc++.h>
     
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
     
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
        int result=1;
        while(n>0)
        {
            if(n % 2 ==1)
                result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
        return result % M;
    }
    signed main()
    {   jaldi
    	int n,m;
    	cin>>n>>m;
    	if(n==m)
    	cout<<"Yes";
    	else
    	cout<<"No";
    	return 0;
    }

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string s;int n;cin>>s>>n;
  vector<string>str;
  for(int i=0;i<min((int)s.size(),n);i++){
    for(int k=0;k<s.size()-i;k++){
	str.pb(s.substr(k,i+1));
      
    }
  }
  sort(str.begin(),str.end());
  int cnt=0,cnt2=0;
  string ans="";
  while(cnt!=n){
    if(ans!=str[cnt2]){
      cnt++;
      ans=str[cnt2];
    }
    cnt2++;
  }
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = cin.Int();
			}

			var aa = a.OrderByDescending(x => x).ToArray();
			for (int i = 0; i < n; i++) {
				if (a[i] == aa[0]) {
					Console.WriteLine(aa[1]);
				} else {
					Console.WriteLine(aa[0]);
				}
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 24512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define N 200
#define Max 1000000

int top;
int S[N];

int pop(){
	return S[top--];
}

void init(){
	top = 0;
}

void push(int x){
	S[++top] = x;
}
int main(){
	char s[Max];
	int a,b;
	init();
	while(scanf("%s",s)!=EOF){
		if(!strcmp(s,"+")){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(!strcmp(s,"-")){
			a = pop();
			b = pop();
			push(b - a);
		}
		else if(!strcmp(s,"*")){
			a = pop();
			b = pop();
			push(a * b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	map<P, bool> mp;
	rep(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		mp[P(a, b)] = true;
		mp[P(b, a)] = true;
	}
	vector<int> a(n);
	rep(i, n) a[i] = i;
	//reverse(all(a));
	int ans = 0;
	do {
		if (a[0] != 0) continue;
		bool elf = true;
		rep(i, n - 1) {
			if (!mp[P(a[i], a[i + 1])]) elf = false;
		}
		if (elf) ans++;
	} while (next_permutation(all(a)));

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
  int A,B,C,K;
  cin >> A >> B >> C;
  cin >> K;
  int count = 0;
  while(count < K && !(B>A && C>B)){
   if(B<=A){
     B = B*2;
     count++;
    }
    else if(count < K && C<=B){
     C = C*2;
     count++;
    }
  }
  if(B>A && C>B) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 3588
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int INF=1e9;

struct node{
	int s,e,m;
	int val=-INF;
	node *l,*r;
	
	node (int _s,int _e){
		s=_s,e=_e,m=s+e>>1;
		
		if (s!=e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	
	void update(int i,int j){
		if (s==e) val=j;
		else{
			if (i<=m) l->update(i,j);
			else r->update(i,j);
			
			val=max(l->val,r->val);
		}
	}
	
	int query(int i,int j){
		if (s==i && e==j) return val;
		else if (j<=m) return l->query(i,j);
		else if (m<i) return r->query(i,j);
		else return max(l->query(i,m),r->query(m+1,j));
	}
} *even=new node(0,200005),*odd=new node(0,200005);

int n;
int arr[200005];
bool high[200005];
int highcnt;
string ans;

bool test(int cx,int cy,int hx,int hy){
	//cout<<cx<<" "<<cy<<" "<<hx<<" "<<hy<<" "<<highcnt<<endl;

	bool b1=true,b2=true;
	int val;
	
	val=cy-cx+highcnt;
	if (val<0) b1=false;
	else if (val%2==0 && even->query(hx+1,200005)<val) b1=false;
	else if (val%2==1 && odd->query(hx+1,200005)<val) b1=false;
	
	val=cx-cy+highcnt;
	if (val<0) b2=false;
	if (val%2==0 && even->query(hy+1,200005)<val) b2=false;
	if (val%2==1 && odd->query(hy+1,200005)<val) b2=false;
	
	return b1||b2;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	rep(x,0,n) cin>>arr[x];
	
	int curr=0;
	rep(x,0,n){
		if (curr<arr[x]){
			curr=arr[x];
			high[x]=true;
			highcnt++;
		}
	}
	
	//rep(x,0,n) cout<<high[x]<<" ";cout<<endl;
	
	even->update(n+1,0);
	rep(x,n,0){
		if (high[x]){
			even->update(arr[x],even->query(arr[x]+1,200005)+2);
			odd->update(arr[x],odd->query(arr[x]+1,200005)+2);
		}
		else{
			even->update(arr[x],odd->query(arr[x]+1,200005)+1);
			odd->update(arr[x],even->query(arr[x]+1,200005)+1);
		}
	}
	
	//rep(x,1,n+1) cout<<even->query(x,x)<<" "<<odd->query(x,x)<<endl;
	
	int cx=0,cy=0,hx=-1,hy=-1;
	
	rep(x,0,n){
		if (high[x]) highcnt--;
		even->update(arr[x],-INF);
		odd->update(arr[x],-INF);
		
		//try add it to x
		bool can;
		if (hx<arr[x]) can=test(cx+1,cy,arr[x],hy);
		else can=test(cx,cy,hx,hy);
		
		if (can){
			ans+='0';
			
			if (hx<arr[x]) cx++,hx=arr[x];
		}
		else{
			ans+='1';
			
			if (hy<arr[x]) cy++,hy=arr[x];
		}
	}
	
	if (cx==cy) cout<<ans<<endl;
	else cout<<"-1"<<endl;
}


Measured memory_bytes: 42164
#include <iostream>
#include <map>
using namespace std;
int main(void){
    
    map<int, int> m;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int d;
        cin >> d;
        m[d];
    }
    
    cout << m.size() << endl;
    
}


Measured memory_bytes: 3196
#include <iostream>
#include<string>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli x,k,n,c,las;
	c=0;
	cin>>n;
	for(lli i=1;i<=9;i++){
		for(lli j=1;j<=9;j++){
			if(i*j==n){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	// x='Z';
	// las=int('Z');
	// if('Z'-(s[0]+k)>=0)cout<<(char)(s[0]+2);
	// cout<<'Z'<<" "<<(s[0]+k);
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 100005

const ll mod = 1000000007;
int N, x[MAXN], cnt[MAXN];
ll powm(ll a, ll k, ll mod){	// not using mulm
  ll ans = 1;
  while (k){
    if (k & 1) ans = ans*a%mod;
    k >>= 1;
    a = a*a%mod;
  }
  return ans;
}
VI binomial(int n) {
  VI ans(n+1,1);
  REP(i,1,n+1) ans[i] = (ll)ans[i-1] * (n-i+1) % mod * powm(i, mod-2, mod) % mod;
  return ans;
}
int getC(VI &C, int m) {
  if (m < 0 || m >= C.size()) return 0;
  return C[m];
}

int main() {
  cin >> N;
  N++;
  VI xs;
  int v = -1;
  REP(i,0,N) {
    scanf("%d", x+i);
    cnt[x[i]]++;
    if (cnt[x[i]] == 2) v = x[i];
  }
  REP(i,0,N) {
    if (x[i] == v) xs.push_back(i);
  }
  VI Cn2 = binomial(N-2), Cab = binomial(xs[0] + N-xs[1]-1);
  REP(k,1,N+1) {
    ll ans = getC(Cn2,k);
    ans = (ans + (ll)2*getC(Cn2,k-1)%mod + mod - getC(Cab, k-1)) % mod;
    ans = (ans + getC(Cn2, k-2))%mod;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
    
using namespace std;
string s;
int main( ) {

    cin >> s;
    if (s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout <<"No"<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean rejectFlg = true;

		for (int i = 0; i < N; i++) {
			int num = sc.nextInt();

			if (num % 2 == 1) {
				continue;
			}else {
				if (num % 3 == 0 || num % 5 == 0) {
					continue;
				}else {
					rejectFlg = false;
					break;
				}
			}
		}

		if (rejectFlg) {
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}
	}
}

Measured memory_bytes: 35984
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pr pair<int, int>
#define v1d vector<int>
#define mp make_pair
#define pb push_back
#define v1p vector<pr>
#define vb vector<bool>
#define v2d vector<vector<int>>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define S(v) sort(v.begin(), v.end())
#define RS(v) sort(v.rbegin(), v.rend())
#define eb emplace_back
#define endl "\n"
#define MOD 1000000007
#define pqx priority_queue <int>
#define pqn priority_queue <int, v1d, greater<int> >
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int32_t main() {
    fio
    int k; cin >> k;
    string s; cin >> s;
    if(s.size() <= k) {
        cout << s; return 0;
    }

    string ans(s.begin(), s.begin() + k);
    ans += "...";
    cout << ans;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {
    int n, l;
    cin >> n >> l;
    vector<string> vc;
    rep(i, n){
        string s; cin >> s;
        vc.push_back(s);
    }
    sort(all(vc));
    rep(i, n){
        cout << vc[i];
    }
    cout << ln;
}

Measured memory_bytes: 256
#include <cstdio>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5 + 10;
const int inf = 1e9 + 7;
int n, u[N];

void find2( int sum )
{
    if( sum == 0 )
        return;
    for( int i = 1; i <= sum; i++ )
    {
        if( (i * (i + 1) ) >> 1 >= sum && sum - i >= 0 && !u[i] )
        {
            printf("%d\n", i);
            sum -= i;
            u[i] = 1;
            find2(sum);
            return ;
        }
    }
    if( sum > 0 )
        printf("%d", sum);
}

main()
{
    scanf("%d", &n);
    int sum = n;
    find2(sum);
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int ans = 0;
    if(n<=k) {
        ans = 1;
        cout<<ans<<endl;
        return 0;
    }
    n = n-k; ans++;
    ans += n/(k-1);
    if(n%(k-1)!=0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scanf("%s %s", &s, &t)
	fmt.Scanf("%d %d", &a, &b)
	fmt.Scanf("%s", &u)
	uInS := strings.Index(s, u)
	uInT := strings.Index(t, u)
	if uInS > -1 && uInT > -1 {
		a--
		b--
	} else if uInS > -1 {
		a--
	} else if uInT > -1 {
		b--
	}
	fmt.Printf("%d %d\n", a, b)
}


Measured memory_bytes: 640
mask = (1<<64)-1
a = 0
def test(a,i):
    if a>>i & 1:
        print(1)
    else:
        print(0)
def _set(a,m):
    a = a | mask[m]
    return a
def clear(a,m):
    a = a & ~mask[m]
    return a
def flip(a,m):
    a = a ^ mask[m]  
    return a
def _all(a,m):
    if a & mask[m] == mask[m]:
        print(1)
    else:
        print(0)
def _any(a,m):
    if a&mask[m] == 0:
        print(0)
    else:
        print(1)
def none(a,m):
    if a & mask[m] == 0:
        print(1)
    else:
        print(0)
def count(a,m):
    print(bin(a&mask[m]).count('1'))
def val(a, m):
    return a & mask[m]
n = int(input())
mask = []
for i in range(n):
    ans = 0
    s, *ma = map(int,input().split())
    for i in ma:
        ans = ans | (1<<i)
    mask += [ans]
q = int(input())
for i in range(q):
    s, *t = map(int, input().split())
    if s == 0:test(a,t[0])
    if s == 1:a = _set(a,t[0])
    if s == 2:a = clear(a,t[0])
    if s == 3:a = flip(a,t[0])
    if s == 4:_all(a,t[0])
    if s == 5:_any(a,t[0])
    if s == 6:none(a, t[0])
    if s == 7:count(a,t[0])
    if s == 8:print(val(a,t[0]))



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

ll mod_pow(ll a, ll b, ll m){
    ll res = 1;
    while(b){
        if(b&1){
            res = a*res % m;
        }
        a = a*a % m;
        b /= 2;
    }
    return res;
}

string s;
int n;
ll mem[100100][2];
ll mod = 1000000007;
ll dp(ll at, bool same){
    if(at >= n){
        return 1;
    }
    if(mem[at][same] != -1) return mem[at][same];
    ll sm = 0;
    sm = (sm + dp(at+1, (s[at] == '0') && same)) % mod;
    if(s[at] == '1' || !same){
        sm = (sm + 2*dp(at+1,(s[at] == '1') && same)) % mod;
    }
    return mem[at][same] = sm % mod;
}

int main(){
    cin >> s;
    memset(mem,-1,sizeof(mem));
    n = s.size();
    cout << dp(0,1) << endl;
    return 0;
}

/*int n, half;
vector<double> prob;
int dp(int at, int al){
    if(at == n-1){
        if(al >= half) return prop[at];
        else return 0;
    }
    return prob[at]*dp(at+1, al+1)+(1-prob[at])*dp(at+1, al);
}

int main(){
    cin.sync_with_stdio(false);
    cin >> n;
    half = n/2;
    prob = vector<double>(n);
    rep(i,0,n) cin >> prob[i];
    cout << dp(0,0) << endl;
    return 0;
}*/


Measured memory_bytes: 8320
#include <iostream>

int main() {
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;

  int count = 0;
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        if (500 * i + 100 * j + 50 * k == x) ++count;
      }
    }
  }
  std::cout << count << std::endl;
}


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

#define abs(a) (((a) < 0) ? (-(a)) : (a))
#define min(a,b) (((a) >(b)) ? (b) : (a))
int main(void) {
    int64_t N,K;
    int64_t sum = 0;
    int64_t x;

    cin >> N >> K;

    for(int i=0;i<N;i++) {
        cin >> x;
        if(abs(K-x) < x) {
            sum += (abs(K-x) * 2);
        } else {
            sum += (x * 2);
        }
    }

    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256
import math

# 2数を受け取って最小公倍数を返す関数
#最大公約数
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

#最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)

a, b = map(int, input().split())
print(lcm(a, b))

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int x;
    cin>>x;
    if(400 <= x and x <= 599)cout << "8" << endl;
    else if(600 <= x and x <= 799)cout << "7" << endl;
    else if(800 <= x and x <= 999)cout << "6" << endl;
    else if(1000 <= x and x <= 1199)cout << "5" << endl;
    else if(1200 <= x and x <= 1399)cout << "4" << endl;
    else if(1400 <= x and x <= 1599)cout << "3" << endl;
    else if(1600 <= x and x <= 1799)cout << "2" << endl;
    else cout << "1" << endl;
    return 0;
    
}

Measured memory_bytes: 3648
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif

        ll n, q;
        string s;
        cin >> n >> q >> s;
        char t[q], d[q];
        rep(i, q) cin >> t[i] >> d[i];

        // solve
        ll il = 0, ir = n - 1;
        repr(i, q) {
            if (il < n && t[i] == s[il] && d[i] == 'L') il++;
            if (il > 0 && t[i] == s[il - 1] && d[i] == 'R') il--;
            if (ir >= 0 && t[i] == s[ir] && d[i] == 'R') ir--;
            if (il < n - 1 && t[i] == s[ir + 1] && d[i] == 'L') ir++;
        }
        cout << max(0LL, ir - il + 1) << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x = c/b;
  int y = a/d;
  if(c%b > 0) x++;
  if(a%d > 0) y++;
  
  if(x <= y) cout << "Yes" << endl;
  else cout << "No" << endl;  
  
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
int main(){
  char a[2], b[2];
 
  scanf("%s%s", a, b);
 
  if(strcmp(a, b) == 0){
    printf("H");
  }else{
    printf("D");
  }
 
  printf("\n");
  
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/dp/tasks/dp_r

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

static const long long mod = 1000000007;

vector<vector<long long>> mat_mult(const vector<vector<long long>>& lhs, const vector<vector<long long>>& rhs) {
	vector<vector<long long>> res(lhs.size(), vector<long long>(rhs[0].size()));
	for (int r = 0; r < lhs.size(); r++) {
		for (int c = 0; c < rhs[0].size(); c++) {
			for (int ir = 0; ir < rhs.size(); ir++) {
				res[r][c] = (res[r][c] + (lhs[r][ir] * rhs[ir][c]) % mod) % mod;
			}
		}
	}
	return res;
}

vector<vector<long long>> mat_pow(const vector<vector<long long>>& mat, long long pow) {
	if (pow == 1) return mat;
	auto result = mat_pow(mat, pow / 2);
	result = mat_mult(result, result);
	if (pow & 1) {
		result = mat_mult(result, mat);
	}
	return result;
}

int main (int argc, char* argv[]) {
	long long n, k;
	cin >> n >> k;

	vector<vector<long long>> g(n, vector<long long>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> g[i][j];
		}
	}

	auto res_mat = mat_pow(g, k);

	long long res = 0;
	for (const auto& r : res_mat) {
		for (long long p : r) {
			res = (res + p) % mod;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256