akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    while(cin >> n, n){
    int len[] = {5, 7, 5, 7, 7};
    string w[44];
    for(int i = 0; i < n; i++) cin >> w[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int cnt = 0, idx = 0;
        for(int j = i; j < n; j++){
        cnt += w[j].size();
        if(cnt == len[idx]){
            cnt = 0, idx++;
            if(idx == 5) break;
        }else if(cnt > len[idx]){ idx = -1; break;}
        }
        if(idx == 5){ ans = i; break;}
    }
    cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
#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()
{
  string S, T;
  cin >> S >> T;
  T = T.substr(0, S.size());
  if (S == T)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
until (h,w = gets.chomp.split.map(&:to_i)) == [0, 0]
  h.times do |i|
    if i % 2 == 0
      w.times do |j|
        print "#" if j % 2 == 0
        print "." if j % 2 == 1
      end
    else
      w.times do |j|
        print "#" if j % 2 == 1
        print "." if j % 2 == 0
      end
    end
    puts
  end
  puts
end

Measured memory_bytes: 6104
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100000

int main(){
    int n;
    int s_cc[26]={0},t_cc[26]={0};
    int ans = 0;
    string s,t;
    
    cin >> n >> s >> t;
    
    for(int i=0;i<n;i++){
        s_cc[s[i]-'a']++;
        t_cc[t[i]-'a']++;
    }
    
    sort(s_cc,s_cc+26);
    sort(t_cc,t_cc+26);
    
    for(int i=0;i<26;i++){
        ans += max(0,s_cc[i]-t_cc[i]);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl l[n];
    cin(i,l);
    sort(l,l + n);
    intl cnt = 0;
    rep(i,n-1)cnt += l[i];
    fp(cnt > l[n-1]);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[3];
	scanf("%s",a);
	if(a[0]==a[1]&&a[0]!=a[2]&&a[1]!=a[2]){
		printf("Yes");
	}
	else if(a[0]==a[2]&&a[0]!=a[1]&&a[2]!=a[1]){
		printf("Yes");
	}
	else if(a[1]==a[2]&&a[1]!=a[0]&&a[2]!=a[0]){
		printf("Yes");
	}
	else if(a[0]==a[2]&&a[0]==a[1]&&a[1]==a[2]){
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	int v[100005];
	int v1[100005];
	int v2[100005];
	int c1[100005]={0};
	int c2[100005]={0};
	
	cin>>n;
	int cnt1=0;
	int cnt2=0;
	for(int i=0;i<n;i++){
		int t=0;
		cin>>t;
		v[i]=t;
		if(i%2==0){v1[cnt1++]=t;c1[t]++;}
		else {v2[cnt2++]=t;c2[t]++;}
	}
	int ans=0;	
	for(int i=0;i<n;i++)
		if(v[0]==v[i])ans++;
	if(ans==n){cout<<n/2<<endl;return 0;}
	int first1 = c1[0];
    int second1 = c1[0];
    for(int i=0;i<100001;i++)
    {
        if(first1 < c1[i])
        {
            second1 = first1;
            first1 = c1[i];
        }
        else if(second1 < c1[i])
        {
            second1 = c1[i];
        }
	}
	int first2 = c2[0];
    int second2 = c2[0];
    for(int i=0;i<100001;i++)
    {
        if(first2 < c2[i])
        {
            second2 = first2;
            first2 = c2[i];
        }
        else if(second2 < c2[i])
        {
            second2 = c2[i];
        }
	}
	int ffirst1,fsecond1;
	int ffirst2,fsecond2;
	for(int i=0;i<100001;i++)
		if(c1[i]==first1){
			ffirst1=i;break;
		}
	for(int i=0;i<100001;i++)
		if(c1[i]==second1){
			fsecond1=i;break;
		}
	for(int i=0;i<100001;i++)
		if(c2[i]==first2){
			ffirst2=i;break;
		}
	for(int i=0;i<100001;i++)
		if(c2[i]==second2){
			fsecond2=i;break;
		}		
	//cout<<first1<<" "<<second1<<endl;
	//cout<<first2<<" "<<second2<<endl;
	if(ffirst1!=ffirst2){
		int cnt1=0;
		for(int i=0;i<n/2;i++)
			if(ffirst1==v1[i])cnt1++;
		int cnt2=0;
		for(int i=0;i<n/2;i++)
			if(ffirst2==v2[i])cnt2++;
		cout<<(n/2-cnt1)+(n/2-cnt2)<<endl;		
	}else{
		int ans1=100000001,ans2=100000001;
		//if(ffirst1!=fsecond2)
		{
			int cnt1=0;
			for(int i=0;i<n/2;i++)
				if(ffirst1==v1[i])cnt1++;
			int cnt2=0;
			for(int i=0;i<n/2;i++)
				if(fsecond2==v2[i])cnt2++;
			ans1=(n/2-cnt1)+(n/2-cnt2);
		}	
		//if(fsecond1!=ffirst2)
		{
			cnt1=0;
			for(int i=0;i<n/2;i++)
				if(fsecond1==v1[i])cnt1++;
			cnt2=0;
			for(int i=0;i<n/2;i++)
				if(ffirst2==v2[i])cnt2++;
			ans2=(n/2-cnt1)+(n/2-cnt2);
		}
		cout<<min(ans1,ans2)<<endl;		
	}	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char x = sc.next().charAt(0);
        char y = sc.next().charAt(0);
        if(x<y) System.out.println("<");
        else if(y<x) System.out.println(">");
        else System.out.println("=");


    }
}


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

using LL = long long;

int main() {
  LL N, T, Q;
  cin >> N >> T >> Q;

  vector<LL> A(N), D(N);
  set<LL> s[2];
  for(auto i = 0; i < N; ++i) {
    cin >> A[i] >> D[i];
    s[--D[i]].emplace(A[i]);
  }
  s[0].emplace(-2e18);
  s[1].emplace(2e18);

  for(auto q = 0; q < Q; ++q) {
    int X;
    cin >> X;
    if(D[--X]) {
      auto x = *--s[0].upper_bound(A[X]);
      auto y = *s[1].upper_bound(x);
      cout << max(A[X]-T, x+(y-x)/2) << endl;
    } else {
      auto x = *s[1].upper_bound(A[X]);
      auto y = *--s[0].upper_bound(x);
      cout << min(A[X]+T, x-(x-y)/2) << endl;
    }
  }
}

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

int main() {
  string a;
  cin >> a ;
  
  for(int i =0;i<3;i++){
    if(a[i] == '1') a[i] = '9';
    else if (a[i] =='9') a[i] ='1';
  }
  
 
     cout << a << endl;
}
  




Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}
func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	a := make([]int, M)
	for i := range a {
		fmt.Scan(&a[i])
	}
	var ca, cb int
	for i := X; i >= 0; i-- {
		for j := 0; j < M; j++ {
			if a[j] == i {
				ca++
			}
		}
	}
	for i := X; i <= N; i++ {
		for j := 0; j < M; j++ {
			if a[j] == i {
				cb++
			}
		}
	}
	fmt.Println(min(ca, cb))
}


Measured memory_bytes: 512
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long w = read.to!long;
	long h = read.to!long;
	long x = read.to!long;
	long y = read.to!long;
	
	if(x * 2 == w && y * 2 == h){
		writeln((w * h).to!real / 2.0, " ", 1);
	}
	else{
		writeln((w * h).to!real / 2.0, " ", 0);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N, 0);
  for (ll i = 0; i < N; i++) {
    cin >> L[i];
  }

  // 昇順にソートする
  sort(L.begin(), L.end());

  ll ans = 0;
  // a <= b <= c
  // a, bを固定する
  for (ll i = 0 ; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      ll a = L[i];
      ll b = L[j];

      // a + b 以下となる最初の値
      auto iter = lower_bound(L.begin(), L.end(), a + b);
      ll index = iter - L.begin();

      ans += max(index - j - 1, (ll)0);
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=a;i>b;i--)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF=1e18;

int main(){
 ll n; cin >> n;
 vector <ll> v(n);
 f(i,0,n){
   cin>>v[i];
 }

 vector <ll> dp(n,INF);
 dp[0]=0;

 f(i,0,n){
   f(j,i+1,i+3){
     if(j<n){
     dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
     }
   }
 }

 cout << dp[n-1] << endl;

}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>

using namespace std;

const int NMAX = 105;
const int KMAX = 1e5+5;
const int MOD = 1e9+7;

int dp[NMAX][KMAX],sp[NMAX][KMAX];
int a[NMAX];
//dp[i][j] = nr of ways to share j candies among [1..i] children
//adaug la dp[i][j] = dp[i-1][j-a[i]] + dp[i-1][j-a[i]+1] + ... + dp[i-1][j]

int main()
{
    int N,K,i,j;
    cin>>N>>K;

    for(i = 1 ; i <= N ; ++i)
        cin>>a[i];

    dp[0][0] = 1;
    for(i = 1 ; i <= N ; ++i)
    {
        for(j = 0 ; j <= K ; ++j)
        {
            sp[i-1][j] = dp[i-1][j];
            if(j > 0)
                sp[i-1][j] = (1LL*sp[i-1][j] + 1LL*sp[i-1][j-1])%MOD;
            dp[i][j] = sp[i-1][j];
            if(j > a[i])
                dp[i][j] -= sp[i-1][j-a[i]-1];
            if(dp[i][j] < 0)
                dp[i][j] += MOD;
        }
    }

    cout<<dp[N][K];

    return 0;
}


Measured memory_bytes: 82176
// package other2017.codefestival2017.finale;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);


        char[] line = in.nextToken().toCharArray();

        int[] cnt = new int[255];
        for (int i = 0; i < line.length; i++) {
            cnt[line[i]]++;
        }

        int a = cnt['a'];
        int b = cnt['b'];
        int c = cnt['c'];

        int min = Math.min(a, Math.min(b, c));
        int max = Math.max(a, Math.max(b, c));

        out.println(max - min <= 1 ? "YES" : "NO");
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
#include<cstring>
#define INF -1
using namespace std;
void dfs(int,int);
int dist[91][91],y,x,cnt=0,mx,m,n;
int dx[4]={0,1,0,-1},
	dy[4]={1,0,-1,0};
int main(void)
{
	int i,j,k;
	while(1) {
		cin>>m>>n;
		mx=-1;
		if(m==0&&n==0) break;
		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				dist[i][j]=0;
			}
		}
		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				cin>>dist[i][j];
			}
		}
		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				if(dist[i][j]==1) {
					cnt=0;
					dfs(i,j);
				}
			}
		}
		cout<<mx<<endl;
	}
	return 0;
}
void dfs(int x,int y)
{
	int i,j,k;
	for(i=0;i<4;i++) {
		if(dist[y+dy[i]][x+dx[i]]==1&&
		   y+dy[i]<=n&&y+dy[i]>=0&&
		   x+dx[i]<=m&&x+dx[i]>=0) {
			cnt++;
			dist[y+dy[i]][x+dx[i]]=0;
			mx=max(mx,cnt);
			dfs(x+dx[i],y+dy[i]);
			cnt--;
			dist[y+dy[i]][x+dx[i]]=1;
		}
	}
}
	

Measured memory_bytes: 3076
def Ex_dice(n):
    return (n+1) / 2

n, k = map(int, input().split())
p = list(map(int, input().split()))

Ex = []
for m in range(n):
    Ex.append(Ex_dice(p[m]))
    
s = [0]*(n+1)
for j in range(n):
    s[j+1] = s[j] + Ex[j]
    
res = -100000
for i in range(n-k+1):
    val = s[k+i] - s[i]
    if res < val:
        res = val
print(res)

Measured memory_bytes: 24804
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <unordered_map>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)RV(A,N);
  std::unordered_map<i8t,int> m;
  for(auto a:A){
    if(m.find(a)==m.end())
      m[a]=1;
    else
      m[a]++;
  }
  std::vector<i8t> e;
  for(auto pair:m){
    if(pair.second>=4){
      e.push_back(pair.first);
      e.push_back(pair.first);
    }else if(pair.second>=2)
      e.push_back(pair.first);
  }

  std::sort(e.begin(),e.end());
  if(e.size()>=2){
    P(e[e.size()-1]*e[e.size()-2]);
  }else P(0);
  return 0;
}



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

int main()
{
	int a,b,x,max,min;
	cin>>a>>b;
	if(a>b)
	{
		max=a;
		min=b;
	}
	else
	{
		min=a;
		max=b;
	}
	if((max-min)%2==0)
	{
		x=(max-min)/2+min;
	}
	else
	{
		x=(max+1-min)/2+min;
	}
	cout<<x;
	return 0;
}

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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

lli dp[300][300];

int main()
{
    lli sum = 0, n;

    cin >> n;
    for(lli i=1; i<=n; i++){
        for(lli j=1; j<=n; j++){
            for(lli k=1; k<=n; k++){
                if(dp[j][k] == 0){
                    dp[j][k] = __gcd(j, k);
                }
                lli x = dp[j][k];
                if(dp[i][x] == 0){
                    dp[i][x] = __gcd(i, x);
                }
                sum += dp[i][x];
            }
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4080
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll n, k;
  std::cin >> n >> k;
  std::vector< ll > va(n, 0);
  for (ll i = 0; i < n; i++) {
    std::cin >> va[i];
  }

  std::vector< ll >::iterator it = std::min_element(va.begin(), va.end());
  ll min_idx = std::distance(va.begin(), it);

  ll ans = 1e12;
  for (ll i = 0; i < k; i++) {
    ll left  = i;
    ll right = k - i -1;
    ll l_cnt = (min_idx - left <= 0) ? 0 : (min_idx - left) / (k-1) + ((min_idx - left) % (k-1) != 0 ? 1 : 0);
    ll r_cnt = (n - min_idx -1 - right <= 0) ? 0 : (n - min_idx -1 - right) / (k-1) + ((n - min_idx -1 - right) % (k-1) != 0 ? 1 : 0);
    //std::cout << "i:" << i << " left:" << left << " right:" << right << " " << l_cnt << " " << r_cnt << std::endl;
    ans = std::min(ans, l_cnt + r_cnt + 1);
  }

  std::cout << ans << std::endl;

  return 0;
}



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

int main()
{
  int p[10];
  for(int i = 0; i < 5; i++) cin >> p[i];
  int k; cin >> k;
  if(p[4] - p[0] <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


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

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,x;
	map<int,int> mp;
	mp.clear();
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> x;
		if(mp[x]==1)
			break;
		mp[x]=1;
	}
	if(i==n)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;
using namespace std;

const ll num =1000000000000001;

int main() {
    ll n;
    cin>>n;
    string alp="abcdefghijklmnopqrstuvwxyz";
    string name="";
    while (n>0){
        --n;
        name = alp[n%26] + name;
        n /= 26;
    } 
    cout<<name<<endl;
    

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a; 
  int cnt = 0;
  vector<int> vec(a);
  for (int i = 0; i < a; i++) {
    cin >> vec.at(i);
    if (vec.at(i) % 2 != 0) cnt++;
  }
  if (cnt % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int a, b;
  int temp;
  int i;

  for(i=0;i<3000; i++){
    scanf("%d %d", &a, &b);

    if(a == 0 && b==0) break;

    if(a > b){
      temp = a;
      a = b;
      b = temp;
    }

    printf("%d %d\n", a, b);
  }

  return 0;
}



Measured memory_bytes: 2044
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int n,i,j,a,b,d[1000010],e[1000010],f[1000010],min;
int main(){
  char s[1000010];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    for(j=a=min=0;s[j];j++){
      if(s[j]=='(')a++;
      else         a--;
      if(min>a)min=a;
    }
    d[i]=min;
    e[i]=a;
  }
  for(i=0;i<n;i++){
    if(e[i]>=0){
      f[R]=e[i];
      hin(d[i]);
    }
  }
  a=0;
  while(C-1){
    i=hout();
    if(a+N[i]<0)goto END;
    a+=f[i];
  }
  R=C=1;
  for(i=0;i<n;i++){
    if(e[i]<0){
      f[R]=-e[i];
      hin(d[i]-e[i]);
    }
  }
  b=0;
  while(C-1){
    i=hout();
    if(b+N[i]<0)goto END;
    b+=f[i];
  }
  if(a-b)goto END;
  printf("Yes\n");
  return 0;
 END:;
  printf("No\n");
  return 0;
}
	 


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

using namespace std;

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

typedef long long ll;

const ll Inf = 1e15;
const double EPS = 1e-9;

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 bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    int mal[3];
    ll ans = -Inf;
    cin >> n >> m;
    vector<vector<ll> > a(n, vector<ll>(3, 0));
    rep (i, n) rep (j, 3) cin >> a[i][j];

    rep (bit, 1 << 3) {
        rep (k, 3) {
            if ((bit >> k) & 1) mal[k] = 1;
            else mal[k] = -1;
        }

        priority_queue<ll> pq;
        rep (i, n) {
            ll s = 0;
            rep (j, 3) {
                s += (a[i][j] * mal[j]);
            }
            pq.push(s);
        }

        ll sum = 0;
        rep (i, m) {
            sum += pq.top();
            pq.pop();
        }

        ans = max(ans, sum);
    }
    cout << ans << endl;
    
    return 0;
}



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

int main(){
	int N; cin >> N;
	rep(i,500009){
		int tmp;
		tmp = i * 1.08;
		if(N == tmp) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;

}










Measured memory_bytes: 3632
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


int h, w;
int a[555][555];

void calc() {
	REP(i, h)REP(j, w) {
		if (a[i][j]) {
			a[i][j] = 0;
			return;
		}
	}
}

int main() {
	cin >> h >> w;
	int cnt = 0;
	REP(i, h)REP(j, w) {
		cin >> a[i][j];
		a[i][j] %= 2;
		if (a[i][j])cnt++;
	}
	if (cnt % 2 == 1) {
		calc();
	}
	vector<tuple<int, int, int, int>>ans;
	for (int i = 0; i < h; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < w; j++) {
				if (a[i][j]) {
					if (j + 1 == w) {
						ans.emplace_back(make_tuple(i, j, i + 1, j));
						a[i + 1][j]++;
						a[i + 1][j] %= 2;
					}
					else {
						ans.emplace_back(make_tuple(i, j, i, j + 1));
						a[i][j + 1]++;
						a[i][j + 1] %= 2;
					}
				}
			}
		}
		else {
			for (int j = w - 1; j >= 0; j--) {
				if (a[i][j]) {
					if (j == 0) {
						ans.emplace_back(make_tuple(i, j, i + 1, j));
						a[i + 1][j]++;
						a[i + 1][j] %= 2;
					}
					else {
						ans.emplace_back(make_tuple(i, j, i, j - 1));
						a[i][j - 1]++;
						a[i][j - 1] %= 2;
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
	for (auto a : ans) {
		cout << get<0>(a) + 1 << " " << get<1>(a) + 1 << " " << get<2>(a) + 1 << " " << get<3>(a) + 1 << endl;
	}
	//system("pause");
}

Measured memory_bytes: 5232
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;

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

	string s;cin>>s;
	s+='T';
	int x,y;cin>>x>>y;
	vector<ll> tate,yoko;
	tate.push_back(0);yoko.push_back(0);
	int cnt=0,flag=1;
	int dir=0,d=0;//0->x,1->y
	for(int i=0;i<(int)s.length();i++){
		if(s[i]=='T'){
			if(d!=0 && !flag){
				if(dir) tate.push_back(d);
				else yoko.push_back(d); 
			}
			flag=0;
			dir = 1-dir;
			d=0;
		}
		else{
			d++;
			if(flag) cnt++;
		}
	}
	x-=cnt;
	//目的地は(x,y)
	int len=yoko.size();
	vector<ll> x_old(20001,0),x_new(20001,0);
	x_old[10000]=1;
	for(int i=1;i<len;i++){
		for(int j=0;j<20000;j++){
			if(x_old[j]){
				x_new[j+yoko[i]]=1;
				x_new[j-yoko[i]]=1;
			}
		}
		for(int j=0;j<20000;j++){
			x_old[j]=x_new[j];
		}
		for(int j=0;j<20000;j++) x_new[j]=0;
	}
	if(x_old[x+10000]==0){
		cout<<"No"<<endl;
		return 0;
	}
	len=tate.size();
	vector<ll> y_old(20001,0),y_new(20001,0);
	y_old[10000]=1;
	for(int i=1;i<len;i++){
		for(int j=0;j<20000;j++){
			if(y_old[j]){
				y_new[j+tate[i]]=1;
				y_new[j-tate[i]]=1;
			}
		}
		for(int j=0;j<20000;j++){
			y_old[j]=y_new[j];
		}
		for(int j=0;j<20000;j++) y_new[j]=0;
	}
	if(y_old[10000+y]==0){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  i64 answer = 0;
  for (auto it1 = A.begin(), it2 = A.begin() + 1; it2 != A.end(); ++it1, ++it2) {
    if (*it1 % 2 == 1 && *it2 > 0) {
      ++answer;
      --*it1;
      --*it2;
    }
  }
  for (i64& A_i : A) {
    answer += A_i / 2;
    A_i %= 2;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 1000001;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	int a[n],b[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[a[i]]=i;
	}
	set<int> s;
	ll ans=0;
	s.insert(-1);
	s.insert(n);
	for(int x=1;x<=n;x++)
	{
		int y=b[x];
		auto it=s.lower_bound(y);
		int r=*it;
		it--;
		int l=*it;
		ans+=1LL*(x)*(y-l)*(r-y);
		s.insert(y);
	}
cout<<ans;
}


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

string str;

set<int> search(int s,int e){
	set<int> a,b,c;
	set<int>::iterator it1,it2;
	int level=0;
	for(int i=s;i<=e;i++){
		if(str[i]=='(')level++;
		else if(str[i]==')')level--;
		if(level==0 && (str[i]=='+'||str[i]=='-'||str[i]=='*'||str[i]=='/')){
			a=search(s,i-1);
			b=search(i+1,e);
			for(it1=a.begin();it1!=a.end();++it1){
				for(it2=b.begin();it2!=b.end();++it2){
					if(str[i]=='+')c.insert(*it1 + *it2);
					else if(str[i]=='-')c.insert(*it1 - *it2);
					else if(str[i]=='*')c.insert(*it1 * *it2);
					else if(*it2 != 0)c.insert(*it1 / *it2);
				}
			}
		}
	}
	if(c.empty()){
		if(str[s]=='('&&str[e]==')')return search(s+1,e-1);
		int num=0;
		while(s<=e){
			num=10*num+str[s++]-'0';
		}
		c.insert(num);
	}
	return c;
}

int main(){
	while(cin>>str,str[0]!='#'){
		cout<<search(0,str.length()-1).size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1268
a = [0,1,2,3,4,5,6,7,8,9]

wa_lis = []
num = 0
def wa(n,k,m):
    global num

    if n == 10 and m == 0 and k == 0:
        num += 1
    if n == 10:
        return
    return wa(n + 1,k - a[n],m - 1) or wa(n+1,k,m)

while True:
   
    n,s = map(int,input().split())
    if [n,s] == [0,0]:
        break
    wa(0,s,n)
    print(num)
    num = 0

Measured memory_bytes: 7572
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

using integer = unsigned long long;

int main(void) {
  integer N;
  std::cin >> N;

  integer power = 1;
  integer div = std::pow((integer)10, 9) + 7;
  for (int i = 0; i < N; i++) {
    power *= i + 1;
    power %= div;
  }

  std::cout << power << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long sum = 0;
        long k = 1;
        for (long i = health; i > 0;) {
            i /= 2;
            sum += k;
            k *= 2;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<ll> v( N ), vv( N );
	rep( i, N ) { cin >> v[i]; vv[i] = v[i]; }

	sort( ALL( v ) );

	// 全体の中央値
	ll midMin = v[( N - 1 ) / 2];
	ll midMax = v[( N - 1 ) / 2 + 1];

	rep( i, N )
	{
		if ( vv[i] <= midMin )
		{
			cout << midMax << endl;
		}
		else
		{
			cout << midMin << endl;
		}
	}

	return ( 0 );
}


Measured memory_bytes: 5376
import sys

cnt = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = range(n1 + 1)
    R = range(n2 + 1)

    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = 1000000000
    R[n2] = 1000000000
    i = j = 0
    global cnt

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) / 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    S = map(int, lines[1].split())
    mergeSort(S, 0, int(lines[0]))
    print cnt

Measured memory_bytes: 25900
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            long t = 1;
            long a = 1;

            for (int i = 0; i < N; i++) {
                long T = sc.nextLong();
                long A = sc.nextLong();

                long tx = -1;
                long ax = -1;

                for (int ti = 0; ti < T; ti++) {
                    if ( (t + ti) % T == 0 ) {
                        tx = t + ti;
                        ax = (tx / T) * A;
                    }
                }

                long ty = -1;
                long ay = -1;

                for (int ai = 0; ai < A; ai++) {
                    if ( (a + ai) % A == 0 ) {
                        ay = a + ai;
                        ty = (ay / A) * T;
                    }
                }

                long tn = -1;
                long an = -1;

                if ( tx >= t && ax >= a ) {
                    tn = tx;
                    an = ax;
                }

                if ( tn == -1 || ty >= t && ay >= a && (ty + ay) < (tn + an) ) {
                    tn = ty;
                    an = ay;
                }

                t = tn;
                a = an;

                if ( t == -1 ) {
                    int zero = 1 / 2;
                    int hoge = 10 / zero;
                }
            }

            System.out.println(t + a);
        }
    }
}


Measured memory_bytes: 24944
#include<cstdio>
#include<cstring>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;
char s[11]; int n;
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if(s[1] != 'A') printf("WA"); else {
		fo(i, 1, n) {
			if((s[i] < 'a' || s[i] > 'z') && s[i] != 'A' && s[i] != 'C') {
				printf("WA"); return 0;
			}
		}
		if(s[2] == 'C' || s[n] == 'C') {
			printf("WA"); return 0;
		}
		int sum = 0;
		fo(i, 3, n - 1) sum += s[i] == 'C';
		if(sum == 1) printf("AC"); else printf("WA");
	}
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 500001

 int A[MAX];
 int H;

 void maxHeap(int i){
           int left,right,largest,tmp;
           left=i*2;
           right=i*2+1;

           if(H>=left && A[i]<A[left])largest=left;
           else largest=i;
           if(H>=right && A[right]>A[largest])largest=right;

           if(largest!=i){tmp=A[largest];A[largest]=A[i];A[i]=tmp;maxHeap(largest);}
           
           }


 int main(){
        int i;
        scanf("%d",&H);
        for(i=1;i<=H;i++){scanf("%d",&A[i]);}
        
        for(i=H/2;i>=1;i--){maxHeap(i);}

        for(i=1;i<=H;i++){printf(" %d",A[i]);}
        printf("\n");
        return 0;
        }



Measured memory_bytes: 3668
// AtCoder Beginner Contest 089 - Problem C: March (https://atcoder.jp/contests/abc089/tasks/abc089_c) 
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    const string march { "MARCH" };
    vector<ll> hs { 0, 0, 0, 0, 0 };

    while (N--)
    {
        string w;
        cin >> w;

        auto i = march.find(w.front());

        if (i != string::npos)
            hs[i]++;        
    }

    ll ans = 0;

    for (int i = 0; i < 5; ++i)
        for (int j = i + 1; j < 5; ++j)
            for (int k = j + 1; k < 5; ++k)
                ans += (hs[i] * hs[j] * hs[k]);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	string str;
	cin >> str;
	bool chk = true;
	int cnt = 0;
	int i = -1, j = n;
	while (i < j)
	{
		while (++i < j && str[i] == 'R')
		{
		}
		while (--j > i && str[j] == 'W')
		{
		}
		if (i < j)
			swap(str[i], str[j]), cnt++;
	}
	bool b = false;
	for (int i = 0; i < n; ++i)
	{
		if (str[i] == 'W')
			b = true;
		if (b && str[i] == 'R')
			cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3780
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <math.h>
#include <map>
#include <algorithm>


using namespace std;
int main()
{
	int N, cnt = 1, H[30], tmp;
	cin >> N;

	cin >> H[0];
	tmp = H[0];
	for (int i = 1; i < N; i++) {
		cin >> H[i];
		if (tmp <= H[i]) {
			tmp = H[i];
			cnt++;
		}
	}

	printf("%d", cnt);

	return 0;

}

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

int main() {
    int n, t, result = 0;
    cin >> n >> t;
    pair<int, int> dish[n];
    for (int i = 0; cin >> dish[i].first >> dish[i].second; i++) {
    }
    sort(dish, dish + n);
    int dp[t] = {};
    for (int i = 0; i < n; i++) {
        result = max(result, dp[t - 1] + dish[i].second);
        for (int w = t - 1; w >= 0; w--) {
            if (dish[i].first <= w) {
                dp[w] = max(dp[w], dp[w - dish[i].first] + dish[i].second);
            }
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 256
S = input() + 'R'
R = 0
L = 0
ans = [0] * (len(S))
for i in range(len(S)):
    if S[i] == 'R':
        R += 1
        if L > 0:
            ans[i - L] += (L + 1) // 2
            ans[i - L - 1] += L // 2
            L = 0
    elif S[i] == 'L':
        L += 1
        if R > 0:
            ans[i] += R // 2
            ans[i - 1] += (R + 1)// 2
            R = 0
print(*ans[:-1])


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

int main() {
    vector<vector<int>> a(3,vector<int> (3,0));
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3) rep(k,3) if(a[j][k] == b) a[j][k] = 0;
    }
    bool ans = false;
    rep(i,3){
        if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0) ans=true;
        if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0) ans=true;
    }
    if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0) ans = true;
    if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0) ans = true;    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

const int MAXN = 55, MAXM = 20;

int n, m, dep[MAXN];
point par[MAXN];
vector <point> E[MAXN];
bitset<MAXN> imam[1 << MAXM];
ll dp[1 << MAXM];

void dfs(int x, int p = -1){
  for(auto e : E[x]){
    if(e.first == p) continue;
    par[e.first] = point(x, e.second);
    dep[e.first] = dep[x] + 1;
    dfs(e.first, x);
  }
}

void ubaci(int x, int y, int mask){
  if(dep[x] < dep[y])
    swap(x, y);
  while(dep[x] != dep[y]){
    imam[mask].set( par[x].second );
    x = par[x].first;
  }
  while(x != y){
    imam[mask].set( par[x].second );
    imam[mask].set( par[y].second );
    x = par[x].first;
    y = par[y].first;
  }
}

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

  cin >> n;
  REP(i, n - 1){
    int a, b; cin >> a >> b;
    a --; b --;
    E[a].pb(point(b, i));
    E[b].pb(point(a, i));
  }
  dfs(0);
  cin >> m;
  REP(i, m){
    int a, b; cin >> a >> b;
    a --; b --;
    ubaci(a, b, (1 << i));
  }

  FOR(mask, 1, (1 << m)){
    if(__builtin_popcount(mask) > 1)
      REP(j, m)
        if(mask & (1 << j)){
          imam[mask] |= imam[(1 << j)];
          imam[mask] |= imam[ mask ^ (1 << j) ];
          break;
        }

    int pot = n - 1 - imam[mask].count();
    dp[mask] = (1LL << pot);
  }

  ll sol = 0;
  FOR(mask, 1, (1 << m)){
    if(__builtin_popcount(mask) % 2)
      sol += dp[mask];
    else
      sol -= dp[mask];
  }

  cout << (1LL << (n - 1)) - sol;
}


Measured memory_bytes: 16640
#include <cstdio>
#include <iostream>
#include <stack>

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

#define INF 1000000000
#define W_MAX 20
#define H_MAX 20

#define V '0' //vacant
#define B '1' //block
#define S '2' //start
#define G '3' //goal

char map[W_MAX][H_MAX];
int dx[] = {-1,0,0,1};
int dy[] = {0,1,-1,0};
int W,H;

int solve(pii s, int dep){ //s:start, dep:depth
  if(dep>=10) return -1;

  /*
  for(int i=0; i<H; i++){
    for(int k=0;k<dep;k++) cout << ' ';
    for(int j=0; j<W; j++){
      if(i==s.first&&j==s.second) cout << S;
      else cout <<map[i][j];
    } cout << endl;
  }
  */

  int res = INF;

  for(int i=0; i<4; i++){
    //check movable
    bool move=false;
    int nx=s.first+dx[i]; int ny=s.second+dy[i];
    if(map[nx][ny]==B) continue;
    while(nx>=0 && nx<H && ny>=0 && ny<W){
      if( map[nx][ny]==G ){
	return 1;
      } else if(map[nx][ny]==B){
	move=true;
	break;
      }
      nx+=dx[i]; ny+=dy[i];
    }

    if(!move) continue;

    //move stone
    map[nx][ny] = V;
    int sol = solve(make_pair(nx-dx[i], ny-dy[i]), dep+1);
    if(sol!=-1) res = min(res, sol+1);

    //restore status
    map[nx][ny] = B;
  }

  if(res==INF) return -1;
  else return res;

}

int main(){
  while(true){
    cin >> W >> H;
    getchar();

    if(W==0 && H==0) break;

    pii s; //start
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
	scanf("%c", &map[i][j]);
	getchar();
	if(map[i][j]==S){
	  s = make_pair(i,j);
	  map[i][j] = V;
	}
      }
    }

    int ans = solve(s,0);

    cout << ans << endl;
  }
}

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

using namespace std;

int main()

{

    int n;
    cin>>n;

    string s;
    cin>>s;

    if(n%2!=0)
    {
        cout<<"No"<<endl;
        return 0;
    }

    for(int i=0,j=n/2;i<n/2;i++,j++)
    {
        if(s[i]!=s[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

      cout<<"Yes"<<endl;





    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

import copy
class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)

    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int, read().split())
    seg = SegmentTree(N, gcd, 0)
    for i in range(N):
        seg.assign(i, next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)

main()


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

using ll = long long;

int main() {
    int n; cin >> n;
    priority_queue<int, vector<int>, greater<>> que;
    for(int i = 0; i < n; ++i) {
        int m; cin >> m;
        vector<int> b(m);
        for(int j = 0; j < m; ++j) {
            cin >> b[j];
        }
        sort(rbegin(b), rend(b));
        que.push(b[0]);
        for(int j = 1; j < m; ++j) {
            if(que.top() < b[j]) {
                que.pop();
                que.push(b[j]);
            }
        }
    }
    ll ans = 0;
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}



Measured memory_bytes: 4856