akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(void){
  int LM,LT,LP,LR;
  int m, t, p, jg;
  int accept[55][15], wrong[55][15];
  int times[55], que[55], used[55];
  int i, j, k, min, flag, maxque;

  while(true){
    scanf("%d%d%d%d", &LM, &LT, &LP, &LR);
    if(LM + LM + LP + LR == 0){ break; }

    // テ・ツ按敕ヲツ慊淌・ツ個?
    for(i = 0; i < 55; i++){
      times[i] = que[i] = used[i] = 0;
      for(j = 0; j < 15; j++){
	wrong[i][j] = 0;
      }
    }
    maxque = 0;

    // テ・ツ青?・ツ?・テ・ツ環崚」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
    for(i = 0; i < LR; i++){
      scanf("%d%d%d%d", &m, &t, &p, &jg);
      // ifテヲツュツ」ティツァツ」
      if(jg == 0){
	times[t] += m + 20 * wrong[t][p];
	que[t]++;
	if(maxque < que[t]){ maxque = que[t]; }
      }
      // ifテ、ツクツ催ヲツュツ」ティツァツ」
      else{ wrong[t][p]++; }
    }

    // テ・ツ青?・ツ閉湘ゥツ。ツ古ヲツ閉ーテ」ツ?ョテ、ツクツュテ」ツ?ァ
    for(i = maxque; i >= 0; i--){


      for(j = 1; j <= LT; j++){

	min = 1000000;

	// テヲツ慊?ゥツ?淌」ツつ津ヲツアツづ」ツつ?」ツつ?
	for(k = 1; k <= LT; k++){
	  if(que[k] == i && used[k] == 0 && min > times[k]){
	    min = times[k];
	  }

	}

	if(min == 1000000){ break; }

	// テ・ツ?コテ・ツ環?
	flag = 0;

	for(k = LT; k >= 1; k--){


	  if(times[k] == min && que[k] == i){
	    if(flag != 0) printf("=");
	    else if(i != maxque || j != 1) printf(",");

	    printf("%d", k);
	    flag = 1;
	    used[k] = 1;
	  }
	}



      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1036
function main(){
	var n = scan();
	var x = [];
	rep(n, function(i){
		x[i] = [];
		rep(n, function(j){
			x[i][j] = scan();
		});
	});

	rep(n, function(i){
		x[i][-1] = 0;
		rep(n, function(j){
			x[i][j] += x[i][j - 1];
		});
	});

	var ans = -Infinity;
	rep(-1, n - 1, function(i){
		rep(i + 1, n, function(j){
			var y = [];
			rep(n, function(k){
				y[k] = x[k][j] - x[k][i];
			});
			var dp = [y[0]];
			rep(1, n, function(k){
				dp[k] = Math.max(dp[k - 1] + y[k], y[k]);
			});
			ans = Math.max(ans, Math.max.apply(null, dp));
		});
	});
	print(ans);
}
 
function rep(a, b, c){
	if(c == null){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		c(i);
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

Measured memory_bytes: 20732
import sys
f = sys.stdin


vlines = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

for line in f:
    result = 'd'
    for v in vlines:
        if 's' !=  line[v[0]] and line[v[0]]== line[v[1]] == line[v[2]]:
            result = line[v[0]]
            break
    print(result)
    

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int cnt[301],cur[301];
int a[301][301];
bool used[301];
int main(){
    int n,m,ai;
    cin>>n>>m;
    rep(i,n)rep(j,m){
        cin>>ai;
        --ai;
        a[i][j]=ai;
    }
    int mn=1000100010;
    rep(i,m){
        memset(cnt,0,sizeof(cnt));
        rep(j,n) ++cnt[a[j][cur[j]]];
        int c=max_element(cnt,cnt+m)-cnt;
        used[c]=true;
        rep(j,n){
            while(cur[j]!=m&&used[a[j][cur[j]]]) ++cur[j];
        }
        mn=min(mn,cnt[c]);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

int N;
vector< vector<double> > dis;

double calc_length(vector<int>& perm) {
	double res = 0;
	for (int i = 0; i < N-1; ++i) {
		res += dis[perm[i]][perm[i+1]];
	}
	return res;
}

int main(void) {
	cin >> N;
	vector< complex<double> > point(N);
	double real,imag;
	vector<int> perm(N);
	for (int i = 0; i < N; ++i) {
		cin >> real >> imag;
		point[i] = {real,imag};
		perm[i] = i;
	}
	dis = vector< vector<double> >(N,vector<double>(N,0));
	for (int i = 0; i < N-1; ++i) {
		for (int j = i+1; j < N; ++j) {
			dis[i][j] = dis[j][i] = abs(point[i]-point[j]);
		}
	}
	int nop = 0;
	double res = 0;
	do {
		res += calc_length(perm);
		++nop;
	} while (next_permutation(perm.begin(),perm.end()));
	cout << setprecision(20) << (double)res/nop << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

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


  string S;
  cin>>S;
  if(S.size()%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  bool isOK=true;
  for(int i=0;i<S.size();i++){
    if(i%2==0&&S[i]!='h'){
      isOK=false;
    }
    if(i%2==1&&S[i]!='i'){
      isOK=false;
    }
      
  }
  if(isOK){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
        
  
  
  
  
  
}




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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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


int n;
ll ans,r,g,b;
string s;

int main(){
  cin>>n>>s;
  for(char c:s){
    if(c=='R')r++;
    if(c=='G')g++;
    if(c=='B')b++;
  }
  ans=r*g*b;
  rep(i,n){
    for(int j=1;i+j+j<n;j++){
      if((s[i]^s[i+j]^s[i+j+j])==('R'^'G'^'B'))ans--;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
      cin>>n;
      n*=n;
      cout<<n;
    }
    return 0ll;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int A = 100001;
int main() {
  int n;
  cin >> n;
  vector<int> v(A);
  int m = 0;
  rep(i,n){
    int a;
    cin >> a;
    v[a]++;
    if(v[a]>1) ++m;
  }
  int ans = n-(m+1)/2*2;
  cout << ans << endl;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef long long LL;
LL n,x;
LL work(LL l1,LL l2) {
	if(!l2) return -l1;
	return work(l2,l1%l2)+2*(l1/l2)*l2;
}
int main()
{
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",work(x,n-x)+n);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,H;
    cin >> N >> H;
    vector<int> A(N),B(N);
    int Amax = 0,Bmin = INF;
    for(int i = 0;i < N;i++){
        cin >> A[i] >> B[i];
        Amax = max(Amax, A[i]);
        Bmin = min(Bmin, B[i]);
    }
    sort(A.begin(),A.end(),greater<int>());
    sort(B.begin(),B.end(),greater<int>());
    int cnt = 0;
    for(int i = 0;i < N && B[i] >= Amax && H > 0;i++,cnt++){
        H -= B[i];
    }
    if(H > 0)cnt += (H + A[0] - 1)/A[0];
    cout << cnt << endl;
}

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

int main() {
  int n;
  cin >> n;
  int fct=1;
  for (int i=0;i<n;i++) fct *= i+1;
  int p[n],q[n];
  vector<int> v(n);
  for (int i=0;i<n;i++) cin >> p[i];
  for (int i=0;i<n;i++) cin >> q[i];
  for (int i=0;i<n;i++) v[i] = i+1;
  vector<int> w[fct+1];
  int idx=1;
  do {
    for (int x : v) {
      w[idx].push_back(x);
    }
    idx++;
  } while (next_permutation(v.begin(), v.end()));
  int a,b;
  for (int i=1;i<fct+1;i++){
    int flg=0;
    for (int j=0;j<n;j++){
      if (w[i][j] != p[j]){
        flg=1;break;
      }
    }
    if (flg) continue;
    a = i;
  }
  for (int i=1;i<fct+1;i++){
    int flg=0;
    for (int j=0;j<n;j++){
      if (w[i][j] != q[j]){
        flg=1;break;
      }
    }
    if (flg) continue;
    b = i;
  }
  cout << (a-b>=0 ? a-b : b-a) << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod =1e9+7;
#define MAX 1000005
ll f[MAX];
ll iv[MAX];
ll poer(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void in_it(){
	f[0]=1;
	iv[0]=1;
	for(int i=1;i<MAX;++i) f[i]=(f[i-1]*i)%mod;
	iv[MAX-1]=poer(f[MAX-1],mod-2);
	for(int i=MAX-2;i>=0;--i) iv[i]=(iv[i+1]*(i+1))%mod;
}
ll C(ll n, ll r){
	if(n<r) return 0;
	ll ans=(f[n]%mod*iv[r]%mod)%mod;
	ans =(ans*iv[n-r]%mod)%mod;
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
	in_it();
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
	ll ans=0;
	for(int i=b;i<w;++i){
		ll x1=i;
		ll y1=h-a-1;
		ll term1=C(x1+y1,x1);
		ll x2=w-1-i;
		ll y2=a-1;
		ll term2=C(x2+y2,y2);
		term1%=mod;
		term2%=mod;
		ans=(ans+(term1*term2)%mod)%mod;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 19264
//
// Created by yamunaku on 2019/09/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    int a,b,c;
    cin >> a >> b >> c;
    vi l(n);
    rep(i,n){
        cin >> l[i];
    }
    int ans=IINF;
    rep(i,1<<(2*n)){
        int x=0,y=0,z=0;
        int tmp=-30+10*n;
        rep(j,n){
            int k=(i&(3<<(2*j)))>>(2*j);
            if(k==0){
                x+=l[j];
            }else if(k==1){
                y+=l[j];
            }else if(k==2){
                z+=l[j];
            }else{
                tmp-=10;
            }
        }
        if(x==0||y==0||z==0) continue;
        ans=min(ans,tmp+abs(x-a)+abs(y-b)+abs(z-c));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	map<char, int> x;
	map<char, int> y;
	int max=0;
	for(int i=1; i<n; i++)
	{
		for(int j=0; j<i; j++)
		{
			x[s[j]]++;
		}
		for(int j=i; j<n; j++)
		{
			y[s[j]]++;
		}
		int cnt = 0;
		for(map<char, int> :: iterator it1 = x.begin(); it1!=x.end(); it1++)
		{
			for(map<char, int> :: iterator it2 = y.begin(); it2!=y.end(); it2++)
			{
				if(it1->first == it2->first)
					cnt++;
			}
		}
		if(cnt> max)
			max = cnt;
		x.clear();
		y.clear();
	}
	cout<<max;

	return 0;
}

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

using namespace std;

long n, a, b;
long ans = 0;

int main(int argc, char const *argv[])
{
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0)
    { //2人のテーブルが奇数個離れている
        ans = (b - a) / 2;
    }
    else if ((b - a) % 2 == 1)
    {
        ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
    }

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


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

#define str(a) to_string(a)
#define int long long
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define MOD 998244353

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







int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;

}












Measured memory_bytes: 3652
#include <stdio.h>
#define N 10000

int LinerSearch(int S[],int n,int flag){
  int i=0;
  S[n]=flag;
  while(S[i]!=flag)i++;
  return i!=n;
}

int main(){
  int i,n,q,S[N],sum=0,flag;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&flag);
    if(LinerSearch(S,n,flag)!=0)sum++;
  }
  printf("%d\n",sum);

  return 0;
}
  



Measured memory_bytes: 2144
// きりみんちゃんの配信からきました
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(max(a*b, max(a+b, a-b)))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

bool = True
cnt=a[0]
for i in range(len(a)-1):
    if a[i+1] != cnt:
        bool = False
if bool == True:
    print("0")
    exit()

def num_place(num,a):
    for i in range(len(a)):
        if num == a[i]:
            x = i
    return x

cnt_list=[]
max=max(a)
min=min(a)
if max >= abs(min):
    cnt_list.append([num_place(max,a),0])
    a[0] += max

    for i in range(len(a)-1):
        if a[i] > a[i+1]:
            a[i+1] += a[i]
            cnt_list.append([i,i+1])
        if a[i] > a[i+1]:
            a[i+1] += a[i]
            cnt_list.append([i,i+1])
else:
    cnt_list.append([num_place(min,a),N-1])
    a[N-1] += min
    for i in range(len(a)-1,0,-1):
        if a[i] < a[i-1]:
            a[i-1] += a[i]
            cnt_list.append([i,i-1])
        if a[i] < a[i-1]:
            a[i-1] += a[i]
            cnt_list.append([i,i-1])

print(len(cnt_list))
for i in  cnt_list:
    print("{} {}".format(i[0]+1,i[1]+1))

Measured memory_bytes: 3188
import math
a, b = map(int,input().split())
e = 10**-7
mi = max(math.ceil(a*12.5),b*10)
ma = min(int(math.ceil((a+1)*12.5)-1),(b+1)*10-1)
if mi > ma:
    print(-1)
else:
    print(mi)


Measured memory_bytes: 3060
import sys
imput = sys.stdin.readline
def func(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d
N,M,L = map(int,input().split())
road = [[10**10]*N for i in range(N)]
for i in range(N):
    road[i][i] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c
road = func(road)
ans = [[10**5]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        if road[i][j] <= L:
            ans[i][j] = 1
ans = func(ans)
for i in range(int(input())):
    a,b = map(int,input().split())
    o = ans[a-1][b-1]
    if o == 10**5:
        print(-1)
    else:
        print(o-1)
    


Measured memory_bytes: 59504
S,leg = [int(i) for i in input().split()]
#2x + 4(S-x) = leg
#2x + 4S - 4x - leg = 0
#2x = 4S-leg
x = (4*S-leg)/2
if x-int(x) == 0 and x>=0 and x <= S:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9096
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int X;
cin >> X;
if(X == 7 || X==5 || X==3){
    cout << "YES" << endl;
}
else{
    cout << "NO" << endl;
}
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    lli n,m;
    cin>>n>>m;
    vinput(a,m);
    lli sum=0;
    rep(i,m,0)sum+=a[i];
    if(sum > n)cout<<-1<<endl;
    else cout<<n - sum <<endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};


int main(void) {
  int a,b;
  cin >> a >> b;
  if(a+b==4)cout<< 2 << endl;
  else if(a+b==3) cout << 3 <<endl;
  else cout << 1 << endl;
  
         
         
  
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int a, b, d, r;
  double f;
  
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = (double)a / b;

  printf("%d %d %.8f\n", d, r, f);

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,p[1000000] = {},t[100] = {},i,ans = 0;scanf("%lld",&n);
  for(i=1;i*(i+1)/2<100;i++) t[i*(i+1)/2] = i;
  for(i=2;i<100;i++){
    if(t[i] == 0) t[i] = t[i-1];
  }
  k = n;
  for(i=2;i*i<=n;i++){
    while(k%i==0){
      k /= i;p[i]++;
    }
  }
  if(k<1000000) p[k]++;
  else ans++;
  for(i=2;i<1000000;i++) ans += t[p[i]];
  printf("%lld\n",ans);
}

Measured memory_bytes: 11640
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100010;
int a[2 * MAXN];

int n, res;

void binSearchHelper(bool topSquare, int& lo, int& hi, int& mid) {
    if (topSquare) {
        res = mid;
        lo = mid + 1;
    }
    else {
        hi = mid - 1;
    }
}

int main() {
    GI(n);

    FOR1(i, 2*n-1) {
        GI(a[i]);
    }

    int lo = 1; int hi = 2*n-1; res = -1;

    while (lo <= hi) {
        int mid = (lo + hi) / 2; // is the answer >= mid?

        if ((a[n] >= mid && a[n-1] >= mid) || (a[n] >= mid && a[n+1] >= mid)) {
            lo = mid + 1; res = mid;
            continue;
        }
        else if ((a[n] < mid && a[n-1] < mid) || (a[n] < mid && a[n+1] < mid)) {
            hi = mid - 1;
            continue;
        }

        int l = n, r = n;

        while (l-1 >= 1 && (a[l] >= mid) != (a[l-1] >= mid)) {
            l--;
        }
        while (r+1 <= 2*n-1 && (a[r] >= mid) != (a[r+1] >= mid)) {
            r++;
        }

        bool bl = (a[l] >= mid);
        bool br = (a[r] >= mid);

        if (l > 1 && r < 2*n-1) {
            if (bl == br) {
                binSearchHelper(bl, lo, hi, mid);
            }
            else if (r - n < n - l) { // r is closer
                binSearchHelper(br, lo, hi, mid);
            }
            else { // l is closer
                binSearchHelper(bl, lo, hi, mid);
            }
        }
        else if (l == 1) {
            binSearchHelper(br, lo, hi, mid);
        }
        else if (r == 2*n-1) {
            binSearchHelper(bl, lo, hi, mid);
        }
        else {
            binSearchHelper(bl, lo, hi, mid);
        }
    }

    printf("%d\n", res);
    
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;

  ll ans = 0;
  REP(i, 2, 10000001) {
    if (N % i == 0) {
      ll n = 0;
      while (N % i == 0) {
        N /= i;
        n++;
      }

      REP(j, 1, 10001) {
        if (n < j) {
          break;
        }
        n -= j;
        ans++;
      }
    }
  }
  if (N != 1) {
    ans++;
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
 
int main(){
  char a[4];
  cin >> a;
  string ans;
  if((a[0]==a[1]&&a[1]==a[2]) || (a[1]==a[2]&&a[2]==a[3])) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int M = 2;

int main() {
  int n;
  cin >> n;
  array<int, 3> a;
  for (auto &e : a) cin >> e;
  vector<string> s(n);
  for (auto &e : s) cin >> e;

  for (auto &e : a) e = min(e, M);

  vector<char> r, t;
  vector<vector<vector<bool>>> v(n, vector<vector<bool>>(3 * M + 1, vector<bool>(3 * M + 1)));
  auto dfs = [&](auto &&dfs, int i) {
    if (i == n) {
      r = t;
      return;
    }
    if (v[i][a[0]][a[1]]) return;
    v[i][a[0]][a[1]] = true;
    for (int k = 0; k < 2; k++) {
      int x = s[i][k] - 'A';
      int y = s[i][1 - k] - 'A';
      if (a[x] <= 0) continue;
      a[x]--;
      a[y]++;
      t.push_back('A' + y);
      dfs(dfs, i + 1);
      t.pop_back();
      a[x]++;
      a[y]--;
    }
  };
  dfs(dfs, 0);

  if (r.empty()) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (auto e : r) cout << e << endl;
  }
}


Measured memory_bytes: 68472
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j] <= x ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

int main() {
  int i, q;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  q = partition(0, n - 1);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == q ) printf("[");
    printf("%d", A[i]);
    if ( i == q ) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll X,Y;
    string S;
    cin >> X >> Y;
    rep(i,101){
        rep(j,101){
            if(i+j == X && 2*i+j*4 == Y){
                cout << "Yes"<<endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){
int ac = 0;int wa = 0;
int re = 0;int tle = 0;
int n;cin >> n;
for(int i = 0; i<n;i++){
string s;
cin >>s;

	if(s == "AC"){
		ac++;
	}
	else if(s == "TLE"){
		tle++;
	}
	else if(s == "WA"){
		wa++;
	}
	else if(s == "RE"){
		re++;
	}
}



cout << "AC x " << ac <<endl;
cout << "WA x " << wa <<endl;
cout << "TLE x " << tle <<endl;
cout << "RE x " << re <<endl;





}
return 0;
}

Measured memory_bytes: 3660
h, w = map(int, input().split())

g = []
for i in range(h):
    g.append(input())

g2 = []
for line in g:
    if '#' in line:
        g2.append(line)

g3 = []
for _ in g2: g3.append([])

for j in range(w):
    if any([g2[i][j] == '#' for i in range(len(g3))]):
        for i in range(len(g3)):
            g3[i].append(g2[i][j])

for line in g3:
    print(''.join(line))

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

using namespace std;

int main(int argc, char const *argv[]) {
	long long n;
	long long y;
	std::cin >> n >> y;

	long long man = 10000;
	long long sen = 1000;
	// 上限値より高い金額
	if (y > n * man) {
		std::cout << "-1 -1 -1" << '\n';
		return 0;
	}
	// 下限値より低い金額
	if (y < n * sen) {
		std::cout << "-1 -1 -1" << '\n';
		return 0;
	}

	// 3段鶴亀
	y = y - sen * n;
	// y円を4000円と9000円で作成できるかを探索すればよい
	// つまり、
	// y = 4000 * p + 9000 * q を探索
	long long p,q;
	p = q = 0;

	p = y / 4000;
	long long r = y - p * 4000;
	p = p - 2 * (r / 1000);
	q = r / 1000;
	// これでとりあえず解が出た

	while (p >= 0) {
		if (p >= 0 && q >= 0 && p + q <= n) {
			std::cout << q << ' ' << p << ' ' << n-p-q << '\n';
			return 0;
		}
		p -= 9;
		q += 4;
	}
	std::cout << "-1 -1 -1" << '\n';

	return 0;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << ln;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll a[n+1]={0},b[m+1]={0};
    for(ll i=1;i<=n;i++)
    {
    	cin>>a[i];
		a[i]+=a[i-1];
	}
    for(ll i=1;i<=m;i++)
    {
    	cin>>b[i];
		b[i]+=b[i-1];
	}
    for(ll i=0;i<=n;i++) if(k>=a[i]) ans=max(ans,upper_bound(b+1,b+1+m,k-a[i])-b-1+i);
    cout<<ans;
}


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

namespace AtCoder.Beginner092
{
    public class ABC092B
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int d = nums[0];
            int x = nums[1];

            int[] a = new int[n+1];
            for(int i = 1; i <= n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            long total = x;
            for(int i = 1; i <= n; i++)
            {
                for(int j = 1; j <= d; j += a[i])
                {
                    total++;
                }
            }

            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 13268
// Problem : B - Popular Vote
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define infl 1e18+5
#define mninfl -1e18-5
#define Mod 1000000007
#define newmod  998244353
int ah=911382323;
int bh=972663749;
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define ct(x,y) cout<<(x)<<" "<<(y)<<endl;
#define nl   cout<<endl
//const long double pi=acos(-1);
//looping
#define int long long
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' ';  cout<<endl
#define pv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";  cout<<endl
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}
#define deb(x) cerr << #x << " = " << x << endl;
#define deb2(x,y)  cerr << #x << " = " << x <<"   "<< #y << " = " << y << endl;
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mkp make_pair
#define all(v) (v).begin(),(v).end()
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef vector < pair <int, int> > vpii;
/*/----------------------------Code begins----------------------------------/*/
int32_t main(){
fio;
int n,m;
cin>>n>>m;
int a[n];
For(i,0,n)
cin>>a[i];
sort(a,a+n);
int sum=accumulate(a,a+n,0);
if(4*m*a[n-m]<sum){
	cout<<"No\n";
}
else cout<<"Yes\n";
}




























Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        string S = ReadLine();
        int w = int.Parse(ReadLine());

        string temp = string.Empty;
        for(int i = 0; i < S.Length; i++)
        {
            if (i % w == 0)
            {
               Write(S[i]);
            }
        }
        ReadLine();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    int n;
    scanf("%d", &n);
    std::vector<int> L(n);
    rep(i, n) scanf("%d", &L[i]);
    sort(begin(L), end(L));
    int ans = 0;
    rep(i, n) repeat(j, i + 1, n) {
        int left = std::distance(begin(L), std::lower_bound(begin(L), end(L), abs(L[i] - L[j])));
        int right = std::distance(begin(L), std::lower_bound(begin(L), end(L), L[i] + L[j]));
        // printf("%d %d\n", left, right);
        ans += std::max(right - j, 0) - std::max(left - j, 0) - 1;
    }
    printf("%d\n", ans);
}

int main() {
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ans = 1;
    int A[N]; rep(i, N) cin >> A[i];
    int state = -1; //減少列か増加列かが未定: -1
    int prev = -1;
    rep(i, N){
        if(i == 0) prev = A[0];
        else{
            if(state == -1){
                if(prev < A[i]){
                    state = 0;
                }
                else if(prev > A[i]){
                    state = 1;
                }
                prev = A[i];
            }
            else if(state == 0){
                //増加
                if(prev > A[i]){
                    ans++;
                    state = -1;
                    prev = A[i];
                }
                else prev = A[i];
            }
            else if(state == 1){
                if(prev < A[i]){
                    ans++;
                    state = -1;
                }
                prev = A[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s) {
		puts("Yes");
	}
	else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x[]={1,3,1,2,1,2,1,1,2,1,2,1};
  int a,b;
  cin >>a>>b;
  if (x[a-1]==x[b-1]) {
    cout <<"Yes"<<endl;
  }
  else {
    cout <<"No"<<endl;
  }
}


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

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> x[0] >> x[1] >> x[2];
    sort(x,x+3);

    for(i=0;i<3;i++){
        if(x[i]!=x[1]) cout << x[i];
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>g[100005];
bool vis[100005];
int tt,c[100005],d[100005];
void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<g[x].size();i++)if(!vis[g[x][i]])dfs(g[x][i]);
	for(int i=0;i<g[x].size();i++)c[i]=d[g[x][i]];
	sort(c,c+g[x].size());
	tt=0;
	for(int i=0;i<g[x].size();i++)tt=max(tt,c[i]+(int)g[x].size()-i-1);
	d[x]=tt+1;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		g[x].push_back(i);
	}
	dfs(1);
	printf("%d\n",d[1]-1);
	return 0;
}

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

const double pi = 3.14159265359;

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double allmin = h*60+m;
    double kakua, kakub, kaku;
    kakua = (h*60+m) / 2;
    kakub = m*6;
    kaku = abs(kakua-kakub);
    kaku = min(kaku, 360-kaku);
    double rad = kaku*pi/180;
    double ans = a*a+b*b;
    ans -= 2*a*b*cos(rad);
    ans = sqrt(ans);
    printf("%.20f\n", ans);
    return 0;
}

Measured memory_bytes: 4164
# -*- coding: utf-8 -*-
# ITP1_9_C
# カードゲーム

tpt = hpt = 0
n = int(input())

for i in range(n):
    taro, hanako = input().split()
    if taro == hanako:
        tpt += 1
        hpt += 1
    elif taro > hanako:
        tpt += 3
    else:
        hpt += 3
        
print(tpt, hpt)



Measured memory_bytes: 5600
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n;cin>>n;
	int a[n+1];
	fo1(i,n){
		cin>>a[i];
	}
	int ans=inf;
	for(int i=1;i<=100;i++){
		int sum=0;
		for(int j=1;j<=n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<=ans){
			ans=sum;
		}
	}
	cout<<ans<<endl;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(ll i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


bool isodd(ll x){
    ll num = 0;
    while(x!=0){
        num++;
        x/=10;
    }
    return (num%2)==1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  ll ans = 0;
  FOR(i,1,n+1){
      if(isodd(i))ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))



using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);

ll A, B, C, X, Y;

vector<pint> query;

ll AB_num[2 * 100005];


int main() {
	
	cin >> A >> B >> C >> X >> Y;

	for (int i = 0; i <= 2 * MAX(X, Y); i++) {
		AB_num[i] += C * i +  A * MAX(0, (X - i / 2)) + B * MAX(0, (Y - i / 2));

	}

	ll ans = inf;
	for (int i = 0; i <= 2 * MAX(X, Y); i++) {
		ans = min(ans, AB_num[i]);

	}


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

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    string T = S.substr(0, (N - 1) / 2), U = S.substr((N + 1) / 2, (N - 1) / 2);
    reverse(U.begin(), U.end());
    if (U != T) {
        cout << "No";
        return 0;
    }
    int M = T.size(), P = U.size();
    string A = T.substr(0, M / 2), B = T.substr((M + 1) / 2, M / 2), C = U.substr(0, P / 2), D = U.substr((P + 1) / 2, P / 2);
    reverse(B.begin(), B.end());
    reverse(D.begin(), D.end());
    if (S.size() == 3 && S.at(0) != S.at(2)) {
        cout << "No";
        return 0;
    }
    //cout << A << endl << B << endl << C << endl << D << endl;
    if (A == B && C == D)cout << "Yes";
    else cout << "No";
    
}

Measured memory_bytes: 256
n=int(input())
l=[]
for _ in range(n):
  l.append(int(input()))
l.sort()
non_0s=[x%10!=0 for x in l]

if not any(non_0s):
  print(0)
  exit()

ans=sum(l)
if ans%10==0:
  for i in range(n):
    if non_0s[i]:
      ans-=l[i]
      break
print(ans)

Measured memory_bytes: 9172
#include <iostream>
#include <string>

int main()
{
    int input;
    std::cin >> input;

    if (0 <= input && input < 1200)
    {
        std::cout << "ABC" << std::endl;
    }
    else if (1200 <= input && input < 2800)
    {
        std::cout << "ARC" << std::endl;
    }
    else if (2800 <= input && input <= 4208)
    {
        std::cout << "AGC" << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >>c;
  if (max({a,b,c})==a+b+c-max({a,b,c})){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

low, high = 0, 0
ans = 0
for i in range(1, N + 2):
    low += i - 1
    high += N - i + 1

    if i >= K:
        ans += (high - low + 1)
        ans %= MOD

print(ans)


Measured memory_bytes: 9176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= in.nextInt();
		long [] a= new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextLong();
		}
		long res= a[0];
		for (int i = 1; i < a.length; i++) {
			long g= gcd(a[i], res);
			a[i]/=g;
			res = (a[i]*res);
		}
		System.out.println(res);

	}
	public static long gcd(long p, long q) {
		if (q == 0) return p;
		else return gcd(q, p % q);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,ans=0;
cin>>n;
int a[n+1],i;
for(i=0;i<n;i++)
    cin>>a[i];
int j,k;
for(i=0;i<n;i++)
{
    for(j=i+1;j<n;j++)
    {

        for(k=j+1;k<n;k++)
        {
            if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]&&a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])
                ans++;
        }
    }

}
cout<<ans<<endl;
}


Measured memory_bytes: 3616
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
typedef long long int64;
using namespace std;
inline int64 read(int f = 1, int64 x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, m, a[N], f[N], s[N], top, vis[N];
int64 ans[N], k;
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    for(int i = n; i; --i) a[i] -= a[i-1], f[i] = i;
    m = read(), k = read();
    for(int i = 1, p; i <= m; ++i) p = read(), swap(f[p], f[p+1]);
    for(int i = 1; i <= n; ++i, top = 0)
        if(!vis[i])
        {
            for(int j = i; !vis[j]; j = f[j]) vis[j] = 1, s[++top] = j;
            for(int j = 1; j <= top; ++j) ans[s[j]] = a[s[(j+k-1)%top+1]];
        }
    for(int i = 1; i <= n; ++i) printf("%lld\n", ans[i] += ans[i-1]);
    return 0;
}

Measured memory_bytes: 3456