akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 52;

struct Edge {
  int to;
  ll cost;
  ll time;

  Edge (int to = -1, int cost = -1, ll time = -1) {
    this->to = to;
    this->cost = cost;
    this->time = time;
  }
};

vector<Edge> E[MAX_N];

struct Node {
  int v;
  ll coin;
  ll time;

  Node(int v = -1, ll coin = -1, ll time = -1) {
    this->v = v;
    this->coin = coin;
    this->time = time;
  }

  bool operator>(const Node &n) const {
    return time > n.time;
  }
};

int main() {
  ll N, M, S;
  cin >> N >> M >> S;

  ll u, v, a, b;
  for (int i = 0; i < M; ++i) {
    cin >> u >> v >> a >> b;

    E[u].push_back(Edge(v, a, b));
    E[v].push_back(Edge(u, a, b));
  }

  ll ans[N + 1];
  ll changeRate[N + 1];
  ll changeTime[N + 1];
  ll c, d;
  for (int i = 1; i <= N; ++i) {
    cin >> c >> d;

    ans[i] = LLONG_MAX;
    changeRate[i] = c;
    changeTime[i] = d;
  }

  ll LIMIT = N * 100;

  priority_queue <Node, vector<Node>, greater<Node>> pque;
  pque.push(Node(1, min(LIMIT, S), 0));

  ll minCoins[N + 1][LIMIT + 1];
  bool visited[N + 1][LIMIT + 1];
  memset(visited, false, sizeof(visited));
  int cnt = 0;

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= LIMIT; ++j) {
      minCoins[i][j] = LLONG_MAX;
    }
  }

  while (!pque.empty()) {
    Node node = pque.top();
    pque.pop();

    if (visited[node.v][node.coin]) continue;
    visited[node.v][node.coin] = true;

    if (ans[node.v] > node.time) {
      fprintf(stderr, "%d: v: %d, coin: %lld, time: %lld\n", ++cnt, node.v, node.coin, node.time);
    }

    ans[node.v] = min(ans[node.v], node.time);

    for (int i = 0; i < E[node.v].size(); ++i) {
      Edge edge = E[node.v][i];

      if (node.coin < edge.cost) continue;
      if (visited[edge.to][node.coin - edge.cost]) continue;
      // visited[edge.to][node.coin - edge.cost] = true;
      if (minCoins[edge.to][node.coin - edge.cost] <= node.time + edge.time) continue;
      minCoins[edge.to][node.coin - edge.cost] = node.time + edge.time;

      pque.push(Node(edge.to, node.coin - edge.cost, node.time + edge.time));
    }

    while (node.coin < LIMIT) {
      node.coin += changeRate[node.v];
      node.coin = min(LIMIT, node.coin);
      node.time += changeTime[node.v];

      if (visited[node.v][node.coin]) break;
      // visited[node.v][node.coin] = true;
      if (minCoins[node.v][node.coin] <= node.time) break;
      minCoins[node.v][node.coin] = node.time;

      pque.push(node);
    }
  }

  for (int t = 2; t <= N; ++t) {
    cout << ans[t] << endl;
  }

  return 0;
}


Measured memory_bytes: 30176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

ll a,b,gap,sum = 1;

cin >> a >> b;

gap = b-a;

for (ll  i = 2; i < 499501; i++)
{  
   sum += i;
   if (gap == i)
   {
      cout << sum - b << endl;
   }
   
}





//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
int n,m,a[1<<11][1<<11],w[12][1<<11],f[1<<11];
#define lowbit(x) ((x)&-(x))
#define mid ((l+r)>>1)
void solve(int l,int r,int x,int d){
	if(l==r) return f[l] = d,void();
	if(x&1) solve(l,mid,x-1,d),solve(mid+1,r,x-1,d|(1<<x)); else
	solve(l,mid,x-1,d|(1<<x)),solve(mid+1,r,x-1,d);
}
int main(){
	n = read(),m = read();
	int h = max(n,m);
	rep(i,0,h){
		rep(j,1,1<<h){
			w[h-1-i][j] = lowbit(j)==(1<<i);
		}
	}
//	rep(i,1,1<<h) f[i] = i;
	solve(1,1<<h,h-1,0);
//	Rep(i,1,1<<h) wri(f[i]);puts("");
	Rep(i,1,1<<h) if(f[i]==0){
		rep(j,i,1<<h) f[j] = f[j+1];
		break;
	}
//	Rep(i,1,1<<h) wri(f[i]);puts("");
	rep(i,1,1<<h){
		rep(j,1,1<<h){
			rep(k,0,h) if(lowbit(i)>>k&1){
				a[i][j] |= w[k][j];
			}
		}
	}
	if(n<m){
		rep(i,1,1<<n){
			rep(j,1,1<<m){
				pc(a[i][j]+'0');
			}puts("");
		}
	} else{
		rep(i,1,1<<n){
			rep(j,1,1<<m){
				pc(a[j][i]+'0');
			}puts("");
		}
	}
	return 0;
}




Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);	
	int n; 
	cin >> n;
	int dp[n][3];
	for(int i = 0; i < n; i++){
		cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
	}
	for(int i = 1; i < n; i++){
		dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] += max(dp[i-1][1], dp[i-1][0]);
	}
	cout << max(dp[n-1][1],max(dp[n-1][2],dp[n-1][0]));
	return 0;		
}


Measured memory_bytes: 1408
#include<stdio.h>
int min(int a,int b)
{
	return a<b?a:b;
}
int main(void)
{
	int ans=1,n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		ans+=min(ans,k);
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <cstdio>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int i,N,M;
    double A;
    long long sum;
    priority_queue<double> que;
    cin>>N>>M;
    for(i=1;i<=N;i++)
    {
        scanf("%lf",&A);
        que.push(A);
    }
    for(i=1;i<=M;i++)
    {
        A=que.top();
        que.pop();
        A/=2;
        que.push(A);
    }
    sum=0;
    for(i=1;i<=N;i++)
    {
        A=que.top();
        que.pop();
        sum+=floor(A);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, x;
   cin >> n;
   map<int, int> mp;
   FOR(i, 1, n + 1)
   {
      cin >> x;
      mp[x] = i;
   }
   for (const auto &a : mp)
   {
      cout << a.second << " ";
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;

typedef complex<double> C;

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

C c[21];

void solve() {
  char cc;
  int z = -1;
  while (z++,cin>>c[z].real()>>cc>>c[z].imag());
  z++;
  
  double S = 0;
  REP(i,1,z-1) {
    double a = abs(c[0]-c[i]);
    double b = abs(c[i]-c[i-1]);
    double cc = abs(c[0]-c[i-1]);
    double z = (a+b+cc)/2;
    S += sqrt(z*(z-a)*(z-b)*(z-cc));
  }
  cout<<S<<endl;
}

int main (int argc, char const* argv[]) {
  solve();
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#define MAX_N 100000000

using namespace std;

long long int dp[45][45];

int main(){

   while(1){
        int w,h;
        int i;
        cin>>w>>h;
        if(w==0&&h==0)break;
        for(int i=0;i<45;i++){
            for(int j=0;j<45;j++){
                dp[i][j]=0;
            }
        }
        dp[1][1]=1;
        int n;
        cin>>n;
        int x,y;
        for(i=0;i<n;i++){
            cin>>x>>y;
            dp[x][y]=-1;
        }
        for(int i=0;i<=w;i++){
            for(int j=0;j<=h;j++){
                if(dp[i][j]!=-1){
                    if(dp[i+1][j]!=-1){
                        dp[i+1][j]+=dp[i][j];
                    }
                    if(dp[i][j+1]!=-1){
                        dp[i][j+1]+=dp[i][j];
                    }
                }
               //printf("[%d] [%d] %lld\n",i,j,dp[i][j]);
            }
        }
        printf("%d\n",dp[w][h]);
    }
    return 0;
}

/*#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a,b;
    while( cin >> a >> b , a || b ){
            int n, dp[20][20] = {0};
            dp[1][1] = 1;
            cin >> n;
            for(int i=0 ; i < n ; i++ ){
                int x,y; cin >> x >> y;
                dp[y][x] = -1;
            }
                for(int y=1 ; y <= b ; y++ ){
                        for(int x=1 ; x <= a ; x++ ){
                            if( dp[y][x] != -1 ){
                                if( y != 1 && dp[y-1][x] != -1 ){
                                    dp[y][x] += dp[y-1][x];
                            }
                            if( x != 1 && dp[y][x-1] != -1 ){
                                    dp[y][x] += dp[y][x-1];
                            }
                        }
                    }
                }
            cout<<dp[b][a]<<endl;
        }
    }*/

Measured memory_bytes: 1160
#include <stdio.h>  
#include <string.h>  
#include <stdlib.h>  
#include <iostream>  
#include <algorithm>  
#include <time.h>  
#include<cstdio>
#include<vector>
#include<functional>


using namespace std;

bool cmp(const int x, const int y) {
	return x < y;
}

int a[110];


int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}

	sort(a, a + n, cmp);
	printf("%d", a[n - 1] - a[0]);
	return 0;
}


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

#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;

#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937

const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;

#define MOD 1000000007

typedef long long ll;
const int mx=2e5+125;

ll pr[mx],ar[mx],br[mx];

#define PB push_back
#define endl '\n'
#define S second
#define F first

void solve()
{
   int n;
   cin>>n;
   int ans=0;
   for(int i=1; i<=n; i++)
    ans+=(n-1)/i;
   cout<<ans<<endl;

}
int main()
{
    faster();
    int tc;
    tc=1;
    while(tc--)
        solve();
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int W, H;
int map[50][50], used[50][50];

void walk(int x, int y){
    used[y][x] = 1;
    REP(i, 8){
        int nx = x+dx[i], ny = y+dy[i];
        if(0 <= nx && nx < W && 0 <= ny && ny < H && !used[ny][nx] && map[ny][nx] == 1){
            walk(nx, ny);
        }
    }
}

int main(){
    while(std::cin >> W >> H, W){
        REP(i, H){
            REP(j, W){
                std::cin >> map[i][j];
            }
        }

        REP(i, H){
            REP(j, W){
                used[i][j] = 0;
            }
        }

        int island_n = 0;
        REP(i, H){
            REP(j, W){
                if(map[i][j] == 1 && !used[i][j]){
                    walk(j, i);
                    island_n++;
                }
            }
        }

        std::cout << island_n << std::endl;
    }
}

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

int main(){
    int H, W;
    int i, j;
    while(1){
        cin >> H >> W;
        if(H + W == 0) break;
        for(j = 0; j < W; j++) cout << "#";
        cout << endl;

        for(i = 1; i < H - 1; i++){
            cout << "#";
            for(j = 1; j < W - 1; j++) cout << ".";
            cout << "#" << endl;
        }

        for(j = 0; j < W; j++) cout << "#";
        cout << endl;
        cout << endl;
    };
    return 0;
}
      



Measured memory_bytes: 3084
###
#Train_Ticket
###

a, b, c, d = list(input()) 
op = ['+', '-'] 
for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d) == 7:
                print(str(a+i+b+j+c+k+d)+'=7') 
                exit() 
                
        

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  ll a[n], b[n];
  ll s, ss;
  s = 0;
  ss = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];   
  }  
  for (ll i = 0; i < n; i++) {
    cin >> b[i];
    ss += b[i]; 
  }
  if (s > ss) {
    cout << "No" << endl;
    return 0;  
  }
  ll A = 0;
  ll B = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] < b[i]) {
      // +2できる回数について
      A += (b[i] - a[i]) / 2; 
    }
    if (a[i] > b[i]) {
      B += a[i] - b[i];  
    }
  }
  if (A >= B) {
    cout << "Yes" << endl;
    return 0;  
  }
  cout << "No" << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n = int(input())

l = [2, 1]
#print(l[0], l[1])
for i in range(2, n + 1):
    #print(i)
    l.append(l[i - 1] + l[i - 2])
    #print(l)
print(l[n])


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

struct edge { ll to, cost; };
vector<edge>v[100010];
ll d[100010];

int main() {
	ll k;
	cin >> k;
	for (int i = 0;i < k;i++) {
		v[i].pb(edge{ (i + 1) % k,1 });
		v[i].pb(edge{ (i * 10) % k,0 });
	}
	priority_queue < P, vector<P>, greater<P>>pq;
	for (int i = 0;i < k;i++)d[i] = INF;
	d[1] = 1;
	pq.push(P(1, 1));
	while (!pq.empty()) {
		P a = pq.top();
		pq.pop();
		ll i = a.second;
		if (d[i] < a.first)continue;
		for (auto u : v[i]) {
			edge e = u;
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(P{ d[e.to], e.to });
		}
	}
	cout << d[0] << endl;
	}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a-c)<=d) cout << "Yes" << endl;
    else if(abs(a-b)<=d&&abs(b-c)<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

class Main{
    public static void main(String args[]){
        int dataSet;
        Scanner in = new Scanner(System.in);
        dataSet = in.nextInt();
        for(int i = 0; i < dataSet; i++){
            int[] e = new int[3];
            for(int j = 0; j < 3; j++){
                e[j] = in.nextInt();
            }
            Arrays.sort(e);
            if(e[0] * e[0] + e[1] * e[1] == e[2] * e[2]){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 21800
/*
  A - Addition and Subtraction Easy
  Contest 050
  Rakesh Kumar --> 03/08/2020
 */

#include <bits/stdc++.h>

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

    std::string s;
    std::getline(std::cin, s);
    std::istringstream iss(s);
    int a = 0, b = 0;
    char o = ' ';
    iss >> a >> o >> b;
    if (o == '+')
        std::cout << a + b << std::endl;
    else
        std::cout << a - b << std::endl;

    return 0;
}


Measured memory_bytes: 3640
o=input()
e=input()

a=""

if len(o)!=len(e):
    e+=" "
    for i in range(len(o)):
        a+=o[i]+e[i]
    print(a[:-1])
else:
    for i in range(len(o)):
        a+=o[i]+e[i]
    print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

template <typename T>
class Counter
{
    std::unordered_map<T, std::size_t> m_counter;

public:
    /// 指定キーのカウントを1upする
    void add(const T& the_key)
    {
        auto p = m_counter.find(the_key);
        if (p == m_counter.end())
        {
            m_counter[the_key] = 1;
            return;
        }

        ++(p->second);
    }

    /// 指定キーのカウントをvalueぶん加算する
    void add(const T& the_key, const std::size_t the_value)
    {
        auto p = m_counter.find(the_key);
        if (p == m_counter.end())
        {
            m_counter[the_key] = the_value;
            return;
        }

        p->second += the_value;
    }

    /// 指定キーのカウントを取得
    std::size_t operator[](const T& the_key) const
    {
        auto p = m_counter.find(the_key);
        return (p == m_counter.end()) ? 0 : p->second;
    }

    std::vector<T> keys() const
    {
        std::vector<T> result;
        result.reserve(m_counter.size());

        for (const auto& item : m_counter)
        {
            result.push_back(item.first);
        }

        return result;
    }
};

int main()
{
    int n;
    std::cin >> n;

    Counter<std::string> counter;

    for (int i = 0; i < n; ++i)
    {
        std::string s;
        std::cin >> s;

        counter.add(s);
    }

    const auto keys = counter.keys();

    std::cout << keys.size() << std::endl;

    return 0;
}


Measured memory_bytes: 24064
#include <stdio.h>

int main(void){

	int d;
  	scanf("%d",&d);
  
  	switch(d){
    
      case 22:
        printf("Christmas Eve Eve Eve");
    	break;
      case 23:
        printf("Christmas Eve Eve");
    	break;   
      case 24:
        printf("Christmas Eve");
    	break;
      case 25:
        printf("Christmas");
    	break;
    }
  
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  ll n; cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    if (i%3 == 0 or i%5 == 0) continue;
    ans += i;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,m=map(int,input().split())
a=min(n,m)
b=max(n,m)
if a==1:
    if b==1:
        print(1)
    else:
        print(b-2)
else:
    print((a-2)*(b-2))

Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>

using namespace std;

int gcd(int a, int b) {
  for(int t; t = a % b; a = b, b = t);
  return b;
}

int main() {
  int a, b, g;
  long long l;
  while(scanf("%d%d", &a, &b) != EOF) {
    g = gcd(a, b);
    l = 1ll * a * b / g;
    printf("%d %lld\n", g, l);
  }
  return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int x,y,z,n;
int main()
{
	cin>>x>>y>>z;
    n=x/(y+z);
    if(x-n*(y+z)<z)
		cout<<n-1<<endl;
		else cout<<n<<endl;
	return 0;
	}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int N, M; cin >>N>>M;

    vector<int> X(M); cin >> X;
    sort(all(X));

    vector<int> dX(M-1);
    rep(i, M-1) {
        dX[i] = X[i + 1] - X[i];
    }
    sort(all(dX), greater<int>());

    int ans = accumulate(min(dX.begin() + N - 1, dX.end()), dX.end(), 0);

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(void)
{
  int n; cin>>n;
  int k=1000;
  
  for(;;){
    if(n>k){
      k+=1000;
    }else{
      break;
    }
  }
  
  cout<<k-n<<endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
using namespace std;
int table[501][501],f[500];
int main(){
	int n,m,a,b,c,d,e,i,j,k;
	bool flag;
	while(cin >> n && n){
		c = 0;
		flag = true;
		cin >> m;
		memset(table,0,sizeof(table));
		memset(f,0,sizeof(f));
		for(i = 0;i < m;i++){
			cin >> a >> b;
			table[b][a] = 1;
			table[a][b] = 1;
		}
		for(i = 1;i <= n;i++){
			if(table[1][i] == 1){
				f[c] = i;
				c++;
			}
		}
		if(c > 0){
			d = c;
			for(i = 0;i < d;i++){
				for(j = 2;j <= n;j++){
					if(table[f[i]][j] == 1){
						for(k = 0;k < c;k++){
							if(j == f[k]){
								flag = false;
							}
						}
						if(flag){
							f[c] = j;
							c++;
						}
						flag = true;
					}
				}
			}
		}
		cout << c << endl;
	}
	
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int a,b;

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){
	while(cin>>a>>b){
		if(a>b)cout<<gcd(a,b)<<endl;
		else cout<<gcd(b,a)<<endl;
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define RMAX 4294967295
#define equals(a,b)(fabs((a)-(b))<EPS)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef complex<double> comp;
typedef vector<complex<double>> vcomp;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef string::const_iterator State;
class ParseError {};
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int N, M, R;
vi r;

bool WarshallFloyd(vvi &graph, int V) {
	rep(k, V)rep(i, V)rep(j, V) {
		// i->(k)->j
		if (graph[i][k] != INF && graph[k][j] != INF) {
			graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
		}
	}
	rep(i, V) {
		if (graph[i][i] < 0) return false;
	}
	return true;
}

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

	cin >> N >> M >> R;
	r = vi(R);
	rep(i, R) {
		cin >> r[i];
		r[i]--;
	}
	vvi G(N, vi(N, INF));
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a][b] = G[b][a] = min(G[a][b], c);
	}
	WarshallFloyd(G, N);
	/*
	rep(i, N){
		rep(j, N) {
			cout << G[i][j];
		}
		cout << endl;
	}
	//*/

	vi perm(R);
	rep(i, R)perm[i] = i;

	int ans = INF;
	do {
		int dist = 0;
		rep(i, R - 1) {
			//cout << G[r[perm[i]]][r[perm[i + 1]]] << endl;
			dist += G[r[perm[i]]][r[perm[i + 1]]];
		}
		//cout << dist << endl;
		ans = min(ans, dist);
	} while (next_permutation(all(perm)));

	cout << ans << endl;

	return 0;
}

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

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int n,k; cin >> n >> k;
    vector<bool> d(n+1,false);
    for(int i=0;i<k;i++){
	int a;
	cin >>a;
	for(int j=0;j<a;j++){
	    int s;cin >> s;
	    d[s] = true;
	}
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
	if(d[i]==0)ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int n, k;
int r, s, p;

int f(int hand, char enemy)
{
  if (hand == 0 && enemy == 's') return r;
  if (hand == 1 && enemy == 'p') return s;
  if (hand == 2 && enemy == 'r') return p;

  return 0;
}

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

  cin >> n >> k;
  cin >> r >> s >> p;

  string t;
  cin >> t;

  vector<vector<char>> c(k);
  for (int i = 0; i < n; ++i) c[i % k].emplace_back(t[i]);

  int ans = 0;
  for (int i = 0; i < k; ++i) {
    int siz = c[i].size();

    int dp[siz+1][3];
    memset(dp, 0, sizeof(dp));

    for (int j = 0; j < siz; ++j) {
      for (int before = 0; before < 3; ++before) {
        for (int now = 0; now < 3; ++now) {
          if (now == before) continue;
          dp[j+1][now] = max(dp[j+1][now], dp[j][before] + f(now, c[i][j]));
        }
      }
    }

    ans += *max_element(dp[siz], dp[siz]+3);
  }

  cout << ans << '\n';

  return (0);
}

Measured memory_bytes: 8112
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

int N;
int A[MAX_N + 1];

map<int, int> prime_factors(int nn, map<int, int> &lcmm) {
  map<int, int> mp;
  for (ll i = 2; i * i <= nn; i++) {
    int cnt = 0;
    while (nn % i == 0) {
      cnt++;
      ++mp[i];
      nn /= i;
    }
    if (cnt != 0) lcmm[i] = max(lcmm[i], cnt);
  }
  if (nn != 1) {
    mp[nn]++;
    lcmm[nn] = max(lcmm[nn], mp[nn]);
  }
  return mp;
}

ll modpow(ll x, ll n) {
  const ll m = MOD;
  ll res = 1;
  while (n > 0) {
    if (n % 2 == 1) res = (res * x) % m;
    x = (x * x) % m;
    n >>= 1;
  }
  return res % m;
}

// clang-format off
const int mod = MOD;
inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
// clang-format on

ll modmul(map<int, int> mp) {
  ll res = 1;
  for (auto m : mp) {
    res = modMul(res, modpow(m.first, m.second));
  }
  return res;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i, N) cin >> A[i];

  map<int, int> lcmm;
  vector<map<int, int>> aprimes(N);
  ll lc = 1;
  ll ans = 0;
  REP(i, N) {                                // N = 10^4
    aprimes[i] = prime_factors(A[i], lcmm);  // N * √A = 10^4 * 10^2 = 10^6
  }

  ll L = modmul(lcmm);

  REP(i, N) {  //
    // lcmm と arpimes[i] をそれぞれ計算していけばよい
    ans = modAdd(ans, modDiv(L, A[i]));  // 10^4 * divmp (10^5) = 10^9
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int a[101][101],start[101],end[101],n,p=0,v[101];
void dfs(int u){
    if(!v[u]){v[u]++;
    start[u]=++p;
    r(i,1,n+1)if(a[u][i])dfs(i);
    end[u]=++p;}
}
int main(){
    int q,qq,qqq;
    cin>>n;
    r(i,0,n){cin>>q>>qq;
        r(i,0,qq){cin>>qqq;
            a[q][qqq]++;
        }
    }
    r(i,1,n+1)if(!v[i])dfs(i);
    r(i,1,n+1)cout<<i<<' '<<start[i]<<' '<<end[i]<<endl;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define PB push_back
#define F first
#define S second
#define MP make_pair
int main(){
    vector<pair<double,int>> v[3],all;
    pair<double,int> temp;
    for(int i=0;i<3;i++){
        for(int j=0;j<8;j++){
            scanf("%d%lf",&temp.S,&temp.F);
            v[i].PB(temp);
        }
        sort(v[i].begin(),v[i].end());
        for(int j=0;j<2;j++)printf("%d %.2lf\n",v[i][j].S,v[i][j].F);
        for(int j=2;j<8;j++)all.PB(v[i][j]);
    }
    sort(all.begin(),all.end());
    for(int i=0;i<2;i++)printf("%d %.2lf\n",all[i].S,all[i].F);
}


Measured memory_bytes: 2596
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

  string p;
  for (ll i = 0; i < s.size(); i++)
  {
    if (s[i] + n > 'Z') {
      s[i] -= 26;
    }
    p.push_back(s[i] + n);
  }
  cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

ll pw[1010];
ll x;

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //ifstream cin ("test.in");
    //ofstream cout ("test.out");
	cin >> x;
	for (int i=1; i<=1000; i++)
		pw[i] = 1LL * i * i * i * i * i;
	for (int i=0; i<=1000; i++){
		for (int j=0; j<=1000; j++){
			//cout << pw[i] << ' ' << pw[j] << '\n';
			if (pw[i] - pw[j] == x){
				cout << i << ' ' << j << '\n';
				return 0;
			}
			if (pw[i] + pw[j] == x){
				cout << i << ' ' << -j << '\n';
				return 0;
			}
		}
	}
	assert(false);
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main()
{
    int n, sum=0, temp, i;
    scanf("%d", &n);
    i=0;
    while(i<n)
    {
        scanf("%d", &temp);
        sum += temp;
        i++;
    }
    sum = sum-n;
    printf("%d\n", sum);
}




Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j;

void solve() {
    ll n;
    cin>>n;

    int dp[11][11];
    fo(i,0,10) {
        fo(j,0,10) dp[i][j] = 0;
    }

    fo(i,1,n+1) {
        int ls = i%10;
        int sz = log10(i);
        int fs = i / pow(10,sz);
        dp[fs][ls]++;
    }

    ll ans = 0;

    fo(i,1,10) {
        fo(j,1,10) {
            ans+=(dp[i][j] * dp[j][i]);
        }
    }
    cout<<ans<<"\n";
}

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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




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

int main(){
  int n;
  cin>>n;
  bool ad=false;
  vector<string>w(n);
  for(int i=0;i<n;i++){
    cin>>w[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(w[i]==w[j]){
        ad=true;
        break;
      }
    }
    if(ad) break;
  }
  for(int i=0;i<n-1;i++){
    if(w[i].back()!=w[i+1].front()){
      ad=true;
      break;
    }
  }
  if(ad) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}
  
        
  


Measured memory_bytes: 256
import java.util.*;
// import java.io.*;

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

        int num = sc.nextInt();

        ArrayList<Point> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            array.add(new Point(sc.nextInt(), sc.nextInt()));
        }

        Collections.sort(array, Comparator.comparing(Point::getX)
            .thenComparing(Point::getY));

        for (int i = 0; i < array.size(); i++) {
            sb.append(String.format("%d %d\n", array.get(i).x, array.get(i).y));
            // if (i != array.size() - 1) sb.append(' ');
        }

        System.out.print(sb);
        
        sc.close();
    }

    static class Point {
        int x, y;
        Point(int a, int b) { x = a; y = b; }
        int getY() { return y; }
        int getX() { return x; }
    }
}



Measured memory_bytes: 184316
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h = {};
    REP(i, n){ int x; cin >> x; h.push_back(x); }
    int ans = 0;
    REP(i, n){
        bool flg = true;
        REP(j, i){
            if(h[j]>h[i])flg = false;
        }
        if(flg)++ans;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
    string a,b;
    bool x=false;
    cin >> a >> b;
    int n=stoi(a+b);
    rep(i,317){
        if((i*i)==n) x=true;
    }
    cout << (x?"Yes\n":"No\n");
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s; cin >> s;
  int now = 0;
  for(int i=0;i<4;++i) {
    if(s[i] == '+') {
      now++;
    } else {
      now--;
    }
  }
  cout << now << endl;
}


Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let r = get!(u64);
    println!("{}", 3 * r * r);
}


Measured memory_bytes: 8572
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto N = readln.chomp.to!long;
    long result;
    foreach (n; 1 .. N + 1)
    {
        long cnt;
        if (n % 2 == 0)
        {
            continue;
        }
        foreach (k; 1 .. n + 1)
            if (n % k == 0)
            {
                cnt++;
            }
        if (cnt == 8)
        {
            result++;
        }
    }
    result.writeln;
}


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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy"<<endl;
    else if(s == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
    
    return 0;
    
}

Measured memory_bytes: 888
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	}
}

Measured memory_bytes: 99164
#include<stdio.h>

int partition(int *,int,int);

int main(){
  int i,n,A[100000],q;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  q=partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");
  return 0;
}

int partition(int *A,int p,int r){
  int x,i,j,a;
  x=A[r];
  i=p-1;
  for(j=0;j<r;j++){
    if(A[j]<=x){
      i++;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  a=A[i+1];
  A[i+1]=A[r];
  A[r]=a;
  return i+1;
}



Measured memory_bytes: 2120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	int n;
	cin >> n;
	int arr[n];
	for (int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	int prevmin = arr[0];
	int count = 1;
	for (int i=0;i<n;i++)
	{
		if (prevmin > arr[i])
		{
			prevmin = arr[i];
			count++;
		}
	}
	cout << count;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
using namespace std;
signed main() {
    int n, m;
    cin >> n >> m;
    cout << min(n % m, abs(n % m - m)) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    n, d, a = map(int, input().split())
    XH = []
    for i in range(n):
        x, h = map(int, input().split())
        XH.append((x, h))

    XH.sort()
    from collections import deque
    q = deque()

    ans = 0
    t = 0
    import copy
    for x, h in XH:
        while q:
            r, s = q.popleft()
            if r+d < x:
                t -= s
            else:
                q.appendleft((r, s))
                break
        h -= t
        if h > 0:
            if h%a == 0:
                b = h//a
                ans += b
                t += a*b
                q.append((x+d, a*b))
            else:
                b = h//a+1
                ans += b
                t += a*b
                q.append((x+d, a*b))
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
		
	for(int i=1; i<=9; i++){
		cout << "1x" << i << "=" << i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "2x" << i << "=" << 2*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "3x" << i << "=" << 3*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "4x" << i << "=" << 4*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "5x" << i << "=" << 5*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "6x" << i << "=" << 6*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "7x" << i << "=" << 7*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "8x" << i << "=" << 8*i << endl;
	}
	for(int i=1; i<=9; i++){
		cout << "9x" << i << "=" << 9*i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
# coding: utf-8
# Your code here!

n = int(input())
lo = []
sh = []

result = 0

MAX = -(10**20)

for i in range(n):
    a,b =map(int, input().split())
    lo.append(a-b)
    sh.append(a+b)
    
c=zip(lo,sh)
d = sorted(c, key=lambda x:x[1])

for i in range(n):
    if MAX <= d[i][0]:
        result += 1
        MAX=d[i][1]

print(result)

Measured memory_bytes: 19804
import sys
import numpy as np
n,m = [int(x) for x in sys.stdin.readline().split()]
r = np.zeros(n)
for i in range(m):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += 1
	r[b-1] += 1
for i in range(n):
	print(int(r[i]))

Measured memory_bytes: 21660
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
int main() {
	string s;
	int cnt = 0;
	cin >> s;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] == s[i + 1] && s[i] == '0') {
			s[i + 1] = '1';
			cnt++;
		}
		else if (s[i] == s[i + 1] && s[i] == '1') {
			s[i + 1] = '0';
			cnt++;
		}

	}
	cout << cnt << endl;
	return 0;

}

Measured memory_bytes: 3736
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m,ans=1; cin>>n>>m;
    if(abs(n-m)>1) cout<<0<<endl;
    else if(abs(n-m)==1){
        rep(i,n) ans=(ans*(i+1))%MOD;
        rep(i,m) ans=(ans*(i+1))%MOD;
        cout<<ans<<endl;
    }
    else{
        rep(i,n) ans=(ans*(i+1))%MOD;
        rep(i,m) ans=(ans*(i+1))%MOD;
        cout<<(ans*2)%MOD<<endl;
    }
}


Measured memory_bytes: 256