akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  vector<long long> a(n);
  map<long long, int> mp;
  REP(i,n){
    cin>>a[i];
    mp[a[i]]++;
  }
  sort(a.begin(), a.end(), greater<long long>());
  
  long long target;
  int ans=0;
  bool flag;//ペアが作れたかどうかを持つ
  REP(i,n){
    if(mp[a[i]]==0)continue;
    flag = false;
    for(int p=31;p>=1;p--){
      target = (1LL<<p) - a[i];
      if(target<=0)break;
      if(target==a[i]){
        if(mp[target]>1){
          ans++;
          mp[target] -= 2;
          flag = true;
          break;
        }else{
          continue;
        }
      }
      if(mp[target]>0){
        ans++;
        mp[a[i]]--;
        mp[target]--;
        flag = true;
        break;
      }else{
        continue;
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

import static java.lang.Integer.parseInt;

/**
 * Chain
 * JOI 2009 予選3
 */
public class Main {

	private static int[] C;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line);
			if (N == 0) break;

			C = new int[N + 2];

			C[N + 1] = 4;

			for (int i = 1; i <= N; i++) {
				C[i] = parseInt(br.readLine());
			}

			int ans = 0;

			for (int i = 1; i <= N; i++) {
				if (C[i] != 1) ans = Math.max(ans, solve(i, 1));
				if (C[i] != 2) ans = Math.max(ans, solve(i, 2));
				if (C[i] != 3) ans = Math.max(ans, solve(i, 3));
			}

			System.out.println(N - ans);
		}
	}

	private static int solve(int i, int c) {

		int p = i, q = i, l = 0, r = 0, ret = 0;

		while (C[p - 1] == c) {
			l++;
			p--;
		}
		while (C[q + 1] == c) {
			r++;
			q++;
		}
		if (l + r + 1 >= 4) {
			ret = l + r + 1;
			ret += solve2(p, q);
		}

		return ret;
	}

	private static int solve2(int p, int q) {

		int l = 0, r = 0, ret = 0;

		if (C[p - 1] == C[q + 1]) {
			int c = C[p - 1];
			while (C[p - 1] == c) {
				p--;
				l++;
			}
			while (C[q + 1] == c) {
				q++;
				r++;
			}
			if (l + r >= 4) {
				ret += l + r;
				ret += solve2(p, q);
			}
		}

		return ret;
	}
}


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

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

  int k;
  cin >> k;
  ll a[k];
  for (int i = 0; i < k; i++) cin >> a[i];
  ll mi = 2, ma = 2;
  for (int i = k - 1; i >= 0; i--) {
    ll mii = (mi + a[i] - 1) / a[i] * a[i];
    ll maa = ma / a[i] * a[i];
    if (mii < mi || mii > ma || maa < mi || maa > ma) {
      cout << -1 << endl;
      return 0;
    }
    mi = mii;
    ma = maa + a[i] - 1;
  }
  cout << mi << " " << ma << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
using namespace std;

#define ALL(c) (c).begin(), (c).end()

int main(void){
    vector<string> weather = {"Sunny", "Cloudy", "Rainy"};
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << weather[(distance(weather.begin(), find(ALL(weather), s)) + 1) % 3] << "\n";
    return 0;
}


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

int main ()
{
    int n,count,l,r;
    cin >> n;
    
    for (int i = 0; i< n ; i++)
    {
        cin >> l >> r;
        count += (r-l+1);
    }

    cout<< count<<endl;
    
}

Measured memory_bytes: 256
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

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

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m;
    n*=3;
    n+=m;
    cout<<n/2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;


int main()
{
    ll n,x,m;
    cin >> n >> x >> m;
    ll sum=x;
    vector<ll> nums;
    vector<ll> c(m+1,0);
    ll used=0;
    bool iszero=false;
    for(int i=1;i<n;i++)
    {
        x=(x*x)%m;
        sum+=x;
        c[x]++;
        if(x==0)
        {
            iszero=true;
            break;
        }
        if(c[x]==2)
        {
            nums.pb(x);
        }
        if(c[x]==3)
        {
            used=i;
            sum-=x;
            break;
        }
        //cout << x << " " << sum << "\n";
    }  
    if(used!=0&&!iszero)
    {
    ll hsum=0;
    ll numssize=nums.size();
    for(ll i=0;i<numssize;i++)
        hsum+=nums[i];
    n-=used;
    ll multi=n/nums.size();
    sum+=multi*hsum;
    ll remain=n-multi*nums.size();
    for(ll i=0;i<remain;i++)
        sum+=nums[i];
    }
    cout << sum;
}

Measured memory_bytes: 4516
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=100000007;
const llint big=1e9;
const llint red=0xE869120;
const llint pro=1002001;
int main(void){
	int a,b,i,j,ans=0,gen,bmax,bmin,q,w,n,m;
	string str;
	vector<int> vec;
	cin>>n>>m>>w;
	if((n*100+m*10+w)%4==0){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>

using namespace std;
struct mmp {
    int x;
    int y;
} abc[2005], def[2005];
int vis[2005];
int t;
int link[2005];
int n;

int find(int x) {
    for (int i = 1; i <= n; i++) {
        if (abc[x].x <= def[i].x && abc[x].y <= def[i].y)
            if (vis[i] != t) {
                vis[i] = t;
                if (link[i] == 0 || find(link[i])) {
                    link[i] = x;
                    return 1;
                }
            }
    }
    return 0;
}

int main() {

    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &abc[i].x, &abc[i].y);
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &def[i].x, &def[i].y);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        t++;
        if (find(i)) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N;
  cin >> N;
  i64 e = 0;
  i64 o = 0;
  rep(i,0,N) {
    i64 a;
    cin >> a;
    a &= 1;
    if(a == 0) {
      e++;
    }
    else {
      o++;
    }
  }

  if(e == N || o == N) {
    cout << 0 << endl;
    return 0;
  }
  if(o & 1) {
    cout << N - 1 << endl;
  }
  else {
    cout << N - 2 << endl;
  }
}



Measured memory_bytes: 3092
h, w = map(int, input().split())
a = []
for i in range(h):
    A = list(map(str,input().split()))
    a.append(A)
kesu = []
for i in range(h):
    b = str(a[i])
    ten = 0
    for l in range(w):
        if b[l+2] == ".":
           ten += 1
    if w == ten :
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    a.pop(K-i)
hi = []
for i in range(w):
    hkari = ""
    for l in range(len(a)):
        h = str(a[l])
        hz = str(h[i+2])
        hkari += str(hz)
    hi.append(hkari)
kesu = []
for i in range(len(hi)):
    b = str(hi[i])
    ten = 0
    for l in range(len(b)):
        if b[l] == ".":
            ten += 1
    if len(b) == ten:
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    hi.pop(K-i)
b = len(str(hi[0]))
ans = []
for i in range(b):
    hkari = ""
    for l in range(len(hi)):
        h = str(hi[l])
        hz = str(h[i])
        hkari += str(hz)
    ans.append(hkari)
for i  in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
# Input#
n = int(input())
# n, k = map(int, input().split())
h = list(map(int, input().split()))

h = [-1] + h

ans = 0

memo = [-1] * (n + 1)
memo[1] = 0
memo[2] = abs(h[2] - h[1])


def dp(i):
    if memo[i] != -1:
        return memo[i]
    else:
        hop1 = dp(i - 1) + abs(h[i] - h[i - 1])
        hop2 = dp(i - 2) + abs(h[i] - h[i - 2])
        memo[i] = min(hop1, hop2)
        return memo[i]


for i in range(n):
    if i == 0 or i == 1 or i == 2:
        continue
    hop1 = memo[i - 1] + abs(h[i] - h[i - 1])
    hop2 = memo[i - 2] + abs(h[i] - h[i - 2])
    memo[i] = min(hop1, hop2)

ans = dp(n)

print("{}".format(ans))


Measured memory_bytes: 85632
//implementation

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (ll)(1e15);
int n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<vector<ll>> dp(n,vector<ll> (n,-INF));

    for (int L = n - 1; L >= 0; L--)
        for (int R = L; R < n; R++)
            if (L == R) dp[L][R] = a[L];
            else dp[L][R] = max(a[L] - dp[L + 1][R],a[R] - dp[L][R - 1]);

    cout << dp[0][n - 1];        
    return 0;
}



Measured memory_bytes: 70784
#include<stdio.h>
#include<math.h>
#define MAX 10000

int main(){
    int x[MAX], n, i, j;
    int count = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &x[i]);

    for(i = 0; i < n; i++){
        if((x[i] == 2 || x[i] % 2 == 1) && x[i] != 1){
            for(j = 3; j <= sqrt(x[i]); j += 2){
                if(x[i] % j == 0) break;
            }
            if(j > sqrt(x[i])) count++;
        }
    }
    printf("%d\n", count);
    return 0; 
}


Measured memory_bytes: 1996
#include<bits/stdc++.h>
using namespace std;
map< vector<int> , int > M;
int main (){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n,x,id=1;cin>>n;
  vector<int>A;
  for(int i=1;i<=n;i++)A.push_back(i);

  do{
    M[A]=++id;
  }while(next_permutation(A.begin(),A.end()));
  vector<int>P,Q;
  for(int i=1;i<=n;i++) {cin >> x ; P.push_back(x);}
  for(int i=1;i<=n;i++) {cin >> x ; Q.push_back(x);}

  cout<<abs(M[P]-M[Q])<<endl;
  return 0;
}



Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll x,a,b;
cin>>x>>a>>b;
cout<<(x-a)%b<<endl;
}









Measured memory_bytes: 256
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]

x=[[d[i][0]+d[i][1],d[i][0],d[i][1]] for i in range(n)]
x.sort()
t=0
t2=-10**9-1
ans=0
for i in range(n):
  if t<x[i][0] and t2 <= (x[i][1]-x[i][2]):
    ans+=1
    t=x[i][0]
    t2=x[i][0]
print(ans)

Measured memory_bytes: 38240
# include <iostream>
using namespace std;
int main()
{
	int R;
	while(cin>>R)
	{
		if(R<1200)
			cout<<"ABC"<<endl;
		if(R>=1200&&R<2800)
			cout<<"ARC"<<endl;
		if(R>=2800)
			cout<<"AGC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	int cnt = 1;
	for (int i = 0; i + 1 < S.size(); i++) {
		if (S[i] != S[i + 1]) cnt++;
	}
	int k = min((cnt - 1) / 2, K);
	int ans = N - cnt + k * 2;
	if (cnt % 2 == 0 && K > k) ans++;
	cout << ans << endl;
}


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

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

long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    return g * a / g * b / g;
}

int main() {
    int N, M;  cin >> N >> M;
    vector<int> A(N);
    long long comul = 1;  // 最小公倍数
    for (int i = 0; i < N; ++i) {
        int a;  cin >> a;
        a /= 2;
        comul = lcm(comul, a);
        if(comul>M)
        {
            cout<<0<<endl;
            return 0;
        }
        A[i] = a;
    }

    int copow = 0;  // 最大公冪数(であるべき数)
    while (true) {
        if (A[0] >> copow & 1) break;
        ++copow;
    }
    // DUMP(copow);

    // 最大公冪数が正しく満たされているかチェック
    for (int i = 0; i < N; ++i) {
        int p = 0;
        while (true) {
            if (A[i] >> p & 1) break;
            ++p;
        }
        if (p != copow) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M/comul-1)/2+1 << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

string ntos(long long n){
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}

string f(ll n){
	string s1 = ntos(n);
	reverse(all(s1));
	ll n1 = s1.sz;
	rep(i,0,6-n1){
		s1 += "0";
	}
	reverse(all(s1));
	return s1;
}

int main() {
	ll n,m;
	cin>>n>>m;
	vector<vector<pair<ll,ll> > > v(n,vector<pair<ll,ll> >());
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
		a--;
		v[a].pb(mp(b,i));
	}
	rep(i,0,n){
		sort(all(v[i]));
	}
	vector<string> vs(m,string());
	rep(i,0,n){
		rep(j,0,v[i].sz){
			ll a = v[i][j].fi;
			ll b = v[i][j].se;
			vs[b] = ""+f(i+1)+f(j+1);
		}
	}
	rep(i,0,vs.sz){
		cout << vs[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 13952
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
#define Rep(i, n) for (lint i = lint(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int a, b, q;
lint s[100010], t[100010], x[100010];
int main() {
	cin >> a >> b >> q;
	s[0] = t[0] = -inf;
	s[a + 1] = t[b + 1] = inf;
	rep(i, a) scanf("%lld", &s[i + 1]);
	rep(i, b) scanf("%lld", &t[i + 1]);
	rep(i, q) scanf("%lld", &x[i]);
	rep(i, q) {
		lint s1, t1, ans;
		s1 = low(s, s + a + 2, x[i]) - s;
		t1 = low(t, t + b + 2, x[i]) - t;
		ans = inf;
		rep(j, 2) {
			rep(k, 2) {
				lint d1, d2;
				d1 = abs(x[i] - s[s1 - j]) + abs(s[s1 - j] - t[t1 - k]);
				d2 = abs(x[i] - t[t1 - k]) + abs(t[t1 - k] - s[s1 - j]);
				ans = min({ ans,d1,d2 });
			}
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 5376
/*input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
*/

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> used(n);
  vector<int> ans(n);
  queue<int> q;
  q.push(0);
  used[0] = 1;
  while (!q.empty()){
    int now = q.front(); q.pop();
    rep(i, g[now].size()) {
      int nxt = g[now][i];
      // cout << now << ":" << g[now][i] << endl;
      if (used[nxt]) continue;
      ans[nxt] = now;
      used[nxt] = 1;
      q.push(nxt);
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    printf("%d\n", ans[i]+1);
  }
}

Measured memory_bytes: 10672
#include <stdio.h>

typedef long long ll;

const ll MOD = (ll)1e9 + 7;

int main(void)
{
	ll n, i, tot = 0, sum = 0;

	scanf("%lld", &n);
	for (i = 1; i <= n; i++)
	{
		ll x;

		scanf("%lld", &x);

		sum = (sum + x) % MOD;
		tot = (tot + x * x) % MOD;
	}

	ll db = (sum * sum % MOD - tot + MOD) % MOD;

	if (db % 2 == 0)
		printf("%lld", db / 2);
	else
		printf("%lld", (db + MOD) / 2);
	return 0;
}

Measured memory_bytes: 1732
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
	ll n, m, ans = 0;
	cin >> n >> m;
	vector<pair<ll, ll>>p(n);
	ll a, b;
	for (ll i = 0;i < n;i++) {
		cin >> a >> b;
		p[i].first = a;
		p[i].second = b;
	}
	stable_sort(p.begin(), p.end());
	ll count = 0;
	for (ll i = 0;i < n;i++) {
		if (count + p[i].second < m) {
			ans += p[i].first*p[i].second;
			count += p[i].second;
		}
		else {
			ans += p[i].first*(m - count);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, a, b) for(int i=(a); i<(int)(b); i++)

typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}

int main(void){
	ll n, m; cin >> n >> m;
	vector<pair<ll, ll> > shop(n);
	rep(i, n){
		cin >> shop[i].first >> shop[i].second;
	}

	sort(shop.begin(), shop.end());
	ll ans = 0;
	rep(i, n){
		if(m <= shop[i].second){
			ans += shop[i].first * m;
			break;
		} else{
			ans += shop[i].first * shop[i].second;
			m -= shop[i].second;
		}
	}

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

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};
const ll MAXC = 200010;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll c[n+1];
    c[0] = -1;
    for(int i=1;i<=n;i++) cin >> c[i];
    vector<ll> dp(n+1);
    vector<ll> csum(MAXC, 0LL);
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        dp[i] = 0;
        if(c[i] != c[i-1]){
            csum[c[i]] += dp[i-1];
            csum[c[i]] %= MOD;
        }
        dp[i] += csum[c[i]];
        dp[i] %= MOD;
        /*
        for(int j=0;j<i;j++){
            if(c[i] == c[j+1] && c[j] != c[j+1]){
                cout << i << " " << j << endl;
                dp[i] += dp[j];
                dp[i] %= MOD;
            }
        }
        */
        
    }
    cout << dp[n] << endl;
}

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

const long long mod=1e9+7;
typedef pair<int,int> p;
int n,m;
long long ans=0,dp[310][310][310];
vector<p>vec[310];
void update(long long &x,long long y){x=(x+y)%mod;}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,l,r,x;i<=m;i++){
		scanf("%d%d%d",&l,&r,&x);
		vec[r].push_back(p(l,x));
	}
	dp[1][0][0]=1;
	for(int i=1;i<=n;i++){
		int t=vec[i].size()-1,l,x;
		for(int j=0;j<i;j++)
		  for(int k=0;k<=max(0,j-1);k++)
		    for(int p=0;p<=t;p++){
		    	l=vec[i][p].first;x=vec[i][p].second;
				if(x==1&&j>=l)dp[i][j][k]=0;
				else if(x==2&&(k>=l||j<l))dp[i][j][k]=0;
				else if(x==3&&k<l)dp[i][j][k]=0;
		    }
		for(int j=0;j<i;j++)
		  for(int k=0;k<=max(0,j-1);k++){
		  	dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
		  	dp[i+1][i][k]=(dp[i+1][i][k]+dp[i][j][k])%mod;
		  	dp[i+1][i][j]=(dp[i+1][i][j]+dp[i][j][k])%mod;
		  }
	}
	for(int i=0;i<n;i++)
	  for(int j=0;j<=max(0,i-1);j++)
	    ans=(ans+dp[n][i][j])%mod;
	printf("%lld",((ans+mod)%mod*3)%mod);
	return 0;
}

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

using namespace std;

const long long inf = 0x7f7f7f7f;
long long GCD(long long a, long long b) { return 0 == b ? a : GCD(b, a%b); }
const long long mod = 1e9 + 7;
const double pi = acos(-1);
long long a[120000];
long long l[120000];
long long r[120000];
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    l[0] = a[0];
    for (int i = 1; i < n; i++)
        l[i] = GCD(l[i - 1], a[i]);
    r[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--)
        r[i] = GCD(r[i + 1], a[i]);
    long long ans = 1;
    for (int i = 1; i < n-1; i++)
        ans = max(GCD(l[i - 1], r[i + 1]), ans);
    cout << max(ans,max(r[1],l[n-2])) << endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 int
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
	// write your code here
        int n = Integer.parseInt(br.readLine().trim());
        Integer [] al = inputvalInteger();
        Arrays.sort(al,  Collections.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i=0; i<al.length;i++){
            if (i % 2 == 0){
                alice += al[i];
            }else{
                bob += al[i];
            }
        }
        System.out.println(alice-bob);
    }

}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] alph = new int[26];
        while (true) {
            try {
                String s = sc.next().toLowerCase();
                for (int i=0; i<s.length(); ++i) {
                    int l = s.charAt(i) - 'a';
                    if (l >= 0 && l < 26) {
                        alph[s.charAt(i) - 'a'] += 1;
                    }
                }
            } catch (Exception e) {
                break;
            }
        }
        for (int i=0; i<alph.length; ++i) {
            System.out.printf("%c : %d\n", 'a'+i, alph[i]);
        }
        sc.close();
    }
}



Measured memory_bytes: 26476
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<s1.length();i++){
        cout<<s1[i];
        if(i<s2.length())cout<<s2[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;


int main() {
	int N;
	cin >> N;
	vector<vector<int>>t(N, vector<int>(3)), dp(N, vector<int>(3));
	for (size_t i = 0; i < N; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			cin >> t.at(i).at(j);
		}
	}
	//dp初期化
	for (size_t i = 0; i < 3; i++)
	{
		dp.at(0).at(i) = t.at(0).at(i);
	}
	//dp開始
	for (size_t i = 1; i < N; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			dp.at(i).at(j) = max(dp.at(i - 1).at((j+1)%3),dp.at(i-1).at((j+2)%3)) + t.at(i).at(j);
		}
	}
	cout << max(dp.at(N - 1).at(0),max( dp.at(N - 1).at(1), dp.at(N - 1).at(2)));
}


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

int main(){
  int count=0;
  int N,X;
  cin>>N>>X;
  vector<int>D(N+1);
  D[0]=0;
  for(int i=0;i<N;++i){
    int x;
    cin>>x;
    D[i+1]=D[i]+x;
  }
  for(int i=0;i<=N;++i){
    if(D[i]<=X){
    count++;
    }
  }
  cout<<count;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)
if(x >= k*d):
    print(x - k*d)
else:
    m = x//d
    x -= m*d
    k -= m
    if(k%2 == 0):   print(x)
    else:   print(abs(x-d))
        

Measured memory_bytes: 61872
n, p = [int(_) for _ in input().split()]
s = input()

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
    print(ans)
    exit()

t = [0 for i in range(n+1)]
P = [0 for i in range(p)]
P[0] += 1
d = 1
for i in range(1, n+1):
    t[i] = (t[i-1]+int(s[n-i])*d) % p
    P[t[i]] += 1
    d = d*10 % p
ans = 0
for c in P:
    ans += c*(c-1)//2
# print(t)
print(ans)


Measured memory_bytes: 11232
from sys import stdin
INF = int(1e9+7)


def modadd(a, b):
    # aとbを足した値をmodする(a + b mod p)
    return (a + b) % INF


def main():
    lines = stdin.readlines()
    N = int(lines[0].split()[0])
    M = [True] * (N + 1)
    for i in map(int, lines[1:]):
        M[i] = False
    dp = [0] * (N + 1)
    dp[0] = 1
    for cur in range(N + 1):
        for i in range(cur + 1, min(cur + 2, N) + 1):
            if M[i]:
                dp[i] = modadd(dp[cur], dp[i])
    print(dp[N])
    return


main()


Measured memory_bytes: 11028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>

char s[205050];

int main()
{
	scanf("%s",&s[1]);
	register int ls=strlen(&s[1]);
	register int fbpos=1;
	for(;fbpos<=ls;fbpos++)
		if(s[fbpos]=='B')
			break;
	register int wbks=0;
	for(register int i=fbpos;i<=ls;i++)
		if(s[i]=='W')
			wbks++;
	register long long ans=0;
	while(fbpos<=ls)
	{
		ans+=wbks;
		fbpos++;
		for(;fbpos<=ls && s[fbpos]=='W';fbpos++)
			wbks--;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, 0, n) cin >> v[i];
    sort(v.begin(), v.end());

    double ans = v[0];
    rep(i, 1, n)
        ans = (double) (ans + v[i]) / 2;
    
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int A, B, C;
  cin >> A >> B >> C;

  int max = (A > B ? A : B) > C ? (A > B ? A : B) : C;
  int min = (A > B ? B : A) < C ? (A > B ? B : A) : C;
  int mid = A + B + C - max - min;

  cout << min + 10 * max + mid << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define nitro ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int p[mx] , sz[mx];
int find_set(int v){
    if(v == p[v]){
        return v;
    }
    return p[v] = find_set(p[v]);
}
void union_set(int x,int y){
    int a = find_set(x);
    int b = find_set(y);
    if(a != b){
        if(sz[a] < sz[b])
            swap(a,b);
        p[b] = a;
        sz[a] += sz[b];
    }
}
int ans[mx]={0};
int main()
{
    nitro ;
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        p[i] = i;
        sz[i] = 1;
    }
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        ans[x] ++;
        ans[y] ++;
        union_set(x,y);
    }
    for(int i=1;i<=k;i++){
        int y,x;
        cin>>x>>y;
        if(find_set(x) == find_set(y)){
            ans[x] ++;
            ans[y] ++;
        }
    }
    for(int i=1;i<=n;i++){
        //cout<<sz[find_set(i)]<<endl;
        cout<<sz[find_set(i)] - ans[i] - 1<<' ';
    }
}


Measured memory_bytes: 2048
def kaibun?(s)
  n = s.size
  if n.even?
    s[0, n / 2] == s[n / 2, n / 2].reverse
  else
    s[0, n / 2] == s[n / 2 + 1, n / 2].reverse
  end
end

s = gets.chomp
n = s.size

if kaibun?(s) && kaibun?(s[0, n / 2]) && kaibun?(s[n / 2 + 1, n / 2])
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int X;
    cin>>X;
    int ans=1;
    bool j=false;
    while(j==false){
        if((X*ans)%360==0){
            j=true;
        }
        else{ans++;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

	int H, W, K;

	cin >> H >> W >> K;

 	vector< vector<char> > s(H, vector<char>(W, 0));
	vector< vector<int> > ans(H, vector<int>(W, 0));
	vector<int> memo(H);

	int first_checker = 0;

	int num = 1;

	for(int i = 0; i < H; i++) {
		bool checker = false;
		for(int j = 0; j < W; j++) {
			cin >> s[i][j];
			if(s[i][j] == '#') {
				ans[i][j] = num;
				num++;
				if(checker == false) {
					checker = true;
					memo[i] = num - 1;
				}
				if(first_checker == 0) {
					first_checker = 1;
				}
			}
		}
		if(!checker) {
			memo[i] = -1;
		}
		if(first_checker == 1) {
			first_checker = 2;
			for(int k = 0; k < i; k++) {
				memo[k] = memo[i];
				for(int j = 0; j < W; j++) {
					ans[k][j] = ans[i][j];
				}
			}
		}
	}

	for(int i = 0; i < H; i++) {
		if(memo[i] == -1) {
			for(int j = 0; j < W; j++) {
				ans[i][j] = ans[i - 1][j];
			}
		} else {
			num = memo[i];
			for(int j = 0; j < W; j++) {
				if(ans[i][j] != 0) {
					num = ans[i][j];
				} else {
					ans[i][j] = num;
				}
			}
		}
	}	

	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}

			
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>

//?????????????????????????????£???????????????
//?¨??????\???:?????????
//         ????????°
//         ????????? ?§???? ?????? (?????????)
std::string Reverse(std::string s, int a, int b){
	std::string S = s;
	for(int i = a; i <= b; i++) s[i] = S[a+b-i];
	return s;
}

std::string Replace(std::string s, int a, int b){
	std::string replace;
	std::cin >> replace;
	for(int i = a; i <= b; i++) s[i] = replace[i-a];
	return s;
}

void Manupulate(std::string& str)//?????§??????????????¨????????¢??°??§????????????????????????
{
	std::string order;
	std::cin >> order;
	int start, end;
	std::cin >> start >> end; //vector???????§??????????????????????
	if(order == "replace")
	{
		str = Replace(str, start , end);
		return;
	}
	if(order == "print")
	{
		std::cout << str.substr(start, end - start + 1) << std::endl;
		return;
	}
	if(order == "reverse")
	{
		str = Reverse(str, start, end);
		return;
	}
}

int main() //main??¢??°???20????¨??????§
{
	//?????????????????????
	std::string str;
	std::cin >> str;
	//???????????°????????????
	int q;
	std::cin >> q;
	//??????????????????????????????
	for(int i = 0; i < q; i++){
		Manupulate(str);
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <math.h>

using namespace std;
typedef long double ld;

ld a,b,x;

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

  cin >> a >> b >> x;

  ld h = x / (a * a);
  ld area = h * a;
  // (h2 * b) / 2 = area;
  ld h2 = area * 2 / b;
  if (a * a * b / 2.0 <= x) {
    //ld space = a * b - area;
    //ld h3 = space * 2 / a;

    //ld radian = atan2(h3, a);
    ld radian = atan2(2 * (a * a * b - x), (a * a * a));
    ld degree = radian * 180.0 / M_PI;
    printf("%.10Lf\n", degree);
    return 0;
  } else {
    ld radian = M_PI / 2 - atan2(2 * x, (a * b * b));
    //ld radian = atan2(h2, b);
    ld degree = radian * 180.0 / M_PI;

    printf("%.10Lf\n", degree);
    return 0;
  }
}


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

using namespace std;

int main(void)
{
	int num, num2;
	cin >> num;
	cin >> num2;
	if (num < 9 && num2 < 9)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size(), ans = 0;
  rep(i, 0, n - 1) {
    if (s[i] != s[i + 1]) {
      ans++;
    }
  }
  cout << ans << endl;
  getchar();
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

N = int(input())
A = [list(map(lambda n: int(n)-1, input().split())) for i in range(N)]
cur = [0 for i in range(N)]
que = [i for i in range(N)]
ans = 0
while len(que) > 0:
    done = {}
    que2 = []
    for n in que:
        if done.get(n):
            continue
        pair = A[n][cur[n]]
        if done.get(pair):
            continue
        if n == A[pair][cur[pair]]:
            cur[n] += 1
            cur[pair] += 1
            done[n] = True
            done[pair] = True
            if cur[n] < N-1:
                que2.append(n)
            if cur[pair] < N-1:
                que2.append(pair)
    if len(done) > 0:
        ans += 1
    que = que2
ok = True
for i in range(N):
    if cur[i] < N-1:
        ok = False
if ok:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 37108
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong(), B = sc.nextLong(), K = sc.nextLong();
		sc.close();
		long t = 0, a = 0;
		if(A>=K) {
			t=A-K;
			a=B;
		}
		else {
			t = 0;
			a = Math.max(0,B-(K-A));
		}
		
		System.out.println(t + " " + a);
		
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

int n;
double dp[3000],newdp[3000],p,ans;

int main(void){
    cin>>n;
    dp[0]=1;
    repi(i,n/2+1,n)ans+=dp[i];
    rep(i,n){
        cin>>p;
        newdp[0]=dp[0]*(1-p);
        repi(j,1,3000)newdp[j]=dp[j]*(1-p)+dp[j-1]*p;
        rep(j,3000)dp[j]=newdp[j];
    }
    repi(i,n/2+1,3000)ans+=dp[i];
    cout<<setprecision(20)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=100100100;
int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i=0;i<n;i++) cin >> x[i];
    int ans=inf;
    for(int i=0;i<=100;i++){
        int cost=0;
        for(int j=0;j<n;j++) cost+=(x[j]-i)*(x[j]-i);
        ans=min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
import itertools #list(accumulate(A))

S = input()
K = ii()
N = len(S)


alphabets = list('abcdefghijklmnopqrstuvwxyz')
l = []

for alpha in alphabets:
    for i, m in enumerate(S):
        if m == alpha:
            flag = 1
            for j in range(1, min(K+1, N-i+1)):
                l.append(S[i:i+j])
    #print(set(l))
    l = sorted(set(l))
    if len(l) >= K:
        print(l[K-1])
        exit()

Measured memory_bytes: 4596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>

const int primN = 3165000;

long long p[primN], hash[primN], pnum;
void mlist() {
    p[pnum++] = 2;
    for (int i=3; i<primN; i+=2)
        if (!hash[i]) {
            p[pnum++] = i;
            if (i<10000) for (int j=i*i; j<primN; j+=(2*i)) hash[j]=1;
        }
}

long long pf[60], pfnum = 0, lim[60];
void pfact(long long n) {
    pfnum = 0;
    if (n==1) {
        pfnum = 1;
        return;
    }
    for (int i=0; i<pnum&&p[i]*p[i]<=n;++i)
        if (n%p[i]==0) {
            lim[pfnum] = 0;
            while (n%p[i]==0) n/=p[i], ++lim[pfnum];
            pf[pfnum++] = p[i];
        }
    if (n!=1) lim[pfnum] =1, pf[pfnum++]= n;
}

void doit() {
    long long l;
    scanf("%lld", &l);
    if (l==0) exit(0);
 /*   long long i;
    long long ans = 0LL;
    for (i=1LL; (i*i)<l; ++i) {
        //printf("%I64d %I64d\n",i*i, l);
        if (l%i==0) {
            pfact(l/i);
            if (pfnum>0) ans += (1LL<<(pfnum-1LL));
            pfact(i);
            if (pfnum>0) ans += (1LL<<(pfnum-1LL));
        }
    }
    if (i*i==l) {
        pfact(i);
        if (pfnum>0) ans += (1LL<<(pfnum-1LL));
    }*/
    pfact(l);
    long long ans=1;
    for(int i=0;i<pfnum;i++)
    ans*=(2*lim[i]+1);
    ans=(ans+1)/2;
    printf("%lld\n", ans);
}

int main() {
    mlist();
    while (1) {
        doit();
    }
    return 0;
}

Measured memory_bytes: 26000
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int A,B;

	scanf("%d %d", &A,&B);
	if (A > 8 || B > 8) {
		printf(":(");
	}
	else {
		printf("Yay!");
	}
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1000000000;

int main()
{
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)
   {
      cout<<"Yes"<<endl;
   }
   else
   {
      cout<<"No"<<endl;
   }
   
   return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

a = [20001*i for i in range(1,n+1)]
b = [20001*(n+1-i) for i in range(1,n+1)]

for i in range(n):
    b[x[i]-1] += i
    
for x in a:print(x, end=' ')
print()
for x in b:print(x, end=' ')

Measured memory_bytes: 5488
import numpy as np

k, q = map(int, input().split())
d = np.array(input().split(), dtype=np.int)
for _ in range(q):
  n, x, m = map(int, input().split())
  quot = (n-1) // k
  rest = (n-1) % k
  dmod = d % m
  same = (k - np.count_nonzero(dmod)) * quot + rest - np.count_nonzero(dmod[:rest])
  a_last = x % m + dmod.sum() * quot + dmod[:rest].sum()
  beyond = a_last // m
  print(n - 1 - same - beyond)

Measured memory_bytes: 14536
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    cout << (s.substr(0, n / 2) == s.substr(n / 2) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if(k % 2 == 0) ans = a - b;
    else ans = b - a;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256