akhauriyash/Code-Regression huggingface dataset:
N = int(input())
judge = [input() for i in range(N)]

N_ac = judge.count('AC')
N_wa = judge.count('WA')
N_tl = judge.count('TLE')
N_re = judge.count('RE')

print('AC x ' + str(N_ac))
print('WA x '+str(N_wa))
print('TLE x '+str(N_tl))
print('RE x '+str(N_re))



Measured memory_bytes: 16304
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    array<char, 9> ar;
    char h;
    REP(i, 9)
    {
        cin >> h;
        ar[i] = h;
    }
    cout << ar[0] << ar[4] << ar[8];
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define eps 1e-7
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
LL arr[Maxn];
const int mod=1000000007;
void init()
{
	arr[1]=1;
	for(int i=2;i<Maxn;i++)
		arr[i]=i*arr[i-1]%mod;
}
int main()
{
	LL m,n;
	init();
	//input;output;
	while(~scanf("%lld%lld",&m,&n))
	{
		if(abs(m-n)>1)
		{
			puts("0");
			continue;
		}
		printf("%lld\n",m==n?2*arr[m]*arr[n]%mod:arr[m]*arr[n]%mod);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAX = 1000;

typedef pair<string, vector<int> > pp;

int main()
{
    string s;
    int n;
    vector<pp> ind;
    vector<int> emp;

    while(cin >> s >> n)
    {
        bool found = false;
        REP(ind.size() )if(ind[i].first == s){ ind[i].second.push_back(n); found = true; break; }
        if(found)continue;

        ind.push_back(pp(s,emp));
        ind[ind.size() - 1].second.push_back(n);
    }
    sort(all(ind));


    REP(ind.size())
    {
        //sort(ind[i].second.begin(), ind[i].second.end());
        sort(all(ind[i].second));
        cout << ind[i].first << endl;
        rep(j, ind[i].second.size())
        {
            cout << ind[i].second[j] ;
            if(j == ind[i].second.size() - 1) break;
            cout << " " ;
        }

        cout << endl ;
    }
    return 0;
}

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

int main(int argc, char* argv[]) {
	int K;
	string S;
	cin >> K >> S;

	int i = 0;
	int end = min(K, (int)S.length());
	for (i = 0; i < end; i++) {
		cout << S[i];
	}
	if (i != S.length()) {
		cout << "...";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

char trans(char x, char y){
    if(x == 'A'){
        if(y == 'A'){
            return 'B';
        }else if(y == 'B'){
            return 'E';
        }else{
            return 'A';
        }
    }else if(x == 'B'){
        if(y == 'A'){
            return 'E';
        }else if(y == 'B'){
            return 'A';
        }else{
            return 'B';
        }
    }else{
        if(y == 'A'){
            return 'A';
        }else if(y == 'B'){
            return 'B';
        }else{
            return 'E';
        }
    }
}

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

    string S,T;
    cin >> S >> T;
    LL q;
    cin >> q;
    vector<tuple<LL,LL,LL,LL>> query;
    for(int i = 0; i < q; i++){
        LL a,b,c,d;
        cin >> a >> b >> c >> d;
        query.push_back(make_tuple(a,b,c,d));
    }

    vector<vector<char>> pres(3,vector<char>(S.size()+1)),pret(3,vector<char>(T.size()+1));
    pres[0][0] = 'E';
    pres[1][0] = 'A';
    pres[2][0] = 'B';
    pret[0][0] = 'E';
    pret[1][0] = 'A';
    pret[2][0] = 'B';

    for(int j = 0; j < 3; j++){
        for(int i = 1; i < S.size()+1; i++){
            pres[j][i] = trans(pres[j][i-1],S[i-1]);
        }
    }

    for(int j = 0; j < 3; j++){
        for(int i = 1; i < T.size()+1; i++){
            pret[j][i] = trans(pret[j][i-1],T[i-1]);
        }
    }

    for(int i = 0; i < q; i++){
        LL a,b,c,d;
        a = get<0>(query[i]);
        b = get<1>(query[i]);
        c = get<2>(query[i]);
        d = get<3>(query[i]);
        char x;
        for(int j = 0; j < 3; j++){
            if(pres[j][a-1] == 'E'){
                x = pres[j][b];
            }
        }
        char y;
        for(int j = 0; j < 3; j++){
            if(pret[j][c-1] == 'E'){
                y = pret[j][d];
            }
        }
        if(x == y){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main(void)
{
	int n, c, k;
	vector<int>t;
	cin >> n >> c >> k;
	for (int i = 0; i < n; ++i)
	{
		int tt; cin >> tt; t.push_back(tt);
	}
	int ans = 0;
	sort(t.begin(), t.end());
	auto itr = t.begin();
	for (;;)
	{
		int lim = (*itr) + k;
		for (int i = 0; i < c; ++i)
		{
			++itr;
			if (t.end() == itr)
			{
				break;
			}
			if (*itr > lim)break;
		}
		++ans;
		if (t.end() == itr)
		{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long Int;

int main(){
	Int N;
	cin >> N;
	for(Int h = 1;h <= 3500;h++){
		for(Int n = 1;n <= 3500;n++){
			Int a = N*n*h;
			Int b = 4*n*h-N*n-N*h;
			if(b <= 0)continue;
			if(a > b && a % b == 0){
				cout << n << " " << h << " " << a/b << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;

    cin>>n;

    long long minn=n;

    for(long long i=1;i<=sqrtl(n);i++)
    {
        if(n%i==0)
        {
            minn=min(minn,i+(n/i)-2);
        }
    }

    cout<<minn<<endl;

    return 0;
}




Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

a = []
b = []

for i in range(A, B + 1):
  a.append(i)

for i in range(C, D + 1):
  b.append(i)

a.extend(b)

ans = [x for x in set(a) if a.count(x) > 1]
if len(ans) == 0:
  print(len(ans))
else:
  print(len(ans) - 1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
//Node T_root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  y=NIL;
  x=root;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}

Node find(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}
  
void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if(com[0]=='f'){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int a, b; cin >> a >> b; cout << a * b;
}


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

using ll = long long;

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

    int a[5];
    rep(i, 5) {
        cin >> a[i];
        if (a[i] == 0) cout << i + 1 << endl; 
    }
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <cstdlib>

int main( void )
{
    std::string str;

    std::cin >> str;

    for( auto it = str.begin(); it != str.end(); it++ ){
        if( *it == '1' ){
            *it = '9';
        }
        else if( *it == '9' ){
            *it = '1';
        }
    }

    std::cout << str << std::endl;
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

const double eps = 1e-7;
const int MOD = 1000000007;
const int MOD_MAX = 200000;

using ll = long long;
using vi = vector<int>; using vi2 = vector<vi>; using vi3 = vector<vi2>;
using vll = vector<ll>; using vll2 = vector<vll>; using vll3 = vector<vll2>;
using vd = vector<double>; using vd2 = vector<vd>; using vd3 = vector<vd2>;
using pi = pair<int, int>; using pll = pair<ll, ll>;
using vpi = vector<pi>; using vpll = vector<pll>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define rloopll(i, n) for (int i = (ll)n - 1; i >= 0; i--)
#define rlooplleq(i, n) for (int i = (ll)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

bool feq(float x, float y) { return abs(x-y) <= eps; }
bool deq(double x, double y) { return abs(x-y) <= eps; }
int ceillog2(ll x) { return int (ceil(log2(x))); }
int floorlog2(ll x) { return int (floor(log2(x))); }
template<class T> T reversed (T container) { reverse(container.begin(), container.end()); return container; }
template<class T> T sort (T container) { sort(container.begin(), container.end()); return container; }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

int main() {
	int n, m; cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define int long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
pi a[200100];
int n;
bool com(pi A,pi B)
{
    if(A.S==B.S)
        return A.F<B.F;
    return A.S<B.S;
}
int32_t main()
{
    go;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i].F>>a[i].S;
    sort(a,a+n,com);
    int t=0;
    for(int i=0;i<n;i++)
    {
        if(t+a[i].F>a[i].S)
        return cout<<"No",0;
        t+=a[i].F;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
//#include "bits/stdc++.h"
//#include <vector>
using namespace std;

long long int ReadReturn(long long int a)
{
	cin >> a;
	return a;
}

int main()
{
	char c=0;
	char str[5];
	str[0] = 156;
	
	for (int i = 1; i <= 4; i++)
	{
		str[i] = getchar();
		if (str[i] == str[i - 1])c++;
	}
	if (c > 0)cout << "Bad";
	else cout << "Good";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  string a,b;
  cin>>a>>b;
  if(a.size()==b.size()){
  rep(i,a.size())
  cout<<a.at(i)<<b.at(i);
    }
  else{
    rep(i,b.size())
      cout<<a.at(i)<<b.at(i);
    cout<<a.at(a.size()-1);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int A, B;
  cin >> A >> B;

  int a = A/100;
  int b = B/100;

  int cnt = b - a + 1;
  if(a*100+a/100+(a-(a/100*100))/10*10 < A){
    cnt--;
  }
  if(b*100+b/100+(b-(b/100*100))/10*10 > B){
    cnt--;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 210000

ll dp[MAX];

int main(void) {
  pll a[MAX];
  ll h, w, d, L, R, temp2;
  cin >> h >> w >> d;

  FOR(i, 1, h+1) {
	FOR(j, 1, w+1) {
	  cin >> temp;
	  a[temp].first = i;
	  a[temp].second = j;
	}
  }

  cin >> n;

  FOR(i, 1, d+1) {
	temp = i;
	dp[temp] = 0;
	temp2 = temp + d;
	while (temp < h*w) {
	  dp[temp2] = llabs(a[temp2].first - a[temp].first) + llabs(a[temp2].second - a[temp].second) + dp[temp];
	  temp = temp2;
	  temp2 += d;
	}
  }

  FOR(i, 0, n) {
	cin >> L;
	cin >> R;
	ans = dp[R] - dp[L];
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
	vector<int> v(n,0);
  for(int i=0;i<n;i++){
  	cin>>v[i];
  }
  sort(v.begin(),v.end());
  cout<<v[n-1]-v[0]<<endl;

	return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,n) loop(i,0,n)

const int MAX_N=50100;
int p[(MAX_N+1)/2];
bool isp[MAX_N+1];
int f(){
    memset(isp,1,sizeof(isp));
    isp[0]=isp[1]=false;
    int idx=0;
    loop(i,2,MAX_N+1){
        if(!isp[i]) continue;
        p[idx++]=i;
        for(int j=i+i; j<=MAX_N; j+=i){
            isp[j]=false;
        }
    }
    return idx;
}

int len;

int main(){
    int n;
    len=f();
    while(cin>>n){
        int ub=*upper_bound(p,p+len,n);
        int lb=*(lower_bound(p,p+len,n)-1);
        cout<<lb<<" "<<ub<<endl;
    }
}

Measured memory_bytes: 1240
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		String s = in.next();
		String t = in.next();
		List<Character> sl = new ArrayList<>(s.length());
		for (int i = 0; i < s.length(); i += 1) {
			sl.add(s.charAt(i));
		}
		List<Character> tl = new ArrayList<>(t.length());
		for (int i = 0; i < t.length(); i += 1) {
			tl.add(t.charAt(i));
		}
		sl.sort(null);
		tl.sort(Collections.reverseOrder());
		for (int i = 0, n = Math.min(sl.size(), tl.size()); i < n; i += 1) {
			if (sl.get(i).charValue() < tl.get(i).charValue()) {
				out.println("Yes");
				return;
			}
			if (sl.get(i).charValue() > tl.get(i).charValue()) {
				out.println("No");
				return;
			}
		}
		out.println(s.length() < t.length() ? "Yes" : "No");
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


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

typedef pair<int,int> P;
const int MAX_N = 400;

bool color[MAX_N][MAX_N];
bool visited[MAX_N][MAX_N];
string s;

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long ans = 0;
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++){
		cin >> s;
		for(int j=0;j<W;j++){
			color[i][j] = (s[j]=='#');
		}
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			long long b = 0,w = 0;
			if(visited[i][j])continue;
			queue<P> q;
			visited[i][j] = true;
			q.push(P(i,j));
			
			while(!q.empty()){
				P now = q.front();
				q.pop();
				if(color[now.first][now.second])b++;
				else w++;
				for(int k=0;k<4;k++){
					int nx = dx[k] + now.first;
					int ny = dy[k] + now.second;
					
					if(!(nx>=0 && ny>=0 && nx<H && ny<W))continue;
					if(visited[nx][ny] || color[nx][ny]==color[now.first][now.second])continue;
					else {
						visited[nx][ny] = true;
						q.push(P(nx,ny));
					}
					
				}
			}
			
			ans += b*w;
		}
	}
	cout << ans << endl;
}

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

def main():
    N = int(input())
    H = list(map(int, input().split()))
    
    ans = 0
    tmp = 0
    for i in range(N-1):
        if H[i] >= H[i+1]:
            tmp += 1
            if tmp > ans:
                ans = tmp
        else:
            tmp = 0
    
    return ans

if __name__ == '__main__':
    print(main())

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

int a,b,k;

int main(){
  int i,j;
  cin >> a >> b >> k;
  i=a;
  while(i<a+k&&i<=b){
    cout << i << endl;
    i++;
  }

if(i<b-k+1)i=b-k+1;
  while(i<=b){
    cout << i << endl;
    i++;
  }
  
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  atcoder - grid1
//
//  Created by r on 5/25/19.
//  Copyright © 2019 r. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

long long dp[1010][1010];
int N, M;
char grid[1010][1010];

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    for (int i = 0; i<N; i++) {
        for (int j = 0; j<M; j++) {
            cin >> grid[i][j];
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i<N; i++) {
        for (int j = 0; j<M; j++) {
            if (grid[i][j] == '#') {
                continue;
            }
            if (i>0) {
                dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
            }
            if (j>0) {
                dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
            }
        }
    }
    cout << dp[N-1][M-1] << endl;
    return 0;
}





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

int f(int n){
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    return f(n-1) + f(n-2) + f(n-3);
}

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        cout << (f(n) / 3650)+1 << endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <set>

using namespace std;

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

    set<char> s;

    s.insert('a');
    s.insert('e');
    s.insert('i');
    s.insert('o');
    s.insert('u');

    cout << ((s.find(c) != s.end())? "vowel" : "consonant") << endl;

    return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

type ElementKey int
type Node struct {
	key    ElementKey
	parent *Node
	rank   int
}

func newNode(key ElementKey) *Node {
	node := Node{}
	node.key = key
	node.parent = &node
	node.rank = 0

	return &node
}

func union(x, y *Node) {
	xSet := findSet(x)
	ySet := findSet(y)
	link(xSet, ySet)
}

func link(x, y *Node) {
	if x.rank > y.rank {
		y.parent = x
	} else {
		x.parent = y

		if x.rank == y.rank {
			y.rank++
		}
	}
}

func findSet(x *Node) *Node {
	if x != x.parent {
		x.parent = findSet(x.parent)
	}
	return x.parent
}

func newDisjointSets(nSets int) *DisjointSets {
	sets := DisjointSets{}
	sets.keyToNode = map[ElementKey]*Node{}
	for i := 0; i < nSets; i++ {
		key := ElementKey(i)
		sets.keyToNode[key] = newNode(key)
	}
	return &sets
}

type DisjointSets struct {
	keyToNode map[ElementKey]*Node
}

func (sets *DisjointSets) union(x, y ElementKey) {
	xNode := sets.keyToNode[x]
	yNode := sets.keyToNode[y]
	union(xNode, yNode)
}

func (sets DisjointSets) findSet(x ElementKey) *Node {
	xNode := sets.keyToNode[x]
	return findSet(xNode)
}

type Edge struct {
	i, j   int
	weight int
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	sets := newDisjointSets(n)
	edges := []Edge{}
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
		for j := 0; j < n; j++ {
			a[i][j] = nextInt()
			if a[i][j] >= 0 {
				e := Edge{
					i:      i,
					j:      j,
					weight: a[i][j],
				}
				edges = append(edges, e)
			}
		}
	}
	sort.Slice(edges, func(i, j int) bool { return edges[i].weight < edges[j].weight })
	totalWeight := 0
	for _, edge := range edges {
		i := ElementKey(edge.i)
		j := ElementKey(edge.j)
		if sets.findSet(i) != sets.findSet(j) {
			totalWeight += edge.weight
			sets.union(i, j)
		}
	}
	fmt.Println(totalWeight)
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n; cin >> n;
	vi a(n);
	REP(i,n) cin >> a[i];
	printf("%d %d %lld\n", *min_element(ALL(a)), *max_element(ALL(a)), accumulate(ALL(a), 0LL));
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

using namespace std;

int color[3][250001] = {};
int d[31][31] = {};

int main(){
  int n, c;
  cin >> n >> c;

  for (int i=0;i < c;i++) {
    for (int j=0;j < c;j++) {
      int tmp;
      cin >> tmp;
      d[i][j] = tmp;
    }
  }

  for (int i=0;i<n;i++) {
    for (int j=0;j<n;j++) {
      int tmp;
      int r = (i + 1 + j + 1) % 3;
      cin >> tmp;
      color[r][tmp-1]++;
    }
  }
  int result = 2147483647;
  for (int i=0;i<c;i++) {
    int tmp_result = 0;
    for (int l=0;l<c;l++) {
      tmp_result += color[0][l] * d[l][i];
    }
    for (int j=0;j<c;j++) {
      int tmp_result_j = tmp_result;
      if (i==j) {
	continue;
      }
      for (int l=0;l<c;l++) {
	tmp_result_j += color[1][l] * d[l][j];
      }
      for (int k=0;k<c;k++) {
	int tmp_result_k = tmp_result_j;
	if (i==k || j==k) {
	  continue;
	}
	for (int l=0;l<c;l++) {
	  tmp_result_k += color[2][l] * d[l][k];
	}
	if (tmp_result_k < result) {
	  result = tmp_result_k;
	  //	  cout << i << "\t" << j << "\t" << k << "\t" << tmp_result_k << endl;
	}
      }
    }
  }
  cout << result << endl;
  return(0);
}


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

using namespace std;

const int mod = 1e9 + 7;
int K, X;
int upper = 1000000, lower = -1000000;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline long long ksm(long long base, int mi) {
	long long res = 1;
	while(mi) {
		if(mi & 1) (res *= base) %= mod;
		(base *= base) %= mod, mi >>= 1;
	}
	return res;
}

int main() {
	cin >> X >> K;
	int u = min(upper, K + X - 1), d = max(lower, K - X + 1);
	for(int i = d; i <= u; ++i) cout << i << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n; cin >> n;
  vector<int> p(n*n);
  rep(i,n*n) {
    cin >> p[i];
  }

  vector<vector<int>> c(n+1, vector<int>(n+1));
  rep1(i,n) rep1(j,n) {
    c[i][j] = min({i-1, n-i, j-1, n-j});
  }

  auto show = [&]()-> void{
		rep1(i,n) {
		  rep1(j,n) cout << c[i][j] << " ";
		  cout << "\n";
		}  
	      };
  
  vector<vector<bool>> f(n+1, vector<bool>(n+1, true));
  using pi = pair<int,int>;
  vector<int> dx = {1, 0, -1, 0};
  vector<int> dy = {0, 1, 0, -1};
  int res = 0;
  rep(i,n*n) {
    int x = (p[i] + n - 1)/n;
    int y = (p[i] % n == 0 ? n : p[i] % n);
    res += c[x][y];
    f[x][y] = false;
    queue<pi> q;
    q.push({x, y});
    while( !q.empty() ) {
      pi pp = q.front(); q.pop();
      int xx = pp.first, yy = pp.second;
      rep(j,4) {
	int nx = xx + dx[j];
	int ny = yy + dy[j];
	if(0 < nx && nx <= n && 0 < ny && ny <= n) {
	  if(chmin(c[nx][ny], c[xx][yy] + f[xx][yy])) {
	    q.push({nx, ny});
	  }
	}
      }
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int x;
    rep(i,0,4){
        cin >> x;
        if(x==0)cout << i+1 << endl;
    }


    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

class BipartiteMatching
{
public:
	BipartiteMatching(int v) : V(v)
	{
		init();
	}

	void init()
	{
		G.clear();
		G.resize(V);
		match.clear();
		match.resize(V);
		used.clear();
		used.resize(V);
	}

	void add_edge(int u, int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}

	int run()
	{
		int res = 0;
		fill(match.begin(), match.end(), -1);
		for (int v = 0; v<V; v++)
		{
			if (match[v]<0)
			{
				fill(used.begin(), used.end(), false);
				if (dfs(v))
				{
					res++;
				}
			}
		}

		return res;
	}

private:
	const int V;
	vector < vector <int> > G;
	vector <int> match;
	vector <bool> used;


	bool dfs(int v)
	{
		used[v] = true;
		for (int i = 0; i<SZ(G[v]); i++)
		{
			int u = G[v][i];
			int w = match[u];
			if (w<0 || !used[w] && dfs(w))
			{
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
};


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

	vector <int> a(n), b(n), c(n), d(n);

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

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

	BipartiteMatching bp(2 * n);

	for (int i = 0; i < n; ++i)
	{
		for (int k = 0; k < n; ++k)
		{
			if (a[i] < c[k] && b[i] < d[k])
			{
				bp.add_edge(i, k + n);
			}
		}
	}

	int ret = bp.run();

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81]
if n in a:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;

ll a[200005], n, k;

bool possible(double x)
{
	ll i, res = 0;

	for (i = 1; i <= n; i++)
		res += (a[i] * 2 / (ll)(x * 2.0) + !(a[i] * 2 % (ll)(x * 2.0) == 0)) - 1;

	return res <= k;
}

int main(void)
{
	ll i;

	scanf("%lld %lld", &n, &k);
	for (i = 1; i <= n; i++)
		scanf("%lld", &a[i]);

	double left = 0.5, right = (double)*max_element(a + 1, a + n + 1);

	for (i = 1; i <= 200; i++)
	{
		double mid = (left + right) / 2.0;

		if (possible(mid))
			right = mid;
		else
			left = mid + 0.1;
	}

	printf("%lld", (ll)round(left));
	return 0;
}


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

int main(void){
	unsigned n;
  	cin>>n;
  	vector<unsigned> vec(4, 0);
  	while(n--){
    	string s;
      	cin>>s;
      	if(s=="AC") vec[0]++;
      	else if(s=="WA") vec[1]++;
      	else if(s=="TLE") vec[2]++;
      	else if(s=="RE") vec[3]++;
    }
  	cout<<"AC x "<<vec[0]<<"\n";
  	cout<<"WA x "<<vec[1]<<"\n";
  	cout<<"TLE x "<<vec[2]<<"\n";
  	cout<<"RE x "<<vec[3]<<"\n";
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

bitset<1002> nn;
int cnt[1002];
const ll MOD = (ll)1e9 + 7;

int main(){
    fastIO;
    for(int i = 2; i <= 1000; i ++ ){
        if(nn[i] == 0){
            for(int j = 2 * i ; j <= 1000; j += i)
                nn[j] = 1;
        }
    }
    int n;
    cin >> n;
    int pp;
    for(int i = 2;  i <= n; i ++ ){
        pp = i;
        for(int j = 2; j <= i; j ++ ){
            if(nn[j]==0){
                while(pp%j==0){
                    cnt[j]++;
                    pp/=j;
                }
            }
        }
    }
    ll res = 1ll;
    for(int i = 2; i <= 1000; i ++ ){
        res = (res * 1ll * (cnt[i] + 1)) % MOD;
    }
    cout << res << "\n";
}

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

struct Unionfind {
	vector< int > par;
	Unionfind(int N) : par(N,-1){
	}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(x == y) return 0;
		if(par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return 1;
	}
	int root(int k) {
		if(par[k] < 0) return (k);
		return (par[k] = root(par[k]));
	}
	int size(int k) {
		return (-par[root(k)]);
	}
};

int main() {
	int n,m;
	cin >> n >> m;
	int cnt{};
	vector<int> a(m),b(m);
	for(int i=0; i<m; i++){
		cin >> a.at(i) >> b.at(i);
		a.at(i)--;
		b.at(i)--;
	}
	for(int i=0; i<m; i++){
		Unionfind unionfind(n);
		for(int j=0; j<m; j++){
			if(i==j) continue;
			unionfind.unite(a.at(j),b.at(j));
		}
		if(unionfind.size(0)!=n) cnt++;
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 256
def round_up(num, divisor):
    if num % divisor == 0:
        return num - (num%divisor)
    else:
        return num - (num%divisor) + divisor
dishes = []
p = []
for i in range(5):
    dishes.append(int(input()))
for i in range(5):
    if dishes[i]%10 == 0:
        p.append(10)
    else:
        p.append(dishes[i]%10)
sum = dishes.pop(p.index(min(p)))
for i in range(len(dishes)):
    sum += round_up(dishes[i], 10)
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define re0(i, n) for (int i = 0; i < (int) n; i ++)
#define rep(i, n) for (int i = 1; i <= (n); i ++)
#define travel(i, u) for (int i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 1e6 + 233;
int n, a[N], duA[N], b[N], duB[N];
int rtA, rtB, rt;

struct Graph {
  set <int> G[N];
  int vis[N], col[N], du[N];
  set < pair <int, int> > seg;
  inline void init(void) {
    memset(vis, 0, sizeof vis);
  }
  inline void add(int x, int y) {
    G[x].insert(y);
  }
  inline void link(int x, int y) {
    ++ du[x]; ++ du[y];
    add(x, y); add(y, x);
  }
  inline void debug(void) {
    rep (i, 2 * n + 1) cout << du[i] << " "; cout << "\n";
  }

  inline void dfs(int u) {
    // cout << u << " ";
    while (G[u].size()) {
      int v = *-- G[u].end();
      G[v].erase(u);
      G[u].erase(v);
      seg.insert({u, v});
      dfs(v);
    }
  }
  inline void doit(void) {
    dfs(rt);
    rep (i, n + n) if (G[i].size()) {
      puts("IMPOSSIBLE");
      exit(0);
    }
    puts("POSSIBLE");
    rep (i, n) {
      if (duA[i] & 1) cout << "0 ";
      else if (seg.count({i, i + n})) cout << "1 ";
      else {
        assert(seg.count({i + n, i}));
        cout << "-1 ";
      }
    }
    cout << "\n";
  }
}G;

int main(void) {
  G.init();
  read(n);
  rep (i, n) {
    read(a[i]);
    if (a[i] == -1) rtA = i;
    else ++ duA[a[i]];
  }
  rep (i, n) {
    read(b[i]);
    if (b[i] == -1) rtB = i;
    else ++ duB[b[i]];
  }
  rep (i, n) if ((duA[i] + duB[i]) & 1)
    return puts("IMPOSSIBLE"), 0;
  rt = n + n + 1;
  rep (i, n) {
    if (a[i] == -1) G.link(i, rt);
    else G.link(i, a[i]);
  }
  rep (i, n) {
    if (b[i] == -1) G.link(i + n, rt);
    else G.link(i + n, b[i] + n);
  }
  rep (i, n) if (~duA[i] & 1)
    G.link(i, i + n);
  // G.debug(); cout << " --\n";
  G.doit();
}


Measured memory_bytes: 100352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define in(s) ll s; cin >> s
#define prarr(a, i ,n) fab(j, i , n) cout << a[j] << " "
#define wh(t) ll t; cin >> t; while(t--)
#define sz(u) u.size()
#define deb(x) cout << #x << " " << x << endl
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define arr(a,n) vl a(n, 0); fab(i, 0, n) cin >> a[i]
#define fab(i,a,b) for(ll i = a; i < b; i++)
#define fba(i,b,a) for(ll i = b; i >= a; i--)
#define fa(i, x) for(auto i: x)
#define mem(s, j) memset(s, j, sizeof(s))
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pl>
#define pl pair<ll, ll>
#define pll pair<ll, pl>
#define vvl vector<vl>
#define vvpl vector<vpl>
#define mxe(x) *max_element(x)
#define mne(x) *min_element(x)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N = (ll)3e5;
const ll inf = (ll)1e18 + 7;
const ll mod = (ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;

bool sortbysec(const pair<ll, ll> &a,const pair<ll, ll> &b){ return (a.second < b.second);}

//-------------policy based-----------------------------
typedef tree<int, null_type, less<int>, rb_tree_tag, 
        tree_order_statistics_node_update> pb_set;
//------------------------------------------------------


vector<char> dir = {'L', 'R', 'U', 'D'};
vl dx = {-1, 1, 0, 0};
vl dy = {0, 0, -1, 1};

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}

ll sm(vl a, ll y) {
    ll sum = 0, x = 0;
    for(auto i: a) {
        sum += i;
        x++;
        if(x == y)
            break;
    }
    return sum;
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}


int main()
{
	sup;
    
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vl total;
    arr(p, a);
    arr(q, b);
    arr(r, c);
    sort(rall(p));
    sort(rall(q));
    sort(rall(r));
    fab(i, 0, x)
        total.pb(p[i]);
    fab(i, 0, y)
        total.pb(q[i]);
    fab(i, 0, c)
        total.pb(r[i]);
    sort(rall(total));
    //prarr(total, 0, x + y);
    ll ans = 0;
    fab(i, 0, x + y) 
        ans += total[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 8432
<?php
while(true){
fscanf(STDIN, "%d %d", $n, $x);
if($n ==0 && $x == 0){ break;}
$count = 0;
for($i = 1; $i <= $n; $i++){
    for($j = $i+1; $j <= $n; $j++){
        for($k = $j+1; $k <= $n; $k++){
            if($i + $j + $k == $x){ $count++;}
        }
    }
}
echo $count.PHP_EOL;
}

Measured memory_bytes: 15296
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A";
	}
	else cout << "B";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

double const EPS = 1.0e-10;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosÆ
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinÆ
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
};

class Line
{
public:
    double a, b, c; // a*x + b*y + c = 0
    Line(double a0, double b0, double c0){
        a = a0;
        b = b0;
        c = c0;
    }
    Line(const Point& p1, const Point& p2){
        double dy = p2.y - p1.y;
        double dx = p2.x - p1.x;
        if(abs(dy / dx) < EPS){
            a = 0.0;
            b = 1.0;
            c = -p1.y;
        }else if(abs(dx / dy) < EPS){
            a = 1.0;
            b = 0.0;
            c = -p1.x;
        }else{
            a = - dy / dx;
            b = 1.0;
            c = dy / dx * p1.x - p1.y;
        }
    }
};

Line perpendicularBisector(const Point& p1, const Point& p2)
{
    return Line(p2.x-p1.x, p2.y-p1.y, (p1.y*p1.y + p1.x*p1.x - p2.y*p2.y - p2.x*p2.x) / 2);
}

bool linesIntersection(const Line& l1, const Line& l2, Point& intersection)
{
    double s = l1.a*l2.b - l2.a*l1.b;
    if(abs(s) < EPS)
        return false;

    intersection = Point(l2.a*l1.c - l1.a*l2.c, l1.b*l2.c - l2.b*l1.c) / s;
    return true;
}

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

    while(--n >= 0){
        Point p1, p2, p3;
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;

        Line l1 = perpendicularBisector(p1, p2);
        Line l2 = perpendicularBisector(p2, p3);
        Point p;
        linesIntersection(l1, l2, p);

        printf("%.3f %.3f %.3f\n", p.x, p.y, p.dist(p1));
    }

    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
 
int main(void){
  int N,key;
  int *data;
  int i,j;
 
  scanf("%d",&N);
 
  data=(int *)malloc(N*sizeof(int));
 
  for(i=0;i<N;i++) scanf("%d",&data[i]);
 
  printf("%d",data[0]);
  for(i=1;i<N;i++){
    printf(" %d",data[i]);
  }
  printf("\n");
 
  for(i=1;i<N;i++){
    key=data[i];
    j=i-1;
    while(j>=0 && data[j]>key){
      data[j+1]=data[j];
      j--;
    }
    data[j+1]=key;
     
    printf("%d",data[0]);
    for(j=1;j<N;j++){
      printf(" %d",data[j]);
    }
    printf("\n");
  }
 
  free(data);
 
  return ;
}

Measured memory_bytes: 604
while True:
    m, f, r = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
    s = m + f
    if m == -1 or f == -1:
        print('F')
        continue
    if s >= 80:
        rank = 'A'
    elif 65 <= s < 80:
        rank = 'B'
    elif 50 <= s < 65 or (30 <= s < 50 and r >= 50):
        rank = 'C'
    elif 30 <= s < 50:
        rank = 'D'
    elif s < 30:
        rank = 'F'
    print(rank)
    

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

struct Card { char mark; int number; };

int bubbleSort(Card c[], int n) {
    int cnt = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int i = n-1; i > 0; --i) {
            if (c[i].number < c[i-1].number) {
                swap(c[i], c[i-1]);
                cnt++;
                flag = true;
            }
        }
    }
    return cnt;
}

int selectionSort(Card c[], int n) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int minj = i;
        bool flag = false;
        for (int j = i; j < n; ++j) {
            if (c[j].number < c[minj].number) {
                minj = j;
                flag = true;
            }
        }
        swap(c[i], c[minj]);
        if (i != minj) cnt++;
    }
    return cnt;
}

void trace(Card c[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i) cout << ' ';
        cout << c[i].mark << c[i].number;
    }
    cout << endl;
}

bool is_stable(Card b[], Card s[], int n) {
    for (int i = 0; i < n; ++i) {
        if (b[i].mark != s[i].mark || b[i].number != s[i].number) return false;
    }
    return true;
}

int main() {
    Card c[36], b[36], s[36];
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> c[i].mark >> c[i].number;
        b[i].mark = s[i].mark = c[i].mark;
        b[i].number = s[i].number = c[i].number;
    }
    bubbleSort(b, n);
    trace(b, n);
    cout << "Stable" << endl;
    selectionSort(s, n);
    trace(s, n);
    if (is_stable(b, s, n)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);

  sort(S.begin(), S.end());
  S.push_back("");

  vector<string> ans;
  for (int i = 1, cnt = 1, Max = 0; i <= N; i++) {
    if (S.at(i - 1) != S.at(i)) {
      if (cnt > Max) {
        ans.clear();
        Max = cnt;
      }
      if (cnt >= Max) ans.push_back(S.at(i - 1));
      cnt = 1;
    }
    else cnt++;
  }

  for (int i = 0; i < ans.size(); i++) cout << ans.at(i) << "\n";
}

Measured memory_bytes: 17892
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
const ll mod = 998244353;
const ll maxn = 200005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    map<int,int>mp;
    int arr[n];
    rep0(i,n) {cin>>arr[i];mp[arr[i]]++;}
    ll ans=0;
    for(auto p:mp){
        ans+=p.s*(p.s-1)/2;
    }
    rep0(i,n){
        ll ans1=ans;
        int z=mp[arr[i]];
        ans1-=z*(z-1)/2;
        z--;
        ans1+=z*(z-1)/2;
        cout<<ans1<<"\n";
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 11136