akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
int fn(int a,int b){
	if(a<b) return fn(b,a);
	
	if(a%b!=0) return fn(b,a%b);
	else return b;
}
int main(void){
	int N,K,A[100000],tem,max=0;
	cin>>N>>K;
	REP(i,N) cin>>A[i];

	if(N>=2){
		tem=fn(A[0],A[1]);
		REP(i,N){
			tem=fn(tem,A[i]);
			chmax(max,A[i]);
		}
		if(max<K ||K%tem!=0) print("IMPOSSIBLE");
		else print("POSSIBLE");
	}else{
		if(A[0]==K) print("POSSIBLE");
		else print("IMPOSSIBLE");
	}


	return 0;
}




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

static const int MAX = 100;
static const int UNVISITED = 0;
static const int VISITING = 1;
static const int VISITED = 2;

static const int INFTY = (1 << 21);


int n, M[MAX][MAX];

int prim()
{
	int d[MAX], p[MAX];
    
	for(int i = 0;i < n;i++)
	{
	  d[i]=INFTY; 
	  p[i]=0;
	}
	
	d[0]=-1;//加入第一个点，-1表示该点在集合U中，否则在集合V中
	int num = 0,ans = 0, e = 0;//e为最新加入集合的点
    while(num < n-1)//加入m-1条边
   {
	int micost=INFTY,miedge=-1;
	for(int i=0;i<n;i++)
		if(d[i]!=-1)
		{
			int temp=M[e][i];
			if(temp<d[i])
			{
				d[i]=temp;
				p[i]=e;
			}
			if(d[i]<micost)
				micost=d[miedge=i];
		}

	ans+=micost;
	d[e=miedge]=-1;
	num++;
	}
	return ans;
}

int main() {
   cin >> n;

   for( int i = 0; i < n; i++ ) {
   	for( int j = 0; j < n; j++ ) {
        int  e; cin >> e;
   		M[i][j] = (e == -1) ? INFTY : e;
   	}
   }

   cout << prim() << endl;

   return 0;
}




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

using namespace std;

int gcd(int i, int j) {

	//ユークリッドの互除法で最大公約数を求める
	//2変数の場合

	if (i < j) { swap(i, j); }

	while (i%j != 0) {
		int r;
		r = i % j;
		if (r == 0) { return j; }
		else { i = j; j = r; }
	}
	return j;
}

long long gcd(vector<long long> &a) {

	//ユークリッドの互除法で最大公約数を求める
	//多変数の場合

	long long x = a[0];
	long long y = a[1];
	for (long long i = 1; i < (long long)a.size(); i++) {
		y = a[i];
		if (x < y) { swap(x, y); }
		while (x%y != 0) {
			long long r;
			r = x % y;
			if (r == 0) {
				break;
			}
			else {
				x = y;
				y = r;
			}
		}
		x = y;
	}
	return y;
}

int main() {

	int n;
	cin >> n;
	vector<long long> a(n);

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


}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int c[3][3];

int main(){
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    string ans = "Yes";
    if (c[0][0]-c[0][1]!=c[1][0]-c[1][1]) ans = "No";
    if (c[1][0]-c[1][1]!=c[2][0]-c[2][1]) ans = "No";
    if (c[0][0]-c[1][0]!=c[0][1]-c[1][1]) ans = "No";
    if (c[0][1]-c[1][1]!=c[0][2]-c[1][2]) ans = "No";
    vector<int> v(3);
    rep(i, 3) rep(j, 3) {
        v[(i+j)%3] += c[i][j];
    }
    if (v[0]!=v[1]) ans = "No";
    if (v[1]!=v[2]) ans = "No";

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  int times,h;
  string card,temp1,temp2;
  while(cin >> card && card[0] != '-') {
    cin >> times;
    for(int i = 0; i < times; i++) {
      cin >> h;
      temp1 = card.substr(0, h);
      temp2 = card.substr(h, card.length());
      card = temp2 + temp1;
    }
    cout << card << endl;
  }
  return 0;
}

Measured memory_bytes: 3168
//#include<iostream>
#include<cstring>
#include<cstdio>
//#include<time.h>
//#include<complex>
#include<algorithm>
#include<stdlib.h>
using namespace std;

int n,m;
#define maxn 5011
#define maxm 211
int a[maxm][maxn],p[maxm][maxn];
/* ji ru bian */ struct Edge{int to,next;}edge[maxn*maxm]; int first[maxm][maxn],le=2;
void in(int x,int y,int v) {Edge &e=edge[le]; e.to=v; e.next=first[x][y]; first[x][y]=le++;}
#define LL long long
LL f[maxn]; int dis[maxn];
int sta[maxn],top;

int main()
{
//	freopen("ditf.in","r",stdin);
//	freopen("ditf.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;i++) scanf("%d",&dis[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			scanf("%d",&a[j][i]);
	
	for (int j=1;j<=m;j++)
	{
		top=0;
		for (int i=n;i;i--)
		{
			while (top && a[j][sta[top]]<=a[j][i]) top--;
			if (top) in(j,sta[top],i);
			p[j][i]=sta[top];
			sta[++top]=i;
		}
	}
	
//	for (int j=1;j<=m;j++,cout<<endl)
//		for (int i=1;i<=n;i++)
//			cout<<p[j][i]<<' ';cout<<endl;

//	for (int j=1;j<=m;j++)
//		for (int i=1;i<=n;i++)
//		{
//			cout<<j<<' '<<i<<"!!!"<<endl;
//			for (int k=first[j][i];k;k=edge[k].next)
//			{
//				Edge &e=edge[k]; cout<<e.to<<' ';
//			}cout<<endl;
//		}cout<<endl;
	
	for (int j=1;j<=m;j++) f[1]+=a[j][1];
	for (int j=1;j<=m;j++)
	{
		int now=a[j][1];
		for (int i=2;i<=n;i++) if (a[j][i]>now) f[i]+=a[j][i]-now,now=a[j][i];
	}
	
	LL Ans=0;
	for (int L=1;L<=n;L++)
	{
//		for (int i=L;i<=n;i++) cout<<f[i]<<' ';cout<<endl<<endl;
		LL ans=f[L]; Ans=max(Ans,ans);
		for (int R=L+1;R<=n;R++) ans-=dis[R-1],ans+=f[R],Ans=max(Ans,ans);
		
		for (int j=1;j<=m;j++)
		{
			int hh=p[j][L];
			for (int x=L+1,last=0;x!=hh;x=p[j][x])
				f[x]+=a[j][x]-last,last=a[j][x];
			if (hh)
			{
				f[hh]-=a[j][hh]-a[j][L];
//				cout<<edge[edge[first[j][hh]].next].to<<"L(L("<<endl;
				f[hh]+=a[j][hh]-a[j][edge[first[j][hh]=edge[first[j][hh]].next].to];
			}
		}
	}
	
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 20608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main(){
    long N;
    std::cin >> N;
    long long A[100000];
    long long v=1000000000000000000;
    
    for(long i=0; i<N; i++){
        std::cin >> A[i];
        if(A[i]==0){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    long long result=A[0];
    for(long i=1; i<N; i++){
        if(LONG_MAX/A[i]<result){
            std::cout << -1 << std::endl;
            break;
        }
        long long temp_result=result*A[i];
        if(temp_result>v){
            std::cout << -1 << std::endl;
            break;
        }
        if(temp_result/A[i]!=result){
            std::cout << -1 << std::endl;
            break;
        }else{
            result = temp_result;
        }
        if(i==N-1){
            std::cout << result << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4400
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

S = In.str()

if S[0] == "R" and S[1] == "R" and S[2] == "R":
    Out.int(3)
elif S[0] == "R" and S[1] == "R":
    Out.int(2)
elif S[2] == "R" and S[1] == "R":
    Out.int(2)
elif "R" in S:
    Out.int(1)
else:
    Out.int(0)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68072
<?php

$result = array();

while (! feof(STDIN)) {
    $line = trim(fgets(STDIN));
    sscanf($line, '%d,%f,%f', $n, $kg, $m);

    if ($kg / ($m*$m) >= 25.0) {
        $result[] = $n;
    }
}
echo implode("\n", $result) . "\n";

Measured memory_bytes: 15408
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector <char> v;
vector<int> num;
string s = "No";

int main(){
  int A,N;
  cin >>N>>A;
  if(N%500 <= A){
    s = "Yes";
  }

  cout << s<< endl;
  return 0;
}



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

using namespace std;

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<pair<int32_t, int32_t>> va(N);
    vector<pair<int32_t, int32_t>> vc(M);
    for(auto& e : va)
        cin >> e.first >> e.second;
    for(auto& e : vc)
        cin >> e.first >> e.second;

    for(auto& ea : va)
    {
        int32_t dmin = 400000000;
        int ans = 0;
        for(int i = M - 1; i >= 0; --i)
        {
            int32_t d = abs(ea.first - vc[i].first) + abs(ea.second - vc[i].second);
            if(dmin >= d)
            {
                dmin = d;
                ans = i + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  bool ex = false;
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0 && A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
      ex = true;
      break;
    }
  }
  if (ex) {
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<int> Vi;
typedef pair<int, int> Pii;
# define pb push_back
# define mp make_pair
# define MOD 1000000007
# define INF 1000000000
# define bug puts("H");

const int N = 100000 + 5;

inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}


int d[N],n,b[N];

int LIS(){
    b[1]=d[1];
    int l,r,mid,len=1;
    for(int i=2;i<=n;i++){
        l=1;
        r=len;
        while(l<=r){
        mid=(l+r)/2;
        if(b[mid]<=d[i]) //if(b[mid]<=d[i]) 改成这样就是最长不下降子序列
        l=mid+1;

        else  r=mid-1;
        }
        b[l]=d[i];
        if(l>len) len++;

    }
    return len;
}
int main ()
{
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>d[i];
        d[i] = 1000000000 - d[i];
    }
    int len=LIS();
    cout<<len;
    return 0;
    return 0;
}


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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const int mod = 1e9 + 7;
const ll N = 2e5 + 5;
ll inf = 1e18;


int main(){

    Fast;

    ll a , b , c , d;
    cin >> a >> b >> c >> d;

    ll tmp = max(a*c , a*d);
    tmp = max(tmp , b*c);
    tmp = max(tmp , b*d);

    cout << tmp ;

    return 0;
}


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

int dp[3001][3001];

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

	string s, t;
	cin >> s >> t;
	for(int i=1; i<=s.size(); ++i) {
		for(int j=1; j<=t.size(); ++j) {
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	//cout << dp[s.size()][t.size()];
	int i=s.size(), j=t.size();
	string ans;
	while(i&&j) {
		if(s[i-1]==t[j-1]) {
			ans=s[i-1]+ans;
			--i;
			--j;
			continue;
		}
		if(dp[i-1][j]>dp[i][j-1])
			--i;
		else
			--j;
	}
	cout << ans;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
 
long long Mygcd(long long a, long long b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}
 
int Mygcd(int a, int b)
{
	if (a % b == 0)return b;
	return Mygcd(b, a % b);
}
 
long long Mylcm(long long a, long long b)
{
	return a * b / Mygcd(a, b);
}
 
int Mylcm(int a, int b)
{
	return a * b / Mygcd(a, b);
}
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	double R;
 
	cin >> R;
 
	double PI = 3.14159265358979323846;
 
	cout << std::fixed << std::setprecision(20) << R * 2 * PI << endl;
 
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

ll dp[3005][3005];

ll bin(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res%mod * (a%mod))%mod;
        res %= mod;
        a *= a;
        a %= mod;
        b>>=1;
    }
    return res%mod;
}

ll inv(ll a) {
    return bin(a, mod-2);
}

int main() 
{ 
    fastio
    int n, s;
    cin>>n>>s;
    vector<int> vec(n+1);
    for(int i = 1; i<=n; ++i) cin>>vec[i];
    
    dp[0][0] = bin(2, n)%mod;
    for(int i = 1; i<=n; ++i) {
        for(int j = 0; j<=s; ++j) {
            if(dp[i-1][j]>0) {
                dp[i][j] += dp[i-1][j];
                if(j+vec[i]<=s) {
                    dp[i][j+vec[i]] += (dp[i-1][j]%mod)*inv(2);
                    dp[i][j+vec[i]] %= mod;
                }
            }
        }
    }

    cout<<dp[n][s]%mod<<endl;
} 

Measured memory_bytes: 73984
alias Point = Tuple!(int, "x", int, "y");

void main() {
  auto H = scan!int, W = scan!int;
  bool[][] table = H.iota.map!(_ => scan.map!(c => c == '.').array).array;
  bool at(Point p){ return table[p.y][p.x]; }

  int solve() {

    alias DP = Tuple!(int, "count", bool, "isGood");

    DP[Point] dp;
    Point[] points = [Point(0, 0)];
    dp[points[0]] = DP(at(points[0]) ? 0 : 1, true);

    while(points.length > 0) {
      Point[] next;
      foreach(p; points) {
        if (p.x < W-1) {
          auto right = Point(p.x + 1, p.y);
          auto count = dp[p].count;
          if (at(p) && !at(right)) count++;
          if (!(right in dp) || (right in dp).count > count) {
            dp[right] = DP(count, at(right));
            next ~= right;
          }
        }
        if (p.y < H-1) {
          auto down = Point(p.x, p.y + 1);
          auto count = dp[p].count;
          if (at(p) && !at(down)) count++;
          if (!(down in dp) || (down in dp).count > count) {
            dp[down] = DP(count, at(down));
            next ~= down;
          }
        }
      }

      points = next;
    }
    
    return dp[Point(W-1, H-1)].count;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }

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


Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n;
map<ll, int> mp;
ll res;
int main()
{
	cin >>n;
	ll ni=n;
	ll b=2;
	while (n!=1)
	{
		bool fl=0;
		for (ll i=b;i*i<=n;i++)
		{
			if (n%i) continue;
			fl=1,b=i;
			while (ni%i==0) ni/=i,mp[i]++;
			//cout <<i<<" ##\n";
		}
		if (!fl)
		{
			mp[ni]++;
			break;
		}
		n=ni;
	}
	for (map<ll, int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		int t=0;
		//cout <<it->Fst<<" #############\n";
		for (int j=1;j<=it->Snd+1;j++)
		{
			t+=j;
			//cout <<j<<" "<<t<<" "<<it->Snd<<" ##\n";
			if (t>it->Snd)
			{
				res+=j-1;
				break;
			}
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 3644
def main():
    N = int(input())
    S = input()
    # ゴールのイメージ：.........###########
    # 左から何個分まで白にするかで場合分けして最小回数を探索
    black_cum_sum = [0] * N
    for i, c in enumerate(S):
        if S[i] == '#':
            black_cum_sum[i] += 1
        if i > 0:
            black_cum_sum[i] += black_cum_sum[i - 1]
    ans = N - black_cum_sum[N - 1]  # 全部黒にするケース
    for n in range(1, N + 1):
        # 白をn個連続にするケース
        # 前半は黒を白に
        c = black_cum_sum[n - 1]
        # 後半は白を黒に
        c += (N - black_cum_sum[N - 1]) - (n - black_cum_sum[n - 1])
        ans = min(ans, c)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 17072
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

const int base = (int)(1e9 + 7);

int n, ans, S;             
int f[2005][2005];

int mul(int x, int y) {
    return (x * 1ll * y) % base;
}

int add(int x, int y) {
    x += y;
    if (x >= base)
        x -= base;
    return x;
}

int bin_pow(int x, int st) {
    int res = 1;
    while (st) {
        if (st & 1)
            res = mul(res, x);
        x = mul(x, x);
        st >>= 1;
    }
    return res;
}

int rec(int ost, int cnt) {
    if (ost < 3)
        return 0;

    if (f[ost][cnt] != 0)
        return f[ost][cnt];
    f[ost][cnt] = 1;

    if (ost < 6)
        return 1;

    for (int nxt = 3; nxt <= ost; ++nxt)
        f[ost][cnt] = add(f[ost][cnt], rec(ost - nxt, cnt + 1));
    
    return f[ost][cnt];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifndef _LOCAL          
    #endif // _LOCAL

    cin >> S;
    cout << rec(S, 1) << "\n";

    return 0;
}

Measured memory_bytes: 14228
// oh yea mr krabs
// REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5+10 ;
const int mod = 1e9+7 ;

int a[maxn] ;
int ans ;

int main(){

    ios::sync_with_stdio(false) ;
    cin.tie(0) ;

    int n ;
    cin >> n ;

    string ans = "No" ;

    for(int i = 1; i < 10; i++)
        for(int j = 1; j < 10; j++)
        if(i*j == n)
        ans = "Yes" ;

    cout << ans ;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cstdio>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
 
typedef complex<int> P;
 
namespace std{
  bool operator<(const P & a,const P & b){
    if (a.real() != b.real())return a.real() < b.real();
    return a.imag() < b.imag();
  }
}
 
const double eps = 1e-10;
 
inline double myabs(P a){
  return sqrt(a.real()*a.real() + a.imag()*a.imag());
}

inline bool is_point_online(P a,P b,P c){
  return myabs(a-c) + myabs(b-c) < myabs(a-b) + eps;
}
 
inline int dot(P a,P b){
  return a.real()*b.real() + a.imag()*b.imag();
}
 
inline int cross(P a,P b){
  return a.real()*b.imag() - a.imag()*b.real();
}
 
inline bool is_intersected_ls(P a1,P a2,P b1,P b2){
  //if ( is_point_online(a1,a2,b1))return true;
  //if ( is_point_online(a1,a2,b2))return true;
  //if ( is_point_online(b1,b2,a1))return true;
  //if ( is_point_online(b1,b2,a2))return true;
  if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<-eps ) && //-EPS
    ( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-eps))return true;
  else return false;
}
 
inline double distance_ls_p(P a,P b,P c){
 if (dot(b-a,c-a) < eps)return myabs(c-a);
 if (dot(a-b,c-b) < eps)return myabs(c-b);
 //complex<double> aa(a.real(),a.imag());
 //complex<double> bb(b.real(),b.imag());
 //complex<double> cc(c.real(),c.imag());
 //return abs( cross(bb-aa,cc-aa))/abs(bb-aa);
 return abs( cross(b-a,c-a))/myabs(b-a);
}
 
inline double distance_ss_p(P a,P b,P c,P d){
 return min(  min( distance_ls_p(a,b,c),distance_ls_p(a,b,d)),min(distance_ls_p(c,d,a),distance_ls_p(c,d,b)));
}
 
main(){
  int n;
  static int cnt[101][101];
  while(cin>>n){
    rep(i,101)rep(j,101)cnt[i][j] = 0;
    vector<P> a(n),b(n);
    vector<pair<P,P> > all;
    double ans = 1e10;
    rep(i,n){
      int y,x,y2,x2;
      scanf("%d%d",&x,&y);
      cnt[y][x]++;
      a[i] = P(x,y);
      scanf("%d%d",&x2,&y2);
      cnt[y2][x2]++;
      b[i] = P(x2,y2);
    }
    rep(i,101){
      rep(j,101){
	if (cnt[i][j] > 1){ans = 0;goto end;}
      }
    }
    rep(i,n){
      REP(j,i+1,n)if (is_intersected_ls(a[i],b[i],a[j],b[j])){ans = 0;goto end;}
    }
    rep(i,n)all.push_back(make_pair(a[i],b[i]));
    sort(all.begin(),all.end());
    rep(i,all.size()){
      REP(j,i+1,all.size()){
	ans = min(ans,distance_ss_p(all[i].first,all[i].second,all[j].first,all[j].second));
      }
    }
  end:;
    printf("%.10lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2392
#pragma GCC optimize("O3")
#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>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

namespace patch{
    template <typename T> string to_string(const T& n){
        ostringstream stm;
        stm << n;
        return stm.str();
    }
}

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

    int n; cin>>n;

    vector<vector<int>> cnt(10, vector<int>(10, 0));
    for(int i=1; i<=n; i++){
        string A = patch::to_string(i);
        int Ah = A[0] - '0', At = A[A.size() - 1] - '0';
        cnt[Ah][At]++;
    }

    int ans = 0;
    for(int i=1; i<=n; i++){
        string A = patch::to_string(i);
        int Bt = A[0] - '0', Bh = A[A.size() - 1] - '0';
        ans += cnt[Bh][Bt];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
struct N{int p,l,r;};
N T[100000];
int n,d,k,c,r,i,j,m,o,D[100000];
void R(int r,int d){
  D[r]=d;
  if(~T[r].r)R(T[r].r,d);
  if(~T[r].l)R(T[r].l,d+1);
}
main(){
  for(scanf("%d",&n);j<n;++j)T[j].p=T[j].l=T[j].r=-1;
  for(;i++<n;)
    for(scanf("%d%d",&d,&k),j=0;j<k;r=c){
      scanf("%d",&c);
      T[c].p=d;
      j++?T[r].r=c:T[d].l=c;
    }
  for(;m<n;++m)if(!~T[m].p)R(m,0);
  for(;o<n;++o){
    printf("node %d: parent = %d, depth = %d, ",o,T[o].p,D[o]);
    printf(~T[o].p?~T[o].l?"internal node, [":"leaf, [":"root, [");
    for(i=0,j=T[o].l;~j;)printf(i++?", %d":"%d",j),j=T[j].r;
    printf("]\n");
  }
}

Measured memory_bytes: 7340
#include<bits/stdc++.h>
using namespace std;
vector<int>l(1e5 + 3, -100000000), r(1e5 + 3, 100000000), ans(1e5 + 3), odd(1e5 + 3, -1);
vector<vector<int> >g(1e5 + 3);
void dfs1(int v, int p){
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(to == p){
            continue;
        }
        dfs1(to, v);
        l[v] = max(l[v], l[to] - 1);
        r[v] = min(r[v], r[to] + 1);
        if(odd[to] != -1){
            if(odd[v] == -1){
                odd[v] = !odd[to];
            }
            if(odd[v] == odd[to]){
                cout << "No";
                exit(0);
            }
        }
    }
}
void dfs2(int v, int p){
    if(p != 0){
        l[v] = max(l[v], l[p] - 1);
        r[v] = min(r[v], r[p] + 1);
        if(odd[v] == -1){
            odd[v] = !odd[p];
        }
    }
    if(l[v] > r[v]){
        cout << "No";
        exit(0);
    }
    if(l[v] == r[v] && odd[v] != l[v] % 2){
        cout << "No";
        exit(0);
    }
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(to == p){
            continue;
        }
        dfs2(to, v);
    }
}
void get_ans(int v, int p){
    if(p == 0){
        ans[v] = l[v];
    }
    else{
        ans[v] = ans[p] - 1;
        if(ans[v] < l[v]){
            ans[v] += 2;
        }
    }
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(to != p){
            get_ans(to, v);
        }
    }
}
int main(){
    int n, k;
    cin >> n;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cin >> k;
    int root = -1;
    for(int i = 1; i <= k; i++){
        int v, p;
        cin >> v >> p;
        root = v;
        odd[v] = p % 2;
        l[v] = r[v] = p;
    }
    dfs1(root, 0);
    dfs2(root, 0);
    get_ans(root, 0);
    cout << "Yes\n";
    for(int i = 1; i <= n; i++){
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 16376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long A,V,B,W,T;
  cin >> A;
  cin >> V;
  cin >> B;
  cin >> W;
  cin >> T;
  if(T * (V - W) >= abs(A - B)){
   cout << "YES" << endl; 
  }else{
   cout << "NO" << endl;  
  }
 
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      long ans =0;
      long[] A = new long[N];
      long sum = 0;
      for(int i=0;i<N;i++){
        A[i] = sc.nextLong();
        sum+=A[i];
      }
      for(int i=0;i<N;i++){
        sum-=A[i];
        ans+=(A[i]%1000000007)*(sum%1000000007);
        ans%=(1000000007);
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 60472
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    vector<pll> data(n);
    rep(i,n){
        long x,l;
        cin >> x >> l;
        data.at(i).first = x+l;
        data.at(i).second = x-l;
    }
    sort(all(data));
    long pos = -1e10;
    int cnt = 0;
    rep(i,n){
        long s = data.at(i).second;
        long t = data.at(i).first;
        if(pos <= s){
            cnt++;
            pos = t;
        }
    }
    cout << cnt << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    int x,y,z,count = 0;
    cin >> x >> y >> z;

    int a = z;

    while(1){
        a += y + z;
        count++;
        if(a > x) break;
    }

    cout << count - 1 << endl;
    
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

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

		int a=0;
		int b=0;

		for(int i=0;i<4;i++){
			a += scan.nextInt();
		}

		for(int i=0;i<4;i++){
			b += scan.nextInt();
		}
	
		if(a>b){
			System.out.println(a);
		}
		else if(b>a){
			System.out.println(b);
		}
		else if(b==a){
			System.out.println(a);
		}
	
	}

}

Measured memory_bytes: 17300
from collections import deque

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

while 1:
    N, M = map(int, input().split())
    if N == M == 0:
        break
    MP = [input() for i in range(M)]
    cost = [[-1]*N for i in range(M)]
    cur = 0
    que = deque()
    for i in range(M):
        for j in range(N):
            if MP[i][j] == '&':
                que.append((i, j))
                cost[i][j] = 0

    while que:
        r, c = que.popleft()
        s = cost[r][c]
        a = MP[r][c]
        for dr, dc in dd:
            nr = r + dr; nc = c + dc
            if not 0 <= nr < M or not 0 <= nc < N or cost[nr][nc] != -1:
                continue
            b = MP[nr][nc]
            t = s + (a != '#' and b == '#')
            cost[nr][nc] = t
            if s == t:
                que.appendleft((nr, nc))
            else:
                que.append((nr, nc))

    ans = N*M
    for i in range(M):
        ans = min(ans, cost[i][0], cost[i][-1])
    for i in range(N):
        ans = min(ans, cost[0][i], cost[-1][i])
    print(ans)


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

using namespace std;

typedef long long ll;

const int maxn = 2e5 + 50;
const int mod = 1e9 + 7;

int x[maxn];

struct matrix{
	int a[3][3];

	matrix operator * (const matrix &other){
		matrix ret;
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				ret.a[i][j] = 0;
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				for (int k = 0; k < 3; k++)
					ret.a[i][j] = (ret.a[i][j] + 1ll * this->a[i][k] * other.a[k][j]) % mod;
		return ret;
	}
};

matrix base = {{
	{1, 0, 0},
	{0, 1, 0},
	{0, 0, 1}
}};

matrix power(matrix a, int b){
	if (b == 0)
		return base;
	matrix ret = power(a, b / 2);
	ret = ret * ret;
	if (b & 1)
		ret = ret * a;
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> x[i];
	x[0] = -1;
	x[m + 1] = n;
	matrix now = {{{1, 0, 0}, {0, 0, 0}, {0, 0, 0}}};
	matrix nex = {{{1, 1, 1}, {0, 1, 2}, {1, 1, 2}}};
	matrix spe = {{{1, 1, 1}, {0, 1, 2}, {0, 0, 1}}};
	for (int i = 1; i <= m + 1; i++){
		int dis = x[i] - x[i - 1] - 1;
		now = now * power(nex, dis);
		if (i <= m)
			now = now * spe;
	}
	cout << now.a[0][2] << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define int long long int
using namespace std;
#define MOD 1000000007
using namespace std;
 
 
int n,m,s[2001],t[2001],sumarray[2001]={0};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if(j){
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            } else {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3684
#include <math.h>
#include <stdio.h>
#include <stack>

using namespace std;

int main() {
    int n, tmp;
    scanf("%d", &n);

    int L[n], length = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);

        if (i == 0) {
            L[0] = tmp;
        } else {
            if (L[length] < tmp) {
                length++;
                L[length] = tmp;
            } else {
                for (int k = 0; k <= length; k++) {
                    if (L[k] >= tmp) {
                        L[k] = tmp;
                        break;
                    }
                }
            }
        }
    }

    printf("%d\n", length + 1);

    return 0;
}



Measured memory_bytes: 2956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		
		int count = 0;
		
		for(int i = 0; i <= A; i++) {
			for(int j = 0; j <= B; j++) {
				for(int k = 0; k <= C; k++) {
					if(500 * i + 100 * j + 50 * k == X) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21460
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main()
{
ll a,b,c;
string ans;

cin >> a>>b>>c;

if(a==b&&a==c)ans="Yes";
else ans="No";


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





Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 12 18:50:46 2019
KeyenceC
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = [0]*n
ok = False

if sum(a) >= sum(b):
    ok = True
    sum_fusoku = 0
    cnt_fusoku = 0
    larger = []
    for i in range(n):
        ab = a[i] - b[i]
        if ab < 0:
            sum_fusoku += -ab
            cnt_fusoku += 1
        else:
            larger.append(ab)
                
    larger.sort(reverse=True)
    cnt_large = 0
    for i in larger:
        if sum_fusoku <= 0:
            break
        sum_fusoku -= i
        cnt_large += 1

if ok == False:
    print(-1)
else:
    ans = cnt_fusoku + cnt_large
    print(ans)


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

int main(){
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
}

Measured memory_bytes: 19236
#include<iostream>
using namespace std;
int main(){
int a,b,c,qwertyuiopasdfghjklzxcvbnm;
cin>>a>>b>>c;
if(a>b){qwertyuiopasdfghjklzxcvbnm=a;a=b;b=qwertyuiopasdfghjklzxcvbnm;}
if(b>c){qwertyuiopasdfghjklzxcvbnm=b;b=c;c=qwertyuiopasdfghjklzxcvbnm;}
if(a>b){qwertyuiopasdfghjklzxcvbnm=a;a=b;b=qwertyuiopasdfghjklzxcvbnm;}
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}


Measured memory_bytes: 3112
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

	int dp[400];
signed main(void) {
	string s;
	cin >> s;
	int n = s.size();
	reverse(s.begin(), s.end());
	int m = 2019;
	vector<int>cnt(m, 0);

	int x = 1, tot = 0, ans = 0;

	rep(i, n) {
		cnt[tot]++;
		tot += (s[i] - '0')*x;
		tot %= m;
		ans += cnt[tot];
		x = x*10 % m;

	}
	print(ans);
	
}

Measured memory_bytes: 3692
N=int(input())
end_A_only=0
start_B_only=0
both=0
count=0
for i in range(N):
    s=input()
    count+=s.count("AB")
    if s[-1]=="A" and s[0] =="B":
        both+=1
    elif s[-1]=="A":
        end_A_only+=1
    elif s[0]=="B":
        start_B_only+=1
    else:
        pass

if both==0:
    count+=min(end_A_only,start_B_only)

else:
    if end_A_only==0 and start_B_only==0:
        count+=both-1
    elif end_A_only==0 or start_B_only==0:
        count+=both
    else:
        count+=both+1
        count+=min(end_A_only-1,start_B_only-1)


print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    ll i,j,k,n,m,d,p,q,ans=0;
    cin  >> n >> d;
    fori(n){
        cin >> p >> q;
        if(p*p + q*q <= d*d){
            ans++;
        }
    }
    cout << ans <<"\n";
} 

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

int main(){
  int N,i,a, k;
  string s;
  cin >> N;
  vector<tuple<string, int, int>> data;
  rep0(i, N){
    cin >> s >> a;
    data.push_back(make_tuple(s, -a, i+1));
  }
  sort(data.begin(), data.end());
  rep0(i, N){
    tie(s, a, k) = data[i];
    cout << k << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;



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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
 
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n;cin>>n;ll curpow=1,ans=1;
    while(n!=1)
    {
        n/=2;
        ans+=2*curpow;
        curpow*=2;
        
    }
    cout<<ans<<endl;
    
    
    return 0;
}












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

int main(){
  int n,w,h,s,t;
  int mas[101][101];
  while(cin >> n,n){
    int maxi = 0;
    memset(mas,0,sizeof(mas));
    cin >> w >> h;
    for(int i=0;i<n;i++){
      int x,y; cin >> x >> y; mas[y-1][x-1] = 1;
    }
    cin >> s >> t;
    for(int i=0;i<h-t+1;i++){
      for(int j=0;j<w-s+1;j++){
	int sum = 0;
	for(int k=i;k<t+i;k++){
	  for(int l=j;l<s+j;l++){
	    if(mas[k][l] == 1) sum++;
	  }
	}
	maxi = max(sum,maxi);
      }
    }
    cout << maxi << endl;
  }
} 

Measured memory_bytes: 1204
#include <stdio.h>

int n;

int main(){
  int i, j;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      printf("%d ", __builtin_ctz(i^j) + 1);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 384
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    dict1 = {}
    dict2 = {}

    for i in range(n):
        a1 = a[i] + i + 1
        a2 = i + 1 - a[i]
        if a1 in dict1:
            dict1[a1] += 1
        else:
            dict1[a1] = 1
        if a2 in dict2:
            dict2[a2] += 1
        else:
            dict2[a2] = 1
    ans = 0
    for i in dict1:
        if i in dict2:
            ans += dict1[i]*dict2[i]
    print(ans)
            
resolve()

Measured memory_bytes: 145560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int temp = 0;
        for (int i = 9; i >= 0; i--) {
            if (n % i == 0) {
                temp = n / i;
                break;
            }
        }
        for (int i = 9; i >= 0; i--) {
            if (temp % i == 0) {
                temp = temp / i;
                break;
            }
        }
        if (temp == 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define PI 4*atan(1)
#define INF 2 * 1e9

typedef long long ll;

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

int main(){
  int V, E;
  cin >> V >> E;
  vector<vector<int>> d(V, vector<int>(V, INF));
  for(int i = 0; i < V; i++)d[i][i] = 0;
  for(int i = 0; i < E; i++){
    int s, t, _d;
    cin >> s >> t >> _d;
    d[s][t] = _d;
  }
  for(int k = 0; k < V; k++){
    for(int i = 0; i < V; i++){
      for(int j = 0; j < V; j++)if(d[i][k] != INF && d[k][j] != INF)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
  for(int i = 0; i < V; i++)if(d[i][i] < 0){
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  for(int i = 0; i < V; i++){
    for(int j = 0; j < V; j++){
      if(d[i][j] == INF)cout << "INF";
      else cout << d[i][j];
      if(j != V - 1)cout << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 3196
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [list(map(int,input().split())) for _ in range(m)]
ans = min(a) + min(b)

for i in range(m):
	ans = min(a[x[i][0]-1] + b[x[i][1]-1] - x[i][2],ans)
print(ans)


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

int main(){
    ll x; cin >> x;
    ll count = 0;
    count = (x / 11) * 2;
    x %= 11;
    // cout << x << endl;
    if(x > 6) count += 2;
    else if( 6 >= x && x > 0) count += 1;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
MOD = 1000000007
chars = ['A', 'C', 'G', 'T']

def seq_gen():
    return ((c1, c2, c3) for c3 in chars for c2 in chars for c1 in chars)

tbl = {}
for i in range(N+1):
    for c1, c2, c3 in seq_gen():
        tbl[(i, c1, c2, c3)] = 0

tbl[(0,'T','T','T')] = 1

for i in range(N):
    for c1, c2, c3 in seq_gen():
        if tbl[(i, c1, c2, c3)] == 0:
            continue
        for a in chars:
            ng_cond =   (a + c1 + c2 == 'AGC' or
                        a + c1 + c2 == 'ACG' or
                        a + c1 + c2 == 'GAC' or
                        a + c2 + c3 == 'AGC' or
                        a + c1 + c3 == 'AGC')
            if not ng_cond:
                tbl[(i+1, a, c1, c2)] += tbl[(i, c1, c2, c3)]
                tbl[(i+1, a, c1, c2)] %= MOD

ans = 0
for c1, c2, c3 in seq_gen():
    ans += tbl[(N, c1, c2, c3)]
    ans %= MOD

print(ans)


Measured memory_bytes: 4216
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
// const double long rf=14;
int i,j,k;

void Anon_mouS(){
	// string s;
    int n;
    cin>>n;
    vi a(n);
    for(i=0;i<n;i++)cin>>a[i];
    map<int,int> m;
    for(i=0;i<n;i++)m[a[i]]++;
    vector <pii> pr;
    int tot=0;
    for(auto x:m){
        pr.pb(x);
        tot+=x.S*(x.S-1)/2;
    }
    vector <pii> ans;
    for(pii x:pr){
        ans.pb(mp(x.F,tot-x.S+1));
    }
    for(auto x:ans){
        m[x.F]=x.S;
    }
    for(i=0;i<n;i++)cout<<m[a[i]]<<endl;
}

int32_t main(){
	// func();
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 15216