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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    sort(ALL(A));

    ll count = 0;
    FOR(k, 1, 100001){
        ll num = distance(A.begin(), lower_bound(ALL(A), k));
        if(num == N-num){
            count++;
        }
    }
    p(count);
    
    return 0;
}

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

int main() {
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];
    ll ans = 0;
    for (int i = 0; i < N-1; i++) {
        ans += min((X[i+1] - X[i]) * A, B);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
    map<int, bool> memo;
 
    int N;
    cin >> N;
 
    int cnt = 0;
 
    for(int i=0; i<N; i++){
        int p[3];
        cin >> p[0] >> p[1] >> p[2];
 
        sort(p, p+3);
 
        int k = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
 
        if(memo.find(k)!=memo.end())
            cnt++;
        else
            memo[k] = true;
    }
 
    cout << cnt << endl;
 
    return 0;
}

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

int main()
{
    int A, B, C;
    cin>>A>>B>>C;

    int nopois = A+B;
    int res = 0;
    if(nopois < C){
        res = nopois + 1 + B;
    }
    else{
        res = B + C;
    }

    cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>

void print_frame(int h, int w)
{
    int i, j, n, x;

    for (i = 1; i <= w; i++) //一行目に#を横幅分出力
    {
        putchar('#');
    }

    putchar('\n');

    for (j = 1; j <= h - 2; j++) //二行目から最終行-1行目まで#.....#を出力
    {
        for (n = 1; n <= w; n++)
        {
            if (n == 1)
            {
                putchar('#');
            }
            else if (n >= 2 && n < w)
            {
                putchar('.');
            }
            else if (n == w)
            {
                putchar('#');
            }
        }

        if (j < h - 2) //最終行-1行目のみ改行を出力しない
        {
            putchar('\n');
        }
        else
        {
        }
    }

    if (h > 2) //高さが2以下の時は改行を行わない
    {
        putchar('\n');
    }

    for (x = 1; x <= w; x++) //最終行に#を出力
    {
        putchar('#');
    }
    putchar('\n');
}

int main(void)
{
    int h, w;

    while (1)
    {
        scanf("%d %d", &h, &w);

        if (h == 0 && w == 0)
        {
            break;
        }
        else
        {
            print_frame(h, w);
            putchar('\n');
        }
    }

    return 0;
}


Measured memory_bytes: 2040
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MaxN = 1e6;
int n, m, i, j, t, k, p, q, sum, flag;
int a[3];

int main()
{
	while(cin >> a[0] >> a[1] >> a[2])
	{
		sort(a, a + 3);
		n = a[2];
		t = a[2] - a[0];
		k = a[2] - a[1];
		if(t % 2 == 0 && k % 2 == 0)
			flag = t / 2 + k / 2;
		else if(t % 2 == 1 && k % 2 == 1)
			flag = t / 2 + k / 2 + 1;
		else
		{
			if(a[2] % 2 == 0)
			{
				if(a[0] % 2 == 0)  flag = t / 2 + (k + 1) / 2 + 1;
				if(a[1] % 2 == 0)  flag = (t + 1) / 2 + k / 2 + 1;
			}
			if(a[2] % 2 == 1)
			{
				if(a[0] % 2 == 1)  flag = t / 2 + (k + 1) / 2 + 1;
				if(a[1] % 2 == 1)  flag = (t + 1) / 2 + k / 2 + 1;
			}
		}
		printf("%d\n", flag);
	}
	return 0;
}

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

int main(){
    int K,N;
    cin >> K >> N;
    int ans = 0;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }

    vector<int> minus(N);
    int a = 0;
    for(int i = 0; i < N; i++){
    if( i == N -1){
        minus.at(i) = vec.at(0) + K - vec.at(i);
    }else{
        minus.at(i) = vec.at(i + 1) - vec.at(i);
    }
    }

    int number = 0;
    for (int i = 0; i < N; i++){
        number = max(number,minus.at(i));
    }
    cout << K - number;
    return 0;
}

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int i;
    bool flag = false;
    for(i=1;i<=B;i++){
        if((A*i)%B==C){
            flag = true;
        }
    }

    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())

    print(lst[K-1])

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {

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

	if (a > b) {
		for (int i = 0; i < a; ++i)
		{
			cout << b;
		}
	}
	else {
		for (int i = 0; i < b; ++i)
		{
			cout << a;
		}
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
namespace Sample
{
  class Sample1
  {
    static void Main()
    {
		string[] line = Console.ReadLine().Trim().Split(' ');
		double first = int.Parse(line[0]);
          double second = int.Parse(line[1]);
      double firstsum = 0;
      double secondsum = 0;
       secondsum = second;
      for(int i =1;i <= first-1; i++){
      
        secondsum = secondsum + second* Math.Pow(10,i);
           // Console.WriteLine(secondsum);

      }
             firstsum = first;

       for(int i =1;i <= second-1; i++){
      
        firstsum = firstsum + first* Math.Pow(10,i);
            //Console.WriteLine(firstsum);

      }
      //Console.WriteLine(firstsum);
      if(secondsum > firstsum){
      Console.WriteLine(secondsum);
      
      }else{
      
            Console.WriteLine(firstsum);

      }
      
		}
	}
}

Measured memory_bytes: 11092
S = input()
n = len(S) - 1
total = 0
for i in range(1 << n):
    t = S[0]
    for j in range(n):
        if (i >> j) & 1:
            t += '+' + S[j + 1]
        else:
            t += S[j + 1]
    total += eval(t)

print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=305;
const int M=2*N;
const int K=2*M;
const int mod=998244353;
int pow(int x, int k){ int ans=1;for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ans=(ll)ans*x%mod;return ans;}
int inv(int x){ return pow(x,mod-2);}
char s[M][M];
int diag(int x, int y, int n){ return x-y+n;}
vector<int> Hash[K];
int po[M],ip[M];
void Add(int d, char c)
{
	Hash[d].pb(((ll)Hash[d].back()*26+c-'a'+1)%mod);
}
int Get(int d, int l, int r)
{
	return (Hash[d][r]-(ll)Hash[d][l-1]*po[r-l+1]%mod+mod)%mod;
}
int main()
{
	int n,i,j;
	scanf("%i",&n);
	for(i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(i=1;i<2*n;i++) for(j=1;j<2*n;j++) s[i][j]=s[(i-1)%n+1][(j-1)%n+1];
	po[0]=ip[0]=1;
	for(i=1;i<M;i++) po[i]=(ll)po[i-1]*26%mod;
	ip[1]=inv(26);
	for(i=2;i<M;i++) ip[i]=(ll)ip[i-1]*ip[1]%mod;
	for(i=0;i<K;i++) Hash[i].pb(0);
	for(i=1;i<2*n;i++) for(j=1;j<2*n;j++) Add(diag(i,j,2*n-1),s[i][j]);
	int ans=0;
	for(i=1;i<=n;i++) for(j=1;j<=n;j++)
	{
		bool ok=1;
		for(int k=1;k<n;k++)
		{
			int d1=diag(i,j+k,n*2-1);
			int d2=diag(i+k,j,n*2-1);
			int l=min(i,j+k),r=l+n-k-1;
			int h1=Get(d1,l,r);
			//printf("(l:%i r:%i)\n",l,r);
			l=min(i+k,j);r=l+n-k-1;
			int h2=Get(d2,l,r);
			//printf("(l:%i r:%i)\n",l,r);
			//printf("(i:%i j:%i k:%i) h1:%i h2:%i\n",i,j,k,h1,h2);
			if(h1!=h2){ ok=0;break;}
		}
		ans+=ok;
		//if(ok) printf("%i %i\n",i,j);
	}
	printf("%i\n",ans);
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


vector<ll> bfs(int n, vector<vector<int>> &g) {

    vector<ll> costs(n, INF);
    costs[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int from = q.front();
        q.pop();
        for (int to  : g[from]) {
            if (costs[to] != INF) continue;
            costs[to] = costs[from] + 1;
            q.push(to);
        }
    }
    return costs;
}


bool bfs2(int n, vector<vector<int>> &g) {
    vector<ll> costs(n, INF);
    costs[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {

        int from = q.front();
        q.pop();
        for (int to  : g[from]) {

            ll current_cost = costs[to];
            ll next_cost = costs[from] + 1;

            if (current_cost != INF) {
                if (current_cost % 2 != next_cost % 2) return false;
                continue;
            }
            costs[to] = next_cost;
            q.push(to);
        }
    }
    return true;
}

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

    vector<P> v(m);
    for (P &p : v) cin >> p.first >> p.second, p.first--, p.second--;

    vector<vector<int>> g(n);
    for (P p: v) g[p.first].push_back(p.second);
    for (P p: v) g[p.second].push_back(p.first);

    vector<ll> costs = bfs(n, g);
    bool is_2 = bfs2(n, g);

    if (is_2) {
        ll a = 0;
        for (ll c : costs) if (c % 2 == 0) a++;
        ll b = n - a;
        ll all = a * b;
        ll ans = all - m;
        cout << ans << endl;
        ret();
    }

    ll all = ll(n) * (n - 1) / 2;
    ll ans = all - m;
    cout << ans << endl;
}

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

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

    int x = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
            x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
num_word = int(input())
word_list=[]
word_list = [str(input()) for i in range(num_word)] 
 
word_list_temp=[]
for j in range(len(word_list)):
  if j == len(word_list)-1:
    print ("Yes")
    break
  else:
    old_word=word_list[j]
    old_word_sep=list(old_word)
    word_list_temp.append(old_word)
    new_word=word_list[j+1]
    new_word_sep=list(word_list[j+1])
    if old_word_sep[len(old_word)-1]!=new_word_sep[0]:
      print ("No")
      break
    elif new_word in list(word_list_temp):
      print ("No")
      break
    else:
      continue

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

border = sum(A) / (4*M)
ans = "No"

popular = 0
for item in A:
    if item >= border:
        popular += 1
        if popular == M:
            ans = "Yes"
            break

print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int n;
    int m;
    long[] a;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        a = new long[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextLong();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        for (int i = 0; i < a.length; i++) {
            n -= a[i];
            if (n < 0) {
                System.out.println("-1");
                break;
            }
            if (i == m-1) {
                System.out.println(n);
            }
        }
    }
}

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

using namespace std;
#define ll long long
const int mod=1e9+7;
const int N=2e5+100;

int a[N];
int n,m;
ll qpow(ll x,ll n)
{
    ll sum=1;
    while(n){
       if(n&1) sum=sum*x%mod;
       x=x*x%mod;
       n>>=1;
    }
    return sum;
}
struct node
{
    int x,y;
};
char d[1003][1003];
int vis[1000009];
int cnt=0;
vector <node>ve[1000009];
int viss[1003][1003];
int dv[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int sx,sy,ex,ey;
void dfs(int x,int y)
{
    for(int i=0;i<4;i++){
          int xx=x+dv[i][0];
          int yy=y+dv[i][1];
    if(!viss[xx][yy] && xx>=1 && xx<=n && yy>=1 && yy<=m && d[xx][yy]!='#'){
         ve[cnt].push_back({xx,yy});
         viss[xx][yy]=cnt;
         dfs(xx,yy);
    }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>m;
    cin>>sx>>sy>>ex>>ey;
    for(int i=1;i<=n;i++){
         cin>>d[i]+1;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) {
            if(!viss[i][j] && d[i][j]!='#'){
            cnt++;
            viss[i][j]=cnt;
            ve[cnt].push_back({i,j});
            dfs(i,j);
            }
        }
    }
 //  cout<<cnt<<endl;

    int sk=viss[sx][sy];
    int ek=viss[ex][ey];

 //   cout<< sk<<" "<<ek<<endl;
   queue<int>q;
   q.push(sk);
   vis[sk]=1;
   while(q.size()){
        int i=q.front();q.pop();
        for(auto v:ve[i]){
             //   cout<<v.x<<" "<<v.y<<endl;
             for(int j=-2;j<=2;j++){
                for(int k=-2;k<=2;k++){
                    int x=v.x+j;
                    int y=v.y+k;
                    if(x>=1 && x<=n && y>=1 && y<=m && !vis[viss[x][y]] && d[x][y]!='#'){
                        vis[viss[x][y]]=vis[i]+1;
                        q.push(viss[x][y]);
                    }
                }
             }
        }
    }
   if(vis[ek]==0) puts("-1");
   else cout<<vis[ek]-vis[sk]<<endl;
    return 0;
}



Measured memory_bytes: 38764
using System;
using System.Collections.Generic;

namespace ABC127 {
	struct Rule : IComparable<Rule> {
		public int b,
		c;
		public Rule (int i_b, int i_c) {
			b = i_b;
			c = i_c;
		}
		public int CompareTo (Rule other) {
			// intと降順と昇順を逆にしたいので工夫する
			int cCompareTo = this.c.CompareTo (other.c);
			if (cCompareTo != 0) {
				return -cCompareTo;
			}
			int bCompareTo = this.b.CompareTo (other.b);
			return -bCompareTo;
		}
	}
	class Program {
		static void Main (string[] args) {
			// 入力
			int N, M;
			int[] firstArray = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			N = firstArray[0];
			M = firstArray[1];
			int[] secondArray = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			List<int> A = new List<int> (N);
			for (int i = 0; i < N; i++) {
				A.Add (secondArray[i]);
			}
			List<Rule> rules = new List<Rule> (M);
			for (int i = 0; i < M; i++) {
				int[] array = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
				rules.Add (new Rule (array[0], array[1]));
			}
			// 処理・出力
			/*	正攻法はこう
				- 0~M-1に対して以下の処理
					- A[]をソート
					- A[0]~A[B[i]]のうち、C[i]以下のものをC[i]に書き換え(これのせいでO(n^2)となる)
				- これで最大の時の結果が出る。あとは和を求めればよい。
				こいつの非効率なところは「同じ値を書き換えまくる」である。
				A[i]は１回しか書き換えないようなアルゴリズムは、こう。
				- A[]をソート
				- B[i],C[i]をC[i]が大きい順にソート
				- A[]を上から順に「B[i]個だけC[i]に書き換える、ただしA[j]>=C[i]となったらもう書き換えない」をする
			 **/
			// Aをソート
			A.Sort ();
			// B,Cをソート
			rules.Sort ();
			// Aを書き換え
			int rulesIndex = 0;
			int aIndex = 0;
			while (aIndex < N && rulesIndex < M) {
				for (int i = aIndex; i < aIndex + rules[rulesIndex].b; i++) {
					if (i >= N) {
						aIndex = N;
						break;
					}
					if (A[i] < rules[rulesIndex].c) {
						A[i] = rules[rulesIndex].c;
					} else {
						// 書き換え終了
						aIndex = N;
						break;
					}
				}
				aIndex += rules[rulesIndex].b;
				rulesIndex++;
			}
			// 合計値の計算
			Int64 total = 0;
			for (int i = 0; i < N; i++) {
				total += A[i];
			}
			Console.WriteLine (total);
		}
	}
}

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

using namespace std;

typedef long long ll;
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n';
vector<ll>g[1000001];
ll vis[1000005]={0};
ll ct=0;
map<ll,ll>mapsy;
ll dfs(ll curr) {
    vis[curr]=1;
      for(ll i=0;i<g[curr].size();i++) {
        ll child=g[curr][i];
        if(vis[child]==0){
            ct++;
            dfs(child);
        }
    }
    return ct;
}

int main(){
    ll t;
    t=1;
    while(t--) {
        ll n,e;
        cin >> n >> e;
        while(e--){
            ll u,v;
            cin >> u >> v;
            if(mapsy[u]!=v){g[u].pb(v);g[v].pb(u);mapsy[u]=v;}
        }
        vector<ll>v;
        ll c=0;
        for(ll i=0;i<=n;i++) {
            if(vis[i]==0){
                v.pb(dfs(i)+1);
                ct=0;
                c++;
            }
        }
         if(c==1) cout<<n<<" ";
    else
    {
           sort(v.begin(),v.end());
          cout<<v[0]+(v[v.size()-1]-v[0]);
    }
        
    }
}


Measured memory_bytes: 53508
S = input()
s = []

for i in range(4):
    s.append(S[i])

mon = int(s[2] + s[3])
yer = int(s[0] + s[1])

if 1 <= mon <= 12:
    if 1 <= yer <= 12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if 1 <= yer <= 12:
        print('MMYY')
    else:
        print('NA')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
	int n;
	string s;
	long long r = 0, g = 0, b = 0;
	long long count;

	cin >> n >> s;
	for (int i = 0;i < n;i++) {
		switch (s[i])
		{
		case 'R':
			r++;
			break;
		case 'G':
			g++;
			break;
		case 'B':
			b++;
			break;
		default:
			break;
		}
	}
	count = r * g * b;
	for (int i = 0;i < n;i++) {
		for (int j = i + 1;2 * j < (n + i);j++) {
			if (s[i] != s[j] && s[j] != s[2 * j - i] && s[i] != s[2 * j - i])count--;
		}
	}

	cout << count << "\n";
	return 0;

}


Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k, n, st, a, a2=-1;
    int maxD = 0;
    cin >> k >> n;
    for(int i=0; i<n; i++){
        cin>>a;
        if(a2 == -1){
            st = a;
        }else{
            maxD = max(maxD, a-a2);
        }
        a2 = a;
    }
    maxD = max(maxD, k+st-a);
    cout << k-maxD << endl;
    return 0;
}

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

string X, Y;

int main(){
  int n;
  int dp[1002][1002];
  cin >> n;
  for (int a=0;a<n;a++){
    cin >> X>> Y;
    X = ' ' + X; Y = ' ' + Y;
    int maxlcs=0;
    for (int i=0;i<=max(X.length(), Y.length());++i)
      dp[i][0] = dp[0][i] = 0;
    for (int i=1;i<=X.length();++i){
      for (int j=1;j<=Y.length();++j){
          if (X[i] == Y[j])
            dp[i][j] = dp[i-1][j-1]+1;
          else
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
          maxlcs = max(maxlcs,dp[i][j]);
      }
    }
    cout << maxlcs-1 << endl;
  }
  return 0;
}




Measured memory_bytes: 6996
from math import atan, pi

a,b,v = map(int, input().split())
if v == a*a*b:
  theta = pi/2
elif v*2 < a*a*b:
  e= v*2/(a*b)
  theta = atan(e/b)
else:
  e = 2*(a*b - v/a)/a
  theta = atan(a/e)
theta *= 180/pi
print(90.0 - theta)


Measured memory_bytes: 3060
#include <cstdio>
int p = 37;
int main() {
	printf("%d %d\n", p * p + p + 1, p + 1);
	for (int i = 0; i < p + 1; i++) {
		printf("1");
		for (int j = i * p + 1; j < (i + 1) * p + 1; j++) printf(" %d", j + 1);
		printf("\n");
	}
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < p; j++) {
			printf("%d", i + 2);
			for (int k = 0; k < p; k++) printf(" %d", k * p + (i * k + j) % p + p + 2);
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define mod 998244353
#define fs first
#define sc second
signed main()
{
  fastio
//   freopen("INPUT.txt", "r", stdin);
//   freopen("OUTPUT.txt", "w", stdout);

  int n,i,j;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  int sum = 0; 
	int pow[61];
	pow[0]=1;
	for(int i=1;i<=60;i++)
	{
		pow[i]=(pow[i-1]*2)%hell;
	}

	for (i = 0; i < 61; i++)  
    { 
        int zc = 0, oc = 0;  
          int idsum = 0;  
        for (j = 0; j < n; j++) 
        { 
            if (a[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            a[j] /= 2; 
        } 

        idsum = (((oc * zc)%hell) * pow[i])%hell;   
		sum += idsum;  
		sum%=hell;
    }
    cout<< sum; 
  return 0;
}

Measured memory_bytes: 2560
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

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

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define P pair<int,int>
#define V vector<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(a);CIN(b);CIN(h);
    COUT((a+b)*h/2);
    return 0;
}


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

int main()
{
  long A, B, K;

  cin >> A >> B >> K;

  if (K >= A)
  {
    K -= A;
    A = 0;
  }
  else
  {
    A -= K;
    K = 0;
  }
  if (K >= B)
  {
    K -= B;
    B = 0;
  }
  else
  {
    B -= K;
    K = 0;
  }

  cout << A << " " << B << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    int can=a-b;
    if(can>=c)
        cout<<"0"<<endl;
    else
        cout<<c-can<<endl;

    return 0;
}


Measured memory_bytes: 3612
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M, X = map(int, input().split())
    info = []
    for _ in range(N):
        info.append(list(map(int, input().split())))

    ans = 10**10
    for i in range(2**N):
        skill = [0] * M
        price = 0
        for j in range(N):
            if i>>j&1:
                price += info[j][0]
                for k in range(1, M+1):
                    skill[k-1] += info[j][k]
        ok = 1
        for m in range(M):
            if skill[m] < X:
                ok = 0
                break
        if ok:
            ans = min(ans, price)
    if ans == 10**10:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69108
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long 
using namespace std;

map<pair<ull, ull>, set<ull>> MakePairIndex(){
    ull pow2, pow5, value, Size;
    double input;
    map<pair<ull, ull>, set<ull>> pair_index;
    
    scanf("%llu", &Size);
    
    for(int i=0; i < Size; i++){
        pow2=0, pow5=0;
        scanf("%lf", &input);
        value=llround(input * 1e9);
        while(value % 2 == 0){
            pow2++;
            value/=2;
        }
        while(value % 5 == 0){
            pow5++;
            value/=5;
        }
        pair_index[*new pair(pow2, pow5)].insert(i);
    }
    return pair_index;
}

int main() {
    ull counter=0;
    pair<ull, ull> A,B;
    set<ull> P, Q;
    map<pair<ull, ull>, set<ull>> pair_index= MakePairIndex();
    
    for(auto i=pair_index.begin(); i!=pair_index.end(); i++){
        for(auto j=i; j!=pair_index.end(); j++){
            A=i->first, B=j->first, P=i->second, Q=j->second;
            
            if(min(A.first + B.first, A.second + B.second) >= 18){
                if(i==j){
                    counter+=P.size()*(Q.size()-1)/2;
                }else if(*i<*j){
                    counter+=(P.size()*Q.size());
                }
            }
        }
    }
    printf("%llu\n", counter);
    return 0;
}

/*Logic:
 * Since floating points are stored as approximate value.
 * Direct multiplication will result in some anomaly.
 * To avoid that we multiplied the given floating point or regular number
 * with 10^9, because the highest number of digits after decimal is 9.
 * This will make the numbers to be in the form
 * number/10^9.
 * Now, if we multiply say (x/10^9 * y/10^9) then we get
 * xy/10^18.
 * To get an integer, all we have to do is cancel out the denominator.
 * So xy has be z*(10^(>=9)).
 * Now we also know that 10^p is basically (2^p)*(5^p).
 * Here, p has to be equal to or greater that 9.
 *
 * Now, comes to the problem of handling TLE.
 * Since the dataset is 2*10^6 and 2 sec, regular brute force gave me TLE.
 * So in order to handle that a map with key (2^p)*(5^q) where p varies and q varies
 * and as value stores the indices of where key was found.
 * Now, for any pair of keys min(p1+p2, q1+q2) >=18, then all we multiply the number
 * of values from the keys.
 * If for the same key min(p1+p1, q1+q1) >=18, then all possible combinations are required.
 * Thus number of values*(number of values-1)/2.
 * Summation of all of these results in the answer.
 */

Measured memory_bytes: 37960
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    MOD = int(1e09 + 7)
    S = sum(A)
    S -= MOD
    ans = 0
    for i in range(N):
        S -= A[i]
        ans += A[i] * S
        ans %= MOD
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 33464
#include <iostream>
#include <climits>
int s[500001], l[250001], r[250001];
static int mg(int left, int m, int right) {
    int n1 = m - left, n2 = right - m, i = 0, j = 0, c = 0;
    for (int k = 0; k < n1; ++k) {
        l[k] = s[left + k];
    }
    for (int k = 0; k < n2; ++k) {
        r[k] = s[m + k];
    }
    l[n1] = INT_MAX;
    r[n2] = INT_MAX;
    for (int k = left; k < right; ++k) {
        ++c;
        if (l[i] <= r[j]) {
            s[k] = l[i++];
        } else {
            s[k] = r[j++];
        }
    }
    return c;
}
static int msort(int left, int right) {
    int c = 0;
    if (left + 1 < right) {
        int m = left + (right - left) / 2;
        c += msort(left, m);
        c += msort(m, right);
        c += mg(left, m, right);
    }
    return c;
}
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> s[i];
    }
    int c = msort(0, n);
    for (int i = 0; i < n; ++i) {
        std::cout << ((i == 0) ? "" : " ") << s[i];
    }
    std::cout << std::endl << c << std::endl;
}



Measured memory_bytes: 6992
#include <stdio.h>
#include <iostream>

int main(int argc, char** argv)
{
    int A,B;
    std::cin >> A;
    std::cin >> B;
    int C = A>12 ? B : A>5 ? B/2 : 0;

    std::cout << C;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int[] x = new int[N+1];
    int sum = 0;
    for (int i = 1; i <= N; i++) {
      x[i] = sc.nextInt();
      sum += x[i];
    }
    
    long[][][] dp = new long[N+1][N+1][sum+1];
    dp[0][0][0] = 1;
    for (int j = 1; j <= N; j++) {
      for (int k = 0; k <= j; k++) {
        for (int s = 0; s <= sum; s++) {
          if (k > 0 && s - x[j] >= 0) {
            // x[j] can be used.
            // not use x[j] + use x[j]
            dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
          } else {
            // x[j] can't be used => not use x[j] case only
            dp[j][k][s] = dp[j-1][k][s];
          }
        }
      }
    }
    
    long ans = 0;
    for (int k = 1; k <= N; k++) {
      if (k*A <= sum) {
        ans += dp[N][k][k*A];
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 85404
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b;
    long double c;
    ll ans = 0;
    cin >> a >> c;
    b = (c+0.00001)*100;
    ans = a * b;
    ans /= 100;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& i: A) cin >> i;

  auto rain = [&](auto x) {
    vector<int> v{x};
    for(auto i=1; i<N; ++i) v.emplace_back(x = A[i - 1] - x);
    return v;
  };

  auto ok = [&](auto v) {
    for(auto i=0; i<N; ++i) if(v[i] + v[(i + 1) % N] != A[i]) return false;
    return true;
  };

  auto check = [&](auto x, auto A) {
    auto v = rain(x);
    return v[N-1] + v[0] < A[N-1];
  };

  auto l=0, h=min(A[0],A[N-1]);
  while(1 < h - l) {
    auto m = (l + h) / 2;
    if(check(m, A)) l = m;
    else            h = m;
  }

  if(ok(rain(l))) h = l;
  auto n = 0;
  for(auto i: rain(h)) cout << (n++ ? " " : "") << 2 * i;
  cout << endl;
}


Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
 
int n,k,ans;
int t[MAX];
int R[MAX];
 
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++)scanf("%d",&t[i]);
  for(int i=n;i>=1;i--)R[i]=(t[i]==t[i+1]?1:R[i+1]+1);
  for(int i=1;i<=n;i++){
    ans=max(ans,k+R[i]+R[i+R[i]]);
    k=(t[i]==t[i-1]?1:k+1);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1968
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
string s;

int pcnt(int x) {
  return __builtin_popcount(x);
}

int f(int x) {
  if(x == 0) return 0;
  return f(x % pcnt(x)) + 1;
}

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

  cin >> n >> s;
  vector<int> x(n);
  REP(i, n) x[i] = s[i] - '0';
  int pc = 0;
  REP(i, n) if(s[i] == '1') pc++;

  vector<int> ans(n, 0);
  REP(i, 2) {
    int npc = pc;
    if(i == 0) npc++; else npc--;
    if(npc <= 0) continue;

    int r0 = 0;
    REP(j, n) r0 = (r0*2+x[j]) % npc;

    int k = 1;
    RREP(j, n) {
      if(x[j] == i) {
        int r = r0;
        if(i == 0) r = (r + k) % npc;
        else r = (r - k + npc) % npc;
        ans[j] = f(r) + 1;
      }
      k = (k * 2) % npc;
    }
  }
  REP(i, n) cout << ans[i] << endl;
}


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

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

int main() {
  int n;
  long long a,b,sum;
  b = 0;
  sum =0;
  cin >> n;
  rep(i,n) {
    cin >> a;
    if (b<a) {
      b = a;
    } else {
      sum = sum+b-a;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, L;
    cin >> N >> L;
    vector<ll> A(N);

    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll c = -1;
    for (ll i = 0; i < N-1; i++) {
        if(A[i] + A[i+1] >= L){
            c = i;
        }
    }
    if(c == -1){
        printf("Impossible\n");
    }
    else{
        printf("Possible\n");
        c++;
        for (ll i = 1; i < c; i++) {
            printf("%lld\n", i);
        }
        for (ll i = N-1; i >= c; i--) {
            printf("%lld\n", i);
        }

    }

}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int m = max(a,b);
	int n = 0;
	for (int i = m; i > 0; i--) {
		if (a%i==0 && b%i==0) n++;
		if (n == k){
			cout << i;
			break;
		}
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  string ans = "";
  rep(i,s.size()){
    if(s.at(i)=='0'){
      ans.push_back('0');
    }else if(s.at(i)=='1'){
      ans.push_back('1');
    }else{
      if(ans.size()==0)continue;
      ans.erase(ans.size()-1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

string s;
const ll K = 5e15;
ll k;

void input() {
  getline(cin, s);
  scanf("%lld", &k);
}

void solve() {
  ll cur = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      cur++;
      if (cur >= k) {
        printf("%c\n", s[i]);
        return;
      }
    } else {
      ll d = 1;
      for (ll j = 0; j < K; j++) {
        d *= (s[i] - '0');
        cur += d;
        if (cur >= k) {
          printf("%c\n", s[i]);
          return;
        }
      }
    }
  }
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


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

for x in range(1000):
    if len(str(x))==n:
        for i in range(m):
            if str(x)[sc[i][0]-1]==str(sc[i][1]):
                continue
            else:
                break
        else:
            print(x)
            break
else:
    print(-1)

Measured memory_bytes: 38384
let input = require('fs').readFileSync('/dev/stdin', 'UTF-8');
var Arr=(input.trim()).split("\n");
Arr.shift();
var bfr=[]; // 全件分の箱

// 4棟分の箱を作る
for(var i=0;i<4;i++){
  bfr.push([]);

  // 3階分の箱を作る
  for(var j=0;j<3;j++){
    bfr[i].push([]);

    // 10部屋分の0を作る
    for(var k=0;k<10;k++){
      bfr[i][j].push(0);
    }
  }
}

// inputで与えられた情報の分ループ
for(var i=0;i<Arr.length;i++){
  var arr=Arr[i].split(" ").map(Number);
  var b=arr[0]-1; // 0
  var f=arr[1]-1; // 0
  var r=arr[2]-1; // 2
  var v=arr[3]-0; // 8

  // 箱の上から0棟, 0階, 2番目の部屋に8人追加する
  bfr[b][f][r]=bfr[b][f][r]+v;
  // 部屋に追加後に、人が9人より多い場合は人数をMaxの9で止める
  if(bfr[b][f][r]>9)bfr[b][f][r]=9;
  // 部屋に追加後に、人が0人より少ない場合は人数をMinの0で止める
  if(bfr[b][f][r]<0)bfr[b][f][r]=0;
}

// 4棟分ループ
for(var i=0;i<4;i++){
  // 3階分ループ
  for(var j=0;j<3;j++){
    // 先頭に空白を置き、空白連結で全棟全階の情報を書き出す
    console.log(" "+bfr[i][j].join(" "));
  }
  // 1棟終わるごとに区切りを書き出す(最後は不要)
  if(i!==3)console.log("####################")
}


Measured memory_bytes: 16152
#include <stdio.h>

int main(void) {
	int k=0;
	
	while(1){
		
		int n, a[111], i, min, max, sum;
		
		scanf("%d", &n);
		
		if(n==0)
		break;
		
		scanf("%d", &a[0]);
		sum=a[0];
		max=a[0];
		min=a[0];
		for(i=1;i<n;i++){
			scanf("%d", &a[i]);
			sum+=a[i];
			if(max<a[i])
			max=a[i];
			if(min>a[i])
			min=a[i];
		}
		
		printf("%d\n", (sum-max-min)/(n-2));
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int X;
    cin >> X;
    vector<bool> expo(X+1);

    expo[1] = true;
    for (int b = 2; b <= X; b++){
        int v = b * b;
        while( v<=X ){
            expo[v] = true;
            v *= b;
        }
    }
    for(int i=X; i>=1; i--){
        if(expo[i]){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i <= (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int x,y;
  cin >> x >> y;
  if(y % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0, j=x; i <= x; i++, j--){
    if(i + j > x) continue;
    else if((i * 4) + (j * 2) == y ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    //j-i=A[j]+A[i]　(j>iとする)
    //i+A[i]=j-A[j]
    map<int,int>mp;
    ll res = 0;
    rep(i,n){
        res += mp[i-a[i]];
        mp[i+a[i]]++;
    }
    out(res);
}

Measured memory_bytes: 21856
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= print . solve

solve :: String -> Int
solve ss = min a b
    where
        a = check True bs
        b = check False bs
        bs = map (== '0') ss

        check f = fst . foldl' ff (0, f)
            where
                ff (acc, flag) x
                    | flag == x = (acc, not flag)
                    | otherwise = (acc + 1, not flag)

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 7164
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    
    long  N ;
    long  A,B;
    long  G;
    long  b,r = 0;
    cin >> N >> A >> B;
    long  sum = A+B;
    G = N/(A+B);
    b = A * G;
    if(N%sum >= A){
        b+= A;
    }else{
        b+= N%sum;
    }
    cout << b << endl;

    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[])
    {
        Main m = new Main();
        m.p2();
    }

    public void p2()
    {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int input = Integer.parseInt(str);
        long sum = 0;
        for(int j = 0; j <= input; j++)
        {
            if(j % 3 != 0 && j % 5 != 0)sum += j;
        }
        System.out.println(sum);
    }

    public void p1()
    {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        if(str.indexOf("7") != -1)System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35840
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    flag=1
    for a in A:
        if a%2==1 or a%3==0 or a%5==0:
            pass
        else:
            flag=0
            break
    if flag:print('APPROVED')
    else: print('DENIED')





if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
int a[200001];
int main(){
int i,j,n;
long long h=0,b=0,w,k=-1;
scanf("%d",&n);
for(i=1;i<=n;i++){scanf("%d",&a[i]);h+=a[i];}
for(i=1;i<n;i++){
	b+=a[i];
	w=b-(h-b);
	if(w<0)w=-w;
	if((w<k)||(k==-1))k=w; 
}
printf("%lld",k);
return 0;
}



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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

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

    int n, d;
    cin >> n >> d;

    vvi x(n, vi(d, 0));
    REP(i, n) REP(j, d) { cin >> x[i][j]; }

    // REP(i, n) REP(j, d) { cout << x[i][j] << endl; }

    int ans = 0;
    REP(i, n) {
        FOR(j, i + 1, n) {
            int dd = 0;
            REP(k, d) { dd += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]); }
            // cout << dd << endl;
            FOR(k, 1, 10000) {
                if(k * k == dd) {
                    // cout << i << j << endl;
                    ans++;
                }
                if(k * k >= dd)
                    break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256