akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long M, long[] A, long[] B) {
    auto uf = UnionFind(N + 1);
    long inc = N * (N - 1) / 2;
    auto ans = new long[](M);

    foreach_reverse (i; 0 .. M) {
        ans[i] = inc;
        if (!uf.haveSameRoot(A[i], B[i]))
            inc -= uf.getSize(A[i]) * uf.getSize(B[i]);
        uf.unite(A[i], B[i]);
    }

    ans.map!(to!string).each!writeln;
}


struct UnionFind {
private:
    long[] rank;
    long[] size;
    long[] par;

public:
    this(long n) {
        rank = repeat(0L).take(n).array;
        size = repeat(1L).take(n).array;
        par = iota(n).array;
    }

    long getRoot(long n) {
        return par[n] = (par[n] == n ? n : getRoot(par[n]));
    }

    long getSize(long n) {
        return size[getRoot(n)];
    }

    bool unite(long n1, long n2) {
        n1 = getRoot(n1);
        n2 = getRoot(n2);
        if (n1 == n2)
            return false;

        long subTreeRoot = rank[n1] < rank[n2] ? n1 : n2;
        long newRoot = rank[n1] < rank[n2] ? n2 : n1;

        par[subTreeRoot] = newRoot;
        size[newRoot] = size[n1] + size[n2];

        if (rank[n1] == rank[n2])
            rank[n1]++;
        return true;
    }

    bool haveSameRoot(long n1, long n2) {
        return getRoot(n1) == getRoot(n2);
    }

    long countRoots() {
        long roots;
        foreach (i, v; par)
            if (getRoot(v) == i)
                roots++;
        return roots;
    }
}



void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long M;
    M = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (M));
    long[] B = new long[](cast(size_t) (M));
    foreach (i; 0 .. cast(size_t) (M)) {
        A[i] = input.front.to!long;
        input.popFront;
        B[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, M, A, B);
    else
        solve(N, M, A, B).writeln;
}


Measured memory_bytes: 8444
import java.util.Scanner;
import java.util.Arrays;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    long[] B = new long[N];
    for (int i =0; i<N; i++) {
      A[i] = sc.nextLong();
      B[i] = A[i] - i;
    }
    Arrays.sort(B);
    if (N == 1) {
      System.out.println(0);
      return;
    }
    long c1 = B[N/2 - 1]; 
    long c2 = B[N/2];
    long ans1 =0;long ans2 =0; long ans;
    for (int i =0; i<N; i++) {
      ans1 += Math.abs(B[i] - c1);
    }
    for (int i =0; i<N; i++) {
      ans2 += Math.abs(B[i] - c2);
    }
    ans = Math.min(ans1,ans2);
    System.out.println(ans);
  }
}

Measured memory_bytes: 62532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 1005;

int memo[2*N][N];

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    
	int n;
	cin >> n;

	// vector<int> a(n);
	int mn = inf, sum = 0, st = 0, vr;

	rep(i,n) {
		cin >> vr;
		sum += abs(vr);
		if(vr < 0)
			st ^= 1;
		if(abs(vr) < mn) {
			mn = abs(vr);
		}

	}

	if(st)
		cout << sum - 2*mn << '\n';
	else
		cout << sum << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
using namespace std;

static const int INFTY = INT_MAX;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
int M[110][110] = {};
int color[110];
int d[110];
queue<int> Q;

void bfs(int s) {
  rep(u, n) color[u] = WHITE;
  rep(u, n) d[u] = INFTY;

  color[s] = GRAY;
  d[s] = 0;
  Q.push(s);

  while (!Q.empty()) {
    int u = Q.front(); Q.pop();
    rep(v, n) {
      if (M[u][v] && color[v] == WHITE) {
        color[v] = GRAY;
        d[v] = d[u] + 1;
        Q.push(v);
      }
    }
    color[u] = BLACK;
  }
}

int main() {
  cin >> n;
  rep(i, n) {
    int id, deg;
    cin >> id >> deg;
    --id;    // 0-indexedに直す
    rep(j, deg) {
      int v;
      cin >> v;
      --v;    // 0-indexedに直す
      ++M[id][v];
    }
  }
  bfs(0);
  rep(i, n) {
    cout << i + 1 << " ";
    if (d[i] != INFTY) cout << d[i];
    else cout << -1;
    cout << endl;
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

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

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


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

    int n;
    cin >> n;

    int sum = 0;
    int x;
    for (int i = 1; sum < n; ++i) {
        sum += i;
        x = i;
    }

    int not_playing = sum - n;
    for (int i = 1; i <= x; ++i) {
        if(i != not_playing){
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	long long int w, h;
	cin >> h >> w;

	if (w == 1 || h == 1) cout << 1 << endl;
	else if ((w * h) % 2 == 0) cout << h * w / 2 << endl;
	else cout << h * w / 2 + 1 << endl;
}	

Measured memory_bytes: 256
def chk(l):
    return l[0]*10+l[1]*5+l[2]

n,y=[int(x) for x in input().split()]
y//=1000
n-=y%5
ans=[0,n,y%5]
t=n*2
while t>=0:
    t-=1
    if y==chk(ans):
        break
    elif y>chk(ans) and ans[1]>0:
        ans[1]-=1
        ans[0]+=1
    elif y<chk(ans) and ans[1]>4:
        ans[1]-=5
        ans[2]+=5
    elif y>chk(ans) and ans[2]>0:
        ans[2]-=1
        ans[0]+=1
    elif y<chk(ans) and ans[0]>4:
        ans[0]-=5
        ans[2]+=5
        
if y==chk(ans):
    print(*ans)
else:
    print("-1 -1 -1")


Measured memory_bytes: 3064
n, m = gets.chomp.split.map(&:to_i)
left, right = gets.chomp.split.map(&:to_i)
(m-1).times{
    x, y = gets.chomp.split.map(&:to_i)
    l1, l2 = [left, x].minmax
    r1, r2 = [right, y].minmax
    left, right = l2, r1
    break if left > right
}
puts [right - left + 1, 0].max

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

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

	ll k0 = a - 1;
	if( b - a <= 2 || k <= k0 )
	{
		cout << 1 + k << endl;
	}
	else
	{
		k -= k0;
		ll k1 = k / 2;
		k -= k1 * 2;
		cout << k0 + k + ( b - a ) * k1 + 1 << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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 (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    int N,K;
    cin >> N >> K;
    vector<ll> left, right;
    left.push_back(0);
    right.push_back(0);
    
    rep(i,N){
        ll x;
        cin >> x;
        if (x == 0) {
            K--; // 0はなかったことにする
        }else if(x > 0){
            right.push_back(x);
        }else{
            left.push_back(-x);
        }
    }

    if(K==0) {
        cout << 0 << endl;
        return 0;
    }

    sort(left.begin(), left.end());
    int NL = left.size();
    int NR = right.size();

    ll ans = 100100100100100100LL;

    //左に行って引き返して右
    for(int i=0; i<min(K, NL); i++){
        if (K - i >= NR) continue;

        ll res;
        res = left[i] * 2;
        res += right[max(0, K - i)];

        chmin(ans, res);
    }

    //右に行って引き返して左
    for(int i=0;i<min(K,NR);i++){
        if (K - i >= NL) continue;
        ll res;
        res = right[i]*2;
        res += left[max(0, K - i)];

        chmin(ans, res);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4520
c500 = int(input())
c100 = int(input())
c50 = int(input())
n = int(input())
result = 0

for x in range(c500+1):
    for y in range(c100+1):
        for z in range(c50+1):
            if x * 500 + y *100 + z * 50 == n :
                result += 1
print(result)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){

  string in;
  int sum = 0;
  while(getline(cin,in)){
    int kake = 1;
    for(int i = in.length()-1; i >= 0; i--){
      if(in[i] < '0' || in[i] > '9'){
	kake = 1;
	continue;
      }
      sum += (in[i] - '0') * kake;
      kake *= 10;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int c=sc.nextInt();
        int b[]=new int[m];
        int a[]=new int[m];
        for(int i=0;i<m;i++)b[i]=sc.nextInt();
        int ans=0;
        for(int j=0;j<n;j++) {
        	for(int i=0;i<m;i++) {
        		a[i]=sc.nextInt();
        	}
        	int sum=0;
        	for(int i=0;i<m;i++) {
        		sum+=a[i]*b[i];
        	}
        	if(sum+c>0)ans++;
        }
    	   System.out.println(ans);
    }
    }

Measured memory_bytes: 22356
#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, C;

    scanf("%d %d %d", &a, &b, &C);

    printf("%lf\n", (double)1/2*a*b*sin(C*M_PI/180.0));
    printf("%lf\n", (double)a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*M_PI/180.0)));
    printf("%lf\n", (double)b*sin(C*M_PI/180.0));
    return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const double pi=3.1415926535897;
int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    cout<<fixed<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos((30*h+(m/2)-6*m)/180*pi));
    
}

Measured memory_bytes: 4228
#include <iostream>
#include <map>

using namespace std;

int n,m;
map<int,int> c;
long long ans;

int main() {
    c[0] = 1;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        s = (s+a)%m;
        if (!c.count(s)) {
            c[s] = 1;
        } else {
            ans += c[s];
            c[s]++;
        }
    }
    cout << ans << endl;
}

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

const int MAX = 200;
const int INF = 1000;
const int D_x[4] = { -1,0,1,0 };
const int D_y[4] = { 0,1,0,-1 };

struct Node {
	Node() {
		for (int i = 0; i < 4; i++) {
			child[i] = NULL;
		}
	}
	Node* child[4];
};

void solve(Node* node, int x, int y, int& min_x, int& min_y, int& max_x, int& max_y) {
	min_x = min(x, min_x);
	min_y = min(y, min_y);
	max_x = max(x, max_x);
	max_y = max(y, max_y);

	for (int i = 0; i < 4; i++) {
		if (node->child[i]) {
			solve(node->child[i], x + D_x[i], y + D_y[i], min_x, min_y, max_x, max_y);
		}
	}
}

int main() {
	int N;
	while (true) {
		cin >> N;
		if (N == 0)break;
		Node node[MAX];
		int min_x = INF;
		int min_y = INF;
		int max_x = -INF;
		int max_y = -INF;

		for (int i = 1; i < N; i++) {
			int n, d;
			cin >> n >> d;
			node[n].child[d] = &node[i];
		}

		solve(node, 0, 0, min_x, min_y, max_x, max_y);

		cout << max_x - min_x + 1 << " " << max_y - min_y + 1 << endl;
	}
	return 0;
}

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

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			int k = n - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

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

  typedef pair<int, int64_t> Item;
  vector<Item> items(n, {0, 0});

  for (int i = 0; i < n; i++) {
    cin >> items[i].first;
    cin >> items[i].second;
  }

  vector<int64_t> result_prev(W + 1, 0);
  vector<int64_t> result(W + 1, 0);
  for (Item item: items) {
    swap(result_prev, result);
    for (int i = 0; i < min(item.first, W + 1); i++) {
      result[i] = result_prev[i];
    }
    for (int i = item.first; i <= W; i++) {
      result[i] = max(result_prev[i],
                      result_prev[i - item.first] + item.second);
    }
  }

  cout << result[W] << endl;

  return 0;
}


Measured memory_bytes: 1920
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)
#define all(c) c.begin(), c.end()
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

// O( ( |V| + |E| ) * log|V| )
const int W = 0, B = 1;
//重み付き有効グラフの隣接リスト表現
vector<int> dijkstra(const vector<vector<pair<int, int>>> &g, int s) {
  int n = g.size();
  priority_queue<pair<int, int>> pq; // cost, node
  vector<int> color(n, W), d(n, INF);
  d[s] = 0;
  pq.push(make_pair(0, s));

  while (!pq.empty()) {
    pair<int, int> f(pq.top());
    pq.pop(); // d[v], v
    color[f.second] = B;

    if (d[f.second] < (-1) * f.first)
      continue; // 最小値を取り出し、それが最短でなければ無視

    rep(i, 0, g[f.second].size()) {
      pair<int, int> v(g[f.second][i]);
      if (color[v.first] != B && d[f.second] + v.second < d[v.first]) {
        d[v.first] = d[f.second] + v.second;
        pq.push(make_pair(
            d[v.first] * (-1),
            v.first)); // priority_queueはデフォルトで大きい値を優先するため-1を掛ける
      }
    }
  }
  return d;
}
bool dfs(vector<vector<pair<int,int>>>&adj,map<int,int>&m,int x){

  bool ret=true;

  rep(i,0,adj[x].size()){
    int u=adj[x][i].first;
    int d=adj[x][i].second;
    if(m.count(u)){
      if(m[x]+d!=m[u])return false;
    }
    else {
      m[u]=m[x]+d;
      ret&=dfs(adj,m,u);
    }
  }
  return ret;

}
signed main() {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> adj(N, vector<pair<int, int>>()); // node, cost
  vector<int> l(M), r(M), d(M);
  rep(i, 0, M) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--, r[i]--;
    adj[l[i]].push_back(make_pair(r[i], d[i]));
    adj[r[i]].push_back(make_pair(l[i], -d[i]));
  }
  map<int,int>m;
  bool f=true;
  rep(i,0,N){
    f&=dfs(adj,m,i);
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 25344
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
    cin >> a[i];
  
  vector<int> lmax, rmax;
  lmax.push_back(0);
  rmax.push_back(0);
  int tmp = 0;
  for(int i=0; i<N; i++){
    tmp = max(tmp, a[i]);
    lmax.push_back(tmp);
  }
  tmp = 0;
  for(int i=0; i<N; i++){
    tmp = max(tmp, a[N-1-i]);
    rmax.push_back(tmp);
  }
  for(int i=0; i<N; i++){
    cout << max(lmax[i], rmax[N-1-i]) << endl;
  }
  return 0;
}

Measured memory_bytes: 4084
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	string s;
	cin >> s;

	int a[26];
	memset(a, 0, sizeof a);

	for (int i = 0; i < s.size(); i++) {
		int t = s[i] - 'a';
		a[t]++;
	}

	for (int i = 0; i < 26; i++) {
		if (a[i] % 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


//ll n, k, x, y;
//
//int main()
//{
//	cin >> n >> k >> x >> y;
//
//	if (n <= k) {
//		cout << n * x << endl;
//	}
//	else {
//		cout << k * x + (n - k) * y << endl;
//	}
//
//	return 0;
//}
//







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

int main(){
    int a,b,i;
    char op;
    for(i=0;;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
            printf("%d\n",a+b);
        else if(op=='-')
            printf("%d\n",a-b);
        else if(op=='*')
            printf("%d\n",a*b);
        else if(op=='/')
            printf("%d\n",a/b);
        else if(op=='?')
            break;
    }
    return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k &&e-b<=k &&e-c<=k &&e-d<=k &&d-a<=k &&d-b<=k &&d-c<=k &&c-b<=k &&c-a<=k &&b-a<=k){
	cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string s, t = "keyence";
	cin >> s;

	int bef = 0, bac = 0;

	for (int i = 0; i < 7; i++) {
		if (s[i] == t[i])
			bef++;
		else
			break;
	}


	for (int i = 0; i < 7; i++) {
		if (s[s.size() - i - 1] == t[7 - i - 1])
			bac++;
		else
			break;
	}

	if (bef + bac >= 7) {
		COUT("YES");
	}
	else {
		COUT("NO");
	}

	return 0;
}


Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

int main() {
	int a = input() - 1, b = input() - 1;
	printf("%d\n", (b + a - 1) / a);
}


Measured memory_bytes: 128
import numpy as np
import sys

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

# だいたいpdfの通り
def main():
    l,a,b,md=MI()

    # 数列の要素がk桁になるのがi項目で、k+1桁になるのがj項目
    k=0
    i=0
    ans=[0,a%md,b%md]
    ans=np.array(ans,dtype="i8")
    # 各桁数ごとに処理
    while i<l:
        k+=1
        j=(10**k-a+b-1)//b
        if j<=0:continue
        if j>l:j=l
        # k桁の要素の個数がe
        e=j-i
        # i項目まで連結した整数をans[i],数列のi項目をs[i]とすると
        #                                       [10**k 0 0]
        # [ans[i],s[i],b] = [ans[i-1],s[i-1],b] [  1   1 0]
        #                                       [  0   1 1]
        # 最後の3x3行列をbbとして、e乗すればよいので、繰り返し二乗法でやる
        bb=np.zeros((3,3),dtype="i8")
        bb[0,0]=pow(10,k,md)
        bb[1,0]=bb[1,1]=bb[2,1]=bb[2,2]=1
        while e:
            if e&1:ans=np.dot(ans,bb)%md
            bb=np.dot(bb,bb)%md
            e>>=1
        i=j

    print(ans[0])

main()


Measured memory_bytes: 12524
import java.util.*;

public class Main{
	public static void main(String[] $$) throws Exception {
		Scanner $ = new Scanner(System.in);
		String S = $.next();
		int w = 0;
		for (int i = 0; i < S.length(); i++){
			if (S.substring(i, i + 1).equals("o")) w++;
		}
		w += (15 - S.length());
		if (w > 7) System.out.println("YES");
		else System.out.println("NO");
		/*
		oxoxoxoxoxoxox -> YES
		xxxxxxxx -> NO
		*/
	}
}


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

int first_num(int d,long long N){
  for(int i=0;i<d-1;i++){
    N/=10LL;
  }
  return (int)N;
}

int ans_n(int d,long long N){
  int ret=0;
  for(int i=0;i<d;i++){
    ret+=(int)(N%10LL);
    N/=10LL;
  }
  return ret;
}

int main() {
  long long N;
  cin>>N;
  //Nを文字列としたもの
  string sn = to_string(N);
  //Nの桁数
  int digit = sn.size();
  //Nの最高位の数
  int first_n = first_num(digit,N);
  
  int ans_a = (digit-1)*9+(first_n-1);
  int ans_b = ans_n(digit,N);
  cout<<max(ans_a,ans_b)<<endl;
}


Measured memory_bytes: 3688
#include<iostream>
#include<iomanip>
#include<vector>
#include<cmath>
using namespace std;

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

    double l[n], a[n], b[n];
    for(int i = 0; i < n; i++)  cin >> l[i] >> a[i] >> b[i];

    double ans = 0;
    for(int i = 1; i < 1<<n; i++){
        vector<int> v;
        for(int j = 0; j < 21; j++){
            if((1<<j) & i)  v.push_back(j);
        }
        if(v.size() != m)   continue;

        double tmp = 0;
        for(int j = 0; j < m; j++){
            for(int k = j+1; k < m; k++){
                tmp += pow(l[v[j]]-l[v[k]], 2.0) + pow(a[v[j]]-a[v[k]], 2.0) + pow(b[v[j]]-b[v[k]], 2.0);
            }
        }

        ans = max(ans, tmp);
    }

    cout << fixed << setprecision(18) << ans << endl;

    return 0;
}


Measured memory_bytes: 3292
n = int(input())
A = list(map(int, input().split( )))
mod = 10**9 + 7
#Aたちの最小公倍数をMとすれば
#答えはsum_{i}M/A_{i} (mod 10**9 + 7)
def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

#(A,B,C)の最小公倍数　=(A,B)の最小公倍数とCの最小公倍数を利用すれば簡単そう.
a = 1
c = 0
s = 0
for i in range(n):
  q = lcm(a,A[i])
  s*=q//a
  a = q
  s+=q//A[i]
print(s%mod)



Measured memory_bytes: 10000
n = int(input())
s = list(input())
t = list(input())
count = 0
if s == t:
    print(n)
    exit()
for i in range(n):
    index = 0
    while s[i + index] == t[index]:
        index += 1
        if index + i == n:
            count = max(count, n - i)
            break

print(n * 2 - count)

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

int main()
{
  int N;
  cin >> N;
  int H[N];
  int j = 0;
  int mx = 0;
  for(int i = 0; i < N; i++){
    cin >> H[i];
    if(H[i] >= mx){
      j++;
      mx = H[i];
    }
  }
  printf("%d\n\r", j);
}

    

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

s = ""

while N != 0:
    # Pythonでは負の数を割っても余りが正になる
    # -2で割ったときの"理想的な"余り(0or1になってくれる)は2で割った余りと同じ
    r = int(N % 2)
    # ここは-2
    N = (N - r) / (-2)
    s += str(int(r))

# N=0の時はから文字列が返ってきてしまう
if s == "":
    print(0)
    exit()
else:
    # reverse
    print(s[::-1])


Measured memory_bytes: 9232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define pb push_back

typedef string::const_iterator State;
int ans;
string s;
ll exp(State &begin);


ll bin(State &begin){
	ll ret=0;
	
	while(isdigit(*begin)){
		ret*=2;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}


ll number(State &begin){
	if(*begin=='0'){
		begin++;
		if(isdigit(*begin))throw "number error1";
		else return 0;
	}
	else if(*begin=='1'){
		return bin(begin);
	}else throw "number error2";
	
	assert(1);
	return -1;
}


ll factor(State &begin){
	if( isdigit(*begin) )return number(begin);
	else if(*begin=='-'){
		begin++;
		if(isdigit(*begin)||*begin=='('||*begin=='-') return -1*factor(begin);
		else throw "factor error1";
	}else if(*begin=='('){
		begin++;
		ll ret = exp(begin);
		if(*begin!=')')throw "factor error2";
		begin++;
		return ret;
	}
	else throw "factor error3";
	assert(1);
	return -1;
}


ll term(State &begin){
	ll ret = factor(begin);
	
	if(*begin=='+'||*begin=='-'||*begin=='$'||*begin==')'){
		return ret;
	}
	else if(*begin=='*'){
		begin++;
		return ret*term(begin);
	}
	else throw "term error";
	
	assert(1);
	return -1;
	
}


ll exp(State &begin){
	ll ret = term(begin);
	
	while(1){
		if(*begin=='+'){
			begin++;
			ret+=term(begin);
		}else if(*begin=='-'){
			begin++;
			ret-=term(begin);
		}else if(*begin=='$'||*begin==')'){
			return ret;
		}else throw "exp error";
	}
	
	assert(1);
	return -1;
}


bool isValid(string tmp){
	int eqc=0;
	rep(i,tmp.size())if(tmp[i]=='=')eqc++;
	if(eqc!=1)return false;
	
	string str[2]={};
	bool f=false;
	rep(i,tmp.size()){
		if(tmp[i]=='=')f=true;
		else if(f)str[1]+=tmp[i];
		else str[0]+=tmp[i];
	}
	if(str[0].size()==0||str[1].size()==0)return false;
	
	State b[2];
	ll res[2];
	try{
		rep(i,2){
			str[i] +='$';
			b[i] = str[i].begin();
			res[i] = exp(b[i]);
		}
	}catch(char const* e){ return false; }
	if(res[0]==res[1] && *b[0]=='$'&&*b[1]=='$'){
		return true;
	}else return false;
}


void dfs(string tmp,vector<bool> used){
	char alp='!';
	int pos=-1;
	rep(i,tmp.size()){
		if(isalpha(tmp[i]))alp=tmp[i],pos=i;
	}
	if(pos==-1){ if(isValid(tmp))ans++; return; }
	
	assert(alp!='!');
	string symbols = "01+-*()=";
	rep(i,symbols.size()){
		if(used[i])continue;
		used[i]=true;
		string ntmp = tmp;
		rep(j,ntmp.size()){
			if(ntmp[j]==alp) ntmp[j] = symbols[i];
		}
		dfs(ntmp,used);
		used[i]=false;
	}
}


int main(){
	cin>>s;
	set<char> st;
	vector<char> vs;
	
	rep(i,s.size())st.insert(s[i]);
	for(auto &e:st)vs.pb(e);
	
	int count=0;
	rep(i,vs.size())if(isalpha(vs[i]))count++;
	if(count>8){
		cout<<0<<endl;
		return 0;
	}
	
	ans=0;
	vector<bool> used(8,false);
	dfs(s,used);
	cout<<ans<<endl;
}

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

double n,m,a[999999],sum;
map<int,int>mp;
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		cin>>a[i];a[i]--;
		mp[a[i]]++;
	}
	for(int i=0;i<n;i++)cout<<mp[i]<<endl;
	return 0;
}

Measured memory_bytes: 14592
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int M = 2 * D + 1;
		System.out.println((N + M - 1) / M);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define loop(i ,a,b) for(int i = a;i<b;i++)
#define rloop(i,a,b) for(int i = a ; i>b;i--)
#define loopll(i,a,b) for( long long int i = a; i<b;i++)
#define rloopll(i,a,b) for(long long int i = a; i>b;i--)
#define eb emplace_back
#define pii pair<int ,int>
#define pll pair<ll ,ll>
#define mk make_pair
#define intmin INT_MIN
#define intmax INT_MAX
#define cout(x) cout<<x<<" ";
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}

int mindig(string & s){
    int temp = INT_MAX;
//    int index = -1;
    for(int i = 0;i<s.size() ; i++){
        if(temp > s[i] - '0'){
            temp = s[i] - '0';
//            index = i;
        }
    }
    return temp;
}
//}
ll power(ll base ,ll exp){
    ll ans = 1;
    for(ll i = 1;i<=exp ; i++){
        ans *= base;
    }
    return ans;
}
//}
//
void factor(ll n ,set<ll> &s ){
        ll x = 2;
        while(n!= 1){
            if(n%x == 0){
                s.insert(x);
                n/= x;
            }
            else{
                x++;
            }
        }
    }

bool prime(int n){
    bool ok = true;
    for(int i = 2 ; i*i <= n ; i++){
        if(n%i == 0){ok =false ; break;}
    }
    return ok;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  int h,w;
  cin>>h>>w;
  vector<string> v;
  for(int i = 0;i<h;i++){
    string t;
    cin>>t;
    v.eb(t);
  }
  int mod = 1e9 + 7;
  vector<vector<int>> dp(h , vector<int>(w , 0));
//  cout<<dp[0][0] << " "<< dp[1][1]<<endl;
  for(int i = 0;i<h;i++){
    for(int j = 0;j<w;j++){
        if(i == 0){
            if(j == 0){
                dp[i][j] = 1;
            }
            else if(v[i][j] == '.'){
                dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
            }
        }
        else{
            if(j == 0 && v[i][j] == '.'){
                dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
            }
            else{
                if(v[i][j] == '.'){
                    dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1])%mod;
                }
            }
        }
    }
  }
  cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 8172
//
// Created by 李青坪 on 2018/12/5.
//

#include <cmath>
#include <cstdio>
#include <algorithm>

#define EPSLON 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPSLON)

using namespace std;

// 点
class Point {
public:
    double x;
    double y;

    Point() {}

    Point(double x, double y) : x(x), y(y) {}

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

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

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

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

    double norm() {
        return x * x + y * y;
    }

    double absVector() {
        return sqrt(norm());
    }

    bool operator==(Point a) const {
        return equals(x, a.x) && equals(y, a.y);
    }
};

typedef Point Vector;

// 线段
class Segment {
public:
    Point a, b;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

Point getCrossPoint(Segment s1, Segment s2) {
    Vector base = s2.b - s2.a;
    double d1 = abs(cross(base, s1.a - s2.a)) / base.absVector();
    double d2 = abs(cross(base, s1.b - s2.b)) / base.absVector();
    double t = d1 / (d1 + d2);
    return s1.a + (s1.b - s1.a) * t;
}

int n;


int main() {
    Segment s[2];
    Point p[4];
    scanf("%d", &n);
    Point point;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 4; ++j) {
            double x, y;
            scanf("%lf %lf", &x, &y);
            point = Point(x, y);
            p[j] = point;
        }
        s[0].a = p[0];
        s[0].b = p[1];
        s[1].a = p[2];
        s[1].b = p[3];
        Point re = getCrossPoint(s[0], s[1]);
        printf("%.10lf %.10lf\n", re.x, re.y);
    }
}
/*
3
0 0 2 0 1 1 1 -1
0 0 1 1 0 1 1 0
0 0 1 1 1 0 0 1

 */


Measured memory_bytes: 2760
#include <iostream>
#include <vector>
#include <numeric>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

using Graph = vector<vector<int>>;
int ans = 0;

bool check(vector<int> dist)
{
    for (int d : dist) {
        if (d == -1)
            return false;
    }
    return true;
}

void dfs(Graph G, vector<int> dist, int now)
{
    if (check(dist)) {
        ++ans;
        return;
    }

    for (auto next : G[now]) {
        if (dist[next] == 1) continue;
        dist[next] = 1;
        dfs(G, dist, next);
        dist[next] = -1;
    }
}

int main()
{
    int N, M; cin >> N >> M;
    Graph G(N);
    rep (i, 0, M) {
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1);
    dist[0] = 1;
    dfs(G, dist, 0);
    cout << ans << endl;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

void solve() {
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vt<vt<int>> dp(n + 1, vt<int>(m + 1));
    vt<vt<pii>> from(n + 1, vt<pii>(m + 1));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int l = dp[i + 1][j], u = dp[i][j + 1],
                lu = s[i] == t[j] ? dp[i][j] + 1 : -1,
                &cur = dp[i + 1][j + 1];
            pii &fr = from[i + 1][j + 1];
            if (lu >= l && lu >= u) {
                cur = lu;
                fr = {i, j};
            } else if (l > u) {
                cur = l;
                fr = {i + 1, j};
            } else {
                cur = u;
                fr = {i, j + 1};
            }
        }
    }

    string ans;
    for (pii cur = {n, m}, fr = from[cur.fi][cur.se];
            cur.fi;
            cur = fr, fr = from[cur.fi][cur.se]) {
        if (fr == pii{cur.fi - 1, cur.se - 1}) {
            ans += s[cur.fi - 1];
        }
    }

    reverse(all(ans));
    cout << ans;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 108972
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll mod = 1000003;

ll __pow(ll a, ll b) { return b ? (b & 1 ? a : 1) * __pow(a * a % mod, b / 2) % mod : 1; }
ll rev(ll a) { return __pow(a, mod - 2); }

int main() {
    V<ll> fact(mod + 10, 1);
    for(ll i = 1; i < fact.size(); i++) fact[i] = i * fact[i - 1] % mod;

    ll Q;
    cin >> Q;
    while(Q--) {
        ll b, a, n;
        cin >> b >> a >> n;
        if(a == 0) {
            cout << __pow(b, n) << endl;
            continue;
        }
        ll b_div_a = b * rev(a) % mod;
        ll val = (n + b_div_a - 1) % mod;
        if(n / mod >= 1) {
            cout << 0 << endl;
            continue;
        }
        // [l, r]
        if(val - n > 0) {
            ll ans = fact[val] * rev(fact[val - n]) % mod;
            (ans *= __pow(a, n)) %= mod;
            cout << ans << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long int t[11]={0};
int main()
{
	long long int max,a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);	
	max=a*d;
	t[2]=a*c;
	t[3]=b*c;
	t[4]=b*d;
	for (int i=2;i<=4;i++)
	 if (max<t[i]) max=t[i];
	printf("%lld\n",max);
	return 0;
}

Measured memory_bytes: 3796
#include "string"
#include <iostream>
using namespace std;
int main()
{
	int n,b;
	cin >> n;
	int a[105] = {0};
	for (int i = 1; i <= n; i++) {
		cin >> b;
		a[0] += b;
		if (a[102] < b)a[102] = b;
		//a[i] = b;
	}
	if (a[102] < a[0]-a[102])cout<< "Yes" <<endl;
	else cout << "No" << endl;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int a,b;
        cin>>a>>b;
        cout<<(a*b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
Scanf.scanf "%d" (fun n ->
    let p = Array.init n (fun _ -> Scanf.scanf " %d" (fun p -> p - 1)) in

    let swap a =
        let c = p.(a) in
        p.(a) <- p.(a + 1);
        p.(a + 1) <- c
    in

    let rec loop i acc =
        if i = n - 1 then acc else
            if p.(i) = i then (
                swap i;
                loop (i + 1) (acc + 1)
            ) else if i = n - 2 && p.(i + 1) = i + 1 then (
                swap i;
                loop (i + 1) (acc + 1)
            ) else loop (i + 1) acc
    in
    loop 0 0 |> Printf.printf "%d\n"
)

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

using namespace std;

unsigned long long pow(int a, int n, int m)
{
    if (n == 0)
    {
        return 1;
    }
    if (n % 2 == 0)
    {
        unsigned long long t = pow(a, n / 2, m);
        return (t * t) % m;
    }
    return (a * pow(a, n - 1, m)) % m;
}

unsigned long long invFact[200001];

unsigned long long prod(unsigned long long a, unsigned long long b, unsigned long long m)
{
    return (a * b) % m;
}

int main()
{
    int n, k;
    int m = 1e9 + 7;
    cin >> n >> k;

    unsigned long long factN_1 = 1;
    for (int i = 1; i <= n - 1; i++)
    {
        factN_1 = prod(factN_1, i, m);
    }
    unsigned long long factN = prod(factN_1, n, m);

    invFact[n] = pow(factN, m - 2, m);

    for (int i = n - 1; i >= 0; i--)
    {
        invFact[i] = prod(invFact[i + 1], i + 1, m);
    }

    unsigned long long ans = 0;
    for (int i = 0; i <= min(n - 1, k); i++)
    {
        unsigned long long nCi = prod(prod(factN, invFact[i], m), invFact[n - i], m);
        unsigned long long n_iHi = prod(prod(factN_1, invFact[i], m), invFact[n - i - 1], m);
        ans = (ans + prod(nCi, n_iHi, m)) % m;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a[100020];
int d[100020];
int dfs(int x, int y) {
	int cnt = 0;
	int re = 0;
	for (int i: a[x]) {
		if (i != y) {
			int t = dfs(i, x);
			re += t;
			if (t == 0) {
				cnt++;
			}
		}
	}
	re += max(cnt - 1, 0);
	return re;
}

int fuck(int x, int y, int dep) {
	d[x] = dep;
	for (int i: a[x]) {
		if (i != y) {
			fuck(i, x, dep + 1);
		}
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	fuck(0, -1, 1);
	int maxdistance = -1;
	int maxindex = -1;
	for (int i = 0; i < n; i++) {
		if (d[i] > maxdistance) {
			maxdistance = d[i];
			maxindex = i;
		}
	}
	int z = dfs(maxindex, -1) + 1;
	printf("%d\n", z);
	return 0;
}

Measured memory_bytes: 12416
#include<stdio.h>
int main(void)
{
	int x[4][3][10] = {{0}};
	int n, b, f, r, v;
	int i, j, k;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		x[b-1][f-1][r-1] = x[b-1][f-1][r-1]+v;
		if(x[b-1][f-1][r-1]<0){
			x[b-1][f-1][r-1] = 0;
		}
	}
	for(j=0; j<15; j++){
		for(k=0; k<10; k++){
			if(j==3 || j==7 || j==11){
				printf("##");
			}
			if(j==0 || j==1 || j==2){
				printf(" %d", x[0][j][k]);
			}
			if(j==4 || j==5 || j==6){
				printf(" %d", x[1][j-4][k]);
			}
			if(j==8 || j==9 || j==10){
				printf(" %d", x[2][j-8][k]);
			}
			if(j==12 || j==13 || j==14){
				printf(" %d", x[3][j-12][k]);
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (d >= Math.abs(a - c))
            System.out.println("Yes");
        else if (d >= Math.abs(b - a) && d >= Math.abs(c - b))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 55;

int n, m;
vector<int> g[maxn];
int up[maxn][12];
int timer=0;
int depth[maxn], tin[maxn], tout[maxn];

int a[maxn], b[maxn];

void dfs(int at, int p, int d=0) {
  depth[at]=d;
  up[at][0]=p;
  tin[at]=timer++;
  for (int to: g[at]) {
    if (to == p) continue;
    dfs(to, at, d+1);
  }
  tout[at]=timer++;
}

int lca[maxn][maxn];

int get_lca(int u, int v) {
  if (u == v) {
    return u;
  }
  if (depth[u] < depth[v]) {
    swap(u, v);
  }
  int dx = depth[u] - depth[v];
  for (int j=11; j>=0; j--) {
    if ((dx>>j)&1) {
      u = up[u][j];
    }
  }
  assert(depth[u] == depth[v]);
  if (u == v) return u;

  for (int j=11; j>=0; j--) {
    if (up[u][j] != up[v][j]) {
      u = up[u][j];
      v = up[v][j];
    }
  }

  return up[u][0];

}

int acc[maxn];
int cnt;


int dfs2(int at, int p) {
  int cur = acc[at];
  for (int to: g[at]) {
    if (to==p) continue;
    cur += dfs2(to, at);
  }
  if (cur > 0) cnt++;
  return cur;
}


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  memset(up, -1, sizeof up);

  cin>>n;
  for (int i=0; i<n-1; i++) {
    int u,v; cin>>u>>v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  dfs(0,0);
  
  for (int j=1; j<12; j++) {
    for (int i=0; i<n; i++) {
      up[i][j] = up[up[i][j-1]][j-1];
    }
  }

  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      lca[i][j] = get_lca(i,j);
    }
  }

  cin>>m;
  for (int i=0; i<m; i++) {
    cin>>a[i]>>b[i];
    --a[i]; --b[i];
  }

  ll ans = 0;

  for (int mask=0; mask<(1<<m); mask++) {
    cnt = 0;
    memset(acc, 0, sizeof acc);
    int bits = 0;
    for (int j=0; j<m; j++) {
      if ((mask>>j)&1) {
	acc[a[j]]++;
	acc[b[j]]++;
	acc[lca[a[j]][b[j]]]--;
	acc[lca[a[j]][b[j]]]--;
	bits++;
      }
    }
    dfs2(0,-1);
    int rest = n-1-cnt;
    ll cur = 1LL<<rest;
    if (bits%2==1) {
      ans -= cur;
    } else {
      ans += cur;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
#define $ scanf("%d",&
#define R(i) for(i=0;i<n;++i)
n,i,j,k,a[17][17];long f[1<<17],g[1<<17];
main(){$ n);R(i)R(j)$ a[i][j]);for(;k<1<<n;++k)R(i)if(k>>i&1)R(j)if(k>>j&1)f[k]+=a[i][j];for(--k;~k;--k)g[k]=f[k];for(++k;k<1<<n;++k)for(i=k&k-1;i;i=k&i-1)g[k^i]+f[i]>g[k]&&(g[k]=g[k^i]+f[i]);printf("%ld\n",g[(1<<n)-1]>>1);}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(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: 3608