akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007

ll beki(ll x, ll n){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll ncr(ll n, ll r){
  ll X = 1, Y = 1;
  for(int i = n - r + 1; i <= n ; i++){
    X = X * i % MOD;
  }
  for(int i = 1; i <= r; i++){
    Y = Y * i % MOD;
  }
  Y = beki(Y, MOD - 2);
  return X * Y % MOD;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll full = beki(2, n) - 1;
  int result = (full - ncr(n, a) - ncr(n, b)) % MOD;
  if(result < 0) result += MOD;
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  rep(i, 100) {
    ll now = i * a - i + 1;
    if(now < b) continue;
    cout << i << endl;
    return 0;
  }
}

Measured memory_bytes: 3620
import operator
import functools

A, B = input().split()

A = int(A)
B = int(B)

value = []

count = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

primeA = prime_factorize(A)

primeB = prime_factorize(B)


for i in range(len(primeA)):
    for j in range(len(primeB)):
        if primeA[i] == primeB[j]:
            value.append(primeA[i])
            primeA[i] = 1
            primeB[j] = 1
            break
        else:
            continue

value = value + primeA + primeB

result = functools.reduce(operator.mul, value)

print(result)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int A, B, C, K; cin >> A >> B >> C >> K;
	while (K > 0) {
		if (A < B && B < C) break;
		if (A >= B) {
			B *= 2;
			--K;
		} else if (B >= C) {
			C *= 2;
			--K;
		}
	}
	if (A < B && B < C) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
	int x1, y1, x2, y2, x3, y3;

	int vx,vy;

	cin >> x1 >> y1 >> x2 >> y2;

	vx = x2 - x1; vy = y2 - y1;

	x3 = x2 + (-1)*vy;
	y3 = y2 + (+1)*vx;

	cout << x3 << " " << y3 << " " << x3+(-1)*vx << " " << y3+(-1)*vy << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc162A
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            for (int i = 0; i < 3; i++)
            {
                if (n % 10 == 7)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                n /= 10;
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 17628
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i,n) for (int i=0; i<n; i++)
#define pll pair<ll, ll>

class UnionFind{
public:
  vector<ll> par; //各元の親を表す配列
  vector<ll> siz; //素集合のサイズを表す配列

  UnionFind(ll sz_): par(sz_), siz(sz_,1){
    for (int i=0; i<sz_; ++i) par[i] = i;
  }
  void init(ll sz_){
    par.resize(sz_);
    siz.assign(sz_,1);
    for (int i=0; i<sz_; ++i) par[i] = i;
  }

  // Find
  ll root(ll x){ //根の検索
    if (par[x] == x){
      return x;
    }else{
      return par[x] = root(par[x]);
    }
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y){
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x,y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(ll x, ll y){
    return root(x) == root(y);
  }
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  ll N, K, L, p, q;
  cin >> N >> K >> L;
  vector<ll> res(N, 1);
  UnionFind Road(N), Rail(N);
  rep(i, K){
    cin >> p >> q; --p; --q;
    Road.merge(p, q);
  }
  rep(i, L){
    cin >> p >> q; --p; --q;
    Rail.merge(p, q);
  }

  map<pll, ll> mp;
  rep(i, N) mp[{Road.root(i), Rail.root(i)}]++;
  rep(i, N) cout << mp[{Road.root(i), Rail.root(i)}] << " ";
  cout << endl;
}


Measured memory_bytes: 19584
#include "bits/stdc++.h"
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> graph(N, vector<int>(N));
  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    graph.at(x).at(y) += 1;
    graph.at(y).at(x) += 1;
  }

  for(int i = 0; i < N; i++){
    int roads = 0;
    for(int j = 0; j < N; j++){
      roads += graph.at(i).at(j);
    }
    cout << roads << endl;
  }
}

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

typedef long long ll;
const int MaxN = 1123456;
const ll mod = 1000000007;
const ll inf = 1000000005LL;

void solve_case() {
    int n; ll w;
	cin >> n >> w;
	
	vector<vector<int>> arr(n + 1, vector<int> (2));
	for(int i = 1; i <= n; i++) {
		cin >> arr[i][0] >> arr[i][1];
	}
	
	int max_v = n * 1000;
	ll dp[n + 1][max_v + 1];
	memset(dp, inf, sizeof(dp));
	dp[1][0] = 0;
	dp[1][arr[1][1]] = arr[1][0];
	
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= max_v; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - arr[i][1] < 0) continue;
			dp[i][j] = min(dp[i][j], dp[i - 1][j - arr[i][1]] + arr[i][0]);
		}
	}
	
	ll ans = 0;
	for(int i = 0; i <= max_v; i++) {
		//cout << "jai ho bhawani\n";
		if (dp[n][i] <= w) ans = i;
	}
	
	cout << ans;
}

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


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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 100 + 5;

ll n;

int main()
{
	io;
	cin >> n;
	vll l(n);
	takearr0(l,n);
	Sort(l);
	ll ans = 0;
	rep(i,0,n-2,1) rep(j,i+1,n-1,1) rep(k,j+1,n,1) if(l[i] < l[j] and l[j] < l[k] and l[i]+l[j]>l[k]) ++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long []a=new long [n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextLong();
		}
		int count_g=0;
		int count_k=0;
		for(int i=0;i<n;i++){
			if(a[i]%2==0)count_g++;
			else count_k++;
		}
		if(count_k%2==0)System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 46748
#include "bits/stdc++.h"
using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    long long ans1 = 0;
    long long ans2 = 0;
    long long sum1 = 0;
    long long sum2 = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            if (sum1 + a[i] > 0) {
                sum1 += a[i];
            }
            else {
                ans1 += 1 - sum1 - a[i];
                sum1 = 1;
            }
        }
        else if (i % 2 == 1) {
            if (sum1 + a[i] < 0) {
                sum1 += a[i];
            }
            else {
                ans1 += 1 + sum1 + a[i];
                sum1 = -1;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            if (sum2 + a[i] > 0) {
                sum2 += a[i];
            }
            else {
                ans2 += 1 - sum2 - a[i];
                sum2 = 1;
            }
        }
        else if (i % 2 == 0) {
            if (sum2 + a[i] < 0) {
                sum2 += a[i];
            }
            else {
                ans2 += 1 + sum2 + a[i];
                sum2 = -1;
            }
        }
    }

    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define f(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define vl vector<ll>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
#define printv(v) for(auto it : v) cout<<it<<" ";


//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;
const long long int MOD = 1e9+7;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{ll d,ti,s;
cin>>d>>ti>>s;
if(d%s==0)
d = d/s;
else
d= d/s+1;
if((d)<=ti)
cout<<"Yes";
else
cout<<"No";
    
}
}


Measured memory_bytes: 3620
a,b,c = map(int,input().split())
k = int(input())
while(k>0):
  if b>a:
    break
  b*=2
  k-=1
while(k>0):
  if c>b:
    break
  c*=2
  k-=1
print("Yes" if c>b and b>a else "No") 

Measured memory_bytes: 9096
# (R, B)の間にあるGみたいな感じ 6種類あるのか？ 6*N^2
n = int(input())
s = input()
rs, gs, bs = [0] * n, [0] * n, [0] * n
if s[0] == "R":
    rs[0] = 1
elif s[0] == "G":
    gs[0] = 1
elif s[0] == "B":
    bs[0] = 1
for i in range(1, n):
    rs[i] = 1 + rs[i - 1] if s[i] == "R" else rs[i - 1]
    gs[i] = 1 + gs[i - 1] if s[i] == "G" else gs[i - 1]
    bs[i] = 1 + bs[i - 1] if s[i] == "B" else bs[i - 1]
ans = 0
for i in range(0, n):
    for j in range(i + 2, n):
        if (s[i] == "R" and s[j] == "B") or (s[i] == "B" and s[j] == "R"):
            ans += gs[j]
            ans -= gs[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == "G":
                ans -= 1
        elif (s[i] == "R" and s[j] == "G") or (s[i] == "G" and s[j] == "R"):
            ans += bs[j]
            ans -= bs[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == "B":
                ans -= 1
        elif (s[i] == "B" and s[j] == "G") or (s[i] == "G" and s[j] == "B"):
            ans += rs[j]
            ans -= rs[i]
            if (i + j) % 2 == 0 and s[(i + j) // 2] == "R":
                ans -= 1
print(ans)


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

int main() {
  const int V = 10;
  const int INF = 1<<28;
  int n;
  while(cin >> n && n) {
    int v = 0;
    int g[V][V];
    for(int i = 0; i < V; ++i) {
      for(int j = 0; j < V; ++j) {
        g[i][j] = i == j ? 0 : INF;
      }
    }
    for(int i = 0; i < n; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      v = max(v,max(a,b)+1);
      g[a][b] = g[b][a] = min(g[b][a], c);
    }

    for(int k = 0; k < v; ++k) {
      for(int i = 0; i < v; ++i) {
        for(int j = 0; j < v; ++j) {
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }
    int minv = -1;
    int mini = INF;
    for(int i = 0; i < v; ++i) {
      int sum = 0;
      for(int j = 0; j < v; ++j) {
        sum += g[i][j];
      }
      if(mini > sum) {
        mini = sum;
        minv = i;
      }
    }
    cout << minv << " " << mini << endl;
  }
  return 0;
}

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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<int, vector<int>> mp;
    int r=0, g=0, b=0;
//    debug(s)
//    debug(n)
    for(int i=0; i<n ;i++)
    {
        if(s[i]=='R')
            r++;
        else if(s[i]=='G')
            g++;
        else
            b++;
        mp[i].push_back(r);
        mp[i].push_back(g);
        mp[i].push_back(b);
    }
//    debug(r)
//    debug(g)
//    debug(b)
    int sum=0;
    for(int i=1; i<n-1; i++)
    {
        int l=i-1;
        int r=i+1;
//        debug(l)
//        debug(r)
//        debug(sum)
        if(s[i]=='R')
        {
            int lg = mp[i][1];
            int lb = mp[i][2];
            int rg = mp[n-1][1]-mp[i][1];
            int rb = mp[n-1][2]-mp[i][2];
            sum+=lg*rb+lb*rg;
            //debug(lg)
            while(l>=0 && r<n)
            {
                if((s[l]=='G' && s[r]=='B') || (s[l]=='B' && s[r]=='G'))
                {
                    sum--;
                }
                l--;
                r++;
            }
        }
        if(s[i]=='G')
        {
            int lr = mp[i][0];
            int lb = mp[i][2];
            int rr = mp[n-1][0]-mp[i][0];
            int rb = mp[n-1][2]-mp[i][2];
            sum+=lr*rb+lb*rr;
            while(l>=0 && r<n)
            {
                if((s[l]=='R' && s[r]=='B') || (s[l]=='B' && s[r]=='R'))
                {
                    sum--;
                }
                l--;
                r++;
            }
        }
        if(s[i]=='B')
        {
            int lr = mp[i][0];
            int lg = mp[i][1];
            int rr = mp[n-1][0]-mp[i][0];
            int rg = mp[n-1][1]-mp[i][1];
            sum+=lr*rg+lg*rr;
            while(l>=0 && r<n)
            {
                if((s[l]=='R' && s[r]=='G') || (s[l]=='G' && s[r]=='R'))
                {
                    sum--;
                }
                l--;
                r++;
            }
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 4064
""" abc055_b """

import sys
from functools import reduce

H = pow(10, 9) + 7

def _main():
    _n = int(sys.stdin.readline())

    # N! = aH + b
    # (N+1)! = a'H + b'
    #
    # (N+1) * N! = aH(N+1) + b(N+1)
    #            = aH(N+1) + int(b(N+1)/H) * H + b(N+1) % H
    # a' = a(N+1) + int(b(N+1)/H)
    # b' = b(N+1) % H
    #
    _b = reduce(lambda b, n: (b * n) % H, range(1, _n + 1), 1)

    print(_b)

if __name__ == '__main__':
    _main()


Measured memory_bytes: 3572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FoxObservation solver = new FoxObservation();
        solver.solve(1, in, out);
        out.close();
    }

    static class FoxObservation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            Map<Integer, Map<Integer, Long>> p = new HashMap<>();
            for (int i = 0; i < N; i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                long w = in.nextInt();
                if (!p.containsKey(x)) {
                    p.put(x, new HashMap<>());
                }
                p.get(x).put(y, w);
            }
            int[] dx = new int[]{0, 1, 0, 1};
            int[] dy = new int[]{0, 0, 1, 1};
            int[] sign = new int[]{1, -1};
            long ans = 0;
            for (int x : p.keySet()) {
                for (int y : p.get(x).keySet()) {
                    for (int sx : sign) {
                        for (int sy : sign) {
                            long nowW = 0;
                            for (int i = 0; i < 4; i++) {
                                int nx = x + dx[i] * sx;
                                int ny = y + dy[i] * sy;
                                if (p.containsKey(nx) && p.get(nx).containsKey(ny)) {
                                    nowW += p.get(nx).get(ny);
                                }
                            }
                            ans = Math.max(ans, nowW);
                        }

                    }

                }
            }
            out.println(ans + " / 1");
        }

    }
}




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

int main() {
	int n, k;
	cin >> n >> k;
	if (n % 2 == 0) {
		if (k <= n / 2) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	} else {
		if (k <= n / 2 + 1) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << 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++)
using ll = long long;

int main(){
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	
	ll ans = 0;
	while (a > 0 && k > 0) {
		ans++;
		a--;
		k--;
//      cout << ans << endl;
	}
	if (a + b < k) {
		k -= b;
		while (c > 0 && k > 0) {
			ans--;
			c--;
			k--;
//          cout << ans << endl;
		}
	}
	cout << ans << endl;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	
	if(x==1 && y==1){
		cout << 1000000 << endl;
		return 0;
	}

	int res = 0;
	
	if(x==1) res += 300000;
	if(x==2) res += 200000;
	if(x==3) res += 100000;
	if(y==1) res += 300000;
	if(y==2) res += 200000;
	if(y==3) res += 100000;
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)

	ans := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				ans += gcd(a, gcd(b, c))
			}
		}
	}

	fmt.Println(ans)
}

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


Measured memory_bytes: 1780
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int H,W;
char S[400][400];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
ll ans = 0;

void dfs(int s, int t, int now, int &black, int &white,vector<vector<bool>> &used){
	if(now == 1) white++;
	if(now == 0) black++;
	used[s][t] = true;
	rep(i,4){
		if(s+dy[i] >= 0 && s+dy[i] < H && t+dx[i] >= 0 && t+dx[i] < W){
			if(now == 0 && S[s+dy[i]][t+dx[i]] == '.' && !used[s+dy[i]][t+dx[i]]) dfs(s+dy[i],t+dx[i],1-now,black,white,used);
			if(now == 1 && S[s+dy[i]][t+dx[i]] == '#' && !used[s+dy[i]][t+dx[i]]) dfs(s+dy[i],t+dx[i],1-now,black,white,used);
		}
	}
}

int main(){
	cin >> H >> W;
	rep(i,H)rep(j,W) cin >> S[i][j];
	vector<vector<bool>> used(H,vector<bool>(W,false));
	rep(i,H)rep(j,W){
		int now = 0;
		int white = 0;
		int black = 0;
		if(S[i][j] == '#' && !used[i][j]){
			dfs(i,j,now,black,white,used);
			ans += (ll)black*white;
		}

	}
	cout << ans << '\n';

}

Measured memory_bytes: 12928
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n, x, y = map(int, input().split())
  ans = [0]*(n-1)
  for i in range(1,n):
    for j in range(i+1,n+1):
      num = min(j-i, abs(i-x)+abs(j-y)+1)
      ans[num-1] += 1
  for i in ans:
    print(i)
  return 0
 
if __name__ == "__main__":
  solve()


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

const int maxn = 2e5 + 10;
int p[maxn], dp[maxn];
bool B[maxn];
set <int> S;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	dp[k - 1] = 1;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	for (int i = 0; i < k; i++)
		S.insert(p[i]);
	int g = n, l = 1;
	for (int i = 0; i < n - 1; i++){
		if (p[i] > p[i + 1])
			l = 1;
		else
			l ++;
		if (l == k){
			g = min(g, i + 1);
		}
		if (l >= k - 1){
			B[i + 1] = true;
		}
	}
	for (int i = k; i < n; i++){
		bool f = *(S.begin()) == p[i - k];
		S.erase(p[i - k]);
		S.insert(p[i]);
		auto x = S.end();
		x --;
		if (((g < i - k && B[i - 1]) || f) && S.find(p[i]) == x)
			dp[i] = dp[i - 1];
		else
			dp[i] = dp[i - 1] + 1;
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 10368
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    h = Intl()
    dp = [10000]*n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2,n):
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),\
        dp[i-2] + abs(h[i]-h[i-2]))
    print(dp[-1])

Measured memory_bytes: 14108
import java.util.*;
 import java.math.BigInteger;
public class Main
{
	static int ans[];
	public static  void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		// String h[]=sc.nextLine().split(" ");
		// long n=Long.parseLong(sc.nextLine());
		String h[]=sc.nextLine().split(" ");
		int n=Integer.parseInt(h[0]);
		int m=Integer.parseInt(h[1]);
		int grid[][]=new int[n][m];
		int dp[][]=new int[n][m];
		for(int i=0;i<n;i++)
		{
			String hh[]=sc.nextLine().split("");
			for(int j=0;j<m;j++)
			{
				if(hh[j].equals("#"))
				{
					grid[i][j]=-1;
				}
			}
		}
		dp[0][0]=grid[0][0]==-1?1:0;
		for(int i=1;i<m;i++)
		{
			if(grid[0][i]==-1 && grid[0][i-1]==0){dp[0][i]=dp[0][i-1]+1;}
			else{dp[0][i]+=dp[0][i-1];}
		}
		for(int i=1;i<n;i++)
		{
			if(grid[i][0]==-1 && grid[i-1][0]==0){dp[i][0]=dp[i-1][0]+1;}
			else{dp[i][0]+=dp[i-1][0];}
		}
		for(int i=1;i<n;i++)
		{
			for(int j=1;j<m;j++)
			{
				int cost1=dp[i-1][j];
				int cost2=dp[i][j-1];
				if(grid[i-1][j]==0 &&grid[i][j]==-1)
				{
					cost1+=1;
				}
				if(grid[i][j-1]==0 &&grid[i][j]==-1)
				{
					cost2+=1;
				}
				dp[i][j]=Math.min(cost1,cost2);


			}
		}
		System.out.println(dp[n-1][m-1]);
		
		
	}
	static long get3(double n, int steps)
	{
		if(n<1){return Integer.MAX_VALUE;}
		if(n==1){return steps;}

		System.out.println(n);
		return get3(n/2.0-1,steps+1);
	}
	static String get(long a, long b)
	{long y=1;
		while(true)
		{

			long z=y-a;
			long q=get2(y,z);
			// System
			if(q==b){return y+" "+z;}
			else if(q>b){return "-1";}
			y+=1;
		}
		// return "-1";
	}
	static long get2(long y, long z)
	{
		return (long)(Math.pow(y,4)+Math.pow(y,3)*z+Math.pow(y,2)*Math.pow(z,2)+y*Math.pow(z,3)+Math.pow(z,4));
	}
	static void get(ArrayList<ArrayList<Integer>>arr, int i , int p,int val[], int arr1[], int len)
	{
		for(int j=0;j<arr.get(i).size();j++)
		{
			if(ans[arr.get(i).get(j)]==0 && arr.get(i).get(j)!=p){
			if(val[arr.get(i).get(j)]>arr1[len-1])
			{
				arr1[len]=val[arr.get(i).get(j)];
				ans[arr.get(i).get(j)]=len+1;
				get(arr,arr.get(i).get(j),i,val,arr1,len+1);
				
			}
			else
			{
				int index=bin(arr1, val[arr.get(i).get(j)], len-1);
				ans[arr.get(i).get(j)]=len;
				// int g=arr1[index];
				arr1[index]=val[arr.get(i).get(j)];
				get(arr,arr.get(i).get(j),i,val,arr1,len);
				// arr1[index]=g;
			}}

		}
	}
	static int bin(int arr[], int val, int len)
	{
		if(arr[0]>=val){return 0;}
		int l=0;
		int r=len;
		while (r - l > 1) { 
            int m = l + (r - l) / 2; 
            if (arr[m] >= val) 
                r = m; 
            else
                l = m; 
        } 
  
        return r; 
		// return l;
	}
	
	

}
class Pair
{
	int a;
	int b;
	int c;
	int d;
	Pair(int e,int f, int g,int h){
		a=e;
		b=f;
		c=g;
		d=h;
	}
}



	


Measured memory_bytes: 24276
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a, b ,c;
    cin >> a >> b >> c;
    int m = max({a, b, c});
    int ans;
    if(m == a){
        ans = m*10 + b + c;
    }else if(m == b){
        ans = m*10 + a + c;
    }else if(m == c){
        ans = m*10 + a + b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;

fn main() {

    input!{
       A1:usize,
       A2:usize,
       A3:usize
    }

    let list = vec![A1, A2, A3];

    let max =  list.iter().max().unwrap();
    let min = list.iter().min().unwrap();

    println!("{}", max - min);

}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
    int i,fl=0,cnt=0,res[100];float mt[8],a,b,c,d,e,f,s,t;
    while(1){
        for(i=0;i<8;i++){
            if(scanf("%f",&mt[i])==EOF){fl=1;break;}
        }
        if(fl==1){break;}
        a=mt[2]-mt[0];b=mt[4]-mt[0];d=mt[3]-mt[1];e=mt[5]-mt[1];
        c=mt[6]-mt[0];f=mt[7]-mt[1];
        s=(c*e-b*f)/(a*e-b*d);t=(a*f-d*c)/(a*e-b*d);
        res[cnt]=(s>=0 && t>=0 && s+t<=1)? 1:0;
        cnt++;
    }
    for(i=0;i<cnt;i++){printf("%s\n",(res[i])? "YES":"NO");}
    return 0;
}
 
        



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int L;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> L;

    int dgt = 1;
    int x = 1;
    while (x <= L) x *= 2, dgt++;
    dgt--;

    int N = dgt;
    vector<tuple<int, int, int>> edges;

    rep(i, 0, N - 1) {
        edges.push_back(make_tuple(N - i - 1, N - i, 1 << i));
        edges.push_back(make_tuple(N - i - 1, N - i, 0));
    }

    rep(i, 0, N - 1) if (L & (1 << i)) {
        int cst = L - (L % (1 << i)) - (1 << i);
        edges.push_back(make_tuple(1, N - i, cst));
    }

    int M = edges.size();
    printf("%d %d\n", N, M);
    fore(t, edges) {
        int a, b, c;
        tie(a, b, c) = t;
        printf("%d %d %d\n", a, b, c);
    }

}

Measured memory_bytes: 256
fun main(args: Array<String>) = yorukatsu13e()

fun yorukatsu13e() {
    val n = readLine()!!.toInt()
    val aList = (1..n).map { readLine()!!.toInt() }

    val list = mutableListOf<Int>()

    fun lowerBound(list: List<Int>, key: Int): Int {
        var ok = list.size
        var ng = -1

        while (ok - ng > 1) {
            val mid = (ng + ok) / 2
            if (list[mid] >= key) ng = mid else ok = mid
        }
        return ok
    }

    for (a in aList) {
        val lowerBound = lowerBound(list, a)
        when (lowerBound) {
            in list.indices -> list[lowerBound] = a
            else -> list.add(a)
        }
    }

    val answer = list.size

    println(answer)
}


Measured memory_bytes: 45804
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << (a + b >= c ? b + c : b + (a + b + 1)) << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  char b; cin >> b;
  if (b == 'A') cout << 'T' << endl;
  else if (b == 'T') cout << 'A' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int n, m, in[1001], data[1002001];

main(){
  while(scanf("%d %d", &n, &m) && (n|m)){
    in[0] = 0;
    for(int i=1;i<=n;i++) scanf("%d", &in[i]);
    for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) data[i*(n+1)+j] = in[i] + in[j];
    int size = (n+1)*(n+1), ans = 0;
    sort(data, data+size);
    for(int i=0;i<size;i++){
      int l = 0, r = size-1;
      while(r-l>1){
        int med = (l+r) / 2;
        if(data[i] + data[med] <= m) l = med;
        else r = med;
      }
      if(data[i] + data[l] <= m) ans = max(ans, data[i] + data[l]);
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		int a = sc.nextInt ();
		int b = sc.nextInt ();

		int c = ( a * 2 ) + ( b * 2 );
		int d = a * b;

		System.out.println ( d + " " + c );
	}
}

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

using namespace std;
int main() {
  int n;
  cin >> n;
  int result = 0;
  for (int i = 1;; i++) {
    if (i * i > n) {
      cout << (i - 1) * (i - 1) << endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    int N, L;
    cin >> N >> L;

    int ans = N * L - N + (N * (N + 1)) / 2;
    if(L <= 0) {
        if (L + N - 1 < 0) {
            ans -= L + N - 1;
        }
    } else {
        ans -= L;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 * 0312.cc: Net Cafe
 */

#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_M = 200000;
const int MAX_N = 15;
const int NBITS = 1 << MAX_N;

/* typedef */

/* global variables */

int wis[MAX_M], tis[MAX_M], wsums[MAX_M + 1], tsums[MAX_M + 1];
int cs[MAX_N], bs[MAX_N];
int dp[NBITS];

/* subroutines */

/* main */

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

  wsums[0] = tsums[0] = 0;
  for (int i = 0; i < m; i++) {
    cin >> wis[i] >> tis[i];
    wsums[i + 1] = wsums[i] + wis[i];
    tsums[i + 1] = tsums[i] + tis[i];
  }

  for (int i = 0; i < n; i++) cin >> cs[i] >> bs[i];

  int nbits = 1 << n;
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;

  for (int bits = 0; bits < nbits; bits++) {
    int wsum0 = wsums[dp[bits]], tsum0 = tsums[dp[bits]];

    for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
      if (! (bits & bi)) {
	int wsum = wsum0 + cs[i], tsum = tsum0 + bs[i];
	int wi = upper_bound(wsums, wsums + m + 1, wsum) - wsums - 1;
	int ti = upper_bound(tsums, tsums + m + 1, tsum) - tsums - 1;
	int bitsi = bits | bi;
	int dpi = min(wi, ti);
	if (dp[bitsi] < dpi) dp[bitsi] = dpi;
      }
  }

  printf("%d\n", dp[nbits - 1]);
  return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    
    vector<string> map(h);
    for(int i = 0; i < h; i++) {
        cin >> map[i];
    }
    
    vector<vector<int>> v = vector<vector<int>>(h, vector<int>(w, 0));
    // left
    for(int i = 0; i < h; i++) {
        int left = -1;
        for(int j = 0; j < w; j++) {
            if(map[i][j] == '#') {
                left = -1;
            }
            else {
                left++;
                v[i][j] += left;
            }
        }
    }
    
    // right
    for(int i = 0; i < h; i++) {
        int right = -1;
        for(int j = w - 1; j >= 0; j--) {
            if(map[i][j] == '#') {
                right = -1;
            }
            else {
                right++;
                v[i][j] += right;
            }
        }
    }
    
    // up
    for(int i = 0; i < w; i++) {
        int up = -1;
        for(int j = 0; j < h; j++) {
            if(map[j][i] == '#') {
                up = -1;
            }
            else {
                up++;
                v[j][i] += up;
            }
        }
    }
    
    // down
    for(int i = 0; i < w; i++) {
        int down = -1;
        for(int j = h - 1; j >= 0; j--) {
            if(map[j][i] == '#') {
                down = -1;
            }
            else {
                down++;
                v[j][i] += down;
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            ans = max(ans, v[i][j]);
        }
    }
    
    cout << ans + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 20096
let () = Scanf.scanf "%d %d %d" @@ fun a b k -> 
  let (takahashi, aoki) = 
    if k <= a
    then ((a-k), b)
    else 
      if (k-a) <= b
      then (0, (b-k+a))
      else (0, 0) in
  Printf.printf "%d %d\n" takahashi aoki

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

int main() {
    int X;
    cin >> X;
    while(true){
    int a=pow(X,0.5);
    bool w=true;
    for(int i=2;i<=a;i++){
        if(X%i==0){
            w=false;
        }
    }
    if(w){
        cout << X << endl;
        break;
    }
    X++;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c, d, x, y;
    cin >> a >> b >> c >> d;
    x = c - a;
    y = d - b;
    cout << c - y << ' ' << d + x << ' ' << a - y << ' ' << b + x << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using Atcoder.AtCoderBeginnerContest101.Questions;
using Atcoder.AtCoderBeginnerContest101.Extensions;

namespace Atcoder.AtCoderBeginnerContest101
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answer = question.Solve(Console.In);
            Console.WriteLine(answer);
        }
    }
}

namespace Atcoder.AtCoderBeginnerContest101.Questions
{
    // ここにQuestionクラスをコピペ
    public class QuestionA : AtCoderQuestionBase
    {
        public override string Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();
            return (s.Count(c => c == '+') - s.Count(c => c == '-')).ToString();
        }
    }

    #region Base Classes

    public interface IAtCoderQuestion
    {
        string Solve(string input);
        string Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public string Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract string Solve(TextReader inputStream);
    }

    #endregion
}

#region Extensions

namespace Atcoder.AtCoderBeginnerContest101.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);    
    public static void main(String[] args) {
        int n = sc.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
        }
        long highest = 0, ans = 0;
        for (long a: arr){
            if (a < highest){
                ans += highest - a;
            }else{
                highest = a;
            }
        } 
        System.out.println(ans);
    }
}

Measured memory_bytes: 62740
#include <stdio.h>
#include <ctype.h>

#define MAX_N 2000001
#define MAX_K 10001

char buf[MAX_N*5];

int getInteger();
void countingSort(int,int*);

int main(){
  int n,i;
  static int A[MAX_N];
  fread(buf,1,MAX_N*5,stdin);
  n = getInteger();
  for(i = 0 ; i < n ; i++){
    A[i] = getInteger();
  }
  countingSort(n,A);
  return 0;
}

int getInteger(){
  int res = 0;
  static int c = 0;
  while(isdigit(buf[c])){
    res *= 10;
    res += (buf[c++]-'0');
  }
  c++;
  return res;
}

void countingSort(int n,int *A){
  int i,C[MAX_K] = {0};
  static int B[MAX_N];
  for(i = 0 ; i < n ; i++){ C[A[i]]++; }
  for(i = 1 ; i < MAX_K ; i++){ C[i] += C[i-1]; }
  for(i = n-1 ; i >= 0 ; i--){
    B[C[A[i]]] = A[i]; C[A[i]]--;
  }
  for(i = 0 ; i < n ; i++){
    printf("%d%c",B[i+1],i < n-1 ? ' ' : '\n');
  }
}

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

int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if((b-a-1)%2==1){
	  long long v=(b-a-1)/2;
    cout<<min(min(v+1,b-1),n-a);
   }
  else{
	  long long v=min(b-1,n-a);
	  //if(v==b-1){
		  long long v1=a+(b-a-2)/2+1;
		  long long v2=(n-b+1)+(n-(a+(n-b)+1)-1)/2+1;
		  
          cout<<min(min(v,v1),v2);
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	ll A, B, N;
	cin >> A >> B >> N;

	if (N < B - 1)puts(((A*N)/B) - A*(N/B));
	else puts((B*A-A)/B);
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    map<char,char>num;
    for(int i=0;i<a.length();i++) num[a[i]]='0';
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]){
            if(num[a[i]]!='0'&&num[a[i]]!=b[i]) {cout<<"No"<<endl;return 0;}
            else if(num[a[i]]=='0') num[a[i]]=b[i];
        }
        else num[a[i]]=b[i];
    }
    for(int i=0;i<a.length();i++) num[b[i]]='0';
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]){
            if(num[b[i]]!='0'&&num[b[i]]!=a[i]) {cout<<"No"<<endl;return 0;}
            else if(num[b[i]]=='0') num[b[i]]=a[i];
        }
        else num[b[i]]=a[i];
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[110];
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	puts(n*m%2==0?"Even":"Odd");
}

Measured memory_bytes: 128