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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  int n=6;
  int a[n];
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  int res=0;
  bool ans[]={false,false,false,false};
  rep(i,n){
      if(a[i]==1)ans[0]=true;
      if(a[i]==2)ans[1]=true;
      if(a[i]==3)ans[2]=true;
      if(a[i]==4)ans[3]=true;
  }
  int tmp=99;
  rep(i,n-1){
      if(a[i]==a[i+1]){
          if(a[i]!=tmp){
              res++;
              tmp=a[i];
          }
      }
  }
  bool o=a[0]&&a[1]&&a[2]&&a[3];
  cout<<(res==2&&o?"YES":"NO");
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;


int main() {

	ll H, W, h, w;
	cin >> H >> W >> h >> w;


	cout << (H - h)*(W - w);

	
	system("PAUSE");
}

Measured memory_bytes: 504
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

ll B[51], P[51], len[51];

ll calc(ll n, int l) {
   if (n == 0) {
      if (l != 0) return 0;
      else return 1;
   }
   if (1 <= n && n <= (len[l] - 3) / 2) return calc(n - 1, l - 1);
   if (n == (len[l] - 3) / 2 + 1) return calc(len[l - 1], l - 1) + 1;
   if ((len[l] - 3) / 2 + 1 < n && n < len[l] - 1) return calc(n - ((len[l] - 3) / 2 + 2), l - 1) + calc(len[l - 1], l - 1) + 1;
   else return calc(len[l - 1], l - 1) * 2 + 1;
}

int main() {
   int N;
   ll X;
   cin >> N >> X;

   B[0] = 0;
   P[0] = 1;
   len[0] = 1;

   for (int i = 1; i <= N; i++) {
      B[i] = B[i - 1] * 2 + 2;
      P[i] = P[i - 1] * 2 + 1;
      len[i] = B[i] + P[i];
   }

   cout << calc(X - 1, N) << endl;
   return 0;
}


Measured memory_bytes: 256
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  200005
ll n,k;
ll a[N],f[N];
bool check(ll v){
	ll sum=0;
	rep(i,0,n) {
		if(a[i]*f[i]>v){
			sum+=(a[i]-v/f[i]);			
		}
	}
	return (sum<=k);
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		cin>>n>>k;
		rep(i,0,n) cin>>a[i];
		rep(i,0,n) cin>>f[i];
		sort(a,a+n);
		reverse(a,a+n);
		sort(f,f+n);
		ll lo=0,h1=1e18;
		while(lo<h1){
			ll mid=(lo+h1)/2;
			if(check(mid)) h1=mid;
			else lo=mid+1;
		}
		cout<<lo<<endl;
	}
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int n;
  ll sum = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n;i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(All(a));
  printf("%d %d %lld\n", a[0], a[n - 1], sum);

  return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int main(void) {
  // Here your code !
  cin >> s;

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    printf("Bad\n");
  }
  else {
    printf("Good\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n, t, m, p, x;
	vector <int> tiempo;
	vector <int> r;
	vector <pair<int, int> > bebidas;
	
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> t;
		tiempo.push_back(t);
	}
	int sum;
	cin >> m;
	for (int i=0;i<m;i++){
		cin >> p>>x;
		sum =0;
		for (int j=0;j<n;j++){
			if (j+1 != p) sum += tiempo[j];
			else sum += x;
		}
		r.push_back(sum);
		
	}
	
	for (int i=0;i<m; i++){
		cout << r[i]<<endl;
	}
	
	return 0;
}

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

namespace AtCoder
{
    public static class program
    {
        public static void Main()
        {
            //入力を保持する
            var NM = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray();
            var N = NM[0];
            var M = NM[1];

            //部屋間は行き来できるためA、B二つの配列を用意
            var As = new int[M];
            var Bs = new int[M];

            //Keyに部屋番号Valueに行先の道順を保持するためのDictionanyを用意
            var conns = new Dictionary<int, List<int>>();
            for (int n = 0; n < M; n++)
            {
                //道順を順番に保持していく
                var path = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray();
                As[n] = path[0];
                Bs[n] = path[1];

                //部屋Aからの道順が存在しなけば、新たに要素を追加する。
                //部屋A(Key) --> B(Value)
                if (!conns.ContainsKey(As[n]))
                {
                    conns[As[n]] = new List<int> { Bs[n] };
                }
                //部屋Aからの道順がすでに存在すれば、追加する。
                //部屋A(Key) --> B(Value)
                else
                {
                    conns[As[n]].Add(Bs[n]);
                }
                //部屋Bも同様に処理する
                if (!conns.ContainsKey(Bs[n]))
                {
                    conns[Bs[n]] = new List<int> { As[n] };
                }
                else
                {
                    conns[Bs[n]].Add(As[n]);
                }
            }

            //foreach (var conn in conns)
            //{
            //    var key = conn.Key;
            //    var valStr = "";
            //    foreach (var val in conn.Value)
            //    {
            //        valStr = valStr + val;
            //    }
            //    Console.WriteLine(key.ToString() + " : " + valStr);
            //}
            var visit = Enumerable.Repeat(-1, N + 1).ToArray();
            var ans = new int[N + 1];
            var q = new Queue<int>();
            q.Enqueue(1);
            visit[1] = 0;
            while (q.Count != 0)
            {
                var now = q.Dequeue();                
                foreach (var conn in conns[now])
                {
                    if (visit[conn] != -1) continue;
                    q.Enqueue(conn);
                    visit[conn] = visit[now] + 1;
                    ans[conn] = now;
                }
            }

            Console.WriteLine("Yes");
            for (int i = 2;i < ans.Length;i++)
            {
                Console.WriteLine(ans[i]);
            }
            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 58296
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] A = new int[3][3];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        int N = sc.nextInt();
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextInt();
        }
        int[][] check = new int[3][3];

        for (int i = 0; i < N; i++) {
            Dobingo(A, B[i], check);
        }
        /*
         * for (int i = 0; i < check.length; i++) { for (int j = 0; j < check.length;
         * j++) { System.out.print(check[i][j]); } System.out.println(); }
         */

        if (hasBingo(check)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }

    public static void Dobingo(int[][] A, int B, int[][] bingo) {
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A.length; j++) {
                if (A[i][j] == B) {
                    bingo[i][j] = 1;
                }
            }
        }
    }

    public static boolean hasBingo(int[][] bingo) {
        // 真ん中
        if (bingo[1][1] == 1) {
            if (bingo[0][0] == 1 && bingo[2][2] == 1) {
                return true;
            } else if (bingo[1][0] == 1 && bingo[1][2] == 1) {
                return true;
            } else if (bingo[2][0] == 1 && bingo[0][2] == 1) {
                return true;
            } else if (bingo[0][1] == 1 && bingo[2][1] == 1) {
                return true;
            }
        }
        // 縦
        if (bingo[0][1] == 1) {
            if (bingo[0][0] == 1 && bingo[0][2] == 1) {
                return true;
            }
        }
        // 縦
        if (bingo[2][1] == 1) {
            if (bingo[2][0] == 1 && bingo[2][2] == 1) {
                return true;
            }
        }
        // 横
        if (bingo[1][0] == 1) {
            if (bingo[0][0] == 1 && bingo[2][0] == 1) {
                return true;
            }
        }
        // 横
        if (bingo[1][2] == 1) {
            if (bingo[0][2] == 1 && bingo[2][2] == 1) {
                return true;
            }
        }

        return false;
    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }

    set<int> st, st2;
    int max_a = 0;
    for(int i=0;i<k;++i) {
        st.insert(a[i]);
        st2.insert(-a[i]);
    }

    int ans = 1;
    for(int i=k;i<n;++i) {
        st.erase(a[i-k]);
        st2.erase(-a[i-k]);

        if(a[i-k] > *st.begin() || -(*st2.begin()) > a[i]) {
            ++ans;
        }

        st.insert(a[i]);
        st2.insert(-a[i]);
    }

    int cnt = 0;
    bool skipped = false;
    for(int i=1;i<n;++i) {
        if(a[i-1] < a[i]) {
            ++cnt;
            if(k-1 == cnt) {
                if(!skipped) {
                    skipped = true;
                } else {
                    --ans;
                }
            }
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19840
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n; cin >> n;
    map<int, int> mp;

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

    int ans = mp.size();
    cout << ans - (n - mp.size()) % 2 << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	// ?????§?????°??¨????°??????°
	public static final int MAXPOINT = 1000;
	public static final int MINPOINT = 0;

	// ???????????°????????§??¨????°?
	public static final int MAXJUDGE = 100;
	public static final int MINJUDGE = 3;

	// ?????°?????????
	static int point[] = new int[MAXJUDGE];
	// ??????????????°
	static int judge = 0;

	public static void main(String args[]) {
		sc = new Scanner(System.in);

		// ????????§EOF????????????????????????????????????
		while (sc.hasNext()) {

			// ?????°????????§??¨????°?
			int max = MINPOINT;
			int min = MAXPOINT;

			// ????¨?
			int sum = 0;

			// ??????????????°??????????????????0??????????????§??????
			if ((judge = sc.nextInt()) == 0)
				break;

			// ??????????????°??????????????°??????????????????
			for (int i = 0; i < judge; i++) {
				point[i] = sc.nextInt();

				// ?????§???????????????
				// ?????§?????\?????????
				if (point[i] >= max) {
					// ?????§????????´??°???????????¨?????????????????????????¨????
					max = point[i];
				}

				// ????°???????????°????????????°(????????¨??¨????????????????????´?????????????????????????????¶????????§???[??\???]??¨??????????????????
				if (point[i] < min) {
					// ?????§????????´??°???????????¨?????????????????????????¨????
					min = point[i];
				}
				// ????¨?????¶?????????????
				sum += point[i];

			}

			// System.out.printf("sum:%d max:%d min:%d\n", sum, max, min);

			// ?????§??¨????°????????????????????????????????????????
			sum -= max;
			sum -= min;

			// ???????????¨?????????????????§??¨????°?????¨?2??????????????????????????????????????§???judge?????°??????-2??????
			System.out.printf("%d\n", sum / (judge - 2));
		}

	}
}

Measured memory_bytes: 29000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  double N,M;
  double ans=0;
  double cnt=1;
  double x;
  cin >> N >> M;
  double t=(N-M)*100+1900*M;
  do{
    x=t*cnt/pow(2,M)*(pow(1-1/pow(2,M),cnt-1));
    ans=ans+x;
    cnt++;
  }while(x>0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

y = b - x / (a ** 2)
if a * a * b >= 2 * x:
    y = ((x / a) / b) * 2
    print(math.degrees(math.atan(b/y)))
else:
    y = ((b * a - x / a) / a) * 2
    print(math.degrees(math.atan(y/a)))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
int main(){
  int H, W;
  while(cin>> H >> W){
    if(H==0 && W==0)break;
    else{
      for(int i=0; i<H; i++){
    if(i%2==1){
      for(int j=0; j<W; j++){
        if(j%2==1)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    else{
      for(int j=0; j<W; j++){
        if(j%2==1)
          cout << ".";
        else
          cout << "#";
      }
      cout << endl;
    }
     
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define max(p,q)((p)>(q)?(p):(q))
int i,j,k;
int row,column,knum;
int r,c,v;
int table[3010][3010];
long long int ret;
long long int dp[3010][3010][4];

//scanfの時は" "を空けずに入れること!
int main()
{
    scanf("%d %d %d",&row,&column,&knum);
    for (i=0;i<3010;i++){
        for (j=0;j<3010;j++){
            table[i][j]=0;
        }
    }
    for (i=0;i<3010;i++){
        for (j=0;j<3010;j++){
            for (k=0;k<4;k++){
                dp[i][j][k]=0;
            }
        }
    }
    for (i=0;i<knum;i++){
        scanf("%d %d %d",&r,&c,&v);
        table[r-1][c-1]=v;
    }
    for (i=0;i<row;i++){
        for (j=0;j<column;j++){
            for (k=2;k>=0;k--){
                dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+table[i][j]);
            }
            for (k=0;k<4;k++){
                if (i<row-1) dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
                if (j<column-1) dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
            }
        }
    }
    ret=dp[row-1][column-1][0];
    for (i=0;i<4;i++){
        ret=max(ret,dp[row-1][column-1][i]);
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 320252
import sys
input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def main():
    A, B, C, D = map(int, input().split())
    g = gcd(max(C,D),min(C,D))
    l = C*D//g
    NB = B - B//C - B//D + B//l
    NA = (A-1) - (A-1)//C - (A-1)//D + (A-1)//l
    ans = NB - NA
    print(int(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

const int K_MAX = 200100;
bool dp[K_MAX];


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

    int N, K;
    cin >> N >> K;

    vector<int> a(N);

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

    for(int i = 0; i < K_MAX; i++){
        dp[i] = false;
    }
    
    for(int i = 0; i < K; i++){
        for(int j = 0; j < N; j++){
            if(!dp[i]){
                dp[i+a[j]] = true;
            }
        }
    }

    if(dp[K]){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int d[50][50], color[505][505], n, c, value[50][5] = {},res=0;
	string str;
	cin >> str;
	n = str.length();
	for (int i = 0; i < n; i++) {
		if (str[i] == 'g') { res++; }
		else{ res--; }
	}
	cout << res / 2 << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final FastIn in = new FastIn();
	private static final PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		Solver sol = new Solver();
		sol.solve();
		out.close();
	}

	private static final class Solver {
		public void solve() {
			int[] ap = new int[26];
			char[] w = in.next().toCharArray();
			for (int i = 0; i < w.length; ++i) {
				ap[w[i] - 'a']++;
			}
			for (int i = 0; i < 26; ++i) {
				if (ap[i] % 2 != 0) {
					out.println("No");
					return;
				}
			}
			out.println("Yes");
		}
	}

	private static final class FastIn {
		private BufferedReader br;
		private StringTokenizer st;

		public FastIn() {
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
			st = null;
		}

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

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


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;cin>>N;
    string S;cin>>S;
    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }else{
        REP(i,N/2){
            if(S[i]!=S[i+N/2]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        
        cout<<"Yes"<<endl;
        return 0;

    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	map<int,int> cnt; cnt.clear();
	rep (i, N){
		int a; cin >> a;
		++cnt[a];
	} // end rep

	int res = 0;
	map<int,int>::reverse_iterator it = cnt.rbegin();
	for (; it != cnt.rend(); ++it){
		int n = (*it).first;
		int c = (*it).second;
		if (c == 0) continue;
		for (int i = 1; i <= 31; ++i){
			int remain = (1<<i) - n;
			if (remain <= 0) continue;
			if (n != remain){
				if (cnt[n] > 0 && cnt[remain] > 0){
					int m = min(cnt[n], cnt[remain]);
					cnt[n] -= m;
					cnt[remain] -= m;
					res += m;
				} // endif
			}else{
				if(cnt[n] - 2 >= 0){
					int m = cnt[n] / 2;
					cnt[n] -= 2 * m;
					res += m;
				} // end if
			} // end if
		} // end for
	} // end for

	cout << res << endl;
			
	return 0;
}

Measured memory_bytes: 38400
class mystack:
    def __init__(self, stack):
        self.max = 200
        self.stack = [stack for _ in range(self.max)]
        self.top = 0

    def init(self):
        self.top = 0

    def push(self, arg):
        self.top += 1
        self.stack[self.top] = arg

    def pop(self):
        self.top -= 1
        return self.stack[self.top + 1]


inputs = list(input().split())

stack = mystack([])

for i in inputs:
    if i == "+":
        a = stack.pop()
        b = stack.pop()
        stack.push(b + a)
    elif i == "-":
        a = stack.pop()
        b = stack.pop()
        stack.push(b - a)
    elif i == "*":
        a = stack.pop()
        b = stack.pop()
        stack.push(b * a)
    else:
        i = int(i)
        stack.push(i)

print(stack.pop())



Measured memory_bytes: 5604
def main():
  while True:
    n = int(input())
    if not n:
      break
  
    D = [1, 2, 3, 4, 5, 6]
    ans = 1
  
    for i in range(n):
      s = input()[0]
  
      if s == "N":
        temp = D[0]
        D[0] = D[1]
        D[1] = D[5]
        D[5] = D[4]
        D[4] = temp
  
      elif s == "S":
        temp = D[0]
        D[0] = D[4]
        D[4] = D[5]
        D[5] = D[1]
        D[1] = temp
  
      elif s == "E":
        temp = D[0]
        D[0] = D[3]
        D[3] = D[5]
        D[5] = D[2]
        D[2] = temp
  
      elif s == "W":
        temp = D[0]
        D[0] = D[2]
        D[2] = D[5]
        D[5] = D[3]
        D[3] = temp
  
      elif s == "L":
        temp = D[1]
        D[1] = D[3]
        D[3] = D[4]
        D[4] = D[2]
        D[2] = temp
  
      elif s == "R":
        temp = D[1]
        D[1] = D[2]
        D[2] = D[4]
        D[4] = D[3]
        D[3] = temp
  
      ans += D[0]
  
    print(ans)

main()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M;
    cin >> N >> M;

    vector<pair<int,int>> AB(N);
    for(int i=0;i<N;i++) {
        cin >> AB[i].first >> AB[i].second;
    }
    
    sort(AB.begin(),AB.end());

    long long ans=0;
    int buy_all=0,buy=0,i=0;
    while(buy_all<M){
        ans += AB[i].first;
        buy++;
        buy_all++;
        if(buy == AB[i].second){
            i++;
            buy=0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
//#define P pair<int,int>


signed main(){
    int N,M,Q;
    int L[214514],R[214514];
    int p[114514],q[114514];
    int D[600][600]={};
    cin >> N >> M >> Q;
    REP(i,M){
        cin >> L[i] >> R[i];
        D[L[i]][R[i]]++;
    }
    /*REP(i,N+1){
        REP(j,N+1){
            cout << D[i][j] << " ";
        }cout << endl;
    }cout << Endl;*/
    OREP(i,N){
        OREP(j,N){
            D[i][j]+=D[i][j-1];
            D[i][j]+=D[i-1][j];
            D[i][j]-=D[i-1][j-1];
        }
    }
    /*REP(i,N+1){
        REP(j,N+1){
            cout << D[i][j] << " ";
        }cout << endl;
    }cout << Endl;*/
    
    REP(i,Q){
        cin >> p[i] >> q[i];
    }
    REP(i,Q){
        int x=p[i],y=q[i];
        cout << D[y][y]-D[x-1][y]-D[y][x-1]+D[x-1][x-1] << endl;
    }
    
    
    
	return 0;
}

Measured memory_bytes: 8832
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	static Node[] V;
	static int treed;
	static int N;
	static int black = 0;
	static int white = 0;
	
	public static void main(String[] args) {
		N = sc.nextInt();
		
		V = new Node[N];
		for(int i=0; i<N; i++) {
			V[i] = new Node();
			V[i].id = i;
		}
		
		for(int i=0; i<N-1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			V[a].nbr.add(b);
			V[b].nbr.add(a);
		}
		
		V[0].dfs1(0, -1);
		
		for(int i=0; i<N; i++) {
			V[i].visited = false;
		}
		V[0].dfs2(true);
		V[N-1].dfs2(false);
		
		if(black > white) {
			System.out.println("Fennec");
		} else {
			System.out.println("Snuke");
		}
	}
	
	static class Node {
		int id;
		boolean visited = false;
		HashSet<Integer> nbr = new HashSet<>();
		
		boolean dfs1(int d, int prev) {
			visited = true;
			if(id == N-1) {
				treed = d;
				if((treed / 2) + 1 == d) {
					nbr.remove(prev);
					V[prev].nbr.remove(id);
				}
				return true;
			}
			
			for(int x : nbr) {
				if(!V[x].visited && V[x].dfs1(d+1, id)) {
					if((treed / 2) + 1 == d) {
						nbr.remove(prev);
						V[prev].nbr.remove(id);
					}
					return true;
				}
			}
			
			return false;
		}
		
		void dfs2(boolean mode) {
			visited = true;
			if(mode) {
				black++;
			} else {
				white++;
			}
			
			for(int x : nbr) {
				if(!V[x].visited) {
					V[x].dfs2(mode);
				}
			}
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

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

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		String[] s = reader.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(s[i]);
		}
		boolean flag = true;
		int i = 0;
		int sum = 0;
		while (flag) {
			flag = false;
			for (int j = n - 1; j >= i + 1; j--) {
				if (a[j] < a[j - 1]) {
					sum++;
					int temp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = temp;
					flag = true;
				}
			}
			i++;
		}
		for (int k = 0; k < n; k++) {
			if (k > 0)
				System.out.print(" ");
			System.out.print(a[k]);
		}
		System.out.println();
		System.out.println(sum);

	}
}

Measured memory_bytes: 16968
#include<iostream>
using namespace std;
int main()
{
    int n,count=1;
    cin>>n;
    int flag=0;
    int a[n];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(n>2)
    {
    if(a[1]>a[2])
    {
        count++;
    }
    }
   for(int i=3;i<=n;i++)
   {
     if(a[i-2]<a[i-1])
     {
        swap(a[i-2],a[i-1]);
     }
      if(a[i]<=a[i-1])
      {
        count++;
      }
   }
   cout<<count;
}

Measured memory_bytes: 1024
n = int(input())
    
ac = 0
wa = 0
tle = 0
re = 0
 
for _ in range(n):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += 1
    
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 9216
#include<stdio.h>

int main(){
    int n,ans,sum=0,tmp,digit;

    scanf("%d",&n);

    tmp = n;

    while(tmp){
        digit = tmp % 10;
        sum = digit + sum;
        tmp /= 10;
    }

    ans = n % sum;

    if(ans == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

#include<deque>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int N;

int main() {
    cin >> N;
    vector<int> a(N);
    deque<int> dq;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (i % 2 == 0) dq.push_back(a[i]);
        else dq.push_front(a[i]);
    }
    if (N % 2 == 0) {
        for (int i = 0; i < N; i++) {
            cout << dq[i] << " ";
        } cout << endl;
    } else {
        for (int i = N-1; i >= 0; i--) {
            cout << dq[i] << " ";
        } cout << endl;
    }

    
    

    



}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define N 500001
int dat[N];
void update(int i,int x){
  for(;i<N;i+=i&-i) dat[i]+=x;
}
int sum(int i){
  int s=0;
  for(;i>0;i-=i&-i)s+=dat[i];
  return s;
}
int rangesum(int l, int r){
  return sum(r)-sum(l-1);
}
  
int main()
{
  int n,q;
  cin>>n>>q;
  vector<int> ql[n+1],qid[n+1];
  int a[n+1];
  for(int i=1;i<=n;i++)
    cin>>a[i];
  for(int i=1;i<=q;i++){
    int l,r;
    cin>>l>>r;
    ql[r].push_back(l);
    qid[r].push_back(i);
  }
  int ans[q+1],temp[n+1];
  for(int i=1;i<=n;i++) temp[i]=0;
  for(int i=1;i<=n;i++){
    if(temp[a[i]]!=0) update(temp[a[i]],-1);
    temp[a[i]]=i;
    update(i,1);
    for(int j=0;j<ql[i].size();j++){
      ans[qid[i][j]]=rangesum(ql[i][j],i);
    }
  }
  for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 53012
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(void){
	scanf("%d",&n);
	int v=n;
	int sum=0;
	while(v>0){
		sum+=v%10;
		v/=10;
	}
	printf("%s\n",n%sum==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
v = (1,
     1,
     2,
     6,
     24,
     120,
     720,
     5040,
     40320,
     362880,
     3628800,
     39916800,
     479001600,
     6227020800,
     87178291200,
     1307674368000,
     20922789888000,
     355687428096000,
     6402373705728000,
     121645100408832000,
     2432902008176640000)

print(v[int(input())])

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

void order(int a, int b, int c){
  int max, scnd, thrd;
  max = a, scnd = b;
  
  if (a < b) {
    max = b;
    scnd = a;
  }
  if (max < c) {
    thrd = scnd ;
    scnd = max;
    max = c;
  }else if(scnd > c){
    thrd = c;
  }else{
    thrd = scnd;
    scnd = c;
  }
  cout << thrd << " " << scnd << " " << max << endl;
}


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

  cin >> a >> b >> c;

  order(a, b, c);
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 2007<<1 , __ = _<<1;

int to[__],ne[__],he[_]={0},ecnt=1;
void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
void addde(int a,int b){adde(a,b),adde(b,a);}

int n,nn,lim;

int dfs(int x,int ff,int d)
{
	if(d<=0)return x<=n;
	int ans=x<=n;
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff)continue;
		ans+=dfs(b,x,d-1);
	}
	return ans;
}

int main()
{
	n=ty(),lim=ty(),nn=n+n;
	for(int i=n+1;i<nn;i++)
	{
		int a=ty(),b=ty();
		addde(a,i),addde(i,b);
	}

	int ans=0;
	for(int i=1;i<nn;i++)ans=max(ans,dfs(i,0,lim));
	printf("%d\n",n-ans);

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int field[101][101];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				cin>>field[i][j];
		int sum=0;
		bool no=false;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				int num=field[i][j];
				bool f=false;
				for(int k = 0; k < n; k++){
					if(k==j)
						continue;
					if(field[i][k]<num){
						f=true;
						break;
					}
				}
				if(f)
					continue;
				f=false;
				for(int k = 0; k < n; k++){
					if(k==i)
						continue;
					if(field[k][j]>num){
						f=true;
						break;
					}
				}
				if(f)
					continue;
				cout<<field[i][j];
				no=true;
				break;
			}
			if(no)
				break;
		}
		if(!no)
			cout<<0;
		cout<<endl;
	}		


	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int i=0;i<n;i++){
		vector<int> new_dp(3);
		vector<int> c(3);
		for(int i=0;i<3;i++) cin>>c[i];
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				if(i!=j)
					new_dp[j]=max(new_dp[j],dp[i]+c[j]);
		dp=new_dp;
	}
	cout<<max(dp[0],max(dp[1],dp[2]));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n; cin>>n;
	int a[n];
	ll sm=0;
	int cnt[100005];
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<n;i++)
	{
		cin>>a[i]; sm+=a[i];
		cnt[a[i]]++;
	}
	int q; cin>>q;

	while(q--)
	{
		ll x,y; cin>>x>>y;;
	//	x--; y--;
		if(cnt[x]>0){
		sm-=cnt[x]*1LL*x;
		sm+=cnt[x]*1LL*y;
		cnt[y]+=cnt[x];
		cnt[x]=0;
		}
		
	//	swap(cnt[a[x]],cnt[a[y]]);
		
		
		cout<<sm<<endl;
		
		
		
		
		
		
	}
}

Measured memory_bytes: 4396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		long nu = b - a + 1;
		long nc = (a % c == 0) ? 1 + (b - a) / c : ((c - a % c) + a > b) ? 0 : 1 + (b - a - (c - a % c)) / c;
		long nd = (a % d == 0) ? 1 + (b - a) / d : ((d - a % d) + a > b) ? 0 : 1 + (b - a - (d - a % d)) / d;
		long cd = (c * d) / gcd(c, d);
		long ncd = (a % cd == 0) ? 1 + (b - a) / cd : ((cd - a % cd) + a > b) ? 0 : 1 + (b - a - (cd - a % cd)) / cd;

		System.out.println(nu - nc - nd + ncd);
	}

	private static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
#define rep1(i,n) for (int i=1 ; i<=(n) ; ++i)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
typedef long long ll;
using namespace std;

const int mod = 1000000007;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint operator~() const { return mint(1) / *this;}
  mint& operator+=(const mint a) { if ((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint a) { if ((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { mint res(*this); return res+=a;}
  mint operator-(const mint a) const { mint res(*this); return res-=a;}
  mint operator*(const mint a) const { mint res(*this); return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
  mint operator/(const mint a) const { mint res(*this); return res/=a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    // nCkを計算するならnの最大値を渡す combination c(n+5); -> nCk = c(n,k).x
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main () {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  combination c(n+k);
  mint ans = 0;
  for (int i = 0; i <= k; ++i) {
    mint now = mint(26).pow(k-i);
    now *= mint(25).pow(i);
    now *= c(i+n-1,n-1);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35520
N = int(input())
A = list(map(int,input().split()))
A.sort()
N = max(A)
l,r = 0,0
for i in A:
    if i > N/2:
        r = i
        break
    l = i
if N/2 - l > r - N/2:
    print(N,r)
else:
    print(N,l)

Measured memory_bytes: 14428
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
int n,a;
int sum[200005];
int main(){
    read(n);
    fr(i,2,n)read(a),++sum[a];
    fr(i,1,n)cout<<sum[i]<<"\n";
    puts("");
	return 0;
}


Measured memory_bytes: 4412
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val s=(1..n).map{readLine()!!.first()}
			.plus("MARCH".toList()) //size==0だとうまくグループに分かれないので前処理
			.filter{ it in "MARCH" }
			.groupBy {it}
			.map {it.value.size.toLong()-1}
	
	var ans = 0L
	for(i in 0..4)for(j in i+1..4)for(k in j+1..4){
		ans+=s[i]*s[j]*s[k]
	}
	println(ans)
}

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

int main()
{
    int k,p;cin>>k>>p;
    vector<int>v(k);
    for(int i=0;i<k;i++)cin>>v[i];
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<p;i++)sum+=v[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
H, W = [int(i) for i in input().split()]
A = []
for i in range(H):
    A.append([int(i) for i in input().split()])
counter_bound = H * W
counter = 0
B = []
for i in range(H):
    if i % 2 == 0:
        tmp = range(W)
        direction = 1
    else:
        tmp = range(W-1,-1,-1)
        direction = -1
    for j in tmp:
        counter += 1
        if counter < counter_bound:
            if A[i][j] % 2:
                A[i][j] -= 1
                if j == tmp[-1]:
                    A[i+1][j] += 1
                    B.append((i+1,j+1,i+2, j+1))
                else:
                    A[i][j+direction] += 1
                    B.append((i+1,j+1,i+1,j+direction+1))
print(len(B))
for b in B:
    print(*b, sep= " ")

Measured memory_bytes: 26596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const int MAX=1e5+1;
const ll INF=1e9;



int main()
{
    int n,m;
    cin>>n>>m;
    vector<P> ab;
    rep(i,n)
    {
        ll a,b;
        cin>>a>>b;
        ab.push_back(P(a,b));
    }
    sort(ab.begin(),ab.end(),[](const P& x,const P& y){return x.first<y.first;});
    ll count=0;
    ll ans=0;
    rep(i,n)
    {
        if(count+ab[i].second<=m)
        {
            count+=ab[i].second;
            ans+=ab[i].first*ab[i].second;
        }
        else
        {
            ll remain=m-count;
            ans+=ab[i].first*remain;
            break;
        }
        
    }
    cout<<ans;





}

Measured memory_bytes: 2420
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
	ll ans = 1;
	while (n) 
	{
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() 
{
	int n; cin >> n;
	ll arr[n];
	For(i,0,n) cin >> arr[i];
	ll ans = 0;
	sort(arr, arr+n);
	For(i,0,n)
	{
		For(j,i+1,n)
		{
			if (arr[i] == arr[j]) continue;
			For(k,j+1,n)
			{
				if (arr[i] == arr[k] or arr[j] == arr[k])
					continue;
				if (arr[i] + arr[j] > arr[k]) ++ans;
			}
		}
	}				
	cout << ans << endl;
}

int main() 
{
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 3652
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use { sc ->
        val a = sc.nextInt()
        val b = sc.nextInt()
        val c = sc.nextInt()
        val list = listOf(a, b, c).sorted().toList()
        println(list[0] + list[1] + list[2] * 10)
    }
}


Measured memory_bytes: 35908
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int N; cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    //約数2の数え上げ
    int cnt=0;
    for(int i=0; i<N; i++){
        while(A[i]%2==0){
            ++cnt;
            A[i]/=2;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int A[100000],n;
int binarysearch(int key);

int main(){
  int i,j,q,goukei=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&j);
    if(binarysearch(j)) goukei++;
      }
  printf("%d\n",goukei);
  return 0;

}


int binarysearch(int key){
  int l=0,r=n,m;

  while(l<r){
    m=(r+l)/2;
    if(key==A[m])return 1;
    if(key>A[m]) l=m+1;
    else if(key<A[m]) r=m;
  }
  return 0;
}




Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll a[N];
    int b;
    cin >> b;
    if(b%2==0)a[0]=2;
    else a[0]=1;
    for(int i=1;i<N;i++){
        int x;
        cin >> x;
        if(x%2==0)a[i]=2*a[i-1];
        else a[i]=a[i-1];
      	cerr << a[i] << endl;
    }
    ll m=pow(3,N)-a[N-1];
    cout << m << endl;
}

/*



 */



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int gcd(int x,int y){
	int t;
	while(y!=0){
		t=x%y;x=y;y=t;
	}
	return x;
}
int ngcd(int n,int a[]){
	int i,d;
	d=a[0];
	for(i=1;i<n&&d!=1;i++)d=gcd(a[i],d);
	return d;
}
int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,x,i;
	cin>>n>>x;
	int a[n+1],b[n];
	for(i=0;i<n;i++)cin>>a[i];
	a[n]=x;
	sort(a,a+n+1);
	for(i=0;i<n;i++)b[i]=a[i+1]-a[i];
	cout<<ngcd(n,b)<<endl;
	
	
	
	
	return 0;
}


Measured memory_bytes: 1024