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

int main() {
  ll n,ans;
  cin >> n;
  ll m = 0,a = 0,r = 0,c = 0,h = 0;
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    if(s[0] == 'M') m++;
    if(s[0] == 'A') a++;
    if(s[0] == 'R') r++;
    if(s[0] == 'C') c++;
    if(s[0] == 'H') h++;
  }
  ans = m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
  cout << ans << endl;
}


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

const int INF = (1LL << 31) - 1;
vector<int> v;

struct DelaySegmentTree {
  int n;
  vector<int> node,delay;
  vector<bool> delayflag;

  // 元配列 v をセグメント木で表現する
  void init(){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,INF);
    delay.resize(2*n-1,INF);
    delayflag.resize(2*n-1,false);

    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = min(node[2*i+1],node[2*i+2]);
  }

  void eval(int k,int l,int r){
    if(delayflag[k]){
      node[k] = delay[k];
      if(r-l > 1){
        delay[2*k+1] = delay[k];
        delayflag[2*k+1] = true;
        delay[2*k+2] = delay[k];
        delayflag[2*k+2] = true;
      }
      delayflag[k] = false;
    }
  }

  void update(int a,int b,int x){ update(a,b,x,0,0,n); }
  void update(int a,int b,int x,int k,int l,int r){
    eval(k,l,r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay[k] = x;
      delayflag[k] = true;
      eval(k,l,r);
    }
    else {
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      node[k] = min(node[2*k+1],node[2*k+2]);
    }
  }

  int getmin(int a,int b){ return getmin(a,b,0,0,n); }
  int getmin(int a,int b,int k,int l,int r){
    //区間 [a, b) 中の要素の最小値を返す
    eval(k,l,r);
    if(b <= l || r <= a) return INF;
    if(a <= l && r <= b) return node[k];
    int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
}seg;

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

  int n,q; cin >> n >> q;
  v.resize(n,INF);
  seg.init();
  for(int i = 0; i < q; i++){
    int com,s,t,x; cin >> com;
    if(com){
      cin >> s >> t;
      cout << seg.getmin(s,t+1) << endl;
    }
    else {
      cin >> s >> t >> x;
      seg.update(s,t+1,x);
    }
  }

  return 0;
}



Measured memory_bytes: 8024
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int dp[31];
  dp[0] = dp[1] = 1;
  dp[2] = 2;
  for(int i = 3; i <= 30; i++) {
    dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    // fprintf(stderr, "dp[%d] = %d\n", i, dp[i]);
  }
  for(int tci = 0; ; tci++) {
    int n; scanf("%d", &n); if(n==0) break;
    printf("%d\n", dp[n]/3650+!!(dp[n]%3650));
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <math.h>

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int a, b, c, A[10000], B[10000], C[10000], e[100][100];
string s, t, r;


int main(){
	int d;
	cin >> a >> b >> c >>d;
	if((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 888
n,a,b = map(int,input().split())
S = input()
now = 0
kai = 0
for s in S:
    if s == "a" and now < (a+b):
        print("Yes")
        now += 1
    elif s == "b" and now < (a+b) and kai < b:
        print("Yes")
        now += 1
        kai += 1
    else:
        print("No")

Measured memory_bytes: 53592
using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var costs = new int[M + 1];
            var opens = new int[M + 1];
            for (int i = 1; i < M + 1; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                costs[i] = ab[0];
                var c = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                foreach (int op in c) opens[i] += 1 << (op - 1);
            }

            var DP = new int[M + 1, 1 << N];
            for (int i = 0; i < M + 1; i++) for (int j = 0; j < (1 << N); j++) DP[i, j] = int.MaxValue;
            DP[0, 0] = 0;
            for (int key = 0; key < M; key++)
            {
                for (int open = 0; open < (1 << N); open++)
                {
                    if (DP[key, open] == int.MaxValue) continue;
                    DP[key + 1, open] = Math.Min(DP[key + 1, open], DP[key, open]);
                    DP[key + 1, open | opens[key + 1]] = Math.Min(DP[key + 1, open | opens[key + 1]], DP[key, open] + costs[key + 1]);
                }
            }
            Console.WriteLine(DP[M, (1 << N) - 1] != int.MaxValue ? DP[M, (1 << N) - 1] : -1);
        }
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string str; cin >> str;
    bool okC = false, okF = false;

    for (char chr : str)
        if (chr == 'C')
            okC = true;
        else if (chr == 'F' && okC)
            okF = true;

    cout << (okF ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,A,B,C,X;
int Y[100];

int solve(){
  int res=0,p=0;
  while(1){
    if(Y[p]==X)p++;
    if(p==N)return res;
    res++;
    X=(A*X+B)%C;
    if(res>10000)return -1;
  }
  return res;
}

int main(){
  while(1){
    cin>>N>>A>>B>>C>>X;
    if(N==0&&B==0&&C==0&&X==0)break;
    for(int i=0;i<N;i++)cin>>Y[i];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, takahashi = 0, aoki = 0;
    cin >> N;
    vector<tuple<int64_t, int64_t, int64_t>> SAB(N);
    for (int i = 0; i < N; i++) {
        cin >> get<1>(SAB.at(i)) >> get<2>(SAB.at(i));
        get<0>(SAB.at(i)) = get<1>(SAB.at(i)) + get<2>(SAB.at(i));
    }
    sort(rALL(SAB));
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            takahashi += get<1>(SAB.at(i));
        }
        else {
            aoki += get<2>(SAB.at(i));
        }
    }
    cout << takahashi - aoki << endl;


}


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

int main(){
  ll n,x,y,a,b,c,d,e,i,j;
  cin  >> n >> x >> y;
  ll z[n+1][n+1],ans[n+1];
  a=min(x,y);
  b=max(x,y);
  for(i=0;i<=n;i++)ans[i]=0;
  for(i=1;i<n;i++){
    for(j=i+1;j<=n;j++){
      c=j-i;
      d=abs(a-i)+abs(b-j)+1;
      e=min(c,d);
      ans[e]+=1;
    }
  }
  for(i=1;i<n;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>

using namespace std;

int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);

    int s,t;
    s = n * a;
    t = b;

    if (s >= t) {
        printf("%d\n", t);
    } else {
        printf("%d\n", s);
    }
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  cout<<"ABC"<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 1e5 + 7;

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

    return 0;
}


Measured memory_bytes: 5748
def main():
    n = input()

    a_s = list(map(int, input().split()))

    ans = 10 ** 20
    for i in [-1, 1]:
        total = 0
        op_num = 0

        for a_i in a_s:
            total += a_i

            if total * i <= 0:
                op_num += abs(total - i)
                total = i
            
            i *= -1

        ans = min(ans, op_num)
    print(ans)
    

main()        
    




Measured memory_bytes: 63216
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<bool> check(n);
    vector<int> penalty(n);
    int ans1=0,ans2=0;
    for(int i=0; i<m; i++){
        int p;
        string s;
        cin>>p>>s;
        p-=1;
        if(s=="AC"){
            if(!check[p]) ans1+=1;
            check[p]=true;
        }
        else if(!check[p]) penalty[p]+=1;
    }
    for(int i=0; i<n; i++) if(check[i]) ans2+=penalty[i];
    cout<<ans1<<" "<<ans2;
    return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    c = c-b;
    if(c<=0){
      cout<<"Yes"<<endl;
      break;
    }
    a = a-d;
    if(a<=0){
      cout<<"No"<<endl;
      break;
    }
  }
}

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

int32_t main() { 
   int h1,m1,h2,m2,k;
   cin>>h1>>m1>>h2>>m2>>k;
   m1 = h1*60 + m1;
   m2 = h2*60 + m2;
   int ans = m2 - m1 - k;
   cout<<ans<<endl;
}  

Measured memory_bytes: 3612
#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 ll long long
#define int long long 
#define MAX 1e5+5
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);

}


 
int32_t main()
{
 c_p_c();
 int n;
 cin>>n;
 map<pair<int,int>,int>cnt;
 for(int i=0;i<n;i++){
    double x;
    cin>>x;
    int l=round(x*1e9);
    int two = 0, five = 0;
        while(l % 2 == 0) {
            two++;
            l /= 2;
        }
        while(l % 5 == 0) {
            five++;
            l /= 5;
        }
        ++cnt[{two,five}];

 }
 int ans=0;
 for(auto p:cnt){
  for(auto pp:cnt){
    if(p.first.first+pp.first.first>=18 && pp.first.second+p.first.second>=18){
      if(p<pp){
        ans+=p.second*pp.second;
      }
      else if(p==pp){
        ans+=(p.second)*(p.second-1)/2;
      }
    }
  }
 }
 cout<<ans<<"\n";



 
 

 
return 0;
}

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

#define MAX_A   10000

int get_g(int i, vector<int> &grp) {
    if (i==grp.at(i)) return i;
    return get_g(grp.at(i), grp);
}

int main() {
    int N;
    cin >>N;
    vector<int> w(N+1, 0);
    vector<vector<int>> ww={{-1, 0}};
    for (int i=1; i<=N; i++) {
        int W=0;
        cin >>W;
        w.at(i)=W;
        ww.push_back({W, i});
    }
    sort(ww.begin()+1, ww.end());
    int MIN=ww.at(1).at(0);
    // Data store
    // grp: Group#
    // grp_depth: Steps to the group root
    vector<int> grp(N+1, 0);
    vector<int> grp_depth(N+1, 0);
    // Initialize group# as each own
    for (int i=1; i<=N; i++) {
        grp.at(i)=i;
    }
    // Grouping
    for (int i=1; i<=N; i++) {
        int xx=i;
        int yy=ww.at(i).at(1);
        xx=get_g(xx, grp);
        yy=get_g(yy, grp);
        // Already in same group, do nothing
        if (xx==yy) continue;
        // Put into one group
        if (grp_depth.at(xx)==grp_depth.at(yy)) {
            // Groups have same height
            // Merge into less-number-group
            grp.at(max(xx, yy)) = get_g(min(xx, yy), grp);
            grp_depth.at(min(xx, yy))++;
        } else if (grp_depth.at(xx)>grp_depth.at(yy)) {
            // x is higher
            // Merge into x so that the hight will not increase
            // (height for y will be +1)
            grp.at(yy) = xx;
        } else
            // y is higher
            // Merget into y
            grp.at(xx) = yy;
    }
    vector<vector<int>> G(N+1);
    for (int i=1; i<=N; i++)
        G.at(get_g(i, grp)).push_back(w.at(i));
    int S=0;
    for (int i=1; i<=N; i++) {
        if (1<G.at(i).size()) {
            int M=10001;
            int SS=0;
            for (int j=0; j<G.at(i).size(); j++) {
                SS +=G.at(i).at(j);
                M=min(M, G.at(i).at(j));
            }
            S +=min(SS+M*(G.at(i).size()-2), SS+M+MIN*(G.at(i).size()+1));
        }
    }
    cout <<S <<endl;
    return 0;
}


Measured memory_bytes: 3296
#include<iostream>
using namespace std;
main()
{
	while(0);
	
	int n;
	cin>>n;
	for(int i=0;i<n;i+=1){
		int x,y,b,p,ans,ano,t=5,s=2;
		cin>>x>>y>>b>>p;
		if(b>t)t=b;
		if(p>s)s=p;
		ans=x*b+y*p;
		ano=4*(x*t+y*s)/5;
		if(ans>ano)ans=ano;
		
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
N, M = map(int, input().split())
A = [list(reversed(list(map(int, input().split())))) for _ in range(N)]

res = N
removed = [0 for _ in range(M)]

while not all(removed):
    S = [0 for _ in range(M)]
    for a in A:
        S[a[-1] - 1] += 1
    res = min(res, max(S))
    x = S.index(max(S))
    removed[x] = 1
    for a in A:
        while a and removed[a[-1] - 1]:
            a.pop()

print(res)

Measured memory_bytes: 43996
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
using namespace std;
int main(void){
    string words[3];
    for(int i=0; i<3; i++){
        cin >> words[i];
        transform(words[i].begin(), words[i].end(), words[i].begin(), ::toupper);
        cout << words[i][0];
    }
}

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

int main() {
  string s, t;
  cin >> s >> t;

  int n = s.size();
  int m = t.size();

  vector<vector<int>> dp(n + 1, vector<int>(m + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  string ans = "";
  while (n > 0 && m > 0) {
    if (dp[n][m] == dp[n - 1][m]) {
      // (i-1,j) -> (i,j) と更新された
      n--;
    } else if (dp[n][m] == dp[n][m - 1]) {
      // (i,j-1) -> (i,j) と更新された
      m--;
    } else {
      n--;
      m--;
      ans += s[n];
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp(a, b) make_pair(a, b)
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const lli mod_ = 998244353;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int n;
int heights[100005];
lli dp[100005];

int main() {
	// ifstream cin("input.in");
	// ofstream cout("output.out");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	
	for(int i = 0; i < n; i++)
		cin >> heights[i];
	dp[1] = abs(heights[1]-heights[0]);
	
	for(int i = 2; i < n; i++)
		dp[i] = min(dp[i-1] + abs(heights[i]-heights[i-1]), dp[i-2] + abs(heights[i]-heights[i-2]));
		
	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int
main (void)
{
  int n, m;
  m = 100000;
  scanf ("%d", &n);
  for (; n > 0; n--)
    m = (double) (ceil (((double) m + (double) m * 0.05) / 1000) * 1000);
  printf ("%d\n", m);
  return 0;
}

Measured memory_bytes: 596
//Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=5e18; 
const long long mod=1e9+7; 
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
LL xx[80],yy[80];
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
    LL n,kk;
    cin>>n>>kk;
    vector<pair<LL,LL> >p;
    for(int i=0;i<n;i++){
        cin>>xx[i]>>yy[i];
        p.push_back(make_pair(xx[i],yy[i]));
    }
    LL ans=5e18;
    sort(xx,xx+n);
    sort(yy,yy+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<n;k++){
                for(int l=k+1;l<n;l++){
                    LL x1=xx[i];
                    LL x2=xx[j];
                    LL y1=yy[k];
                    LL y2=yy[l];
                    LL ct=0;
                    for(int b=0;b<n;b++){
                        LL X=p[b].first,Y=p[b].second;
                        if(X>=x1&&X<=x2&&Y>=y1&&Y<=y2) ct++;
                    }
                    if(ct>=kk) ans=min(ans,(y2-y1)*(x2-x1));
                }
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).ok();
    return word.trim().to_owned();
}

fn main() {
    let (n, m) = {
        let line = get_input();
        let mut split_line = line.split_whitespace();
        let n:u32 = split_line.next().unwrap().parse().unwrap();
        let m:u32 = split_line.next().unwrap().parse().unwrap();
        (n,m)
    };

    let mut l:Vec<u32> = Vec::new();
    let mut r:Vec<u32> = Vec::new();

    for _i in 0..m {
        let (li, ri) = {
            let line = get_input();
            let mut split_line = line.split_whitespace();
            let l:u32 = split_line.next().unwrap().parse().unwrap();
            let r:u32 = split_line.next().unwrap().parse().unwrap();
            (l-1,r-1)
        };
        l.push(li);
        r.push(ri);
    }

    let mut lo = 0;
    let mut ro = n - 1;

    for i in 0..m {
        lo = std::cmp::max(lo, l[i as usize]);
        ro = std::cmp::min(ro, r[i as usize]);
    }

    let ans = if lo <= ro { ro - lo + 1 } else { 0 };

    println!("{}", ans);
}


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

int main() {
    //
    int num;
    string str;
    vector<string> vec(26);
    vec = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
           "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

    cin >> num >> str;

    for (int i = 0; i < str.size(); i++){
        int tmp =  str.at(i) - 'A';
        if (tmp+num < 26) cout << vec.at(tmp + num);
        else cout << vec.at((tmp+num) - 26);
    }
    //
}


Measured memory_bytes: 3552
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
 
auto& in = std::cin;
auto& out = std::cout;
 
int32_t N;
int32_t ARR[300000];
int64_t MAX[112345];//[N-1,2N][0,N+1]
int64_t MIN[112345];//[N-1,2N]
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
 
	in >> N;
	for (size_t i = 0; i < 3*N; i++)
	{
		in >> ARR[i];
	}
	//std::sort(ARR, ARR + N);
	//std::sort(ARR+2*N-1, ARR + 3*N);
 
	//前を最大化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(-ARR[i]);
			sum += ARR[i];
		}
		MAX[0] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(-ARR[N+i]);
			sum += ARR[N+i];
			sum += que.top(); que.pop();
			MAX[i+1] = sum;
		}
	}
	//後ろを最小化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(ARR[3*N-1-i]);
			sum += ARR[3*N-1-i];
		}
		MIN[N+1] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(ARR[2*N-1 - i]);
			sum += ARR[2*N-1 - i];
			sum -= que.top(); que.pop();
			MIN[N-i] = sum;
		}
	}
	//[N-1,2N]を処理
	int64_t max_value = (-9223372036854775807);
	for (int32_t i = 0; i <= N; i++)
	{
		max_value = std::max(max_value, MAX[i] - MIN[i+1]);
	}
	std::cout << max_value << std::endl;
	return 0;
}
#endif

Measured memory_bytes: 3952
#include <iostream> 
using namespace std;
int main()
{
	int a; cin>>a;
	int b=a%100;
	a/=100;
	if(a>0 and a<13 and b>0 and b<13) cout<<"AMBIGUOUS";
	else if(a==0 and b==0 or b==0 and b>12 or a>12 and b==0 or a>12 and b>12) cout<<"NA";
	else if(a>0 and a<13) cout<<"MMYY";
	else cout<<"YYMM";
}






Measured memory_bytes: 3100
s = input()
if s[0] == s[1]:
    if s[2] == s[3] and s[0] !=s[2]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[2]:
    if s[1] == s[3] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[3]:
    if s[1] == s[2] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
# https://atcoder.jp/contests/arc081/tasks/arc081_a
N = int(input())
A = list(map(int, input().split()))

# まずは使える辺の長さを抽出
from collections import Counter
A_cnt = Counter(A)
candi = []
for k, v in A_cnt.items():
    if v >= 4:
        candi.extend([k, k])
    if v >= 2:
        candi.append(k)
if len(candi) < 2:
    print(0)
    exit()
A_ls = sorted(candi, reverse=True)
print(A_ls[0] * A_ls[1])


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

int main() {
    ld a, b, x;
    cin >> a >> b >> x;
    ld y = a*a*b - x;
    ld Sx=x/a, Sy=y/a;
    ld Sj = a*b/2;
    ld ans;
    ld pi = 3.14159265358979323846;
    if (Sy <= Sj) {
        ld p = (2*Sy)/(a*a);
        ans = atan(p);
    }
    else {
        ld p = (b*b)/(2*Sx);
        ans = atan(p);
    }
    // ans = atan((2*Sy)/(a*a));
    ans *= 180/pi;

    cout << fixed << setprecision(8);
    cout << ans << endl;
}

Measured memory_bytes: 3852
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
d=[[1,0],[0,1]]
def dfs(x,y):
    a[x][y]="."
    for i in d:
        if 0<=x+i[0]<h and 0<=y+i[1]<w and a[x+i[0]][y+i[1]]=="#":
            dfs(x+i[0],y+i[1])
            break
dfs(0,0)
# for i in range(h):
#     print(a[i])
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            print("Impossible")
            exit()
print("Possible")


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

int main() {
	int P, Q, R;
	cin >> P >> Q >> R;
	int A = P + Q;
	int B = P + R;
	int C = Q + R;
	if (A <= B && B <= C)cout << A << endl;
	else if (A <= C && C <= B)cout << A << endl;
	else if (B <= A && A <= C)cout << B << endl;
	else if (B <= C && C <= A)cout << B << endl;
	else cout << C << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=505;
ll a[N][N],s1[N][N],s2[N][N],dp[N][N];
inline ll get(int a,int b,int c){return s2[c][a]-s2[b-1][a]-s1[b][c];}
int main(){
	int n,i,j,k;ll sum=0ll,w;
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		for(j=  1;j!=i;++j){scanf("%lld",&a[i][j]);sum+=a[i][j];}
		for(j=i+1;j<=n;++j){scanf("%lld",&a[i][j]);sum+=a[i][j];}
	}
	for(i=n;i   ;--i)for(j=i;j<=n;++j)s1[i][j]=s1[i+1][j]+s1[i][j-1]-s1[i+1][j-1]+a[i][j];
	for(i=1;i<=n;++i)for(j=n;j   ;--j)s2[i][j]=s2[i-1][j]+s2[i][j+1]-s2[i-1][j+1]+a[i][j];
	for(i=1;i<=n;++i)dp[1][i]=get(1,1,i);
	for(i=2;i<=n;++i)for(j=i;j<=n;++j){
		w=0ll;
//		for(k=1;k!=i;++k)printf("dp[%d][%d] %lld+%lld => dp[%d][%d]\n",k,i-1,dp[k][i-1],get(k,i,j),i,j);
		for(k=1;k!=i;++k)cmax(w,dp[k][i-1]+get(k,i,j));
		dp[i][j]=w;
	}
//	printf("S1\n");
//	for(i=1;i<=n;++i){for(j=1;j<=n;++j)printf("%lld ",s1[i][j]);printf("\n");}
//	printf("S2\n");
//	for(i=1;i<=n;++i){for(j=1;j<=n;++j)printf("%lld ",s2[i][j]);printf("\n");}
//	printf("DP\n");
//	for(i=1;i<=n;++i){for(j=1;j<=n;++j)printf("%lld ",dp[i][j]);printf("\n");}
	w=0ll;
	for(i=1;i<=n;++i)cmax(w,dp[i][n]);
	printf("%lld",sum-w);
	return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_bakc
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

const int MAXN=200001;
int par[MAXN], sz[MAXN];

void init() {
	memset(par, -1, sizeof par);
	for(int i=0;i<MAXN;++i) sz[i]=1;
}

int get(int x) {
	if(par[x]==-1) return x;
	return par[x]=get(par[x]);
}

void merge(int x, int y) {
	int px=get(x), py=get(y);
	
	if(px==py) return ;
	
	if(sz[px]>sz[py]) {
		swap(px, py);
		swap(x, y); //:) lyft
	}
	
	par[px]=py;
	sz[py]+=sz[px];
}


int main() {
	IO;
	int n,m;
	cin>>n>>m;
	init();
	for(int i=0;i<m;++i) {
		int a,b;
		cin>>a>>b;
		merge(a,b);
	}
	
	int ans=0;
	for(int i=1;i<=n;++i) {
		ans=max(ans, sz[get(i)]);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 5212
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#include <time.h>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
bool prime[100000];
int a[100004];
int vis[100005];
int main()
{
    int n;
    cin >> n;
    int ji = 0;
    ll sum = 0;
    for(int i = 1;; i++)
    {
        if(i%2 == 0 || i%3 == 0)
        {
            a[ji++] = i;
            sum += i;
            vis[i] = 1;
        }
        if(ji == n-1)break;
    }
    for(ll i = 1;; i++)
    {
        if(!vis[i] && __gcd(i, sum) != 1 && (sum+i)%2 == 0 && (sum+i)%3 == 0)
        {
            a[ji++] = i;
            break;
        }
    }
    for(int i = 0; i < ji; i++)
    cout << a[i] << ' ';
    cout << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int l, r, d; scanf("%d%d%d", &l, &r, &d);
  printf("%d", r/d-(l-1)/d);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3816
from fractions import Fraction

n = int(input())
a = list(map(int,input().split()))

b = 0
c = Fraction(0)

for i in range(n):
    b = Fraction(1, int(a[int(i)]))
    c = c + b

c = Fraction(c.denominator, c.numerator)


print(float(c))

Measured memory_bytes: 5308
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        //String s = stdIn.next();
        //boolean flag = false;
        //int a[] = new int[n];
        
        //for(int i = 0; i < n; i++){
        //    a[i] = stdIn.nextInt();
        //}
        
        //if(flag){
        System.out.println(a + a * a + a * a * a);
        //}else{
        //    System.out.println();
        //}
    }
}


Measured memory_bytes: 35612
#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 sum = 0;
    int p, N, K;
    vector<int> P;

    cin >> N >> K;

    for (int i = 0; i < N; i++)
    {
        cin >> p;
        P.push_back(p);
    }

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

    for (int i = 0; i < K; i++)
    {
        sum += P[i];
    }

    cout << sum << endl;

    return 0;
}


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

#define Ff(i,a,b) for(i=a;i<b;i++)
#define Fb(i,a,b) for(i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define mp make_pair
#define PI 2*asin(1)
#define all(x) x.begin(),x.end()
#define trav(x) for(auto& i:x)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define spc ' '

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<long long> vll;
typedef map<int, int> mi;
typedef map<long long, long long> mll;
typedef unordered_map<int, int> umi;
typedef unordered_map<long long, long long> umll;
typedef set<int> si;
typedef set<long long> sll;
typedef unordered_set<int> usi;
typedef unordered_set<long long> usll;

const ll N = 1e9 + 7;
#define int long long

void sub() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
}


void solve() {
	int n;
	cin >> n;
	int a[n];
	int i, j;
	int s = 0;
	Ff(i, 0, n)
	cin >> a[i];
	int g = 0;
	Ff(i, 0, n)
	g += a[i];
	Ff(i, 0, n - 1) {
		s = (s + (a[i] % N) * ((g - a[i]) % N)) % N;
		g -= a[i];
	}
	cout << s << endl;
}



int32_t main() {
	FIO
	sub();
	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}




Measured memory_bytes: 5120
judgeAlpha :: Char -> Char
judgeAlpha i
  | 'A' <= i && i <= 'Z' = 'A'
  | 'a' <= i && i <= 'z' = 'a'
  | otherwise ='$'

main :: IO ()
main = do
    c <- getChar
    let result = judgeAlpha c
    putChar result

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

namespace ITP1_10
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str_List = Console.ReadLine().Split(' ');
            double a = double.Parse(str_List[0]);     // ????????????1
            double b = double.Parse(str_List[1]);     // ????????????2
            double c = double.Parse(str_List[2]);     // ?§????

            // ?§???????????????¢????????????
            var sin = Math.Sin(c * (Math.PI / 180));
            var cos = Math.Cos(c * (Math.PI / 180));

            var S = (a * b * (double)sin) / 2;
            var L = a + b +  Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2) - (2 * a * b * cos) );
            var H = b * sin;

            Console.WriteLine(S);
            Console.WriteLine(L);
            Console.WriteLine(H);


            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 9500
#include <stdio.h>

int main(void) {
	int limit = 10000;
	int n[limit], x[limit], r[limit], count, m;
	for (count = 0; count < limit; count++) {
		scanf("%d %d", &n[count], & x[count]);
		if (n[count] == 0 && x[count] == 0) {
			break;
		}
	}
	for (int i = 0; i < count; i++) {
		r[i] = 0;
		if (6 <= x[i]) {
			for (int j = 1; j < n[i] - 1; j++) {
				for (int k = n[i]; k > j + 1; k--) {
					m = x[i] - k - j;
					if (m > j && m < k) {
						r[i]++;
					}
				}
			}
		}
	}
	for (int i = 0; i < count; i++) {
		printf("%d\n", r[i]);
	}
	return 0;
}



Measured memory_bytes: 2096
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	string ans = "AC";

	string n;
	cin >> n;

	if (n[0] != 'A') ans = "WA";

	int cnt = 0;
	for (int i = 2; i < n.size()-1; i++) {
		if (n[i] == 'C') cnt++;
	}
	if (cnt != 1) ans = "WA";

	for (int i = 0; i < n.size(); i++) {
		if (n[i] == 'A' || n[i] == 'C') continue;

		if (isupper(n[i])) {
			ans = "WA";
				break;
		}
	}


	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	int N, d;
	cin >> N;

	set<int> st;

	for (int i = 0; i < N; i++) {
		cin >> d;
		st.insert(d);
	}


	cout << st.size() << endl;


	//end = clock();
	//printf("%d msec.\n", end - start);
}


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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int k;
      k=Integer.parseInt(sc.next());

      if(k%2==0){
        System.out.println((k/2)*(k/2));
      }else{
        System.out.println((k/2)*(k/2+1));
      }
    
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 22868
#include<stdio.h>
#include<stdlib.h>
int main()
{
 int x,y,i,a[100000],fact=0;
 scanf("%d %d ",&x,&y);
for(i=1;i<=x;i++)
{
  scanf("%d",&a[i]);
}
for(i=1;i<=x;i++)
{
    if(a[i]>=y)
    {
        fact++;
    }
}
    printf("%d",fact);
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main(void) {
	int n;
	scanf("%d", &n);
	vector<double> v(n);
	for(auto&& e : v) {
		scanf("%lf", &e);
	}

	sort(ALL(v));

	double result = v.front();
	v.erase(v.begin());
	for(auto i = v.begin(); !v.empty();) {
		result = (result + *i) / 2;
		v.erase(i);
	}

	printf("%lf\n", result);
	return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> s(M);
    vector<int> c(M);
    vector<int> ans(N,-1);

    rep(i,M)
    {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    rep(i,M)
    {
        if( ans[s[i]] == c[i] || ans[s[i]] == -1 ) ans[s[i]] = c[i];
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }

    if( N == 1 && M == 0 )
    {
        cout << 0 << endl;
        return 0;
    }
    else if( ans[0] == 0 )
    {
        if( N==1 ) cout << 0 << endl;
        else cout << -1 << endl;
        return 0;
    }
    else if( ans[0] == -1 ) ans[0] = 1;


    rep(i,N)
    {
        if( ans[i] != -1 ) cout << ans[i];
        else cout << 0;
    }
    cout << endl;
}


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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

const int inf=INT_MAX/2-100;

int main(){
	int n=read(),m=read();
	vector<int> right(n,inf);
	for(int i=0;i<m;i++){
		int a=read()-1,b=read()-1;
		right[a]=min(right[a],b);
	}
	int nx=inf,ans=0;
	for(int i=0;i<n-1;i++){
		nx=min(nx,right[i]);
		if(i+1==nx){
			nx=inf;
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
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 A, P;
    cin >> A >> P;
    P += A * 3;
    cout << P / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int k = 0;
			k = values[a];
			values[a] = values[b];
			values[b] = k;
		}
		for (int i = 0; i < values.length; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 17192
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int N;
int A[8],B[8];
int now[8];
int Aans,Bans;
int use[9];
int cou=0;
void func(int depth){

    if(depth==N){
        int Aflu=1,Bflu=1;
        for(int i=0;i<N;i++){
            if(now[i]!=A[i])Aflu=0;
            if(now[i]!=B[i])Bflu=0;
        }
        if(Aflu==1)Aans=cou;
        if(Bflu==1)Bans=cou;
        cou++;
        return;
    }

    for(int i=1;i<=N;i++){

        if(use[i]==0){
            now[depth]=i;
            use[i]=1;
            func(depth+1);
            use[i]=0;
        }
    }
}
int main(){

    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];
    func(0);
    cout<<abs(Aans-Bans)<<endl;
    return 0;
}


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

int main() {

	ll n, k; cin >> n >> k;
	map<ll, ll> mp;
	for (ll i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		mp[a] += b;
	}
	ll cnt = 0;
	ll ans;
	for (auto u : mp) {
		cnt += u.second;
		if (k <= cnt) {
			ans = u.first;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b,c;
    int d;
    cin>>a>>b>>c;
    if(a>b){
        d=a;
        a=b;
        b=d;
    
    }
    if(b>c){
        d=b;
        b=c;
        c=d;
    }
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    
    cout<<a <<" "<< b <<" "<< c <<endl;
    
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;g
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll k;
    cin >> k;

    ll ans = 0;

    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {
                ans += gcd(i, gcd(j, l));
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define pai 3.14159265359
#define mod 1000000007

int main()
{
    long long int n, x;
    cin >> n >> x;
    x = min(x, n - x);
    long long int zyoge = n - x, sayu = x;
    long long int ans = 0;
    // cout << zyoge  << sayu << endl;
    for(int i = 0; (zyoge != 0 && sayu != 0); i++){
        if(i % 2 == 0){
            ans += 3 * (zyoge / sayu) * sayu;
            zyoge = zyoge % sayu;
        } else {
            ans += 3 * (sayu / zyoge) * zyoge;
            sayu = sayu % zyoge;
        }
        // cout << zyoge << " " << sayu << endl;
    }
    cout << ans << endl;
}

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

typedef struct {
  double x,y;
}P;

void koch(int n,P a,P b){
  if(n==0) return;
  P s,t,u;
  double th=M_PI/3;

  s.x=((2.0*a.x)+(1.0*b.x))/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)/2-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)/2+s.y;
  //if(s.x<0) s.x*=(-1.0);
  //if(s.y<0) s.y*=(-1.0);
  //if(t.x<0) t.x*=(-1.0);
  //if(t.y<0) t.y*=(-1.0);
  //if(u.x<0) u.x*=(-1.0);
  //if(u.y<0) u.y*=(-1.0);

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  P a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}



Measured memory_bytes: 2048
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n,C=map(int, input().split())
    d = [0] * C
    for i in range(C):
        d[i] = [int(j) for j in input().split()]
    c = [0] * n
    for i in range(n):
        c[i] = [int(j)-1 for j in input().split()]
    cost = [[0] * C for _ in range(3)]
    for x in range(n):
        for y in range(n):
            for target in range(C):
                cost[(x+y)%3][target] += d[c[x][y]][target]
    ans = 1e9
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if len({i, j, k}) < 3:
                    continue
                ans = min([ans, cost[0][i] + cost[1][j] + cost[2][k]])
    print(ans)

main()

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

int main()
{
    std::string yohou, tenki;
    std::cin >> yohou >> tenki;
    int match = 0;

    if (yohou[0] == tenki[0]) match += 1;
    if (yohou[1] == tenki[1]) match += 1;
    if (yohou[2] == tenki[2]) match += 1;
    std::cout << match << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long N, M;
	scanf("%lld %lld", &N, &M);
	if (N * 2 > M) printf("%lld\n", M / 2);
	else printf("%lld\n", (N * 2 + M) / 4);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128