akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;



namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            //string A = Console.ReadLine();//Aから読み込む
            string[] s = Console.ReadLine().Split(' ');//　文字たちを読み込む
            int A = int.Parse(s[0]);//
            int B = int.Parse(s[1]);//
            int K = (A+B) /2;
            
            //string s = Console.ReadLine();//こいつだけは文字列
            //ここまでが入力部分でーす💛
            if(Math.Abs(A-K) == Math.Abs(B-K)){
           Console.WriteLine(K);
            }else{
           Console.WriteLine("IMPOSSIBLE");     
            }
        }
    }
}




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

using namespace std;

int main() {
	int n, cnt = 0;
	string s;

	cin >> n >> s;

	for (int i = 0; i < 1000; i++) {
		int c[3] = { i / 100, (i / 10) % 10, i % 10 };
		int f = 0;
		for (int j = 0; j < n; j++) {
			if (s[j] == ('0' + c[f])) f++;
			if (f == 3) {
				cnt++;
				break;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
n.times do
    b = gets.chomp.each_char.map{|c| sprintf("%04b", c.to_i(16))}.join
    sign = (b[0] == ?0 ? '' : ?-)
    x = b[1..-1].to_i(2).to_f / 2 ** 7
    puts sign + x.to_s
end


Measured memory_bytes: 6908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    string s = inp1;
    int n = s.length();

    // 文字の距離をとるだけでよい
    vector<vector<int>> pos(26, vector<int>());
    rep(i, n) {
        pos[(s[i] - 'a')].emplace_back(i);
    }

    int a, b;
    a = b = -1;
    rep(i, 26) {
        int sz = pos[i].size();
        rep(j, sz - 1) {
            if (pos[i][j + 1] - pos[i][j] <= 2) {
                a = pos[i][j] + 1;
                b = pos[i][j + 1] + 1;
                i = 26;
                break;
            }
        }
    }

    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 1144
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define entire(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
void solve()
{
	ll n;
	cin >> n;
	std::vector<ll> v(n);
	rep(i, n)cin >> v[i];
	ll res = 0;
	repe(i, 1, n) {
		if (v[i] >= v[i - 1])
			continue;
		res += v[i - 1] - v[i];
		v[i] = v[i - 1];
	}
	cout << res << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	int T = 1;
	// cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 4776
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	ll x,y;
	cin>>x>>y;
	y=y/x;
	cout<<__lg(y)+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

double ratio[2][1001];
double hit[1001];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    MEMSET(ratio, 0);
    MEMSET(hit, 0);
    ratio[0][0] = 1.0;
    double ans = 0;
    REP(i, n) {
      int next = (i + 1) & 1;
      MEMSET(ratio[next], 0);
      double p = 1.0;
      REP(j, 100) {
        hit[j] += p * ratio[i & 1][j];
        ratio[next][0] += (1 - p) * ratio[i & 1][j];
        ratio[next][j + 1] += p * ratio[i & 1][j];
        p /= 2.0;
      }
      ratio[next][99] += ratio[next][100];
    }
    for (int i = 100 - 1; i >= 0; i--) {
      ans += hit[i];
    }
    printf("%.8f\n", ans);
  }
}

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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  if(i%2==1&&a[i]%2==1)cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3

A, B, K = map(int,input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1

        B += A / 2
        A -= A / 2
        
    else:
        if B % 2 == 1:
            B -= 1
    
        A += B / 2
        B = B / 2

print(int(A),int(B))




Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;


int main(int argc, char* argv[]){
int X;
scanf("%d",&X);

if(X>=30){
	printf("Yes\n");
}else{
	printf("No\n");
}

}


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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    if (s == "Sunny") writeln("Cloudy");
    else if (s == "Cloudy") writeln("Rainy");
    else if (s == "Rainy") writeln("Sunny");
}


Measured memory_bytes: 256
from heapq import heappush, heappop

INF = float("inf")

N, M, *LRC = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i in range(N - 1):
    E[i + 1].append((i, 0))
for l, r, c in zip(*[iter(LRC)] * 3):
    E[l - 1].append((r - 1, c))

D = [INF] * N
D[0] = 0

Q = [(0, 0)]
while Q:
    dist, cur = heappop(Q)
    for nxt, cost in E[cur]:
        cand = dist + cost
        if D[nxt] > cand:
            D[nxt] = cand
            heappush(Q, (cand, nxt))

print(-1 if D[N - 1] == INF else D[N - 1])


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<int> b(n - 1);
	for(auto &x : b){
		cin>>x;
	}
	ll ans = b[0] + b.back();
	for(int i = 1; i + 1 < n; i++){
		ans += min(b[i - 1], b[i]);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset> //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip> //do setprecision
#include <ctime>
#include <complex>
using namespace std;

int main(void){
  int A,B,C;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  if((A+B)>=C){
   printf("Yes\n"); 
  }else{
    printf("No\n");
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> dp1(n),dp2(n),dp3(n);
    for(int i=0;i<n;i++){
        int a,b,c;
        cin >> a >> b >> c;
        if(i == 0){
            dp1.at(i) += a;
            dp2.at(i) += b;
            dp3.at(i) += c;
            //cout << dp1.at(i) << " " << dp2.at(i) << " " << dp3.at(i) << endl;
        }else{
            dp1.at(i) += max(dp2.at(i-1),dp3.at(i-1)) + a;
            dp2.at(i) += max(dp1.at(i-1),dp3.at(i-1)) + b;
            dp3.at(i) += max(dp1.at(i-1),dp2.at(i-1)) + c;
            //cout << dp1.at(i) << " " << dp2.at(i) << " " << dp3.at(i) << endl;
        }
    }
    cout << max(dp1.at(n-1),max(dp2.at(n-1),dp3.at(n-1))) << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    int a,b,c;
    int t;
    int ans=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(a>c)
    {
        t=a;
        a=c;
        c=t;
    }
    if(b>c)
    {
        t=b;
        b=c;
        c=t;
    }
    if(a%2==0&&b%2==0&&c%2==0)
    {
        ans=(c-a)/2+(c-b)/2;
    }
    else if(a%2!=0&&b%2!=0&&c%2!=0)
    {
        ans=(c-a)/2+(c-b)/2;
    }
    else if(a%2==0&&b%2==0&&c%2!=0)
    {
        ans++;
        ans+=(c-a-1)/2+(c-b-1)/2;
    }
    else if(a%2==0&&b%2!=0&&c%2==0)
    {
        ans++;
        ans+=(c-a)/2+(c+1-b)/2;
    }
    else if(a%2!=0&&b%2==0&&c%2==0)
    {
        ans++;
        ans+=(c+1-a)/2+(c-b)/2;
    }
    else if(a%2!=0&&b%2!=0&&c%2==0)
    {
        ans++;
        ans+=(c-a-1)/2+(c-b-1)/2;
    }
    else if(a%2!=0&&b%2==0&&c%2!=0)
    {
        ans++;
        ans+=(c-a)/2+(c+1-b)/2;
    }
    else if(a%2==0&&b%2!=0&&c%2!=0)
    {
        ans++;
        ans+=(c+1-a)/2+(c-b)/2;
    }
    printf("%d\n",ans);
    return 0;
}






















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

using namespace std;
int n;
int arr[100005];


int dp(int n,vector<int> &Dp){
	if(Dp[n]!=-1){
		return Dp[n];
	}
	if(n<=0){
		return 1000000;
	}
	if(n==1){
		return 0;
	}
	int ans=min(dp(n-2,Dp)+abs(arr[n]-arr[n-2]),dp(n-1,Dp)+abs(arr[n]-arr[n-1]));
    Dp[n]=ans;
  
    return Dp[n];
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	vector<int> Dp(n+1,-1);
	cout<<dp(n,Dp)<<endl;

}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {
  int n,k;
  cin>>k>>n;
  vi a(n);
  for(int i=0;i<n;i++)cin>>a[i];

    int ans=INT_MAX;
    for(int i=0;i<n;i++)
    {
      if(i==0)
      ans=min(ans,min((a[n-1]-a[0]),k-(a[1]-a[0])));
      else if(i==n-1)
        ans=min(ans,min((a[n-1]-a[0]),k-(a[n-1]-a[n-2])));
      else ans=min(ans,min(k-(a[i]-a[i-1]),k-(a[i+1]-a[i])));
    }

    cout<<ans;

  //while loop ending 
  }

return 0;
}

Measured memory_bytes: 1792
#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 n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n);
  rep(ri, 2 ){
        { // solve R
            int count = 0;
            rep(i, n) {
                if (s[i] == 'R') {
                    count++;
                } else {
                    ans[i] += count / 2;
                    ans[i - 1] += (count + 1) / 2;
                    count = 0;
                }
            }
        }

        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());

        rep(i, n) {
            if (s[i] == 'L') {
                s[i] = 'R';
            } else {
                s[i] = 'L';
            }
        }
  }

  rep(i, n) {
      printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 1024
import Control.Applicative

main :: IO ()
main = solve <$> readLn >>= putStrLn

solve :: Int -> String
solve n = f 0 50000
  where
    f s l
      | s + 1 == l = ":("
      | t == n = show m
      | t < n = f m l
      | t > n = f s m
      where
        m = (s + l) `div` 2
        t = tax m
        
tax :: Int -> Int
tax = (flip div 100) . (* 108)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long a[3*N];
    for(int i = 0; i < 3*N; i++){
        cin >> a[i];
    }
    sort(a, a+N*3);
    reverse(a, a+N*3);
    long sum = 0;
    // 偶数番目を足してく
    for(int i = 0; i < N; i++){
        sum += a[2*i+1];
    }
    cout <<  sum << endl;
}

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

int main() {
  int H, W;
  string S, pre, cur, post;
  cin >> H >> W;
  rep(i, H){
    if(i > 0) pre = cur;
    if(i == 0) cin >> cur;
    else cur = post;
    if(i < H-1) cin >> post;
    rep(j,W){
      if(cur.at(j)=='#'){
        cout << '#';
        continue;
      }
      int ans = 0;
      if(i>0){
        if(j>0&&pre.at(j-1)=='#') ans++;
        if(pre.at(j)=='#') ans++;
        if(j<W-1&&pre.at(j+1)=='#') ans++;
      }
      if(j>0&&cur.at(j-1)=='#') ans++;
      if(j<W-1&&cur.at(j+1)=='#') ans++;
      if(i<H-1){
        if(j>0&&post.at(j-1)=='#') ans++;
        if(post.at(j)=='#') ans++;
        if(j<W-1&&post.at(j+1)=='#') ans++;
      }
      cout << ans;
    }
    cout << endl;
  }
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;

    Vi v(3*n);
    REP(i, 3*n) cin >> v[i];

    Vl plus(n+1);
    priority_queue<int, V<int>, greater<int>> q;
    ll sum = 0;
    REP(i, n) {
        q.push(v[i]);
        sum += v[i];
    }
    plus[0] = sum;
    REP2(i, n, 2*n) {
        q.push(v[i]);
        int x = q.top(); q.pop();
        sum += v[i];
        sum -= x;
        plus[i-n+1] = sum;
    }

    Vl minus(n+1);
    priority_queue<int> q2;
    sum = 0;
    RREP(i, 3*n-1, 2*n) {
        q2.push(v[i]);
        sum += v[i];
    }
    minus.back() = sum;
    RREP(i, 2*n-1, n) {
        q2.push(v[i]);
        int x = q2.top(); q2.pop();
        sum += v[i];
        sum -= x;
        minus[i-n] = sum;
    }

    ll maxi = -1e18;
    REP(i, n+1) {
        maxi = max(maxi, plus[i] - minus[i]);
    }
    std::cout << maxi << '\n';

    return 0;
}


Measured memory_bytes: 4088
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)n - 1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
typedef pair<ll, ll> pll;

struct edge {
    int to, cost;
};
typedef vector<vector<edge>> AdjList;
AdjList graph;

typedef pair<int, int> P;
const int INF = 1e9;

vector<int> dist;
vector<int> prever;

void dijkstra(int n, int s) {
    dist = vector<int>(n, INF);
    prever = vector<int>(n, -1);
    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) {
            continue;
        }
        for (int i = 0; i < graph[v].size(); i++) {
            edge e = graph[v][i];
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                prever[e.to] = v;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
}

vector<int> get_path(int t) { //頂点tへの最短路
    vector<int> path;
    for (; t != -1; t = prever[t]) {
        path.push_back(t);
    }

    reverse(path.begin(), path.end());
    return path;
}

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

    int n, m;
    cin >> n >> m;
    graph = AdjList(n);
    map<pll, bool> used;
    for (int i = 0; i < m; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        from--, to--;
        graph[from].push_back((edge){to, cost});
        graph[to].push_back((edge){from, cost});
    }

    rep(i, n) {
        dijkstra(n, i);
        for (int j = i + 1; j < n; j++) {
            vector<int> path = get_path(j);
            rep(k, path.size() - 1) {
                used[{path[k], path[k + 1]}] = true;
                used[{path[k + 1], path[k]}] = true;
            }
        }
    }

    cout << m - (int)(used.size() / 2) << endl;
    return 0;
}

Measured memory_bytes: 3696
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()

if N==1:
    print(X[-1] - X[0])
else:
    D = [X[i+1]-X[i] for i in range(len(X)-1)]
    #print(D)
    D.sort()
    print(sum(D[:-(N-1)]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    ll ans = 1;
    const int mod = 1e9+7;
    if (n % 2 == 1){
        if (mp.find(0) == mp.end() || mp[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 2; i <= n-1; i += 2){
            if (mp[i] != 2){
                cout << 0 << endl;
                return 0;
            }
            ans *= 2;
            ans %= mod;
        }
    }else{
        for(int i = 1; i <= n-1; i += 2){
            if (mp[i] != 2){
                cout << 0 << endl;
                return 0;
            }
            ans *= 2;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6556
#include <stdio.h>

#define NUMBER_MAX (123456*2)

int sosuu_num[NUMBER_MAX+1];

void make_sosuu_num_list(void) {
	int i,j;
	for(i=0;i<=NUMBER_MAX;i++)sosuu_num[i]=1;
	sosuu_num[0]=sosuu_num[1]=0;
	for(i=2;i<=NUMBER_MAX;i++) {
		if(sosuu_num[i]) {
			for(j=i+i;j<=NUMBER_MAX;j+=i)sosuu_num[j]=0;
		}
	}
	for(i=1;i<=NUMBER_MAX;i++)sosuu_num[i]+=sosuu_num[i-1];
}

int main(void) {
	int n;
	make_sosuu_num_list();
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",sosuu_num[2*n]-sosuu_num[n]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

  

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,ans = 0;
	cin >> n;
	vector<pair<int,int>> fact;
	if(n == 1){
		cout << 0 << "\n";
		return 0;
	}
	bool pr = true;
	ll store = n;
	for(ll fac = 2;fac * fac <= store;fac++){
		int cnt = 0,ansc = 0;
		while(n % fac == 0){
			pr = false;
			n /= fac;
			cnt++;
		}
		int check{0};
		for(int j{1};check+j <= cnt;j++){
			check += j;
			ansc++;
		}
		ans += ansc;
	}
	if(n != 1){
		ans++;
	}
	if(pr){
		cout << 1 << "\n";
		return 0;
	}
	cout << ans << "\n";
	return 0;
}





Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 char b;
 cin >> b;
  
  if (b == 'A'){
    cout << 'T' << endl;
  }
  else if (b == 'T'){
    cout << 'A' << endl;
  }
  else if (b == 'G'){
    cout << 'C' << endl;
  }
  else if (b == 'C'){
    cout << 'G' << endl;
  }
    
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end()))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    while (true) {
        int m, n;
        cin >> m >> n;
        if (m == 0 && n == 0) { break; }
        vector<string> s(n);
        rep(i, n) { cin >> s[i]; }
        auto pow = [](int a, int n) {
            int ret = 1;
            rep(i, n) { ret *= a; }
            return ret;
        };
        vint dp(pow(3, m));
        for (int i = pow(3, m) - 1; i >= 0; i--) {
            string state = "";
            rep(j, m) { state.push_back(i / pow(3, j) % 3 + '0'); }
            int cnt = 0;
            rep(j, n) {
                bool ok = true;
                rep(k, m) {
                    if (s[j][k] == '0' && state[k] == '2') { ok = false; }
                    if (s[j][k] == '1' && state[k] == '1') { ok = false; }
                }
                if (ok) { cnt++; }
            }
            if (cnt <= 1) { continue; }
            dp[i] = LLONG_MAX;
            rep(j, m) {
                if (state[j] != '0') { continue; }
                int p = pow(3, j);
                chmin(dp[i], max(dp[i + p * 1], dp[i + p * 2]) + 1);
            }
        }
        cout << dp[0] << endl;
    }
}


Measured memory_bytes: 4400
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        if h == 0 or h == H - 1:
            print('#' * W)
            continue
        print('{}{}{}'.format('#', '.'*(W-2), '#'))
    print()



Measured memory_bytes: 5616
/**
 *    author:  morato
 *    created: 29.08.2020 17:10:22
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> v(5);
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
    if (!v[i]) {
      ans = i + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

const int N = 1e2;

map<int, int> mp;

inline int solve(int s)
{
    mp.clear();
    int i = 1;
    while (true) {
        if (mp.count(s)) return i;
        mp.insert({s, 1});
        s = s&1 ? s*3+1 : s/2;
        ++i;
    }
}

int main()
{
    int s;
    cin >> s;
    cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"20"# => r#"15800"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize,
        b: usize,
    }

    (if a + b > 23 { a + b - 24 } else { a + b }).to_string()
}

Measured memory_bytes: 4352
$s = <STDIN>;

chomp $s;
my @dat =  split(//,$s);

$N = length $s;
$T = ($N-1)/2;
$A =  substr($s, 0, $T);
$B = reverse($A);
$flag = 0;
if($A eq $B ){
  #print "Yes\n";
}else{
  $flag = 1;
  #print "No\n";
}
$T2 = ($N+3)/2;
$A =  substr($s, $T2-1, $N);
$B = reverse($A);
if($A eq $B ){
  #print "Yes\n";
}else{
  $flag = 1;
  #print "No\n";
}
$A =  $s;
$B = reverse($A);
if($A eq $B ){
  #print "Yes\n";
}else{
  $flag = 1;
  #print "No\n";
}


if($flag == 0 ){
  print "Yes";
}else{
  print "No";
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int enum_divisors(int N)
{
    vector<int> res;
    for (int i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    return res.size();
}

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

    if(a+b>=c)  puts("Yes");
    else    puts("No");

    return 0;
}

Measured memory_bytes: 3632
import std.stdio,std.string,std.conv,std.algorithm,std.array;
 
void main()
{
    bool[501][501] M;
    while(true)
    {
        int n, m;
        string line=readln.chomp;
        try{n=line.to!int;}catch(Exception e){ throw new Exception(line);}
        try{m=readln.chomp.to!int;}catch(Exception e){ throw new Exception("m");}
 
        if(n==0&&m==0)break;
 
        foreach(unused;0..m)
        {
            int[] input;
            try{input=readln.split.map!(to!int).array;}catch(Exception e){ throw new Exception("list");}
            M[input[0]][input[1]]=true;
            M[input[1]][input[0]]=true;
        }
 
        int[int] num;
 
        foreach(i; 1..n+1)
        {
            if(M[1][i])
            {
                num[i]=0;
 
                foreach(j; 2..n+1)
                {
                    if(M[i][j])
                    {
                        num[j]=0;
                    }
                }
            }
        }
 
        writeln(num.length);
 
        foreach(i; 1..n+1) foreach(j; 1..n+1) M[i][j]=false;
    }
}

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

int main() {
    string S, T;
    int count = 0;
    cin >> S >> T;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == T.at(i)){
            continue;
        }
        count++;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3812
N=gets.to_i
A=gets.split.map(&:to_i).each.with_index.map{|a,i|a-i}

h=Hash.new{|h,k|h[k]=0}
A.each do |a| h[a]+=1 end
ans=0
A.each.with_index do |a,i|
  ans+=h[-a-i-i]
  h[a]-=1
end
p ans

Measured memory_bytes: 47748
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    
    int tmp=MIN(a-b,c);
    printf("%d\n", c-tmp);

    return 0;
}


Measured memory_bytes: 128
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
k = int(input())
 
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            ans += gcd(i,j,l)
 
print(ans)

Measured memory_bytes: 69644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int ppre=0;
    int pre=0;
    vector<int>kaisa;
    vector<int>kaikaisa;
    int A;
    int sum=0;
    int disN_1;
    int disN;
    for(int i=0;i<N;i++){
        cin>>A;
        if(i==N-2){disN_1=abs(A);}
        if(i==N-1){disN=abs(A);}
        kaisa.push_back(abs(A-pre));
        sum+=abs(A-pre);
        if(i>=1){
            kaikaisa.push_back(abs(A-ppre));
        }
        ppre=pre;
        pre=A;       
    }
    for(int i=0;i<N;i++){
        if(i!=N-1){
            cout<<sum-kaisa[i]-kaisa[i+1]+kaikaisa[i]+disN<<endl;
        }
        else{
            cout<<sum-kaisa[N-1]+disN_1<<endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll W, H, x, y;
	double max = 0;

	cin >> W >> H >> x >> y;

	max = (double)W * H / 2;
	ll m;
	if (2*x == W && 2*y == H) m = 1;
	else m = 0;

	cout << fixed << setprecision(7) << max << " ";
	cout << m << "\n";
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
INF = 10 ** 8
N, M, R = map(int,input().split())
r = list(map(lambda x: int(x)-1 ,input().split()))
MAP = [[INF for i in range(N)] for j in range(N)]
for i in range(M):
    A, B, C = map(int,input().split())
    MAP[A-1][B-1] = C
    MAP[B-1][A-1] = C
for k in range(N):
    for i in range(N):
        for j in range(N):
            MAP[i][j] = min(MAP[i][j], MAP[i][k] + MAP[k][j])

ans = INF
for L in permutations(r):
    temp = 0
    for i in range(R-1):
        temp += MAP[L[i]][L[i+1]]
    ans = min(ans, temp)
print(ans)

Measured memory_bytes: 47192
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	cout<<n*n*n<<endl;
	return 0;
}

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

#define MOD 1000000007

using namespace std;

int bitmask[1<<21];
bool chk[1<<21];
queue<int> q;

int main()
{
  vector<int> data;
  int n;

  scanf("%d",&n);
  data.resize(n);
  bitmask[0]=1;
  q.push(0);
  chk[0]=true;
  for(int c=0;c<n;c++)
  {
    for(int c2=0;c2<n;c2++)
    {
      scanf("%d",&data[c2]);
    }
    while(!q.empty()&&__builtin_popcount(q.front())==c)
    {
      for(int c2=0;c2<n;c2++)
      {
        if (data[c2]&&(q.front()&(1<<c2))==0)
        {
          bitmask[q.front()|(1<<c2)]+=bitmask[q.front()];
          bitmask[q.front()|(1<<c2)]%=MOD;
          if (!chk[q.front()|(1<<c2)])
          {
            q.push(q.front()|(1<<c2));
            chk[q.front()|(1<<c2)]=true;
          }
        }
      }
      q.pop();
    }
  }
  printf("%d\n",bitmask[(1<<n)-1]);
}


Measured memory_bytes: 12032
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
inline int max(R int x,R int y){return x>y?x:y;}
inline int min(R int x,R int y){return x<y?x:y;}
const int N=2e5+5,M=N*35,inf=0x3f3f3f3f;
int ls[M],rs[M],sz[M],rt[N],nd;
void ins(int &p,int q,int l,int r,int x){
	p=++nd,ls[p]=ls[q],rs[p]=rs[q],sz[p]=sz[q]+1;
	if(l==r)return;int mid=(l+r)>>1;
	x<=mid?ins(ls[p],ls[q],l,mid,x):ins(rs[p],rs[q],mid+1,r,x);
}
int query(int p,int q,int l,int r,int ql,int qr){
	if(!(sz[p]-sz[q])||ql<=l&&qr>=r)return sz[p]-sz[q];
	int mid=(l+r)>>1,res=0;
	if(ql<=mid&&query(ls[p],ls[q],l,mid,ql,qr))return 1;
	if(qr>mid&&query(rs[p],rs[q],mid+1,r,ql,qr))return 1;
	return 0;
}
struct node{
	int x,v;
	inline bool operator <(const node &b)const{return x<b.x;}
}a[N];
int b[N],las[N],f[N],mx[N],mn[N],sum[N];
int n;
inline int find(R int pos){
	R int l=0,r=pos-1,ans=pos-1,mid;
	while(l<=r){
		mid=(l+r)>>1;
//		printf("%d %d %d %d %d\n",pos,l,r,mid,query(rt[pos-1],rt[mid],1,n,mx[mid]+1,mn[pos]-1));
		if(mid==pos-1||mx[mid]+1>mn[pos]-1||!query(rt[pos-1],rt[mid],1,n,mx[mid]+1,mn[pos]-1))
			ans=mid,r=mid-1;
		else l=mid+1;
	}
	return ans;
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n)scanf("%d%d",&a[i].x,&a[i].v),b[i]=a[i].v;
	sort(a+1,a+1+n),sort(b+1,b+1+n);
	fp(i,1,n){
		a[i].v=lower_bound(b+1,b+1+n,a[i].v)-b;
		ins(rt[i],rt[i-1],1,n,a[i].v);
//		printf("%d %d %d\n",i,a[i].x,a[i].v);
	}
	mx[0]=0;fp(i,1,n)mx[i]=max(mx[i-1],a[i].v);
	mn[n+1]=inf;fd(i,n,1)mn[i]=min(mn[i+1],a[i].v);
//	printf("%d\n",find(n+1));
	fp(i,1,n+1)las[i]=find(i);
//	fp(i,1,n+1)printf("%d %d\n",i,las[i]);
	f[0]=sum[0]=1;
	fp(i,1,n+1){
		f[i]=dec(sum[i-1],(las[i]?sum[las[i]-1]:0));
		sum[i]=add(sum[i-1],f[i]);
	}
	printf("%d\n",f[n+1]);
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)

int M, K;

int main() {
    cin >> M >> K;
    int l = (1 << M);
    if (M == 1 && K == 1 || K >= l) {
        cout << -1 << endl;
        return 0;
    }
    if (M == 1 && K == 0) {
        cout << "0 0 1 1" << endl;
        return 0;
    }
    REP (i, l) if (i != K) {
        cout << i << " ";
    }
    cout << K << " ";
    REPR (i, l) if (i != K) {
        cout << i << " ";
    }
    cout << K << endl;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  
  int count=0;
  for(int i=1; i<=n-2; i++){
    if(p[i-1] < p[i] && p[i] < p[i+1]){
      count++;      
    }
    else if(p[i-1] > p[i] && p[i] > p[i+1]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S = [list(ST().replace("a","0").replace("b","1").replace("c","2"))[::-1] for _ in range(3)]
    term = 0
    while True:
        nex = S[term].pop()
        term = int(nex)
        if not S[term]:
            if term == 0:
                print("A")
            elif term == 1:
                print("B")
            else:
                print("C")
            exit()
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#define prob CandyAddict
#ifdef  DEBUG
#define MAXN 100300
#else
#define MAXN 100300
#endif

#include <bits/stdc++.h>

using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define endl '\n'
#define PI  3.141592653589793238
#define MOD (1000000007)
#define INF (1100000000)
#define EPS 0.00000001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);//use flush(cout)
#endif
    ll N;
    cin>>N;
    for (int n=1;n<=3500;n++)
        for (int h=1;h<=3500;h++) {
            ll num = N*n*h;
            ll deno = 4*n*h-N*(n+h);
            if ( deno !=0 && num%deno==0 ) {
                ll ans = num/deno;
                if (ans>0  ) {
                    cout<<h<<" "<<n<<" "<<ans;
                    return 0;
                }
            }

        }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string num;
    while(1){
        int sum=0;
        cin>>num;
        if(num[0]=='0'){
            break;
        }
        for(int i=0;i<num.size();i++){
            sum=sum+num[i]-'0';
        }
    
        cout<<sum<<endl;
    }
    
    return 0;
}


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

int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int n,i,a[3];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&a[0],&a[1],&a[2]);
        qsort(a,3,sizeof(int),compare);
        if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1]) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 2032
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C_kill = 0
try:
    for i in range(N):
        C_kill = C_kill + min(A[i], B[i])
        B[i] = max(0, B[i]-A[i])
        C_kill = C_kill + min(A[i+1], B[i])
        A[i+1] = max(0, A[i+1] - B[i])
except:
    print("ERROR")

print(C_kill)

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

int main() {
  double n, a, s = 0;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  for(int i = 0; i < n; i++){
    a = 10000000000 / v.at(i);
    s += a;
  }
  double u = (10000000000 / s);
  cout << fixed << setprecision(10);
  cout << u << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	static Scanner sc=new Scanner(System.in);
	static PrintWriter pr=new PrintWriter(System.out);
	public static void main(String[] args) {
		while(sc.hasNext()){
			char a[]=sc.next().toCharArray();
			for(int i=0;i<a.length;i++){
				if(a[i]=='@'){
					for(int j=0;j<a[i+1]-'0';j++){
						System.out.print(a[i+2]);

					}
					i+=2;
				}else {
					System.out.print(a[i]);
				}
			}
			System.out.println();
			
		}
	}
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    map < int , int > ans ;

    int n , x , y ;
    cin >> n >> x >> y ;

    for ( int i = 1 ; i <= n ; i ++ )
    {
        for ( int j = i + 1 ; j <= n ; j ++ )
        {
            int d = j - i ;
            d = min ( d , abs ( x - i ) + 1 + abs ( y - j ) ) ;
            d = min ( d , abs ( y - i ) + 1 + abs ( x - j ) ) ;

            ans[d] ++ ;
        }
    }

    for ( int i = 1 ; i < n ; i ++ )
    {
        cout << ans[i] ;
        line ;
    }
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int N[10],i,j,h,max;
 
  for(i=0;i<10;i++){ scanf("%d",&N[i]); }
  for(i=0;i<10;i++){
    max=i;
    for(j=i;j<10;j++){
      if(N[j]>N[max]){ max=j ;}
    }
    h=N[max];
    N[max]=N[i];
    N[i]=h;
  }
  printf("%d\n%d\n%d\n",N[0],N[1],N[2]);
 
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    string A, B;
    cin >> A >> B;
    
    int a = A.size();
    int b = B.size();

    if (a == b)
    {
        int now = a;
        for(int i = 0; i < now; i++) {
            if(A.at(i) > B.at(i)) {
                a = 3;
                b = 1;
                break;
            } else if(A.at(i) < B.at(i)) {
                a = 1;
                b = 3;
                break;
            }
        }
    }
    
    

    if (a > b)
    {
        cout << "GREATER" << endl;
    } else if (a < b) {
        cout << "LESS" << endl;
    } else {
        cout << "EQUAL" << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 3636