akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

	int n;
	cin>>n;

	ll res=0;

	map<P,int> mp;

	for(int i=1;i<=n;i++)
	{
		if(i%10==0) continue;
		int s=i%10;
		
		int d=log10(i);
		int dd=1;
		for(int i=0;i<d;i++)
			dd*=10;
		int t=(i/dd)%10;
		mp[{s,t}]++;
	}
		

	for(int i=1;i<=n;i++)
	{
		if(i%10==0) continue;
		
		int s=i%10;
		
		int d=log10(i);
		int dd=1;
		for(int i=0;i<d;i++)
			dd*=10;
		int t=(i/dd)%10;
		res+=mp[{t,s}];
	}

	cout<<res<<endl;
		

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int a[3];
   int b;
   int i;
   int counter=0;


   cin >> b;
   for(i=0;i<3;i++) {
       a[i] = b%10;
       b /= 10;
       if(a[i]==1) {
           counter += 1;
       }
   }
   cout << counter << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
int a[200000];
int tmp[300000];

void init()
{
    cin>>n;
    for (int i=0; i<n; ++i)
        cin>>a[i];
    sort(a,a+n); 
}

void work()
{
    int t=(n-1)/2;
    long long sum=(n%2)?max((a[t]+a[t-1]),3*a[t]-a[t+1]):a[t]-a[t+1];
    for (int i=0; i<=t; ++i)
        sum-=2*a[i];
    for (int i=t+1; i<n; ++i)
        sum+=2*a[i];
    cout<<sum<<endl;
}

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


Measured memory_bytes: 640
import itertools

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

count = 0
p_count = 0
q_count = 0

for v in itertools.permutations(sorted(p), n):
    if list(v) == p:
        p_count = count
    if list(v) == q:
        q_count = count

    count += 1

print(abs(p_count - q_count))

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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  rep(i,n){
    if(s[i]==s[n-1-i]){
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;
string s;
set<string> x;

void solve(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s;
		x.insert(s);
	}
	llint ans=x.size();
	cout << ans << endl;
}

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


Measured memory_bytes: 19216
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N;
int rec[110];
int P[110][15];
 
signed main() {
    cin >> N;
    rep(i,0,N) {
        int val = 0;
        rep(k,0,10) {
            int p; cin >> p;
            val = (val << 1LL) | p;
        }
        rec[i] = val;
    }

    rep(i,0,N) rep(j,0,11) cin >> P[i][j];

    int ans = -INF;
    rep(bit,1,1<<10) {
        int tmp = 0;
        rep(i,0,N) {
            int ad = __builtin_popcount(bit & rec[i]);
            tmp += P[i][ad];
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, ans = 0, Max = 0;
    cin >> n;
    int h[n];
    rep(i, n) {
        cin >> h[i];
        Max = max(Max, h[i]);
    }
    REP(i, 1, Max + 1) {
        bool first = true;
        rep(j, n) {
            if (h[j] >= i) {
                if (first) ans++;
                first = false;
            } else {
                first = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,M;
  cin >>N>>M;
  vector<pair<int,int>>p(M);
  for(int i=0;i<M;i++){
    cin>>p[i].first>>p[i].second;
  }
  rep(x,1000){
    int keta=1;
    int nx=x/10;
    vector<int>d(1,x%10);//１は要素数,x%10は初期値
    while(nx){//nxが0になるまで続ける
      keta++;
      d.push_back(nx%10);//十の位と百の位の数を後ろにつける
      nx/=10;
    }
    if(keta!=N)continue;//桁数が一致しないときは次の数にいく
    reverse(d.begin(),d.end());//一の位、十の位、百の位になっていた数字を逆にする
    bool ok=true;//判定
    rep(i,M){
      if(d[p[i].first-1]!=p[i].second)ok=false;//各桁の数が一致するかを調べる
    }
    if(ok){
      cout<<x<<endl;//全て一致したときは出力して終了
      return 0;
    }
  }
  cout<<-1<<endl;//999まで調べて見つからなかったときは-1を出力する
  return 0;
}

Measured memory_bytes: 256
<>;
map{push@$_,$_[--$|]for@_=glob}<>;
$m=1e9+7;
sub f{
	my($x,$y)=@_;
	return$f[$x]if$f[$x];
	$f[$x]=1;
	($f[$x]*=$y==$_||g($_,$x))%=$m for@$x;
	$f[$x]+=g($x,$y);
	$f[$x]%=$m;
}
sub g{
	my($x,$y)=@_;
	return$g[$x]if$g[$x];
	$g[$x]=1;
	($g[$x]*=$y==$_||f($_,$x))%=$m for@$x;
	$g[$x];
}
print f(1,0),$/;

Measured memory_bytes: 172288
#include <stdio.h>

int main(void)
{
    char str[11];
    scanf("%s", str);

    char* p = str;
    do{
        if(*p++ != 'h'){
            printf("No\n");
            return 0;
        }
        if(*p++ != 'i'){
            printf("No\n");
            return 0;
        }
    }while(*p!='\0');

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d=a-b;
    if(d>0){
        int e=c-d;
        if(e>0){
            cout<<e<<endl;
        }else{
            cout<<0<<endl;
        }
    }else{
        cout<<c<<endl;
    }

}


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

using namespace std;

int N;
const int Dist[] = { 0,100,200,300,400,500 };
const int Degree[] = { 0,30,60,90,120,150,180 };

int main() {
	int r, t, posD, posR;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> r >> t;
		posR = upper_bound(Dist, Dist + 6, r) - Dist - 1;
		//cout << "dist:" << posR << endl;
		posD = upper_bound(Degree, Degree + 7, t) - Degree - 1;
		//cout << "degree:" << posD << endl;
		if (r == Dist[posR] && t == Degree[posD]) {
			cout << posD * 5 + posR << endl;
			continue;
		}
		if (r == Dist[posR]) {
			cout << posD * 5 + posR << " " << posD * 5 + posR + 5 << endl;
			continue;
		}
		if (t == Degree[posD]) {
			cout << posD * 5 + posR << " " << posD * 5 + posR + 1 << endl;
			continue;
		}
		cout << posD * 5 + posR << " " << posD * 5 + posR + 1 << " ";
		cout << posD * 5 + posR + 5<< " " << posD * 5 + posR + 6 << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
//#define ll long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;

using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ld ans = 0, a, o = 1;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ans += o / a;
    }
    cout << fixed;
    cout.precision(10);
    cout << o / ans << '\n';
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {

	int N, K, size;
	int[] a,segment;
	long[] b;

	public void init(int _size) {
		size = 1;

		while (size < _size)
			size *= 2;
		segment = new int[2 * size];
		for (int i = 0; i < 2 * size - 1; i++) {
			segment[i] = 0;
		}
	}

	public void update(int i, int a) {
		i += size - 1;
		segment[i] += a;

		while (i > 0) {
			i = (i - 1) / 2;
			segment[i] += a;
		}
	}

	public int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)
			return 0;

		if (a <= l && r <= b)
			return segment[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

			return vl + vr;
		}
	}

	public void solve() {
		N = nextInt();
		K = nextInt();

		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt() - K;
		}

		b = new long[N+1];
		for(int i = 0;i < N;i++){
			b[i+1] += b[i] + a[i];
		}

		TreeSet<Long> set = new TreeSet<>();
		for(int i = 0;i <= N;i++){
			set.add(b[i]);
		}

		List<Long> list = new ArrayList<>();
		for(long i : set){
			list.add(i);
		}

		init(N+1);
		long ans = 0;
		for (int i = 0; i <= N; i++) {
			int x = Collections.binarySearch(list, b[i]);
			ans += query(0, x+1, 0, 0, size);
			update(x, 1);
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 54784
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
ans1 = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] == '1':
        ans1 += 1
    elif i % 2 == 1 and s[i] == '0':
        ans1 += 1
ans2 = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] == '0':
        ans2 += 1
    elif i % 2 == 1 and s[i] == '1':
        ans2 += 1
print(min(ans1, ans2))

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

int main(void)
{
    int n; cin >> n;
    int x[102] = {0};
    int sum = 0;
    for (int i = 0; i < n; i++) 
    {
        cin >> x[i]; sum += x[i];
    }
    int c = sum / n;
    int d1 = 0, d2 = 0;
    for (int i = 0; i < n; i++)
    {
        d1 += (c - x[i]) * (c - x[i]);
        d2 += (c + 1 - x[i]) * (c + 1 - x[i]);
    }
    int ans = min(d1, d2);
    cout << ans << endl;
}

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

int main() {
    int m, n;
    cin >> m >> n;
    int ans=0;
    for(int i=1;i<=25;i++) {
        if(n==1) {
        cout<<0<< endl;
        break;
        }
        if(i==1) {
        ans+=m;
        } 
        else {
        ans+=m-1;
        }
        if(ans>=n) {
        cout<<i<<endl;
        break;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
 
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    String stringS = sc.next();
    String stringT = sc.next();
    
    int lengthS = sc.nextInt();
    int lengthT = sc.nextInt();
    
    String stringU = sc.next();
    
    if (stringU.equals(stringS)) {
      lengthS--;
    } else {
      lengthT--;
    }
    
    System.out.println(lengthS + " " + lengthT);
    
  }
  
}

Measured memory_bytes: 38752
n,m = map(int, input().split())
sc = [ list(map(int,input().split())) for _ in range(m)]

ans = [0] * n
change_cnt = [0] * n
if n >= 2:
    ans[0]=1
for i in range(n):
    for j in range(m):
        if i+1 == sc[j][0]:
            if ans[i] != sc[j][1]:
                ans[i] = sc[j][1]
                change_cnt[i] += 1
                if change_cnt[i] > 1:
                    print(-1)
                    exit()

if n>=2:
    if ans[0]==0:
        print(-1)
        exit()

answer = ''
for i in range(len(ans)):
    answer += str(ans[i])

print(int(answer))


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

int main(void) {
	int n;

	cin >> n;

	cout << (n - 2) * 180 << endl;

	

	return 0;
}

Measured memory_bytes: 256
a, b, k = gets.chomp.split(' ').map(&:to_i)
turn = true

k.times do
  if turn # 高橋
    if a % 2 != 0
      a -= 1
    end
    num = a / 2
    a /= 2
    b += num
  else
    if b % 2 != 0
      b -= 1  
    end
    num = b / 2
    b /= 2
    a += num
  end
  turn = !turn
end

puts "#{a} #{b}"

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
typedef long long int ll;
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    static int n,a[200000];
    int flg=0;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]!=0){
            flg=1;
        }
    }

    if(!flg){
        printf("Yes\n");
        return 0;
    }
    qsort(a,n,sizeof(int),asc);

    if(n%3!=0){
        printf("No\n");
        return 0;
    }

    
    if(a[0]!=a[n/3-1]||a[n/3]!=a[2*n/3-1]||a[2*n/3]!=a[n-1]){
        printf("No\n");
        return 0;
    }

    if((int)(a[0]^a[2*n/3])==a[n/3]){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");




    return 0;

}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  
  int ans = 0;
  int teisuu = int('0');
  
  for (int i = 0; i < 10; i++)  {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        bool cond1 = false;
        bool cond2 = false;
        for (int l = 0; l < S.size(); l++) {
          if (!cond1 && !cond2 && int(S.at(l)) == teisuu + i) {
            cond1 = true;
            continue;
          } 
          if (cond1 && !cond2 && int(S.at(l)) == teisuu + j) {
            cond2 = true;
            continue;
          }
          if (cond1 && cond2 && int(S.at(l)) == teisuu + k) {
            ans++;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MAXN=1e6+10,Mod=1e9+7;long long n,f[MAXN],s;int main(){scanf("%lld",&n);f[1]=n;f[2]=n*n%Mod;for(int i=3;i<=n;++i)f[i]=(((f[i-1]+s)%Mod+(n-1)*(n-1)%Mod)%Mod+(n-i+2))%Mod,(s+=f[i-2])%=Mod;printf("%lld\n",f[n]);return 0; }

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n, a[100010], b[100010], c[100010];
int d[100010];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];
	sort(a, a + n);
	sort(c, c + n);
	rep(i, n) {
		d[i] = lower_bound(a, a + n, b[i]) - a;
	}
	int ans = 0;
	rep(i, n) {
		ans += d[i] * (c + n - upper_bound(c, c + n, b[i]));
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int a , b;
    cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = 1.00000000 * a / b;

        cout << fixed;
        cout << d << " " << r << " " << f << endl;

    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    set<int> a;
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        a.insert(d);
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int a = Integer.parseInt(data[0]);
    int b = Integer.parseInt(data[1]);
    
    if (a<10 && b<10){
      System.out.println(a*b);
    } else {
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 200002;

int n, d[maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;

	map<int, int> m;

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

	map<int, int>::iterator it = m.end();
	--it;

	int max1 = it->first, cnt1 = it->second;
	if (it != m.begin())
		--it;

	for (int i = 0; i < n; ++i)
		if (d[i] == max1 && cnt1 == 1)
			cout << it->first << endl;
		else
			cout << max1 << endl;

	return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main() {
	int fl=1;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++) {
		if((i%2==0 && s[i]=='L') || (i%2!=0 && s[i]=='R')) {
			fl=0;
			break;
		}
	}
	if(fl==0) cout<<"No";
	else cout<<"Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a[100][100];
int main()
{
    int n,i,j,row[100],col[100],s;
    while(cin>>n && n!=0)
    {
        for(i=0;i<n;i++)
        {
            col[i]=0;row[i]=2000000000;
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                cin>>a[i][j];
                if(a[i][j]<row[i])
                {
                    row[i]=a[i][j];
                }
            }
        }
        for(j=0;j<n;j++)
        {
            for(i=0;i<n;i++)
            {
                if(a[i][j]>col[j])
                {
                    col[j]=a[i][j];
                }
            }
        }
        for(s=-1,i=0;i<n&&s!=101;i++)
            for(j=0;j<n;j++)
            {
                if(a[i][j]==row[i] && a[i][j]==col[j])
                {
                    if(s==-1)
                    {
                        cout<<a[i][j]<<endl;
                        s=0;
                    }
                }
            }
           // cout<<endl;
            if(s==-1) cout<<0<<endl;
    }
    return 0;
}

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

int main() {
    int a, b;
    cin >>a >>b;
    int d=a/b;
    int e=a%b;
    double f=(double)a/(double)b;
    cout <<d <<" " <<e <<" " <<fixed <<setprecision(10) <<f <<endl;
    return 0;
}


Measured memory_bytes: 3280
bingo = []
for i in range(3):
    for j in map(int, input().split()):
        bingo.append(j)
    # bingo.append(list(map(int, input().split())))

N = int(input())
blist = []
for i in range(N):
    blist.append(int(input()))
bset = set(blist)

aplist = [
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 4, 8],
    [2, 4, 6]
    ]
cset = set()

for i, n in enumerate(bingo):
    if n in bset:
        cset.add(i)
        
    # print(i, n)
# print(cset)

for tests in aplist:
    isok = True
    for test in tests:
        if test not in cset:
            isok = False
            break
    if isok:
        print("Yes")
        # print(tests)
        exit()
print("No")








Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/dp/tasks/dp_d
 */
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int W = in.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(maxValue(N, W, w, v));
    }

    public static long maxValue(int N, int W, int[] w, int[] v) {
        long[] dp = new long[W + 1];
        for (int i = 0; i < N; i++) {
            long[] temp = new long[W + 1];
            for (int j = 1; j <= W; j++) {
                if (j - w[i] >= 0) {
                    temp[j] = dp[j-w[i]] + v[i];
                }
                temp[j] = Math.max(dp[j], temp[j]);
            }
            dp = temp;
        }
        return Arrays.stream(dp).max().getAsLong();
    }

}


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    string ans[s.size()];

    int win = 0;
    int grade_b = 1;
    int i;
    for(i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'a') {
            if (win < a + b) {
                ans[i] = "Yes";
                win++;
            }
            else {
                ans[i] = "No";
            }
        }
        else if (s[i] == 'b') {
            if (win < a + b && grade_b <= b) {
                ans[i] = "Yes";
                win++;
            }
            else {
                ans[i] = "No";
            }
            grade_b++;
        }
        else {
            ans[i] = "No";
        }
    }

    for(i = 0; i < (int)s.size(); i++) {
        cout << ans[i] << endl;
    }
}


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

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

long long MOD = 1000000000 + 7;

template<typename T>
T gcd(T a, T b) {
  if(a < b) swap(a,b);
    
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  cout << setprecision(10);
  ll N,X; cin >> N >> X;

  ll ans;
  for(int i = 0; i < N; i++){
    ll tmp; cin >> tmp;
    tmp = abs(tmp - X);
    if(i == 0){
      ans = tmp;
    } else { 
      ans = gcd(ans, tmp);
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
  int num=0;
  string W,T;
  cin>>W;
  for(int i=0;i<W.size();i++)W[i]=tolower(W[i]);
  while (cin>>T,T!="END_OF_TEXT"){
    for(int i=0;i<T.size();i++)T[i]=tolower(T[i]);
    if(T==W)num++;
  }
cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using ll = long long;
using namespace std;
int main() {
  	string s;
  	cin >> s;  	
  	sort(s.begin(), s.end());
  	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
      	cout << "Yes" << endl;
    } else {
      	cout << "No" << endl;
    }
  	return 0;
}

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

using namespace std;
#define ll long long

const int N=1e6+100;

ll ma=1e18;


void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    if(n<0) n=-n;
    ll kk=n/k;
    if(kk<m){
        ll d=n%k;
        ll mm=m-kk;
        if(mm%2)  cout<<k-d<<endl;
        else cout<<d<<endl;
    }
    else cout<<n-m*k<<endl;
}
int main()
{
    ios::sync_with_stdio(0);
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

signed main() {
    int i,j;
    int N;
    int count=0,headB=0,tailA=0;
    cin>>N;
    vector<string> S(N);
    int Both=0;
    rep(i,0,N){
        cin>>S.at(i);
    }
    rep(i,0,N){
        for(j=0;j<S.at(i).size()-1;){
            if(S.at(i).at(j)=='A' && S.at(i).at(j+1)=='B'){
                count++;
                j+=2;
            }
            else{
                j++;
            }
        }
        int cBoth=0;
        if(S.at(i).at(0)=='B'){
            headB++;
            cBoth++;
        }
        if(S.at(i).at(S.at(i).size()-1)=='A'){
            tailA++;
            cBoth++;
        }
        if(cBoth==2){
            Both++;
        }
    }
    
    if(tailA==Both && headB==Both && Both>0){
        headB--;
    }
    cout<<count+min(headB,tailA)<<endl;
return 0;
}

Measured memory_bytes: 768
def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    m = 1000000007
    ans = 0
    ss = sum(a[1:])
    for i in range(n-1):
        ans += a[i]*ss
        ss -= a[i+1]
        ans %= m
    print(ans)

main()

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

const int mod = 1e9 + 7;

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

    int n = 3;

    vector<int> sequences (k+1);
    for (int x = k; x >= 1; x--) {
        int c = k/x;
        for (int i = 1; i < n; i++) {
            c = (c * (k/x)) % mod;
        }
        for (int i = x+x; i <= k; i += x) {
            c = (c - sequences[i] + mod) % mod;
        }
        sequences[x] = c;
    }

    int s = 0;
    for (int i = 1; i <= k; i++) {
        s = (s + (i*sequences[i]) % mod) % mod;
    }
    cout << s << "\n";
}


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

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  int v[n];
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int m[100000];
  int u[100000];
  for(int i = 0; i < 100000; i++) {
    m[i] = 0;
    u[i] = 0;
  }
  for(int i = 0; i < n; i += 2) {
    m[v[i]]++;
    u[v[i+1]]++;
  }
  int m_max = max(m[0], m[1]);
  int u_max = max(u[0], u[1]);
  for(int i = 0; i < 100000-1; i++) {
    m_max = max(m_max, m[i+1]);
    u_max = max(u_max, u[i+1]);
  }
  vector<int> m_itr;
  vector<int> u_itr;
  for(int i = 0; i < 100000; i++) {
    if(m[i] == m_max) {
      m_itr.push_back(i);
    }
    if(u[i] == u_max) {
      u_itr.push_back(i);
    }
  }
  if(m_itr[0] != u_itr[0]) {
    cout << n - m_max - u_max << endl;
  } else {
    int second_m_max = -1;
    int second_u_max = -1;
    for(int i = 0; i < 100000; i++) {
      if(i != m_itr[0]) {
        second_m_max = max(second_m_max, m[i]);
      }
      if(i != u_itr[0]) {
        second_u_max = max(second_u_max, u[i]);
      }
    }
    int s_m_itr;
    int s_u_itr;
    for(int i = 0; i < 100000; i++) {
      if(m[i] == second_m_max && i != m_itr[0]) {
        s_m_itr = i;
      }
      if(u[i] == second_u_max && i != u_itr[0]) {
        s_u_itr = i;
      }
    }
    cout << n - m_max - max(second_m_max, second_u_max) << endl;
  }
  return 0;
}


Measured memory_bytes: 2044
from collections import defaultdict
from heapq import nsmallest

class UnionFind():
    "Either 0-indexed or 1-indexed"

    __slots__ = ["parent"]

    def __init__(self, size):
        self.parent = [-1] * (size + 1)
    
    def find(self, a):
        path = []
        while self.parent[a] >= 0:
            path.append(a)
            a = self.parent[a]
        for child in path:
            self.parent[child] = a
        return a

    def union(self, a, b):
        a = self.find(a)
        b = self.find(b)

        if a == b:
            return
        else:
            if self.parent[a] == self.parent[b]:
                self.parent[a] = b
                self.parent[b] -= 1
            elif self.parent[a] < self.parent[b]: #aのほうが大きい
                self.parent[b] = a
            else:
                self.parent[a] = b #bのほうが大きい
        
    def same(self, a, b):
        return self.find(a) == self.find(b)


N, M = map(int, input().split())
As = list(map(int, input().split()))
uf = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x, y)

anc_to_group = defaultdict(list)
for v in range(N):
    anc_to_group[uf.find(v)].append(v)

group_minima = []
remains = []
for group in anc_to_group.values():
    costs = [As[v] for v in group]
    minimum = min(costs)
    costs.remove(minimum)
    group_minima.append(minimum)
    remains += costs

if len(anc_to_group) == 1:
    print(0)
elif len(anc_to_group) - 2 > len(remains):
    print("Impossible")
else:
    ans = sum(group_minima)
    ans += sum(nsmallest((len(anc_to_group) - 2), remains))
    print(ans)

Measured memory_bytes: 34252
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[rune]int, len(s))
	isDiff := true
	for _, r := range s {
		m[r]++
		if m[r] > 1 {
			isDiff = false
			break
		}
	}
	if isDiff {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;

/**
 * <pre>
 * NumberOfIsland
 *
 * ??¶?????°???????????????
 * </pre>
 *
 * @author ?????????????????§???
 *
 */
public class Main{

    static boolean[][] map;
    static boolean[][] check;
    static int island ;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		 while(sc.hasNext()) {
	            map = new boolean[12][12];
	            check = new boolean[12][12];
	            island = 0;
	            for(int cnt = 0; cnt < map.length; cnt++) {
	                int trans = 0;
	                for( String s : sc.next().split("",0)) {
	                    if(s.equals("1")) {
	                        map[cnt][trans] = true;
	                    }
	                    else {
	                        map[cnt][trans] = false;
	                    }
	                    trans++;
	                }
	            }
	            for(int mh = 0; mh < map.length ; mh++) {
	                for(int mw = 0; mw < map.length; mw++) {
	                    if(map[mh][mw] && !check[mh][mw]) {
	                        fun(mh,mw);
	                    }
	                }
	            }
	            System.out.println(island);
		} // ?????????????????????
	}// ?????????????????????????????????

	static void fun(int mh, int mw) {
        flag(mh,mw);
        island++;
    }

    static void flag(int mh, int mw) {
        check[mh][mw] = true;

        if(mw + 1 < 12 && map[mh][mw+1] && !check[mh][mw+1]) {
            flag(mh,mw+1);
        }
        if(mh + 1 < 12 && map[mh+1][mw] && !check[mh+1][mw]) {
            flag(mh+1,mw);
        }
        if(mw - 1 > -1 && map[mh][mw-1] && !check[mh][mw-1]) {
            flag(mh,mw-1);
        }
        if(mh - 1 > -1 && map[mh-1][mw] && !check[mh-1][mw]) {
            flag(mh-1,mw);
        }
    }
}// ??????????????????????????????

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0, left = 0, right = n - 1;
	while (left <= right) {
		if (s[left] == 'x'&&s[right] != 'x') {
			ans++;
			left++;
		}
		else if (s[left] != 'x'&&s[right] == 'x') {
			ans++;
			right--;
		}
		else if (s[left] == s[right]) {
			left++;
			right--;
		}
		else {
			cout << -1;
			return 0;
		}
	}
	cout << ans;
}

Measured memory_bytes: 512
import sys

A, B, m = map(int, input().split())
a = [int(i) for i in sys.stdin.readline().rstrip().split()]
b = [int(i) for i in sys.stdin.readline().rstrip().split()]
ans = min(a) + min(b)
for i in range(m):
    x, y, c = map(int, input().split())
    tmp = a[x-1] + b[y-1] - c
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 18504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

    static class BTAKOYAKIFESTIVAL2019 {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            int[] arr = new int[n];
            int i = 0, j = 0;
            for (i = 0; i < n; i++)
                arr[i] = ni();
            int sum = 0;
            for (i = 0; i < n; i++) {
                for (j = i + 1; j < n; j++)
                    sum += arr[i] * arr[j];
            }
            pn(sum);

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

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

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

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

    }
}



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

int main(){
  int N;
  cin >> N;
  int i, sum, max, l;
  sum = 0;
  max = 0;
  for(i=0;i<N; ++i){
    cin >> l;
    if(l > max)max = l;
    sum += l;
  }
  int tmp = sum - 2*max;
  if(tmp > 0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  int max = a;
  if (b > max) {
    max = b;
  }
  if (c > max) {
    max = c;
  }
  printf("%d\n", a+b+c-max);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main()
{
    int N;
    int total_W;
    while(cin>>N>>total_W)
    {
        vector<long long int> W(N+5),V(N+5),DP(total_W+5,0);
        for(int i=0;i<N;i++)
        {
            cin >> W[i] >> V[i];
        }
        for(int i=0;i<N;i++)
        {
            for(int j=total_W;j>0;j--)
            {
                if(j-W[i]<0)break;

                DP[j]=max(DP[j] , DP[ j - W[i] ] + V[i] );
            }
        }
        cout<<DP[total_W]<<'\n';
    }
    return 0;
}


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

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

    for (auto& e : s) {
        char d = e - 'A';
        d += n;
        d %= 26;
        d += 'A';
        cout << d;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
	int n; cin>>n;
	int a[200000];
	FOR(i,0,n){
		cin>>a[i];
		a[i]-=i;
	}
	sort(a,a+n);
	int b=a[n/2];
	ll ans=0;
	FOR(i,0,n){
		ans+=abs(a[i]-b);
	}
	co(ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

vector<long long> hoge;

void solve(string s){
    long long n=stoll(s);
    if(n>3234566667) return;
    
    hoge.push_back(n);
    
    long long ed=s.at(s.size()-1)-'0';
    
    if(ed!=0 && ed!=9){
        solve(s+to_string(ed-1));
        solve(s+to_string(ed));
        solve(s+to_string(ed+1));
    }else if(ed!=9){
        solve(s+to_string(ed));
        solve(s+to_string(ed+1));
    }else {
        solve(s+to_string(ed-1));
        solve(s+to_string(ed));
    }
}

int main(){
    for(int i=1;i<=9;i++){
        solve(to_string(i));
    }
    
    sort(hoge.begin(),hoge.end());
    
    int k;
    cin>>k;
    cout<<hoge.at(k-1)<<endl;
    
    return 0;
}

Measured memory_bytes: 1400
def main():
    n, m = map(int, input().split())
    lr_lst = [list(map(int, input().split())) for _ in range(m)]
    left = 0
    right = n + 1

    for i in range(m):
        if left < lr_lst[i][0]:
            left = lr_lst[i][0]
        if lr_lst[i][1] < right:
            right = lr_lst[i][1]

    if right - left < 0:
        print(0)
    else:
        print(right - left + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 89460
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using LLONG = long long;

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

    // 余りとなりうるものを探索する
    LLONG sum = 0;
    for (LLONG x = 1; x * x < N; ++x)
    {
        if (N % x == 0)
        {
            const LLONG m = N / x - 1;
            if (x < m) sum += m;
        }
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

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

    int recover = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j)
            recover += d[i] * d[j];
    }

    cout << recover << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = sc.nextInt();
     	int b = sc.nextInt();
        int count = 0;
        
        while(true){
          if(a >= b){
          a = a / b;
          count += 1;
          }else{
            count+= 1;
            break;
          }
        }
		
        
          System.out.println(count);

    }
}

Measured memory_bytes: 35752
n = int(input())
A = list(map(int,input().split()))
for i in range(n-1) :
    A[i] = A[i] - 1
res = [[] for i in range(n)]

for i in range(n-1) :
    res[A[i]].append(i)

for i in range(n) :
    print(len(res[i]))

Measured memory_bytes: 44020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll x;
	cin>>x;
	ll div = 2*(x/11);
	// if(x%2==0) div+=0;
	if(x%11>6) div+=2;
	else if(x%11>0 and x%11 <=6)div+=1;
	p(div);
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) cout << s[i] << t[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BigDecimal N = new BigDecimal(br.readLine());
        int n = N.intValue();
        BigDecimal result = new BigDecimal(n % 2 == 0 ? n/2 : (n/2) + 1).divide(new BigDecimal(n), 7, BigDecimal.ROUND_CEILING);
        System.out.println(result);
    }
}


Measured memory_bytes: 21076
def greatestCommonDivisor(num1, num2):
	if num1 % num2 == 0 : return num2
	return num1 % num2

while True:
	try:
		a,b = map(int,raw_input().split())
	except EOFError:
		break
	
	while a != b:
		if a > b:
			a = greatestCommonDivisor(a, b)
		elif b > a:
			b = greatestCommonDivisor(b, a)
			
	print a

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

int main(){
    int n;
    cin >> n;
    string s[n];
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i <n ; i++){
        cin >> s[i];
        if(s[i] == "AC"){
            ac++;
        }else if(s[i] == "WA"){
            wa++;
        }else if(s[i] == "TLE"){
            tle++;
        }else if(s[i] == "RE"){
            re++;
        }
    }
    cout << "AC" << " x "  << ac << endl;
    cout << "WA" << " x "  << wa << endl;
    cout << "TLE" << " x "  << tle << endl;
    cout << "RE" << " x "  << re << endl;

    return 0;
}





Measured memory_bytes: 6752