akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,K;
string S;
vector<int>v;
vector<int>su;
int main(){
	cin>>N>>K>>S;
	int now=-1;
	int c=0;
	REP(i,N){
		if((S[i]-'0')!=now){
			if(i!=0){
				v.push_back(c);
				c=0;
			}
			now=S[i]-'0';
		}
		c++;
	}
	v.push_back(c);
	REP(i,v.size()){
		if(i==0){
			su.push_back(v[0]);
		}else{
			su.push_back(su[i-1]+v[i]);
		}
	}
	/*if(su.size()<=2*K){
		cout<<N<<endl;
		return 0;
	}*/
	int ans=0;
	c=0;
	/*if(S[i]=='0'){
		ans=su[2*K-1];
		c++;
	}else{
		if(su.size()<=2*K+1){
			ans=N;
		}
	}*/
	/*REP(i,su.size()){
		cout<<su[i]<<endl;
	}*/
	if(S[0]=='0'){
		ans=su[min((int)(su.size()-1),2*K-1)];
		c++;
	}
	while(c<su.size()){
		//cout<<c<<" "<<ans<<endl;
		if(c==0){
			ans=max(ans,su[min((int)(su.size()-1),c+2*K)]);
		}else{
			ans=max(ans,su[min((int)(su.size()-1),c+2*K)]-su[c-1]);
		}
		c+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <iomanip>
#include <typeinfo>
#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll int,ll int>
#define pii             pair<ll int,ll int>
#define vi              vector<ll int>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll int)x.size()
#define hell            1000000007
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (long long int i=a;i<b;i++)
#define repr(i,a,b)     for (long long int i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define bs              binary_search
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/
 
//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    rep(i,0,n){
        cin>>arr[i];
    }
    ll pres=1;
    ll cnt=0;
    rep(i,0,n){
        if (arr[i]==pres){
            cnt++;
            pres++;
        }
    }
    if (cnt==0){
        cout<<-1<<endl;
        return;
    }
    cout<<n-cnt<<endl;
}
 
signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

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

  if (a == b) {
    cout << c << endl;
  } else if(b == c) {
    cout << a << endl;
  }else{
    cout << b << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = 0.5 * (double) h * (double) w;
    cout << ans << " ";
    if ( 2 * x ==  w && 2 * y == h ){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}





















Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int ans = 0, l = 0, r = n - 1;
		while(l < r) {
			if(s.charAt(l) == s.charAt(r)) {
				l++; r--;
			} else {
				if(s.charAt(l) != 'x' && s.charAt(r) != 'x') {
					System.out.println(-1);
					return;
				} else {
					if(s.charAt(l) == 'x') {
						l++;
						ans++;
					}
					if(s.charAt(r) == 'x') {
						r--;
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23908
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

double a, b, x;

int main() {
  cin >> a >> b >> x;
  if(a * a * b >= 2 * x) {
    double ans;
    ans = 360 * atan(a * b * b / (2 * x)) / (M_PI * 2);
    cout << std::fixed << std::setprecision(8) << ans << endl;
    return 0;
  }
  double ans;
  ans = 360 * atan(2 * (a * a * b - x) / (a * a * a)) / (M_PI * 2);
  cout << std::fixed << std::setprecision(8) << ans << endl;
  return 0;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
using namespace std;
int cnt[100009];
bool f[100009];

int main(){
  int n,m;
  cin>>n>>m;
  f[1]=true;
  for(int i=1;i<=n;i++)cnt[i]=1;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    f[y]|=f[x];
    cnt[x]--;
    cnt[y]++;
    if(cnt[x]==0)f[x]=false;
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(cnt[i]>0&&f[i]==true){
      ans++;
    }
  }
  cout<<ans<<endl;
  return(0);
}


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

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

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

Measured memory_bytes: 3656
#include <cassert>
#include <functional>
#include <numeric>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <iostream>
using namespace std;

vector<int> bruteforce(int n, int *a) {
    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 0);
    function <bool()> check = [&]() {
        for (int i = 1; i < n; i++) {
            if (a[ans[i-1]] == ans[i]) return false;
        }
        return true;
    };
    do {
        if (check()) return ans;
    } while (next_permutation(ans.begin(), ans.end()));
    return {};
}

int main() {
    int n; cin >> n;
    if (n == 2) { cout << "-1\n"; return 0; }
    int a[n], in_deg[n];
    fill(in_deg, in_deg+n, 0);
    // vector<int> ainv[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i]; a[i]--;
        in_deg[a[i]]++;
        // ainv[a[i]].push_back(i);
    }
    vector<int> ans;
    set<int> V;
    map<int, int> deg_cnt;
    for (int i = 0; i < n; i++) {
        V.insert(i);
        deg_cnt[in_deg[i]]++;
    }
    int u = -1;
    while (V.size() > 3) {
        while (deg_cnt.rbegin()->second == 0)
            deg_cnt.erase(prev(deg_cnt.end()));
        auto it = [&]() {
            if (deg_cnt.rbegin()->first == V.size() - 1) {
                for (int i = 0; i < n; i++)
                    if (in_deg[i] == V.size() - 1) return V.find(i);
            } else {
                auto it = V.begin();
                return (*it == u) ? next(it) : it;
            }
        }();
        const int v = *it;
        u = a[v];
        if (in_deg[u] > 0) {
            deg_cnt[in_deg[u]]--;
            in_deg[u]--;
            deg_cnt[in_deg[u]]++;
        }
        deg_cnt[in_deg[v]]--;
        in_deg[v] = 0;
        V.erase(it);
        ans.push_back(v);
    }
    for (int u : V) ans.push_back(u);
    do {
        if (n > 3 && a[ans[n-4]] == ans[n-3]) continue;
        if (a[ans[n-3]] == ans[n-2]) continue;
        if (a[ans[n-2]] == ans[n-1]) continue;
        break;
    } while (next_permutation(ans.end()-3, ans.end()));
    for (int x : ans) cout << x+1 << ' '; cout << endl;

    // vector<int> ans2 = bruteforce(n, a);
    // assert (ans2.size() == n);
    // for (int i = 0; i < n; i++) assert(ans[i] == ans2[i]);
}


Measured memory_bytes: 8668
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f

N = int(input())

x = [[] for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        p, q = map(int, input().split())
        x[i].append([p-1, q])

ans = 0
for i in range(0,2**N):
    flag = 1
    for j in range(N):
        if ((i >> j) & 1):
            for xx in x[j]:
                if xx[1] == 1:
                    if not ((i >> xx[0]) & 1):
                        flag = 0
                        break
                else:
                    if ((i >> xx[0]) & 1):
                        flag = 0
                        break

        if flag == 0:
            break

    if flag == 0:
        continue
    else:
        ans = max(ans, popcount(i))

print(ans)






Measured memory_bytes: 79156
from collections import deque
import sys
N,M=map(int,input().split())
table=[[] for i in range(N)]
ans=[]
for i in range(M):
    a,b,c=map(int,input().split())
    table[a-1].append((b-1,c))
    table[b-1].append((a-1,c))
    #ans.append((a-1,b-1,c))
h=deque()
inf=-10**13
h.append(0)
flag=True
visit=[(inf,0)]*N
visit[0]=(0,0)
tree=[]
while h:
    #print(h)
    x=h.popleft()
    for y,d in table[x]:
        if visit[y][0]!=inf and visit[y][1]==visit[x][1]:
            flag =False
            tree.append((x,y,d))
        elif visit[y][0]!=inf:
            if (visit[x][0]+visit[y][0])!=d:
                print(0)
                sys.exit()
        elif visit[y][0]==inf:
            t=(visit[x][1]+1)%2
            visit[y]=(d-visit[x][0],t)
            h.append(y)
#print(flag)
#print(visit)
#print(tree)
if flag:
    mi=-inf
    ma=-inf
    for i in range(N):
        if visit[i][1]==0:
            mi=min(mi,visit[i][0])
        else:
            ma=min(ma,visit[i][0])
    print(max(0,ma+mi-1))
    sys.exit()
#print(visit)
a,b,c=tree[0]
s=visit[a][1]
t=visit[a][0]+visit[b][0]
if (c -t)%2==1:
    print(0)
    sys.exit()
w=(c-t)//2
dp=[inf]*N
if s==0:
    dp[0]=w
else:
    dp[0]=-w

k=deque()
k.append(0)
while k:
    x =k.popleft()
    for y,d in table[x]:
        if dp[y]!=inf and (dp[x]+dp[y])!=d:
            print(0)
            sys.exit()
        if dp[y]==inf:
            dp[y]=d-dp[x]
            k.append(y)
for i in range(N):
    if dp[i]<=0:
        print(0)
        sys.exit()
print(1)




Measured memory_bytes: 54428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main (String[] args) throws IOException{
	    InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
	    BufferedReader in = new BufferedReader(reader);
		String[] str = in.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		double d = Integer.parseInt(str[1]);
		int cnt = 0;

		for(int i=0; i < n; i++) {
			str = in.readLine().split(" ");
			double x = Integer.parseInt(str[0]);
			double y = Integer.parseInt(str[1]);
			if(Math.sqrt(x*x+y*y)<=d) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 54392
n = int(input())
count = 0
okay = False
for i in range(n):
  temp1, temp2 = map(int,input().split())
  if temp1 == temp2:
    count += 1
  else:
    count = 0

  if count >= 3:
    okay = True
    break
    
if okay == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

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

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n; cin>>n;
    dd p[n]; rep(i,0,n-1){cin>>p[i];}
    dd dp[n][n+1] = {0};
    rep(i,0,n-1){
        rep(j,0,n){
            if(i==0){
                if(j==0){dp[i][j] = 1-p[i];}
                else if(j==1){dp[i][j] = p[i];}
                continue; 
            }
            if(j==0){
                dp[i][j] = (1-p[i])*dp[i-1][j];
                continue;
            }
            dp[i][j] = p[i]*dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
        }
    }
    dd ans = 0;
    rep(i,(n+1)/2,n){
        ans  += dp[n-1][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 74008
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:57:39
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int p = 1;
    for (int i = 0; i < n; i++) {
        p = min(2*p, p+k);
    }

    cout << p << endl;

    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    vector<string> S(N);
    ll i, j;
    for(auto &e : S)
        cin >> e;

    set<string> P;
    for(auto s : S) {
        P.insert(s);
    }
    cout << P.size() << endl;

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  long long r = 0, g = 0, b = 0;
  for (char c: s) {
    if (c == 'R') {
      ++r;
    } else if (c == 'G') {
      ++g;
    } else {
      ++b;
    }
  }
  long long ans = r * g * b;
  for (int i=0; i<n; i++) {
    for (int j=1; j<n; j++) {
      if (i + 2 * j >= n) {
        break;
      }
      if (s[i] != s[i+j] && s[i+j] != s[i+2*j] && s[i+2*j] != s[i]) {
        --ans;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

diff = 1000
index = 0
for i in range(N):
    tmp = abs(A-(T-H[i]*0.006))
    if diff > tmp:
        diff = tmp
        index = i+1

print(index)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	long long int a, b;
	char ch;
	
	scanf("%lld %c %lld", &a, &ch, &b);
	
	if (ch == '+') {
		printf("%lld\n", a + b);
	}
	else if (ch == '-') {
		printf("%lld\n", a - b);
	}
	
	return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder output = new StringBuilder();

        int i = 1;

        while(true){
            String input = br.readLine();
            int x = Integer.parseInt(input);

            if(x == 0){
                break;
            }
            output.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(x)).append("\n");
        }
            System.out.print(output);
//          ??¢?????????????????????????????????????????????println???????????¨????¨??????????????????????????????¨????????????
    }
}

Measured memory_bytes: 30892
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
	int n;
	double sum1=0, sum2=0, sum3=0;
	double d1, d2, d3, d4;
	int i;
	
	cin >> n;
	int x[n], y[n];
	
	for(i=0;i<n;i++)
		cin >> x[i];
	for(i=0;i<n;i++)
		cin >> y[i];
	
	for(i=0;i<n;i++){
		sum1+=fabs((double)x[i]-(double)y[i]);
		sum2+=pow((double)x[i]-(double)y[i], 2.0);
		sum3+=pow(fabs((double)x[i]-(double)y[i]), 3.0);
	}
	
	d4=fabs((double)x[0]-(double)y[0]);
	for(i=1;i<n;i++){
		d4=max(d4, fabs((double)x[i]-(double)y[i]));
	}
	
	d1=sum1;
	d2=sqrt(sum2);
	d3=pow(sum3, 1.0/3.0);
	
	cout << fixed << setprecision(5) << d1 << endl;
	cout << fixed << setprecision(5) << d2 << endl;
	cout << fixed << setprecision(5) << d3 << endl;
	cout << fixed << setprecision(5) << d4 << endl;
	
	return 0;
}

Measured memory_bytes: 1300
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    c = collections.Counter(a)
    ans = 0
    for i in c:
        if c[i] >= i:
            ans += c[i] - i
        else:
            ans += c[i]
    print(ans)
    return 0

if __name__ == '__main__':
    solve()

Measured memory_bytes: 23360
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt();
		Map<Integer, Integer> cnt = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			if (!cnt.containsKey(x)) {
				cnt.put(x, 0);
			}
			cnt.put(x, cnt.get(x) + 1);
		}
		int m = in.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = in.nextInt();
			if (!cnt.containsKey(b[i]) || cnt.get(b[i]) == 0) {
				out.println("NO");
				return;
			}
			cnt.put(b[i], cnt.get(b[i]) - 1);
		}
		out.println("YES");
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


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

typedef long long ll;

int main () {
	int n; cin >> n;
	string s; cin >> s;
	stack<char> stk;
	int beg = 0, end = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(') stk.push(s[i]);
		else {
			if (stk.empty()) beg++;
			else stk.pop();
		}
	}

	end = stk.size();

	for (int i = 0; i < beg; i++)
		cout << '(';
	cout << s;
	for (int i = 0; i < end; i++)
		cout << ')';
	cout << endl;

	return 0;
}


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

string rev(string ss){
  reverse(ss.begin(),ss.end());
  return ss;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string str;
    set<string> s;
    cin >> str;

    for(int i = 1 ; i < str.size() ; i++){
      string l = str.substr(0,i),r = str.substr(i);
      s.insert(l+r);
      s.insert(rev(l)+r);
      s.insert(l+rev(r));
      s.insert(rev(l)+rev(r));
      s.insert(r+l);
      s.insert(rev(r)+l);
      s.insert(r+rev(l));
      s.insert(rev(r)+rev(l));
    }
    cout << s.size() << endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC147D()
{
	int N;
	cin >> N;
	vl A(N);
	for (auto& x : A)
		cin >> x;

	vl nD(61);
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 61; ++j)
		{
			int x = (A[i] >> j) & 1;
			if (x == 1)
			{
				++nD[j];
			}
		}
	}

	ll MOD = 1000000007;
	ll sum = 0;
	int m = 1;
	for (int i = 0; i < 61; ++i)
	{
		ll x = nD[i] * (N - nD[i]);
		x %= MOD;
		sum += m * x;
		sum %= MOD;
		m *= 2;
		m %= MOD;
	}
	cout << sum << endl;
}

int main()
{
	ABC147D();
	return 0;
}

Measured memory_bytes: 2560
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll gcm(ll a,ll b){
  if(a%b==0)return b;
  else return(gcm(b,a%b));
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

int main() {
  int x;
  cin >> x;
  for(int i=x;i<1000000000;i++){
    int flag = 0;
    for(int k=2;k<x;k++){
      if(i%k==0){
        flag = 1;
        break;
      }
    }
    if(flag==0){
      cout<<i<<endl;
      return 0;
    }
  }//forend
}

Measured memory_bytes: 3636
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
typedef modint<MOD> m;
#pragma endregion

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

int main() {
  cin >> H;
  ll a = 1;
  ll count = 0;
  while(H > 0){
    count += a;
    H /= 2;
    a *= 2;
  }
  cout << count;
}



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

long long n, c = 0;
long long heights[200000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> heights[i];
    }
    for (int i = 1; i < n; i++)
    {
        if (heights[i] < heights[i - 1])
        {
            c += heights[i - 1] - heights[i];
            heights[i] = heights[i - 1];
        }
    }
    cout << c;
}

Measured memory_bytes: 5168
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sortBy)
import Data.Function (on)

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  abs <- sequence . replicate n $ unsafeListToPair . map unsafeSignedDecimal . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    abs' = sortBy (compare `on` snd) abs
    r = snd . foldl step (0, True) $ abs'
      where
        step (_, False) _ = (undefined, False)
        step (c, _) (a, b) = let c' = c + a in if c' <= b then (c', True) else (undefined, False)
  putStrLn $ if r then "Yes" else "No"

unsafeListToPair :: [Int] -> (Int, Int)
unsafeListToPair (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 114044
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e10;
////////////////////////////////////////////////////////////////////
int t[100001],x[100001],y[100001];
/////////////////////////////////////////////////////////////////////
int main(){
    int n;cin >> n;
    rep(n) cin >> t[i+1] >> x[i+1] >> y[i+1];
    bool ans = true;
    for(int i = 0;i < n;i++){
        int d = (t[i+1] - t[i]) - (abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])) ;
        //debug(d);
        ans &= (d >= 0) && (d %2 == 0);
    }
    if(ans)cout << "Yes" << endl;else cout << "No" << endl;
    return 0;
}

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

vector<vector<pair<int, int>>> T;
int color[100005];

void dfs(int v, int d) {
    for (auto p : T[v]) {
        int to = p.first;
        int w = p.second;
        if (color[to] != -1) continue;
        if ((d+w) % 2 == 0) color[to] = 0;
        else color[to] = 1;
        dfs(to, d+w);
    }
}

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

    T.resize(n);
    rep(i,n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;v--;

        T[u].push_back(make_pair(v, w));
        T[v].push_back(make_pair(u, w));
    }

    int d = 0;
    rep(i,n) color[i] = -1;
    color[0] = 0;
    dfs(0, d);

    rep(i,n) cout << color[i] << endl;
    return 0;
}


Measured memory_bytes: 7424
#include<stdio.h>

int main(){
  
  int x,i,fibo[44];
    scanf("%d",&x);
    for(i=0;i<=x;i++){
      if(i==0) fibo[i]=1;
      if(i==1) fibo[i]=1;
      if(i>1) fibo[i]=fibo[i-1]+fibo[i-2];
      if(i==x) printf("%d\n", fibo[i]);
    }
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int nc2(int n)
{
  return ( n * (n-1) ) /2;
}
signed main()
{
   int n;
   cin >> n;
   vector<int> add(n+1,0) ,sub( n+1,0), f(n+1,0), a(n);
   for(int i=0 ; i<n ; i++ )
   {
     cin >> a[i];
     f[ a[i] ]++ ;
   }
    int tot = 0;
  for(int i=1 ; i<=n ; i++ )
  {
     tot += nc2( f[i]);
     sub[i] = nc2( f[i] );
     add[i] = nc2( f[i]-1 );
  }
  for(int i=0 ; i<n ; i++ )
  {
     int ans = tot - sub[a[i]] + add[a[i]];
     cout << ans << '\n';
  }
}

Measured memory_bytes: 8832
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    i64 n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    i64 diff = b - a;
    forn(x, n) {
        i64 y = n - 1 - x;
        i64 lower = x * c - y * d;
        i64 upper = x * d - y * c;
        //cout << lower << " " << upper << endl;
        if (diff >= lower && diff <= upper) {
            printf("YES");
            exit(0);
        }
    }
    printf("NO");
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double a = l[0], b = l[1], x = l[2];
            x /= a;

            var many = x >= a * b / 2 ? true : false;
            var ans = 0D;

            if (many)
            {
                var h = 2 * (a * b - x) / a;
                ans = Math.Atan2(h, a) / (2 * Math.PI) * 360;
            }
            else
            {
                var w = x * 2 / b;
                ans = Math.Atan2(b, w) / (2 * Math.PI) * 360;
            }

            Console.WriteLine(ans);
        }
    }
}


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

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

   vector<vector<bool>> m(H + 2, vector<bool>(W + 2, false));

   rep(i, 1, H + 1) {
     rep(j, 1, W + 1) {
       char tmp;
       cin >> tmp;
       if (tmp == '.') m.at(i).at(j) = true;
     }
   }

   int ans = 0;
   vector<pair<int, int>> l{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

   rep(i, 1, H + 1) {
     rep(j, 1, W + 1) {
       if (m.at(i).at(j)) {
         vector<vector<int>> cnt(H + 2, vector<int>(W + 2, -1));
         queue<pair<int, int>> q;
         cnt.at(i).at(j) = 0;
         q.push({i, j});
         pair<int, int> tmp_p;
         while (!q.empty()) {
           tmp_p = q.front();
           q.pop();
           for (auto p : l) {
             if (m.at(tmp_p.first + p.first).at(tmp_p.second + p.second) && cnt.at(tmp_p.first + p.first).at(tmp_p.second + p.second) == -1) {
               q.push({tmp_p.first + p.first, tmp_p.second + p.second});
               cnt.at(tmp_p.first + p.first).at(tmp_p.second + p.second) = cnt.at(tmp_p.first).at(tmp_p.second) + 1;
               ans = max(ans, cnt.at(tmp_p.first + p.first).at(tmp_p.second + p.second));
             }
           }
          }
        }
      }
    }
    cout << ans << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  string n;
  cin >> n;

  if ((n.substr(0,1) == n.substr(1,1) || n.substr(3,1) == n.substr(1,1)) && n.substr(1,1) == n.substr(2,1)) pr("Yes");
  else pr("No");


  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    while (h[i] > 0) {
      ans++;
      for (int j = i; j < N; j++) {
        if (h[j] == 0) break;
        h[j]--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e3;
const ll MOD = 1e9 + 7;

int main(){
    ll n;
    cin >> n;

    ll ans = 0;
    for(ll i=1; i<n; i++) ans += i;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n;
	cin>>n;
	//ll sum=0;
	map<ll,ll>m;
	int sum=0;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i],sum^=a[i];
	for(int i=0;i<n;i++)
	a[i]^=sum;
	for(int i=0;i<n;i++)
	cout<<a[i]<<" ";
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first<y.second)
        return true;
    else if(x.first==y.second)
        return x.second<y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
vector<int> g[100001];
vector<bool> vis(100001);
vector<int> ans(100001,0);

int dfs(int node)
{
    vis[node]=1;
    if(!g[node].size()){
        ans[node]=0;
        return 1;
    }
    for(int to : g[node]){
        if(!vis[to])
            ans[node]=max(ans[node],dfs(to));
        else
        {
            ans[node]=max(ans[node],ans[to]+1);
        }
    }
    return ans[node]+1;
}

void solve()
{   
    int n,m;
    cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        g[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i])
            dfs(i);
    }
    int dd=INT_MIN;
    for(int i=1;i<=n;i++){
        //cout<<ans[i]<<' ';
        dd=max(dd,ans[i]);
    }
    //cout<<'\n';
    cout<<dd; 

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 8192
#include <cmath>
#include <iostream>
#include <cstdio>
#define PI 3.1415926535897932
using namespace std;

int main(void){
	int deg=0;
	int a,b;
	double x,y;

	while(scanf("%d,%d",&a,&b),a||b){
		x+=a*cos((double)deg/180.0*PI);
		y+=a*sin((double)deg/180.0*PI);
		deg+=b;
	}
	cout<<(int)y<<endl<<(int)x<<endl;
	return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define modulo 998244353
#define endl '\n'
#define pb push_back
using namespace std;
vector <int> adj[100001];
ll fxp(ll a, ll b)
{
    if(b == 0)return 1;
	if(b%2 == 0){
		ll c = fxp(a,b/2);
		return (c*c)%1000000007;
	}
	return (a*fxp(a,b-1))%1000000007;
}
int lcm(int c,int d)
{
    int a=c;
    int b=d;
    int ans;
    if(a>=b)
    {
        while(b!=0)
        { 
            int x=b;
            b=a%b;
            a=x;
        }
        ans = ( c*d)/a;
    }
    else
    {
        while(a!=0)
        {
            int x=a;
            a=b%a;
            b=x;
        }
        ans = ( c*d)/b;  
    }
    return ans;
}
int root_find()
{
    ll x;
    for(int i=1;i<100001;i++)
    {
        if(adj[i].size()==1)
        {
            x = i;
            break;
        }
    }
    return x;
}
void dfs(int s,int y)
{
    for(int i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]==y)
        continue;
        dfs(adj[s][i],s);
    }
}
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return n/2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return n/i; 
    } 
  
    return n; 
}  
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    ll ans=0;
    for(int i=0;i<n;i=i+2)
    {
        if(a[i]%2!=0)
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5996
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<bitset>

using namespace std;

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

int N, M;
vector<vector<int>> E;
map<P, int> edgeref;//両端の頂点をつなぐ辺の番号のReference 辺は1-idx

int bef[50];
ll used_edge[20];//各クエリごとの最短距離上にある辺ならば、その番号(辺番号は1-idxの設定なので、それを-1したもの番目)のbitを立てる

int bitCount(ll bits) {
	int ret = 0;
	while (bits) {
		if (bits & 1)ret++;
		bits >>= 1;
	}
	return ret;
}

void dfs(int now, int bpos) {
	for (int i = 0; i < E[now].size(); i++) {
		int nxt = E[now][i];
		if (nxt == bpos)continue;
		bef[nxt] = now;
		dfs(nxt, now);
	}
}

int main() {
	cin >> N;
	E.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edgeref[P(a, b)] = i + 1;
		edgeref[P(b, a)] = i + 1;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	cin >> M;

	for (int i = 0; i < M; i++) {
		int s, e;
		cin >> s >> e;
		s--, e--;

		bef[s] = -1;
		dfs(s, -1);

		int now = e;
		//使われてる辺を復元する
		while (now != s) {
			used_edge[i] |= (1LL << (edgeref[P(now, bef[now])] - 1));
			now = bef[now];
		}
	}

	ll ans = 0;
	for (int bit = 0; bit < (1LL << M); bit++) {
		ll flg = bitCount(bit) % 2 == 0 ? +1LL : -1LL;
		ll using_edge = 0;//選ばれた集合に関しての辺の和集合
		for (int i = 0; i < M; i++) {
			if ((bit >> i) & 1)using_edge |= used_edge[i];
		}
		ll tmp = (1LL << (N - 1 - bitCount(using_edge)));
		ans += tmp * flg;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
  // input
  int a, b;
  cin >> a >> b;

  int s;
  s = a+b;
  if (a-b > s) s=a-b;
  if (a*b > s) s=a*b;

  // output
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(scan.hasNext()){
			int n=scan.nextInt();
			if(n%2==0){
				System.out.println(0.5000000000);
			}
			else{
				int temp=(n+1)/2;
			//	System.out.println((double)temp/n);
				System.out.printf("%.10f\n",(double)temp/n);
			}
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;

    if(d == 1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	vector<ll> cnt(1+n), arr(n);
	for(int i  = 0; i < n; i++) {
		cin >> arr[i];
		cnt[arr[i]]++;
	}
	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		sum+=cnt[i]*(cnt[i]-1)/2;
	}
	for(int i = 0; i < n; i++) {
		ll x = sum;
		x-=cnt[arr[i]]*(cnt[arr[i]]-1)/2;
		x+=(cnt[arr[i]]-1)*(cnt[arr[i]]-2)/2;
		cout << x << '\n';
	}

	return 0;
}


Measured memory_bytes: 5760