akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<set>

#define rep(i,n) for(int i=0;i<(n);i++)
#define MP make_pair
#define PB push_back
using namespace std;

int n,m;

void bfs(int k,vector<int> &cnt,vector<bool>&b,vector<vector<int> > &g){
    if(cnt[k]==1||cnt[k]==0){
        b[k] = 0;
        for(int i:g[k]){
            if(b[i]){
                cnt[i]--;
                bfs(i,cnt,b,g);
            }
        }
    }   
}
bool bfs3(int k,int z,vector<bool>&b,vector<vector<int> > &g){
    if(b[k])return true;
    for(int x:g[k]){
        if(x!=z){
            if(bfs3(x,k,b,g))return b[k]=true;
        }
    } 
    return false;
}
int bfs2(int k,int z,vector<int>&w,vector<vector<int> > &g){
    int s=w[k];
    int mx = 0;
    for(int x:g[k]){
        if(x!=z){
            mx = max(mx,bfs2(x,k,w,g));
        }
    }
    return s+mx;
}


int main(){
    cin >> n >> m;
    vector<int> w(n+1);
    vector<vector<int> > g(n);
    rep(i,n)cin >> w[i];
    rep(i,m){
        int u,v;
        cin >> u >> v;
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> cnt(n);
    rep(i,n){
        cnt[i] = g[i].size();
    }
    vector<bool> b(n,1);
    rep(i,n){
        bfs(i,cnt,b,g);
    }
    if(!b[0]){
        bfs3(0,0,b,g);
    }
    vector<int>p;
    int sm=0;
    rep(i,n){
        if(b[i]){
            p.PB(i);
            sm+=w[i];
        }
    }
    w[n]=sm;
    set<int>st;
    for(int x:p){
        for(int y:g[x]){
            st.insert(y);
        }
    }
    vector<vector<int> >g2(n+1);
    rep(i,n){
        if(!b[i]){
            for(int x:g[i]){
                if(b[x]){
                    g2[i].PB(n);
                    g2[n].PB(i);
                }else{
                    g2[i].PB(x);
                }
            }
        }
    }
    if(b[0]){
        cout << bfs2(n,n,w,g2) << endl;
    }else{
        cout << bfs2(0,0,w,g2) << endl;
    }
    return 0;
}


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


int main() {

	int n, y;
	cin >> n >> y;
	int ans = 0;
	int tmp = 0;
	bool flag = false;

	for (int i = 0; i <= n; i++) {//10000
		tmp = i * 10000;
		if (tmp > y)break;

		for (int j = 0; j <= n; j++) {//5000
			tmp = i*10000 + j * 5000;
			if (tmp > y)break;

			if ((n - i - j) * 1000 + tmp == y) {
				cout << i << " " << j << " " << n - i - j << endl;
				flag = true;
				break;
			}

			if (flag)break;
			
		}

		if (flag)break;

	}

	if (flag == false) {
		cout << "-1 -1 -1" << endl;
	}
}


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

int W,H;
char field[51][51];
int dirx[] = {-1,0,1,-1,0,1,-1,0,1};
int diry[] = {-1,-1,-1,0,0,0,1,1,1};

char cntBomb(int y, int x){
    int cnt = 0;
    for(int i = 0; i < 9; i++){
        if( x+dirx[i] >= 0 && x+dirx[i] < W && y+diry[i] >= 0 && y+diry[i] < H ){
            if( field[y+diry[i]][x+dirx[i]] == '#' )
                cnt++;
        }
    }
    return '0'+(cnt);
}

int main(void){
    cin >> H >> W;
    for(int i=0; i < H; i++)
        cin >> field[i];

    for(int i=0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(field[i][j] == '.'){
                field[i][j] = cntBomb(i,j);
            }
        }
    }
    for(int i = 0; i < H; i++){
        cout << field[i] << endl;
    }
}


Measured memory_bytes: 256
object Main {

    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
	        val a,b,c,d,e = sc.nextInt
	        val list = List(a,b,c,d,e).sortWith(_>_)
            printf("%d %d %d %d %d\n", list(0), list(1), list(2), list(3), list(4))
    	}
    }
}

Measured memory_bytes: 44976
#include <bits/stdc++.h>
#define ll long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
int main()
{
    FAST
    ll n;cin>>n;
    string s,x;cin>>s;
    int st=0;
    // while(s[st]=='0') st++;
    ll pc=0;
    f(i,0,n) if(s[i]=='1') pc++;
    ll m1=0,m2=0;
    ll p1[n+1]={},p2[n+1]={};
    if(pc>1)
    {
        fr(i,n-1,st)
        {
            m1 += (s[i]-'0')*powmp(2,n-i-1,pc-1);
            m1%=(pc-1);
        }
        p1[0]=1;
        f(i,1,n+1) p1[i]=(p1[i-1]*2)%(pc-1);
    }
    fr(i,n-1,st)
    {
        m2+=(s[i]-'0')*powmp(2,n-i-1,pc+1);
        m2%=(pc+1);
    }
    p2[0]=1;
    f(i,1,n+1) p2[i]=(p2[i-1]*2)%(pc+1);
    // cout<<m1<<" - "<<m2<<endl;
    f(i,0,n)
    {
        ll ans=0;
        if(s[i]=='1')
        {
            if(pc==1) cout<<"0\n";
            else
            {
                ans++;
                ll mod=(m1-p1[n-i-1])%(pc-1);
                if(mod<0) mod+=pc-1;
                while(mod)
                {
                    ans++;
                    mod=mod%((ll)(__builtin_popcount((unsigned int)mod)));
                }
                cout<<ans<<endl;
            }
        }
        else
        {
            ans++;
            ll mod=(m2+p2[n-i-1])%(pc+1);
            if(mod<0) mod+=pc+1;
            while(mod)
            {
                ans++;
                mod=mod%((ll)(__builtin_popcount((unsigned int)mod)));
            }
            cout<<ans<<endl;
        }
        
    }

}


Measured memory_bytes: 6892
// 2015/05/30 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	while(true){
		char s[150];
		cin >> s;

		if(strcmp(s, "0")==0)
			break;

		int A = 0, B = 0;

		for(int i=1; i<strlen(s); i++){		// 最初のサーブは見ない
			if(s[i]=='A'){
				A++;
			}
			else{
				B++;
			}
		}

		if(A>B){		// 最後のポイントの処理
			A++;
		}
		else{
			B++;
		}

		cout << A << ' ' << B << '\n';
	}

	return 0;
}

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


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

  int n, r; cin >> n >> r;

  if(n < 10){
    int x = 10 - n;
    cout << 100 * x + r;
  }
  else cout << r;
  cout << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
/** Problem0168 : Kannondou **/
int main()
{
	int n, k[31];
	k[0] = 1; k[1] = 1; k[2] = 2; k[3] = 4;
	for (int i=4; i<31; i++) {
		k[i] = k[i-1] + k[i-2] + k[i-3];
	}
	
	while (cin >> n, n!=0) {
		cout << k[n]/10/365+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define PB push_back
#define X first
#define Y second
#define INF 1000 * 1000 * 1000

#define LL long long
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;
const int MAX = 1 << 17;
vector<int> g[100005] , gr[100005];
int p[100005];
int in[100005];
int used[100005];
vector<int> topo;
int lvl[100005];
void dfs(int u)
{
	used[u] = 1;
	for(auto v : g[u])
	{
		if(!used[v])
		{
			p[v] = u;
			dfs(v);
		}
	}
	topo.PB(u);
}
int main()
{
	ios_base::sync_with_stdio(0);
	memset(p , -1 , sizeof p);
	int N , M;
	cin >> N >> M;
	for(int i = 0; i < N - 1 + M; i++)
	{
		int u , v;
		cin >> u >> v;
		u--;v--;
		g[u].PB(v);
		gr[v].PB(u);	
		in[v]++;
	}
	for(int i = 0; i < N; i++)
		if(in[i] == 0)
		{
			dfs(i);
		}
	reverse(topo.begin() , topo.end());
	for(int i = 0; i < topo.size(); i++)
		lvl[topo[i]] = i;
	vector<int> ans(N);
	for(auto i : topo)
	{
		p[i] = -1;
		for(auto v : gr[i])
		{	
			if(p[i] == -1 || lvl[v] > lvl[p[i]])
				p[i] = v;
		}
		ans[i] = p[i];
	}
	for(auto i : ans)
		cout << i + 1 << endl;
}


Measured memory_bytes: 18940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int W = scan.nextInt();

		int[] w = new int[N+1];
		long[] v = new long[W+1];
		w[0] = 0;
		v[0] = 0L;

		for(int i=1;i<N+1;i++) {
			w[i] = scan.nextInt();
			v[i] = scan.nextLong();
		}

		long[][] ans = new long[N+1][W+1];

		for(int i=0;i<W+1;i++) {
			ans[0][i] = 0L;
		}

		for(int item = 1;item < N+1;item++) {
			for(int weight = 0;weight < W+1;weight++) {
				if(weight < w[item] && ans[item-1][weight] == 0) {
					ans[item][weight] = 0L;
				}else if(weight < w[item] && ans[item-1][weight] != 0){
					ans[item][weight] = ans[item-1][weight];
				}else {
					ans[item][weight]=Math.max(ans[item-1][weight],
							(long)ans[item-1][weight-w[item]]+v[item]);
				}
			}
		}

		/*		for(int i=0;i<N+1;i++) {
					for(int j=0;j<W+1;j++) {
						System.out.print(ans[i][j]+" ");
					}
					System.out.println();
				}
				System.out.println();*/

		System.out.println(ans[N][W]);

		scan.close();
	}

}


Measured memory_bytes: 126288
#include<bits/stdc++.h>
using namespace std;
long long int a[310][310],w[310][310],nexts[310][310],n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            nexts[i][j]=-1;
            cin>>a[i][j];
            w[i][j]=a[i][j];
        }
    }
    for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(w[i][j]>w[i][k]+w[k][j])
            {
                w[i][j]=w[i][k]+w[k][j];
            }
        }
    }}

    long long int ans=0;
    for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(w[i][j]==w[i][k]+w[k][j] && i!=k && k!=j)
            {
                nexts[i][j]=1;
            }
        }
    }}
    bool flag=false;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            //cout<<w[i][j]<<endl;
            if(w[i][j]!=a[i][j])
            {
                flag=true;
            }
            if(nexts[i][j]==-1) ans+=(long long int)w[i][j];
        }
    }
    if(flag) cout<<"-1"<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 2432
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{



	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] tmp = scanner.nextLine().split(" ");
		int n        = Integer.parseInt(tmp[0]);
		int m        = Integer.parseInt(tmp[1]);
		String[] tem = scanner.nextLine().split(" ");
		int[] list   = new int[m];

		for(int i = 0; i < m; i++) {
			list[i] = Integer.parseInt(tem[i]);
		}

		Arrays.sort(list);
		Integer[] diff   = new Integer[m - 1];

		for(int i = m - 1; i > 0 ; i--) {
			diff[i - 1] = list[i] - list[i - 1];

		}

		Arrays.sort(diff, Comparator.reverseOrder());

		int ans = 0;
		for(int i = n - 1; i < m - 1; i++) {

			ans += diff[i];
		}

		System.out.println(ans);
	}
}


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

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    vector<int> A(N,0);
    int E, O;
    E = 0;
    O = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        E += ((1 + A.at(i))%2);
        O += (A.at(i)%2);
    }
    //cout << E << ':' << O << endl;
    cout << (ll)pow(3, N) - (ll)pow(2, E) << endl;

    return 0;
}

Measured memory_bytes: 4116
#!/usr/bin/env python3


def main() -> None:
    S = r()
    T = r()
    w('Yes' if T.startswith(S) and len(S) + 1 == len(T) else 'No')


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
long long weights[N],n,prices[N],dp[101][100002];
long long  solve(long long i,long long weight){
    if(weight<weights[i]){
        return solve(i+1,weight);
    }
    if(i==n||weight==0){
        return 0;
    }
    if(dp[i][weight]!=-1){
        return dp[i][weight];
    }
    return dp[i][weight]=max(prices[i]+solve(i+1,weight-weights[i]),solve(i+1,weight));
}
int main()
{
long long weight,i;
memset(dp,-1,sizeof(dp));
cin>>n>>weight;
for(i=0;i<n;++i){
    cin>>weights[i]>>prices[i];
}
cout<<solve(0,weight)<<endl;




    return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	int N, L; cin >> N >> L;
	vector<string> Ss;
	for(int i=0; i<N; i++) {
		string s;
		cin >> s;
		Ss.push_back(s);
	}
	sort(ALL(Ss));
	for(int i=0; i<N; i++) cout << Ss[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 89;
	while (kkt) {
		ll n; scanf("%lld", &n); if (n == 0) break;
		vector<vector<bitset<51>>> dp(31,vector<bitset<51>>(n));
		for (int i = 0; i < n; i++) dp[0][i][i] = true;
		vector<vector<ll>> d(31);
		for (int i = 0; i < n; i++) {
			int f; scanf("%d", &f);
			for (int j = 0; j < f; j++) {
				int x; scanf("%d", &x);
				d[x].push_back(i);
			}
		}
		bool ok = false;
		for (int i = 1; i < 31; i++) {
			for (int j = 0; j < n; j++) dp[i][j] |= dp[i - 1][j];
			for (int j = 0; j < d[i].size(); j++) {
				for (int k = 0; k < d[i].size(); k++) {
					if (j == k) continue;
					dp[i][d[i][j]] |= dp[i - 1][d[i][k]];
				}
			}
			
			for (int j = 0; j < n; j++) if (dp[i][j].count() == n) {
				cout << i << "\n";
				ok = true;
				break;
			}
			if (ok) break;
		}
		if (!ok) puts("-1");
	}
	return 0;

}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, m;
	vector<double> a;
	cin >> n >> m;
	double s = 0;
	while(n--) {
		int e; cin >> e;
		a.pb(e);
		s += e;
	}
	sort(rall(a));
	for (int i = 0; i < m; i++)
		if (a[i] < s/(4*m)) return cout << "No" << ende, 0;
	cout << "Yes" << ende;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,n,M[100][100],k,l,o;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&k,&l);
    k--;
    for(j=0;j<l;j++){
      scanf("%d",&o);
      o--;
      M[k][o]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j>=1)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	map<char, ll>mp;
	rep(i, n) {
		mp[s[i]]++;
	}
	ll ans = 1;
	for (auto p : mp) {
		ll x = p.second + 1;
		ans *= x;
		ans %= MOD;
	}
	ans--;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
  	for(int i = 0; i < n; i++)
     	cin >> a[i];
    int cnt = 0;
    for(int i = 1; i < n - 1; i++)
    {
        if(a[i] > a[i - 1] && a[i + 1] > a[i])
            cnt++;
        else if(a[i] > a[i + 1] && a[i] < a[i - 1])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,m,d;
    bool b=true;
    map<int,int> mpd,mpt;
    cin >> n;
    rep(i,n){
        cin >> d;
        mpd[d]++;
    }
    cin >> m;
    rep(i,m){
        cin >> d;
        mpt[d]++;
        if(mpt[d]>mpd[d]) b=false;
    }
    if(b) cout << "YES\n";
    else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 18944
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int[][] p = new int[n][d];
        int ans = 0;
        for(int i = 0; i < n;i++){
            for(int j = 0;j < d;j++){
                p[i][j] = sc.nextInt();
            }
        }

        for(int i = 0;i < n;i++){
            for(int j = i+1;j < n;j++){
                int sum = 0;
                for(int k = 0;k<d;k++){
                    sum += Math.pow(p[i][k]-p[j][k], 2);
                }
                if((double)Math.sqrt(sum)==(double)((int)Math.sqrt(sum))){
                    ans++;
                }
            }      
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int S;
char vis[1000001];
int main(){
  int i;
  rd(S);
  for(i=1;;i++){
    if(vis[S]++){
      break;
    }
    if(S%2){
      S =3*S+1;
    }
    else{
      S =S/2;
    }
  }
  wt_L(i);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int S;
// char vis[1000001];
// {
//   int i;
//   rd(S);
//   for(i=1;;i++){
//     if(vis[S]++) break;
//     S = if[S%2, 3S+1, S/2];
//   }
//   wt(i);
// }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b)
{
	return (b>0)?gcd(b,a%b):a;
}
int main()
{
	long long a, b;
	cin >> a >> b;
	long long t=gcd(a, b);
	long long cnt=0;
	for (long long i=2; i<=t/i; i++)
	{
		if (t%i==0)
		{
			cnt++;
			while (t%i==0)
			{
				t/=i;
			}
		}
	}
	if (t>1)
	{
		cnt++;
	}
	cout << cnt+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	ll ans = 0;
	REP(r, N + 1) {
		REP(g, N + 1) {
			if (r * R + g * G > N)break;
			if ((N - r * R - g * G) % B == 0)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int c=sc.nextInt();
    long val[]=new long[n+1];
    long wt[]=new long[n+1];
    for(int i=1;i<=n;i++)
    {
      
        wt[i]=sc.nextInt();
        val[i]=sc.nextInt();
      
    }
   long[][] t=new long[n+1][c+1];
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=c;j++)
      {
		 if(wt[i]<=j)
		 {
		 t[i][j]=Math.max(val[i]+t[i-1][(int)(j-wt[i])],t[i-1][j]);}
		 else
		 {
			 t[i][j]=t[i-1][j];
		 }
      }
    }
    System.out.println(t[n][c]);
  }
}

Measured memory_bytes: 127440
#include <cstdio>
using namespace std;


int N, M, X;
bool A[100];


int main() {
    scanf("%d %d %d", &N, &M, &X);
    for(int i = 0; i < M; i++) {
        int a;
        scanf("%d", &a);
        A[a - 1] = true;
    }

    int cost1 = 0;
    for(int i = 1; i <= X; i++) {
        if(A[i - 1]) cost1++;
    }
    int cost2 = 0;
    for(int i = X; i <= N; i++) {
        if(A[i - 1]) cost2++;
    }

    if(cost1 < cost2)
        printf("%d\n", cost1);
    else
        printf("%d\n", cost2);

    return 0;
}


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

int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n,h,w,c=0,x,y;
        cin>>n>>h>>w;
        for(int i=0; i<n; i++)
        {
                cin>>x>>y;
                if(h<=x && w<=y)
                        c++;
        }
        cout<<c<<endl;
        return 0;
}


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

typedef long long ll;

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

    ll n; cin >> n;
    vector<ll> a(n),b(n),c(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll uku = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        ll ushi = upper_bound(c.begin(),c.end(),b[i]) - c.begin();
        ans += uku * (n-ushi);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            solve(reader);
        }
    }

    private static void solve(InputReader reader) throws IOException {
        String ns = reader.readLine();
        char[] n = ns.toCharArray();

        int sum = 0;
        for (int i = 0; i < n.length; i++) {
            sum += n[i] - '0';
        }

        String ans = (Integer.parseInt(ns) % sum) == 0 ? "Yes" : "No";
        System.out.println(ans);
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }

    static int lcm(int m, int n) {
        return m / gcd(m, n) * n;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


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

int main(){

    int N;
    cin >> N;
    string S;
    cin >> S;
    string ans = "No";
    int Ssize = S.size();

    if(Ssize%2 == 1) {
    }else {
        if(S.substr(0,Ssize/2) == S.substr(Ssize/2,Ssize/2)){
            ans = "Yes";
        }
    }
        cout << ans << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int a, b, c, x, count = 0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	rep(i, c + 1) {
		rep(j, b + 1) {
			rep(k, a + 1) {
				if (i * 50 + j * 100 + k * 500 == x)++count;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const ll MOD = 998244353;
void Main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    For(i,0,k) cin >> l[i] >> r[i];
    vector dp(n+2, 0LL);
    dp[0] = 1;
    For(i,1,n){
        dp[i] += dp[i-1];
        dp[i] %= MOD;
        //For(t,1,n+1) cout << dp[t] << " \n"[t==n];
        For(j,0,k){
            if(i + l[j] <= n){
                dp[i+l[j]] += dp[i];
                dp[i+l[j]] %= MOD;
                dp[min(n+1, i+r[j]+1)] -= dp[i];
                dp[min(n+1, i+r[j]+1)] = (dp[min(n+1, i+r[j]+1)] + MOD) % MOD;
            }
        }
    }
    cout << dp[n] % MOD << endl;
    //For(t,1,n+1) cout << dp[t] << " \n"[t==n];
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 4836
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

double dp[301][301][301];

double findAnswer(int one, int two, int three, int n) {
	if((one < 0 || two < 0 || three < 0) || (one == 0 && two == 0 && three == 0))
		return 0;
	if(dp[one][two][three] > 0)
		return dp[one][two][three];
	return dp[one][two][three] = (n + one * findAnswer(one - 1, two, three, n) + two * findAnswer(one + 1, two - 1, three, n) + three * findAnswer(one, two + 1, three - 1, n)) / (one + two + three);
}

void solve() {
	int n, ele, ones = 0, twos = 0, threes = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> ele;
		if(ele == 1)
			ones++;
		else if(ele == 2)
			twos++;
		else 
			threes++;
	}
	memset(dp, -1.0, sizeof(dp));
	cout << fixed << setprecision(14) << findAnswer(ones, twos, threes, n);
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 213376
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <deque>
using namespace std;

int score[100], ranking[100], check1[100], check2[100];

int main()
{
    int n; cin >> n;
    int len = n*(n-1)/2;

    for(int i=0;i < len;++i) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        if (c > d) score[a-1] += 3;
        else if (d > c) score[b-1] += 3;
        else ++score[a-1], ++score[b-1];
    }

    for(int i=0;i < n;++i) ranking[i] = score[i];

    sort(ranking, ranking+n, greater<int>());

    for(int i=0;i < n;++i) {
        for(int j=0;j < n;++j) {
            if (check1[i]) break;
            if (score[i] == ranking[j]) {
                if (ranking[j] == check2[j]) {
                    score[i] = j+1;
                    check1[i] = 1;
                    continue;
                }
                if (!check2[j]) score[i] = j+1;
                check1[i] = 1, check2[j] = ranking[j];
            }
        } 
    }

    for(int i=0;i < n;++i) printf("%d\n", score[i]);

}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)

int main() {
    int n, u, k, v;
    cin >> n;

    int mat[n][n];
    REP(i, n) REP(j, n) mat[i][j] = 0;

    REP(i, n) {
        cin >> u >> k;
        u--;
        REP(j, k) {
            cin >> v;
            v--;
            mat[u][v] = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            if (j) cout << " ";
            cout << mat[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
	int a,b,i,j,n=0,k[9999][5],h;
	scanf("%d %d",&a,&b);
	while(a!=0 || b!=0)
	{
		n++;
		k[n][1]=a;
		k[n][2]=b;
		scanf("%d %d",&a,&b);
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=k[i][1];j++)
		{
			for(h=1;h<=k[i][2];h++)
				if(j!=1 && j!=k[i][1] && h!=1 && h!=k[i][2])
					printf(".");
				else
					printf("#");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2120
fn main() {
    let _: i32 = readln();
    let a: Vec<i64> = readln();
    let mut c: HashMap<i64, i64> = HashMap::new();
    for &x in &a {
        *c.entry(x).or_insert(0) += 1;
        *c.entry(x - 1).or_insert(0) += 1;
        *c.entry(x + 1).or_insert(0) += 1;
    }
    let answer = c.into_iter().map(|(_, v)| v).max().unwrap();
    println!("{}", answer);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 12540
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	TLong n;
	TLong p = 1;
	scanf("%lld",&n);
	for (int i = 2; i <= n; ++i)
	{
		p = p * i % TBMod;
	}
	printf("%lld\n", p);
	return 0;
}

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

int main()
{
    int t[10];
    for(int i=0;i<10;i++)cin>>t[i];
    sort(t,t+10);
    for(int j=9;j>=7;j--)cout<<t[j]<<endl;
    return 0;
}



Measured memory_bytes: 3104
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

all = S.count("R") * S.count("G") * S.count("B")

cnt = 0
for i in range(N):
    for j in range(i, N):
        k = 2 * j - i
        if k >= N:
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt += 1
print(all - cnt)

Measured memory_bytes: 9112
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	map<int, int> m;
	m[a] = 1;
	m[b] = 1;
	m[c] = 1;
	cout << m.size() << endl;

	return 0;
}

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

int main()
{
    ll n,w;
    cin>>n>>w;
    ll dp[w+1]={};
    for(ll i=0;i<n;i++)
    {
        ll weight,value;
        cin>>weight>>value;
        for(ll have = w - weight; have >= 0; have--)
        {
            dp[weight+have] = max(dp[weight+have], dp[have]+value);
        }
    }
    ll ans=0;
    for(ll i:dp) if(i>ans) ans=i;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

signed main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0] << endl;
}

Measured memory_bytes: 256
/************************************/
/* NoobM							*/
/* File Name : chaa.cpp				*/
/* Date : 13.07.2020 02:37:00 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n, m, c;
	cin >> n >> m >> c;
	
	int counter = 0;
	
	vi(m, b);
	
	rr(i, n) {
		ll total = 0;
		
		rr(j, m) {
			int x;
			cin >> x;
			total += (x * b[j]);
		}
		total += c;
		
		if(total > 0) counter++;
	}
	
	cout << counter << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) cout << B << '\n';
  else if (A >= 6) cout << B / 2 << '\n';
  else cout << 0 << '\n';
}


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

int main(void) {
	int N;
	int sum[2][101];

	cin >> N;
	sum[0][0] = sum[1][0] = 0;
	int a;
	for (int j = 0; j < 2; ++j) {
		for (int i = 1; i <= N; ++i) {
			cin >> a;
			sum[j][i] = a + sum[j][i - 1];
		}
	}

	int max_cnt = -1;
	for (int i = 1; i <= N; ++i) {
		int cnt = sum[0][i] + (sum[1][N] - sum[1][i - 1]);
		max_cnt = max(cnt, max_cnt);
	}

	cout << max_cnt << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

   int n;
   long long int l[100];
   int ans = 0;

   cin >> n;

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

   for(int i = 0; i < n - 2; i++){
      for(int j = i + 1; j < n - 1; j++){
         for(int k = j + 1; k < n; k++){
            if((l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) && (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j])){
               ans++;
            }
         }
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3644
import java.util.PriorityQueue

fun main(args: Array<String>)
{
    val (n, m) = readNInts()
    val ptj = Array<MutableList<Int>>(m, { mutableListOf<Int>() })
    for (i in 1..n)
    {
        val (a, b) = readNInts()
        if (a > m) continue
        ptj[m - a].add(-b)
    }

    var ans = 0L
    val q = PriorityQueue<Int>()
    for (i in m-1 downTo 0)
    {
        for (b in ptj[i])
        {
            q.offer(b)
        }

        if (!q.isEmpty())
        {
            ans += -q.poll().toLong()
        }
    }

    println(ans)
}

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)


Measured memory_bytes: 68992
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>

int main()
{
    char a;
    int x = 0;
    while (std::cin >> a) {
        if (a == '+') x++;
        else if (a == '-') x--;
    }
    std::cout << x << std::endl;
}

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

const int MXN=10005;
const int MOD=1e9+7;
int add(int&x,int y){return(x+=y)<MOD?x:x-=MOD;}
int sub(int&x,int y){return(x-=y)>= 0?x:x+=MOD;}

char K[MXN];
int D,dp[MXN][105][2];

int main(){
  dp[0][0][0]=1;
  dp[0][0][1]=1;
  scanf("%s%d",K,&D);
  int N=strlen(K);
  reverse(K,K+N);
  for(int i=0;K[i];++i){
    for(int d=0;d<=9;++d){
      for(int k=0;k<D;++k){
        add(dp[i+1][(k+d)%D][0],dp[i][k][0]);
        if(d+'0'<K[i])
        add(dp[i+1][(k+d)%D][1],dp[i][k][0]);
        if(d+'0'==K[i])
        add(dp[i+1][(k+d)%D][1],dp[i][k][1]);
      }
    }
  }
  printf("%d\n",sub(dp[N][0][1],1));
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
int b[240005];
int main()
{
	int n;cin>>n;
	int a[105];
	memset(b,0,sizeof(b));
	for(int i=1;i<=200;i++)
	for(int j=1;j<=200;j++)
	for(int k=1;k<=200;k++)
	{
		long long x;
		x=(i+j)*(i+j)+(j+k)*(j+k)+(i+k)*(i+k);
		if(x%2==0)
		{
			x/=2;
			b[x]++;
		}
	}
	for(int i=1;i<=n;i++)
	cout<<b[i]<<endl;
}

Measured memory_bytes: 4568
from collections import defaultdict, Counter
import itertools

def main():
    num = int(input())
    data = list(map(int, input().split()))
    ans = 0
    for i in range(num - 1):
        if data[i] == i + 1:
            data[i], data[i + 1] = data[i + 1], data[i]
            ans += 1
    if data[num - 1] == num:
        ans += 1

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 52908