akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


#define CNT_MAX 100
#define INF (1e+9)
int main(void) {
    int cnt, ts;
    cin >> cnt >> ts;
    vector<int> arr(ts);
    int mmax = 0;
    for(int i = 0; i < ts; i++) {
        int val;
        cin >> val;
        mmax = max(val, mmax);
    }
    // A*A*A*A
    int rem = cnt - mmax;
    cout << max(0, mmax-1 - rem) << endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin >> n;
    string ans="";
    while(n>0){
        n-=1;
        ans = (char)('a'+(n%26))+ans;
        n/=26;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
 // cout<<1<<endl;
  int N;
  cin>>N;
  int save = N;
  int div=0;
  while(N!=0){
    div+=N%10;
    N=N/10;
  }
  
  string ans = save%div==0 ? "Yes":"No";
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
Bli = list(map(int,input().split()))
Ali = [list(map(int, input().split())) for _ in range(N)]

ans = 0

for A in Ali:
    sumNum = 0
    for num, a in enumerate(A):
        sumNum += a * Bli[num]
        
    if sumNum + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int N,L[205];
int rez;
int main()
{
    cin>>N;
    for(int i=1;i<=2*N;i++)cin>>L[i];
    sort(L+1,L+1+2*N);
    for(int i=1;i<=2*N;i+=2)rez+=L[i];
    cout<<rez;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n)*((n)+1)>>1)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;

const int MAXN = 22, MOD=1e9+7;
int n;
ll mat[MAXN][MAXN], dp[MAXN][1<<MAXN];

ll f(int i, int mask){
    if(mask==0) return i<0;
    if(i<0) return mask==0;
    if(~dp[i][mask]) return dp[i][mask];
    ll ans=0;
    for (int j=0; j<n; j++){
        if(mat[i][j] && mask&(1<<j)){
            ans = (ans + f(i-1, mask^(1<<j)))%MOD;
        }
    }
    return dp[i][mask] = ans;
}

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



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

    memset(dp, -1, sizeof dp);

    cout << f(n-1, (1<<n)-1) << "\n";





    return 0;
}

/*
1
9 3
111100000
 */

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  ll n, W;
  cin >> n >> W;
  vector < ll > w(n + 1), v(n + 1);
  for(int i = 1; i <= n; i++) cin >> w[i] >> v[i];
  vector < vector < ll > > dp(MAXN, vector < ll > (105, LLONG_MAX));

  ll mx = LLONG_MIN;
  for(int j = 0; j <= n; j++) dp[0][j] = 0;
  for(int i = 0; i < MAXN; i++){
    for(int j = 1; j <= n; j++){
      if(i - v[j] >= 0 && dp[i - v[j]][j - 1] != LLONG_MAX) dp[i][j] = min(dp[i][j - 1], dp[i - v[j]][j - 1] + w[j]);
      dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
    if(dp[i][n] <= W && dp[i][n] > 0) mx = max(mx, (ll)i);
  }

  cout << mx << '\n';
}


Measured memory_bytes: 85376
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int x;
  cin >> x;
  rep1 (i, x / 100) {
    int mini = 100 * i, maxi = 105 * i;
    if (mini <= x && x <= maxi) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, H: int, M: int):
    long = 360/60 * M
    long_x = math.sin(math.radians(long))*B
    long_y = math.cos(math.radians(long))*B
    short = 360/12 * H + 30/60 * M
    short_x = math.sin(math.radians(short))*A
    short_y = math.cos(math.radians(short))*A
    print(math.sqrt((long_x - short_x) ** 2 + (long_y - short_y) ** 2))
    return

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(A, B, H, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9492
b = input()
be = b.replace('A', '&') #strで拾って(変数名.replace(‘置換前’, ’置換後’))
bea = be.replace('T', 'A')
beam = bea.replace('&', 'T')
beami = beam.replace('C', '$')
beamin = beami.replace('G', 'C')
beaming = beamin.replace('$', 'G')
print(beaming)


Measured memory_bytes: 3060
import java.util.Scanner;
 
class Main{
 
    public static void main(String[] args){
 
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        scanner.close();
        while(true){
            c = c - b;
            if(c<=0){
                System.out.println("Yes");
                return;
            }
            a = a -d;
            if(a<=0){
                System.out.println("No");
                return;
            }
        }
    }
 
}

Measured memory_bytes: 27080
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  cout << s[0] << n - 2 << s[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 3612
using System;

public class lec01_A
   {
      public static void Main(){
        int[] A;
        var n = int.Parse(Console.ReadLine());
        A = new int[n];
        string[] str = Console.ReadLine().Split(' ');
        for(int i = 0; i < n;i++){
        A[i] = int.Parse(str[i]);
        }
        for(int i = 0;i < n - 1;i++){
          int v = A[i + 1];
          int j = i;
          for(int k = 0;k < n - 1;k++){
          Console.Write(A[k] + " ");
          }
          Console.Write(A[n - 1]);
          Console.WriteLine();
          while(j >= 0 && A[j] > v){
               A[j + 1] = A[j];
               j--;
               A[j + 1] = v;
          }
        }
       for(int k = 0;k < n - 1;k++){
        Console.Write(A[k] + " ");
      }
      Console.Write(A[n - 1]);
      Console.WriteLine("");
      }
  }


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

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

   string s,ans;
   cin >> s;
   rep(i,s.size()){
      if(s[i] == 'B'){
         if(!ans.empty()){
            ans.pop_back();
         }
      }
      else{
         ans += s[i];
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

int main() {
    std::string moji;
    int a, b;
    
    while (1) {
        std::cin >> a >> b;
        moji = std::to_string(a+b);
        if (std::cin.eof()) break;
        std::cout << moji.size() << std::endl;
    }
    
    return 0;
}




Measured memory_bytes: 3236
N,K=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(abs, a))
i=b.index(min(b))
c=list(filter(lambda x: x>=0, a))
e=sorted(c)
d=list(map(abs, filter(lambda x: x<0, a)))
f=sorted(d)

lp=len(c)
lm=len(d)
s=[]
if 0 in a:
    K -=1

if K==0:
    print(0)
elif lp==0:
    print(f[K-1])
elif lm==0:
    print(e[K-1])
elif K==N:
    print(min(2*e[lp-1]+f[lm-1],2*f[lm-1]+e[lp-1]))
else:
    for i in range(lp):
        if K-i<=lm:
            if i==K:
                u=e[i-1]
            else:
                u=2*e[i-1]+f[K-i-1]
            s.append(u)
    for t in range(lm):
        if K-t<=lp:
            if t==K:
                q=f[t-1]
            else:
                q=2*f[t-1]+e[K-t-1]
            s.append(q)

    print(min(s))

    


Measured memory_bytes: 16444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    string s,t;cin >> s >> t;
    int count = 0;
    rep(i, 3) {
        if(s[i]==t[i])count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){
  string s,t;
  cin >> s >> t;
  int ss = s.size();
  bool f = true;
  rep(i,ss){
    if(s[i] != t[i])
      f = false;
  }

  cout << (f ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector< vector<int> > A(n, vector<int>(m, 0));
    vector<int> b(m);
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A.at(i).at(j);
        }
    }
    
    for (int i = 0; i < m; i++) {
        cin >> b.at(i);
    }
    
    for (int i = 0; i < n; i++) {
        int ans = 0;
        for (int j = 0; j < m; j++) {
            ans += A.at(i).at(j) * b.at(j);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int K=gi();
	    String S=gs();
        


        //System.out.print(c);

        if (S.length()<=K) {
        	System.out.println(S);
        }else{
        	System.out.println(S.substring(0,K) + "...");
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38508
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto isSwap = false;
	auto count = 0;
	for (auto i = 1; i <= N; ++i)
	{
		int p;
		cin >> p;
		if (!isSwap)
		{
			if (i == p)
			{
				isSwap = true;
				++count;
			}
		}
		else
		{
			isSwap = false;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> a(n);
  for (auto& x : a) cin >> x;
  int lo = 0, hi = 1 << 30;
  auto judge = [&] (int len) -> bool {
    long long cnt = 0;
    for (auto& x : a) {
      cnt += (x + len - 1) / len - 1;
    }
    return cnt <= k;
  };
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    if (judge(mid)) hi = mid;
    else lo = mid;
  }
  cout << hi << endl;
  return 0;
}

Measured memory_bytes: 4680
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int a,ans;
int main()
{
  cin>>a;
  if(a/1000==2)ans++;
  if(a%100/10==2)ans++;
  if(a%1000/100==2)ans++;
  if(a%10==2)ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import collections


num_op = int(input())
dllist = collections.deque()

for i in range(0, num_op):
    op = input().split(' ')
    if op[0] == 'insert':
        dllist.appendleft(op[1])
    elif op[0] == 'delete':
        if op[1] in dllist:
            dllist.remove(op[1])
    elif op[0] == 'deleteFirst':
        dllist.popleft()
    elif op[0] == 'deleteLast':
        dllist.pop()

print(' '.join(dllist))


Measured memory_bytes: 69728
from collections import defaultdict

n=int(input())
ab=[[int(i) for i in input().split()] for j in range(n)]
cd=[[int(i) for i in input().split()] for j in range(n)]
ab.sort()
cd.sort()
    
ans=0

for i in cd:
    check=-1
    pair=[-1,-1]
    for j in ab:
        
        if j[0]>i[0]:
            break
        if check<j[1]<i[1]:
            check=j[1]
            pair=j
    if pair != [-1,-1]:
        ans+=1
        ab.remove(pair)
print(ans)
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
double v[55];
double ans=0;
int main(){
	cin>>n;
	REP(i,n)cin>>v[i];
	sort(v,v+n,greater<double>());
	double t=2;
	for(int i=0;i<n-1;i++){
		ans+=(v[i]/t);
		t*=2;
	}
	t/=2;
	ans+=v[n-1]/t;
	printf("%.15f",ans);
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC_167_C
//
//  Created by Joe Mori on 2020/05/10.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<vector>
int main(int argc, const char * argv[]) {
    int n,m,x,price=10000000,p=0;
    std::cin>>n>>m>>x;
    std::vector<int> c(n);
    std::vector<std::vector<int> >a(n,std::vector<int>(m));
    std::vector<int> ability(m);
    for(int i=0;i<n;i++){
        std::cin>>c[i];
        for(int j=0;j<m;j++){
            std::cin>>a[i][j];
        }
    }
    for(int bit=0;bit<(1<<n);bit++){
        p=0;
        std::vector<int> ability(m);
//        std::cout<<bit<<std::endl;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                for(int j=0;j<m;j++){
                    ability[j]+=a[i][j];
                }
                p+=c[i];
            }
        }
//        std::cout<<price<<std::endl;
        for(int j=0;j<m;j++){
            if(ability[j]<x){
                break;
            }
            if(j==m-1){
                price=std::min(price,p);
            }
        }
    }
    if(price==10000000)std::cout<<-1<<std::endl;
    else std::cout<<price<<std::endl;
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

const lint INF = 1000000000000000000;
const int MAX_G = 2600;
struct Edge {int to; int g_cost; int t_cost;};
using Graph = vector<vector<Edge>>;

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    Graph G(N);
    rep(i, M) {
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        --U;
        --V;
        G[U].push_back(Edge{V, A, B});
        G[V].push_back(Edge{U, A, B});
    }
    rep(i, N) {
        int C, D;
        cin >> C >> D;
        G[i].push_back(Edge{i, -C, D});
    }
    
    vector<vector<lint>> cost(N, vector<lint>(MAX_G + 1, INF));
    cost[0][min(S, MAX_G)] = 0;
    vector<vector<int>> used(N, vector<int>(MAX_G + 1, 0));
    priority_queue<pair<lint, pair<int, int>>> pq;
    pq.push(pair<lint, pair<int, int>>{0, pair<int, int>{0, min(MAX_G, S)}});
    while (!pq.empty()) {
        int v = pq.top().second.first;
        int g = pq.top().second.second;
        pq.pop();
        if (used[v][g]) continue;
        for (auto e : G[v]) {
            if (g - e.g_cost < 0) continue;
            lint alt = cost[v][g] + e.t_cost;
            if (alt < cost[e.to][min(g - e.g_cost, MAX_G)]) {
                cost[e.to][min(g - e.g_cost, MAX_G)] = alt;
                pq.push(pair<lint, pair<int, int>>{-alt, pair<int, int>{e.to, min(g - e.g_cost, MAX_G)}});
            }
        }
        used[v][g] = 1;
    }
    for (int t = 1; t < N; ++t) {
        lint ans = INF;
        rep(i, MAX_G + 1) ans = min(ans, cost[t][i]);
        cout << ans << "\n";
    }
    return 0;
}


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

using namespace std;

int main() {
  vector<int> vec(32);
  vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };                                                                                              
  int n; 
  cin >> n;
  cout << vec.at(n - 1) << endl;
}

Measured memory_bytes: 256
n = int(input())
v_list = list(map(int, input().split()))
nums_even = {-1: 0}
nums_odd = {-1: 0}
for i, v in enumerate(v_list):
    if i % 2 == 0:
        nums_even.setdefault(v, 0)
        nums_even[v] += 1
    else:
        nums_odd.setdefault(v, 0)
        nums_odd[v] += 1
even_max = -1
even_max2 = -1
for key, val in nums_even.items():
    if val > nums_even[even_max]:
        even_max2 = even_max
        even_max = key
    elif val > nums_even[even_max2]:
        even_max2 = key
odd_max = -1
odd_max2 = -1
for key, val in nums_odd.items():
    if val > nums_odd[odd_max]:
        odd_max2 = odd_max
        odd_max = key
    elif val > nums_odd[odd_max2]:
        odd_max2 = key
if even_max != odd_max:
    print(n - nums_even[even_max] - nums_odd[odd_max])
else:
    m = max(nums_even[even_max] + nums_odd[odd_max2], nums_even[even_max2] + nums_odd[odd_max])
    print(n - m)


Measured memory_bytes: 17056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int N = scanner.nextInt();
		int[][] graph = new int[W][H];
		int[] x = new int[N];
		int[] y = new int[N];
		int[] a = new int[N];
		for(int i=0;i<N;i++) {
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();
			a[i] = scanner.nextInt();
		}

		for(int i=0;i<N;i++) {
			switch(a[i]) {
			case 1:
				for(int j=0;j<x[i];j++) {
					for(int k=0;k<H;k++) {
						graph[j][k]=1;
					}
				}
				break;
			case 2:
				for(int j=x[i];j<W;j++) {
					for(int k=0;k<H;k++) {
						graph[j][k]=1;
					}
				}
				break;
			case 3:
				for(int j=0;j<W;j++) {
					for(int k=0;k<y[i];k++) {
						graph[j][k]=1;
					}
				}
				break;
			case 4:
				for(int j=0;j<W;j++) {
					for(int k=y[i];k<H;k++) {
						graph[j][k]=1;
					}
				}
				break;
			}
		}
		int ans =0;
		for(int i=0;i<W;i++) {
			for(int j=0;j<H;j++) {
				ans += graph[i][j];
	//			System.out.print(graph[i][j]+" ");
			}
		//	System.out.println();
		}
		System.out.println(W*H-ans);
		scanner.close();
	}

}


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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, b) for (int i = a; i < b; i++)

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 int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s; cin >> s;
    int len = s.length();
    vector<int> a(len); rep(i, len) a[i] = 0; //0で初期化

    rep (i, len) {
        if (s[i] == 'L') {
            // 境界に入ったので探索開始
            int k = i - 1;
            int r_cnt = 0;
            int l_cnt = 0;
            int l_border = i;
            int r_border = i - 1;
            while (s[k]=='R') {
                // 左方向の探索
                if ((i - k) % 2 == 0) {
                    l_cnt++;
                } else {
                    r_cnt++;
                }
                k--;
                if (k < 0) {
                    // R探索終了
                    break;
                }
            }
            //右方向の探索の前準備
            k = i;
            i++;
            l_cnt++;
            while (s[i]=='L') {
                //右方向の探索
                if ((i - k) % 2 == 0) {
                    l_cnt++;
                } else {
                    r_cnt++;
                }
                i++;
                if (i == len) {
                    break;
                }
            }
            a[r_border] = r_cnt;
            a[l_border] = l_cnt;
        }
    }
    rep(i, a.size()) cout << a[i] << " ";
} 


Measured memory_bytes: 1104
#include <iostream>

using namespace std;
void go(int sx, int sy, int tx, int ty) {
	for (int i=sy; i<ty; i++) cout << 'U';
	for (int i=sx; i<tx; i++) cout << 'R';
}
void back(int sx, int sy, int tx, int ty) {
	for (int i=ty; i>sy; i--) cout << 'D';
	for (int i=tx; i>sx; i--) cout << 'L';
}
int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	go(sx, sy, tx, ty);
	back(sx, sy, tx, ty);
	cout << 'L';
	go(sx-1, sy, tx, ty+1);
	cout << 'D';
	cout << 'R';
	back(sx, sy-1, tx+1, ty);
	cout << 'U' << endl;
	

	return 0;
}


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

using namespace std;

void Get_Val(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

const int Max_N(2050);

int gcd(const int &a, const int &b)
{
	return b == 0 ? a : gcd(b, a % b);
}

int N, A[Max_N];
vector<int> To[Max_N];

inline void Add_Edge(const int &s, const int &t)
{
	To[s].push_back(t);
}

void init()
{
	Get_Val(N);
	for (int i = 1;i <= N;++i)
		Get_Val(A[i]);
	sort(A + 1, A + 1 + N);
	for (int s = 1;s <= N;++s)
		for (int t = 1;t <= N;++t)
			if (s != t && gcd(A[s], A[t]) > 1)
				Add_Edge(s, t);
}

bool done[Max_N];
vector<int> Ans[Max_N], Tmp;

void merge(vector<int> &u, vector<int> &v)
{
	Tmp.clear();
	for (int a = 0, b = 0;a < u.size() || b < v.size();)
		if (a == u.size())
			Tmp.push_back(v[b++]);
		else
			if (b == v.size())
				Tmp.push_back(u[a++]);
			else
				if (u[a] > v[b])
					Tmp.push_back(u[a++]);
				else
					Tmp.push_back(v[b++]);
	u = Tmp;
}

void dfs(const int &u)
{
	done[u] = true;
	for (int i = 0, v;i != To[u].size();++i)
		if (!done[v = To[u][i]])
			dfs(v), merge(Ans[u], Ans[v]);
	Tmp = Ans[u];
	Ans[u].clear(), Ans[u].push_back(A[u]);
	for (int i = 0;i != Tmp.size();++i)
		Ans[u].push_back(Tmp[i]);
}

void work()
{
	for (int x = 1;x <= N;++x)
		if (!done[x])
			dfs(x), merge(Ans[0], Ans[x]);
	for (int i = 0;i != Ans[0].size();++i)
		printf("%d ", Ans[0][i]);
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 31616
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static String reverse(String s) {
		return new StringBuilder(s).reverse().toString();
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int m = sc.nextInt();
			for(int i=1; i<=m; i++) {
				String s = sc.next();
				TreeSet<String> p = new TreeSet<>();
				for(int j=0; j<s.length()-1; j++) {
					String f = reverse(s.substring(0, j+1));
					String t = reverse(s.substring(j+1));
					p.add(reverse(f) + t);
					p.add(t + reverse(f));
					p.add(reverse(t) + f);
					p.add(f + reverse(t));
					p.add(f + t);
					p.add(t + f);
					p.add(reverse(f) + reverse(t));
					p.add(reverse(t) + reverse(f));
				}
				System.out.println(p.size());
			}
		}
	}
}


Measured memory_bytes: 63052
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRGBBoxes solver = new BRGBBoxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRGBBoxes {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int r = in.nextInt();
            int g = in.nextInt();
            int b = in.nextInt();
            int n = in.nextInt();
            int ans = 0;
            for (int i = 0; i * r <= n; i++) {
                for (int j = 0; j * g <= n; j++) {
                    int rest = n - i * r - j * g;
                    if (rest >= 0 && rest % b == 0) ans++;
                }
            }
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21204
#include <iostream>
 
using namespace std;
 
int main()
{
int h=0, m=0, s=0;
 
cin >>s;
 
h =int(s/3600);
s -=h*3600;
m =int(s/60);
s -=m*60;
 
cout <<h <<":" <<m <<":" <<s <<endl;
 
return 0;
}

Measured memory_bytes: 3112
from collections import defaultdict
from sys import stdin


def main():
    input = lambda: stdin.readline()
    N, M = map(int, input().split())
    KS = [list(map(int, input().split())) for _ in [0] * M]
    P = tuple(map(int, input().split()))

    sw = defaultdict(list)
    for i, ks in enumerate(KS, start=1):
        for s in ks[1:]:
            sw[s].append(i)

    ans = 0
    for mask in range(1 << N):
        light = [0] * M
        sum_ = []
        for i in range(N):
            if mask & 1 << i:
                sum_ += sw[i+1]
        for i in sum_:
            light[i-1] ^= 1
        if P == tuple(light):
            ans += 1
    print(ans)


main()


Measured memory_bytes: 3316
#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() {
    int a;
    char op;
    int b;

    cin >> a >> op >> b;

    int ans =0;
    if (op == '+') ans = a+b;
    if (op == '-') ans = a-b;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

int main() {
char s;
   cin >> s;

 if((s>= 'a') && (s<='z')){
    cout << "a";;
  }
  else if((s>= 'A') && (s<='Z')){
    cout << "A";
  }

}


Measured memory_bytes: 3588
import java.util.*;
import java.lang.Math;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner cin = new Scanner(System.in);
		long N = cin.nextLong();
		long K = cin.nextLong();
		
		long min = N%K;
		
		if(min>Math.abs(min-K)) min = Math.abs(min-K);
		
		System.out.println(min);

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


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

int main()
{
    string S;
    cin>>S;

    if(S=="Sunny")
        cout<<"Cloudy"<<endl;
    else if (S=="Cloudy")
        cout<<"Rainy"<<endl;
    else if ( S=="Rainy")
        cout<<"Sunny"<<endl;
       
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = 0;
  if(A >= B) {
    for(int i = 0; i < 100; i++) {
      B = B * 2;
      ans++;
      if(A < B) {
        break;
      }
    }
  }
  if(B >= C) {
    for(int i = 0; i < 100; i++) {
      C = C * 2;
      ans++;
      if(B < C) {
        break;
      }
    }
  }
  if(ans > K) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

int main(){
    int a,b; 
    string op;
    while(1<2){
    cin>>a>>op>>b;
    if( op =="+")cout<<a+b<<endl;
        else if(op=="-")cout<<a-b<<endl;    
            else if(op=="*")cout<<a*b<<endl;
                else if(op=="/")cout<<a/b<<endl;
                    else break;
    }
}


Measured memory_bytes: 3168
import sys
input = sys.stdin.readline
R, L, K = map(int, input().split())
V = [0]*(R*L)
max2 = lambda x, y: x if x > y else y
for _ in range(K):
    r, c, v = map(int, input().split())
    V[(c-1)*R+(r-1)] = v
A, B, C, D = [[0]*(R+1) for _ in range(4)]
for i in range(L):
    for j in range(R):
        A[j] = max(A[j-1],B[j-1],C[j-1],D[j-1])
        v = V[i*R+j]
        if v != 0:
            D[j], C[j], B[j] = max2(C[j]+v,D[j]), max2(B[j]+v,C[j]), max2(A[j]+v,B[j])
print(max(A[-2],B[-2],C[-2],D[-2]))

Measured memory_bytes: 145780
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  string s;
  cin>>s;
  rep(i,s.length()){
    if(i%2==0)cout<<s[i];
  }

  cout<<endl;
  return 0;
}


Measured memory_bytes: 3604
package main

import (
	"fmt"
	"log"
)

func main() {
	var X int64
  _, err := fmt.Scanf("%d", &X)
  var hund int64
  hund = 100
  counter :=0
  for (hund < X ){
    
    hund += int64(float64(hund)*.01)
    counter++
  }
  

	if err !=nil{
		log.Fatal(err)
  }
  fmt.Print(counter)
}


Measured memory_bytes: 1824
from collections import defaultdict


def main():
    s = input()
    ans = 0
    for i in range(len(s)):
        if i < (len(s) + 2 - 1) // 2:
            if s[i] == "p":
                ans -= 1
        else:
            if s[i] == "g":
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int x[10][10];

int main() {
    int n, d;
    cin >> n >> d;
    rep(i, n) {
        rep(j, d) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int tmp = 0;
            rep(k, d) {
                tmp += pow(x[j][k] - x[i][k], 2);
            }
            if (tmp == pow(floor(sqrt(tmp)), 2)) {
                ans++;
            }
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
struct ToUpper {
    char operator()(char c) { return toupper(c); }
};
struct ToLower {
    char operator()(char c) { return tolower(c); }
};
const int N=200010;
const int P=1000000007;
using ll = long long;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/

/*
	char s[N];
	strlen(s)
*/

/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

/*添字1がa個、2がb個
  vector<vector<ll>> map(a,vector<ll>(b));
*/

int main(){
	char a,b,c;
  cin>>a>>b>>c;
  cout<<a<<b<<c<<endl;
}



Measured memory_bytes: 3632
n,d = map(int,input().split())
l = [list(map(int,input().split()))for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        r = 0
        for k in range(d):
            r += (l[i][k]-l[j][k])**2
        r = r**0.5
        if r == int(r):
            ans += 1
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def calc_det(lis):
  return lis[0]*lis[3]-lis[1]*lis[2]

def sq(x):
  return x*x

for s in sys.stdin:
  d = map(float, s.split() )
  if len(d) == 1:
    continue
  x1,y1,x2,y2,x3,y3 = d[0],d[1],d[2],d[3],d[4],d[5]
  d11 = 2*(x3-x2)
  d12 = 2*(y3-y2)
  d21 = 2*(x2-x1)
  d22 = 2*(y2-y1)
  x11 = sq(x3)-sq(x2)+sq(y3)-sq(y2)
  x21 = sq(x2)-sq(x1)+sq(y2)-sq(y1)
  y12 = x11
  y22 = x21

  x0 = calc_det( [x11,d12,x21,d22] )/calc_det( [d11,d12,d21,d22] )
  y0 = calc_det( [d11,y12,d21,y22] )/calc_det( [d11,d12,d21,d22] )

  r = ( (x0-x1)**2 + (y0-y1)**2 )**0.5

  print "%.3f %.3f %.3f" % (x0,y0,r)

'''
Bibliography
３点を通る円の半径を求む（#７）
http://www.geocities.jp/jtqsw192/FIG/313r/3point_r.htm
'''

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int n;
string s;

int main()
{
  fastio();

  cin >> n >> s;
  if (n % 2) {
    cout << "No\n";
    return 0;
  }

  bool ok = true;
  forn(i,n/2) {
    ok &= s[i] == s[i+n/2];
  }

  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int v[101];
int main()
{
    //freopen("f.in","r",stdin);
    //freopen("f.out","w",stdout);
    int n,x,i;
    scanf("%d%d",&n,&x);
    for(i=1;i<=n;++i)
    {
        scanf("%d",&v[i]);
    }
    sort(v+1,v+n+1);
    i=1;
    while(x>=v[i]&&i<=n)
    {
        x-=v[i];
        i++;
    }
    if(i<=n)
        printf("%d\n",i-1);
    else
    {
        if(x)
            printf("%d\n",n-1);
        else
            printf("%d\n",n);
    }
    return 0;
}


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

int main(){
  string s;cin>>s;
  int a,b,n=s.size();
  rep(i,n){
    if(s[i]=='A'){a=i;break;}
  }
  rep(i,n){
    if(s[n-i-1]=='Z'){b=n-i-1;break;}
  }
  cout<<b-a+1;
}

Measured memory_bytes: 640
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[3];
int b[3];
int main() {
	rep(i, 3){
		cin >> a[i];
	}

	b[0]=abs(a[0] -a[1]);
	b[1]=abs(a[0] -a[2]);
	b[2]=abs(a[1] -a[2]);
	sort(b,b+3);
	cout << b[0]+b[1] << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

def get_sum_digits(n, m):
    r = 0
    while n:
        r, n = r + n % m, n // m
    return r

N = int(input())
ans = 10*5
for i in range(N+1):
    ans = min(ans, get_sum_digits(i, 6) + get_sum_digits(N-i, 9))
print(ans)

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

using namespace std;
int a[100005];
bool check;
long long ans;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(check){
			ans++;
			a[i]--;
		}
		ans+=a[i]/2;
		a[i]%=2;
		if(a[i]&&a[i+1]!=0)check=1;
		else check=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
n,k=map(int,input().split())
a=list(map(int,input().split()))
t={1:0}
g={0:1}
c,d=1,0
while d!=k:
    d+=1
    c=a[c-1]
    if c in t:
        print(g[t[c]+(k-t[c])%(d-t[c])])
        exit()
    else:
        t[c]=d
        g[d]=c
print(c)

Measured memory_bytes: 34316
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
X = load_list()


mn = 2**100
for i in range(1, max(X)+1):
    power = sum([(x-i) * (x-i) for x in X])
    mn = min(power, mn)

print(mn)

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

int main() {
    string S;
    cin >> S;

    bool a = false;
    bool b = false;
    for (auto c = S.begin(); c != S.end(); c++) {
        if (*c == 'A') {
            a = true;
        } else {
            b = true;
        }
        if (a && b) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
b_1 = []
a_2 = []
m.times do |i|
  a, b = gets.split.map(&:to_i)
  if a == 1
    b_1 << b
  end
  if b == n
    a_2 << a
  end
end
if (b_1 & a_2).size > 0 
  puts 'POSSIBLE'
else
  puts 'IMPOSSIBLE'
end

Measured memory_bytes: 9848
import Data.List
import Control.Monad

main = do
 [[a11,a12,a13],[a21,a22,a23],[a31,a32,a33]] <- replicateM 3 (map read . words <$> getLine :: IO[Int])
 let a1 = sort [a11,a12,a13]
 let a2 = sort [a21,a22,a23]
 let a3 = sort [a31,a32,a33]
 let a4 = sort [a11,a21,a31]
 let a5 = sort [a12,a22,a32]
 let a6 = sort [a13,a23,a33]
 let a7 = sort [a11,a22,a33]
 let a8 = sort [a13,a22,a31]
 num <- read <$> getLine :: IO Int
 b <- sort <$> replicateM num (read <$> getLine :: IO Int)
 putStrLn $ if((isSubsequenceOf a1 b) || (isSubsequenceOf a2 b) || (isSubsequenceOf a3 b) || (isSubsequenceOf a4 b) || (isSubsequenceOf a5 b) || (isSubsequenceOf a6 b) || (isSubsequenceOf a7 b) || (isSubsequenceOf a8 b)) then "Yes" else "No"

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

using namespace std;


int main() {
	string divide[4] = { "dream", "dreamer", "erase", "eraser" };

	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++)  reverse(divide[i].begin(), divide[i].end());
	
	bool can = true;
	for (int i = 0; i < s.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; ++j) {
			string d = divide[j];
			if (s.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}
	if (can)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512