akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define LL long long
#define PLL pair<LL, LL>
#define LD long double
#define VI vector<int>
#define VPII vector<PII>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define FOR(a,s,d) for (int a = (s); a <= (int)(d); ++a)
#define FORD(a,s,d) for (int a = (s); a >= (int)(d); --a)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RE(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define siz(x) ((int)x.size())
#define Sim template <class s
Sim, class d> ostream & operator<<(ostream &os, pair<s,d> x){return os << "<" << x.F << ", " <<
  x.S << "> ";}
Sim> auto operator<<(ostream &os, s x) -> typename enable_if<!is_same<s,string>::value,
  decltype(x.begin(), os)>::type
{ int o = 0; os << "{"; for (auto c : x) {if(o++) os << ", "; os << c;}return os << "} ";}
void dor() {cerr << endl;}
Sim, class ...t> void dor(s x, t...y) {cerr << x << " "; dor(y...);}
#ifdef DEB
#define debug(c...) dor(__FUNCTION__, ":", __LINE__, ": ", c)
#else
#define debug(...)
#endif
const int M = 128;
const LL inf = 1e18;

int n;
vector<int> V[M], V2[M];
LL res = inf, leaf = inf;
vector<PII> E;

void DFS(int v, int p)
{
  for (auto x : V[v])
  {
    if (x != p)
    {
      V2[v].PB(x);
      DFS(x, v);
    }
  }
}

void makeGraph(int a, int b)
{
  for (int i = 1; i <= n; i++)
  {
    V2[i].clear();
  }
  DFS(a, b);
  if (b != 0)
  {
    DFS(b, a);
  }
}

void solve(vector<int> X)
{
  LL depth = 1;
  LL curr = siz(X);
  while (true)
  {
    LL maxi = 0;
    vector<int> XX;
    for (auto x : X)
    {
      maxi = max(maxi, (LL)siz(V2[x]));
      for (auto xx : V2[x])
      {
        XX.PB(xx);
      }
    }
    if (maxi == 0)
    {
      break;
    }
    depth++;
    if ((LD)maxi * curr > inf)
    {
      return;
    }
    curr = maxi * curr;
    swap(X, XX);
  }
  //debug(depth, curr);
  if (res > depth || (res == depth && leaf > curr))
  {
    res = depth;
    leaf = curr;
  }
}

int main()
{
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  scanf("%d", &n);
  for (int i = 2; i <= n; i++)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    V[a].PB(b);
    V[b].PB(a);
    E.PB(MP(a, b));
  }
  for (int i = 1; i <= n; i++)
  {
    makeGraph(i, 0);
    vector<int> X;
    X.PB(i);
    solve(X);
  }
  for (auto p : E)
  {
    makeGraph(p.F, p.S);
    vector<int> X;
    X.PB(p.F);
    X.PB(p.S);
    //debug(X);
    solve(X);
  }
  printf("%lld %lld\n", res, leaf);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
long long a,b;
 
long long xorsum(long long a, long long b){
    
    long long xor1toa;
    long long xor1tob;
    
    a--;
    if (a%4==0) xor1toa=a; else
        if (a%4==1) xor1toa=1; else
            if (a%4==2) xor1toa=a+1;
                else xor1toa=0;
                
    if (b%4==0) xor1tob=b; else
        if (b%4==1) xor1tob=1; else
            if (b%4==2) xor1tob=b+1;
                else xor1tob=0;
    
    return xor1tob^xor1toa;
}
 
int main(){
    cin>>a>>b;
    cout<<xorsum(a,b);
}

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

#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)

constexpr int MaxLen = 1000;
int Memo[MaxLen+1][MaxLen+1];
int main() {
	std::string line;
	const auto nextline = [&line](){
		std::getline(std::cin, line);
	};
	nextline();
	const int NQ = std::stoi(line);
	For(i, 0, NQ) {
		std::string s0, s1;
		std::getline(std::cin, s0);
		std::getline(std::cin, s1);

		int len0 = s0.length(),
			len1 = s1.length();
		if(len0 < len1) {
			std::swap(s0, s1);
			std::swap(len0, len1);
		}
		ForLE(j, 0, len0)
			Memo[j][0] = 0;
		ForLE(j, 0, len1)
			Memo[0][j] = 0;

		ForLE(j, 1, len1) {
			ForLE(k, 1, len0) {
				int res = std::max(
								Memo[k][j-1],
								Memo[k-1][j]
							);
				if(s0[k-1] == s1[j-1])
					res = std::max(Memo[k-1][j-1] + 1, res);
				Memo[k][j] = res;
			}
		}
		std::cout << Memo[len0][len1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 7036
/* Aditya0412 */
    #include <bits/stdc++.h>
    using namespace std; 
    #define int long long 
    #define pb push_back 
    #define vii vector < int > 
    #define pii pair < int , int >
    #define fi first
    #define all(a)      (a).begin(),(a).end()
    #define si(x)       (int)((x).size())
    #define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
    #define se second 
    #define endl        '\n'
    #define f(i,a,b)    for(int i=a;i<b;i++)
    #define mem(a,x)          memset(a,x,sizeof(a))
    #define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    // const int  mod=998244353;
    const int  mod = 1000000000+7;
    const int  N=1000000+6;
    #define M_PI           3.14159265358979323846

    // int x2[]={+1,-1,+0,+0};
    // int y2[]={+0,+0,+1,-1};
    // int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
    // int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
    // int x2[]={-2,-2,-1,-1,+1,+1,+2,+2};
    // int y2[]={-1,+1,-2,+2,-2,+2,-1,+1};

    // === Debug macro starts here ===

    int recur_depth = 0;
    #ifdef DEBUG
    #define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
    #else
    #define dbg(x)
    #endif
    template<typename Ostream, typename Cont>
    typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
        os<<"[";
        for(auto& x:v){os<<x<<", ";}
        return os<<"]";
    }
    template<typename Ostream, typename ...Ts>
    Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
        return os<<"{"<<p.first<<", "<<p.second<<"}";
    }

    // === Debug macro ends here ===

    main() 
    {
        fastIO;
        string s;cin>>s;
        int n=si(s);
        n--;
        if(s[n]=='s')
        s+="es";
        else
        {
            s+="s";
        }
        cout<<s;
        
    } 

Measured memory_bytes: 3656
H,W=map(int,input().split())
lsa=[]
#lsacom=[]
dcomi={}
dcomj={}
for i in range(H):
    lsa.append(input())
for i in range(H):
    for j in range(W):
        if lsa[i][j]=="#":
            break
    else:
        dcomi[i]=1
for j in range(W):
    for i in range(H):
        if lsa[i][j]=="#":
            break
    else:
        dcomj[j]=1
for i in range(H):
    for j in range(W):
        if (not i in dcomi) and (not j in dcomj):
            print(lsa[i][j],end="")
    if not i+1 in dcomi:
        print()


Measured memory_bytes: 4468
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var m=arr.shift()-0;
   if(m==0)break;
   var xy=[];
   while(m--)xy.push(arr.shift().split(" ").map(Number));
   var obj={};
   var n=arr.shift()-0;
   while(n--){
      var ary=arr.shift().split(" ").map(Number);
      obj[ary[0]+","+ary[1]]=[ary[0],ary[1]];
   }
   for(var k in obj){
      var dx=obj[k][0]-xy[0][0];
      var dy=obj[k][1]-xy[0][1];
      var flag=xy.every(function(v){
         return (obj.hasOwnProperty((v[0]+dx)+","+(v[1]+dy)));
      });
      if(flag){console.log(dx,dy);break;}
   }
}

Measured memory_bytes: 21952
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int res = n%10;
  if(res == 3) {
  	cout<<"bon";
  } else if(res == 0 || res ==1 || res == 6|| res ==8) {
  	cout<<"pon";
  } else {
  	cout<<"hon";
  }
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> P(n+1);
    for(int i = 0; i < n; i++) cin >> P[i];
    P[n] = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(P[i] == i + 1){
            ans++;
            if(P[i+1] == i + 2) i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    cin >> a;
    int ans = -1;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] >= L) ans = i + 1;
    }
    if (ans == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for (int i = 1; i < ans; i++) cout << i << endl;
    for (int i = N - 1; i >= ans; i--) cout << i << endl;
}


Measured memory_bytes: 1664
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    int x,a,b;
    cin>>x>>a>>b;
    
    if(abs(x-a)<abs(x-b)) cout<<"A"<<endl;
    else cout<<"B"<<endl;
}



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

int main()
{
    int a, b ;
    cin >> a >> b ;

    for (int i = 0; i < 1250; i++)
    {
        if(a==(int)((i+1)*0.08)&&b==(int)((i+1)*0.1))
        {
            cout << i+1 << endl ;
            return 0 ;
        }
    }
    cout << -1 << endl ;
    
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    REP(i,s.length()) ans += (s[i] != t[i]);
    cout << ans << endl;

    return 0;
}


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

//#define endl "\n"
#define ll long long int
#define f(i,n) for(ll i=0;i<n;i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define MOD 1000000007

void yes(){
    cout << "YES" << endl;
}

void no(){
    cout << "NO" << endl;
}

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

    ll n,k;
    cin >> n >> k;

    ll arr[n];
    ll brr[n];

    f(i,n)
        cin >> arr[i];
    f(i,n)
        brr[i]=-1;

    ll cnt=0;
    ll t=1;
    ll diff=0;
    ll prev=0;
    ll thr=0;

    while(1)
    {
        if(brr[t-1]==-1)
        {
            ll x = arr[t-1];
            brr[t-1]=cnt;
            cnt++;

            prev=t;
            t=x;
        }
        else
        {
            thr = brr[t-1];
            diff = brr[prev-1]-brr[t-1]+1;
            break;
        }
    }

    
    if(k>thr+diff)
    {
        ll left = k - thr;
        ll d = left/diff;

        k = left - d*(diff);
        k+=thr;
    }

    t=1;
    ll cntt=0;
    ll xx=0;

    if(k==0 && thr==0)
    {
        cout << "1" << endl;
        exit(0);
    }
   
    while(cntt<k)
    {
        xx = arr[t-1];
        cntt++;

        t=xx;
    }

    cout << xx << endl;

    return 0;
}


Measured memory_bytes: 6788
hisi=0
tyou=0
while True:
    try:
        a,b,c=map(int,input().split(","))
        if a**2+b**2==c**2:
            tyou +=1
        elif a==b:
            hisi +=1
    except:
        print(tyou)
        print(hisi)
        break



Measured memory_bytes: 5592
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli x,a;
	cin>>x>>a;

	if(x<a)cout<<0<<endl;
	else cout<<10<<endl;


	return 0;
}


Measured memory_bytes: 256
n = int(input())

cnt = 0
fitn = 0
while(fitn < n):
    cnt += 1
    fitn += cnt
    
    if(fitn > n):
        print("No")
        exit()


numofrow = cnt + 1
ans = []
for i in range(numofrow):
    ans.append([])

idx = 1
for i in range(numofrow):
    for j in range(i+1,numofrow):
        ans[i].append(idx)
        ans[j].append(idx)
        idx += 1


print("Yes")
print(numofrow)
for i in range(numofrow):
    print(cnt," ".join(map(str,ans[i])))

Measured memory_bytes: 9068
n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int INFTY=2e9+1;

int main() {
    int x, y, ans;
    scanf("%d%d", &x, &y);
    ans=INFTY;
    if(x<=y) ans=min(ans, y-x);
    if(-x<=y) ans=min(ans, y+x+1);
    if(x<=-y) ans=min(ans, -y-x+1);
    if(-x<=-y) ans=min(ans, -y+x+2);
    printf("%d\n", ans);
    return 0;
}

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

int k;
string a;
int main()
{
	int i, t;
	cin >> a >> k;
	for (i = 0; i < a.size() - 1; i++) {
		t = ('z' + 1 - a[i]) % 26;
		if (t <= k) k -= t, a[i] = 'a';
	}
    a[a.size() - 1] = (a[a.size() - 1] - 'a' + k) % 26 + 'a';
    cout << a << endl;
    return 0;
}

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

using namespace std;

const int64_t INF = 1LL << 60;

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  int64_t T;
  cin >> N >> T;
  vector<int64_t> A, B, C;
  for (int i = 0; i < N; i++) {
    int64_t a, b;
    cin >> a >> b;
    if (a == 0) {
      C.emplace_back(b + 1);
    } else {
      A.emplace_back(a);
      B.emplace_back(b);
    }
  }
  vector<int> idx(A.size());
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(),
       [&](int a, int b) { return A[b] * (B[a] + 1) < A[a] * (B[b] + 1); });
  vector<int64_t> dp(31, T + 1);
  dp[0] = 0;
  for (int i : idx) {
    for (int j = (int)dp.size() - 2; j > -1; j--) {
      if (dp[j] > T) continue;
      chmin(dp[j + 1], (A[i] + 1) * (dp[j] + 1) + B[i]);
    }
  }
  sort(C.begin(), C.end());
  for (int i = 0; i < (int)C.size() - 1; i++) {
    C[i + 1] += C[i];
  }
  int res = 0;
  for (int i = 0; i < (int)dp.size(); i++) {
    if (dp[i] > T) continue;
    int p = upper_bound(C.begin(), C.end(), T - dp[i]) - C.begin();
    res = max(res, i + p);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 4324
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int a, b;
    cin >> a >> b;
    cout << ((a*b) % 2 == 1 ? "Odd" : "Even") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }
  
  
  
  
  
  
  const int mod = 1000000007 ;//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
  
  
  
  
  
  
  int main() {
   ll n ;cin>> n ;
   vector<ll> A(n) ; rep(i,n) cin>>A[i] ;
   vector<map<ll,ll>> so(n) ;
   rep(i,n){
     map<ll,ll> k= factor(A[i]) ;
     so[i]=k ;
   }
  map<ll,ll> dai ;
  rep(i,n){
    for(auto p :so[i]){
      dai[p.first]=max(dai[p.first],p.second) ;
    }
  }
  
  
  mint lcm=1 ;
  for(auto p :dai){
    rep(i,p.second){
      lcm*=p.first ;
    }
  }
  mint ans= 0;
  rep(i,n){
   ans+= lcm/A[i] ; 
  }
    cout<<ans<<endl ;
  return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <unordered_set>
#include <numeric>
using namespace std;

const int MOD = 1e9 + 7;
#define ll long long


int main()
{
	vector<int>arr(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> arr[i];
	}

	sort(arr.begin(), arr.end());
	cout << arr[0] + arr[1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010;
ll a[N],n,k,pos[N],neg[N];
ll negnum,zernum,posnum,negtot,zertot,postot;
bool cmp(ll x,ll y){
	return x<y;
}
ll negmin(ll x){
	ll ans=0;
	for(ll i=1;i<=negnum;++i){
		ll l=1,r=posnum,mid;
		while(l<=r){
			mid=(l+r)/2;
			if(pos[mid]*neg[i]>=x) r=mid-1;
			else l=mid+1;
		}
		ans+=r;
	}
	return ans;
}
ll posmin(ll x){
	ll ans=0;
	for(ll i=2;i<=negnum;++i){
		ll l=1,r=i-1,mid;
		while(l<=r){
			mid=(l+r)/2;
			if(neg[mid]*neg[i]>=x) r=mid-1;
			else l=mid+1;
		}
		ans+=r;
	}
	for(ll i=2;i<=posnum;++i){
		ll l=1,r=i-1,mid;
		while(l<=r){
			mid=(l+r)/2;
			if(pos[mid]*pos[i]>=x) r=mid-1;
			else l=mid+1;
		}
		ans+=r;
	}
	return ans;
}
void bsneg(ll x){
	ll l=1,r=neg[negnum]*pos[posnum],mid;
	while(l<=r){
		mid=(l+r)/2;
		if(negmin(mid)<x) l=mid+1;
		else r=mid-1;
	}
	printf("-%lld\n",r);
}
void bspos(ll x){
	ll l=1,r=max(pos[posnum]*pos[posnum-1],neg[negnum]*neg[negnum-1]),mid;
	while(l<=r){
		mid=(l+r)/2;
		if(posmin(mid)<x) l=mid+1;
		else r=mid-1;
	}
	printf("%lld\n",r);
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(ll i=1;i<=n;++i) scanf("%lld",&a[i]);
	sort(a+1,a+1+n,cmp);
	negnum=zernum=posnum=0;
	for(ll i=1;i<=n;++i){
		if(a[i]<0) ++negnum;
		else if(a[i]>0) ++posnum;
		else ++zernum;
	}
	negtot=negnum*posnum;
	zertot=zernum*(posnum+negnum)+zernum*(zernum-1)/2;
	postot=(((n-1)*n)>>1)-zertot-negtot;
	//printf("%lld %lld %lld %lld %lld %lld\n",negnum,zernum,posnum,negtot,zertot,postot);
	for(ll i=1;i<=posnum;++i) pos[i]=a[negnum+zernum+i];
	for(ll i=1;i<=negnum;++i) neg[i]=-a[negnum+1-i];
	//for(ll i=1;i<=posnum;++i) printf("%lld ",pos[i]);
	//for(ll i=1;i<=negnum;++i) printf("%lld ",neg[i]);
	if(k<=negtot) bsneg(negtot+1-k);
	else if(k<=negtot+zertot) printf("0");
	else bspos(k-negtot-zertot);
	return 0;
}

Measured memory_bytes: 4224
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 2000;
const int MOD = (int)1e9 + 7;

int n, fact[N + 1], size[N], dp[N][3][N];
std::vector<int> children[N];

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

void dfs(int u)
{
    static int tmp[3][N];

    size[u] = 1;
    dp[u][0][0] = 1;
    for (auto v : children[u]) {
        dfs(v);
        int ns = size[u] + size[v];
        for (int t = 0; t < 3; ++ t) {
            memset(tmp[t], 0, sizeof(int) * ns);
        }
        for (int t = 0; t < 3; ++ t) {
            for (int x = 0; x < size[u]; ++ x) {
                if (!dp[u][t][x]) {
                    continue;
                }
                for (int y = 0; y < size[v]; ++ y) {
                    for (int tt = 0; tt < 3; ++ tt) {
                        if (!dp[v][tt][y]) {
                            continue;
                        }
                        auto pd = 1LL * dp[u][t][x] * dp[v][tt][y] % MOD;
                        if (t < 2 && tt < 2) {
                            update(tmp[t + 1][x + y + 1], pd);
                        }
                        if (tt == 0) {
                            pd = 500000004LL * pd % MOD;
                        }
                        update(tmp[t][x + y], pd);
                    }
                }
            }
        }
        for (int t = 0; t < 3; ++ t) {
            memcpy(dp[u][t], tmp[t], sizeof(int) * ns);
        }
        size[u] += size[v];
    }
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("A.in", "r", stdin);
#endif
    scanf("%d", &n);
    fact[0] = 1;
    for (int i = 1; i <= n; ++ i) {
        fact[i] = 2LL * fact[i - 1] * i % MOD;
    }
    for (int i = 1, p; i < n; ++ i) {
        scanf("%d", &p);
        children[p - 1].push_back(i);
    }
    memset(dp, 0, sizeof(dp));
    dfs(0);
    int result = 0;
    for (int i = 0; i < n; ++ i) {
        int add = 1LL * fact[n - i] * (500000004LL * dp[0][0][i] % MOD + dp[0][1][i] + dp[0][2][i]) % MOD;
        if (i & 1) {
            add = MOD - add;
        }
        update(result, add);
    }
    printf("%d\n", result);
}


Measured memory_bytes: 47616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<ll> que;  
    rep(i, 0, n) {
        ll a;
        cin >> a;
        que.push(a);
    }

    rep(i, 0, m) {
        ll val = que.top();
        que.pop();
        que.push(val/2);
    }

    ll ans = 0;
    rep(i, 0, n) {
        ans += que.top();
        que.pop();
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll ans=INF;
ll N,A,B,C;
vector<int> l(10);

void dfs(int a, int b, int c, int i, ll now){
    if(i==N){
        if(a==0 || b==0 || c==0){
            return;
        }else{
            ans=min(ans,now+abs(A-a)+abs(B-b)+abs(C-c));
            return;
        }
    }
    //cout<<now<<" ";
    for(int j=0;j<4;j++){
        if(j==0){
            if(a!=0){
                dfs(a+l[i],b,c,i+1,now+10);
            }else{
                dfs(a+l[i],b,c,i+1,now);
            }
        }else if(j==1){
            if(b!=0){
                dfs(a,b+l[i],c,i+1,now+10);
            }else{
                dfs(a,b+l[i],c,i+1,now);
            }
        }else if(j==2){
            if(c!=0){
                dfs(a,b,c+l[i],i+1,now+10);
            }else{
                dfs(a,b,c+l[i],i+1,now);
            }
        }else{
            dfs(a,b,c,i+1,now);
        }
    }
}

int main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++) cin>>l[i];
    dfs(0,0,0,0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        int n = sc.nextInt();
        int[] w = new int[n];
        for(int i=0;i<n;i++) w[i] = sc.nextInt();
        int sum = 0;
        for(int c:w) sum += c;
        int pre = w[0], ans = Math.abs(sum-2*pre);
        for(int i=1;i<n-1;i++){
            pre += w[i];
            ans = Math.min(ans,Math.abs(sum-2*pre));
        }
        System.out.println(ans);
    }
}



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

const int N = 100100;

int n, W; 
long long w[105], v[105], dp[105][N];

int main()
{
	cin >> n >> W;
	for (int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= W; j++)
		{
			if (w[i] <= j) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	cout << dp[n][W];
}

Measured memory_bytes: 79360
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

L,A,B,MOD = map(int,read().split())

def geom_seq_sum(r,n,MOD):
    """
    return \sum_{i=0}^{n-1} r^i mod MOD
    """
    if r == 1:
        return n%MOD
    r1 = r-1
    return ((pow(r,n,r1*MOD)-1)//r1)% MOD

def geom_seq_sum_1(r,n,MOD):
    """
    return \sum_{i=0}^{n-1} ir^i mod MOD
    """
    if r == 1:
        return n*(n-1)//2%MOD
    r1 = r-1
    x = pow(r,n,r1*r1*MOD)
    return (-(x-1)//r1 + (n-1)*x + 1)//r1 % MOD

S = 0
for d in range(1,20):
    # d桁の最初、最後、項数
    lower = 10**(d-1)
    upper = 10**d-1
    # lower <= A+nB <= upper
    nlower = (lower-A+B-1)//B
    nupper = (upper-A)//B
    if nlower < 0:
        nlower = 0
    if nupper >=L:
        nupper = L-1
    if nlower > nupper:
        continue
    items = nupper - nlower + 1
    r = (10**d) % MOD
    last = A+B*nupper
    x = last * geom_seq_sum(r,items,MOD)
    x -= B * geom_seq_sum_1(r,items,MOD)
    length = d*items
    S *= pow(10,length,MOD); S += x
    S %= MOD

print(S)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int a[] = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = Integer.parseInt(str[i]);
		}
		System.out.println(a[0] * a[1] / 2);
	}
}

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

#define F first
#define S second
#define MP make_pair

using namespace std;
using pii = pair<long long int, long long int>;

const int N = 3e3+100;

long long int dp[N][N];

pair<long long int, long long int> p[N][N];

bool farg(pii p1, pii p2) {
    return p1.F-p2.F==p1.S-p2.S;
}

int main () {
    memset(p,-1,sizeof(p));
    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;
                p[i][j]=make_pair(i-1,j-1);
            }
            if(dp[i][j]<dp[i-1][j]) {
                dp[i][j]=dp[i-1][j];
                p[i][j]=make_pair(i-1,j);
            }
            if(dp[i][j]<dp[i][j-1]) {
                dp[i][j]=dp[i][j-1];
                p[i][j]=make_pair(i,j-1);
            }
        }
    }
    string ans;
    ans.clear();
    pair<long long int, long long int> now=make_pair(s.size(),t.size());
    while(now.F!=0&&now.S!=0) {
        if(p[now.F][now.S].F==-1)break;
        if(farg(now,p[now.F][now.S])) {
            ans+=s[now.F-1];
        }
        now=p[now.F][now.S];
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
}


Measured memory_bytes: 223488
r1,c1,r2,c2=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p=10**9+7
N=2*10**6+10
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print((cmb(r2+1+c2+1,c2+1,p)-cmb(r1+c2+1,c2+1,p)-cmb(r2+1+c1,c1,p)+cmb(r1+c1,c1,p))%p)

Measured memory_bytes: 132908
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>

using namespace std;

long long a[100010],b[100010],c[100010],f[100010][10];

int main(void)
{
    //freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	f[1][1] = a[1];
	f[1][2] = b[1];
	f[1][3] = c[1];
	
	for(int i=2;i<=n;i++)
	{
		f[i][1] = max(f[i-1][2]+a[i],f[i-1][3]+a[i]);
		f[i][2] = max(f[i-1][1]+b[i],f[i-1][3]+b[i]);
		f[i][3] = max(f[i-1][1]+c[i],f[i-1][2]+c[i]);
	}
	cout << max(f[n][1],max(f[n][2],f[n][3])) << endl;
	return 0;
}













Measured memory_bytes: 10368
#include<stdio.h>
int main(){
	int a,b,x;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op=='+'){
			x=a+b;
		}else if(op=='-'){
			x=a-b;
		}else if(op=='*'){
			x=a*b;
		}else if(op=='/'){
			x=a/b;
		}else{
			break;
		}

	
		printf("%d\n",x);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

 
int main(){
   int n ; cin>>n ;
   cout<< 0 <<endl ;
   string s ; cin >>s ;
   if(s=="Vacant") return 0 ;
   int l =0 ; int r= n ;
   while(1){
     int m = (r+l) /2 ;
     cout<< m<< endl ;
     string ss ;cin>>ss ;
     if(ss=="Vacant" ) break ;
     bool ok= (s==ss) ;
     int a = m%2 ;
     if(ok==a) r=m ;
    else l= m+1 ;

   }
 return 0 ;
}


Measured memory_bytes: 3852
#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>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int n, m;

int dijkstra(vector<vector<P>> &G){
    vector<vector<int>> dist(n, vector<int>(2, 1e9));
    priority_queue<T, vector<T>, greater<T>> que;
    dist[0][0] = 0;
    que.emplace(0, 0, 0);

    while(!que.empty()){
        int ccost, cv, cused;
        tie(ccost, cv, cused) = que.top();
        que.pop();

        if(dist[cv][cused] < ccost) continue;

        for(auto x : G[cv]){
            int nv, ncost;
            tie(nv, ncost) = x;
            
            if(dist[cv][cused] + ncost < dist[nv][cused]){
                dist[nv][cused] = dist[cv][cused] + ncost;
                que.emplace(dist[nv][cused], nv, cused);
            }

            if(cused) continue;

            for(auto y : G[nv]){
                int nnv, nncost;
                tie(nnv, nncost) = y;

                if(dist[cv][0] < dist[nnv][1]){
                    dist[nnv][1] = dist[cv][0];
                    que.emplace(dist[nnv][1], nnv, 1);
                }
            }
        }
    }

    return min(dist[n-1][0], dist[n-1][1]);
}

int main(){
    while(1){
        cin>>n>>m;
        if(n == 0) return 0;

        vector<vector<P>> G(n);
        for(int i=0; i<m; i++){
            int a, b, c; cin>>a>>b>>c;
            a--, b--;
            G[a].emplace_back(b, c);
            G[b].emplace_back(a, c);
        }

        cout << dijkstra(G) << endl;
    }
}


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

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> c(N), t(N);
    for(int i=0; i<N; i++) cin >> c[i] >> t[i];
    int ans = 1000000;
    for(int i=0; i<N; i++){
        if(t[i] <= T){
            ans = min(ans, c[i]);
        }
    }
    if(ans == 1000000)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))



inline int sub(vi& d){
    if (d[0]%2 || d[1]%2 || d[2]%2) return 0;
    if (d[0] == d[1] && d[1] == d[2]) return -1;
    vector<int> e = d;
    d[0] = (e[1] + e[2])/2;
    d[1] = (e[2] + e[0])/2;
    d[2] = (e[0] + e[1])/2;
    return 1;
}

ll solve(int a,int b,int c){
    vector<int> d {a,b,c};
    int cnt = 0;
    while (true) {
        // cerr << d << cnt << endl;
        switch (sub(d)) {
            case -1: return -1;
            case 1: ++cnt; break;
            case 0: return cnt;
        }
    }
}

int main() {
    int a,b,c; cin>>a>>b>>c;
    cout<<solve(a,b,c)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,i,d,c,s,j;

        scanf("%d",&n);

        d=n/7;c=n/4;
        for(i=0;i<=c;i++){
                for(j=0;j<=d;j++){
                        if((i*4+j*7)==n) {
                                printf("Yes\n");
                                return 0;
                        }
                }
        }

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	string s[5];
	for (int i = 0; i < 3; i++)cin >> s[i];
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))


N,K = input_multiple_number()
A = input_multiple_number_as_list()

isVisit = [-1]*N

orgK = K
now = 1
cnt = 0
looper = 0
while K > 0:
	if isVisit[now-1] >= 0:
		looper = cnt - isVisit[now-1]
		break

	isVisit[now-1] = cnt
	now = A[now-1]
	cnt += 1

K -= cnt
if K <= 0:
	now = 1
	K = orgK
else:
	K %= looper

for i in range(K):
	now = A[now-1]

print(now)


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

inline ll fun(ll n) {
    return ((n * (n-1)) >> 1LL);
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n;
    cin >> n;
    vi v(n);
    unordered_map<int,ll> m;
    rep(i, 0, n) {
        cin >> v[i];
        ++m[v[i]];
    }
    ll t = 0;
    for (auto it : m) {
        t += fun(it.se);
    }
    rep(i, 0, n) {
        auto k = m[v[i]];
        ll ans = t - fun(k) + fun(k-1);
        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 8392
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int n,k;
vector<int> v[2020];
int fun(int node, int centre, int dist)
{
    int temp=1;
    if(dist)
    {
        for(int i=0;i<(int)v[node].size();++i)
        {
            if(v[node][i]!=centre)
                temp+=fun(v[node][i],node,dist-1);
        }
    }
    return temp;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0,y=0,res=0;
    cin>>n>>k;
    for(int i=0;i+1<n;++i)
    {
        cin>>x>>y;
        --x;--y;
        v[x].pb(y);
        v[y].pb(x);
    }
    if(k&1)
    {
        for(int i=0;i<n;++i)
            for(int j=0;j<(int)v[i].size();++j)
                res=max(res,fun(i,v[i][j],k/2)+fun(v[i][j],i,k/2));
    }
    else
    {
        for(int i=0;i<n;++i)
            res=max(res,fun(i,i,k/2));
    }
    cout<<(n-res)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string S;
  cin >> S;
  bool p = S.at(0) == 'R';
  bool q = S.at(1) == 'R';
  bool r = S.at(2) == 'R';
  
  if(p && q && r) cout << 3 << endl;
  else if((p && q) || (q && r)) cout << 2 << endl;
  else if(p || q || r) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3588
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
#define LL long long
using namespace std;
LL sta[N],a[N],t[N],s[N],ans;
int tp,n,m;
int td(LL k,int r)
{
    int l=1,res=0;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(a[mid]<=k) res=mid,l=mid+1;
        else r=mid-1;
    }
    return res;
}
int main()
{
    scanf("%d%d",&n,&m);
    sta[tp=1]=n;
    for(int i=1;i<=m;i++)
    {
        LL x;scanf("%lld",&x);
        while(x<=sta[tp]) tp--;
        sta[++tp]=x;
    }
    m=tp;
    for(int i=1;i<=m;i++) a[i]=sta[i];
    t[m]=1;
    for(int i=m;i>=1;i--)
    {
        LL k=a[i];int p=td(k,i-1);
        while(p)
        {
            t[p]+=(k/a[p])*t[i];
            k%=a[p];
            p=td(k,p-1);
        }
        s[1]+=t[i];s[k+1]-=t[i];
    }
    for(int i=1;i<=n;i++) {ans+=s[i];printf("%lld\n",ans);}
    return 0;
}

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

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

    for (int i = 0; i < s.length(); i++) { 
        if (s[i] != '?') {
            continue;
        }
        s[i] = 'D';
    }

    cout << s << endl;
}


Measured memory_bytes: 3756
s = input()
k = int(input())

if int(s[0]) == 1:
  one_count = 0
  i = 0
  while i < len(s) and int(s[i]) == 1:
    one_count += 1
    i += 1
  if k <= one_count:
    print(1)
  else:
    print(s[one_count])
else:
  print(s[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define db(i) cout<<i<<" ";
#define db1(i) cout<<"("<<i<<")";
#define db2(i) cout<<"["<<i<<"]";
#define db3(i) cout<<"{"<<i<<"}";
#define ff first 
#define ss second
#define vv vector
#define pp pair
#define pi acos(-1);
#define printarr(a,n) cout<<"[";for(int i=0;i<n;i++){db1(a[i]);}cout<<"]";

using namespace std;

bool isprime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
        if(n%i==0)
        return false;
    return true;
}
int maxarr(int *a,int n)
{
    int val=a[0];
    for(int i=1;i<n;i++)
    {
        if(val<a[i])
        {
            val=a[i];
        }
    }
    return val;
}

int minarr(int *a,int n)
{
    int val=a[0];
    for(int i=1;i<n;i++)
    {
        if(val>a[i])
        {
            val=a[i];
        }
    }
    return val;
}


int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
} 
int power(int x, int y, unsigned int p=ULLONG_MAX)  
{  
    int res = 1;     
    x = x % p; 
    if (x == 0) 
      return 0; 
    while (y > 0)  
    {    
        if (y & 1)  
           res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
    if(a.ss<b.ss)
        return true;
    else if(a.ss>b.ss)
        return false;
    else
    {
        if(a.ff<b.ff)
            return true;
        else
            return false;
    }
    
}
bool cmp1(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.ss<b.ss);
}


//if no test cases add coments for reading




signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int a[n];
        
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
           
        }
        while(k--)
        {
            int b[n+1]={0};
            
            
            for(int i=0;i<n;i++)
            {
                int l=0,r=n-1;
                l=max(l,i-a[i]);
                r=min(r,i+a[i]);
               // db1(l);
              //  db1(r);
                b[l]++;
                b[r+1]--;
            }
            int mival=INT_MAX;
            a[0]=b[0];
            for(int i=1;i<n;i++)
            {
                b[i]=b[i]+b[i-1];
                a[i]=b[i];
                mival=min(a[i],mival);
            }
            if(mival==n)
            break;
        }
        for(int i=0;i<n;i++)
        {
            cout<<a[i]<<" ";
        }
     
      
    }
   
}


Measured memory_bytes: 6708
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <bitset>
using namespace std;
bitset<2000100>B;
int n,A[2100];
int main(){
	scanf("%d",&n); int s=0;
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	for (int i=1;i<=n;i++) s+=A[i];
	B[0]=1;
	for (int i=1;i<=n;i++) B|=(B<<A[i]);
	int num=s/2;
	while (B[num]==0) num--;
	cout<<s-num<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template <typename T>
T lcm(T a, T b) {
    // return (a * b) / gcd(a, b);
    T g = gcd(a,b);
    return a / g * b;
}

signed main() {
    int n;
    cin >> n;
    int ans = 1;
    rep(i, 0, n) {
        int t;
        cin >> t;
        ans = lcm<int>(ans, t);
    }
    cout << ans << endl;
}


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

int digit(int N){
	string Nstr = to_string(N);
	int ret = 0;
	for(int i = 0; i < Nstr.size(); i++){
		ret += Nstr[i] - '0';
	}
	return ret;
}

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	for(int i = 1; i <= N; i++){
		if(A <=digit(i) && digit(i) <= B){
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256