akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int q;
  cin >> q;
  vector<int> x(q), y(q);
  for(int i = 0; i < q; i++) cin >> x[i] >> y[i];

  auto copy = a;
  sort(copy.begin(), copy.end());

  int outnum = 0;
  for(int i = 0; i < n; i++){
    if(a[i] != copy[i]) outnum++;
  }

  if(outnum == 0){
    cout << 0 << endl;
    return 0;
  }
  int ans = -1;
  int j = 0;
  while(outnum != 0 && j != q){

    if(a[x[j] - 1] == copy[x[j] - 1]) outnum++;
    if(a[y[j] - 1] == copy[y[j] - 1]) outnum++;

    if(a[y[j] - 1] == copy[x[j] - 1]) outnum--;
    if(a[x[j] - 1] == copy[y[j] - 1]) outnum--;

    // スワップ
    int tmp = a[x[j] - 1];
    a[x[j] - 1] = a[y[j] - 1];
    a[y[j] - 1] = tmp;
    j++;
    if(outnum == 0) ans = j;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7644
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    auto c = [&](ll x) {
        string s = to_string(x);
        string t = s;
        reverse(all(t));
        bool ok = true;
        rep(i, 0, s.size()) {
            ok &= s[i] == t[i];
        }
        return ok;
    };
    ll ans = 0;
    rep(i, a, b + 1) {
        if(c(i)) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int contestProblems, numberOfSubmissions;

  	cin >> contestProblems >> numberOfSubmissions;

  	int wa[106000];
  	bool ac[105000];

  	for (int i = 1; i < contestProblems; ++i) {
  	    ac[i] = false;
  	    wa[i] = 0;
  	}

    int problemNumber;
    string result;

    int wrongAnswers = 0;
    int correctAnswers = 0;

    for (int i = 0; i < numberOfSubmissions; ++i) {
        cin >> problemNumber >> result;

        if (ac[problemNumber]) {
            continue;
        }
        if (result == "AC") {
            ac[problemNumber] = true;
            correctAnswers++;
            wrongAnswers += wa[problemNumber];
        } else if (result == "WA") {
            wa[problemNumber]++;
        }
    }

    cout << correctAnswers << " " << wrongAnswers;

    return 0;
}





Measured memory_bytes: 768
d[5],i;
main(){
	for(;~scanf("%d",d+i);i++);
	for(qsort(d,5,4,"\x8b\1+\6\xc3");i;printf("%d%c",d[i],--i?32:10));
for(i=0; i<10000000; i++)d[0] = d[1];        
return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

string base = string("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	string S;
	cin >> N >> S;
	for (ll n = 0; n < S.size(); n++) {
		ll st = S[n] - 'A';
		cout << base.substr((st + N) % 26, 1);
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

all = (a + b + c).sort

count = 0
4.times do |i|
  if all.count(i + 1) == 2
    count += 1
  end
end

if count == 2
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll N;
pair<ll,ll> P[200010];
pair<ll,ll> Q[200010];

int main(){
   cin >> N;
   rep(i,N){
      cin >> P[i].first >> P[i].second;
      Q[i].first = P[i].first - P[i].second;
      Q[i].second = P[i].first + P[i].second;
   }
   ll Mx = -INF,mx = INF,My = -INF,my = INF;
   rep(i,N){
      Mx = max(Mx,Q[i].first);
      mx = min(mx,Q[i].first);
      My = max(My,Q[i].second);
      my = min(my,Q[i].second);
   }
   cout << max(Mx-mx,My-my) << endl;
}

Measured memory_bytes: 9832
h,n,*t=map(int,open(0).read().split())
dp=[10**18]*(h+1)
dp[0]=0
for a,b in zip(*[iter(t)]*2):
    for j in range(h+1):
        dp[j]=min(dp[j],dp[max(0,j-a)]+b)
print(dp[h])

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

typedef vector<vector<int> > Matrix;

const int INF = 100000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
          // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
  int h,w;
  std::cin >> h>>w;
  d = Matrix(10, vector<int>(10, INF));
  for (int i = 0; i < 10; i++) {
    /* code */
    for (int j = 0; j < 10; j++) {
      /* code */
      std::cin >> d[i][j];
    }
  }
  warshall_floyd(10);
  int ans=0;
  
  for (int i = 0; i < h*w; i++) {
    /* code */
    int a;
    std::cin >> a;
    if(a!=-1){
      ans+=d[a][1];
      
    }
  }
  std::cout << ans << std::endl;
  
}

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

int n,now,sum = 0,large = -0x3f;

inline int read(){
	int s = 0,w = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		s = s*10+ch-'0';
		ch = getchar();
	}
	return s*w;
}

int main(){
	n = read();
	for(int i = 1;i <= n;++i){
		now = read();
		large = max(now,large);
		sum += now;
	}
	sum -= large;
	if(sum > large)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

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

    if (i == 1) {
        cout << "Hello World" << endl;
        return 0;
    }

    int a, b;
    cin >> a >> b;

    cout << a + b << endl;
}



Measured memory_bytes: 256
INF = 10**18

N, K, C = map(int, input().split())
S = input()

lt = [-INF for _ in range(K + 1)]
rt = [-INF for _ in range(K + 1)]

j = -1
for i in range(1, K + 1):
    while True:
        j += 1
        if S[j] == 'o' and j - lt[i - 1] > C:
            lt[i] = j
            break

j = -1
for i in range(1, K + 1):
    while True:
        j += 1
        if S[-1 - j] == 'o' and j - rt[i - 1] > C:
            rt[i] = j
            break

lt = lt[1:]
rt = rt[1:]
rt = [N - x - 1 for x in rt]
rt = rt[::-1]

res = []

for i in range(K):
    if lt[i] == rt[i]:
        res.append(lt[i] + 1)

print('\n'.join(map(str, res)))


Measured memory_bytes: 86688
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll a, b;
	cin >> a >> b;
	cin >> s;
	ll p = -1;
	ll f = 0;
	rep(i, s.size()) {
		if (s[i] == '-') {
			if (f == 1) {
				cout << "No" << endl;
				return 0;
			}
			p = i;
			f = 1;
		}
	}
	if (p == -1) {
		cout << "No" << endl;
		return 0;
	}
	else {
		if (a == p && (s.size() - (p + 1) == b)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

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

bool BinarySearch(vector<int> &s_array,int &n){
    vector<int> array = s_array;
    int first_index=0,final_index=(int)array.size();
    while(first_index<final_index){
        int half = (first_index + final_index) / 2;
        if(array.at(half) == n){
            return true;
        }else{
            if(array.at(half) < n){
                first_index = half + 1;
            }else{
                final_index = half;
            }
        }
    }
    return false;
}

int main(){
    int ns,nt,num,count=0;
    cin >> ns;
    vector<int> s_array(ns);
    for(int i=0; i<ns; i++) cin >> s_array.at(i);
    cin >> nt;
    for(int i=0; i<nt; i++){
        cin >> num;
        if(BinarySearch(s_array,num)){
            count ++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 100000000701247094
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll n;
  cin >> n;
  
  rep(i,100){
    if(jou(2,i)<=n && n<jou(2,i+1)) {
    cout << jou(2,i+1)-1 << endl;
    return 0;
    }
  }
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a,b,c = inputMap()
    
    tot = a+b+c
    cc = max(a,b,c)
    
    if tot - cc == cc:
        print("Yes")
    else:
        print("No")
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 39024
n = int(input())

task = []
for _ in range(n):
    a, b = map(int, input().split())
    task.append([a, b])

task = sorted(task, key=lambda x: x[1])

time = 0
for a, b in task:
    time += a
    if time > b:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 39584
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
typedef long long ll;
#define MAX_V 10000
const ll INF = 1LL << 50;
using namespace std;

struct edge{
  ll from,to,cost;
};

edge es[MAX_V];

ll d[MAX_V];
bool neg[MAX_V];
int V,E;

void Bellman_Ford(int s){
  for(int i=0;i<=V;i++)d[i]=INF;
  d[s]=0;
  ll cnt = 0;
  while(true){
    cnt++;
    bool update = false;
    for(int i=0;i<E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if(!update)break;
    if(cnt==V)return;
  }
}

bool find_negative_loop(){
  memset(neg,0,sizeof(neg));
  for(int i=0;i<V;i++){
    for(int j = 0; j < E;j++){
      edge e = es[j];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        neg[e.to]=true;
        if(i==V-1)return true;
      }
      if(neg[e.from])neg[e.to] = true;
    }
  }
  return false;
}

int main(){
  cin >> V >> E;
  ll a,b,c;
  for(int i=0;i<E;i++){
    cin >> a >> b >> c;
    es[i].from = a-1;
    es[i].to = b-1;
    es[i].cost = -1*c;
  }
  bool ch;
  Bellman_Ford(0);
  ll ret = -1*d[V-1];
  ch=find_negative_loop();
  if(ch&&neg[V-1])cout << "inf" << endl;
  else cout << ret << endl;
  return 0;
}


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

int main(){
    int n, tem, d;
    cin >> n;
    
    tem = n;
    d = 0;
    while ( tem > 0 ) {
        d += tem % 10;
        tem = tem / 10;
    }
    
    if ( n % d == 0 ) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return (0);
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define sz(a) (int)(a).size()

using namespace std;

typedef vector<int> vi;
typedef long long ll;


void reconstruct(vector<vi>& dp,string& a,string& b){
	int n=sz(a);
	int m=sz(b);
	int i=n,j=m;
	string s="";
	while(i!=0 && j!=0){
//		cout<<a[i-1]<<" "<<b[i-1];
		if(a[i-1]==b[j-1]){
			s+=a[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	reverse(s.begin(),s.end());
	cout<<s<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a,b;
	cin>>a>>b;
	int n=sz(a),m=sz(b);
	vector<vi> dp(n+1,vi (m+1));
	for(int i=0;i<n+1;i++){
		for(int j=0;j<m+1;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
				continue;
			}
			if(a[i-1]==b[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	reconstruct(dp,a,b);
}


Measured memory_bytes: 35584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[110][100010];

int main(){
  int n,W;
  cin >> n >> W;
  vector<int> w(n);
  vector<int> v(n);
  rep(i,n){
    cin >> w[i] >> v[i];
  }
  rep(i,n){
    rep(j,W+1){
      if(j+w[i]<=W) chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  ll ans=0;
  rep(j,W+1){
    chmax(ans,dp[n][j]);
  }
  cout << ans << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, p;

  while(cin >> n >> p, n+p) {
    VI m(n);
    int s = p;

    for(int i = 0; ; i++) {
      if(s > 0) {
	m[i%n]++;
	s--;
	
	if(m[i%n] == p) {
	  cout << i%n << endl;
	  break;
	}	
      }
      else {
	s += m[i%n];
	m[i%n] = 0;
      }
    }
  }
}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    mod_build();
    ll ans = 0;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll s = 0;
    rep(i,n-1){
        s += inv[i+1];
        s %= mod;
        ans += (a[i+1]-a[i])*s%mod;
    }
    ans %= mod;
    cout<<ans*fact[n-1]%mod<<endl;

    return 0;
}

Measured memory_bytes: 3456
def main():
  w, h, n = input_list()
  
  points = []
  for x in range(w):
    row = [True]*h
    points.append(row)
      
  for _ in range(n):
    x, y, a = input_list()
    if a == 1:
      for px, row in enumerate(points):
        for py, v in enumerate(row):
          if px+1 <= x:
            points[px][py] = False
    if a == 2:
      for px, row in enumerate(points):
        for py, v in enumerate(row):
          if px+1 > x:
            points[px][py] = False
    if a == 3:
      for px, row in enumerate(points):
        for py, v in enumerate(row):
          if py+1 <= y:
            points[px][py] = False
    if a == 4:
      for px, row in enumerate(points):
        for py, v in enumerate(row):
          if py+1 > y:
            points[px][py] = False
  ans = 0
  for p in points:
    ans += p.count(True)
  print(ans)

def input_list():
  return map(int, input().split())

import math
main()

Measured memory_bytes: 3188
//abc149A
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int n, k, i, cou=0, tmp, ax, bx;
  char a[100], b[100];
  scanf("%s %s", a, b);
  for(i=0; b[i] != '\0'; ++i) printf("%c", b[i]);
  for(i=0; a[i] != '\0'; ++i) printf("%c", a[i]);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;

const int MAXN = (int)1e5 + 5;

int hap[MAXN][3];
int dp[MAXN][3];

int main(void) {
    int n;

    scanf(" %d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            scanf(" %d", &hap[i][j]);
        }
    }

    for (int j = 0; j < 3; j++) {
        dp[1][j] = hap[1][j];
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], hap[i][j] + dp[i - 1][k]);
                }
            }
        }
    }
    int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 2560
import Control.Monad
import Data.List

main = do
  li <- getLine
  let [n,m] = map read $ words li
  scs <- forM [1..m] (\_ -> do
    li <- getLine
    let [s,c] = map read $ words li
    return (s,c)
    )
  let ans = compute n scs
  print ans

compute :: Int -> [(Int,Int)] -> Int
compute n scs
  | not (ok c1) = -1
  | otherwise = inner n
  where
    [c1,c2,c3] = [ nub $ findAll i scs | i <- [1..3] ]
    ok c = null c || singleton c
    dig d c = if null c then d else head c
    d1 = dig 1 c1
    d2 = dig 0 c2
    d3 = dig 0 c3
    inner 1 | null c1 && null c2 && null c3 = 0
    inner 1 | null c2 && null c3 = d1
    inner _ | d1 == 0 = -1
    inner 2 | ok c2 && null c3 = d1 * 10 + d2
    inner 3 | ok c2 && ok c3 = d1 * 100 + d2 * 10 + d3
    inner _ = -1

findAll _ [] = []
findAll x ((y,z):yzs)
  | x == y = z : findAll x yzs
  | True   = findAll x yzs

singleton [_] = True
singleton _ = False


Measured memory_bytes: 508
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
bool f(string s) {
	bool a = 1;
	char c = s[0];
	rep(i, s.size()) {
		if (s[i] != c)a = 0;
	}
	return a;
}
string s;
ll v[26];
int main() {
	cin >> s;
	rep(i, s.size()) {
		v[s[i] - 'a'] = 1;
	}
	string ss = s;
	ll ans = INF;
	rep(i, 26) {
		if (v[i]) {
			ll ct = 0;
			while (!f(ss)) {
				++ct;
				rep(j, ss.size() - 1) {
					if (ss[j] == 'a' + i || ss[j + 1] == 'a' + i)ss[j] = 'a' + i;
				}
				ss.pop_back();
			}
			//cout << ss << endl;
			ss = s;
			ans = min(ct, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int pos = 0;
    int ans = 0;
    while(pos < n)
    {
        while(pos+1 < n && a[pos] == a[pos+1]) pos++;
        if(pos == n-1)
        {
            ans++;
            break;
        }
        bool inc = false;
        if(a[pos] < a[pos+1]) inc = true;
        if(inc)
        {
            while(pos+1 < n && a[pos] <= a[pos+1]) pos++;
        }
        else
        {
            while(pos+1 < n && a[pos] >= a[pos+1]) pos++;
        }
        if(pos == n-1)
        {
            ans++;
            break;
        }
        pos++;
        ans++;
    }
    cout << ans << endl;
}



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

constexpr int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
constexpr int INF = 1e9;

struct state {
    int y, x, infected;
    bool operator<(state const& s) const {
        return make_tuple(y, x, infected) < make_tuple(s.y, s.x, s.infected);
    }
};

bool is_in(int y, int x, int n) {
    return (0 <= y && y < n && 0 <= x && x < n);
}

int next_infected(int y, int x, int infected, int n) {
    int res = 0;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<n; ++j) {
            if(i == y && j == x) {
                continue;
            }
            int cnt = 0;
            for(int k=0; k<8; ++k) {
                int adj_y = i + dy[k];
                int adj_x = j + dx[k];
                if(!is_in(adj_y, adj_x, n)) {
                    continue;
                }
                cnt += (adj_y == y && adj_x == x) || (infected >> (adj_y * n + adj_x)) & 1;
            }
            if((infected >> (i * n + j)) & 1) {
                if(cnt == 2 || cnt == 3) {
                    res |= 1 << (i * n + j);
                }
            } else {
                if(cnt == 3) {
                    res |= 1 << (i * n + j);
                }
            }
        }
    }
    return res;
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<string> v(n);
        int sy, sx, sinfected = 0;
        for(int i=0; i<n; ++i) {
            cin >> v[i];
            for(int j=0; j<n; ++j) {
                if(v[i][j] == '@') {
                    sy = i;
                    sx = j;
                } else if(v[i][j] == '#') {
                    sinfected |= 1 << (i * n + j);
                }
            }
        }
        map<state, int> memo;
        memo[state{sy, sx, sinfected}] = 0;
        queue<state> que;
        que.push(state{sy, sx, sinfected});
        int res = INF;
        while(!que.empty()) {
            auto now = que.front();
            que.pop();
            if(now.infected == 0) {
                res = memo[now];
                break;
            }
            for(int i=0; i<8; ++i) {
                int ny = now.y + dy[i];
                int nx = now.x + dx[i];
                if(!is_in(ny, nx, n) || (now.infected >> (ny * n + nx)) & 1) {
                    continue;
                }
                int next_inf = next_infected(ny, nx, now.infected, n);
                auto next = state{ny, nx, next_inf};
                if(memo.count(next) == 0) {
                    memo[next] = memo[now] + 1;
                    que.push(next);
                }
            }
        }
        cout << (res == INF ? -1 : res) << endl;
    }
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    //取りうる得点のリストを作り、ソート後大きいほうから10で割り切れるかを調べ、割り切れないものを出力すればよい
    //制約の値が小さいので2次元DPで取りうる値は求められるはず

    int n;
    cin >> n;

    int dp[101][10001] = {};

    dp[0][0] = 1;

    for(int i = 1; i <= n; i++){
        int tmp;
        cin >> tmp;

        for(int j = 0; j <= 10000; j++){
            if(dp[i - 1][j] == 1){
                dp[i][j + tmp] = 1;
                dp[i][j] = 1;
            }
        }
    }

    int ans = 0;

    for(int i = 10000; i >= 0; i--){
        if(dp[n][i] == 1 && i % 10 != 0){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			
			for(int i=0; i < W; i++){
				System.out.print("#");
			}
			System.out.println("");
			
			for(int i=1; i < H-1; i++){
				System.out.print("#");
				
				for(int j=1; j < W-1; j++){
					System.out.print(".");
				}
				System.out.println("#");
		}
			
			if(H > 1){
				for(int i=0; i < W; i++){
					System.out.print("#");
				}
				System.out.println("");
			}
		System.out.println("");
	    }
	    sc.close();
	}
}


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

int main() {
  int x,y;
  cin >> x >> y ;
  
  if ( x%500 <= y ) {
    
    cout << "Yes" << endl;
  }
  
  else if ( x%500 > y ) {
    
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 256
import           Data.Char (toLower)

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  s <- getLine
  putStrLn $ solve n k s

solve :: Int -> Int -> String -> String
solve _ k s = take (k - 1) s ++ (toLower (s !! (k - 1)) : drop k s) where


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  int max =0;
  cin >> N;
  vector<string> adder(N);
  for(int i = 0;i<N;i++){
    cin >> adder[i];
  }
  cin >> M;
  vector<string> disser(M);
  for(int i=0;i<M;i++){
    for(int i = 0;i<N;i++){
    cin >> disser[i];
    }
  }
  while(adder.size()>0){
    int x = 0;
    string y = adder[0];
    for(int i=0;i<adder.size();i++){
      if(adder[i] == y){
        x++;
      }
    }
    for(int i = 0;i<disser.size();i++){
      if(disser[i] == y){
        x--;
      }
    }
    if(x > max){
      max = x;
    }
    adder.erase(std::remove(adder.begin(), adder.end(), y), adder.end());
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A;
int B;
int C;
int X;
int main(){
  int i, k, res=0;
  rd(A);
  rd(B);
  rd(C);
  rd(X);
  for(i=0;i<A+1;i++){
    int j;
    for(j=0;j<B+1;j++){
      k = X - 500*i - 100*j;
      if(0 <= k  &&  k <= 50*C){
        res++;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B, C, X;
// {
//   int i, k, res = 0;
//   rd(A,B,C,X);
//   rep(i,A+1) rep(j,B+1){
//     k = X - 500i - 100j;
//     if(0 <= k <= 50C) res++;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> v) {
  double result = 0.0;

  sort(all(v));
  result = v.at(0);
  FOR(i, 1, N) { result = 0.5 * (result + v.at(i)); }

  cout << result << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &v[i]);
  }
  solve(N, std::move(v));
  return 0;
}


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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define _REP(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

using namespace std;

int main(){
    double n;

    cin >> n;

    if(n == 1)cout <<setprecision(6) << 1.000000 << endl;
    else {
        if(int(n)%2 == 0)cout <<  setprecision(6) << 0.5 << endl;
        else {
            int b = n/2;
            double a =  (b + 1)/n;
            cout << setprecision(6) << a << endl;
        }

    }

    return 0;
}

Measured memory_bytes: 256
S = list(input())
S = S[::-1]
exist = [[S[0]]]
work = []
now_idx = 0
for i in range(1,len(S)):
    work.extend(S[i])
    if work != exist[now_idx]:
        exist.append(work)
        work = []
        now_idx += 1
print(len(exist))

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

using namespace std;

struct Edge {
    int u;
    int v;
    long long c;
    Edge() {}
    Edge(int u, int v, long long c): u(u), v(v), c(c) {}
};

struct PqEle {
    int u;
    int num;
    long long content;
    PqEle() {}
    PqEle(int u, int num, long long content): u(u), num(num), content(content) {}
    bool operator <(const PqEle& o) const {
        return make_pair(num, content) > make_pair(o.num, o.content);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    auto t0 = clock();
    int n, m;
    long long l;
    cin >> n >> m >> l;
    vector<vector<Edge>> adj_list(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        --a;
        --b;
        if (c <= l) {
            adj_list[a].push_back(Edge(a, b, c));
            adj_list[b].push_back(Edge(b, a, c));
        }
    }
    int q;
    cin >> q;
    vector<pair<int, int>> queries(q);
    for (int i = 0; i < q; ++i) {
        cin >> queries[i].first >> queries[i].second;
        --queries[i].first;
        --queries[i].second;
    }
    auto dijkstra = [&](int start_id) {
        priority_queue<PqEle> pq;
        pq.push(PqEle(start_id, 0, 0LL));
        vector<bool> visited(n, false);
        vector<int> dist(n, -1);
        while (!pq.empty()) {
            auto p = pq.top();
            int node_id = p.u;
            pq.pop();
            if (visited[node_id]) {
                continue;
            }
            dist[node_id] = p.num;
            visited[node_id] = true;
            for (auto& edge : adj_list[node_id]) {
                if (!visited[edge.v]) {
                    if (edge.c + p.content > l) {
                        pq.push(PqEle(edge.v, p.num + 1, edge.c));
                    } else {
                        pq.push(PqEle(edge.v, p.num, edge.c + p.content));
                    }
                }
            }
        }
        return dist;
    };
    vector<vector<int>> dists(n);
    for (int i = 0; i < n; ++i) {
        dists[i] = dijkstra(i);
    }
    for (auto q : queries) {
        cout << dists[q.first][q.second] << "\n";
    }
    cerr << "time used = " << (clock() - t0) << endl;
    return 0;
}


Measured memory_bytes: 5524
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    string s,t;
    cin>>t>>s;
    t+=s[s.length()-1];
    if(s==t)
        cout<<"Yes"<<endl;
    else
    {
            cout<<"No"<<endl;
    }
    
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

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

int N,M,C,b[25],ans;

int main()
{
	cin >> N >> M >> C;
	for(int i = 1; i <= M; i++) cin >> b[i];
	for(int i = 1; i <= N; i++){
		int sum = 0;
		for(int j = 1; j <= M; j++){
			int x;
			cin >> x;
			sum = sum + x*b[j];
		}
		if (sum + C > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;

  double v = a * a * b;

  double ans;
  if (v / 2.0 >= x) {
    ans = 90.0 - (atan2((2.0 * x) / (a * b), b) / 2 / M_PI) * 360.0;
  } else {
    ans = (atan2((2.0 * (v - x)) / (a * a), a) / 2 / M_PI) * 360.0;
  }

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL

template<typename T>
void show(vector<T>& v) {
    cout << '[';
    for (const T& e : v) {
        cout << e << ',';
    }
    cout << ']' << endl;
}

#endif

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

template<typename T>
vector<T> read_n(const size_t n) {
    T dummy;
    vector<T> v(n);
    for (size_t i = 0; i < n; i++) {
        cin >> dummy;
        v[i] = dummy;
    }
    return v;
}

template<typename T>
vector<T> read_n() {
    size_t n;
    cin >> n;
    return read_n<T>(n);
}

int main() {
  init();

  int n, a, b;
  string s;
  cin >> n >> a >> b;
  cin >> s;
  int t = a + b;

  int qual = 0;
  int q_ab = 0;

  for (const char& c: s) {
      switch(c) {
          case 'a':
              if (qual < t) {
                  cout << "Yes" << endl;
                  qual++;
              } else {
                  cout << "No" << endl;
              }
              break;
          case 'b':
              if (qual < t && q_ab < b) {
                  cout << "Yes" << endl;
                  qual++;
                  q_ab++;
              } else {
                  cout << "No" << endl;
              }
              break;
          case 'c':
              cout << "No" << endl;
              break;
      }
  }

  return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS() ios::sync_with_stdio(0);cin.tie(0);
#define mp(a,b) make_pair(a,b)
signed main()
{
	int a,b,c,d,k;
	while(cin>>a>>b>>c>>d>>k)
	{
		a=a*60+b;
		c=c*60+d;
		c-=a;
		if(c<0) c+=1440;
		cout<<c-k<<"\n";
	}
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            int n = sn.nextInt();
            long dp[] = new long[88];
            dp[0] = 2;
            dp[1] = 1;
            for (int i = 2; i <= n; i++) {
                dp[i] = dp[i - 1] + dp[i - 2];
            }
            System.out.println(dp[n]);
        }

    }
}



Measured memory_bytes: 21844
import numpy as np

n, m, x = map(int, input().split())
a = []
c = []
for _ in range(n):
    t = list(map(int, input().split()))
    c.append(t[0])
    a.append(t[1:])
a = np.array(a)

ans = 9999999999
for i in range(2 ** n):
    p = np.zeros(m)
    csum = 0
    for j in range(n):
        if i & (2 ** j):
            p += a[j]
            csum += c[j]
    if np.amin(p) >= x and csum < ans:
        ans = csum
if ans == 9999999999:
    print(-1)
else:
    print(ans)


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

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int multi_gcd(vector<int> n_list)
{
    int res = gcd(n_list.at(0), n_list.at(1));
    for (int i = 2; i < n_list.size(); i++)
    {
        res = gcd(res, n_list.at(i));
    }
    return res;
}

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> x(N), abs_x(N);
    rep(i, N)
    {
        cin >> x.at(i);
        x.at(i) -= X;
    }

    if (N == 1)
    {
        cout << abs(x.at(0)) << endl;
        return 0;
    }

    sort(x.begin(), x.end());

    rep(i, N) { abs_x.at(i) = abs(x.at(i)); }
    int n_gcd = multi_gcd(abs_x);
    cout << n_gcd << endl;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    V.at(a)++;
    V.at(b)++;
  }
  string ans = "YES";
  for (int i = 0; i < N; i++) {
    if (V.at(i) % 2 != 0) ans = "NO";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3736
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  st a = "ABC";
  a += tos(N);
  co(a);
}

Measured memory_bytes: 256