akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    int q; cin >> q;
    int flag = 0;
    int f;
    string a = "", b = "", c;
    rep(i,q) {
        int t; cin >> t;
        if (t == 1) {
            if (flag) flag = 0;
            else flag = 1;
        } else if (t == 2) {
            cin >> f;
            cin >> c;
            if (f == 1) {
                if (flag) b += c;
                else a += c;
            } else if (f == 2) {
                if (flag) a += c;
                else b += c;
            }
        }
        // cout << a << " " << b << endl;
    }
    reverse(a.begin(), a.end());
    string ans = a + s + b;
    if (flag) reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N,total;
  cin >> N;
  total=0;
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    total+=r+1-l;
  }
  cout << total << endl;
}

Measured memory_bytes: 3624
n, m = map(int, input().split())
# ps = [list(map(int, input().split())) for _ in range(m)]
ans = [0 for _ in range(n)]
pe = [0 for _ in range(n)]
accnt = 0
pecnt = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if ans[p - 1] == 0 and s == "WA":
        pe[p - 1] += 1
    elif ans[p - 1] == 0 and s == "AC":
        ans[p - 1] = 1

for i in range(n):
    if ans[i] == 0:
        pe[i] = 0

print(sum(ans), end = " ")
print(sum(pe), end = "")
print()

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vvll c(3,vll(3));
  rep(i,3) rep(j,3) cin>>c[i][j];
  
  ll a1=0;
  ll b1=c[0][0], b2=c[0][1], b3=c[0][2];
  ll a2=c[1][0]-b1, a3=c[2][0]-b1;
  
  if(c[1][1]==a2+b2
    &&c[1][2]==a2+b3
    &&c[2][1]==a3+b2
    &&c[2][2]==a3+b3
  ){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d,x,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	y=n/c;
	if(n%a>0){
		x=x+1;
	}
	if(n%c>0){
		y=y+1;
	}
	if(x*b<=y*d){
		printf("%d\n",x*b);
	}
	else{
		printf("%d\n",y*d);
	}
	return 0;
}


Measured memory_bytes: 2088
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f w h c = let t = gcd w h in w * h * c `div` t^2

main = getInts >>= print . apply3 f



Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
	int dmin = 100;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        int d=0;
        while(a[i]%2==0){
            a[i] /= 2;
            d++;
        }
        dmin = min(dmin,d);
    }
    cout << dmin << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
int main(){

    string s,t;
    cin >> s >> t;
    bool ans = true;
    rep(i,s.length()) if(s.at(i) != t.at(i)) ans = false;
    if(ans) CYES;
    else CNO;

}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    unsigned long p{0};
    for(auto& i : A){
        cin >> i;
        p = i - p;
    }
    for(const auto& i : A){
        cout << p << " ";
        p = 2 * i - p;
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, m, price[1009], dp[1009][4500];
string s;
vector<int> keys[1009];
int solve(int i, int msk)
{
    if(i==m)
    {
        if(msk==(1<<n)-1)
            return 0 ;
        return 2e8;
    }
    int &ans=dp[i][msk];
    if(ans!=-1)
        return ans;
    ans=solve(i+1,msk);
    for(auto j : keys[i])
        msk|=(1<<j);
    ans=min(ans,solve(i+1,msk)+price[i]);
    return ans;
}
int main()
{
    IO
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>price[i];
        int sz;
        cin>>sz;
        while(sz--)
        {
            int x;
            cin>>x;
            x--;
            keys[i].push_back(x);
        }
    }
    memset(dp,-1,sizeof dp);
    int ans=solve(0,0);
    if(ans>1e8)
        ans=-1;
    cout<<ans;

}


Measured memory_bytes: 21444
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる
	int x,y,cost;
};

int dp[21]={};
char c[21][21]={};
int main() {

	int h,w;
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>c[j][i];
		}
	}
	queue<pos> que;
	int total=0;
	rep(i,h){
		rep(j,w){
			int d[21][21]={};
			if(c[j][i]!='.')continue;
			pos pos1={j,i,0};
			d[j][i]=1;
			que.push(pos1);
				while(!que.empty()){
					pos pos3=que.front();que.pop();
					total=max(total,pos3.cost);
					if(c[pos3.x+1][pos3.y]=='.'&&d[pos3.x+1][pos3.y]==0){
						pos pos4={pos3.x+1,pos3.y,pos3.cost+1};
						que.push(pos4);
						d[pos3.x+1][pos3.y]=1;
					}
					if(c[pos3.x][pos3.y+1]=='.'&&d[pos3.x][pos3.y+1]==0){
						pos pos5={pos3.x,pos3.y+1,pos3.cost+1};
						que.push(pos5);
						d[pos3.x][pos3.y+1]=1;
					}
					if(c[pos3.x-1][pos3.y]=='.'&&d[pos3.x-1][pos3.y]==0){
						pos pos6={pos3.x-1,pos3.y,pos3.cost+1};
						que.push(pos6);
						d[pos3.x-1][pos3.y]=1;
					}
					if(c[pos3.x][pos3.y-1]=='.'&&d[pos3.x][pos3.y-1]==0){
						pos pos7={pos3.x,pos3.y-1,pos3.cost+1};
						que.push(pos7);
						d[pos3.x][pos3.y-1]=1;
					}
				}
			}
		}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	int t=max(n,m);
	cout<<k/t+(k%t!=0); 
	return 0;
}




Measured memory_bytes: 256
L ,R = map(int,input().split())

ans =[]
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
        if (i * j % 2019) == 0:
            break
    else:
        continue
    break

print(min(ans))

Measured memory_bytes: 6888
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll n, k;
    string s;
    cin >> n >> k >> s;
    ll t = 1;
    rep(i, n-1) if(s[i] != s[i+1]) t++;
    // cout << t << endl;
    ll x = max(1LL, t-2*k);
    cout << n - x << endl;
    return 0;
}

Measured memory_bytes: 512
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 15:31:22

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int a[10], rem = 0, sum = 0;
	for(int i = 1; i <= 5; ++i){
		cin >> a[i];
		if(a[i]%10){
			rem = max(rem, 10-a[i]%10);
			a[i] = a[i]/10*10 + 10;
		}
		sum += a[i];
	}
	cout << sum - rem << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>

using ll = long long;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>      
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h> // include all
#define MOD 1000000007
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    int pNum;
    int dNum;

    cin >> pNum;
    pNum++;
    int problem[pNum];
    fill(problem,problem+pNum,0);

    int sumTime = 0;
    FOR(i,1,pNum){
        cin >> problem[i];
        sumTime += problem[i];
    }
    
    cin >> dNum;
    pair <int,int> drink[dNum];

    REP(i,dNum){
        int key,value;
        cin >> key >> value;
        drink[i].first = key;
        drink[i].second = value;
    }
    int ans = 0;

    REP(i,dNum){
        int probIndex = drink[i].first;
        int solveTime = drink[i].second;

        ans = sumTime - problem[probIndex] + solveTime;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        
        
        void solve()
        {
        	int n;
        	cin>>n;
        	
        	if(n>=30)
        	{
        		cout<<"Yes";
			}
			else
			{
				cout<<"No";
			}
		}
        signed main()
        {
        	solve();
		}

Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	char str[110][5];
	
	int a = 0;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		scanf("%s", str[i]);
	}
	
	for (int i = 0; i < n; i++){
		if(str[i][0] == 'A') a++;
		if(str[i][0] == 'U') {
			if (a <= 0){
				a = -1;
				break;
			}
			else a--;
		}
	}
	
	if (a == 0) printf("YES\n");
	if (a != 0) printf("NO\n");
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;

    int ans=0;

    if(x>y)ans=min({a*x+b*y,2*c*x,2*c*y+(x-y)*a});
    else ans=min({a*x+b*y,2*c*y,2*c*x+(y-x)*b});

    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;

namespace A___Harmony
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            if (((AB[0] + AB[1]) % 2) == 1)
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            else
            {
                Console.WriteLine((AB[0] + AB[1]) / 2);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll A,B,C,E,D;
  cin  >> A >> B >>  C >> D >> E;
  if(A==0){
    cout <<  1 << endl;
    return 0;
  }
  if(B==0){
    cout <<  2 << endl;
    return 0;
  }
  if(C==0){
    cout <<  3 << endl;
    return 0;
  }
  if(D==0){
    cout <<  4 << endl;
    return 0;
  }
  if(E==0){
    cout <<  5 << endl;
  }
}

Measured memory_bytes: 3632
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n;
vector<int> E[N];

int fa[N],dep[N],sz[N];
void dfs(int u,int f) {
	dep[u]=dep[fa[u]=f]+1,sz[u]=1;
	for (int v:E[u])
		if (v!=f) dfs(v,u),sz[u]+=sz[v];
}
int jump(int u,int k) {
	while (k--) u=fa[u];
	return u;
}

int main() {
	n=read();
	for (int i=1;i<n;++i) {
		int u=read(),v=read();
		E[u].emplace_back(v),E[v].emplace_back(u);
	}
	dfs(1,0); int t=jump(n,(dep[n]-2)/2);
	puts(sz[t]>=n-sz[t]?"Snuke":"Fennec");
	return 0;
}

Measured memory_bytes: 18028
import math
e=map(float,raw_input().split())
a=e[0]
b=e[1]
C=math.radians(e[2])
c=(a**2+b**2-2*a*b*math.cos(C))**0.5
h=b*math.sin(C)
S=h*a*0.5
L=a+b+c
print S
print L
print h


Measured memory_bytes: 4796
#include <iostream>
using namespace std;
int main(void){
   double a;
   
   while(cin>>a){
       double b=0,c=0;
       b=a;
       c+=a;
       for(int i=2;i<=10;i++){
           if(i%2==0) b*=2;
           else if(i%2==1) b/=3;
           c+=b;
       }
       cout<<fixed<<c<<endl;
       
   }
   
    return 0;
}



Measured memory_bytes: 3192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AWhiteCells {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int rows = in.nextInt();
            int cols = in.nextInt();
            int h_row = in.nextInt();
            int h_col = in.nextInt();
            out.println((rows - h_row) * (cols - h_col));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> d(n);
  for (auto& e : d) cin >> e;
  for (int i = 0; i + 1 < n; i++) d[i + 1] += d[i];
  cout << int(upper_bound(begin(d), end(d), x) - begin(d)) + 1 << endl;
}


Measured memory_bytes: 256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

def main():
    a,b,n = readInt()
    x = min(b-1,n)
    ans = a * x // b - a * (x // b)
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9180
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


"""
全点対探索 & Nが小さいのでワーシャルフロイド．クエリも多めだし
合計距離から補給の回数をうまく計算するのは難しい，
残燃料を持つのも厳しい．
距離バージョンではなくて補給回数バージョンで新しいグラフとか作りたい

新しいグラフは距離がL以下の全点に対してならコスト1の辺を結ぶ．
最初からLあるのでコスト-1

"""
def main():
    
    def warshall_floyd(d):
        #d[i][j]: iからjへの最短距離
        N=len(d)
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
        return d
    
    mod=10**9+7
    N,M,L=MI()
    inf = 10**12
    d=[[inf]*N for _ in range(N)]
    for i in range(M):
        a,b,c=MI()
        a-=1
        b-=1
        d[a][b]=c
        d[b][a]=c
        
    d=warshall_floyd(d)
    
    nd=[[inf]*N for _ in range(N)] # 距離がL以下ならコスト1で結ぶ
    
    for i in range(N):
        for j in range(N):
            if d[i][j]<=L:
                nd[i][j]=1
    
    nd =warshall_floyd(nd)
    
    Q=I()
    for _ in range(Q):
        s,t=MI()
        s-=1
        t-=1
        ans=nd[s][t]
        if ans >= inf:
            ans=0
        print(ans-1)
        
    
    
    
main()


Measured memory_bytes: 78640
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1
used = [True] * n
used[0] = False
i = a[0]
k1 = 1
g = [0]
f1 = True
while True:
    if k == k1:
        f1 = False
        print(i + 1)
        break
    if used[i]:
        used[i] = False
        k1 += 1
        g.append(i)
        i = a[i]
    else:
        break
if f1:
    f = False
    g1 = []
    for j in g:
        if j == i:
            f = True
        if f:
            g1.append(j)
    print(g1[(k - (len(g) - len(g1))) % len(g1)] + 1)

Measured memory_bytes: 32412
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main(){
    int h,n;
    cin >> h >> n;
    int m = 4e4;
    vector<int> a(n),b(n),dp(m,INT_MAX/2);
    dp[0] = 0;
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    REP(i,m){
        REP(j,n){
            if(i-a[j]>=0){
                 chmin(dp[i],dp[i-a[j]]+b[j]);
            }
        }
    }
    int res = INT_MAX;
    FOR(i,h,m){
        chmin(res,dp[i]);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 512
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut br = BufReader::new(std_in.lock());
    let mut bw = BufWriter::new(std_out.lock());
    
    let n = rn::<usize>(&mut br);
    let mut h = rvn::<usize>(&mut br);

    h[0] -= 1;
    for i in 1..n {
        if h[i] < h[i-1] {
            writeln!(&mut bw, "No");
            return;
        }
        if h[i] > h[i-1] {
            h[i] -= 1;
        }
    }
    writeln!(&mut bw, "Yes");
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 8444
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}
ll a[3002][3002];
ll dp[3002][3002][4];
ll row[3002];
ll r,c,k;
ll f(int i,int j,int cnt){
    //cout<<i<<" "<<j<<" "<<cnt<<endl;
    if(i<=0 || j<=0 || i>r || j>c || cnt>3) return 0;
    if(dp[i][j][cnt]!=-1) return dp[i][j][cnt];

    ll x,y,x1,y1; x=y=x1=y1=0;

    if(cnt<3 && a[i][j]!=0){
        x=a[i][j]+f(i+1,j,0);
    }
    x1=f(i+1,j,0);

    if(cnt<3 && a[i][j]!=0) y=a[i][j]+f(i,j+1,cnt+1);
    y1=f(i,j+1,cnt);

    ll p=max(x,x1); ll q=max(y,y1);
    //cout<<i<<" "<<j<<" "<<cnt<<" "<<p<<" "<<q<<endl;
    return dp[i][j][cnt]=max(p,q);

}
int main()
{
    memset(dp,-1,sizeof(dp));

    cin>>r>>c>>k;
    ll x,y,v;
    for(int i=1;i<=k;i++){
        cin>>x>>y>>v;
        a[x][y]=v;
    }

    cout<<f(1,1,0)<<endl;

//    for(int i=1;i<=r;i++){
//        for(int j=1;j<=c;j++){
//            cout<<i<<" "<<j<<"   ";
//            for(int k=0;k<=3;k++) cout<<dp[i][j][k]<<" "; cout<<endl;
//        }
//    }

    return 0;
}




Measured memory_bytes: 356044
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> v = vector<int>(0)){
    if((int)v.size() == n){
        int sum = 0;
        for(int i = 0; i < q; ++i){
            if(v[b[i]] - v[a[i]] == c[i])   sum += d[i];
        }
        chmax(ans, sum);
        return;
    }

    int st = 1;
    if(v.size() != 0)   st = v.back();
    for(int i = st; i <= m; ++i){
        vector<int> next = v;
        next.push_back(i);
        dfs(next);
    }
}

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

    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for(int i = 0; i < q; ++i){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    }

    dfs();
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <iostream> 
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <random>
#include <queue>
#include <stack>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

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

const int maxn = 5000 + 123;
const int MOD = 1e9 + 7;
int n, m;
int a[maxn];


std::vector<int> V[maxn];
int scc = 0;
int color[maxn];
int odd[maxn][2];

ll f[maxn];


void fail() {
	cout << 0 << endl;
	exit(0);
}

void dfs(int u) {
	odd[scc][color[u] - 1]++;
	for (auto v: V[u]) {
		if (color[v]) {
			if (color[v] == color[u]) {
				return fail();
			}
		} else {
			color[v] = 3 - color[u];
			dfs(v);
		}
	}
}


int f1[maxn];
int solve() {
	cin >> n >> m;
	For(i,1,n) cin >> a[i];

	For(i,1,n) For(j, i + 1, n) if (a[j] < a[i]) {
		V[i].push_back(j);
		V[j].push_back(i);
	}

	memset(color, 0, sizeof(color));
	memset(odd, 0, sizeof(odd));
	scc = 0;
	For(u, 1, n) if (!color[u]) {
		color[u] = 1;
		scc++;
		dfs(u);
	}

    f[0] = 1;
    for(int i = 1; i <= scc; i++) {
        for(int j = 0; j <= n; j++) f1[j] = f[j], f[j] = 0;
        for(int j = n; j >= 0; j--) {
            for(int k = 0; k <= 1; k++) if (j >= odd[i][k]) 
                f[j] = (f[j] + f1[j - odd[i][k]]) % MOD;
        }
    }
    ll ans = 0;
    for(int i = n - m; i <= m; i++)
        ans = (ans + f[i]) % MOD;
    return ans;

}

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

	return 0;

}			



Measured memory_bytes: 6380
import math
a,b,c,d=map(int,input().split())
lcm_cd=c*d//math.gcd(c,d)
c_cnt=b//c-(a-1)//c
d_cnt=b//d-(a-1)//d
cd_cnt=b//lcm_cd-(a-1)//lcm_cd
print(b-a+1-c_cnt-d_cnt+cd_cnt)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,n,m;
	int sum,y;
	int gk,gk2;
	int cnt=0;
	cin>>a>>n>>m;
	y=1;
	while(1){
		sum=a+y;
		gk=1;
		for(int i=0;i<n;i++){
			gk*=sum;
		}
//		cout<<gk<<endl;
		if(gk>m)	break;
		gk2=0;
		while(gk!=0){
			gk2+=gk%10;
			gk/=10;
		}
//		cout<<"y="<<y<<endl;
//		cout<<"gk2="<<gk2<<endl;
		if(gk2==y)	cnt++;
//		cout<<"cnt="<<cnt<<endl;
		y++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=3000;

int n;
char s[2*MAXN+1];

int a[2*MAXN],na;
int b[2*MAXN],nb;
int idx[2*MAXN];
int match[2*MAXN];

string dp[2*MAXN+1];

void run() {
	scanf("%d%s",&n,s);

	na=nb=0; REP(i,2*n) if(s[i]=='a') idx[i]=na,a[na++]=i; else if(s[i]=='b') idx[i]=nb,b[nb++]=i; assert(na==n&&nb==n);
	REP(i,2*n) match[i]=s[i]=='a'?b[idx[i]]:s[i]=='b'?a[idx[i]]:-1;

	dp[2*n]="";
	for(int i=2*n-1;i>=0;--i) {
		dp[i]=dp[i+1];
		if(match[i]<i) continue;
		if(s[i]=='a') { dp[i]=max(dp[i],"ab"+dp[match[i]+1]); continue; }
		
		vector<bool> used(2*n,false); int nused=0,mxused=-1; used[i]=true,mxused=max(mxused,i),++nused; used[match[i]]=true,mxused=max(mxused,match[i]),++nused;
		FORE(j,i+1,mxused) {
			if(s[j]!='b') continue;
			assert(match[j]>mxused);
			used[j]=true,mxused=max(mxused,j),++nused; used[match[j]]=true,mxused=max(mxused,match[j]),++nused;
		}
		string cur(nused,'?'); int at=0; FORE(j,i,mxused) if(used[j]) cur[at++]=s[j]; assert(at==nused);
		dp[i]=max(dp[i],cur+dp[mxused+1]);
	}

	printf("%s\n",dp[0].c_str());
}

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


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
#define PI acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NL printf("\n")
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int dp[102][1002];
int inf  = 100000009;
int N,M;
int a[101][101];
int solve(int n, int m){

        if(n>=N || m>=M){
            return inf;
        }

        if(dp[n][m]!=-1) return dp[n][m];

        dp[n][m]=min(solve(n-1,m) , solve(n,m-1))+a[n][m];
        return dp[n][m];
}
int sum[101][101];

int main()
{
      //fast;
     int t=1;
    // cin >> t;

    while(t--)
    {
      int n,m;
      cin >> n;
      ll a[n+10];
      ll b[n+10];
      memset(a,0,sizeof a);
      for(int i =1; i<=n; i++){
        cin >> b[i];
        a[b[i]]++;
      }

      ll tot = 0;
      for(int i = 1; i<=n; i++){
         if(a[i]==0) continue;
        tot+=(a[i]*(a[i]-1))/2;
      }

      for(int i = 1; i<=n; i++){
          cout << tot-(a[b[i]]-1)<<endl;
      }

     }

          return 0;
}


Measured memory_bytes: 5760
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_8-C
 
Character - Counting Characters
Time Limit : 1 sec, Memory Limit : 65536 KB
?????????????????????

?????????????????±??????????????????????????¢???????????????????????°?????°??????????????°????????????????????????????????? ??????????°?????????¨??§??????????????\???????????????
Input

?????°????????????????????????????????±???????????????????????????
Output

?????????????????±???????????????????????¢???????????????????????°?????\??????????????¢?????§????????????????????????

a : a????????°
b : b????????°
c : c????????°
  .
  .
z : z????????°

Constraints

    ??±???????????????????????° < 1200

Sample Input

This is a pen.

Sample Output

a : 1
b : 0
c : 0
d : 0
e : 1
f : 0
g : 0
h : 1
i : 2
j : 0
k : 0
l : 0
m : 0
n : 1
o : 0
p : 1
q : 0
r : 0
s : 2
t : 1
u : 0
v : 0
w : 0
x : 0
y : 0
z : 0

=end
fh=STDIN
#fh=open("IPT1_8_C.txt")
h = Hash.new
("a".."z").each {|c| h[c]=0}
while fh.gets
  s=$_.chomp
  str=s.downcase.split(//)
  str.each {|c|
    if not h.has_key?(c) then
      h[c]=0
    end
    h[c] += 1
  }
end

("a".."z").each {|c| puts c + " : " + h[c].to_s}

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

int main(){
    long long r, d, x;
    cin >> r >> d >> x;
    for(int i = 1; i <= 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;

  rep(i,0,s.size()){
    if(s[i]!=',')cout<<s[i];
    else cout<<" ";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;



int main() {
	string s;
	cin >> s;
	if (s[0] >= 'a' && s[0] <= 'z') {
		cout << 'a' << endl;
	} else {
		cout << 'A' << endl;
	}

	return 0;
}



Measured memory_bytes: 3028
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            out.println( in.readString().startsWith( "YAKI" ) ? "Yes" : "No" );
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

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

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

        public String readString () {
            int c = read();
            while ( isSpaceChar( c ) ) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint( c );
                c = read();
            } while ( ! isSpaceChar( c ) );
            return res.toString();
        }

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

    }
}



Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n;
char s[N];
int a[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int cnt1=0;
	For(i,1,n){
		a[i]=s[i]=='1';
		cnt1+=a[i];
	}
	if (cnt1==0)
		return puts("0"),0;
	LL ans=(LL)cnt1/2*(cnt1/2+1);
	if (cnt1&1)
		ans+=(cnt1+1)/2;
	int cnt0=n-cnt1;
//	outval(ans);outval(cnt0);
	vi v;
	int c0=0,c1=0;
	int p0=0,p1=0;
	For(i,1,n)
		if (a[i]==0){
			if (c1){
				v.pb(c0),c1=c0=0;
				if ((i-1)&1)
					p1++;
				else
					p0++;
			}
			c0++;
		}
		else {
			if (c1)
				ans+=cnt0;
			c1^=1;
		}
	v.pb(c0);
	if (c1){
		v.pb(0);
		if (n&1)
			p1++;
		else
			p0++;
	}
	if (v.size()==1)
		return printf("%lld\n",ans),0;
//	outval(ans);
//	outval(p0),outval(p1);
//	outarr(v,0,(int)v.size()-1);
	while (v[0]>0){
		ans+=p1;
		swap(p0,p1);
		v[0]--;
	}
//	outval(ans);
	For(i,1,(int)v.size()-1){
		p1--;
		while (v[i]>1){
			ans+=i;
			ans+=p1;
			swap(p0,p1);
			v[i]--;
		}
	}
//	outtag();
//	outval(p0),outval(p1);
//	outval(ans);
//	outarr(v,0,(int)v.size()-1);
	int flag=0;
	if (v.back()==0){
		if ((int)v.size()==2)
			return printf("%lld\n",ans),0;
		ans+=(int)v.size()-1;
		v.pop_back();
		flag=1;
	}
	int vsz=(int)v.size()-1;
	For(i,0,vsz-1-flag)
		ans+=(vsz+(vsz-i)+1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4808
import java.util.*;
 
public class Main {

    private static int MOD = 1_000_000_007;

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

        System.out.println(N == M ? "Yes" : "No");
    }
}


Measured memory_bytes: 22604
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;

int main() {
	ll n, k,dgt=0;
	cin >> n >> k;
	for (ll i = 0; n > 0; i++) {
		ll(n /= k);
		dgt++;
	}
	cout << dgt << endl;
	
}


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

int main() {


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

    double avg = 0;
    for (int i = 0; i < n; ++i) avg += a[i];
    avg /= n;

    //sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (abs(static_cast<double>(avg - a[i])) < abs(static_cast<double>(avg - a[ans]))) ans = i;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c;
	int d=0,e=0;
	while(~scanf("%d,%d,%d",&a,&b,&c)){
		if(a*a+b*b==c*c)d++;
		if(a==b)e++;
	}
	printf("%d\n%d\n",d,e);
}

Measured memory_bytes: 0