akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T, typename E>
struct SkewHeap{
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using C = function<bool(T,T)>;
  G g;
  H h;
  C c;
  T INF;
  E ei;
  SkewHeap(G g,H h,C c,T INF,E ei):g(g),h(h),c(c),INF(INF),ei(ei){}

  struct Node{
    Node *l,*r;
    T val;
    E add;
    Node(T val,E add):val(val),add(add){l=r=nullptr;}
  };

  void eval(Node *a){
    if(a==nullptr) return;
    if(a->add==ei) return;
    if(a->l) a->l->add=h(a->l->add,a->add);
    if(a->r) a->r->add=h(a->r->add,a->add);
    a->val=g(a->val,a->add);
    a->add=ei;
  }

  T top(Node *a){
    return a!=nullptr?g(a->val,a->add):INF;
  }

  T snd(Node *a){
    eval(a);
    return a!=nullptr?min(top(a->l),top(a->r)):INF;
  }

  Node* add(Node *a,E d){
    if(a!=nullptr) a->add=h(a->add,d);
    return a;
  }

  Node* push(T v){
    return new Node(v,ei);
  }

  Node* meld(Node *a,Node *b){
    if(!a||!b) return a?a:b;
    if(c(top(a),top(b))) swap(a,b);
    eval(a);
    a->r=meld(a->r,b);
    swap(a->l,a->r);
    return a;
  }

  Node* pop(Node* a){
    eval(a);
    auto res=meld(a->l,a->r);
    delete a;
    return res;
  }

};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using Heap=SkewHeap<int, int>;
  auto g=[](int a,int b){return a+b;};
  auto c=[](int a,int b){return a<b;};
  int INF = -1;
  Heap heap(g,g,c,INF,0);
  auto base=heap.push(0);

  string s;
  while(cin>>s,s!="end"){
    int x;
    if(s=="insert"){
      cin>>x;
      base=heap.meld(base,heap.push(x));
    }
    if(s=="extract"){
      x=heap.top(base);
      base=heap.pop(base);
      cout<<x<<"\n";
    }
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 34428
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    double N, K;
    cin >> N >> K;
    
    vector<double> p(N);
    REP(i, N) cin >> p[i];

    // 累積和
    vector<double> sum(N+1, 0);
    REP(i, N) sum[i+1] = sum[i] + p[i] + 1;

    // K差を見ていく
    double ans = 0;
    for(int i = 0; i+K <= N; i++)
        ans = maxs(ans, sum[i+K] - sum[i]);
        cout << fixed << setprecision(10) << (double)(ans) / 2 << endl;

    // double temp = 0;
    // double sum = 0;
    // for(int i = 0; i < K; i++) {
    //     sum += p[i];
    // }
    // temp = sum;
    // for(double i = K; i < N; i++) {
    //     temp -= p[i-K];
    //     temp += p[i];
    //     if (temp > sum) sum = temp;
    // }
    
    // double ans = 0;
    // ans = (sum + K) / 2;
    // printf("%.15f\n", ans);

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  vector<int> L(2*N);
  for (int i=0; i<2*N; i++) {
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  for (int j=0; j<N; j++) {
    ans=ans+L[2*j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
using System;
using static System.Console;

namespace abc174
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(ReadLine());
            var cList = ReadLine();
            var start = 0;
            var end = n - 1;
            var count = 0;
            while (start <= end)
            {
                if (cList[start] == 'R')
                {
                    ++start;
                }
                else if (cList[end] == 'W')
                {
                    --end;
                }
                else
                {
                    ++count;
                    ++start;
                    --end;
                }
            }
            WriteLine(count);
        }
    }
}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  string s;

  for(int i = 0; i < h; i++){
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

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

using namespace std;

int main()
{
	string s[8];
	vector<string> temp,temp2;
	rep(i,8)
	{
		cin >> s[i];
	}
	cout << 90 << endl;
	rep(i,8)
	{
		string t = "";
		for(int j=7;j>=0;j--)
		{
			t += s[j][i];
			cout << s[j][i];
		}
		temp.push_back(t);
		cout << endl;
	}

	cout << 180 << endl;
	rep(i,8)
	{
		string t = "";
		for(int j=7;j>=0;j--)
		{
			t += temp[j][i];
			cout << temp[j][i];
		}
		temp2.push_back(t);
		cout << endl;
	}

	cout << 270 << endl;
	rep(i,8)
	{
		for(int j=7;j>=0;j--)
		{
			cout << temp2[j][i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int ii = 1; ii <= k; ii++) {
                ans += gcd(gcd(i, j), ii);
            }
        }
    }
    cout << ans;
    //----------------------------------------------------------------------
    #ifdef LOCAL
        cout << "\n";
        cerr << "Time elapsed: " << (double)clock()/CLOCKS_PER_SEC << "s.\n";
    #endif
}
/*

*/


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

int main() {
    string o, e;
    cin >> o >> e;
    for (int i = 0; i < o.length() + e.length(); i++) {
        if (i % 2 == 0) cout << o[i / 2];
        else cout << e[i / 2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");

        int sum=0;
        int[] time = new int[n];
        for(int i=0; i<str.length; i++){
            time[i] = Integer.parseInt(str[i]);
            sum += time[i];
        }

        int m = Integer.parseInt(br.readLine());
        for(int i=0; i<m; i++){
            str = br.readLine().split(" ");
            int idx = Integer.parseInt(str[0]);
            int effect = Integer.parseInt(str[1]);

            System.out.println(sum - time[idx-1] + effect);
        }
    }
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(){
  int i,j,N,A[100],tmp,count=0,min;
  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  for(i = 0; i < N; i++){
    min = i;
    for(j = i; j < N; j++){
      if(A[j] < A[min]){
    min = j;
      }
    }  
    tmp = A[i];
    A[i] = A[min];
    A[min] = tmp;
    if(min != i){
      count++;
    } 
  }
  for(i = 0; i < N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <algorithm>

using namespace std;

int main()
{
    const long long inf = 2000000000;
    int n, w;
    cin >> n >> w;
    long long cost[n];
    long long value[n];
    const int max_n = 100;
    const int max_v = 1000;
    vector<vector<long long>> dp(max_n + 2);

    for (int i = 0; i < n; ++i){
        cin >> cost[i] >> value[i];
    }
    for (int i = 0; i <= n+1; ++i){
        dp[i].resize(max_n * max_v + 1);
    }

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < max_n * max_v + 1; ++j){
            if(i == 0 && j == 0){
                dp[0][0] = 0;
            }
            else {
                dp[i][j] = inf;
            }
        }
    }
    
    for (int i = 0; i <= n; ++i){
        for (int j = 0; j < max_n * max_v + 1; ++j){
            if(j - value[i] >= 0){
                dp[i+1][j] = min(dp[i][j], dp[i][j-value[i]] + cost[i]);
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    
    int res;
    for (int i = 0; i < max_n * max_v + 1; ++i){
        if(dp[n+1][i] <= w){
            res = i;
        }
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    int ans;

    if ((a + W) < b)
    {
        ans = b - W - a;
    }
    else if (b < a)
    {
        ans = a - (b + W);
    }
    else
    {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
'use strict';
let lines = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
lines.pop();
let n = parseInt(lines[0].split(' ')[0]);
let t = new Array(10).fill(false);
for(let d of lines[1].split(' ')) t[parseInt(d)] = true;
for(; ; n++) {
	let m = n;
	while(m > 0) {
		let d = m % 10;
		if(t[d]) break;
		m = (m - d) / 10;
	}
	if(m == 0) break;
}
console.log(n);

Measured memory_bytes: 9464
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl;
#define FLG(flg) if(flg) cout << "Yes" << endl; else cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define COUT(s) cout << s << endl;
#define AN vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
#define IN  int n;  cin >> n;
#define VI  vector<int> 
#define SS stringstream ss;
#define SOLVE cout << solve() << endl;

int main () {
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(),t.end());
    int ans = 0;
    REP(i, s.length()) {
        if (s[i] != t[i]) ans++;
    }
    ANS(ans/2)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, ptr, res;
int A[100000];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);

  sort(A, A + N);

  while (ptr < N) {
    int cc = A[ptr], f = 0;
    while (ptr < N && A[ptr] == cc) {
      f++;
      ptr++;
    }
    res += f % 2;
  }
  printf("%d\n", res);
}


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

const int MOD = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);

    int n,m;
    cin >> n >> m;
    vector<long long>x(n),y(m);
    for(int i=0;i<n;i++)
        cin >> x[i];
    for(int i=0;i<m;i++)
        cin >> y[i];

    long long sum1 = 0;

    for(int i=0;i<n;i++){
        sum1=(sum1+x[i]*(2*i+1-n))%MOD;
    }

    long long sum2 = 0;

    for(int i=0;i<m;i++){
        sum2=(sum2+y[i]*(2*i+1-m))%MOD;
    }

    cout << (sum1*sum2+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


int main() {
	ll mod = 1e9 + 7;
	ll n, m; cin >> n >> m;
	vector<ll> X(1+n), Y(1+m);
	REP(i, 1, 1+n) cin >> X[i];
	REP(i, 1, 1+m) cin >> Y[i];
	ll sum_x = 0;
	ll sum_y = 0;
	REP(i, 1, n) sum_x = (sum_x + i * (n - i) * (X[i + 1] - X[i])) % mod;
	REP(j, 1, m) sum_y = (sum_y + j * (m - j) * (Y[j + 1] - Y[j])) % mod;
	PRI(sum_x * sum_y % mod);
	return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int p,q,r;
    cin>>p>>q>>r;
    cout << p+q+r-max({p,q,r})<<"\n";
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };

int ans[600][600];
void disp(int h, int w) {
	rep(i, h) {
		rep(j, w) {
			if (j)cout << ' '; cout << ans[i][j];
		}cout << endl;
	}
}
signed main() {
	int H, W, h, w; cin >> H >> W >> h >> w;
	
	rep(i, h) {
		rep(j, w) {
			if (i == h - 1 && j == w - 1)ans[i][j] = -(600*(h*w-1)+1);
			else ans[i][j] = 600;
		}
	}
	
	for (int i = h; i < H; i++) {
		rep(j, W) {
			ans[i][j] = ans[i - h][j];
		}
	}

	rep(i, H) {
		for (int j = w; j < W; j++) {
			ans[i][j] = ans[i][j - w];
		}
	}


	int sum = 0;
	rep(i, H)rep(j, W)sum += ans[i][j];
	if (sum <= 0)puts("No");
	else {
		puts("Yes");
		disp(H, W);
	}
}

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

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

X = [0 for i in range(N)]
Y = [0 for i in range(N)]

for i in range(1, N):
    X[i] = gcd(X[i-1], A[i-1])

for i in range(N-1)[::-1]:
    Y[i] = gcd(Y[i+1], A[i+1])

Z = [gcd(X[i], Y[i]) for i in range(N)]
print(max(Z))


Measured memory_bytes: 14584
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



int main() {

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

	int h, n;
	cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		sum += a;
	}

	if (h <= sum) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}



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

int main(void)
{
  int a, k;
  string s;
  cin >> a >> s >> k;
  k = k - 1;
  string ans = "";
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == s[k])
    {
      ans += s[k];
    }
    else
      ans += "*";
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;


  if(x-r<0 || y-r<0 || x+r>w || y+r>h)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 3112
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);
    
    writeln(n & 1 ? n * 2 : n);
}









































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);
//ll dx[4] = {1,0,-1,0};
//ll dy[4] = {0,1,0,-1};

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;

int main() {
	ll n,sum=0,ans=0,sumb=0;
	cin >> n;
	vll a(n), b(n), sa;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	rep(i, n) {
		cin >> b[i];
		sumb += b[i];
	}
	if (sum < sumb) {
		cout << -1 << endl;
		return 0;
	}

	ll ret = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			ans++;
			ret += (b[i] - a[i]);
		}
		else {
			ll x = a[i] - b[i];
			sa.push_back(x);
		}
	}
	//cout << ret << endl << endl;
	sort(reall(sa));
	//rep(i, sa.size()) cout << sa[i] << endl;
	if (ret == 0) ans = 0;
	else {
		rep(i, sa.size()) {
			if (ret > 0) ret -= sa[i], ans++;
		}
	}
	cout << ans << endl;
	//rep(i, n) cout << a[i] - b[i] << endl;
	return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <fstream>
#include <cstdio>
#include <math.h>
#include <limits>
#include <string>
#include <vector>
#include <time.h>
#include <stdlib.h>
using namespace std;

bool exist(int s, int n, int set[]) {
	int count;
	bool output;
	count=0;
	output=false;
	while (count!=n) {
		if (set[count]==s) {
			output=true;
		}
		count++;
	}
	return output;
}

int main() {
	int s;
	int n;
	int current;
	int count;
	int min;
	scanf("%d", &s);
	scanf("%d", &n);
	int* coin=new int[s];
	int* set=new int[n];
	count=0;
	while (count!=s) {
		coin[count]=0;
		count++;
	}
	count=0;
	while (count!=n) {
		scanf("%d", &set[count]);
		count++;
	}
	current=0;
	while (current!=s) {
		current++;
		if (exist(current, n, set)==true) {
			//printf("coin[%d]: 1\n", current);
			coin[current-1]=1;
		}
		else {
			min=0;
			count=0;
			while (count!=n) {
				if (current-set[count]>0) {
					if (coin[current-set[count]-1]<min || min==0) {
						min=coin[current-set[count]-1];
					}
				}
				count++;
			}
			//printf("coin[%d]: %d\n", current, min+1);
			coin[current-1]=min+1;
		}
	}
	printf("%d\n", coin[current-1]);
	return 0;
}

Measured memory_bytes: 1384
#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}

	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			int a,b;
			cin>>a>>b;
			if(a-2*b<=0) cout<<0<<endl;
			else cout<<a-2*b<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <algorithm>
#define ll long long
#define all(a) (a).begin(),(a).end()

int main(int argc, char const *argv[]) {
  while(1){
    int m=0,nmin=0,nmax=0;
    scanf("%d%d%d",&m,&nmin,&nmax);
    if(m==0 && nmin==0 && nmax==0){
      break;
    }
    std::vector<int> p(m+1);
    for (int i = 1; i <= m; i++) {
      scanf("%d",&p[i]);
    }
    int temp=0,memo=0,memoid=0;
    for (int i = nmin; i <= nmax; i++) {
      temp=p[i]-p[i+1];
      memo=std::max(memo,temp);
      if(memo==temp) memoid=i;
    }
    p.erase(all(p));
    printf("%d\n",memoid);
  }
  return 0;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
 
using namespace std;
 
struct Node
{
	int pare = -1;
	vector<int> nowHow;
	int howChild = 0;
};
 
int n, b;
Node a[100010];
 
void check(int now, int how){
	a[now].nowHow.push_back(how);
 
	// cout << a[now].nowHow.size() << " - " << a[now].howChild << "=" << how << endl;
	if((a[now].nowHow.size() != a[now].howChild && a[now].howChild != 0) || a[now].pare == -1) return;
 
	int nextHow = 0;
	sort(a[now].nowHow.begin(), a[now].nowHow.end());
 
	int ret = max(a[now].howChild, 1);
	for(int i = 0;i < ret;i++){
		nextHow = max(nextHow, a[now].nowHow[i] + (ret - i));
	}
 
	check(a[now].pare, nextHow);
}
 
int main(){
	cin >> n;
	for(int i = 0;i < n - 1;i++){
		cin >> b;
		b--;
		a[i + 1].pare = b;
		a[b].howChild++;
	}
 
	// cout << "-----" << endl;
	vector<int> leaf;
	for(int i = 0;i < n;i++){
		if(a[i].howChild == 0){
			check(i, 0);
			// cout << i << endl;
		}
	}
 
	sort(a[0].nowHow.begin(), a[0].nowHow.end());
	int ans = 0, howSize = a[0].nowHow.size() - 1;
	for(int i = 0;i < a[0].nowHow.size();i++){
		ans = max(ans, a[0].nowHow[i] + (howSize - i));
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 15104
use std::io;
use std::str::FromStr;
use std::str::Chars;
use std::i32;
use std::u8;
use std::f64;
use std::ascii::AsciiExt;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::io::prelude::*;
use std::time::Duration;
use std::cmp;

macro_rules! println_stderr(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! print_stderr(
    ($($arg:tt)*) => { {
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

fn main() {
    let n = next_int();
    let a = next_ints();
    let mut ans = 1e8 as i64;
    for i in -100..101 {
        let mut cost = 0;
        for e in a.clone() {
            cost += (e-i).pow(2);
        }
        ans = cmp::min(ans,cost);
    }
    println!("{}",ans);
}

#[allow(dead_code)]
fn next_string() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

#[allow(dead_code)]
fn next_strings() -> Vec<String> {
    let input = next_string();
    input.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn next_int() -> i64 {
    let input = next_string();
    i64::from_str(input.trim()).unwrap()
}

#[allow(dead_code)]
fn next_ints() -> Vec<i64> {
    let input = next_string();
    input.split_whitespace().map(|x| x.parse().unwrap()).collect()
}


Measured memory_bytes: 380
#include<stdio.h>
int main(void){
  int a,b;

  scanf("%d",&a);
  scanf("%d",&b);
  if(a<b) printf("a < b\n");
  else if(a>b) printf("a > b\n");
  else if(a==b) printf("a == b\n");
  return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;

class Main
{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    System.out.println( ((a < b && b < c) ? "Yes" : "No"));
  }
}

Measured memory_bytes: 26196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100010

int main()
{
	int n, c, sum = 0;
	cin >> n;
	for (int i = 1;i <= n;++i)
	{
		cin >> c;
		sum ^= c;
	}
	if (sum)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,a[20];

int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = 0;
  if(solve(i+1,m)||solve(i+1,m-a[i]))res=1;
  return res; 
}

int main(){
  int q,m[2000],i;
  int ans;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  
  for(i=0;i<q;i++){
    ans = solve(0,m[i]);
    if(ans)printf("yes\n");
    else printf("no\n");
  }
  
  
  return 0;
}






Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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

  cout << (t+s);

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, R, B, W, G;
	
	scanf("%d" "%d" "%d" "%d", &R ,&B, &W, &G);
	
	a = R + B + W + G;
	
	printf("%d\n", a);
		
	return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    char c; cin >> c;
    cout << char(c+1) << endl;
    return 0;
}

Measured memory_bytes: 256
input = raw_input().split(' ')
K = int(input[0])
T = int(input[1])
input = raw_input().split(' ')
max_num = 0
sum_num = 0
for i in range(0, T):
  temp = int(input[i])
  if max_num < temp:
    max_num = temp
  sum_num += temp

if max_num <= sum_num - max_num + 1:
  print "0"
else:
  print max_num - (sum_num - max_num) - 1


Measured memory_bytes: 2568
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>

using namespace std;


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

    uint32_t H[100000];
    int arrayA[100000];
    for(int i=0;i<N;i++){
        cin>> H[i];
        arrayA[i]=1;
    }

    for(int i=0;i<M;i++){
        int temp1,temp2;
        cin >> temp1>>temp2;

        if(H[temp1-1] > H[temp2-1]){
            arrayA[temp2-1]=0;
        }
        else if(H[temp1-1] == H[temp2-1]){
            arrayA[temp2-1]=0;
            arrayA[temp1-1]=0;
        }
        else{
            arrayA[temp1-1]=0;
        }
    }

    int countnum=0;
    for(int i=0;i<N;i++){
        if(arrayA[i] ==1){
            countnum++;
        }
    }
    cout<<countnum<<endl;

}



Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
vector<int> parent(200005), sze(200005);
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    sze[v] = 1;
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (sze[a] < sze[b])
            swap(a, b);
        parent[b] = a;
        sze[a] += sze[b];
    }
}
vector<int> adj[200005], deg(200005);
int mx=0;
map<pair<int, int>, int> mp;
void solve(){
    int n, m;
    cin>>n>>m;
    FOR(i, 1, n+1) {
        make_set(i);
    }
    FOR(i, 0, m) {
        int a, b; cin>>a>>b;
        if(find_set(a)!=find_set(b)){
            union_sets(a, b);
        }
    } 
    FOR(i, 1, n+1) {
        mx = max(mx, sze[i]);
    }
    cout<<mx;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

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

int main() {

 long long int A=0;
 long long int B=0;
 long long int C=0;
 long long int D=0;
 long long int LCM=0;
 long long int ANS=0;

 //入力
 int ret = scanf("%lld %lld %lld %lld", &A , &B , &C , &D);
 if( ret == EOF ) {
    printf( "scanfでエラー\n" );
    return -1;
  }
 
 //CとDの最大公約数を求める(n)
 long long int m=C;
 long long int n=D;
 long long int temp=0;
 //m>nとなるように入替
 if(m<n){
  temp=m;
  m=n;
  n=temp;
 }
 temp = m % n;
 while (temp != 0)
 {
 	m = n;
	n = temp;
	temp = m % n;
 }
 if (n != 0){
  //最大公約数
   LCM = C * D / n;
   ANS = (B-A+1) - (B/C - (A-1)/C) - (B/D - (A-1)/D) + (B/LCM - (A-1)/LCM);
 }
 else if(n == 0){
  ANS = (B-A+1) - (B/C - (A-1)/C) - (B/D - (A-1)/D);
 }

 printf("%lld",ANS);

 return (0);
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const ll INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 7;
const int maxm = 1e5 + 7;
const int mod = 192600817;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
    IO;
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=a*min(n,(b-1))/b;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define pie 3.141592653589793238
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long plus, zero, minus, k;
  cin >> plus >> zero >> minus >> k;
  
  if(k-plus<=0){
    cout << k << endl;
  }
  else if(k-plus-zero<=0){
    cout << plus << endl;
  }
  else if(k-plus-zero-minus<=0){
    cout << plus-(k-(plus+zero)) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
a,b,c,x,y = map(int,input().split())


A = 0
B = 0
res = 0

if c*2 <= a+b:
    res += min(x,y)*2*c
    A = min(x,y)
    B = min(x,y)

if x > A:
    res += (x-A)*min(2*c,a)
if y > B:
    res += (y-B)*min(2*c,b) 
print(res)


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

class TSort{
public:
  int V;
  vector<unordered_set<int> > in,out;
  vector<int> tp;
  TSort():V(0){}
  TSort(int V):V(V),in(V),out(V){}
  
  void add_edge(int from,int to){
    assert(from >= 0 && to >= 0);
    assert(from < V && to < V);
    out[from].insert(to);
    in[to].insert(from);
  }

  vector<int> dfs(){
    vector<int> visited(V,0);
    
    function<void(int)> dfs = [&](int pos){
      if(visited[pos]++) return;
      for(int nx:out[pos]) dfs(nx);
      tp.push_back(pos);
    };
    
    tp.clear();
    for(int i=0;i<V;i++) dfs(i);
    reverse(tp.begin(),tp.end());
    return tp;
  }

  vector<int> bfs(){
    auto tmp = in;
    tp.clear();
    queue<int> Q;
    for(int i=0;i<V;i++)if(in[i].empty()) Q.push(i);
    
    while(!Q.empty()){
      int v = Q.front();Q.pop();
      tp.push_back(v);
      for(int nx:out[v]){
        if(in[nx].size() == 1) Q.push(nx);
        in[nx].erase(v);
      }     
    }
    for(int i=0;i<V;i++) if(!in.empty()) tp.clear(); // exist loop
    tmp = in;
    return tp;
  }
};


int main(){
  int n,m;
  cin>>n>>m;
  TSort A(n);
  
  for(int i=0,a,b;i<m;i++)cin>>a>>b,A.add_edge(a,b);
  
  A.bfs();
  for(int i=0;i<n;i++)cout<<A.tp[i]<<endl;
  return 0;
}



Measured memory_bytes: 10668
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for (int i = 0; i < n; i++) {
			
			if (sc.next().charAt(0) == 'Y') {
				System.out.println("Four");
				return;
			}
			
		}
		
		System.out.println("Three");
		
	}

}

Measured memory_bytes: 21716
h,w = map(int,input().split())
l = [list(map(str,input().split())) for i in range(h)]
m = [chr(i) for i in range(ord('A'),ord('Z'))]

for i in range(h):
    for j in range(w):
        if l[i][j] == 'snuke':
            print(m[j] + str(i + 1))
            break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

struct Point{
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(x*a, y*a); }
  Point operator / (double a) { return Point(x/a, y/a); }

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

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;

struct Segment{
  Point p1, p2;
};

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

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

Point project(Segment s, Point p){
  Vector a = s.p2 - s.p1;
  Vector b = p - s.p1;
  return s.p1 + a * (dot(a, b)/a.norm());
}

Point reflect(Segment s, Point p){
  return p + (project(s, p) - p)*2;
}

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Point p1 = Point(x1, y1);
  Point p2 = Point(x2, y2);
  Segment s = {p1, p2};

  int q; cin >> q;
  rep(i, q){
    int x, y; cin >> x >> y;
    Point p = Point(x, y);
    Point ans = reflect(s, p);
    cout << fixed << setprecision(10);
    cout << ans.x << " " << ans.y << endl;
  }

  return 0;

}



Measured memory_bytes: 3296
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {

    string S; cin>>S;
    int Q; cin>>Q;
    int reversecount=0;
    string mae, ato;
    for (int i = 0; i < Q; ++i) {
        int T; cin>>T;
        if(T==1){
            reversecount++;
        }else{
            int F; cin>>F;
            char C; cin>>C;
            bool original = true; //元の文字列
            if(reversecount%2==0){ //元の状態だから
                original = true;
                if(F==1){
                    mae = C + mae;
                }else{
                    ato = ato + C;
                }

            }else{
                original = false;
                if(F==1){
                    ato = ato +C;
                }else{
                    mae = C + mae;
                }
            }
        }
    }

    if(reversecount%2==0){
        cout<<mae<<S<<ato<<endl;
    }else{
        S = mae + S + ato;
        reverse(S.begin(),S.end());
        cout<<S<<endl;
    }

    return 0;
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	ll x; cin>>x;
	cout<<360/__gcd(360ll,x);
	
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main (void)
{
  int rate;
  char str[8];
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&rate);
  if(rate < 1200)
  {
    printf("ABC\n");
  }
  else
  {
    printf("ARC\n");
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <memory.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <time.h>
#include <assert.h>
#include <cmath>
#include <stack>
#include <string.h>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d", &n);
	vector<pair<int, int> > w;
	for (int i = 0; i < n; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		w.push_back({ l,r });
	}
	ll res = 1e18;
	for (int it = 0; it < 1; ++it) {
		ll kk = 0;
		for (int jt = 0; jt < 2; ++jt) {
			ll k = 0;
			ll cur = 0;
			multiset<pair<int, int> > mn, mx;
			for (int i = 0; i < n; ++i) {
				int l = w[i].first;
				int r = w[i].second;
				if (it == 1) {
					l = -l;
					r = -r;
					swap(l, r);
				}
				mx.insert(make_pair(l, r));
				mn.insert(make_pair(r, l));
			}
			for (int i = 0; i < n; ++i) {
				if (((i % 2) ^ jt) == 0) {
					auto u = *--mx.end();
					mx.erase(--mx.end());
					int l = u.first;
					int r = u.second;
					mn.erase(mn.find(make_pair(r, l)));
					if (cur > r) {
						k += cur - r;
						cur = r;
					}
					else if (l > cur) {
						k += l - cur;
						cur = l;
					}
				}
				else {
					auto u = *mn.begin();
					mn.erase(mn.begin());
					int l = u.second;
					int r = u.first;
					mx.erase(mx.find(make_pair(l, r)));
					if (cur > r) {
						k += cur - r;
						cur = r;
					}
					else if (l > cur) {
						k += l - cur;
						cur = l;
					}
				}
			}
			k += abs(cur);
			kk = max(kk, k);
		}
		res = min(res, kk);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10356
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n=sc.nextInt();
        int tmp;
        long sum=0;
        long minus=0;
        long min=Integer.MAX_VALUE;
        for(int i=0;i<n;i++){
            tmp=sc.nextInt();
            sum+=Math.abs(tmp);
            if(tmp<0){
                minus++;
            }
            min=Math.min(min,Math.abs(tmp));
        }
        System.out.println(minus%2==0?sum:sum-min*2);
    }
}

Measured memory_bytes: 49548
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size))           \
  scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name)
#define DEBUG(...) debug(__LINE__,__VA_ARGS__)
#define MOD 1000000007

using namespace std;

string to_string(string s) { return s; }

template <class T>
string to_string(vector<T> v) {
	string ret = "{";
	FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
	if (v.size() > 0) {
		ret += to_string(LAST(v));
	}
	ret += "}";
	return ret;
}

void debug_print() { cerr << endl; }

template <class Head, class... Tail>
void debug_print(Head head, Tail... tail) {
	cerr << to_string(head) << " ";
	debug_print(tail...);
}

template <class... T>
void debug(T... args) {
	debug_print(args...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
	cout << to_string(head);
	print(tail...);
}

int main() {
	ll N;
	cin>>N;
	ll a=1,b=1;
	FOR(i,N){
		ll A,T;
		cin>>A>>T;
		ll ma=(a+A-1)/A,mb=(b+T-1)/T;
		a=A*max(ma,mb);
		b=T*max(ma,mb);
	}
	print(a+b);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n;
ll a[60];

bool is_ok(ll mid){
	ll sum=0;
	// x*n-(mid-x)>=a[i]-(n-1)
	REP(i, n){
		if(a[i]-(n-1)+mid-1>=0){
			sum+=(a[i]-(n-1)+mid-1)/(n+1)+1;
		}
		if(sum>mid){
			return false;
		}
	}
	return sum<=mid;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n;
	REP(i, n){
		cin>>a[i];
	}
	ll lb=-1, ub=1e18;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(is_ok(mid)){
			ub=mid;
		}
		else{
			lb=mid;
		}
	}
	// DEBUG(ub);
	ll ans=0;
	for(ll i=max(0ll, ub-1000); i<ub+1000; ++i){
		if(is_ok(i)){
			ans=i;
			break;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int A,B;
scanf ("%d %d",&A,&B);
if(A>=0 && A<=23 && B<=23 && B>=0 && A+B<=23){
printf ("%d\n",A+B);
return 0;
}else if((A+B)>=24){
printf ("%d\n",(A+B)-24);
return 0;
}else {
scanf("%d %d",&A,&B);
}
return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

bool check(string s, string t){
  for(int i = 1; i < 26; ++i){
    for(int j = 0; j < (int)s.size(); ++j){
      if(s[j] == 'a' + i){
	--s[j];
	if(s[j] != t[j]) return false;
	break;
      }
      if(s[j] < 'a'+i && s[j] != t[j]) return false;
    }
  }
  return true;
}

void make(set<string> &S, string s, string ret, int i){
  //cout << ret << endl;
  if(s.size() == ret.size()) S.insert(ret);
  string ret1 = ret + string(1,s[i]), ret2 = ret + string(1,s[i]+1);
  //cout << ret1 << " " << ret2 << endl;
  if(check(ret1,s)) make(S,s,ret1,i+1);
  if(s[i] < 'z' && check(ret2,s)) make(S,s,ret2,i+1);
}

int main(){
  string s;
  while(cin >> s, s != "#"){
    set<string> S;
    make(S,s,"",0);
    cout << S.size() << endl;
    if(S.size() < 11){
      for(set<string>::iterator itr = S.begin(); itr != S.end(); ++itr)
	cout << *itr << endl;
    }else{
      set<string>::iterator itr = S.begin();
      vector<string> V;
      for(int i = 0; i < 5; ++i){
	V.push_back(*itr);
	++itr;
      }
      itr = S.end();
      for(int i = 0; i < 5; ++i){
	--itr;
	V.push_back(*itr);
      }
      sort(V.begin(),V.end());
      for(int i = 0; i < 10; ++i)
	cout << V[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X,Y = map(int,read().split())

A = [X]
while A[-1] <= Y:
    A.append(A[-1] * 2)

answer = len(A) - 1
print(answer)

Measured memory_bytes: 3060