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

bool f(int x, vector<int> &d) {
  while(x > 0){
    int y = x % 10;
    for(int i = 0; i < d.size(); i++){
      if(y == d.at(i)) return false;
    }
    x /= 10;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<int> d(k);
  for(int i = 0; i < k; i++) cin >> d.at(i);
  
  while(true){
    if(f(n, d)){
      cout << n << '\n';
      return 0;
    }
    n++;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	long n, k;
	cin >> n >> k;
	long a[100001], b[100001];
	long num[100001];
	for (int i = 1; i <= 100000; i++) {
		num[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		num[a[i]] += b[i];
	}
	long s = 0;
	long ans;
	int i = 1;
	while (s < k) {
		s += num[i];
		 ans = i;
		if (i >= 100000) break;
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <vector> 
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    int a,b,c=1;
    cin >>a >> b;
    
    for(int i=0 ; i<a;i++){
        if(c < b){
            c *=2;
        }else{
            c +=b;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define int long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN

const int N=1e5+5;
const ll mod=1e9+7;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
void EE(ll a,ll b,ll &co1,ll &co2)
{
    if(a%b==0)
    {
        co1=0;
        co2=1;
        return;
    }
    EE(b,a%b,co1,co2);
    ll temp=co1;
    co1=co2;
    co2=temp-co2*(a/b);
}
ll modinv(ll a,ll m)
{
    ll x,y;
    EE(a,m,x,y);
    if(x<0) x+=m;
    return x;
}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+1]={0};
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i] += a[i-1];
    }
    ll ans = MX;
    for(ll i=1;i<n;i++)
    {
        ans = min(ans,abs(a[i]-(a[n]-a[i])));
    }
    cout<<ans;  
    return 0;
}  

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

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;

double tb(double n){
	return n * n;
}
int main(void){

int nm,ans;
double xa,ya,ra,xb,yb,rb;

	cin >> nm;
//		if(nm == 0) break;
		rep(i,nm){
			cin >> xa >> ya >> ra;
			cin >> xb >> yb >> rb;
			
			double xy = sqrt(tb(xa-xb) + tb(ya-yb));
			if( xy > ra+rb) ans = 0;
			else if( xy + rb < ra ) ans = 2;
			else if( xy + ra < rb ) ans = -2;
			else ans = 1;
			cout << ans << endl;
		}
	
	return 0;
}

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

static string name[20] = {"yotta", "zetta", "exa", "peta", "tera", "giga", "mega", "kilo", "hecto", "deca", "deci", "centi", "milli", "micro", "nano", "pico", "femto", "ato", "zepto", "yocto"};
static int T[20] = {24, 21, 18, 15, 12, 9, 6, 3, 2, 1, -1, -2, -3, -6, -9, -12, -15, -18, -21, -24};
bool isW(string n){
  for ( int i = 0; i < 20; i++ )
    if ( name[i] == n ) return true;
  return false;
}

int getW(string pre){
  for ( int i = 0; i < 20; i++ ){
    if ( name[i] == pre )  return T[i];
  }
}

int normalize(string &base, int w){
  if ( base.find('.') == string::npos) base += '.';
  int p = base.find('.');
  for ( int i = p; i >=2; i-- ) { swap(base[i], base[i-1]); w++;}
  while( base[0] == '0' ){
    base.erase(base.begin());
    swap(base[0], base[1]);
    w--;
  }
  if ( base[base.size()-1] == '.' ) base.erase(base.end()-1);
  return w;
}

void compute(){
  string base, unit;
  int w = 0;
  cin >> base >> unit;
  if ( isW(unit) ) { w = getW(unit); cin >> unit; }
  w = normalize(base, w);
  cout << base << " * 10^" << w << " " << unit << endl;
}

main(){
  int tcase; cin >> tcase;
  for ( int i = 0; i < tcase; i++ ) compute();
}

Measured memory_bytes: 0
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N, W = [int(x) for x in input().split()]

dp = defaultdict(lambda: float('inf'))
dp[0] = 0

for i in range(N):
    w, v = [int(x) for x in input().split()]

    add = defaultdict(lambda: float('inf'))
    for vv in list(dp.keys()):
        if dp[vv + v] > dp[vv] + w:
            add[vv + v] = dp[vv] + w
    dp.update(add)

print(max(filter(lambda i: i[1] <= W, dp.items()), key=lambda x:x[0])[0])


Measured memory_bytes: 19300
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <string>
using namespace std;
#define rep(i,n) for (ll i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 
int main() {
  ll n,c,m,w=0,memo=0,memo2=0,sx=0,sy=1,ans=0,gx,gy;
  string ka,ss;
  cin>>n;
  vector<ll> A(n),B(n);
  rep(i,n)cin>>A[i];
  B[n-1]=A[n-1];
  rep(i,n-1){B[n-i-2]=(B[n-i-1]+A[n-i-2])%1000000007;}
  while(w<n-1){
    ans=(ans+(A[w]*B[w+1]))%1000000007;
    w++;
  }
  cout<<ans<<endl;
 
  
  
}

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

using namespace std;

int main()
{

    int ans = 0;
    int cnt = 0;
    int A[5];
    cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];

    for (int i = 0; i <= 9; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if ((10 - (A[j] % 10)) % 10 == i)
            {
                cnt++;
                if (cnt != 5)
                {
                    int a = ((10 - (A[j] % 10)) % 10);
                    ans += A[j] + a;
                }
                else
                {
                    ans += A[j];
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

bool linearSearch(int ary[], int size,  int key) {
  ary[size] = key;

  int i = 0;
  while (ary[i] != key) {
    i ++;
  }

  return i != size;
}

int main() {
  int n;cin>>n;
  int S[n+1];
  for(int i = 0; i < n; i ++) {
    cin >> S[i];
  }

  int q; cin>>q;
  int ans = 0;
  for (int i = 0; i < q; i ++) {
    int key;
    cin >> key;

    if (linearSearch(S, n, key)) ans++;
  }

  cout << ans << endl;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n; cin >> n;

	vector <int> a(n);


	map <int, int> m;


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


	for(int i = 0; i < n; i++){
		if(prev(m.end())->second > 1){
			cout << prev(m.end())->first << endl;
		}else{
			if(a[i] == prev(m.end())->first){
				cout << prev(prev(m.end()))->first << endl;
			}else{
				cout << prev(m.end())->first << endl;
			}
		}
	}





	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
using namespace std;
int main()
{
  int n, l; cin >> n >> l;
  int sum = l * n - n + n * (n + 1) / 2;
  int del = -1;
  int mn = 2e9;
  for (int i = 1; i <= n; i++)
  {
    if (abs(l + i - 1) < mn)
    {
      mn = abs(l + i - 1);
      del = i;
    }
  }
  cout << sum - l - del + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

ll x[100001] = {};
ll d[100001] = {};
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, m)cin >> x[i];

	sort(x, x + m);
	rep(i, 1, m) d[i - 1] = x[i] - x[i - 1];

	sort(d, d + m - 1);
	reverse(d, d + m - 1);
	ll sum = 0;
	rep(i, 0, n - 1) {
		sum += d[i];
	}

	cout << x[m - 1] - x[0] - sum << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] d = new int[n];
    int max = 0;
    int cur = 0;
    for(int i = 0; i < n; i++){
      d[i] = sc.nextInt();
      if(i < k){
        cur += d[i];
        max = cur;
      }else{
        cur = cur + d[i] - d[i - k];
        max = Math.max(cur,max);
      }
    }
    System.out.println((max + k)/2.0);
  }
}

Measured memory_bytes: 72648
ll=list()
for i in range(3):
    a=input()
    b=a.split()
    ll.append(int(b[0]))
    ll.append(int(b[1]))
c1=ll.count(1)
c2=ll.count(2)
c3=ll.count(3)
c4=ll.count(4)
if c1>2 or c2>2 or c3>2 or c4>2:
    print("NO")
else:
    print("YES")



Measured memory_bytes: 3060
n,m = map(int,input().split())

for val in range(n):
    tmp = list(map(int,input().split()))
    k = tmp[0]
    if val == 0:
        a_L = set(tmp[1:])
    else:
        a_L = set(tmp[1:]) & a_L

print(len(a_L))



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

namespace _20200412_ABC162B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(1);

            int N = int.Parse(input[0]);

            long output = 0;

            for(int i = 1; i <= N; i++)
            {
                if (i % 3 == 0)
                {
                    continue;
                }
                if (i % 5 == 0)
                {
                    continue;
                }

                output += i;
            }

            Console.WriteLine(output);
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }

    }
}


Measured memory_bytes: 17644
M=998244353
N,*A=open(0)
d=[0]*90001
d[0]=1
e=[0]*90001
e[0]=1
z=1
s=0
for a in A:
	i=s;a=int(a);s+=a;z*=3
	while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
if~s%2:z+=e[s//2]*3
print(z%M)

Measured memory_bytes: 141900
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int a,b,c,d,e;
 	cin>>a>>b;
 	c=a+b;
 	d=a-b;
 	e=a*b;
 	if(c>=d&&c>=e)
 		cout<<c<<endl;
 	else if(d>=c&&d>=e)
 		cout<<d<<endl;
 	 else
	 	 cout<<e<<endl; 	
 	return 0;
}
 	
 					

Measured memory_bytes: 3644
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

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

  vector <ll> Count(2e5 + 1);
  for (int i = 0; i < N; i++){
    Count[A[i]]++;
  }
  
  ll ans = 0;
  for (int i = 0; i < 2e5 + 1; i++){
    ans += Count[i] * (Count[i] - 1) / 2;
  }

  for (int i = 0; i < N; i++){
    cout << ans - (Count[A[i]] - 1) << endl;
  }
  
  return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;
#define pi 3.141592653589793238462643383279

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double rad = abs((double)(2.0 * pi * (double)h / 12.0) + (pi * m / 6 / 60) - (double)(2.0 * pi * (double)m / 60.0));

    //cout << rad << endl;
    double ans = (double)(a*a) + (double)(b*b) - (double)(2.0 * a * b * cos(rad));
    
    ans = sqrt(ans);

    printf("%.12f\n", ans);

    
    return 0;
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

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




struct Block{
    int w,s;ll v;
    Block(int w,int s,ll v):w(w),s(s),v(v){}
    Block(){}
};

const int OV=11000;
ll dp[1100][11100];

signed main(){
    int n;cin>>n;
    vector<Block>a(n);
    rep(i,n){
        int w,s;ll v;cin>>w>>s>>v;
        a[i]=Block(w,s,v);
    }

    sort(ALL(a),[](Block lhs,Block rhs){
        return lhs.w+lhs.s<rhs.w+rhs.s;
    });

    rep(i,n){
        rep(j,OV+1){
            if(j<=a[i].s){
                int to=min(OV,j+a[i].w);
                chmax(dp[i+1][to],dp[i][j]+a[i].v);
            }
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    ll res=0;
    rep(j,OV+1)chmax(res,dp[n][j]);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 74636
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////


int h,w;
char m[103][103];

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

void dfs(int x,int y){
    char s=m[x][y];
    m[x][y]='.';
    for(int i=0;i<=3;i++){
        int xx=x+dx[i],yy=y+dy[i];
        if(m[xx][yy]==s)dfs(xx,yy);
    }
}

int main(){
    while(cin>>h>>w,h||w){
        int ans=0;
        for(int i=0;i<=h-1;i++)scanf("%s",m[i]);
        for(int i=0;i<=h-1;i++)for(int j=0;j<=w-1;j++){
            if(m[i][j]!='.')dfs(i,j),ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
const int maxm = 2e6+7;
const ll mod = 1e9+7;

int ar[100];
int main()
{
    char ch[10];
    scanf("%s", ch);
    for(int i=0;i<4;i++){
        ar[ch[i]-'A']++;
    }
    int ins=0;
    for(int i=0;i<26;i++){
        if(ar[i]==2)ins++;
    }
    printf("%s\n", ins==2?"Yes":"No");

    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B, long long K){
    set<int> ans;
    REP2(i, A, min(A+K, B)) ans.insert(i);
    REP2(i, max(B-K+1, A), B+1) ans.insert(i);

    for(auto it = ans.begin(); it != ans.end(); it++) cout << *it << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d

#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main()
{
	int N, M;
	cin >> N >> M;
	vector< pair<int, int> > A(M);
	for(int i=0;i<A.size();i++){
		int a,b;
		cin >> a >> b;
		A[i] = make_pair(b,a);
	}

	sort(A.begin(), A.end());

	// for(int i=0;i<A.size();i++) cout << A[i].first << " " << A[i].second << endl;

	int bridge = 0;
	int ans = 0;
	for(int i= 0;i<A.size();i++){
		if (!(bridge >= A[i].second)){
			bridge = A[i].first - 1;
			ans ++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) cin >> s[i];

  int result = 0;
  for (int a = 0; a < n; ++a) {
    vector<string> ss(n);
    for (int i = 0; i < n; ++i) {
      ss[(i + a) % n] = s[i];
    }
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (ss[i][j] != ss[j][i]) {
          ok = false;
          break;
        }
      }
    }
    if (ok) result += n;
  }
  cout << result << endl;
  return 0;
}


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

int main(){
    string o,e;
    cin>>o;
    cin>>e;
    string ans;
    for(int i=0;i<e.size()+o.size();i++){
    if(i%2==0)ans+=o[i/2];
    else ans+=e[i/2];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def examA():
    S = {0:"pon",1:"pon",2:"hon",3:"bon",4:"hon",5:"hon",6:"pon",7:"hon",8:"pon",9:"hon"}
    N = SI()
    ans = S[int(N[-1])]
    print(ans)
    return

def examB():
    K = I()
    S = SI()
    N = len(S)
    if N<=K:
        ans = S
    else:
        ans = S[:K]+"..."
    print(ans)
    return

def examC():
    A, B, H, M = LI()
    a = abs(H*30 - M*5.5)
    deg = min(360-a,a)*math.pi/180
    #print(deg)
    ans = (A**2 + B**2 - 2*A*B*math.cos(deg))**(0.5)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

const int m = 1000000007;

int print(ll ans){
  ans%=m;
  if(ans<0) ans+=m;
  cout << ans << "\n";
  return 0;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans=1;
  if(a[0]<0){
    if(k%2==1){
    rep(i,k){ans*=a[i];ans%=m;}
    print(ans);
    return 0;
    }else{
    rep(i,k){ans*=a[n-1-i];ans%=m;}
    print(ans);
    return 0;
    }
  }
  int index1=0,index2=n-1;
  if(k%2==1){
    ans*=a[0];
    k--;
    index1++;
  }
  rep(i,k/2){
    if(a[index1]*a[index1+1]>a[index2]*a[index2-1]){
      ans*=a[index1];ans%=m;
      ans*=a[index1+1];ans%=m;
      index1+=2;
    }else{
      ans*=a[index2];ans%=m;
      ans*=a[index2-1];ans%=m;
      index2-=2;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for (int& x : a) scanf("%d", &x);
    // dp[i][j] la gia tri max X -Y tai doan i..j
    long long dp[n + 1][n + 1];
    for (int i = n - 1; i >= 0; i--){
        for (int j = i; j < n; j++){
            if (i == j) dp[i][j] = a[i];
            else dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
        }
    }
    cout << dp[0][n-1];
}


Measured memory_bytes: 46464
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

const int MAX_SIZE = 52;

int LCS(const string& a, const string& b){
    int n = (int)a.size(), m = (int)b.size();
    vector<int> x(n), y(m);
    rep(i,n){
        x[i] = a[i]-'a';
        if(x[i] < 0){
            x[i] = a[i]-'A'+26;
        }
    }
    rep(i,m){
        y[i] = b[i]-'a';
        if(y[i] < 0){
            y[i] = b[i]-'A'+26;
        }
    }
    vector<vector<int> > vec(MAX_SIZE);
    for(int j = m-1; j >= 0; --j){
        vec[y[j]].push_back(j);
    }
    vector<int> xs(n+1, INF);
    xs[0] = -INF;
    vector<P> nx(n+1,P(-INF,-INF));
    rep(i,n){
        vector<int>& ys = vec[x[i]];
        rep(j,(int)ys.size()){
            int k = lower_bound(xs.begin(),xs.end(),ys[j]) - xs.begin();
            xs[k] = ys[j];
            nx[k] = P(y[ys[j]], k-1);
        }
    }
    int l = lower_bound(xs.begin(),xs.end(),INF-1) - xs.begin();
    int id = l-1;
    int ans = 0;
    while(true){
        id = nx[id].second;
        if(id == -INF) break;
        ans++;
    }
    return ans;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    rep(i,q){
        string a,b;
        cin >> a >> b;
        cout << LCS(a,b) << "\n";
    }
    return 0;
}



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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

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

int main(){
    int N; cin >> N;
    ll ans=(modpow(10, N, MOD)-2*modpow(9, N, MOD)%MOD+modpow(8, N, MOD))%MOD;
    if(ans < 0) ans+=MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
using namespace std;

int main () {
    int n;
    cin >> n;
    int a[n+1];
    for (int i=1;n>=i;i++) cin >>a[i];
    bool check=false;
    int j=n;
    while (j>=1) {
        if (check) cout<<' ';
        cout<<a[j];
        j-=2;
        check=true;
    }
    if (n%2==1) j=2;
    else j=1;
    while (n>=j) {
        cout<<' '<<a[j];
        j+=2;
    }
    cout<<endl;
}


Measured memory_bytes: 2944
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	k := scanInt()
	s := scanText()

	cnt := make([][]int, 2)

	pre := 1
	c := 0

	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(string(s[i]))
		if pre != num {
			cnt[pre] = append(cnt[pre], c)
			c = 1
		} else {
			c++
		}
		pre = num
	}
	cnt[pre] = append(cnt[pre], c)

	sum := cnt[1][0]
	c = 0

	p := 0
	if len(cnt[0]) == len(cnt[1]) {
		cnt[1] = append(cnt[1], 0)
	}

	ans := sum

	for i := 0; i < len(cnt[0]); i++ {
		sum += cnt[0][i]+cnt[1][i+1]
		c++

		if c>k {
			sum -= cnt[0][p]+cnt[1][p]
			p++
			c--
		}

		if sum>ans {
			ans = sum
		}
		// fmt.Println(sum,c,cnt[0][i],cnt[1][i+1])
	}

	fmt.Println(ans)
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


const int vmax=110;

int V;
vi G[vmax];
vi rG[vmax];
vi vs;
bool used[vmax];
int cmp[vmax];


void add_edge(int from,int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
		if(!used[G[v][i]])
			dfs(G[v][i]);
	vs.push_back(v);
}

void rdfs(int v,int k){
	used[v]=true;
	cmp[v]=k;

	for(int i=0;i<rG[v].size();i++)
		if(!used[rG[v][i]])
			rdfs(rG[v][i],k);
}

int scc(void){
	memset(used,0,sizeof(used));
	vs.clear();
	for(int v=0;v< V ;v++)
		if(!used[v])
			dfs(v);
	memset(used,0,sizeof(used));
	int  k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]])
			rdfs(vs[i],k++);
	}
	return k;
}

int N,M,T;
int dp[110][10010];
int p[110],t[110],k[110];
int a[1010],b[1010];

bool rel[110][110];
bool check[110];

int s;

int deq[10010];
int deqv[10010];

void solve(int cur){
	vi index;
	rep(i,N) if(cur==cmp[i]) index.pb(i);
	if(index.size()==1&&!rel[cur][cur]){
		int tar=index[0];
		for(int j=T;j>=t[tar];j--) dp[cur][j]=max(dp[cur][j],dp[cur][j-t[tar]]+p[tar]);
	}else{
		for(auto &i :index){
			rep(aa,t[i]){
				int ss=0,tt=0;
				for(int j=0;j*t[i]+aa<=T;++j){
					int val=dp[cur][j*t[i]+aa]-j*p[i];
					while(ss<tt && deqv[tt-1]<=val) tt--;
					deq[tt]=j;
					deqv[tt++]=val;
					dp[cur][j*t[i]+aa]=deqv[ss]+j*p[i];
					if(deq[ss]==j-k[i]) ss++;
				}
			}
		}
	}
	rep(i,s) if(rel[cur][i]) rep(j,T+1) dp[i][j]=max(dp[i][j],dp[cur][j]);
}

int main(void){
	while(cin >> N >> M >> T){
		if(N==0)
			break;
		V=N;
		rep(i,N) cin >> p[i]  >> t[i] >> k[i];

		rep(i,vmax) G[i].clear(),rG[i].clear();
		rep(i,vmax)rep(j,10010) dp[i][j]=0;
		rep(i,vmax)rep(j,vmax) rel[i][j]=false;
		rep(i,vmax) check[i]=false;

		rep(i,M){
			cin >> a[i] >> b[i];
			a[i]--,b[i]--;
			add_edge(a[i],b[i]);
		}

		s=scc();
		rep(i,M) a[i]=cmp[a[i]],b[i]=cmp[b[i]];
		rep(i,M) rel[a[i]][b[i]]=true;

		int ans=0;
		rep(i,s) solve(i);

		rep(i,s) ans=max(ans,dp[i][T]);

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

Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+5;
int n;
vector<int > g[maxn];
int sg[maxn];
void addedge(int from,int to)
{
    g[from].push_back(to);
    g[to].push_back(from);
}
int dfs(int v,int fa)
{
    if(g[v].size()==1 && fa==g[v][0]) return sg[v]=0;
    sg[v]=0;
    for(int i=0;i<(int)g[v].size();i++)
    {
        int u=g[v][i];
        if(u!=fa) sg[v]=sg[v] xor (1+dfs(u,v));
    }
    return sg[v];
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){int from,to;scanf("%d%d",&from,&to);addedge(from,to);}
    dfs(1,-1);
    if(sg[1]) printf("Alice\n");
    else printf("Bob\n");
    return 0;
}


Measured memory_bytes: 13952
s=input()
yy = ["%02d" % i for i in range(100)]
mm = ["%02d" % i for i in range(1, 13)]
yymm = s[:2] in yy and s[2:] in mm
mmyy = s[:2] in mm and s[2:] in yy
print(["NA","MMYY","YYMM","AMBIGUOUS"][yymm*2+mmyy])


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

const int N = 1000;
const int inf = 1000 * 1000 * 1000 + 7;

int n;
string st[N];
bool mark[N];
int dis[N];

void input() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> st[i];

    for (int i = 0; i < n; i++)
        dis[i] = inf;

    return;
}

int BFS(int v) {
    queue <int> Q;

    int res = 0;
    Q.push(v) ;
    mark[v] = true;
    dis[v] = 0;
    while (!Q.empty()) {
        int v = Q.front() ;
        Q.pop() ;

        for (int i = 0; i < n; i++)
            if (st[v][i] == '1')
                if (!mark[i]) {
                    mark[i] = true;
                    dis[i] = dis[v] + 1;
                    Q.push(i) ;
                    res = max(res, dis[i]) ;
                }
                else if (dis[i] % 2 == dis[v] % 2) {
                    cout << -1 << endl;
                    exit(0) ;
                }
    }
    return res;
}

int main() {
    input() ;

    int ans = 0;

    for (int i = 0; i < n; i++) {
        ans = max(ans, BFS(i)) ;
        for (int i = 0; i < n; i++) {
            dis[i] = 0;
            mark[i] = false;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <math.h>

int main(void){
  int i,j,n,d,k,l,count=0;
  double distance,sum;
  scanf("%d %d",&n,&d);
  int a[n][d];
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      scanf("%d",&a[i][j]);
    }
  }
  /*debug
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      printf("a[%d][%d]=%d ",i,j,a[i][j]);
    }
    printf("\n");
  }*/
  //距離
 for(i=0;i<n;i++){
    for(k=i+1;k<n;k++){
      for(j=0;j<d;j++){
        //printf("%d ",(a[i][j]-a[k][j])*(a[i][j]-a[k][j]));
        sum+=((a[i][j]-a[k][j])*(a[i][j]-a[k][j]));
        //printf("%f\n",sum);
      }
      //printf("%f\n",sum);
      for(l=0;l<=sum;l++){
        if(sum==l*l){
          count+=1;
        }
      }
      sum=0;
    }
  }


  printf("%d\n",count);

  return 0;
}


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

using namespace std;
using ll = long long;

ll solve(vector<vector<ll>> &pts, vector<vector<vector<ll>>> &memo, int r = 0,
         int c = 0, int cnt = 0) {
  if (r >= pts.size() || c >= pts.front().size()) {
    return 0;
  }

  if (memo[r][c][cnt] < 0) {
    ll v = pts[r][c];
    if (cnt >= 3) {
      memo[r][c][cnt] =
          max({solve(pts, memo, r + 1, c, 0), solve(pts, memo, r, c + 1, cnt)});
    } else {
      memo[r][c][cnt] =
          max({v + solve(pts, memo, r + 1, c, 0), solve(pts, memo, r + 1, c, 0),
               v + solve(pts, memo, r, c + 1, cnt + (v > 0)),
               solve(pts, memo, r, c + 1, cnt)});
    }
  }

  return memo[r][c][cnt];
}

int main(int argc, const char *argv[]) {
  int r, c, k;
  cin >> r >> c >> k;
  vector<vector<ll>> pts(r, vector<ll>(c, 0));
  for (int i = 0; i < k; ++i) {
    int r, c;
    ll v;
    cin >> r >> c >> v;
    r--;
    c--;
    pts[r][c] = v;
  }

  vector<vector<vector<ll>>> memo(r + 1, vector(c + 1, vector(4, -1ll)));
  cout << solve(pts, memo) << '\n';
  return 0;
}

Measured memory_bytes: 708000
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    ll n,k;
    cin>>n>>k;
    init();
   if(n>k){
       cout<<0<<endl;
       return 0;
   }
   mint ans=COM(k,n)*fac[n];
   cout<<ans<<endl;
}



Measured memory_bytes: 50060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    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 c[300005],a[300005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,k,x,y,t,m;

	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		c[a[i]]++;
	}

	ll ans=0;
	for(i=1;i<=n;i++)
	{
		if(c[i])
		{
			// cout<<c[i]<<" "<<i<<endl;
			ans+=(c[i]*(c[i]-1))/2;
		}
	}
	// cout<<ans<<endl;

	for(i=1;i<=n;i++)
	{
		x=0;
		if(c[a[i]]>1)
			x=(c[a[i]]-1)*(c[a[i]]-2),x/=2;
		y=c[a[i]]*(c[a[i]]-1);
		y/=2;
		cout<<ans+x-y<<endl;
	}
}

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b) % 24 << endl;
  return 0;
}


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

int main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) { cin>>a[i]; a[i]-=i+1; }
    sort(begin(a), end(a));
    long res=0;
    for(auto& e: a) res+=abs(e-a[n/2]);
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, A;
  ci(N, A);
  co(N * N - A);
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n;
    cin>>n;
    VI a(n);
    VI num(n+1);
    rep(i,n-1) {
      cin>>a[i];
      num[a[i]]++;
    }

    for(int i=1;i<n+1;i++){
      cout<<num[i]<<endl;
    }
}


Measured memory_bytes: 4844
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,stdin.readline().split()))
q=int(input())
count=defaultdict(lambda:0)
for i in a:
    count[i]+=1
s=sum(a)
for _ in range(q):
    b,c=map(int,stdin.readline().split())
    s+=count[b]*(c-b)
    count[c]+=count[b]
    count[b]=0
    print(s)

Measured memory_bytes: 24144
#include<stdio.h>

int main(void) {
	 int x, y;
	scanf("%d %d", &x, &y);

	float kame,turu;
	kame = (y - 2*x) / 2.f;
	turu = (4 * x - y) / 2.f;

	if (((turu >= 0) && (turu == (int)turu))&&((kame>=0)&&(kame == (int)kame))) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int prev_t = 0, X = 0, Y = 0;
    rep(i, N) {
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(X - x) + abs(Y - y);
        int difft = t - prev_t;
        if(d % 2 != difft % 2 || d > difft) {
            cout << "No" << endl;
            return 0;
        }
        prev_t = t;
        X = x;
        Y = y;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
w1 = math.pi * H / 6 + math.pi * M / 360
w2 = math.pi * M / 30
rad = abs(w1 - w2)
if rad > math.pi:
    rad = 2 * math.pi - rad

print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(rad)))

Measured memory_bytes: 9456
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
b = True
wh = 0
for i in range(n - 1):
  if b == False:
    b = True
    continue
  if a[i] == a[i + 1]:
    b = False
    if wh == 0:
      wh = a[i]
    else:
      print(wh * a[i])
      exit()
print(0)

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

int main()
{
    int a, b;
    char opt;
    for (;;) {
	cin >> a >> opt >> b;
	switch (opt) {
	case '+':
	    cout << a + b << endl;
	    break;
	case '-':
	    cout << a - b << endl;
	    break;
	case '*':
	    cout << a * b << endl;
	    break;
	case '/':
	    cout << a / b << endl;
	    break;
	case '?':
	    return 0;
	}

    }
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	int a;
	vector<ll>V(N);
	for (int i = 0; i < N; ++i) {
		cin >> a;
		V.at(i) = a;
	}
	sort(V.begin(), V.end());
	ll sum = 0;
	int count = 1;
	for (int i = 0; i < N-1; ++i) {
		if (V[i] == V[i + 1]) {
			count++;//同じ数が何個連続して並んでいるか
		}
		else {
			if (V[i] >count){
				sum += count;
			}
			else if (V[i] < count) {
				sum += count - V[i];
			}
			count = 1;
		}
	}
	if (V[N - 1] < count) {
		sum += count - V[N - 1];
	}
	else if (V[N - 1] > count) {
		sum += count;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n; cin >> n;
  vec f(n+1, 0);

  for (int x = 1; x*x < n; x++) {
    for (int y = 1; y*y < n; y++) {
      for (int z = 1; z*z < n; z++) {
        int i = x*x+y*y+z*z+x*y+y*z+z*x;
        if (i <= n) f[i]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << f[i] << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
 
int main(){
    string S;
    ll K;
    cin >> S >> K;
    pair<ll, ll> n(1,1);
    REP(i, S.size()) {
        if(S[i] != '1') {
            n.first = stoi(S.substr(i, 1));
            n.second = i+1;
            break;
        }
    }
    if (K < n.second) cout << "1\n";
    else cout << n.first << "\n";
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  for(int i(0);i<K;i++){
    if(i%2==0){
      if(A%2==1){
        A -= 1;
      }
      B += A/2;
      A/=2;
    }else{
      if(B%2==1) B-=1;
      A+=B/2;
      B/=2;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}



Measured memory_bytes: 3596
Q,H,S,D = map(int,input().split())
N = int(input())
num = min(4*Q,2*H,S)
if num*2 <= D:
    print(N*num)
elif N % 2 == 0:
    print(N*D//2)
else:
    print(N//2*D+num)

Measured memory_bytes: 9116
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    int N;
    cin>>N;
    vector<int> p;
    for(int i=0;i<N;i++){
      int a;
      cin>>a;
      p.push_back(a);
    }
    bool s=0;
    for(int i=0;i<N;i++){
      if(p[i]==i+1)continue;
      if(p[p[i]-1]==i+1 && s==0){
        swap(p[p[i]-1],p[i]);
        s=1;
        continue;
      }
      cout<<"NO";
      return 0;
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 256