akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	for i := 1; i <= 3; i++ {
		if i != a && i != b {
			fmt.Printf("%d\n", i)
			os.Exit(0)
		}
	}
}


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

int abs(int a){
 return a > 0? a: -a;
}

int main(){
 unsigned N, M;
 int *a, *b, *c, *d;
 unsigned ml, m, l;

 scanf("%d%d", &N, &M);
 a = (int *)malloc(sizeof(int) * N);
 b = (int *)malloc(sizeof(int) * N);
 c = (int *)malloc(sizeof(int) * M);
 d = (int *)malloc(sizeof(int) * M);
 for(unsigned i = 0; i < N; i++) scanf("%d%d", a + i, b + i);
 for(unsigned i = 0; i < M; i++) scanf("%d%d", c + i, d + i);

 for(unsigned i = 0; i < N; i++){
  ml = unsigned(-1);
  for(unsigned j = 0; j < M; j++){
   l = abs(a[i] - c[j]) + abs(b[i] - d[j]);
   if(ml > l){
    ml = l;
    m = j;
   }
  }
  printf("%d\n", m + 1);
 }
}

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

using namespace std;


template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
struct StronglyConnectedComponents {
  const G &g;
  UnWeightedGraph gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return comp[k];
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(UnWeightedGraph &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) continue;
        t[x].push_back(y);
      }
    }
  }
};

const int INF = 1 << 30;


int main() {
  int N, M, C[100000];
  cin >> N >> M;
  for(int i = 0; i < N; i++) cin >> C[i];
  UnWeightedGraph g(N * 2);
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a *= 2;
    b *= 2;
    for(int j = 0; j < 2; j++) {
      g[a + j].emplace_back(b + (j + 1) % 2);
    }
  }
  StronglyConnectedComponents< UnWeightedGraph > scc(g);
  UnWeightedGraph t;
  scc.build(t);
  int belong[200000] = {};
  for(int i = 0; i < N; i++) belong[scc[2 * i]] += C[i];
  vector< int > dp(t.size(), -INF);
  dp[scc[0]] = belong[scc[0]];
  for(int i = 0; i < t.size(); i++) {
    for(auto &p : t[i]) dp[p] = max(dp[p], dp[i] + belong[p]);
  }
  cout << *max_element(begin(dp), end(dp)) << endl;
}




Measured memory_bytes: 53232
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'


int main() {
	#ifndef ONLINE_JUDGE
	//freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	vector<ll> nums(n);
	for_(i, 0, n) cin >> nums[i];
	ll ans = 0, mx = nums[0];
	for_(i, 1, n) {
		if (nums[i] < mx) {
			ans += mx-nums[i];
		}
		mx = max(mx, nums[i]);
	}
	
	cout<<ans << endl;

	return 0;
}


Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<ll>> v(R, vector<ll>(C, -1));
    for(int i = 0; i < K; i++) {
        int r, c;
        ll val;
        cin >> r >> c >> val;
        v[r - 1][c - 1] = val;
    }
    vector dp(R, vector(C, vector(4, 0LL)));
    if(v[0][0] != -1) {
        dp[0][0][1] = v[0][0];
    }
    for(int i = 0; i < R; i++) {
        for(int j = 0; j < C; j++) {
            for(int cnt = 0; cnt <= 3; cnt++) {
                if(i + 1 < R) {
                    chmax(dp[i + 1][j][0], dp[i][j][cnt]);
                    if(v[i + 1][j] != -1) {
                        chmax(dp[i + 1][j][1], dp[i][j][cnt] + v[i + 1][j]);
                    }
                }
                if(j + 1 < C) {
                    chmax(dp[i][j + 1][cnt], dp[i][j][cnt]);
                    if(cnt < 3 && v[i][j + 1] != -1) {
                        chmax(dp[i][j + 1][cnt + 1],
                              dp[i][j][cnt] + v[i][j + 1]);
                    }
                }
            }
        }
    }
    ll ans = -LLINF;
    for(int i = 0; i <= 3; i++) {
        chmax(ans, dp[R - 1][C - 1][i]);
    }
    cout << ans << endl;
}

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

using namespace std;

int R,C,N; 
vector<pair<int,int> >p;
int s[100010];

int trans(int x,int y)
{
	if (x>0 && x<R && y>0 && y<C) return -1;
	if (y==0) return x;
	if (x==R) return R+y;
	if (y==C) return R+C+(R-x);
	//x=0
	return 2*R+2*C-y;
}

bool vis[100010];

int main()
{
	scanf("%d%d%d",&R,&C,&N);
	for (int i=1;i<=N;i++)
	{
		int x,y,p1,p2;
		scanf("%d%d",&x,&y);
		p1 = trans(x,y);
		scanf("%d%d",&x,&y);
		p2 = trans(x,y);
		//printf("AFT: %d %d\n",p1,p2);
		if (p1==-1 && p2==-1) continue;
		if (p1 < p2) swap(p1,p2);
		if (p1==-1 || p2==-1)
		{
			//printf("%d %d x2\n",p1,i);
			p.push_back(make_pair(p1,i));
			p.push_back(make_pair(p1,i));
		}
		else
		{
			//printf("%d %d %d %d\n",p1,i,p2,i);
			p.push_back(make_pair(p1,i));
			p.push_back(make_pair(p2,i));
		}
	}
	sort(p.begin(),p.end());
	int M = p.size()-1;
	memset(vis,false,sizeof(vis));
	int cnt = 0;
	bool ok = true;
	for (int i=0;i<=M;i++)
	{
		int pos = p[i].first, num = p[i].second;
		//printf("%d %d\n",pos,num);
		if (vis[num])
		{
			if (cnt != s[num])
			{
				//puts("HERE!");
				ok = false;
			}
			cnt--;
		}
		else
		{
			vis[num] = true;
			s[num] = ++cnt;
		}
		//printf("cnt = %d\n",cnt);
	}
	puts(ok?"YES":"NO");
}

Measured memory_bytes: 2420
//01
#include<iostream>
#include<complex>
#include<algorithm>
#include<set>
#include<cmath>

using namespace std;

typedef complex<double> P;

double cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

struct R{
  P p[4];
  bool in(R a){
    for(int i=0;i<4;i++){
      bool sn[2]={};
      for(int j=0;j<4;j++){
	double c=cr(a.p[i]-p[j],p[(j+1)%4]-p[j]);
	if(fabs(c)>1e-9){
	  sn[c<0]=true;
	}
      }
      if(sn[0]&&sn[1])return false;
    }
    return true;
  }
};

int pr[100];

int find(int x){
  return (x==pr[x])?x:pr[x]=find(pr[x]);
}

void unite(int a,int b){
  pr[find(a)]=find(b);
}

bool ois(double a,double b,double c,double d){
  if(a>b){
    swap(a,b);
  }
  if(c>d){
    swap(c,d);
  }
  return d-a>-1e-9&&b-c>-1e-9;
}

int main(){
  for(int t;cin>>t,t;){
    while(t--){
      int n;
      cin>>n;
      R p[100];
      for(int i=0;i<n;i++){
	pr[i]=i;
      }
      for(int i=0;i<n;i++){
	for(int j=0;j<4;j++){
	  int x,y;
	  cin>>x>>y;
	  p[i].p[j]=P(x,y);
	}
	for(int j=0;j<i;j++){
	  if(p[i].in(p[j])||p[j].in(p[i]))goto con;
	  for(int k=0;k<4;k++){
	    P a=p[i].p[k],b=p[i].p[(k+1)%4];
	    for(int l=0;l<4;l++){
	      P c=p[j].p[l],d=p[j].p[(l+1)%4];
	      if(!ois(a.real(),b.real(),c.real(),d.real())
		 ||!ois(a.imag(),b.imag(),c.imag(),d.imag()))continue;
	      if(cr(a-b,c-b)*cr(a-b,d-b)<=1e-9&&cr(c-d,a-d)*cr(c-d,b-d)<=1e-9)goto con;
	    }
	  }
	  continue;
	con:
	  unite(i,j);
	}
      }
      set<int> s;
      for(int i=0;i<n;i++){
	s.insert(find(i));
      }
      cout<<s.size()<<endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int x, y;
    cin >> x >> y;
    if(x < y) cout << 0;
    else cout << 10;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int w,h,A,B;
	cin>>h>>w>>A>>B;
	for(int i=0;i<h;i++){
		if(i<B){
			for(int j=0;j<A;j++)
				cout<<0;
			for(int j=A;j<w;j++)
				cout<<1;
		}
		else{
			for(int j=0;j<A;j++)
				cout<<1;
			for(int j=A;j<w;j++)
				cout<<0;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
void solve(int n,int x){
	int ans=0;
	for(int i=1;i<n;++i) for(int j=i+1;j<n;++j){
		int k=x-i-j;
		if(n>=k&&k>j) ++ans;
	}
	cout<<ans<<endl;
}

int main(){
	while(true){
		int n,x;
		cin>>n>>x;
		if(n!=0) solve(n,x);
		else break;
	}
}

Measured memory_bytes: 3112
from collections import deque


nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
t = 0
queue = deque()
for i in range(n):
    p = input().split()
    queue.append(p)
while queue:
    proc = queue.popleft()
    if int(proc[1]) <= q:
        t += int(proc[1])
        print(proc[0], t)
    else:
        proc[1] = int(proc[1]) - q
        t += q
        queue.append(proc)


Measured memory_bytes: 17408
#include <stdio.h>

int main (void)
{
int A,B,C;
C = 0;
 scanf("%d %d", &A,&B);
 //printf("入力値 A=%d,B=%d\n",A,B);

 if(0 < A && A< 10 && 0 < B && B < 10){
     C = A * B;
     printf("%d",C);
 }
 else{
     C = -1;
     printf("%d",C);
 }
 return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll flag = 1, count = 0;
  while (flag) {
    flag = 0;
    for (ll i = n-1; i > 0; i--) {
      if (v.at(i) < v.at(i-1)) {
        swap(v.at(i), v.at(i-1));
        count++;
        flag = 1;
      }
    }
  }
  rep(i, n) {
    if (i < n-1) {
      cout << v.at(i) << ' ';
    } else {
      cout << v.at(i) << endl;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n,m,a;
  while(cin>>n>>m>>a,n+m+a){
    vector<pair<int,pair<int,int> > > v(m);
    vector<int> ans(n);
    REP(i,n) ans[i] = i;
    REP(i,m){
      int h,p,q; cin>>h>>p>>q;
      v[i].f = h; v[i].s.f = p; v[i].s.s = q;
    }
    sort(v.rbegin(), v.rend());
    REP(i,m)
      swap(ans[v[i].s.f-1], ans[v[i].s.s-1]);
    REP(i,n) if(ans[i] == a-1) cout << i+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 920
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

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

typedef long long ll;
const int mod=1000000007;

ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int n;
int x[100005];
ll pre[100005];
ll ans,mul;

int main(){

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

    cin>>n;
    mul=1;for(int i=2;i<n;i++)mul=mul*i%mod;
    for(int i=1;i<=n;i++){
        cin>>x[i];
        pre[i]=(pre[i-1]+mul*qpow(i,mod-2)%mod)%mod;
    }
    for(int i=1;i<n;i++){
        ans=(ans+(x[i+1]-x[i])*pre[i]%mod)%mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i == 0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int n, d[200000], m, t[200000];
map<int, int>mpa, mpb;
int main() {
	cin >> n;
	rep(i, n)cin >> d[i];
	cin >> m;
	rep(i, m)cin >> t[i];
	rep(i, n)mpa[d[i]]++;
	rep(i, m)mpb[t[i]]++;
	rep(i, m) {
		if (mpb[t[i]] > mpa[t[i]]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 20608
#include <stdio.h>

int main(void){
  int r, g, b, num;
  scanf("%d %d %d", &r, &g, &b);
  num = 100 * r + 10 * g + b;
  if(num % 4 == 0) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;

int main(){
	ll n, m; cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 200000

int main(void) {
    int num = get_int();
    int arr[NUM_MAX];
    fget_array(arr, num);

    int left;
    int right = 0;
    int sum = 0;
    uint64_t cnt = 0;
    for(left = 0; left < num; left++) {
        for(; right < num; right++) {
            if(sum & arr[right]) break;
            sum = sum ^ arr[right];
        }
#ifdef DEBUG
        printf("[%d] [%d, %d)\n", sum, left, right);
#endif
        cnt += (right - left);
        sum = sum ^ arr[left];
    }
    printf("%llu\n", cnt);
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int n;
  LL a[100010];
  LL b[100010];

  scanf("%d",&n);

  REP (i, n) scanf("%lld %lld",&a[i], &b[i]);

  LL ans = 0;
  RREP (i, n) {
    if ((ans + a[i]) % b[i] != 0) {
      ans += b[i] - ((ans + a[i]) % b[i]);
    }
  }
  printf("%lld\n",ans);
}


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

int main()
{
	string s;
	while(cin >> s && s != "0"){
		int ans = 0;
		for (int i = 0;i < s.size();i++) {
			ans += s[i]-'0';
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
long double a,b,h,m,c,d1,d2;
int main()
{
	cin>>a>>b>>h>>m;
	d1=m/2.0+h*30.0;
	d2=m*6.0;
	d2=fabs(d1-d2);
	c=sqrt(2.0*a*b)*sqrt((a*a+b*b)/(2.0*a*b)-cos(d2*3.14159265358979323846264338327950L/180.0));
	cout<<fixed<<setprecision(15)<<c; 
}


Measured memory_bytes: 4112
#include<iostream>
using namespace std;
int main(){
	int t,n;
	int aka[5]={0};
	int i;
	for(i=0;i<4;i++){
		cin>>t>>n;
		if(t==1){
			aka[i]=6000*n;
		}
		else if(t==2){
			aka[i]=4000*n;
		}
		else if(t==3){
			aka[i]=3000*n;
		}
		else{
			aka[i]=2000*n;
		}
	}
	for(i=0;i<4;i++){
		cout<<aka[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}
int main(){
string s,t;
cin>>s>>t;
int n=s.size()-t.size();
int ts = t.size();

vector<int> a(n+1);
 for(int i=0;i<ts;i++){
            for(int j=0; j<=n;j++){
            if(s[i+j]!=t[i]){
                a[j]++;
            }
        }
    }
  if(n==0){cout<<a[0]<<endl; return 0;}  
rep(i,n){
    if(a[i]<a[i+1])a[i+1]=a[i];
}
cout<<a[n-1]<<endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		String s2[] = s.split("");
		String t2[] = t.split("");
		int c = 0;
		for (int i = 0; i < s2.length; i++) {
			if (s2[i].equals(t2[i]))
				c++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
struct node {
	int x,y,id;
} a[1000001];
multiset<int> red;
multiset<int> blue;
bool cmp(const node & a , const node & b ){
	return a.x<b.x;	
}
int calc(){
	return (*red.rbegin()-*red.begin())*(*blue.rbegin()-*blue.begin());
}
main() {
	int n=read();
	for(int i=1; i<=n; i++) {
		a[i].x=read(),a[i].y=read();
		if(a[i].x>a[i].y) swap(a[i].x,a[i].y);
		red.insert(a[i].x);
		blue.insert(a[i].y);
	}
	sort(a+1,a+1+n,cmp);
	int minx=calc();
	for(int i=1;i<=n;i++){
		int x=a[i].x,y=a[i].y;
		red.erase(red.find(a[i].x));
		blue.erase(blue.find(a[i].y));
		red.insert(a[i].y),blue.insert(a[i].x);
		minx=min(minx,calc());
	}
	printf("%lld",minx);
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	int h, w, k;
	long long int cnt = 0;
	cin >> h >> w >> k;
	vector <string> grid(h);
	for (auto &i : grid) cin >> i;
	for (int i = 0; i < (1 << w); ++i){
		for (int j = 0; j < (1 << h); ++j){
			long long int black = 0;
			for (int row = 0; row < h; ++row){
				if ( ((1 << row) & j ) != 0){
				for (int col = 0; col < w; ++col){
					if ( ((1 << col) & i) != 0){
						if (grid[row][col] == '#') ++black;
					}
				}
				}
			}
			if (black == k) ++cnt;
		}
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3568
n=int(input())
*l,=map(int,input().split())
a,b=max(l),min(l)
pa,pb=l.index(a),l.index(b)

print(2*n-1)
if abs(a)>=abs(b):
  for i in range(n):
    print(pa+1,i+1)
  for i in range(n-1):
    print(i+1,i+2)
else:
  for i in range(n):
    print(pb+1,i+1)
  for i in range(n-1):
    print(n-i,n-i-1)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;

namespace Maximum_Sum_Sequence
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                List<int> input = new List<int>();
                
                for (int i = 0; i < n; ++i)
                {
                    input.Add(int.Parse(Console.ReadLine()));
                }

                List<int> temp = new List<int>();
                
                for (int i = 0; i < n; ++i)
                {
                    int sum = 0;
                    for (int j = i; j < n; ++j)
                    {
                        sum += input[j];
                        temp.Add(sum);
                    }
                }

                temp.Sort();
                Console.WriteLine(temp[temp.Count-1]);
            }


        }
    }
}



Measured memory_bytes: 57312
import numpy as np
N, M = map(int, raw_input().split())
a, b, c, d = [], [], [], []
for i in range(N):
    x, y = map(int, raw_input().split())
    a.append(x)
    b.append(y)
for j in range(M):
    x, y = map(int, raw_input().split())
    c.append(x)
    d.append(y)
for i in range(N):
    print np.argmin([abs(a[i] - c[j]) + abs(b[i] - d[j]) for j in range(M)]) + 1

Measured memory_bytes: 18636
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var N int
	fmt.Sscanf(scanner.Text(), "%d", &N)

	ws := make([]string, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%s", &ws[i])
	}

	ans := true
	done := make(map[string]struct{})
	done[ws[0]] = struct{}{}
	for i := 1; i < len(ws); i++ {
		prev := ws[i-1]
		if _, e := done[ws[i]]; e {
			ans = false
			break
		}
		if prev[len(prev)-1] != ws[i][0] {
			ans = false
			break
		}
		done[ws[i]] = struct{}{}
	}

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 640
N,K = map(int,input().split())
huga = list(map(int, input().split()))
new_list_reverse = sorted(huga, reverse=True)
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
Ni = 10 ** 5 +1  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, Ni + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
s=0
for i in range(0,N-K+1):
    s+=new_list_reverse[i]*cmb(N-i-1,K-1,10**9+7)
for i in range(K-1,N):
    s-=new_list_reverse[i]*cmb(i,K-1,10**9+7)
print(s%(10**9+7))

Measured memory_bytes: 26528
#include<bits/stdc++.h>
#define LL long long
#define MAX 2005
using namespace std;
int n,x;
int a[MAX],mn[MAX];
LL calc(int t){
	for (int i=0;i<n;i++) mn[i]=min(mn[i],a[(i-t+n)%n]);
	LL tans=0;
	for (int i=0;i<n;i++) tans+=mn[i];
	return tans;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>x;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++) mn[i]=1e9+10;
	LL ans=1e18+10;
	for (int i=0;i<n;i++)
	  ans=min(ans,1ll*x*i+calc(i));
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a+b == c || b+c == a || c+a == b) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  string s; cin >> s;
  if((s.size() % 2 == 0) xor (s[0] == s[s.size() - 1])) cout << "Second\n";
  else cout << "First\n";
}

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

int main() {
  int d;
  int n;
  cin >> d;
  cin >> n;
  int ans;
  if (d==0){
    ans=1;
  }else if(d==1){
    ans=100;
  }else{
    ans=10000;
  }
  if (n==100){
    cout << ans*101;
  }else{
    cout << ans*n;
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np
from scipy import signal

MOD = 998244353

N, M = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

def divideArr3(As, numD):
    arrA = np.array(As, dtype=np.int64)
    mask = (1<<numD) - 1
    arrA0 = arrA & mask
    arrA1 = (arrA>>numD) & mask
    arrA2 = arrA>>(2*numD)
    return arrA2, arrA1, arrA0

def convolveArr(arrA, arrB):
    arrC = np.rint(signal.fftconvolve(arrA, arrB)).astype(np.int64)
    return arrC

def convolveMOD(As, Bs, MOD):
    numD = 10
    div = 1<<numD
    arrA2, arrA1, arrA0 = divideArr3(As, numD)
    arrB2, arrB1, arrB0 = divideArr3(Bs, numD)

    arrC4 = convolveArr(arrA2, arrB2) % MOD
    arrC2 = convolveArr(arrA1, arrB1) % MOD
    arrC0 = convolveArr(arrA0, arrB0) % MOD
    arrC3 = (convolveArr(arrA2+arrA1, arrB2+arrB1) % MOD - arrC4 - arrC2) % MOD
    arrC1 = (convolveArr(arrA1+arrA0, arrB1+arrB0) % MOD - arrC2 - arrC0) % MOD
    arrC2 += (convolveArr(arrA2+arrA0, arrB2+arrB0) % MOD - arrC4 - arrC0) % MOD
    arrC2 %= MOD

    div2 = div*div%MOD
    div3 = div2*div%MOD
    div4 = div3*div%MOD
    arrAns = ((arrC4*div4)%MOD + (arrC3*div3)%MOD + (arrC2*div2)%MOD + (arrC1*div)%MOD + arrC0) % MOD
    return arrAns.tolist()

anss = convolveMOD(As, Bs, MOD)
print(' '.join(map(str, anss)))


Measured memory_bytes: 305928
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Bomber
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 300000;
const int MAX_W = 300000;
const int MAX_M = 300000;

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;

/* global variables */

pii ps[MAX_M];
int cs[MAX_M], ycs[MAX_H], xcs[MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w, m;
  scanf("%d%d%d", &h, &w, &m);

  for (int i = 0; i < m; i++) {
    int y, x;
    scanf("%d%d", &y, &x);
    y--, x--;
    ps[i] = pii(y, x);
  }
  sort(ps, ps + m);

  int n = 0;
  for (int i = 0; i < m;) {
    int j = i + 1;
    while (j < m && ps[i] == ps[j]) j++;
    ps[n] = ps[i];
    cs[n] = j - i;
    n++;
    i = j;
  }

  for (int i = 0; i < n; i++) {
    ycs[ps[i].first] += cs[i];
    xcs[ps[i].second] += cs[i];
  }
  //for (int i = 0; i < h; i++) printf("%d ", ycs[i]); putchar('\n');
  //for (int i = 0; i < w; i++) printf("%d ", xcs[i]); putchar('\n');

  int maxyc = -1, maxxc = -1;
  vi maxys, maxxs;
  for (int y = 0; y < h; y++) {
    if (maxyc < ycs[y])
      maxyc = ycs[y], maxys.clear(), maxys.push_back(y);
    else if (maxyc == ycs[y])
      maxys.push_back(y);
  }
  for (int x = 0; x < w; x++) {
    if (maxxc < xcs[x])
      maxxc = xcs[x], maxxs.clear(), maxxs.push_back(x);
    else if (maxxc == xcs[x])
      maxxs.push_back(x);
  }

  int maxc = 0;
  for (vi::iterator yit = maxys.begin(); yit != maxys.end(); yit++)
    for (vi::iterator xit = maxxs.begin(); xit != maxxs.end(); xit++) {
      int c = maxyc + maxxc;
      pii p(*yit, *xit);
      int k = lower_bound(ps, ps + n, p) - ps;
      if (k >= n || ps[k] != p) {
	maxc = c;
	break;
      }
      c -= cs[k];
      if (maxc < c) maxc = c;
    }

  printf("%d\n", maxc);
  return 0;
}


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

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  int64_t ans = max({a*c, a*d, b*c, b*d});
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3616
package main

import "fmt"

type edge struct {
	from int
	to   int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	m := make(map[edge]int, 2*N)
	var x, y int
	for i := 0; i < M; i++ {
		fmt.Scan(&x, &y)
		if x == 1 || y == N {
			m[edge{from: x, to: y}]++
		}
	}

	found := false
	for i := 1; i <= N; i++ {
		if i == 1 {
			if m[edge{from: 1, to: N}] != 0 {
				found = true
				break
			}
		} else {
			if m[edge{from: 1, to: i}] != 0 && m[edge{from: i, to: N}] != 0 {
				found = true
				break
			}
		}
	}

	if found {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 21376
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1)% LEN;
	return x;
}

int min(int a, int b){
	return a < b ? a : b;
}

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	char str[64];
	
	scanf("%d %d", &n, &q);
	for(i = 1; i <= n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n + 1;
	
	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0)enqueue(u);
		else{
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}


Measured memory_bytes: 11852
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  ll mod = 1000000007;
  vector<vector<ll> > f(h + 1, vector<ll>(w, 0));
  rep(j, w) f[0][j] = (j == 0);
  vl fib(w + 1, 0);
  fib[0] = 1;
  fib[1] = 1;
  for (int i = 2; i <= w; i++) {
    fib[i] = fib[i - 1] + fib[i - 2];
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 0; j < w; j++) {
      if (j > 0) {
        f[i][j] =
            (f[i][j] + f[i - 1][j - 1] * fib[w - 1 - j] * fib[j - 1]) % mod;
      }
      f[i][j] = (f[i][j] + f[i - 1][j] * fib[j] * fib[w - j - 1]) % mod;
      if (j < w - 1) {
        f[i][j] = (f[i][j] + f[i - 1][j + 1] * fib[j] * fib[w - j - 2]) % mod;
      }
    }
  }
  cout << f[h][k - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll Mod = 998244353;
ll B[N], B1[N];
namespace SegmentTree{
	const int N = 2e5 + 5;
	struct node	//设计线段树节点
	{
		int l, r;
		ll base;
		ll val;
		int tag;
		
	}t[N * 4];
	void push_up(node &rt, const node &ls, const node &rs)//定义上传操作
	{
		rt.val = (ls.val * B[rs.r - rs.l + 1] % Mod + rs.val) % Mod;
	}
	void mark(node &rt, int val)//定义标记操作
	{
		rt.val = rt.base * val % Mod;
		rt.tag = val;
	}
	void push_down(int k) //定义下传操作
	{
		if(t[k].tag == 0) return;
		mark(t[k << 1], t[k].tag);
		mark(t[k << 1 | 1], t[k].tag);
		t[k].tag = 0;
	}
	void build(int k, int l, int r)
	{
		if(l == r)//定义叶节点初始化操作
		{	
			t[k].l = l;
			t[k].r = r;
			t[k].base = B1[1];
			t[k].val = B1[1];
			t[k].tag = 0;
			return;
		}
		int mid = (l + r) / 2;
		build(k << 1, l, mid);
		build(k << 1 | 1, mid + 1, r);
		push_up(t[k], t[k << 1], t[k << 1 | 1]);
		//定义非叶节点的初始化操作
		t[k].l = l, t[k].r = r;
		int len = t[k << 1 | 1].r - t[k << 1 | 1].l + 1;
		t[k].base = (t[k << 1].base * B[len] + B1[len]) % Mod;
		t[k].tag = 0;
	}
	void modify(int k, int x, int y, long long val)
	{
		if(x > y) return;
		if(x <= t[k].l && t[k].r <= y) return mark(t[k], val);
		push_down(k);
		int mid = (t[k].l + t[k].r) / 2;
		if(x <= mid) modify(k << 1, x, y, val);
		if(y > mid) modify(k << 1 | 1, x, y, val);
		push_up(t[k], t[k << 1], t[k << 1 | 1]);
	}
	node query(int k, int x, int y)
	{
		
		if(x <= t[k].l && t[k].r <= y) return t[k];
		push_down(k);
		int mid = (t[k].l + t[k].r) / 2;
		if(y <= mid) return query(k << 1, x, y);
		else if(x > mid) return query(k << 1 | 1, x, y);
		else
		{
			node L = query(k << 1, x, y), R = query(k << 1 | 1, x, y);
			node rt;
			push_up(rt, L, R);
			return rt;
		}
	}
}
int main () {
	B[1] = 10;
	B1[1] = 1;
	for(int i = 2; i < N; ++ i) B[i] = B[i - 1] * 10 % Mod;
	for(int i = 2; i < N; ++ i) B1[i] = (B1[i - 1] * 10 + 1 ) % Mod;
	int n, m;
	cin >> n >> m;
	SegmentTree :: build(1, 1, n);
	for(int i = 1; i <= m; ++ i)
	{
		int l, r, d;
		cin >> l >> r >> d;
		SegmentTree :: modify(1, l, r, d);
		int ans = SegmentTree :: query(1, 1, n).val;
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 23124
#include<stdio.h>
using namespace std;
//scanf("%d%d",&W,&H);
//printf("%d\n",c);
int main() {
  int H,W,j,i;
  i=1;
  j=1;
  while(1){
    scanf("%d %d",&H,&W);
    
    if(H==0 && W==0) break;
    
    while(j<H+1){
      
      
      while(i<W+1){
        i=i+1;
        printf("#");
      }
     
      printf("\n");
      j=j+1;
      i=1;
    }
    i=1;
    j=1;
    printf("\n");
  }
}


Measured memory_bytes: 2684
def val(X, point):
    ans = 0
    for v in X:
        ans += (v - point) ** 2
    return ans


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

point = sum(X) // len(X)
first = val(X, point)
second = val(X, point + 1)
print(min(first, second))

Measured memory_bytes: 3060
x,y = map(int,input().split())
if ((x >= 0 and y >= 0) or (x < 0 and y < 0)) and x < y:
    print(abs(x-y))
elif (x >= 0 and y >= 0) and y < x:
    print(abs(x-y+1+(y != 0)))
elif (x < 0 and y < 0) and y < x:
    print(abs(x-y)+2)
elif x == -y:
    print(1)
else:
    print(abs(abs(x)-abs(y))+(y != 0))

Measured memory_bytes: 9052
#include<stdio.h>
#define MAX 500000
#define INFTY 1000000000
int cnt,L[MAX/2+2],R[MAX/2+2];

void merge(int A[],int left,int mid,int right){
  int i,k,j;
  int n1 = mid - left;
  int n2 = right - mid;
  // L[0...n1], R[0...n2] を生成
  for(i = 0;i<n1;i++){
    L[i] = A[left + i];
  }
  for( i = 0;i< n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = INFTY;
  i = 0;
  j = 0;
  for (k = left;k<right;k++){
    cnt++;
    if( L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,n, left, mid);
    mergeSort(A,n, mid, right);
    merge(A, left, mid, right);
  }
}
int main(){
  int A[MAX],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}
	  
    



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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vector<P> s;
  for (int i = 1; i*i <= n; ++i) {
    s.push_back(P(i,0));
    s.push_back(P(n/i,0));
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  rep(i,s.size()-1) {
    int l = n/s[i+1].first;
    int r = n/s[i].first;
    s[i].second = r-l;
  }
  s.back().second = 1;
  int m = s.size();
  // rep(i,m) {
  //   printf("%d %d\n", s[i].first, s[i].second);
  // }
  map<int,int> mp;
  rep(i,m) mp[s[i].first] = i;
  vector<vector<mint>> dp(k+1, vector<mint>(m));
  dp[0][mp[n]] = 1;
  rep(i,k) {
    for (int j = m-2; j >= 0; --j) dp[i][j] += dp[i][j+1];
    rep(j,m) {
      int nj = mp[n/s[j].first];
      dp[i+1][j] += dp[i][nj]*s[j].second;
    }
  }
  mint ans = 0;
  rep(j,m) ans += dp[k][j];
  cout << ans.x << endl;
  return 0;
}

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

#define ROW_MAX 50
#define COL_MAX 50
#define BUF_SIZE ROW_MAX+5

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(char *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

struct point2d {
    int row;
    int col;
};

struct point2d dist4[4] = {
    { 1, 0 },
    { -1, 0 },
    { 0, 1 },
    { 0, -1 }
};

int is_equal(struct point2d p1, struct point2d p2) {
    return p1.row == p2.row && p1.col == p2.col;
}

struct point2d queue[ROW_MAX*COL_MAX];
static int q_start = 0;
static int q_end = 0;

int is_empty(void) {
    return q_start == q_end;
}
void enqueue(struct point2d p) {
    queue[q_end++] = p;
}

struct point2d dequeue(void) {
    return queue[q_start++];
}

int main(void) {
    int row, col;
    get_int2(&row, &col);

    // boundary: wall
    static char map[ROW_MAX+2][COL_MAX+2];
    char buf[BUF_SIZE];
    int i, j;
    int walls = 0;
    for(i = 1; i <= row; i++) {
        get_str(&buf[1], BUF_SIZE);
        for(j = 1; j <= col; j++) {
            map[i][j] = (buf[j] == '.');
            walls += (buf[j] != '.');
        }
    }

    struct point2d start = {1, 1};
    struct point2d goal = { row, col };
    static int cnt_map[ROW_MAX+2][COL_MAX+2];
    enqueue(start); cnt_map[start.row][start.col] = 1;
    int ans = -1;

    while(!is_empty()) {
        struct point2d p = dequeue();
#ifdef DEBUG
        printf("%d, %d\n", p.row, p.col);
#endif
        if(is_equal(p, goal)) {
            ans = row*col - walls - cnt_map[p.row][p.col];
            break;
        }
        // BFS
        for(i = 0; i < 4; i++) {
            struct point2d np = {
                p.row + dist4[i].row,
                p.col + dist4[i].col
            };
            if(map[np.row][np.col] && !cnt_map[np.row][np.col]) {
                cnt_map[np.row][np.col] = cnt_map[p.row][p.col] + 1;
                enqueue(np);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

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



int main() {
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n;
long double m;
cin>>n>>m;
long double p = (long double)n *m;
 ll t = floor(p);
 cout<<t;
	


	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
inline int add(int a, int b, int mod = ::mod) { return (a += b) < mod? a : a - mod; }
inline int mul(int a, int b, int mod = ::mod) { return 1LL * a * b % mod; }
inline void adds(int& a, int b) { a = add(a, b); }

string s;
int a[100000];
int dp[100000][13];
int dnk[100000];

int f(int k, int s)
{
    if (k == ::s.size())
        return s == 5;
    if (dp[k][s] != -1)
        return dp[k][s];

    int sol = 0;
    if (::s[k] == '?')
    {
        for (int i = 0; i <= 9; ++i)
            adds(sol, f(k + 1, add(s, mul(dnk[k], i, 13), 13)));
    }
    else
        sol = f(k + 1, add(s, mul(dnk[k], a[k], 13), 13));
    return dp[k][s] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    dnk[0] = 1;
    for (int i = 1; i < s.size(); ++i)
        dnk[i] = mul(dnk[i - 1], 10, 13);

    reverse(all(s));
    for (int i = 0; i < s.size(); ++i)
        a[i] = s[i] - '0';

    memset(dp, -1, sizeof dp);
    cout << f(0, 0);
}


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

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

    ll buka[n];
    for (ll i = 0; i < n; i++) {
        buka[i] = 0;
    }

    for (ll i = 0; i < n - 1; i++) {
        ll a;
        cin >> a;
        buka[a - 1]++;
    }

    for (ll i = 0; i < n; i++) {
        cout << buka[i] << endl;
    }
}

Measured memory_bytes: 5156
n = int(input())
n <= 52

S = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
H = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
C = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
D = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]


for i in range(n):
    x, y = input().split()
    if x == "S":
        S[int(y)-1] = 1
    elif x == "H":
        H[int(y)-1] = 1
    elif x == "C":
        C[int(y)-1] = 1
    elif x == "D":
        D[int(y)-1] = 1
    else:
        pass

for m, val in enumerate(S):
    if val == 0:
        print("S", m+1)
for j, val in enumerate(H):
    if val == 0:
        print("H", j+1)
for k, val in enumerate(C):
    if val == 0:
        print("C", k+1)
for l, val in enumerate(D):
    if val == 0:
        print("D", l+1)



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

ll c;
int main()
{
    
    Fast;

    string st,sr;
    cin>>st;
    cin>>sr;
    if(st[0]==sr[0])
    	c++;
    if(st[1]==sr[1])
    	c++;
    if(st[2]==sr[2])
    	c++;
     cout<<c;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k;
long long sum=0;
int main()
{
	int H,W,h,w;
	scanf("%d%d%d%d",&H,&W,&h,&w);
	k=int(1e9)/h/w;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
		{
			if(i%h==0&&j%w==0)sum-=(h*w-1)*k+1;
			else sum+=k;
		}
	if(sum<=0)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(i%h==0&&j%w==0)printf("%d ",-(h*w-1)*k-1);
			else printf("%d ",k);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2816
def dfs(now):
    if vis[now]==1:#既に訪問済みであればreturn
        return 0
    vis[now]=1#訪問した記録をつける
    for i in range(n):
        if graph[now][i]==1:#接続していれば、移動
            dfs(i)
n,m=map(int,input().split())
edge=[[int(i) for i in input().split()]for i in range(m)]#入力値を受け取る
graph=[[0 for i in range(n)]for i in range(n)]
vis=[0]*n#既にある頂点を訪問したか管理する配列
for i in range(m):
    graph[edge[i][0]-1][edge[i][1]-1]=1#グラフを生成
    graph[edge[i][1]-1][edge[i][0]-1]=1
ans=0
for i in range(m):
    graph[edge[i][0]-1][edge[i][1]-1]=0#ある辺を消去
    graph[edge[i][1]-1][edge[i][0]-1]=0
    vis=[0]*n
    dfs(0)
    connect=False#全ての点が繋がっているか判断する値
    for j in range(n):
        if vis[j]==0:#訪問していない点があればcout
            connect=True
    if connect:
        ans+=1
    graph[edge[i][0]-1][edge[i][1]-1]=1#消した辺をもとに戻す
    graph[edge[i][1]-1][edge[i][0]-1]=1
print(ans)


Measured memory_bytes: 3064