akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<ll, int> P;


struct node {
	int id;
	int p;
	int t;
	vi from;
	int d;
	bool operator<(const node & another) const {
		return (d != another.d ? d > another.d : id < another.id);
	}
};


int main() {
	int n; cin >> n;
	vector<node> nodes(n, { 0, -1, 0, {} ,0 });
	Loop1(i, n - 1) {
		nodes[i].id = i;
		int x; cin >> x;
		x--;
		nodes[i].p = x;
		nodes[x].from.push_back(i);
	}
	queue<int> que;
	que.push(0);
	que.push(-1);
	int depth = 0;
	while (que.size()) {
		int a = que.front(); que.pop();
		if (a == -1) {
			depth++;
			if (que.size()) que.push(-1);
		}
		else {
			nodes[a].d = depth;
			Loop(j, nodes[a].from.size()) {
				que.push(nodes[a].from[j]);
			}
		}
	}
	vector<node> nodes2 = nodes;
	sort(nodes2.begin(), nodes2.end());
	Loop(i, n) {
		int a = nodes2[i].id;
		multiset<int> st;
		Loop(j, nodes[a].from.size()) {
			st.insert(nodes[nodes[a].from[j]].t);
		}
		auto itr = st.begin();
		Loop(j, st.size()) {
			nodes[a].t = max(nodes[a].t, *itr) + 1;
			itr++;
		}
	}
	cout << nodes[0].t << endl;
	return 0;
}


Measured memory_bytes: 15872
r = []

while True:
    n = input().split()
    a = n[0]
    op = n[1]
    b = n[2]
    a = int(a)
    b = int(b)
    op = str(op)
    if op == "+":
        a1 = a + b
        r.append(a1)
    elif op == "-":
        a2 = a - b
        r.append(a2)
    elif op == "*":
        a3 = a * b
        r.append(a3)
    elif op == "/":
        a4 = a // b
        r.append(a4)
    elif op == "?":
        break

for item in r:
    print(item)



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

int main() {
    int w,h;
    cin >> w >> h;
    char c;
    int cnt = 0;
    while(cin >> c) if (c == '#') cnt++;
    if (cnt == w + h - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int h, w;
	cin >> h >> w;
	VI v(26);

	rep(i, h) {
		string s;
		cin >> s;
		rep(j, s.size()) {
			v[s[j] - 'a']++;
		}
	}
	sort(all(v));

	int num4 = (w - w % 2) / 2 * (h - h % 2) / 2;
	int num1 = ((w % 2 == 1 && h % 2 == 1) ? 1 : 0);
	int num2 = (w * h - num1 - num4 * 4) / 2;

	bool flag = false;
	for (int i = v.size() - 1; i >= 0; i--)
	{
		int tmp = min(num4, v[i] / 4);
		num4 -= tmp;
		v[i] -= tmp * 4;
		num2 -= v[i] / 2;
		v[i] -= v[i] / 2 * 2;
		num1 -= v[i];
		v[i] -= v[i];

		if (num4 == 0 && num2 == 0 && num1 == 0) {
			flag = true;
			break;
		}
	}

	

	cout << (flag ? "Yes" : "No") << endl;
}



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

	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = map(int, input().split())
d = {}
for a in l:
  if a in d:
    d[a] += 1
  else:
    d[a] = 1

m = []
for k, v in d.items():
  if v >= 2:
    m.append([k, v])

m.sort(reverse=True)
if len(m) == 0:
  print(0)
elif m[0][1] >= 4:
  print(m[0][0]**2)
elif len(m) >= 2:
  print(m[0][0]*m[1][0])
else:
  print(0)
  

Measured memory_bytes: 23564
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] array = input.Split(' ');

            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);

            int d = a / b;
            int r = a % b;
            decimal f = (decimal)a / b;

            Console.WriteLine(string.Format("{0} {1} {2}", d, r, f));
        }
    }
}

Measured memory_bytes: 9220
#include<stdio.h>
#include<stdlib.h>
int cmpfunc(const void*a,const void*b)
{
    if((*(int*)a - *(int*)b)>0)
    {
        return -1;
    }
    if((*(int*)a - *(int*)b)<0)
    {
        return 1;
    }
    if(*(int*)a == *(int*)b)
    {
        return 0;
    }
    
}
int main(void)
{
    int n,m,a[100],sum=0,count=0;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum = sum + a[i];
    }
    qsort(a,n,sizeof(a[0]),cmpfunc);
    float judge = (float)sum/(4*m);
    for(int i=0;i<m;i++)
    {
        if(a[i]>=judge)
        {
            count++;
        }
    }
    if(m<=count)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    
}

Measured memory_bytes: 128
while (ln = gets.chomp) != '-1 -1 -1' do
  m, f, r = ln.split.map(&:to_i)
  if m < 0 || f < 0
    puts 'F'
  else
    sum = m + f
    if sum >= 80
      puts 'A'
    elsif sum >= 65
      puts 'B'
    elsif sum >= 50
      puts 'C'
    elsif sum >= 30
      if r >= 50
        puts 'C'
      else
        puts 'D'
      end
    else
      puts 'F'
    end
  end
end

Measured memory_bytes: 6100
#include <stdio.h>

int main()
{
  int i, j, n, u, k, v;
  int m[101][101];

  scanf("%d", &n);

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      m[i][j] = 0;
    }
  }

  for (i = 0; i < n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      m[u][v] = 1;
    }
  }

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (j == 1) {
        printf("%d", m[i][j]);
      } else {
        printf(" %d", m[i][j]);
      }
    }
    puts("");
  }

  return 0;
}

Measured memory_bytes: 648
n,m=map(int,input().split())
city=list(list(map(int,input().split()))+[i] for i in range(m))
city.sort(key=lambda x:x[1])
city.sort(key=lambda x:x[0])
for j,l in enumerate(city):
    if j!=0 and city[j-1][0]==city[j][0]:
        city[j].append(city[j-1][3]+1)
    elif j!=0 and city[j-1][0]!=city[j][0]:
        city[j].append(1)
    else:
        city[j].append(1)
city.sort(key=lambda x:x[2])
for k in range(m):
    print('{0:06d}{1:06d}'.format(city[k][0],city[k][3]))

Measured memory_bytes: 31352
var
 n,i,m,max:longint;
 s:ansistring;
begin
 readln(n);
 readln(s);
 for i:=1 to n do
  begin
   if s[i]='I' then inc(m)
    else if s[i]='D' then dec(m);
   if m>max then max:=m;
  end;
 writeln(max);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,m,x,sum;
int main()
{
    sc2(n,m);
    rep(i,1,m){
        sc(x);
        sum+=x;
    }
    if(n>=sum)pf(n-sum);
    else pf(-1);
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int begin,end;
    int i;
    for(i = 0;i < s.size();++i){
        if(s.at(i) == 'A'){
            begin = i;
            break;
        }
    }
    for(i = s.size()-1;i >= 0;--i){
        if(s.at(i) == 'Z'){
            end = i;
            break;
        }
    }
    cout << end-begin+1 << endl;
    return 0;
}

Measured memory_bytes: 640
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}

#define EPS (1e-10)
#define EQ(a, b) (abs((a)-(b)) < EPS)

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    vector<int> gap('z'-'a'+1, 0);
    vector<int> gapmax('z'-'a'+1, 0);
    string s;cin >> s;
    for(int i=0;i<int(s.size());i++){
        char c = s[i];
        for(int j=0;j<'z'-'a'+1;j++){
            if(j == c-'a'){
                gapmax[j] = max(gapmax[j], gap[j]);
                gap[j] = 0;
            }else{
                gap[j]++;
                if(i == int(s.size())-1){
                    gapmax[j] = max(gapmax[j], gap[j]);
                }
            }
        }
    }
    cout << *min_element(gapmax.begin(), gapmax.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#coding: utf-8

while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        a = 0
        for i in range(1,n+1):
            i = i*1.0
            if i*(i+1)/2 > n:
                break
            for k in range(1,n+1):
                if i*(2*k+i-1)/2 > n:
                    break
                elif i*(2*k+i-1)/2 == n:
                    a = a + 1
                else:
                    continue
        print a - 1

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

ll INF = 1e+18;
#define MAX_V 300

struct edge {
  ll to;
  ll cost;
};

ll V;
ll E;
ll L;
vector<edge> G[MAX_V];
ll d[MAX_V][MAX_V];
ll c[MAX_V][MAX_V];

void warshall_floyd_dis() {

  for ( ll i = 0; i < V; i++ ) {
    fill(d[i], d[i]+V, INF);
    d[i][i] = 0;
    for ( ll j = 0; j < G[i].size(); j++ ) {
      edge e = G[i][j];
      d[i][e.to] = e.cost;
    }
  }

  for ( ll k = 0; k < V; k++ ){
    for ( ll i = 0; i < V; i++ ) {
      for ( ll j = 0; j < V; j++ ) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void warshall_floyd_ct() {

  for ( ll i = 0; i < V; i++ ) {
    fill(c[i], c[i]+V, INF);
    c[i][i] = 0;
    for ( ll j = 0; j < V; j++ ) {
      if ( d[i][j] <= L && d[i][j] > 0 ) {
        c[i][j] = 1;
      }
    }
  }

  for ( ll k = 0; k < V; k++ ){
    for ( ll i = 0; i < V; i++ ) {
      for ( ll j = 0; j < V; j++ ) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
}

int main() {

  cin >> V >> E >> L;
  for ( ll i = 0; i < E; i++ ) {
    ll a, b, c;
    cin >> a >> b >> c;
    if ( c > L ) {
      continue;
    }
    a--; b--;
    edge ea = {b, c};
    edge eb = {a, c};
    G[a].push_back(ea);
    G[b].push_back(eb);
  }


  warshall_floyd_dis();
  warshall_floyd_ct();

  ll q;
  cin >> q;

  while ( q-- > 0 ) {
    ll s, t;
    cin >> s >> t;
    s--; t--;
    ll ans = ( d[s][t] != INF && d[s][t] != 0 ) ? c[s][t]-1 : -1;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int [] dp = new int [n];

        dp[n-1] = 0;
        dp[n-2] = Math.abs(arr[n-1] - arr[n-2]);

        for (int i = n - 3; i >= 0; i--) {
            dp[i] = Math.min(Math.abs(arr[i] - arr[i+1]) + dp[i+1],Math.abs(arr[i] - arr[i+2]) + dp[i+2]);
        }

        System.out.println(dp[0]);
    }
}


Measured memory_bytes: 48872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  if (s.at(1) == 'B') {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

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

int n, m;

bool cmp (int a, int b) {
	return (a>b);
}

int main() {
	cin>>n>>m;
	int mi, total=0;
	int a[n];
	for (int i=0; i<n; i++) {
		cin>>a[i];
		total+=a[i];
	}
	mi=total/(4*m);
	if (total%(4*m)!=0) mi++;
	sort(a, a+n, cmp);
	int jwb=0;
	for (int i=0; i<m; i++) {
		if(a[i]>=mi) jwb++;
	}
	if (jwb==m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = Integer.parseInt(s.nextLine());
		int[][] input = new int[cnt+1][2];
		int[][] result = new int[cnt+1][cnt+1];
		for(int i=1 ; i<=cnt ; i++) {
			String[] tmp = s.nextLine().split(" ");
			input[i][0] = Integer.parseInt(tmp[0]);
			input[i][1] = Integer.parseInt(tmp[1]);
		}
		for(int i=0 ; i<result.length ; i++) {
			for(int j=0 ; j<result[0].length ; j++) {
				if(i==j)
					result[i][j] = 0;
				else
					result[i][j] = Integer.MAX_VALUE;
			}
		}
		//????§£?????§????????????????????????????§£??¬?????????????????£????????????2015/04/11
		//??°??????????????????????????????2???cnt?????§?±??????????
		for(int c=2 ; c<=cnt ; c++) {
			//??°?????????????§?????????????
			for(int i=1 ; i<=cnt-c+1 ; i++) {
				//????°??????????????±????
				int j = i + c -1;
				//?§??????????????????????1??\???????????????????????????????????????
				for(int k=i ; k<j ; k++) {
					result[i][j] = Math.min(result[i][j], result[i][k] + result[k+1][j] + input[i][0]*input[k][1]*input[j][1]);
				}
			}
		}
		System.out.println(result[1][cnt]);
	}

}

Measured memory_bytes: 20180
n, m, x = map(int, input().split())
a_l = list(map(int, input().split()))

for i, a in enumerate(a_l):
    if x < a:
        break
if i > len(a_l)/2:
    ans = len(a_l[i:])
else:
    ans = len(a_l[:i])
print(ans)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    vi b(n-1);
    for(ll i=0;i<n-1;i++)
        cin>>b[i];
    a[0]=b[0];
    for(ll i=1;i<n-1;i++)
    {
        a[i]=min(b[i-1],b[i]);
    }
    a[n-1]=b[n-2];
    ll sum=0;
    for(ll i=0;i<n;i++)
        sum+=a[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 256
def m():
    s = input()
    t = input()
    a = {chr(i): "" for i in range(97, 97 + 26)}
    b = {chr(i): "" for i in range(97, 97 + 26)}
    n = len(s)
    for i in range(n):
        if a[s[i]] == "":
            a[s[i]] = t[i]
        else:
            if a[s[i]] != t[i]:
                return 'No'
        if b[t[i]] == "":
            b[t[i]] = s[i]
        else:
            if b[t[i]] != s[i]:
                return 'No'
    return 'Yes'
print(m())


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

vector<int> A;
int N,K;
const int inf=1000000000000000001;

void solve(int &l,int &r){
	//l,r以下の数が何個あるかで二分探索
	while(l+1<r){
		int x=(l+r)/2;
		int sum=0;
		for(int i=0;i<N;i++){
			if(A[i]>=0){
				int left=-1,right=N;
				while(left+1<right){
					int c=(left+right)/2;
					if(A[c]*A[i]<x)left=c;
					else right=c;
				}
				sum+=right;
			}else{
				int left=-1,right=N;
				while(left+1<right){
					int c=(left+right)/2;
					if(A[c]*A[i]<x)right=c;
					else left=c;
				}
				sum+=N-right;
			}
			if(A[i]*A[i]<x)sum--;
		}
		sum/=2;
		if(sum<K)l=x;
		else r=x;
	}	
}

signed main(){
	cin>>N>>K;
	A.assign(N,0);
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A.begin(),A.end());
	int l=-inf,r=inf;
	solve(l,r);
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
    int a, b, c;
    
    /*
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    */
    scanf("%d%d%d", &a, &b, &c);
    
    if (a == b && a == c) {
        printf("No\n");
    } else if (a != b && a != c && b != c) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


vector<ll> A, B, C;
map<ll, ll> m;
int main() {
    ll N;
    cin >> N;

    A.assign(N, 0);
    ll A_star = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        A_star ^= A[i];
    }

    for(int i = 0 ; i<N; i++) {
        cout << (A_star ^ A[i]) << " ";
    }

    cout << endl;


            

    return 0;    
}



Measured memory_bytes: 4764
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N;

int main() {

	cin >> N;

	ll n = N, d = 1;
	while (n >= 10) {
		n /= 10;
		++d;
	}

	ll ans = 0;
	rep(a, N) {
		ll A = a + 1;
		ll f = A, l = A % 10;
		while (f >= 10) f /= 10;
		if (l == 0) continue;
		if (f == l) ++ans;
		rep(i, d - 1) {
			if (i != d - 2) {
				ll add = 1;
				rep(t, i) add *= 10;
				ans += add;
			}
			else {
				if (l < n) {
					ll add = 1;
					rep(t, i) add *= 10;
					ans += add;
				}
				if (l == n) {
					ll B = l;
					rep(t, i + 1) B *= 10;
					B += f;
					ll b = B;
					rep(t, i) {
						ll add = 1;
						rep(u, i - t) add *= 10;
						while (B <= N) {
							B += add;
						}
						B -= add;
					}
					ans += (B - b) / 10 + 1;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (100006)
ll n,dist[MAXN],p[MAXN];
vector<int>v[MAXN];
bitset<MAXN> in;
int main(){
	FAST
	cin>>n;
	FOR(i,0,n-2){
		ll a,b;cin>>a>>b;
		v[a].eb(b), v[b].eb(a);
	}
	function<void(ll,ll)>dfs=[&](ll x,ll par){
		p[x]=par;
		for(auto i:v[x]) if(i^par) {
			dist[i]=dist[x]+1, dfs(i,x);
		}
	};
	dfs(1,1);
	ll mx = 1;
	FOR(i,1,n) if(dist[i]>dist[mx]) mx=i;
	dist[mx]=0, dfs(mx,mx);
	ll mx2=mx;
	FOR(i,1,n) if(dist[i]>dist[mx2]) mx2=i;
	vector<ll> path;
	for(ll i=mx2; ; i=p[i]){
		in[i]=1;
		path.eb(siz(v[i])-1-ll(i!=mx2&&i!=mx));
		if(i==mx) break;
	}
	FOR(i,1,n) if(!in[i] && siz(v[i]) > 1) { cout<<"-1\n"; return 0; }
	bool rev = 0;
	for(ll co=0, co1=siz(path)-1; co < co1; ++ co, -- co1){
		if(path[co] > path[co1]) { rev=1; break; }
		else if(path[co] < path[co1]) break;
	}
	if(rev) reverse(all(path));
	ll co=1;
	for(auto i:path){
		ll myval=co++;
		while(i--) cout<<co++<<' ';
		cout<<myval<<' ';
	}cout<<'\n';
}


Measured memory_bytes: 15092
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

#define MAX 1000001
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

COMinit();

int X, Y; cin >> X >> Y;

if((double)Y/X < .5 || (double)Y/X > 2) cout << "0\n";
else if ((double)Y/X > 1 ){
    int x=X, y=Y, cnty=0;
    while((double)y/x != 2) {
        x -=2; --y;
        if ((double)y/x > 2){ cout << "0\n"; return 0;}
        ++cnty;
    }
    cout << COM(x+cnty, x) << endl;
}
else {
    int x=X, y=Y, cnty=0;
    while((double)y/x != .5) {
        --x; y -= 2;
        if ((double)y/x < .5){ cout << "0\n"; return 0;}
        ++cnty;
    }
    cout << COM(y+cnty, y) << endl;
}

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 23808
S = input()
ans = [0] * len(S)
firstR = 0
lastR = 0
firstL = 0
lastL = 0
now = "R"
for idx, char in enumerate(S):
    if now == "R" and char != now:
        lastR = idx - 1
        firstL = idx
        now = "L"
    elif now == "L" and char != now:
        lastL = idx - 1
        ans[lastR] += (lastR - firstR) // 2 + (lastL - firstL + 1) // 2 + 1
        ans[firstL] += (lastR - firstR + 1) // 2 + (lastL - firstL) // 2 + 1
        firstR = idx
        now = "R"

lastL = len(S) - 1
ans[lastR] += (lastR - firstR) // 2 + (lastL - firstL + 1) // 2 + 1
ans[firstL] += (lastR - firstR + 1) // 2 + (lastL - firstL) // 2 + 1
for idx, val in enumerate(ans):
    if idx < len(S) - 1:
        print("{} ".format(val), end="")
    else:
        print(val)

Measured memory_bytes: 4984
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 1e9;
  for (int i = 0; i <= s.size() - t.size(); i++) {
    int cnt = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i + j] != t[j]) cnt++;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(505050)
N = int(input())
C = [int(c)-1 for c in input().split()]
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

Cnt = [0] * N
Ans = [0] * N
Siz = [0] * N

def dfs1(v):
    siz = 1
    for u in G[v]:
        G[u].remove(v)
        siz += dfs1(u)
    Siz[v] = siz
    return siz

#Cnt_down = [0] * N

def dfs(v):
    color = C[v]
    cnt_old = Cnt[color]
    siz = 1
    siz_up = N
    #cnt_down = 0
    for u in G[v]:
        #Cnt_down[color] = 0
        Cnt[color] = N - Siz[u]  # 上を塞ぐ
        s = dfs(u)
        siz += s
        siz_up -= s
        Ans[color] += s * (siz_up-cnt_old)
        #cnt_down += Cnt_down[color]
    Ans[color] += siz_up - cnt_old
    #print(siz_up, cnt_old, cnt_down)
    Cnt[color] = cnt_old + siz
    #print(v, Ans)
    return siz

dfs1(0)
dfs(0)
print("\n".join(map(str, Ans)))


Measured memory_bytes: 242220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B,C;cin>>A>>B>>C;
    cout<<min(C,B/A)<<endl;
}

Measured memory_bytes: 256
import sys
from sys import stdin
N = int(stdin.readline().rstrip())
S = list(stdin.readline().rstrip())
res = 10**9
ctb = 0
ctw = 0
bs = [0]*N
ws = [0]*N
for i in range(N):
    if S[i] == '.':
        ctw += 1
    else:
        ctb += 1
    bs[i] = ctb
    ws[i] = ctw
for i in range(N):
    res = min(res, bs[i]+ws[-1]-ws[i])
res = min(res, bs[-1], ws[-1])
print(res)

Measured memory_bytes: 14116
'use strict';

function Main(input) {
    const tmp = input.trim().split('\n');
    const D = Number(tmp[0]);
    const C = tmp[1].split(' ').map((v) => Number(v));
    const S = tmp
        .slice(2, 2 + D)
        .map((v) => v.split(' ').map((v) => Number(v)));
    const T = tmp.slice(-1 * D).map((v) => Number(v));

    let LastContestDays = Array(26).fill(0); // コンテストの種類ごとの最終開催日
    let currnetContestLebels = Array(26).fill(0); // ある開催日のコンテストごとの満足度
    let lebelDrops = Array(26).fill(0); // ある開催日のコンテストごとの満足低下量

    for (let i = 1; i <= D; i++) {
        for (let j = 0; j < C.length; j++) {
            lebelDrops[j] = C[j] * (i - LastContestDays[j]) * -1;
        }
        const drop = lebelDrops.reduce((acc, cur) => acc + cur);
        let maxLebel = 0;
        let openContestNo = 0;
        for (let k = 0; k < C.length; k++) {
            currnetContestLebels[k] = S[i - 1][k] + drop - lebelDrops[k];
            if (maxLebel < currnetContestLebels[k]) {
                maxLebel = currnetContestLebels[k];
                openContestNo = k;
            }
        }
        LastContestDays[openContestNo] = i;
        console.log(openContestNo + 1);
    }

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int N; cin >> N;
  vector<int> d(N);
  for (int i{}; i < N; ++i) cin >> d[i];
  int ans{};
  for (int i{}; i < N - 1; ++i) {
    for (int j{i+1}; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }

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


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

MOD = 998244353  # type: int

def baai(n1, n2):
    return(n1**n2%MOD)

def solve(N: int, D: "List[int]"):
    cn=[0]*(N*2)
    for i in range(N):
        cn[D[i]]+=1

    if D[0]!=0:
        print(0)
    else:
        answer=1
        bak=cn[0]
        kyo=1
        hen=1
        while True:
            cnt=cn[kyo]
            hen+=cnt
            if cnt==0:
                break
            answer=answer*baai(bak, cnt)%MOD
            bak=cnt
            kyo+=1
        if hen==N:
            print(answer%MOD)
        else:
            print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15988
#include<bits/stdc++.h>
using namespace std;
class Trees{
  vector<int> par;
  vector<int> rank;
  public:
  int root(int i){
    int rt;
    if(par[i]==i){rt=i;rank[i]=1;}
    else{rt=root(par[i]);par[i]=rt;rank[i]=2;}
    return rt;
  }
  void unite(int i,int j){
    int rki=rank[i];int rkj=rank[j];
    if(rki<rkj){par[root(i)]=root(j);rank[i]++;}
    else{par[root(j)]=root(i);rank[j]++;}
  }
  bool same(int i,int j){
    return root(i)==root(j);
  }
  int n_group(){
    vector<int> tmp(par.size(),0);int ans=0;
    for(int i=0;i<par.size();i++)tmp[root(i)]=1;
    for(int i=0;i<par.size();i++)ans+=tmp[i];
    return ans;
  }
  
  Trees(int n){
    for(int i=0;i<n;i++) {par.push_back(i);rank.push_back(1);};
  }
};
int main(){
  int N,M;cin>>N>>M;
  Trees tree(N*2);
  for(int i=0;i<M;i++){
    int x,y,z;cin>>x>>y>>z;x--;y--;
    if(z%2==0){tree.unite(x,y);tree.unite(x+N,y+N);}
    else {tree.unite(x,y+N);tree.unite(x+N,y);}
  }
  cout<<tree.n_group()/2;
}



Measured memory_bytes: 2796
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cstdlib>
#include <cassert>
using namespace std;

char rgb(char a, char b) {
    assert(a != b);
    if (a == 'r') {
        if (b == 'g') return 'b';
        else if (b == 'b') return 'g';
    } else if (a == 'g') {
        if (b == 'r') return 'b';
        else if (b = 'b') return 'r';
    } else {
        if (b == 'r') return 'g';
        else if (b == 'g') return 'r';
    }
    exit(1);
}

struct state_t {
    string worm;
    int count;
    state_t(string worm, int count) : worm(worm), count(count) {}
};

bool same_characters(string s) {
    assert(!s.empty());
    char p = s[0];
    for (int i = 0; i < s.size(); i++) {
        if (p != s[i]) return false;
    }
    return true;
}

int main() {
    string s;
    while (getline(cin, s)) {
        if (s == "0") break;

        queue<state_t> q;
        set<string> cache;

        q.push(state_t(s, 0));

        bool found = false;
        while (!q.empty()) {
            state_t p = q.front(); q.pop();
            string u = p.worm;
//            cout << u << endl;
            if (cache.count(u)) continue;
            cache.insert(u);
            if (same_characters(u)) {
                cout << p.count << endl;
                found = true;
                break;
            }
            for (int i = 0; i < u.size()-1; i++) {
                if (!(u[i] == u[i+1])) {
                    char c = rgb(u[i], u[i+1]);
                    string t = u; t[i] = t[i+1] = c;
                    q.push(state_t(t, p.count+1));
                }
            }
        }

        if (!found) cout << "NA" << endl;

//        for (set<string>::iterator si = cache.begin();
//                si != cache.end(); si++) {
//            cout << *si << ' ';
//        }
//        cout << endl;
    }

    return 0;
}

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

int main() {
    
    int n, y, i, j, c, m, p;
    c = 0;
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {

        scanf("%d", &y);
        
        if (y == 2) {
            c = c + 1;
        }
        else if (y < 2 || y % 2 == 0){
            
        }
        
        else {
            m = sqrt(y);
            p = 0;
            for (j = 3; j <= m; j = j + 2){
                if (y % j == 0) {
                    p = 1;
                    break;
                }
            }
            if (p == 0){
                c = c + 1;
            }
        }
    }
    printf("%d\n", c);
    return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string s; cin >> s;
    int i = (s[0]-'0')*10+(s[1]-'0');
    int j = (s[2]-'0')*10+(s[3]-'0');
    if(i>=1 && i<=12){
        if(j>=1 && j<=12) cout << "AMBIGUOUS";
        else cout << "MMYY";
    }else{
        if(j>=1 && j<=12) cout << "YYMM";
        else cout << "NA";
    }
    cout << endl;
    return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	cout << n*m-n-m+1 << endl;
	return 0;
}


Measured memory_bytes: 256
/* 문제
2015.

*/


#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const int mod = 1000000007;
const int cons = 100001;
const double pi = 3.141592653589793;



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

	int k;
	scanf("%d", &k);

	for (int i = 0; i < str.length(); i++)
	{
		if (i < str.length() - 1 && str[i] == 'a')continue;
		int rem = 'z' - str[i] + 1;

		if (i < str.length() - 1)
		{
			if (k >= rem)
			{
				k -= rem;
				str[i] = 'a';
			}
			else
			{
				continue;
			}
		}
		else
		{
			k %= 26;

			if (k == 0)break;

			if (k >= rem)
			{
				str[i] = 'a';
				k -= rem;
				str[i] += k;
			}
			else
			{
				str[i] += k;
			}
		}
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 512
//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> piii;

const int maxN = 2e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int a[maxN], p[maxN], par[maxN];
ll ans = 0;
pii c[maxN];

struct cmp{
	bool operator () (piii X, piii Y) const{
		pii A = X.first, B = Y.first;
		if (A.first * B.second == A.second * B.first)
			return (X.second < Y.second);
		return (1ll * A.first * B.second > 1ll * A.second * B.first);
	}
};

set <piii, cmp> S;

int getpar(int v){
	return (par[v] == v ? v : par[v] = getpar(par[v]));
}

void join(int u, int v){
	u = getpar(u);
	v = getpar(v);
	if (u > 1)
		S.erase({c[u], u});
	S.erase({c[v], v});
	ans += 1ll * c[u].second * c[v].first;
	par[v] = u;
	c[u].first  += c[v].first;
	c[u].second += c[v].second;
	if (u > 1)
		S.insert({c[u], u});
	return;
}

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; scanf("%d", &n);
	for (int i = 2; i <= n; i++)
		scanf("%d", p + i);
	for (int i = 1; i <= n; i++){
		scanf("%d", a + i);
		par[i] = i;
		c[i] = {!a[i], a[i]};
		if (i > 1)
			S.insert({c[i], i});
	}
	while (!S.empty()){
		int v = S.begin()->second;
		int x = p[v];
		join(x, v);
	}
	printf("%lld\n", ans);
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 



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

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

    int n;
    cin >> n;
    vector<int> as(n);
    vector<int> ps(n + 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as[i] = a;
        ps[a] = i;
    }

    long long ans = 0;
    set<int> used;
    used.insert(ps[n]);
    auto get_gt = [&](int a) -> vector<int> {
        auto it = used.lower_bound(ps[a]);
        if (it == used.end()) return {n, n};
        vector<int> ret;
        ret.push_back(*it);
        it++;
        if (it == used.end()) {
            ret.push_back(n);
            return ret;
        }
        ret.push_back(*it);
        return ret;
    };
    auto get_lt = [&](int a) -> vector<int> {
        auto it = used.lower_bound(ps[a]);
        if (it == used.begin()) return {-1, -1};
        vector<int> ret;
        it--;
        ret.push_back(*it);
        if (it == used.begin()) {
            ret.insert(ret.begin(), -1);
            return ret;
        }
        it--;
        ret.insert(ret.begin(), *it);
        return ret;
    };
    for (int i = n - 1; i >= 1; i--) {
        auto gt = get_gt(i);
        auto lt = get_lt(i);

        long long cnt = 0;
        cnt += (long long)(lt[1] - lt[0]) * (gt[0] - ps[i]);
        cnt += (long long)(ps[i] - lt[1]) * (gt[1] - gt[0]);
        ans += cnt * i;
        // cout << "i : " << i << ", cnt : " << cnt << endl;

        used.insert(ps[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

int main(){
    int n;
    
    cin>>n;
    cout<<3*n*n<<endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> v(m);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            v[a-1] += 1;
        }
    }
    int count = 0;
    rep(i,m){
        if(v[i] == n)count++;
    }
    P(count);
}

int main() {
  solve();
  return 0;
}


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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (auto& i : B) cin >> i;
	vector<vector<int>> A(N, vector<int>(M));
	for (auto& i : A) for (auto& j : i) cin >> j;

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int sum = C;
		for (int j = 0; j < M; j++) {
			sum += A[i][j] * B[j];
		}

		if (sum > 0) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;


int main() {
    int n;
    cin>>n;
    int ans = 1;
    for(int i=2;i<=n;i++){
        int v = i*i;
        while(v<=n){
            ans = max(ans,v);
            v*=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9 + 7);

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

	map<int, int> m;
	int N;
	cin >> N;
	for(int i = 1; i <= N; i++) {
		int n = i;
		for(int j = 2; j <= n; j++) {
			while(n % j == 0) {
				n /= j;
				m[j]++;
			}
		}

	}

	ll ans = 1;
	for(auto v : m) {
		ans = (ans * (v.second + 1)) % MOD;
	}

	cout << ans << endl;
}

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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int R;
    cin >> R;
    if(R < 1200) cout<< "ABC" << endl;
    else if(R < 2800) cout << "ARC" << endl;
    else cout << "AGC" <<endl;
    return 0;
}


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


int main(){
int N;
  cin >> N;
  bool torf=false;
  
  vector <ll> A(N);
  ll ans=1;
  ll ans2=LLONG_MAX;
  rep(i,N){
    cin >> A.at(i);
    if(A.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,N){
    if(ans2<A.at(i)){
      torf=true;
      break;
    }
    ans=ans*A.at(i);
    ans2=1000000000000000000/ans;
    if(ans>1000000000000000000){
      torf=true;
      break;
    }
  //  cout << ans << endl;
    
  }
  

  
  if(torf==true)
    cout << -1 << endl;
  else
    cout << ans << endl;
   
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

// vector<int> a(5);
map<int,int> counter;
int n;
string temp;
string s = "MARCH";

int main(void){
    cin >> n;
    REP(i,0,n) {
        int num;
        cin >> num;
        counter[num]++;
    }
    
    int ans = 0;
    for (auto u: counter) {
        if (u.first < u.second) {
            ans += u.second - u.first;
        }
        else if (u.first > u.second) {
            ans += u.second;
        }
    }
    
    cout << ans << endl;
    // long long ans = 0;
    // REP(i,0,5) {
    //     REP(j,0,5) {
    //         if (i == j) continue;
    //         long long temp = 1;
    //         for (auto u : counter) {
    //             // cout << u.first << u.second << endl;
    //             if (u.first == s[i] || u.first == s[j]) continue;
    //                 temp *= u.second;
    //         }
    //         ans += temp;
    //         cout << ans << endl;
    //         // cout << ans << endl;
    //     }
    // }
    
    // cout << ans << end;
    // int ans = 1;
    // for (auto u : counter) {
    //     // cout << u.first << u.second << endl;
    //     ans *= u.second;
    // }
    // cout << ans << endl;

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 083 C / Link: http://abc083.contest.atcoder.jp/tasks/abc083_c  ----- */


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

	LL X, Y; cin >> X >> Y;


	LL ans = 0LL;
	FOR(i, 0, 100) {
		LL a = X << i;
		if (a <= Y)ans++;
		else break;
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

int main(){
    int N[5],i;
    int mk[20];
    fornum(i,0,4){
        scanf("%d",&N[i]);
        mk[N[i]]++;
    }
    
    if(mk[1]&&mk[4]&&mk[7]&&mk[9]){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 256