akhauriyash/Code-Regression huggingface dataset:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

# @lru_cache(None)

t=1
# t=int(input())
for _ in range(t):
    n=L()[0]
    A=L()
    A.sort(reverse=True)
    ans=A[0]
    for i in range(1,n-1):
        if i%2:
            ans+=A[(i+1)//2]
        else:
            ans+=A[i//2]
    print(ans)


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007
template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;

struct MComb {
    std::vector<mint> fact;
    std::vector<mint> inversed;
    MComb(int n) { // O(n+log(mod))
        fact = std::vector<mint>(n+1,1);
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
        inversed = std::vector<mint>(n+1);
        inversed[n] = fact[n] ^ (MOD-2);
        for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
    }
    mint ncr(int n, int r) {
        return (fact[n] * inversed[r] * inversed[n-r]);
    }
    mint npr(int n, int r) {
        return (fact[n] * inversed[n-r]);
    }
    mint nhr(int n, int r) {
        assert(n+r-1 < (int)fact.size());
        return ncr(n+r-1, r);
    }
};

mint solve() {
	int x = ri(), y = ri();
	if ((x + y) % 3) return 0;
	int num = (x + y) / 3;
	int x2 = x - num;
	if (x2 < 0 || x2 > num) return 0;
	MComb com(x + y + 1);
	return com.ncr(num, x2);
}

int main() {
	std::cout << solve() << std::endl;
	return 0;
}


Measured memory_bytes: 15872
#include<iostream>
using namespace std;
int main(){
  int i,j,k;
  int r,c;
  int b;
  cin >> r >> c;
  int rsum[100]={};
  int csum[100]={};
  int sum=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    rsum[i]+=b;
    csum[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      rsum[i]+=b;
      csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
  }
  cout << csum[0];
  for(j=1;j<c;j++){
    cout << " " << csum[j];    
  }
  cout << " " << sum <<  endl;
  return 0;
}



Measured memory_bytes: 3108
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ArrayList<int[]> list = new ArrayList<>();
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), D = sc.nextInt();
		
		for(int i = 0; i < N; i++) {
			int[] mlist = new int[D];
			for(int j = 0; j < D; j++) {
				mlist[j] = sc.nextInt();
			}
			list.add(mlist);
		}
		
		for(int i = 0; i < N-1; i++) {
			for(int j = i + 1; j < N; j++) {
				if(dis(list.get(i),list.get(j))) ans++;
			}
		}
		System.out.println(ans);
		
	}
	
	public static boolean dis(int[] list1, int[] list2) {
		int sum = 0;
		for(int i = 0; i< list1.length; i++) {
			sum += Math.pow((list1[i]-list2[i]),2);
		}
		if((Math.sqrt(sum) * 10)%10 == 0)  return true;
		else return false;
	}
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll TA,TB,AA,AB,BA,BB;
  cin>>TA>>TB>>AA>>AB>>BA>>BB;
  ll da = TA*(BA-AA),db=TB*(BB-AB);
  ll c = da+db;
  bool inf = false;
  ll ans = 0LL;
  if((da>0&&c>0)||(da<0&&c<0))ans = 0LL;
  else if(c==0LL) inf = true;
  else {
    ll cnt = db/c;
    ans = 2LL*cnt-1LL;
    if(db%c==0LL)ans--;
  }
  if(inf) cout<<"infinity"<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

min, max = map(int, input().split())

for i in range(1, M):
    L, R = map(int, input().split())
    if L > max or R < min:
        print(0)
        exit()
    elif min < L <= max:
        min = L
    elif min <= R < max:
        max = R
print(max-min+1)


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

int main()
{
	int N, T, A, H;
	double Tn;
	int ans = 0;
	double diff = 1000;

	cin >> N;
	cin >> T >> A;

	for (int i = 1; i <= N; i++)
	{
		cin >> H;
		Tn = T - 0.006 * H;
		if (diff > abs(A - Tn))
		{
			diff = abs(A - Tn);
			ans = i;
		}
	}

	cout << ans << endl;

	return(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;



int main() {
  io();
  
  int n;
  vi arr;
  cin >> n;
  fori(i, n) {
  	int a;
    cin >> a;
    arr.pb(a);
  }
  int t = 0;
  int tdiff;
  fori(i, n) {
    int diff;
    int a = 0, b = 0;
    fori(k, i) {
      a += arr[k];
    }
    foris(k, i, n) {
      b += arr[k];
    }
    diff = abs(b - a);
    cout << "";
    if(diff < tdiff) {
      t = i;
      tdiff = diff;
    }
  }
  cout << tdiff;
  
  return 0;
}

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

ll reputable(ll a) {

    ll reputable_num = 1;
    
    if (a%2==0) {
        reputable_num += reputable(a/2);
    }
    else return 0;

    return reputable_num;
}

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

    ll n, tmp; cin >> n;
    vector<ll> a(n,0); for (ll i=0; i<n; i++) cin >> tmp, a[i] = reputable(tmp);

    sort(a.begin(), a.end());
    //reverse(a.begin(), a.end());

    cout << a[0] << "\n";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc118d
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = ReadIntList();
            var N = nm[0];
            var M = nm[1];
            var honsuu = new int[10] { int.MaxValue, 2, 5, 5, 4, 5, 6, 3, 7, 6 }; // 本数に射影
            var A = ReadIntList().OrderBy(n => honsuu[n]).ThenByDescending(n => n).ToList();


            var dp = new int[N + 1]; // dp[i] : i をマッチ棒で作るときの最大桁数

            dp[0] = 0;
            for (int i = 1; i <= N; i++)
            {
                dp[i] = int.MinValue;
                foreach (var a in A)
                {
                    if (i < honsuu[a])
                        break;
                    dp[i] = Math.Max(dp[i - honsuu[a]] + 1, dp[i]);
                }
            }
            var output = new int[dp[N]];
            
            for(int i = 0; i < output.Length; i++)
            {
                foreach (var a in A.OrderByDescending(n=>n))
                {
                    if (honsuu[a] <= N && dp[N - honsuu[a]] == dp[N] - 1)
                    {
                        output[i] = a;
                        N -= honsuu[a];
                        break;
                    }
                }
            }
            Console.WriteLine(String.Join("", output));
#if DEBUG
            Console.ReadKey();
#endif
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
    }
}


Measured memory_bytes: 13504
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;

int main() {
ll n;
string s;
cin >> n >> s;
//cout << char(2+'a') << endl;
string ans = "";
rep(i,s.size()){
    //cout << s[i]-'A' << endl;
    int x = s[i]-'A';
    x = (x+n)%26; 
    ans += char(x+'A'); 
    //s[i]=(s[i]-'A'+n)%26+'A';
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin>>N;
  bool ans=false;
  for(int i=0;i<3;i++){
      if(N[i]==N[i+1]) ans=true;
  }
  if(ans) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

S = s_in()
N = len(S)

if S[0] == '0':
    print(-1)
    exit()
elif S[-1] == '1':
    print(-1)
    exit()

for i in range((N-1)//2):
    if S[i] != S[-i-2]:
        print(-1)
        exit()

parent = N
for i in range(N-1, 0, -1):
    s = S[i-1]
    if s == '1':
        print(i, parent)
        parent = i
    else:
        print(i, parent)


Measured memory_bytes: 4764
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

Measured memory_bytes: 3064
S = input()
if S == 'SUN':
    print("7")
elif S == 'MON':
    print("6")
elif S == 'TUE':
    print("5")
elif S == 'WED':
    print("4")
elif S == 'THU':
    print("3")
elif S == 'FRI':
    print("2")
else:
    print("1")

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;


int main(){
    int a=0, b=0;
    for(int i=0;i<4; i++){
        int w;
        cin >> w;
        a+=w;
    }
    for(int i=0;i<4; i++){
        int w;
        cin >> w;
        b+=w;
    }
    cout<<max(a,b)<<endl;
    return 0;
}



Measured memory_bytes: 3084
import math
N=input()
A=map(int, raw_input().split() )

fact=[]
inv_fact = []

mod=10**9+7
fact_tmp = 1
for i in range(1, N+1):
	fact.append(i)
	inv_fact.append( pow(i, mod-2, mod) )


f=math.factorial(N)%mod

sum_inv_fact=[]  #ruiseki_inv_fact
for x in inv_fact:
	if len(sum_inv_fact)==0:
		sum_inv_fact.append(x)
	else:
		sum_inv_fact.append( sum_inv_fact[-1]+x )


s=0
for j in range(N):
	s+= (sum_inv_fact[N-j-1]+sum_inv_fact[j]-1)*f*A[j]
	s%=mod

print s


Measured memory_bytes: 51988
<?php
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $a, $b);

CONST EVEN='Even';
CONST ODD='Odd';

if($a % 2 ===0){
    print EVEN;
    exit;
}

if($b % 2 ===0){
    print EVEN;
    exit;
}
print ODD;
exit;



Measured memory_bytes: 4728
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    long MOD = 998244353;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }

        long[][] dp1 = new long[2][sum + 1];
        long[][] dp2 = new long[2][sum + 1];
        dp1[0][0] = dp2[0][0] = 1;

        int x = 1;

        for (int i = 0; i < n; i++) {
            Arrays.fill(dp1[x], 0);
            Arrays.fill(dp2[x], 0);
            for (int j = sum; j >= 0; j--) {
                if (j >= a[i])
                    dp1[x][j] = (dp1[x][j] + dp1[1 - x][j - a[i]]) % MOD;
                dp1[x][j] = (dp1[x][j] + 2 * dp1[1 - x][j]) % MOD;
                if (j >= a[i])
                    dp2[x][j] = (dp2[x][j] + dp2[1 - x][j - a[i]]) % MOD;
                dp2[x][j] = (dp2[x][j] + dp2[1 - x][j]) % MOD;
            }
//            debug(dp1[x]);
//            debug(dp2[x]);
            x = 1 - x;
        }

        long ans = 1;

        for (int i = 0; i < n; i++) ans = (ans * 3) % MOD;
        for (int i = (sum + 1) / 2; i <= sum; i++) {
            ans = (ans - 3 * dp1[1 - x][i] + 3 * MOD) % MOD;
        }

        if (sum % 2 == 0) ans = (ans + 3 * dp2[1 - x][sum / 2]) % MOD;

        System.out.println(ans);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 25080
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll a,b[N];
    rep(0,i,N){
        cin>>a;
        b[a-1]=i+1;
    }
    rep(0,i,N)cout<<b[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){

    ll n;
    cin >> n;
    ll a[n];
    rep(i,0,n) cin >> a[i];

    sort(a,a+n,greater<ll>());

    ll ans = 0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            ll ok = -1,ng = n;
            while(abs(ok-ng) > 1){
                ll mid = (ok+ng)/2;

                if(a[i] < a[j] + a[mid]){
                    ok = mid;
                }
                else{
                    ng = mid;
                }
            }

            ans += max(0LL,ok - j);
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const int N = 300100;
int a[N], n;

int main(){
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	int i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	bool flag = 1;
	for (i = 1; i <= n; i++){
		if (a[i] != 0){
			flag = 0;
			break;
		}
	}
	if (flag){
		printf("Yes\n");
		return 0;
	}
	if (n % 3 != 0){
		printf("No\n");
		return 0;
	}
	for (i = 0; i <= 2; i++){
		for (j = 1; j <= n / 3; j++){
			if (a[i * (n / 3) + j] != a[i * (n / 3) + 1]){
				printf("No\n");
				return 0;
			}
		}
	}
	if ((a[1] ^ a[n / 3 + 1]) != a[n / 3 * 2 + 1]){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

ll a, b;
char c;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> c >> b;
	if ( c == '+' )
		cout << a + b << endl;
	if ( c == '-' )
		cout << a - b << endl;
	return 0;
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = k;
  rep(i, n-1) {
    ans *= k-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())


ans = []
for ai in range(a,a+k):
  if ai <= b:
    ans.append(ai)
for bi in range(b,b-k,-1):
  if bi >=a:
    ans.append(bi)
    
for i in sorted(list(set(ans))):
  print(i)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, cnt = 0;
  cin >> n;
  int a[n];
  REP(i, n) {
    cin >> a[i];
    if((i + 1) % 2 == 1 && a[i] % 2 == 1) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
    using namespace std;
        int main() {
        	int N, M;
    		cin >> N >> M;
     
    		int vec[N];
            for (int i = 0; i < N; i++) {
            cin >> vec[i];
            }
     
    		double sum = 0;
    		for (int i = 0; i < N; i++) {
            	sum += vec[i]; 
            }
     
    		int count = 0;
			double siki = sum/(4*M);
    		for (int i = 0; i < N; i++) {
    			if (vec[i] >= siki){
    				count++;
    			}
            }
     
    	if (count >= M)	cout << "Yes" << endl;
    	else 	cout << "No" << endl;

        }

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	char *str;
	if(a+b==c||a==b+c||b==a+c)
		str ="Yes";
	else
		str ="No";
	printf("%s\n",str);

	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(input()) - 1 for _ in range(N)]
now = 0
se = set([])
ans = 0

while True:
    if now == 1:
        break
    now = A[now]
    if now in se:
        print(-1)
        exit()
    se.add(now)
    ans += 1
print(ans)


Measured memory_bytes: 13220
N = int(input())
L = [input() for _ in range(N)]
ctrAB = 0
lastA = 0
firstB = 0
lAfB = 0
for s in L:
    if s[0] == 'B' and s[-1] == 'A':
        lAfB += 1
    if s[0] == 'B':
        firstB += 1
    if s[-1] == 'A':
        lastA += 1
    ctrAB += s.count('AB')
if lAfB != 0 and lAfB == lastA and lAfB == firstB:
    print(ctrAB + lAfB - 1)
else:
    print(ctrAB + min(lastA,firstB))


Measured memory_bytes: 3700
#include <stdio.h>
int main(void){
    int i,j,a,b;
    
while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)break;
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            
            if(j==0||j==b-1)printf("#");
            else if(i==0||i==a-1)printf("#");
            else printf(".");
        }
 printf("\n");
}
    printf("\n");
}
return(0);
}



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<string> s;
  vector<int> t;
  Solver(LL n) : n(n), s(n), t(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    int p;
    for (int i = 0; i < n; ++i) {
      if (s[i] == x) {
        p = i;
      }
    }
    int ans = 0;
    for (int i = p + 1; i < n; ++i) {
      ans += t[i];
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, m = MII()
    loads = {i: [] for i in range(n)}
    for i in range(m):
        a, b = MIIZ()
        loads[a].append(b)
        loads[b].append(b)
    for l in loads.values():
        print(len(l))

if __name__ == '__main__':
    main()

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

int main(){
	int a, b;
  	cin >> a >> a >> a >> b;
  	cout << (a % 977 == 0 || (b % 3 == 0 && a % 73 !=0)|| b % 10 == 3 || b % 11 == 0 || b % 479 == 0? "Yes" : "No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		
		if ( n1 > 12 ){
			System.out.println(n2);
		}else if ( n1> 5){
			System.out.println(n2/2);
		}else {
			System.out.println(0);
		}
	}

}

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

public class Main
{
  int n, max = 0;
  int[] a, l, r;
  
  Main(Scanner in, PrintWriter out)
  {
    n = in.nextInt();
    a = new int[n];
    l = new int[n+1];
    r = new int[n+1];
    for (int i = 0; i < n; i++)
      a[i] = in.nextInt();
    for (int i = 1; i <= n; i++)
      l[i] = gcd(a[i-1], l[i-1]);
   	for (int i = n-1; i >= 0; i--)
      r[i] = gcd(a[i], r[i+1]);
    for (int i = 0; i < n; i++)
      max = Math.max(max, gcd(l[i], r[i+1]));
    out.println(max);
  }
  
  int gcd(int a, int b)
  {
    return b == 0 ? a : gcd(b, a%b);
  }
  
  public static void main(String[] args)
  {
	Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main(in, out);
    out.close();
  }
}


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

int main(void){
    ll N;
    cin>>N;
    vector<ll> capa(5);
    for(int i=0;i<5;i++) cin>>capa.at(i);
    sort(capa.begin(),capa.end());
    if(N%capa.at(0)==0) cout<<4+N/capa.at(0)<<endl;
    else cout<<5+N/capa.at(0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100001][4];
int n;
ll dp[100001][4];
ll cal(int i,int j)
{
    if(i>n)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    ll ans=-1000000000;
    if(j==1)
    ans=max(ans,max(cal(i+1,2)+a[i][j],cal(i+1,3)+a[i][j]));
    else if(j==2)
    ans=max(ans,max(cal(i+1,3)+a[i][j],cal(i+1,1)+a[i][j]));
    else if(j==3)
    ans=max(ans,max(cal(i+1,2)+a[i][j],cal(i+1,1)+a[i][j]));
    dp[i][j]=ans;
    return ans;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i][1]>>a[i][2]>>a[i][3];
    memset(dp,-1,sizeof(dp));
    ll ans=-100000000;
    for(int i=1;i<=3;i++)
    ans=max(ans,cal(1,i));
    cout<<ans;
}



Measured memory_bytes: 11136
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		int ans = 0;

		if ( a > b) {
			ans += b;
		} else {
			ans += a;
		}

		if ( c > d) {
			ans += d;
		} else {
			ans += c;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 22228
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

ll gcd(ll x, ll y)
{
    while (y > 0)
    {
        ll tmp = y;
        y = x % y;
        x = tmp;
    }
    return x;
}

// 最大公約数か0( )
int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;

    if (n >= k)
    {
        cout << min(n % k, abs(n % k - k)) << endl;
    }
    else
    {
        cout << min(n, abs(n - k)) << endl;
    }
}

Measured memory_bytes: 256
def main():
    x, k, d = list(map(int, input().split(" ")))
    dk = d*k
    if abs(x) < dk:
        div_count = abs(x)//d
        if (k - div_count)%2==0:
            ans = abs(x)%d
        else:
            ans = d - abs(x)%d
    else:
        ans = abs(dk - abs(x))
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 9164
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	#N = int(input())
	X, A = map(int, input().split(" "))

	if X < A:
		print(0)
	else:
		print(10)



if __name__ == "__main__":
	main()

Measured memory_bytes: 6120
def main():
    s = input()
    length = len(s)
    ans = 0

    #'+'の追加位置を示すビットパターンpt 0~2^(n-1)-1
    for pt in range(2**(length-1)):
        plus_num = 0
        s_tmp = s
        num =[]

        for i in range(length-1):
            if (pt >> i)&1 :
                s_tmp = s_tmp[:i+1+plus_num] + '+' + s_tmp[i+1+plus_num:]
                #+を追加したぶんのズレ
                plus_num += 1
        
        num = s_tmp.split('+')
        for i in num:
            ans += int(i)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {

	int r=0,c=0,i=0,j=0,k=0,l=0,m=0;

	scanf("%d%d",&r,&c);

	int a[r][c],b[c];

	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
		}
	}

	for(i=0;i<r;i++){
		l=0;
		for(j=0;j<c;j++){
			printf("%d ",a[i][j]);
			l=l+a[i][j];
		}
		printf("%d\n",l);
	}
	
	for(i=0;i<c;i++){
		l=0;
		for(j=0;j<r;j++){
			l=l+a[j][i];
			k=k+a[j][i];
		}
		printf("%d ",l);
	}
	
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
#define MAX 100
using namespace std;

int map[MAX+2][MAX+2];
bool check[MAX+2][MAX+2];
int dx[4] = { -1,1,0,0};
int dy[4] = { 0,0,-1,1};

int main () {

  while ( true ) {

    queue<int> next;

    while( !next.empty() ) {
      next.pop();
    }
    
    int w,h;
    cin >> w >> h ;

    if ( w == 0 )
      break;

    int xs,ys;
    cin >> xs >> ys;
    
    int xg, yg;
    cin >> xg >> yg;

    int n;
    cin >> n;

    int c,d,x,y;

    for ( int i=0; i<MAX+2; i++ ) {
      for ( int j=0; j<MAX+2; j++ ) {
	map[i][j] = 0;
	check[i][j] = true;
      }
    }

    for ( int i=0; i<n; i++ ) {
      cin >> c >> d >> x >> y;
      
      //int count = 0;
      for ( int j=0; j<2; j++ ) {
	for ( int k=0; k<4; k++ ) {
	  //cout << count;
	  if ( d == 0 ) {
	    map[y+j][x+k] = c;
	  } else {
	    map[y+k][x+j] = c;
	  }
	}
      }
      //cout << endl;
    }

    next.push(ys*1000 + xs );

    int point;
    bool goal = false;

    int sc = map[ys][xs];

    /*
      for ( int i=0; i<=h; i++ ) {
      for ( int j=0; j<=w; j++ ) {
      cout << map[i+1][j+1];
      }
      cout << endl;
      }
      cout << endl;
    */
    int xn,yn;
    if ( map[yg][xg] == sc ) {
	while ( !next.empty() ) {
	  point = next.front();
	  next.pop();
	  xn = point%1000;
	  yn = point/1000;

	  if (map[yn][xn] == 0 )
	    continue;

	  if (point == yg*1000+xg) {
	    goal = true;
	    break;
	  }

	  for ( int i=0; i<4; i++ ) {
	    if ( check[yn+dy[i]][xn+dx[i]] ) {
	      check[yn+dy[i]][xn+dx[i]] = false;
	      if ( map[yn+dy[i]][xn+dx[i]] == sc ) {
		next.push((yn+dy[i])*1000+ xn +dx[i]);
	      }
	    }
	  }
	}

    }

    if ( goal )
      cout << "OK\n";
    else
      cout << "NG\n";
  }
}
    
      
      

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

int main() {
  int n, a[110];
  cin >> n;
  for (int i=0;i<n;i++)
    cin >> a[i];

  for (int i=n-1;i>0;i--)
    cout << a[i] << " ";
  cout << a[0];
  cout << endl;
}



Measured memory_bytes: 3072
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------

signed main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	int s = 0;
	rep(i, n)s ^= a[i];
	int ans = s;
	rep(i, n)a[i] &= ~s;
	int r = 0;
	vector<int>top(n);
	for (int i = 60; i >= 0; i--) {
		int j = r;
		for (; j < n; j++) {
			if (a[j] >> i & 1) {
				swap(a[r], a[j]);
				break;
			}
		}
		if (j == n) continue;
		top[r] = i;
		rep(k, n) {
			if (r == k) continue;
			if (a[k] >> i & 1) a[k] ^= a[r];
		}
		r++;
	}
	int x = 0;
	for (int i = 60; i >= 0; i--) {
		int nx = x | (1ll << i);
		int b = nx;
		rep(j, r) {
			if (b >> top[j] & 1) b ^= a[j];
		}
		if ((b & nx) == 0) x = nx;
	}
	ans += x * 2;
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String order = s.nextLine();
    int cost = 700;
    for(int i = 0; i < 3 ; i++)
      if(order.charAt(i) == 'o')cost += 100;
    System.out.printf("%d",cost);
  }
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

string s, t;
ll n, m;
int used[ 30 ];
int used1[ 30 ];
vi place[ 30 ];
vi places[ 30 ];

ll binary( ll pl, int x )
{
	ll lo = 0, hi = places[ x ].size() - 1;
	ll ans = -1;
	while ( lo <= hi )
	{
		ll mid = lo + ( hi - lo ) / 2;
		if ( places[ x ][ mid ] > pl )
		{
			hi = mid - 1;
			ans = ( ll )places[ x ][ mid ];
		}
		else
		{
			lo = mid + 1;
		}
	}
	
	return ans;
}

int main()
{
	cin >> s >> t;
	n = s.size();
	m = t.size();
	
	FOR( i, 0, n )
	{
		used[ ( int )s[ i ] - 97 ]++;
		places[ ( int )s[ i ] - 97 ].pb( i );
	}
	FOR( i, 0, m )
	{
		if ( !used[ ( int )t[ i ] - 97 ] )
		{
			cout << "-1\n";return 0;
		}
		used1[ ( int )t[ i ] - 97 ]++;
		place[ ( int )t[ i ] - 97 ].pb( i );
	}
	
	/*FOR( i, 0, 26 )
	{
		cout << ( char )( i + 97 ) << ' ';
		FOR( j, 0, ( int )places[ i ].size() )
			cout << places[ i ][ j ] << ' ';
		cout << "\n";
	}*/
	
	vector < ll > v;
	ll pos = -1, q = 0;
	FOR( i, 0, m )
	{
		int x = ( int )t[ i ] - 97;
		
		ll npos = binary( pos, x );
		if ( npos == -1 )
			npos = places[ x ][ 0 ];
		//cout << npos << "\n";
		v.pb( npos );
		//cout << pos << ' ' << npos << "\n";
		if ( pos >= npos )
			q++;
		pos = npos;
	}
	/*
	FOR( i, 0, m )
		cout << v[ i ] << ' ';
	cout << "\n";
	*/
	//cout << q << "\n";
	cout << q * ( ll )n + ( ll )v[ m - 1 ] + 1 << "\n";
	return 0;
}


Measured memory_bytes: 3004
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < b.size(); i++) {
		if (a == b) {
			cout << "Yes" << endl;
			return 0;
		}
		char c = b[0];
		b.erase(0, 1);
		b += c;
	}
	if (a == b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
dp = [0,abs(a[0]-a[1])]
for i in range(2,N):
  dp.append(min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2])))
print(dp[N-1])

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

int main()
{

    int a,b,h,m;
    cin>>a>>b>>h>>m;


    long double x1,y1,th1;
    th1 = h*30+0.5*m;
    x1 = a*sin(th1/360.0*2.0*M_PI);
    y1 = a*cos(th1/360.0*2.0*M_PI);

    long double x2,y2,th2;
    th2 = m*6.0;
    x2 = b*sin(th2/360.0*2.0*M_PI);
    y2 = b*cos(th2/360.0*2.0*M_PI);


    
        cout << fixed << setprecision(15) <<sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))<<endl;
    

    return 0;
}


Measured memory_bytes: 4160
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <iomanip>
typedef long long ll;
using namespace std;

    vector<ll>a(5005);
    vector<ll>b(5005);
    vector<ll>track;
    bool vis[5005];
 

 void dfs(int u , long long total_cycle){
        if(vis[u]) return ;
        vis[u]=true;
        total_cycle+=b[u];
        track.push_back(total_cycle);
        dfs(a[u],total_cycle);
    }


    void solve(){
        int n,k;
        cin>>n>>k;
        for(int i=0;i<n;i++){
            cin>>a[i];
            a[i]--;
        }
        for(int i=0;i<n;i++)
            cin>>b[i];
        ll ans=-(1e18);
        for(int i=0;i<n;i++){
            memset(vis,false,sizeof(vis));
            dfs(i,0);
            if(track.back()>0 && k>=(int)(track.size())){
                ll cycles=(ll)(k/(int)track.size());
                ll left=(ll)(k%(int)track.size());
                ll maxi=-1e18;
                for(int x=0;x<(int)track.size();x++)
                    maxi=max(maxi,track[x]);
                ans=max(ans,(cycles-1LL)*(track.back())+maxi);
                maxi=-1e18;
                for(int x=0;x<left;x++)
                    maxi=max(maxi,track[x]);
                ans=max(ans,(cycles*track.back()) + maxi);
            }
            else{
                for(int j=0;j<(min((int)track.size(),k));j++){
                    ans=max(ans,track[j]);
                }
            }
            track.clear();
        }
        cout<<ans;
        return;
    }
int main()
{

	ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
		//freopen("in.txt","r",stdin);
        int t=1;
        // cin>>t;
            solve();

	return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,c1=0,c2=0,i;
    cin>>n;
    ll a[n];
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        if (a[i]%4==0)
            c1++;
        else if (a[i]%2==0)
            c2++;
    }
    if (c1>=n/2 || 2*c1+c2>=n)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
ll ans;
struct DSU{
    int par[max_n];
    bool have[max_n];
    void init(int n){
        for(int i=1;i<=n;i++)par[i]=i,have[i]=false;
    }
    int findpar(int x){
        return x==par[x]?x:par[x]=findpar(par[x]);
    }
    void unite(int x,int y,int w){
        x=findpar(x),y=findpar(y);
        if(x!=y){
            if(have[x]&&have[y])return;
            par[x]=y,have[y]=have[x]|have[y];
            ans+=w;
        }
        else{
            if(have[x])return;
            else{
                have[x]=true;
                ans+=w;
            }
        }
    }
}D;
struct edge{
    int u,v,w;
    bool operator <(edge p){
        return w>p.w;
    }
}e[max_n];
int n,h,w;
int main(){
    scanf("%d%d%d",&n,&h,&w);
    D.init(h+w);
    for(int i=1;i<=n;i++)scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
    sort(e+1,e+n+1);
    ans=0;
    for(int i=1;i<=n;i++){
        int u=e[i].u,v=e[i].v+h,c=e[i].w;
        D.unite(u,v,c);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
long long N,A,B,C,D,ans;
//定义
void AC(long long Q,long long W,long long E,long long R,long long T)
//一定要long long!!!
{
    long long X=min(min(4*Q,2*W),E);
    //公式1
    long long Y=min(X*T,(T/2*R+T%2*X));
    //公式2
    cout<<Y<<"\n";
    //输出
} 
int main()
{
    scanf("%d%d%d%d%d",&A,&B,&C,&D,&N);
    //输入
    AC(A,B,C,D,N);
    //进入函数中
    return 0;
}

Measured memory_bytes: 256
import sys
S = input()
T = input()

if not ( len(S) == 3 and len(T) == 3 ): sys.exit()
if not ( ('S' in S or 'C' in S or 'R' in S) and ('S' in T or 'C' in T or 'R' in T)):
    sys.exit()

count = 0
for s in range(len(S)):
    if S[s] == T[s]: count += 1

print(count)

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

int main(){
    long long a[100] = {};
    a[0] = 2;
    a[1] = 1;

    for(int i = 2; i < 100; i++){
        a[i] = a[i-1] + a[i-2];
    }
    int n; cin >> n;
    cout << a[n] << endl;
}


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

const int N = 1e5 + 5;
string s;

int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};


using ll = long long;
ll quick_pow(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}


modular dp[N][2];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s;
    
    s = '#' +s;
    int len = s.length();
    
    dp[0][0] = 0; // less
    dp[0][1] = 1; // not less
    for (int i = 1; i < len; i++){
        if(s[i] == '1'){
            dp[i][0] = 3 * dp[i-1][0] + dp[i-1][1];
            dp[i][1] = dp[i-1][1]*2;
        }else{
            dp[i][0] = dp[i-1][0]*3;
            dp[i][1] = dp[i-1][1];
        }
    }
    
    cout<<dp[len-1][0] + dp[len-1][1]<<endl;
    

    
    
    
    
    return 0;
}



Measured memory_bytes: 1280
#import <bits/stdc++.h>
using namespace std;typedef long long ll;
#define rp(i,n) for(ll i=0;i<n;++i)
int main(){ll n;cin>>n;vector<ll> v(99);for(char c='A';c<='C';++c)cin>>v[c];vector<string> s(n);rp(i,n)cin>>s[i];vector<char>a(n);rp(i,n){char x=s[i][0],y=s[i][1],M=(v[x]>=v[y]?x:y),m=x^y^M;if(v[x]==v[y]&&i+1<n&&(s[i+1][0]==x||s[i+1][1]==x))swap(M,m);if(v[M]==0){puts("No");return 0;}v[M]--,v[m]++;a[i]=m;}puts("Yes");rp(i,n)cout<<a[i]<<endl;}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

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

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

typedef long long ll;

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

	std::map<std::string, ll> m = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0},};
	std::string judge[4] = {"AC", "WA", "TLE", "RE"};

	for(int i=0; i<n; i++){
		std::string s;
		std::cin >> s;
		m[s]++;
	}

	for(int i=0; i<4; i++){
		std::cout << judge[i] << " x "<< m[judge[i]] << std::endl;
	}

	return 0;
}

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

int n, height;
long long ans;
unordered_map <int,int> pairOne;

int main() {
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> height;
        if (pairOne.count(i - height))
            ans += pairOne[i - height];
        pairOne[i + height]++ ;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 11472