akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define N 110


int main() {
    string s;
    cin >> s;
    vector<int> cnt(3, 0);
    for (char ch : s) {
        ++cnt[ch - 'a'];
    }
    sort(all(cnt));
    if (cnt[2] - cnt[0] > 1) {
        cout << "NO";
    } else {
        cout << "YES";
    }

    return 0;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int q;
  cin>>q;
  vector<long long> ans;
  rep(i,q){
    int tmp;
    cin>>tmp;
    if(tmp==0){
      int x;
      cin>>x;
      ans.push_back(x);
    }
    else if(tmp==1){
      int p;
      cin>>p;
      cout<<ans[p]<<'\n';
    }
    else{
      ans.pop_back();
    }
  } 
  return(0);
}


Measured memory_bytes: 5020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using ll = long long;
using namespace std;

int main(){
    ll n,x,ans=0;
    cin >> n >> x;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    for(ll i=0;i<(n-1);i++){
        if(a[i]<=x) ans++;
        x-= a[i];
    }
    if(a[n-1]==x)   ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    final static String[] hougaku = {"North","East","South","West","Right","Left"};
    final static int[] taiou = {1,2,3,4,5,6};

    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int top=1,n=5,e=3,w=4,s=2,b=6;
            int ans=1;
            int temp;
            int kaisu = sc.nextInt();
            String move;
            if(kaisu==0)break;
            for(int i=0;i<kaisu;i++){
                move=sc.next();
                if(hougaku[0].equals(move)){
                    temp=top;
                    top=s;
                    s=b;
                    b=n;
                    n=temp;
                }else if(hougaku[1].equals(move)){
                    temp=top;
                    top=w;
                    w=b;
                    b=e;
                    e=temp;
                }else if(hougaku[2].equals(move)){
                    temp=top;
                    top=n;
                    n=b;
                    b=s;
                    s=temp;
                }else if(hougaku[3].equals(move)){
                    temp=top;
                    top=e;
                    e=b;
                    b=w;
                    w=temp;
                }else if(hougaku[4].equals(move)){
                    temp=w;
                    w=s;
                    s=e;
                    e=n;
                    n=temp;
                }else if(hougaku[5].equals(move)){
                    temp=w;
                    w=n;
                    n=e;
                    e=s;
                    s=temp;
                }
                ans+=top;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 25196
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[55],s1[55];
int a[55];
int main()
{
    int n;
    while(cin>>n)
    {
        scanf("%s",&s);
        scanf("%s",&s1);
        int r=0,z;
        long long sum=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]==s[i+1]){i++;a[r++]=2;}
            else a[r++]=1;
        }
        if(a[0]==1){sum=3;z=1;}
        else {sum=6;z=2;}
        for(int i=1;i<r;i++)
        {
            if(a[i]==2)
            {
                if(a[i]==z)
                {
                    sum=sum*3%1000000007;
                }
                else
                {
                    z=a[i];
                    sum=sum*2%1000000007;
                }
            }
            else
            {
                if(a[i]==z)
                {
                    sum=sum*2%1000000007;
                }
                else
                {
                    z=a[i];
                }
            }
        }
        printf("%lld\n",sum);
    }

    return 0;
}


Measured memory_bytes: 256
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N,K = (int(x) for x in input().split())
A = list(map(int, input().split()))
m = max(A)
if N == 1:
    if A[0] == K:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    if K > m:
        print('IMPOSSIBLE')
    else:
        gcd = xgcd(A[0],A[1])
        for i in range(2,N):
            gcd = xgcd(gcd,A[i])
            if gcd == 1:
                print('POSSIBLE')
                break
        else:
            if K % gcd == 0:
                print('POSSIBLE')
            else:
                print('IMPOSSIBLE')

Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;  
  	int n,k;
  	cin>>n>>k;
  	set<int> s;
  	while(k--)
    {
      int d;
      cin>>d;
      for(int i=0;i<d;++i)
      {
        int no;
        cin>>no;
        s.insert(no);
      }
    }
  cout<<n-(int)s.size();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll N,X;
    Scll2(N,X);
  
    ll a = N-X, b = X;
    if( a<b ) swap(a,b);
    ll ans = N;
    do{
        ans += 2*b*(a/b);
        ll c = a%b;
        a = b;
        b = c;
    }while( b );
    ans -= a;
  
    printf("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 3828
#include <iostream>

using namespace std;

double max(double a, double b)
{
  return a > b ? a : b;
}

int main()
{
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  
  double maxConcentration = -1.0;
  double maxWater = -1.0;
  double maxSugar = -1.0;

  for (int aId = 0; aId * (100 * A) <= F; aId++)
  {
    for (int bId = 0; bId * (100 * B) <= F; bId++)
    {
      for (int cId = 0; cId * C <= F; cId++)
      {
        for (int dId = 0; dId * D <= F; dId++) 
        {
          int water = aId * (100 * A) + bId * (100 * B);  //g
          int sugar = cId * C + dId * D;                  //g
          if (water == 0) continue;
          if (water + sugar > F) continue;
          double tolerance = water * ((double)E / 100.0);
          if (tolerance < (double)sugar) continue;
          double concentration = (double)(100 * sugar) / (double)(water + sugar);
          if (0 <= concentration)
          {
            if (maxConcentration < concentration)
            {
              maxConcentration = concentration;
              maxWater = water;
              maxSugar = sugar;
            }
          }
        }
      }
    }
  }

  std::cout << maxWater + maxSugar << " " << maxSugar << endl;
}


Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))

four_divisible = 0
odd = 0
for e in a:
    if e % 2 != 0:
        odd += 1
    elif e % 4 == 0:
        four_divisible += 1
    
if odd > four_divisible:
    if odd == four_divisible + 1 and odd + four_divisible == N:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Measured memory_bytes: 14252
// Created by sz
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;

const int N = 1e5 + 5, mod = 1e9+7;
int cnt[26];


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin>>n>>s;
    
    s = "#"+s;
    ll ans = 1;
    for (int i = 1; i <= n; i++){
        cnt[s[i] - 'a'] ++;
    }
    
    for (int i = 0; i < 26; i++){
        ans = (ans * ((1+cnt[i])%mod))%mod;
    }
    
    ans = (ans-1+mod)%mod;
    cout<<ans<<endl;
    
    return 0;
}


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

int main() {
    vector<int> towns;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) towns.push_back(0);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        towns[a - 1]++, towns[b - 1]++;
    }
    for(int i = 0; i < n; i++) {
        printf("%d\n", towns[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
//inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main()
{
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,k-n%k)<<endl;
	return 0;
}
///////////////////////////

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

int main(){
    int x;
    cin>>x;
    int tmp;
    int ans=1;
    for(int i=2; i<=x; i++){
        int power=i*i;
        for(int p=2;;p++) {
            if(power > x)break;
            ans = max(ans, power);
            power *= i; 
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.cstream;
import std.stdio;
import std.string;
import std.algorithm;
 
void main(){
 
string inc=readln();
/+inc = chomp(inc);/+ /+改/+行+/を/+と+/る+/ +/ +/
 
int[string] mostLongestHash;
int[string] frequent;
int first,ansLength,ansFrequent;
 
 
  for(int i/+ use 0 as default +/;i<inc.length;i++){
    if(inc[i] == ' ' || i == inc.length-1){
     mostLongestHash[inc[first..i]]=cast(int)inc[first..i].length;
     ansLength = max(cast(int)inc[first..i].length,ansLength);
     ansFrequent = max(++frequent[inc[first..i]],ansFrequent);
    /+
     writeln(inc[first..i]);
     writeln(mostLongestHash[inc[first..i]]);
     writeln(frequent[inc[first..i]]);
     writeln(ansLength);
     writeln(ansFrequent);
    +/
     first=i+1;
    }
  }
 
  //writeln(mostLongestHash.values);
 
first=0;
  for(int i=0;i<inc.length;i++){
    if(inc[i] == ' ' || i == inc.length-1){
      if(frequent[inc[first..i]] == ansFrequent){
      write(inc[first..i]);
      write(" ");
      break;
      }
      first=i+1;
    }
  }
 
first=0;
  for(int i=0;i<inc.length;i++){
    if(inc[i] == ' ' || i == inc.length-1){
      if(mostLongestHash[inc[first..i]] == ansLength){
      writeln(inc[first..i]);
      break;
      }
      first=i+1;
    }
  }
 
 
 
}

Measured memory_bytes: 1164
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

  int p[100000];
  int q[100000];
  int r[100000];
  for (int i = 0; i < a; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> q[i];
  }
  for (int i = 0; i < c; i++) {
    cin >> r[i];
  }

  sort(p, p+a);
  reverse(p, p+a);
  sort(q, q+b);
  reverse(q, q+b);

  vector<int> list;
  for (int i = 0; i < x; i++) {
    list.push_back(p[i]);
  }
  for (int i = 0; i < y; i++) {
    list.push_back(q[i]);
  }
  for (int i = 0; i < c; i++) {
    list.push_back(r[i]);
  }

  sort(list.begin(), list.end());
  reverse(list.begin(), list.end());

  long long ans = 0;
  for (int i = 0; i < x+y; i++) {
    ans += list[i];
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
using namespace std;
int k, a, b, flag = 1;
int main()
{
	scanf("%d%d%d", &k, &a, &b);
	for(int i = a; i <= b; i++)
	{
		if(i%k == 0) 
		{
			printf("OK");
			flag = 0;
			break;
		}
	}
	if(flag) printf("NG");
	return 0;
}

Measured memory_bytes: 3784
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


a, b = LI()
ans = 'Even' if a * b % 2 == 0 else 'Odd'
print(ans)


Measured memory_bytes: 61920
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    ll X;
    cin>>X;
    ll a=X/500;
    ll b=(X-500*a)/5;
    cout<<1000*a+5*b<<endl;
    return 0;
}

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

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    
    cin >> n;
    
    int ans = 0;
    
    for(int i = 1; i <= 110; ++i)
    {
        for(int k = 2; k <= 12; ++k)
        {
            int a = pow(i, k);
            
            if(n < a)
            {
                break;
            }
            
            ans = max(ans, a);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
H = list(map(int, input().split()))
max_h = 0
count = 0

for h in H:
    if h >= max_h:
        max_h = h
        count += 1
print(count)

#H_max = np.amax(H)
#H_max_index = np.argmax(H)


Measured memory_bytes: 12488
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <list>
#include <vector>
using namespace std;

bool is_finish(list<int> t){
  int a = 0;
  for(list<int>::iterator it = t.begin() ; it != t.end() ; it++){
    if(*it != ++a) return false;
  }
  return true;
}

int main(){
  int n;
  list<int> block;
  while(cin >> n, n){
    int a;
    for(int i = 0 ; i < n ; i++){
      cin >> a;
      block.push_back(a);
    }
    
    int ans = 0;
    while(!is_finish(block)){
      if(ans > 10000) break;
      int cnt = 0;
      
      for(list<int>::iterator it = block.begin() ; it != block.end() ; it++){
	(*(it))--;
	cnt++;
      }
      block.push_back(cnt);
      block.remove(0);
      ans++;
    }
    if(ans > 10000) cout << -1 << endl;
    else cout << ans << endl;
    block.clear();
  }
  return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const ll maxn=1e6+10;
ll f[maxn];
ll C[30][30];

struct node{
	int x,y;
	bool operator < ( node b ) const { return x-y>b.x-b.y; }
}a[maxn];

char s[maxn];



int main()
{
	int n,right=0,left=0,s0=0,s1=0;
	scanf("%d",&n);
	for( int i=1;i<=n;i++ )
	{
		int l=0,r=0;
		scanf("%s",s+1);
		for( int j=1;s[j];j++ )
		{
			if( s[j]=='(' ) l++;
			else 
			{
				if( l ) l--;
				else r++;
			}		
		}
		if( !l && r ) right+=r;
		else if( l && !r ) left+=l;
		else a[i]=(node){l,r};	
		s0+=l,s1+=r;
	}
	if( s0!=s1 ) 
	{
		puts("No"); 
		return 0;
	}
	sort(a+1,a+1+n);
	for( int i=1;i<=n;i++ )
	{
		if( left<a[i].y )
		{
			puts("No");
			return 0;
		} 
		left-=a[i].y-a[i].x;
	}
	if( left!=right ) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<29)

vector<int> v(10);
int G[400][400];

signed main(){

  int n,m,r; cin >> n >> m >> r;
  for(int i = 0; i < r; i++) cin >> v[i];
  fill(G[0],G[400],INF);
  for(int i = 0; i < m; i++){
    int a,b,c; cin >> a >> b >> c;
    a--; b--;
    G[a][b] = G[b][a] = c;
  }

  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
      }
    }
  }

  v.resize(r);
  sort(v.begin(),v.end());
  int ans = INF;
  do{
    int res = 0;
    for(int i = 0; i < v.size()-1; i++){
      res += G[v[i]-1][v[i+1]-1];
    }
    ans = min(ans,res);
  }while(next_permutation(v.begin(),v.end()));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    
    vector<long long> MIN(N, INF);
    vector<long long> MAX(N, -INF);
    
    long long M = A[0];
    for(int i = 0; i < N; i++){
        if(M > A[i] && i != N - 1)M = A[i];
        MIN[i] = M;
    }
    
    M = A[N - 1];
    for(int i = N - 1; i >= 0; i--){
        MAX[i] = M;
        if(M < A[i])M = A[i];
    }
    
    long long ans = -INF;
    for(int i = 1; i < N; i++){
        long long res = MAX[i] - MIN[i];
        if(ans < res)ans = res;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7468
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define deb(X) std::cerr << ">>> deb(" << __LINE__ << \") " << #X << " = " << (X) << std::endl
//#undef deb
//#define deb(X) (void)0
int32_t main()
{
	fast();
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			//int x=i;
			int ans=0;
			for(int x=1;x<=sqrt(i);x++)
			{
				for(int y=1;y<=sqrt(i);y++)
				{
					if(4*i-3*x*x-3*y*y-2*x*y>=0)
					{
						
						long double z=(long double)sqrt(4*i-3*x*x-3*y*y-2*x*y);
						if(z-(int)z==0)
						{
							int e=abs(z-x-y);
							int r=e/2;
							if(e%2==0 && e/2!=0&& x*x+y*y+r*r+x*y+y*r+r*x==i)
							{
			//					cout<<i<<" "<<x<<" "<<y<<" "<<e/2<<endl;
								ans++;
							}
						}
					}
				}
			}
			cout<<ans<<"\n";
		}
	}
}







Measured memory_bytes: 3532
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = 0;

	void doIt() {
		int n = sc.nextInt();
		int cur = 0;
		for(int i = 0; i < n; i++) {
			if(sc.nextInt() == cur + 1)cur++;
		}
		if(cur == 0)System.out.println(-1);
		else System.out.println(n - cur);
	}

	long gcd(long a, long b) {
		return (b != 0) ? gcd(b, a % b) : a;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
	
}


Measured memory_bytes: 62796
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N;
  cin>>N;
  vector<int> city(N+1),brave(N);
  rep(i,N+1)cin>>city[i];
  rep(i,N)cin>>brave[i];
  int ans=0;
  rep(i,N){
    if(city[i]>=brave[i]){
      ans+=brave[i];
      continue;
    }
    else if(brave[i]<city[i]+city[i+1]){
      ans+=brave[i];
      city[i+1]-=brave[i]-city[i];
    }
    else{
      ans+=city[i]+city[i+1];
      city[i+1]=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int h, w;
    while (true)
    {
        cin >> h >> w;
        if (h + w == 0)
        {
            break;
        }

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cout << '#';
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(a, b, c);
    if (a == b && a != c) cout << "Yes" << endl;
    else if (b == c && b != a) cout << "Yes" << endl;
    else if (c == a && c != b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main() {
	string s,t;
	cin >> s >> t;
	int trans[26][26];
	rep(i,26) rep(j,26) trans[i][j] = 0;
	int n = s.size();
	rep(i,n) {
		int from = s[i] - 'a';
		int to = t[i] - 'a';
		trans[from][to] = 1;
		//trans[to][from] = 1;
	}
	bool fl_trans = true;
	rep(i,26) {
		int cnt = 0;
		rep(j,26) cnt += trans[i][j];
		if (cnt >= 2) fl_trans = false;
	}
	rep(i,26) {
		int cnt = 0;
		rep(j,26) cnt += trans[j][i];
		if (cnt >= 2) fl_trans = false;
	}
	
	if (fl_trans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

int main(){
  int n;
  float m;
  cin >> n >> m;
  vector<float> a(n);
  float total = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    total += a[i];
  }
  float jud = total/(4*m);
  int count = n;
  for(int i=0;i<n;i++){
    if(a[i]<jud){
      count--;
    }
  }
  if(count>=m){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

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

    cout << 3 * r * r << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int n;
ll a, b;
vector<ll> vc;

bool check(ll t) {
  ll cnt = 0;
  REP(i, n) {
    if (vc[i] > b * t) {
      cnt += (vc[i] - b * t + a - b - 1) / (a - b);
    }
  }
  return cnt <= t;
}

int main() {
  cin >> n >> a >> b;
  REP(i, n) {
    ll h;
    cin >> h;
    vc.push_back(h);
  }
  ll ok = 1e9, ng = 0;
  while (1 < abs(ok - ng)) {
    ll mid = (ok + ng) / 2;
    if (check(mid))
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
  return 0;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int k;
	cin >> k;
	int ans = 0;

	rep(i,k)rep(j,k)
	{
		if(i%2 == 0 && j%2 == 1) ans++;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

// ax+by=gcd(a,b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a;
  x = 1; y = 0;
  if (b) {
    g = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  }
  return g;
}
 
ll invMod(ll a, ll p) {
  ll x, y;
  if (extgcd(a,p,x,y) == 1) return (x+p)%p;
  return 0;
}


string s;
int mod;

int term(int &i);
int fact(int &i);

int exp(int &i) {
  int p = term(i);
  while(s[i]=='+' || s[i]=='-') {
    if (s[i++] == '+') (p += term(i)) %= mod;
    else (p = p-term(i)+mod) %= mod;
  }
  return p;
}

int term(int &i) {
  int p = fact(i);
  while(s[i]=='*' || s[i]=='/') {
    if (s[i++] == '*') (p *= fact(i)) %= mod;
    else {
      int tmp = fact(i);
      if (tmp == 0) throw 0;
      (p *= invMod(tmp,mod)) %= mod;
    }
  }
  return p;
}

int fact(int &i) {
  if (s[i] == '(') {
    i++;
    int p = exp(i);
    assert(s[i++]==')');
    return p;
  } else {
    int num = 0;
    while(isdigit(s[i])) {
      num *= 10;
      num += s[i]-'0';
      i++;
    }
    return num;
  }
}

int main() {
  string line;
  while(getline(cin,line),line!="0:") {
    int colon = line.find(':');
    mod = atoi(line.substr(0,colon).c_str());
    line = line.substr(colon+1);
    s = "";
    FOR(it, line) if (*it!=' ') s+=*it;
    int id = 0;
    try {
      int res = exp(id);
      cout << s << " = " << res << " (mod " << mod << ")" << endl;      
    } catch (int i) {
      puts("NG");
    }

  } 
}

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

using namespace std;
#define ll long long

const int N = 1e5 + 5;
ll INF = 998244353;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin>>n>>k;

    vector<int> arr(n);

    for(int i=0;i<n;i++)
        cin>>arr[i];


    unordered_map<int,vector<int>> hmap;
    vector<int> dp(n,0);

    int maxlen = 1;
    dp[n-1] = 1;
    hmap[1].push_back(arr[n-1]);

    for(int i = n-2; i>=0; i--)
    {
        int len = 0;
        bool flag = false;
        for(int j = maxlen; j>0;j--)
        {
            for(auto it:hmap[j])
            {
                if(abs(it - arr[i]) <= k)
                {
                    len = j;
                    flag = true;
                    break;
                }
            }
            if(flag)
                break;
        }

        dp[i] = 1 + len;
        maxlen = max(maxlen, dp[i]);
        hmap[1 + len].push_back(arr[i]);
    }

    cout<<maxlen<<endl;

}


Measured memory_bytes: 32920
#include <cstdio>

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

int next[70][200008];
int main() {
  int N;
  ll K;
  scanf("%d%lld", &N, &K);
  rep(i, N) {
    scanf("%d", &next[0][i]);
    next[0][i]--;
  }
  rep(j, 69) {
    rep(i, N) {
      next[j+1][i]=next[j][next[j][i]];
    }
  }
  int cur = 0;
  rep(j, 70) {
    if(K%2) cur = next[j][cur];
    K/=2;
  }
  printf("%d\n", cur + 1);
  return 0;
}


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

#define ivec vector<int>
#define dvec vector<double>

int main(){
    int N, T, L, B;
    while(true){
        scanf("%d%d%d%d", &N, &T, &L, &B);
        if((N|T|L|B) == 0) break;
        ivec lose(N + 1, 0);
        ivec back(N + 1, 0);
        for(int i = 0; i < L; i++){
            int a;
            scanf("%d", &a);
            lose[a] = 1;
        }
        for(int i = 0; i < B; i++){
            int a;
            scanf("%d", &a);
            back[a] = 1;
        }
        vector< dvec > dp(T + 1, dvec(N + 1, 0));
        dp[0][0] = 1;
        for(int i = 0; i < T; i++){
            for(int j = 0; j < N; j++){
                for(int s = 1; s <= 6; s++){
                    int nxt = j + s;
                    if(j + s > N){
                        nxt = N - (j + s - N);
                    }
                    if(lose[nxt]){
                        if(i > T - 2) continue;
                        dp[i + 2][nxt] += dp[i][j] / 6;
                    }else if(back[nxt]){
                        dp[i + 1][0] += dp[i][j] / 6;
                    }else{
                        dp[i + 1][nxt] += dp[i][j] / 6;
                    }
                }
            }
            dp[i + 1][N] += dp[i][N];
        }
        printf("%.12f\n", dp[T][N]);
    }
    
    return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
using ll = long long;
using namespace std;
const int INF = 1e9;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main() {

    ll A, B;
    cin >> A >> B;

    ll g = gcd(A, B), ans = 0;

    cout << prime_factor(g).size() + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<P> C;
    rep(i,N) cin>>A[i]>>B[i],C.emplace_back(A[i]+B[i],i);;
    ll ans=0;
    sort(ALL(C),greater<P>());
    rep(i,N){
        if(i%2==0){
            ans+=A[C[i].second];
        }
        else{
            ans-=B[C[i].second];
        }
    }
    cout<< ans <<"\n";



}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 4084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

string s;

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> s;
	for( int i = 1; i <= s.length(); ++i )
	{
		if( ( ( i & 1 ) && ( s[ i - 1 ] == 'L' ) ) || ( !( i & 1 ) && ( s[ i - 1 ] == 'R' ) ) )
		{
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << "\n";
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = IOUtils.ReadLongs();
            var cnt1 = nums[0];
            var cnt0 = nums[1];
            var cnt_1 = nums[2];
            var takeCount = nums[3];

            var rest = takeCount;
            var sum = 0L;
            if (takeCount <= cnt1)
            {
                System.Console.WriteLine(takeCount);
                return;
            }
            rest = takeCount - cnt1;
            sum = cnt1;

            if (rest <= cnt0)
            {
                System.Console.WriteLine(sum);
                return;
            }
            rest = rest - cnt0;

            sum = sum - rest;
            System.Console.WriteLine(sum);

        }
    }
    
    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 28244
#include <iostream>
#define N 50
using namespace std;

int dx[N];
int dy[N];

main(){
  int n;
  int count=0;
  while(1){
    cin >> n;
    if(n==0) break;
    count++;

    for(int i=0;i<n;i++){
      cin >> dx[i] >> dy[i];
    }

    double sum=0;
    for(int i=0;i<n-1;i++){
      sum+=dx[i]*dy[i+1]-dy[i]*dx[i+1];
    }
    sum+=dx[n-1]*dy[0]-dy[n-1]*dx[0];
    sum/=2.0;
    if(sum<0) sum*=-1;
    printf("%d %.1f\n", count, sum);
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


    class ClassMain    {

        public static void Main(String[] args){
            //Console.WriteLine("Hello World!");
            while(true){
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break ; }
                for(int i=0; i<n; i++){
                    int[] scores = new int[3];
                    scores = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    Console.WriteLine(evalClass(scores[0],scores[1],scores[2]));



                }
            }


        }

        public static String evalClass(int pm, int pe, int pj) {
            if (pm == 100 || pe == 100 | pj == 100) {
                return "A";
            }
            if (pm + pe >= 180) {
                return "A";
            }
            if (pm + pe + pj >= 240) {
                return "A";
            }
            if (pm + pe + pj >= 210) {
                return "B";
            }
            if (pm + pe + pj >= 150 && (pm>=80 || pe>=80)) {
                return "B";
            }
            return "C";
        }

    }

Measured memory_bytes: 5852
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String si[] = new String[n];
		String qi[] = new String[n];
		String ri[] = new String[n];
		int i;
		int pi[] = new int[n];
		int aa, ab, wa;
		String w;

		for (i = 0; i < n; i++) {
			si[i] = s.next();
			pi[i] = s.nextInt();
			qi[i] = si[i] + pi[i];
			ri[i] = qi[i];
		}

		Arrays.sort(qi);
		Arrays.sort(si);

		for (int m = 0; m < qi.length - 1; m++) {
			for (int j = 0; j < qi.length - 1; j++) {

				if (si[j].equals(si[j + 1])) {//文字だけの比較
					aa = Integer.parseInt(qi[j].replaceAll("[^0-9]", ""));//数値だけの比較
					ab = Integer.parseInt(qi[j + 1].replaceAll("[^0-9]", ""));
					if (aa < ab) {
						w = qi[j];
						qi[j] = qi[j + 1];
						qi[j + 1] = w;

						w = si[j];
						si[j] = si[j + 1];
						si[j + 1] = w;
					}
				}
			}
		}

		for (int l = 0; l < qi.length; l++)
			for (int k = 0; k < qi.length; k++) {
				if (ri[k].equals(qi[l])) {
					System.out.println(k + 1);
				}
			}
	}
}


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

int main(){
 double a,b,x;
  cin>>a>>b>>x;
  double ta=2*(-x/(a*a*a)+b/a);
  if(ta<=b/a) {
    printf("%.10lf\n",atan(ta)/(2*3.141592653589)*360.0);
    return 0;
  }
  ta=a*b*b/(2*x);
  printf("%.10lf\n",atan(ta)/(2*3.141592653589)*360.0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){

		ini(x);
		ini(x1);
		ini(morty);
		int tmp = 0;
		if(x%morty == 0){
			tmp++;
			int tmp1 = x1-x;
			if(tmp1/morty){
				tmp+=tmp1/morty;
			}
			out(tmp);
		}
		else{
			x  = morty*((x/morty)+1);
			if(x1<x){
				out(0);
				return;
			}
			else{
				tmp+=1;
				int tmp1 = x1-x;
				if(tmp1/morty){
				tmp+=tmp1/morty;
				}
				out(tmp);
			}
		}
	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
#define f first
#define s second
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int INF = 1 << 30;
int n, m, k;
vector<P> road[3001];
int shop[3001], dis[3001], from[3001], save[3001][3001];
queue<PP> que;
int main(){
	cin >> n >> m >> k;
	for (int i = 0; i<m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		road[a].push_back(P(b, c));
		road[b].push_back(P(a, c));
	}
	for (int i = 0; i<k; i++)
		cin >> shop[i];
	fill(dis, dis + 3001, INF);
	for (int i = 0; i<k; i++){
		for (int j = 0; j<road[shop[i]].size(); j++){
			que.push(make_pair(make_pair(shop[i], road[shop[i]][j].f), road[shop[i]][j].s));
			dis[shop[i]] = 0;
			dis[road[shop[i]][j].f] = min(dis[road[shop[i]][j].f], road[shop[i]][j].s);
			from[road[shop[i]][j].f] = shop[i];
		}
	}
	while (!que.empty()){
		PP p = que.front();
		que.pop();
		for (int i = 0; i<road[p.f.s].size(); i++){
			if (dis[road[p.f.s][i].f]>p.s + road[p.f.s][i].s){
				que.push(make_pair(make_pair(p.f.s, road[p.f.s][i].f), p.s + road[p.f.s][i].s));
				dis[road[p.f.s][i].f] = p.s + road[p.f.s][i].s;
				from[road[p.f.s][i].f] = p.f.s;
			}
		}
	}
	double ans = 0;
	for (int i = 0; i<3001; i++)
		fill(save[i], save[i] + 3001, INF);
	for (int i = 1; i <= n; i++){
		if (dis[i] != INF){
			for (int j = 0; j<road[i].size(); j++){
				double a = double(road[i][j].s + dis[i]+dis[road[i][j].f]) / 2;
				if (a>ans && save[i][road[i][j].f]>a + dis[i]){
					ans = a;
					save[i][road[i][j].f] = ans;
				}
					save[i][road[i][j].f] = a;
			}
		}
	}
	int ans2;
	ans += 0.5;
	ans2 = int(ans);
	cout << ans2 << endl;
}

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

#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return -INF;
}

int v;
bool f(int x) {
    return x < v;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    segtree<int, op, e> seg(a);
    int t, x, l, r;
    rep(i, q) {
        cin >> t;
        if (t == 1) {
            cin >> x >> v;
            x--;
            seg.set(x, v);
        } else if (t == 2) {
            cin >> l >> r;
            l--;
            cout << seg.prod(l, r) << endl;
        } else {
            cin >> x >> v;
            x--;
            cout << seg.max_right<f>(x) + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6116
import numpy as np


# 約数の列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


N, K, *A = map(int, open(0).read().split())

A = np.array(A, np.int64)
d = make_divisors(A.sum())

for i in d[::-1]:
    r = A % i
    r.sort()
    r = r[r != 0]
    if r.size == 0:
        print(i)
        exit()
    else:
        n = np.arange(r.size - 1, 0, -1)

    np.cumsum(r, out=r)
    equal = np.where(r[:-1] == i * n - (r[-1] - r[:-1]))[0]
    if np.any(r[equal] <= K):
        print(i)
        exit()

Measured memory_bytes: 12816
//
//  main.cpp
//  Biscuits
//
//  Created by Uttam Datta on 04/06/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

vector <long long int> A;
long long int N;
bool odd = false;
long long int p;

long long int ans(){
    if(p == 0 && odd == false){
        return pow(2,N);
    }
    else if(p == 1 && odd == false){
        return 0;
    }
    
    if(odd){
        return pow(2, N-1);
    }
    return 0;
}



int main(){
    
    cin >> N >> p;
    A.clear();
    A.resize(N);
    for(long long int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i]%2 == 1){
            odd = true;
        }
    }
    cout << ans() << endl;
    return 0;
}



Measured memory_bytes: 256