akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

mi mp;

void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
           mp[i]++;
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
       	mp[n]++;
}  

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		mp.clear();
		int n;
		cin >> n;
		primeFactors(n);
		vi v;
		for(auto it: mp)
			v.pb(it.first);
		vi vv;
		for(int x:v)
		{
			int res = x;
			while(res<=n)
			{
				vv.pb(res);
				res = res*x;
			}
		}
//		for(int x:vv)
//			cout << x << " ";
//		cout << endl;
		sort(all(v));
		int ans = 0;
		for(int x:vv)
		{
			if(n%x==0)
			{
				ans++;
				n = n/x;
			}
		}
		cout << ans;
			
	}
}


Measured memory_bytes: 3680
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def tan(deg):
    rad = deg * math.pi / 180.
    return math.tan(rad)

def calcDiff(a, b, angle, x):
    if tan(angle) > b / a:
        res = a*b*b/(2.* tan(angle))
    else:
        res = a*a*b - a*a*a*tan(angle) / 2.
    return res - x

def main():
    a, b, x = LI()
    ok = 0
    ng = 90
    diff = calcDiff(a, b, 0, x)
    while diff > 10**(-6) or diff < 0:
        m = (ok + ng) / 2.
        diff = calcDiff(a, b, m, x)
        if diff < 0:
            ng = m
        else:
            ok = m
    print(ok)

main()



Measured memory_bytes: 66540
#include <stdio.h>
#define N 1;
int main(void) {
  int i,num,change;
  num = N;
  while(1){
    char buf[128];
    fgets(buf, 128, stdin);
    sscanf(buf, "%d", &num);
    if(num > 10000 || num < 1) break;
    i = 1000;
    while (num > i) {
      i+=1000;
    }
    change = i - num;
    printf("%d\n",change);
    break;
  }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

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

  ll n,m,l;
  cin>>n>>m>>l;
  vector<vector<ll>> dist1 (n,vector<ll>(n,INF));
  vector<vector<ll>> dist2 (n,vector<ll>(n,INF));
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    chmin(dist1[a][b],c);
    chmin(dist1[b][a],c);
  }
  ll q;
  cin>>q;
  vector<pair<ll,ll>> query;
  rep(i,q){
    ll s,t;
    cin>>s>>t;
    s--;t--;
    query.emplace_back(s,t);
  }

  rep(k,n)rep(i,n)rep(j,n){
    chmin(dist1[i][j],dist1[i][k]+dist1[k][j]);
  }

  rep(i,n)rep(j,n){
    if(dist1[i][j]<=l)dist2[i][j]=1;
  }

  rep(k,n)rep(i,n)rep(j,n){
    chmin(dist2[i][j],dist2[i][k]+dist2[k][j]);
  }

  rep(i,q){
    ll s,t;tie(s,t)=query[i];
    if(dist2[s][t]==INF)cout<<to_string(-1)<<endl;
    else cout<<to_string(dist2[s][t]-1)<<endl;
  }

}


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

using namespace std;

#define inti long long int

int main()
{
    inti i,x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0){
        cout<<1<<endl;
    }else if(x2==0){
        cout<<2<<endl;
    }else if(x3==0){
        cout<<3<<endl;
    }else if(x4==0){
        cout<<4<<endl;
    }else{
        cout<<5<<endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main(){
  int a,b;
  cin>>a>>b;
  int num = 16 - (a + b);

  if (abs(a-b)>num)
  {
    cout << ":(" << endl;
  }
  else
    cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n,k = map(int,input().split())
a = list(map(int,input().split()))

ans = 0
adds = 0
mins = 0

for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if j < i:
                adds += 1
                mins += 1
            elif i < j:
                adds += 1

ans = (adds*(k+1)*k//2 - mins*k) % 1000000007
print(ans)


Measured memory_bytes: 41964
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

vecint dfs(const vector<vecint>& g, const vecint& x, int i = 0) {
  int sum = 0;
  vector<bool> dp(5002, false);
  dp[0] = true;
  for (auto&& to : g[i]) {
    vector<bool> tmp(5002, false);
    const auto v = dfs(g, x, to);
    if (v.empty()) return v;
    REP(j,5002) {
      if (!dp[j]) continue;
      tmp[min(5001, j+v[0])] = true;
      tmp[min(5001, j+v[1])] = true;
    }
    sum += v[0] + v[1];
    swap(tmp, dp);
  }
  for (int j = x[i]; j >= 0; --j) {
    if (dp[j]) return {sum-j, x[i]};
  }
  return vecint();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vector<vecint> g(n);
  FOR(i,1,n) {
    int p;
    cin>>p;
    --p;
    g[p].push_back(i);
  }
  vecint x(n);
  for(auto&& e:x)cin>>e;
  auto res = dfs(g, x);
  if (res.empty()) {
    cout<<"IMPOSSIBLE"<<endl;
  } else {
    cout<<"POSSIBLE"<<endl;
  }
  return 0;
}


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

int main(){
  string s;
 cin>>s;
 int i=s.size();
 
 if(s.at(i-1)=='s'){
 cout<<s;
   cout<<"es"<<endl;
 }
  else{
 cout<<s;
   cout<<"s"<<endl;
  }
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
using namespace std;
ll n;
double A[3000];
double dp[3000][3000];
double solve(ll h,ll t, ll ind){
    if(ind == n){
        if(h > t){
            return 1;
        }else
            return 0;
    }
    if(dp[h][t] != -1)
        return dp[h][t];
    dp[h][t] = A[ind]*solve(h+1,t,ind+1) +
                (1-A[ind])*solve(h,t+1,ind+1);
    return dp[h][t];
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(ll i = 0; i < 3000; i++)
        for(ll j = 0; j < 3000; j++)
            dp[i][j] = -1;
    for(ll i = 0; i < n; i++){
        cin>>A[i];
    }
    cout << std::setprecision(10) << solve(0,0,0);
    return 0;
}




//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>

void print(int* A, int n)
{
	std::cout << A[0];
	for (int i=1; i<n; i++) std::cout << " " << A[i];
	std::cout << std::endl;
}

int main()
{
	int n; std::cin >> n;
	
	int* A = new int[n];
	for (int i=0; i<n; i++) A[i] = i+1;
	
	do { print(A, n); } while (std::next_permutation(A, A + n));
	
	delete[] A;
	
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

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

  struct Item {
    int weight;
    int64_t value;
  };
  vector<Item> items(n, {0, 0});

  for (int i = 0; i < n; i++) {
    cin >> items[i].weight;
    cin >> items[i].value;
  }

  vector<Item > result;
  for (Item item: items) {
    const int limit = result.size();
    result.push_back(item);
    for (int i = 0; i < limit; i++) {
      int w = result[i].weight + item.weight;
      int64_t v = result[i].value + item.value;
      if (w > W) {
        break;
      }
      result.push_back({w, v});
    }

    // Sort the result:
    sort(result.begin(), result.end(), [](const Item& v1, const Item& v2) {return v1.weight < v2.weight;} );
    // Filter-out the sub-optimal results.
    int out = 1;
    for (int in = 1; in < result.size(); in++) {
      int prevIdx = out - 1;
      if (result[prevIdx].weight == result[in].weight) {
        result[prevIdx].value = max(result[prevIdx].value, result[in].value);
      } else if (result[prevIdx].value < result[in].value) {
        result[out++] = result[in];
      }
    }
    result.resize(out);
  }

  cout << result.back().value << endl;

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAX = (int)1e2;

int N, K;

void solve() {
	int s[MAX ];
	bool ok=0;
	int b;
	//int b[MAX ][MAX];
	for (int i = 0; i < K; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			cin >> b;
			s[j] -= b;
		}
	}

	ok = 1;
	for (int i = 0; i < K; i++) {
		if (s[i] < 0) {
			ok = 0;
			break;
		}
	}
	cout << ((ok) ? "Yes" : "No") << endl;
}

int main() {
	
	while (1) {
		cin >> N >> K;
		if (N == 0 && K == 0) {
			break;
		}
		solve();
	}
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
int a[N],n,L;

int main(){
	read(n),read(L);
	rep(i,1,n)read(a[i]);
	rep(i,1,n-1)
		if(a[i]+a[i+1]>=L){
			puts("Possible");
			rep(j,1,i-1)printf("%d\n",j);
			per(j,n-1,i+1)printf("%d\n",j);
			printf("%d\n",i);
			return 0;
		}
	puts("Impossible");
	return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    ll ans = 0;
    rep (i, S.size()/2) {
        if (S[i] != S[S.size()-i-1]) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
int n;
map<int,int>cnt;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(n);
    ll sum=0;
    rep(i,1,n){
        int t;read(t);
        cnt[t]++;
        sum+=t;
    }
    int q;read(q);
    while(q--){
        int a,b;read(a),read(b);
        sum+=cnt[a]*(b-a);
        cnt[b]+=cnt[a];
        cnt[a]=0;
        write(sum),putchar('\n');
    }
	//===========================================================
	return 0;
}

Measured memory_bytes: 8056
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int h, w;
vvc s(50, vc(50));
vvb flag(50, vb(50, false));
int BFS()
{
	queue<tuple<int, int, int>> que;

	que.push(make_tuple(0, 0, 0));
	flag[0][0]=true;

	tuple<int, int, int> p;

	while(!que.empty()){
		p=que.front(); que.pop();
		int f=get<0>(p), t=get<1>(p), cost=get<2>(p);
		if(f==h-1&&t==w-1) return cost;
		if(f!=0){
			if(s[f-1][t]=='.'&&!flag[f-1][t]){
				que.push(make_tuple(f-1, t, cost+1));
				flag[f-1][t]=true;
			}
		}
		if(f!=h-1){
			if(s[f+1][t]=='.'&&!flag[f+1][t]){
				que.push(make_tuple(f+1, t, cost+1));
				flag[f+1][t]=true;
			}
		}
		if(t!=0){
			if(s[f][t-1]=='.'&&!flag[f][t-1]){
				que.push(make_tuple(f, t-1, cost+1));
				flag[f][t-1]=true;
			}
		}
		if(t!=w-1){
			if(s[f][t+1]=='.'&&!flag[f][t+1]){
				que.push(make_tuple(f, t+1, cost+1));
				flag[f][t+1]=true;
			}
		}
	}
	return -1;
}
int main(void)
{
	cin>>h>>w;

	int cnt=0;

	rep(i, h){
		rep(j, w){
			cin>>s[i][j];
			if(s[i][j]=='#') cnt++;
		}
	}
	int res=BFS();
	if(res==-1){
		cout<<-1<<endl;
	}else{
		cout<<h*w-res-1-cnt<<endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int SZ = 3e5 + 100;
int ch[SZ], cw[SZ];

int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int h, w;
    cin >> h >> w;
    int m;
    cin >> m;
    vector<int> x(m), y(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i] >> y[i];
        ++cw[x[i]];
        ++ch[y[i]];
    }
    int mxw = *max_element(cw, cw + SZ);
    int mxh = *max_element(ch, ch + SZ);
    int kw = 0, kh = 0;
    int cnt = 0;
    for (int i = 0; i < SZ; ++i) {
        if (cw[i] == mxw) {
            ++kw;
        }
        if (ch[i] == mxh) {
            ++kh;
        }
    }
    for (int i = 0; i < m; ++i) {
        if (cw[x[i]] == mxw && ch[y[i]] == mxh) {
            ++cnt;
        }
    }
    if (kh * kw != cnt) {
        cout << mxw + mxh;
    } else {
        cout << mxw + mxh - 1;
    }
    return 0;
}


Measured memory_bytes: 12660
def x(s)s.size>1&&s[0..0]=='X'end
while(l=gets)
l=~/([0-9X]+)\+([0-9X]+)=([0-9X]+)/
a=$1+'+'+$2+'=='+$3
puts 'NA' if ((x($1)||x($2)||x($3))?1:0).step(9){|i|if eval(a.gsub('X',i.to_s)) then p i;break end}end

Measured memory_bytes: 2596
#include <iostream>

using namespace std;

int N, Q, A[100001] = {}, B,C;
long long sum;
int main(){
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> B;
        A[B] ++;
        sum += B;
    }
    cin >> Q;
    for(int i=0;i<Q; i++){
        cin >> B >> C;
        sum += (C - B)*A[B];
        A[C] += A[B];
        A[B] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4008
/******************************************
*******************************************
*******************************************
	PREPARED BY - SOMESH AWASTHI 
	CHANDIGARH UNIVERSITY
*******************************************
*******************************************
*******************************************/

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

int main()
{
	io
	#ifdef SOMU
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	int n, k;
	cin >> n >> k;
	vi arr(n), dp(n, INT_MAX);
	dp[0] = 0;
	fr(i, 0, n) cin >> arr[i];
	fr(i, 1, n) {
		int j = i;
		j--;
		while(j >= 0 && i - j <= k) {
			dp[i] = min(dp[j] + abs(arr[i] - arr[j]), dp[i]);
			j--;
		}
	}
	cout << dp[n - 1];

	#ifdef SOMU
		cout << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	ll n, x[222222],cx[222222], i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x[i];
		cx[i] = x[i];
	}
	sort(cx, cx + n);
	for (i = 0; i < n; i++) {
		if (x[i] > cx[n / 2 - 1])
			cout << cx[n / 2 - 1] << endl;
		else
			cout << cx[n / 2] << endl;
	}
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A==C){
    cout << B << endl;
  }
  if (A==B){
    cout << C << endl;
  }
  if (C==B){
    cout << A << endl;
  }
}

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

typedef long long ll;

ll n, k, w[100000];
ll INF = 0xfffffffffffffff;

bool ok(ll p) {
    ll now = 0;
    ll cnt = 1;
    for(int i = 0; i < n; i++) {
        if(now + w[i] <= p) {
            now += w[i];
        } else {
            if(p < w[i])
                return false;
            cnt++;
            now = w[i];
        }
    }
    return cnt <= k;
}

int main() {
    cin >> n >> k;
    for(ll i = 0; i < n; i++) {
        cin >> w[i];
    }
    ll lb = 0;
    ll ans = 100000 * n;

    while(ans - lb > 1) {
        ll mid = (ans + lb) / 2;
        if(ok(mid))
            ans = mid;
        else
            lb = mid;
    }
    cout << ans << endl;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int A,B; cin >> A >> B;
    cout << max(0,A - 2*B) << endl;

    


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n;

void printNode(int *A){
  for(int i = 0; i < n; ++i){
    printf("node %d: ", i + 1);
    printf("key = %d, ", A[i]);
    if(i != 0){
      int p = (i - 1) / 2;
      printf("parent key = %d, ", A[p]);
    }
    int l = 2 * i + 1;
    if(l < n)
      printf("left key = %d, ", A[l]);
    int r = 2 * i + 2;
    if(r < n)
      printf("right key = %d, ", A[r]);
    printf("\n");
  }
}
int main(){
  scanf("%d", &n);
  int A[n];
  for(int i = 0; i < n; ++i){
    scanf("%d", &A[i]);
  }

  printNode(A);
  return 0;
}



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

 using namespace std;
 int main(){
   string S,N;
   int n;
   
   cin >> S;
   N = S.substr(S.length() - 1);
   
   if (N == "s") {
     cout << S + "es" << endl;
   }
   else
     cout << S + "s" << endl;
 }

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;
#define LL long long

map<string,int> s;
map<string,int>::iterator it;
int main()
{
	int n,len;
	cin>>n>>len;
	for(int i=0;i<n;i++){
		string x;
		cin>>x;
		s[x]++;
	}
	for(it = s.begin();it!=s.end();it++){
		for(int i=0;i<(*it).second;i++)
			cout<<(*it).first;
	}
	cout<<endl;
	
	return 0;	
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    vector<vector<ll>> v(N, vector<ll>(3));
    for (auto &&i : v) {
        for (auto &&j : i) {
            cin >> j;
        }
    }

    ll ans = -INF64;

    REP(bit, (1 << 3)) {
        vector<ll> x;
        REP(j, N) {
            ll sum = 0;
            REP(i, 3) {
                if (bit & (1 << i)) {
                    sum += v[j][i];
                } else {
                    sum -= v[j][i];
                }
            }
            x.emplace_back(sum);
        }
        RSORT(x);
        ll oisi = 0;
        REP(i, M) { oisi += x[i]; }
        chmax(ans, oisi);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int h,w,k;
vvc a;

int main(){
	cin>>h>>w>>k;
	a=vvc(h,vc(w));
	int x,y;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		cin>>a[i][j];
		if(a[i][j]=='S'){
			x=i;
			y=j;
		}
	}
	vvb used(h,vb(w,0));
	queue<pip> q;
	q.push({{x,y},0});
	used[x][y]=1;
	int res=inf;
	while(!q.empty()){
		pip p=q.front();
		q.pop();
		int X=p.first.first,Y=p.first.second,I=p.second;
		int m=min(min(X,h-X-1),min(Y,w-Y-1));
		res=min(res,(m+k-1)/k+1);
		if(I==k) continue;
		for(int i=0;i<4;i++){
			int cx=X+dx[i],cy=Y+dy[i];
			if(cx>=0&&cx<h&&cy>=0&&cy<w&&a[cx][cy]=='.'&&!used[cx][cy]){
				q.push({{cx,cy},I+1});
				used[cx][cy]=1;
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, y;
    cin >> n >> y;
    y /= 1000;
    rep(i, 0, 2001){
        rep(j, 0, 2001){
            int k = n - i - j;
            if(k < 0) continue;
            if(10 * i + 5 * j + k == y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }   
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    int num_minus = lower_bound(all(a), 0) - a.begin();
    int minus_part, plus_part;
    if (num_minus >= n - 1) {
        minus_part = n - 2;
        plus_part = 0;
    } else if (num_minus >= 1) {
        minus_part = num_minus - 1;
        plus_part = n - num_minus - 1;
    } else {
        minus_part = 0;
        plus_part = n - 2;
    }
    //最大値を先に求める
    int ans = a[n - 1] - a[0];
    for (int i = 1; i < n - 1; i++) {
        if (i <= minus_part) {
            ans -= a[i];
        } else {
            ans += a[i];
        }
    }
    cout << ans << endl;
    //(p-q)-(r-s)としたい
    int p = a[n - 1], r = a[0];
    queue<int> q, s;
    for (int i = 1; i <= minus_part; i++) {
        q.push(a[i]);
    }
    for (int i = minus_part + 1; i < n - 1; i++) {
        s.push(a[i]);
    }
    // p-q
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        cout << p << " " << now << endl;
        p = p - now;
    }
    // r-s
    while (!s.empty()) {
        int now = s.front();
        s.pop();
        cout << r << " " << now << endl;
        r = r - now;
    }
    //(p-q)-(r-s)
    cout << p << " " << r << endl;
}

Measured memory_bytes: 2688
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])
 
def main():
    n = inp()
    a = []
    for i in range(n):
        a.append((int(input()),i))
    a.sort()
    ans = 0
    for i in range(0,n,2):
        if a[i][1]%2 == 1:
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 54996
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] > h[b-1]:
        ans[b-1] = 'X'
    elif h[a-1] < h[b-1]:
        ans[a-1] = 'X'
    else:
        ans[a-1] = 'X'
        ans[b-1] = 'X'

print(ans.count(1))

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    map<int, int> mp;
    rep(i, 0, n){
        mp[a[i]]++;
        mp[a[i]-1]++;
        mp[a[i]+1]++;
    }
    int mx = 0;
    for(auto i : mp) mx = max(mx, i.second);
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 7952
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int x;

void solve(){
	scanf("%d",&x);
	for(int i=1;;i++){
		if(i*360%x==0){
			printf("%d\n",i*360/x);
			break;
		}
	}	
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 1700
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P>PP;
int p[10], q[10];
bool itti(int n,vector<int>V,int a[]) {
	rep(i, n) {
		if (V[i] != a[i])return false;
	}
	return true;
}
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> p[i];
	rep(i, n)cin >> q[i];
	int r=-1,s=-1;
	vector<int>A;
	rep(i, n)A.push_back(i + 1);
	int cnt = 0;
	do {
		if (itti(n, A, p))r = cnt;
		if (itti(n, A, q))s = cnt;
		cnt++;
	} while (next_permutation(A.begin(), A.end()));
	cout << abs(r - s) << endl;
}

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

int main()
{
    double a, b, x;
    std::cin >> a >> b >> x;
    double v = a * a * b;
    double hoge;
    double height, theta;
    if (x > v / 2) {
        hoge = v - x;
        height = static_cast<double>(hoge / a / a * 2);
        theta = atan((double)(height / a));
    } else {
        hoge = x;
        height = static_cast<double>(hoge / a / b * 2);
        theta = atan((double)(height / b));
    }
    //std::cout << height;
    if (x < v / 2) {
        //std::cout << 90.0 - theta * 180.0 / M_PI << std::endl;
        printf("%.8f\n", 90.0 - theta * 180.0 / M_PI);
    } else {
        printf("%.8f\n", theta * 180.0 / M_PI);
        //std::cout << theta * 180.0 / M_PI << std::endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn=2e5+10;
struct Item
{
	long long A,B;
};
int n;
Item a[maxn];
bool cmp(Item x,Item y)
{
	return x.B<y.B;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].A>>a[i].B;
	}
	sort(a,a+n,cmp);
	long long tim=0LL;
	for(int i=0;i<n;i++)
	{
		tim+=a[i].A;
		if(tim>a[i].B)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
 
using namespace std;
 
int main(){
    int64_t N,Q;
 
    cin >> N;
    int64_t countnum[100002];
    int64_t sum=0;
 
    for(int i=0;i<100002;++i){
        countnum[i]=0;
    }
	  
  
    for(int64_t i=0;i<N;i++){
        int64_t temp;
        cin >> temp;
        sum+=temp;
        countnum[temp]+=1;
    }
 
    cin >> Q;
 
    int64_t Bi[100001];
    int64_t Ci[100001];
    for(int64_t i=0;i<Q;i++){
        cin >> Bi[i]>>Ci[i];
    }
 
 
    for(int64_t i=0;i<Q;++i){
        sum -= Bi[i] *countnum[Bi[i]];
        sum += Ci[i] *countnum[Bi[i]];
 
        cout<<sum <<endl;
        countnum[Ci[i]] +=countnum[Bi[i]];
        countnum[Bi[i]] =0;
 
    }
 
 
}

Measured memory_bytes: 5940
def main(n: int, a: list):
    ans = 0

    i = 1

    if 1 not in set(a):
        print(-1)
        return

    for _a in a:
        if _a != i:
            ans += 1
        else:
            i += 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Measured memory_bytes: 25988
x = input()
ans=0
tmp_ans=0
for i in x:
    if i=="R":
        tmp_ans+=1
    else:
        if ans<tmp_ans:
            ans=tmp_ans
            tmp_ans=0
else:
    if ans<tmp_ans:
            ans=tmp_ans
            tmp_ans=0
print(ans)

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):
    a, b = [0], [0]
    for v in A:
        a.append(a[-1] + v)
    for v in B:
        b.append(b[-1] + v)

    j = M
    ret = 0
    #print(a)
    #print(b)
    for i, v in enumerate(a):
        while j > 0 and v + b[j] > K:
            j -= 1
        if v + b[j] <= K:
            #print(i, v, j, b[j])
            ret = max(ret, i + j)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 138268
#include <iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<long, long> P;

int main(void){
    long n,m;
    cin >>n>>m;
    std::vector<long> cards(n);
    for(int i=0;i<n;i++){
        cin >>cards[i];
    }
    sort(cards.begin(),cards.end());
    
    
    std::vector<P> changes;
    for(int i=0;i<m;i++){
        long b,c;
        cin >>b>>c;
        changes.push_back(P(c,b));
    }
    sort(changes.begin(),changes.end());

    // for(int i=0;i<m;i++){
    //     cout <<changes[i].first<<" "<<changes[i].second<<endl;
    // }

    long idx =0;
    for(int i=0;i<m;i++){
        idx +=changes[i].second;
    }
    if(n<idx){
        idx=n;
    }
    // cout <<idx;
    std::vector<long> ans(idx);
    for(int i=0;i<idx;i++){
        ans[i]=0;
    }
    long a=0;
    for(int i=m-1;i>=0;i--){
        for(int j=0;j<changes[i].second;j++){
            if(idx-1<a){
                break;
            }
            ans[a]=changes[i].first;
            a++;
        }
        if(idx<a){
            break;
        }        
    } 
    
    // for(int i=0;i<idx;i++){
    //     cout << ans[i];
    // }
    
    long sum=0;
    for(int i=0;i<n;i++){
        if(idx<i){
            sum+=cards[i];
        }else if(cards[i]<ans[i]){
            sum+=ans[i];
        }else{
            sum+=cards[i];
        }
    }
    cout << sum<<endl;
}

Measured memory_bytes: 3440
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        # フラグが立っていれば "+" 、なければ "-"
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 3064
def ghke(k, x):
    print('Yes') if k * 500 >= x else print("No")

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    k, x = [int(_) for _ in in_str[0].split(' ')]
    ghke(k, x)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
}

int main() {
  int A,B,C,D; cin>>A>>B>>C>>D;
  YN(C*B>=A);
}


Measured memory_bytes: 3628
program main
  implicit none

  integer :: x, y, p

  read(*,*) x, y

  if(x == 1 .and. y == 1)then
     p = 400000
  else
     p = 0
  end if

  select case(x)
  case(1)
     p = p + 300000
  case(2)
     p = p + 200000
  case(3)
     p = p + 100000
  case default
     p = p
  end select

  select case(y)
  case(1)
     p = p + 300000
  case(2)
     p = p + 200000
  case(3)
     p = p + 100000
  case default
     p = p
  end select

  write(*,*) p

end program main



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

int main() {
  string s,t;
  cin >> s >> t;
  vector<int> a,b;
  int k=0; 
  for(int i=0; i<s.size(); i++) {
    if(k<t.size()&&s[i]==t[k]) {
      a.push_back(i);
      k++;
    }
  }
  k=t.size()-1;
  for(int i=s.size()-1; i>=0; i--) {
    if(k>=0&&s[i]==t[k]) {
      b.push_back(i);
      k--;
    }
  }
  reverse(b.begin(),b.end());
  if(a.size()==t.size()&&a==b) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}


Measured memory_bytes: 8976
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

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

//long longしか使わない
int main() {
	ll n;
	cin >> n;
	vector<ll>f(n + 1);
	f[0] = 1;
	f[1] = 1;
	for (ll i = 2;i <= n;++i) {
		f[i] = f[i - 1] + f[i - 2];
	}
	cout << f[n] << endl;
	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>

int main ( )
{
	double input ;
	double max = -1e9 ;
	double min = 1e9 ;
	while ( scanf ( "%lf" , &input ) == 1 ) {
		if ( input > max ) {
			max = input ;
		}
		else if ( input < min ) {
			min = input ;
		}
	}
	printf ( "%lf\n" , max - min ) ;
	return 0 ;
}

Measured memory_bytes: 1076