akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=998244353;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n;
int p2[max_n];
P p[max_n];
int main(){
    scanf("%d",&n);
    p2[0]=1;
    for(int i=1;i<=n;i++)p2[i]=Mul(p2[i-1],2);
    for(int i=1;i<=n;i++)scanf("%d%d",&p[i].fi,&p[i].se);
    int ans=n+1;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int a=p[j].se-p[i].se,b=p[i].fi-p[j].fi;
            int c=-a*p[j].fi-b*p[j].se;
            int cnt=2;
            for(int k=j+1;k<=n;k++){
                if(a*p[k].fi+b*p[k].se+c==0)cnt++;
            }
            for(int k=1;k<j;k++){
                if(k==i||k==j)continue;
                if(a*p[k].fi+b*p[k].se+c==0)cnt=0;
            }
            ans=Add(ans,Sub(p2[cnt],cnt+1));
        }
    }
    printf("%d\n",Sub(p2[n],ans));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e+9 + 7;

ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a, long long mod)
{
  return modpow(a, mod - 2, mod);
}

int main()
{
  int N, K;
  cin >> N >> K;

  for (int i = 1; i <= K; i++)
  {
    ll ans;
    if (i > N - K + 1)
      ans = 0;
    else
    {
      ans = 1;
      for (int j = 0; j < i; j++)
      {
        ans *= N - K + 1 - j;
        ans %= mod;
        ans *= modinv(j + 1, mod);
        ans %= mod;
      }
      if (i >= 2)
      {
        for (int j = 0; j < i - 1; j++)
        {
          ans *= K - 1 - j;
          ans %= mod;
          ans *= modinv(j + 1, mod);
          ans %= mod;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        struct point
        {
            public double x;
            public double y;
        }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            Action<point, point, double, long> koch = null;
            var rad60 = Math.PI * 60 / 180;
            var points = new List<point>();
            koch = (p1, p2, rad, num) =>
             {
                 if (--num < 0) return;
                 var pl = new point() { x = p1.x + (p2.x - p1.x) / 3, y = p1.y + (p2.y - p1.y) / 3 };
                 var pr = new point() { x = p1.x + 2 * (p2.x - p1.x) / 3, y = p1.y + 2 * (p2.y - p1.y) / 3 };
                 var nrad = rad + rad60;
                 var len = Math.Sqrt(Math.Pow(p1.x - p2.x, 2) + Math.Pow(p1.y - p2.y, 2)) / 3;
                 var pm = new point()
                 {
                     x = pl.x + len * Math.Cos(nrad),
                     y = pl.y + len * Math.Sin(nrad)
                 };
                 koch(p1, pl, rad, num);
                 points.Add(pl);
                 koch(pl, pm, nrad, num);
                 points.Add(pm);
                 koch(pm, pr, nrad + 4*rad60, num);
                 points.Add(pr);
                 koch(pr, p2, rad, num);
             };
            var ps = new point() { x = 0, y = 0 };
            var pe = new point() { x = 100, y = 0 };

            points.Add(ps);
            koch(ps, pe, 0, N);
            points.Add(pe);

            foreach (var p in points)
                WriteLine($"{p.x} {p.y}");
        }
    }
}



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

int main(){
    vector <int> A(3);
    for (int i=0; i<3; i++) cin>>A[i];
    
    sort(A.begin(),A.end(),greater<int>());
    int ans=abs(A[1]-A[0])+abs(A[2]-A[1]);
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
using namespace std;
// }}} End Header

lli sigma1(lli n){
	return n*(n+1)/2;
}
lli sigma2(lli s, lli n){
	return sigma1(n) - sigma1(s -1);
}
int main()
{
	lli n, k, sum=0;
	cin >> n >> k;

	for(lli i=k; k<=n+1; k++){
		lli small = sigma1(k-1);
		lli big = sigma2(n-k+1, n);
		sum += (big -small +1);
	}
	sum = sum%(1000000000+7);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("125");
            //176
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("9999999999");
            //12656242944
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct JyoutaiDef
    {
        internal int CurrInd;
        internal long CurrSum;
        internal long TotalSum;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];
        int UB = S.Length - 1;

        var Stk = new Stack<JyoutaiDef>();
        JyoutaiDef WillPush;
        WillPush.CurrInd = 0;
        WillPush.CurrSum = 0;
        WillPush.TotalSum = 0;
        Stk.Push(WillPush);

        long Answer = 0;
        while (Stk.Count > 0) {
            JyoutaiDef Popped = Stk.Pop();

            //クリア判定
            if (Popped.CurrInd > UB) {
                //Console.WriteLine(Popped.CurrSum + Popped.TotalSum);
                Answer += Popped.CurrSum + Popped.TotalSum;
                continue;
            }

            int CurrNum = int.Parse(S[Popped.CurrInd].ToString());

            //+を使う経路
            if (Popped.CurrInd > 0) {
                WillPush.CurrInd = Popped.CurrInd + 1;
                WillPush.CurrSum = CurrNum;
                WillPush.TotalSum = Popped.TotalSum + Popped.CurrSum;
                Stk.Push(WillPush);
            }

            //+を使わない経路
            WillPush.CurrInd = Popped.CurrInd + 1;
            WillPush.CurrSum = Popped.CurrSum * 10 + CurrNum;
            WillPush.TotalSum = Popped.TotalSum;
            Stk.Push(WillPush);
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 3032
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)



signed main(){
	int A,B;
	cin>>A>>B;
	cout<<max(A,B)+max(max(A,B)-1,min(A,B))<<endl;
	return 0;
}


Measured memory_bytes: 256
NMAX=40
ABMAX=10
INF=1000000
N,MA,MB=map(int,input().split())
A=[0]*NMAX
B=[0]*NMAX
C=[0]*NMAX
dp=[[[INF for _ in range(NMAX*ABMAX+1)] for _ in range(NMAX*ABMAX+1)] for _ in range(NMAX+1)]
for i in range(N):
  A[i],B[i],C[i]=map(int,input().split())

dp[0][0][0]=0
for i in range(N):
  for ca in range(NMAX*ABMAX+1):
    for cb in range(NMAX*ABMAX+1):
      if dp[i][ca][cb]==INF: continue
      dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
      dp[i+1][ca+A[i]][cb+B[i]]=min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])

ans=INF
for ca in range(1,NMAX*ABMAX+1):
  for cb in range(1,NMAX*ABMAX+1):
    if ca*MB==cb*MA: ans=min(ans,dp[N][ca][cb])
if ans==INF: ans=-1
print(ans)


Measured memory_bytes: 60068
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    int c[n];
    int i;
    for(i=0; i<n; i++){
        cin>>c[i];
    }
    sort(c, c+n);
    int ans = 0;
    for(i=0; i<n-1; i++){
        if(c[i]==c[i+1]){
            ans++;
        }
    }
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n, d;
	cin >> n >> d;
	int ans = 0;
	while (n > 0)
	{
		n -= 2*d + 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;

	long x = min( { A,B,C,D,E } );
	cout << (N + x-1) / x + 4 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	int p[a]; rep(i,a) cin >> p[i];
	int q[b]; rep(i,b) cin >> q[i];
	int r[c]; rep(i,c) cin >> r[i];
	sort(p, p + a);
	reverse(p, p + a);
	sort(q, q + b);
	reverse(q, q + b);
	sort(r, r + c);
	reverse(r, r + c);
	int64_t ans = 0;
	stack<int64_t> stp;
	stack<int64_t> stq;
	for(int i = 0; i < x; ++i) {
		ans += p[i];
		stp.push(p[i]);
	}
	for(int i = 0; i < y; ++i) {
		ans += q[i];
		stq.push(q[i]);
	}
	int64_t sum = ans;
	for(int i = 0; i < c; ++i) {
		if(stp.empty() and stq.empty()) break;
		if(stp.empty()) {
			int64_t rr = stq.top();
			stq.pop();
			sum -= rr;
			sum += r[i];
		} else if(stq.empty()) {
			int64_t ll = stp.top();
			stp.pop();
			sum -= ll;
			sum += r[i];
		} else {
			int64_t ll = stp.top();
			int64_t rr = stq.top();
			if(ll < rr) {
				stp.pop();
				sum -= ll;
				sum += r[i];
			} else {
				stq.pop();
				sum -= rr;
				sum += r[i];
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
int n,m;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	if(n<m){
		for(ri i=1;i<=m;++i)
			print(n);
	}
	else{
		for(ri i=1;i<=n;++i)
			print(m);
	}
	return 0;
}

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

int main(void)
{
    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n), b(m), dpa(n + 1), dpb(m + 1);
    rep(i, n)
    {
        cin >> a.at(i);
        dpa.at(i + 1) = dpa.at(i) + a.at(i);
    }
    rep(i, m)
    {
        cin >> b.at(i);
        dpb.at(i + 1) = dpb.at(i) + b.at(i);
    }

    int ans = 0, j = m;

    rep(i, n + 1)
    {
        if (dpa.at(i) > k)
            break;
        while (dpb.at(j) > k - dpa.at(i))
        {
            j--;
        }
        ans = max(ans, i + j);
    }

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


Measured memory_bytes: 9576
import copy
N,M=map(int,input().split())
path_matrix=[[0 for i in range(N)] for j in range(N)]
L=[[] for i in range(M)]

for i in range(M):
    a,b=map(int,input().split())
    path_matrix[a-1][b-1]=1
    path_matrix[b-1][a-1]=1
    L[i].append(a)
    L[i].append(b)

color_white=["W" for i in range(N)]
color_black=["B" for i in range(N)]
visited=copy.deepcopy(color_white)

def path(x,y):
    path_matrix[x-1][y-1]=0
    path_matrix[y-1][x-1]=0
    return DFS(x,path_matrix)

def DFS(x,tim):
    visited[x-1]="B"
    if visited==color_black:
        return True
    total_ans=0
    for i in range(N):
        if tim[x-1][i]==1 and visited[i]=="W":
            total_ans=int(DFS(i+1,tim))

    return total_ans
    
ans=0
for i in range(M):
    visited=copy.deepcopy(color_white)
    if path(L[i][0],L[i][1])==0:
        ans+=1
    path_matrix[L[i][0]-1][L[i][1]-1]=1
    path_matrix[L[i][1]-1][L[i][0]-1]=1

print(ans)

Measured memory_bytes: 9292
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int x=0,y=0,z=0,n,out=0;
	string s;
	cin>>n;
	rep(i,n){
		cin>>s;
		rep(i,s.size()-1){
			if(s.substr(i,2)=="AB") out++;
		}
		if(s[0]=='B' && s[s.size()-1]=='A') z++;
		else if(s[0]=='B') x++;
		else if(s[s.size()-1]=='A') y++;
	}
	if(x==0 && y==0){
		out+=max(0,z-1);
	}
	else{
		out+=z+min(x,y);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a[3],b[3];
	int g[3][3];

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin >> g[i][j];
		}
	}

	a[0] = 0;

	for(int i=0;i<3;i++)
	{
		b[i] = g[0][i] - a[0];
	}

	for(int i=0;i<3;i++)
	{
		a[i] = g[i][0] - b[0];
	}

	bool good = true;

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(g[i][j] != a[i] + b[j])
			{
				good = false;
				break;
			}
		}
	}

	if(good)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
     int a,b;
     cin >>a >>b;
     int x=b-a;
     int sum=0;
     for(int i=1;i<=x;i++){
         sum+=i;
     }
     cout << sum-b << endl;
    return 0; 

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n,ans=0;
  vector<pair<int,int>> a(5);
  for(i=0;i<5;i++){
    cin >> n;
    a.at(i).second=n;
    if(n%10==0) a.at(i).first=0;
    else a.at(i).first=10-n%10;
  }
  sort(a.begin(),a.end());
  n=0;
  for(i=0;i<4;i++){
    while(1){
      if(a.at(i).second<=n) break;
      n+=10;
    }
    ans+=n;
    n=0;
  }
  cout << ans+a.at(i).second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);


void solve(){




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


    ll a;
    long double b;
    cin >> a >> b;
    ll ans;
    ans = a*b;
    cout << ans << endl;
 
    return 0;
 
 
}



Measured memory_bytes: 3764
#include <iostream>
#define Iset int i,j,l;
#define Fi for (i = 0; i < 9; i++)
using namespace std;

int main() {
	int a, b[11], c=0;
	
	Iset;
	cin >> a;
	start:
	Fi {
		cin >> b[i];
			c += b[i];
	}
	cout << a-c << endl;

	cin >> a ;
	if (a == 0) {
		goto end;
	}
	else {
		c = 0;
		goto start;
	}
	end:
	return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e8;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

int x, y, a, b, c;
vl p, q, r;

int main() {
	setIO();

    cin >> x >> y >> a >> b >> c;
    REP(a) {ll z; cin >> z; p.pb(z);}
    REP(b) {ll z; cin >> z; q.pb(z);}
    REP(c) {ll z; cin >> z; r.pb(z);}

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());
    sort(r.begin(), r.end());
    reverse(r.begin(), r.end());

    int aId = 0, bId = 0, cId = 0;
    ll ans = 0;
    REP(x+y) {
        vector<pair<ll,int>> s;
        if (aId < x) s.pb({p[aId], 0});
        if (bId < y) s.pb({q[bId], 1});
        if (cId < c) s.pb({r[cId], 2});
        sort(s.begin(), s.end());
        reverse(s.begin(), s.end());
        ans += s[0].f;
        if (s[0].s == 0)
            aId++;
        else if (s[0].s == 1)
            bId++;
        else
            cId++;
    }

    cout << ans;

	return 0;
}


Measured memory_bytes: 3316
def main():
    n, k= map(int, input().split())
    lis = list(map(int, input().split()))
    dp = []
    tmp = []
    for _ in range(n+1):
        dp.append(0)

    for i in range(2, k+1):
        if i <= n:
            dp[i] = abs(lis[i-1] - lis[0])
        # print(i, dp[i])
    #print("start")
    for i in range(k+1, n+1):
        for t in range(1, k+1):
            cost_t = abs(lis[i-1] - lis[i-1 - t]) + dp[i-t]
            tmp.append(cost_t)
        dp[i] = min(tmp)
        tmp = []
        #print(i, dp[i])
    print(dp[n])

if __name__ == "__main__":
    main()

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

using namespace std;
map<int,int> cnt;
int main(){
    int n; cin >> n;

    for(int i = 0; i < n; i++){
        int l ; cin >> l;
        cnt[l]++;
    }
    int m; cin >> m;
    for(int i = 0 ; i < m; i++){
        int l; cin >> l;
        if(cnt[l] <= 0){
            cout << "NO";
            return 0;
        }else cnt[l]--;
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <climits>
#define int int64_t
#define endl "\n"
#define mod 1000000007
using namespace std;

void io()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

string s;
int d;

int dp[10002][102][2];

int solve(int pos,int sum,int tight){
    if(pos == s.length()+1){
        if(sum % d == 0){
            return 1;
        }else return 0;
    }

    if(dp[pos][sum][tight]!=-1){
        return dp[pos][sum][tight];
    }

    int end = ((tight ? (s[pos-1]-'0') : 9));
    int ans=0;
    for (int i = 0; i <= end; i++)
    {
        ans = ans + solve(pos+1,(sum+i%d)%d,tight&(i == end))%mod;
    }
    return dp[pos][sum][tight]=ans;
    
}

void Solution()
{
    cin >> s >> d;
    memset(dp,-1,sizeof dp);
    cout << (solve(1,0,1)-1)%mod;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //io();
    Solution();
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  vector<ll> a(3);
  REP(i, 3) { cin >> a[i]; };

  sort(all(a), greater<int>());

  cout << a[0] * 10 + a[1] + a[2] << "\n";
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int m;
    cin >> m;
    cout << 48 - m << "\n";
    
    return 0;
}

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

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

  long long n,m;

  std::cin >> n >> m;
  int a[10000];
  for (int i = 0; i < m; ++i) {
    std::cin >> a[i];
    n -= a[i];
  }

  if (n >= 0) {
    std::cout << n << std::endl;
  } else {
    std::cout << "-1" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int gcd(int x, int y);  // 最大公約数を求める関数

int main()
{
    int x, y, K;
    int gcd_num;
    int A[100];
    int j = 0;
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &K);
    gcd_num = gcd(x, y);
    for(int i = 1; i <= gcd_num; i++){
        if( gcd_num % i == 0){
            A[j] = i;
            j++;
        }
    }

    printf("%d\n", A[j- K]);

    return 0;
}

// 最大公約数を求める関数
int gcd(int x, int y)
{
    int r;

    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    // ユーグリッドの互除法
    while((r = x % y) != 0)  // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}


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

int cocoon[5][5];
bool used[10], sameRev[10];

int solve(vector<string>& slit, int cnt)
{
	int ans = 0;

	if (cnt < 5) {
		for (unsigned int i = 0; i < slit.size(); ++i) {
			if (used[i])
				continue;

			used[i] = true;
			for (int j = 0; j < 5; ++j)
				cocoon[cnt][j] += (slit[i][j] - '0');
			ans += solve(slit, cnt+1);
			for (int j = 0; j < 5; ++j)
				cocoon[cnt][j] -= (slit[i][j] - '0');

			if (!sameRev[i]) {
				for (int j = 0; j < 5; ++j)
					cocoon[cnt][j] += (slit[i][5-j-1] - '0');
				ans += solve(slit, cnt+1);
				for (int j = 0; j < 5; ++j)
					cocoon[cnt][j] -= (slit[i][5-j-1] - '0');
			}
			used[i] = false;
		}
	} else {
		for (unsigned int i = 0; i < slit.size(); ++i) {
			if (used[i])
				continue;

			used[i] = true;

			bool straight = true;
			for (int j = 0; j < 5; ++j) {
				cocoon[j][cnt-5] += (slit[i][j] - '0');
				if (cocoon[j][cnt-5] != 1)
					straight = false;
			}

			if (straight) {
				if (cnt == 9) {
					bool valid = true;
					for (int y = 0; y < 5 && valid; ++y) {
						for (int x = 0; x < 5 && valid; ++x) {
							if (cocoon[y][x] != 1)
								valid = false;
						}
					}
					if (valid)
						++ans;
				} else {
					ans += solve(slit, cnt+1);
				}
			}
			for (int j = 0; j < 5; ++j)
				cocoon[j][cnt-5] -= (slit[i][j] - '0');


			if (!sameRev[i]) {
				bool rev = true;
				for (int j = 0; j < 5; ++j) {
					cocoon[j][cnt-5] += (slit[i][5-j-1] - '0');
					if (cocoon[j][cnt-5] != 1)
						rev = false;
				}

				if (rev) {
					if (cnt == 9) {
						bool valid = true;
						for (int y = 0; y < 5 && valid; ++y) {
							for (int x = 0; x < 5 && valid; ++x) {
								if (cocoon[y][x] != 1)
									valid = false;
							}
						}
						if (valid)
							++ans;
					} else {
						ans += solve(slit, cnt+1);
					}
				}
				for (int j = 0; j < 5; ++j)
					cocoon[j][cnt-5] -= (slit[i][5-j-1] - '0');
			}
			used[i] = false;
		}
	}
	return ans;
}

int main()
{
	vector<string> slit(10);
	while (cin >> slit[0]) {
		if (slit[0] == "END")
			break;

		for (int i = 1; i < 10; ++i)
			cin >> slit[i];

		for (int i = 0; i < 10; ++i) {
			string s = slit[i];
			reverse(s.begin(), s.end());
			if (slit[i] == s)
				sameRev[i] = true;
			else
				sameRev[i] = false;
		}

		for (int i = 0; i < 5; ++i) {
			for (int j = 0; j < 5; ++j)
				cocoon[i][j] = 0;
		}
		for (int i = 0; i < 10; ++i)
			used[i] = false;
		cout << (solve(slit, 0) >> 3) << endl;
	}
	return 0;
}

Measured memory_bytes: 916
class UnionFindTree:
    def __init__(self, n):
        self.__parents = [-1] * n

    def find(self, x):
        p = self.__parents
        if p[x] < 0:
            return x
        parent = self.find(p[x])
        p[x] = parent
        return parent

    def union(self, x, y):
        p = self.__parents
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if p[x] > p[y]:
            x, y = y, x
        p[x] += p[y]
        p[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.__parents[self.find(x)]


def spline(func_=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func_, iter_)


def main():
    n, m = spline()
    chains = UnionFindTree(n)
    f = lambda x: int(x) - 1
    bridges = [tuple(spline(func_=f)) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    for i in range(m - 2, -1, -1):
        x, y = bridges.pop()
        tmp = ans[i + 1]
        if not chains.same(x, y):
            tmp -= chains.size(x) * chains.size(y)
        chains.union(x, y)
        ans[i] = tmp
    print(*ans, sep='\n')


if __name__ == "__main__":
    main()


Measured memory_bytes: 20076
num = int(input())
a = "SHCD"
table = [[i,m] for i in a for m in range(1,14)]

for i in range(num):
    card = input().split()
    card[1] = int(card[1])
    table.remove(card)

for m in table:
    print("{0} {1}".format(m[0],m[1]))

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

const int N = 3009;
int n, a[N], dp[N][N][2];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];

    for(int len = 1; len <= n; ++len) {
        for(int i = 1; i <= n - len + 1; ++i) {
            int j = i + len - 1;
            if(i == j) {
                dp[i][i][0] = a[i];
                dp[i][i][1] = -a[i];
                continue;
            }
            dp[i][j][0] = max(a[i] + dp[i + 1][j][1], a[j] + dp[i][j - 1][1]);
            dp[i][j][1] = min(-a[i] + dp[i + 1][j][0], -a[j] + dp[i][j - 1][0]);
        }
    }
    cout << dp[1][n][0] << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

vl ans;
void dfs(ll x){
  ans.push_back(x);
  if(x > 3234566667) return;
  int a = x%10;
  dfs(x*10+a);
  if(a != 0) dfs(x*10+(a-1));
  if(a != 9) dfs(x*10+(a+1));
  return;
}

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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  bool ok = a[0] >= 0;
  rep(i,n-1){
    bool now = a[i+1] >= 0;
    ok = (ok == now);
  }
  ll sum = 0;
  vi b(n);
  rep(i,n) {
    b[i] = abs(a[i]);
    sum += b[i];
  }
  sort(all(b));
  int mn = b[0];
  if(ok) cout << sum << endl;
  else cout << sum-mn*2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << (N / 2) * (N - 2) << endl;
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (i + j != N + 1) {
					cout << i << " " << j << endl;
				}
			}
		}
	}
	else {
		cout << (N - 1 + (N - 1) * (N - 2)) / 2 << endl;
		int ct = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (i + j != N) {
					cout << i << " " << j << endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    string a, b, c;
    cin>>a>>b>>c;
    int an = a.size();
    int bn = b.size();
    int cn = c.size();

    printf("%c%c%c\n", a[0]-32, b[0]-32, c[0]-32);
    return 0;
}


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

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	
	long long ans = 0;
	for(int i = k; i <= n; i += k) ans++;
	ans = pow(ans, 3);
	
	//kが偶数ならば追加で計算する
	if(k % 2 == 0){
		long long ifEven = 0;
		for(int i = k/2; i <= n; i+=k) ifEven++;
		ans += pow(ifEven, 3);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

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

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    int l,r,d;
    cin >> l >> r >> d;
    cout << r/d - (l-1)/d<< endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check


void solve(long long N, long long K, std::vector<long long> A){
    REP(i, N){
        A[i] = (A[i]-1) % K;
    }
    vll B(N+1, 0);
    REP(i, N){
        B[i+1] = (B[i]+A[i]) % K;
    }
    map<ll, vll> mp;
    REP(i, N+1){
        if(!mp.count(B[i]))
            mp[B[i]] = vll(1, i);
        else
            mp[B[i]].push_back(i);
    }
    
    ll cnt = 0;
    for( auto it=mp.begin(); it != mp.end(); ++ it){
        if(it->second.size()>1){
            vll C = it->second;
            ll sz = C.size();
            //* shakutori
            ll s=0, t=0;
            while(s<sz){
                while(  C[t]-C[s] < K && t < sz){
                    t++;
                }
                cnt += max(0LL, (t-s-1));
                s++;
            }
        }
    }

    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
  int N;
  long long int h, n, w;

  if(argc == 2){
    N = atoi(argv[1]);
  }else
    cin >> N;

  for(h = 1; h < 3500; h++){
    for(n = h; n < 3500; n++){
      if((4*h*n - N*h - N*n) <= 0) continue;
      w = ((long long int)N*h*n)/(4*h*n - N*h - N*n);
      if(4*h*n*w == (long long int)N*(n*w + w*h + h*n)){
        printf("%ld %ld %ld\n", h, n, w);
        return 0;
      }
    }
  }
  cout << "error *****************************" << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> city(N,0);
    int x;
    int M;
    cin >> M;
    rep(i,2*M){
        cin >> x;
        city.at(x-1)++;
    }
    rep(i,N){
        cout << city.at(i) << endl;
    }
}   

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

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

ll lcm(ll a, int b) {
  return a / gcd(a, b) * b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll k = 1;
  for (int i = 0; i < n; i++) {
    k = lcm(k, a[i] / 2);
  }

  for (int i = 0; i < n; i++) {
    if (k % a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (m / k + 1) / 2 << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string,LL> m;
    LL n;
    cin>>n;
    REP(i,n){
        string s;
        cin>>s;
        SORT(s);
        m[s]++;
    }
    LL ans = 0;
    EACH(i,m){
        LL x = i->second;
        ans += x * (x-1) / 2;
    }
    PUTS(ans);
}

Measured memory_bytes: 11264
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll N,A,B; cin>>N>>A>>B;
    if(A>B){
        cout<<0<<endl;
        return 0;
    }
    ll mn=(N-1)*A+B;
    ll mx=(N-1)*B+A;
    if(mx>mn){
    cout<<mx-mn+1<<endl;
    }
    else if(mn==mx){
        cout<<1<<endl;
    }
    else cout<<0<<endl;
}



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

int main(){
  int N;
  cin >> N;
  if(N%10==9){
    cout << "Yes" << endl;
  }
  else if(N/10==9){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 2e5+5,MOD = 998244353;

int d[4*N];
int lazy_tag[4*N];
int combine(int a, int b){
	return (a+b)%MOD;
}

void modify(int pos, int val, int ind = 1, int l = 0, int r = N-1){
	if(l==r){
		d[ind] = val%MOD;
	}else{
		int mid = (l+r)/2;
		if(pos<=mid) modify(pos,val,ind<<1,l,mid);
		else modify(pos,val,ind<<1|1,mid+1,r);
		d[ind] = combine(d[ind<<1],d[ind<<1|1]);
	}
}

void apply(int ind, int val, int l, int r){
	if(ind>=0&&ind<4*N){
		d[ind] = (d[ind] + (r-l+1)*val%MOD)%MOD;
		lazy_tag[ind] = (lazy_tag[ind] + val%MOD)%MOD;
	}
}

void range_modify(int ml, int mr, int val, int ind = 1, int l = 0, int r = N-1){
	if(ml>r||mr<l) return;
	if(ml<=l&&mr>=r){
		d[ind] = (d[ind] + (r-l+1)*val%MOD)%MOD;
		lazy_tag[ind] = (lazy_tag[ind] + val%MOD)%MOD;
		return;
	}
	int mid = (l+r)/2;
	if(lazy_tag[ind]){
		apply(ind<<1, lazy_tag[ind], l, mid);
		apply(ind<<1|1, lazy_tag[ind], mid+1, r);
		d[ind] = combine(d[ind<<1],d[ind<<1|1]);
		lazy_tag[ind] = 0;
	}
	range_modify(ml,mr,val,ind<<1,l,mid);
	range_modify(ml,mr,val,ind<<1|1,mid+1,r);
	d[ind] = combine(d[ind<<1],d[ind<<1|1]);
}

int query(int ql, int qr, int ind = 1, int l = 0, int r = N-1){
	if(ql>r||qr<l) return 0;
	if(ql<=l&&qr>=r) return d[ind]%MOD;
	int mid = (l+r)/2;
	if(lazy_tag[ind]){
		apply(ind<<1, lazy_tag[ind], l, mid);
		apply(ind<<1|1, lazy_tag[ind], mid+1, r);
		d[ind] = combine(d[ind<<1],d[ind<<1|1]);
		lazy_tag[ind] = 0;
	}
	return combine(query(ql,qr,ind<<1,l,mid),query(ql,qr,ind<<1|1,mid+1,r));
}

vector<pair<int,int>> v;

signed main(){
	fastio
	int n,k;
	cin >> n >> k;
	while(k--){
		int l,r;
		cin >> l >> r;
		v.push_back({l,r});
	}
	int arr[n+1] = {};
	range_modify(1,1,1,1,1,n);
	for(int i = 1;i < n;i++){
		arr[i] = query(i,i,1,1,n);
		for(auto x : v){
			if(x.first+i>n) continue;
			range_modify(x.first+i,min(n,x.second+i),arr[i],1,1,n);
		}
	}
	cout << query(n,n,1,1,n) << "\n";
}

Measured memory_bytes: 13400
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
s_max = sum(s)

if s_max % 10 != 0:
    print(s_max)
    exit()
else:
    for i in s:
        if i % 10 != 0:
            print(s_max - i)
            exit()

print(0)

Measured memory_bytes: 2940
def main():
    n,m=map(int,input().split(' '))
    road = [[i for i in list(map(int,input().split(' ')))] for i in range(m)]
    ans = [0]*n
    for i,j in road:
        ans[i-1] += 1
        ans[j-1] += 1
    for i in ans:
        print(i)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#-*- coding:utf-8 -*-
from collections import deque

N, K = map(int, input().split())
V = [int(_) for _ in input().split()]

mn = min(N,K)   # 取り出せる個数
ans = 0
for a in range(mn+1):
    for b in range(mn+1-a):
        que = deque(V)
        have = []
        for i in range(a):  # 左からの取り出し
            have.append(que.popleft())
        for i in range(b):  # 右からの取り出し
            have.append(que.pop())
        have.sort() # 昇順ソート
        c = K - a - b   # c回まで除去可能
        neg = [v for v in have if v < 0]
        if len(neg) < c:
            ans = max(ans, sum(have[len(neg):]))
        else:
            ans = max(ans, sum(have[c:]))

print(ans)

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



int main() {
	ll N;
	cin >> N;
	int tmp;
	vector<ll>A(N);

	rep(0, N) {
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	rep(0, N) {
		
		if (i != 0) {
			if (tmp == A[i]) {
				cout << "NO" << endl;
				return 0;
			}
		}
		tmp = A[i];
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1792
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)
#define printM(a, n, m) F(i, 0, n){ FE(j, 0, m) cout << a[i][j] << (i==m?'\n':' ');}

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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

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

#define printMatrix(mat,n,m){ \
    F(i, 0, n){               \
        F(j, 0, m){           \
            cout << mat[i][j] << space;\
        }\
        cout << endl;\
    }\
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    long n;
    long W;
    long weight[110];
    long value[110];
    // dp table start from 1? no, we use idex 0
    vector< vector<ll> > dp(110, vector<long long>(100010));
    cin >> n;
    cin >> W;
    //remark: index start from 1
    FE(i, 1, n){
        long index = i;
        cin >> weight[index] >> value[index];
    }
    FE(i, 1, n){
        FE(w, 1, W){
            chmax(dp[i][w], dp[i-1][w]);
            if(weight[i] <= w){
                chmax(dp[i][w], dp[i-1][w-weight[i]] + value[i]);
            }
        }
    }
    ll ans = dp[n][W];
#if TST==1
    printMatrix(dp, n+2, W+2);
#endif
    cout << ans << endl;
}


Measured memory_bytes: 87296
#include<iostream>
#include<map>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    int n,a;
    cin>>n;
    map<int,int> x;
    rep(i,n){
        cin>>a;
        x.insert(make_pair(a,i+1));
    }
    for(auto p:x) cout<<p.second<<" ";

    return 0;
}

Measured memory_bytes: 5504
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e6+10;

string pw[50];

bool restore(string S,string T,int idx,string& p){
	int ls=S.size(), lt=T.size();
	p=S;
	for(int i=0;i<idx;i++){
		if(S[i]=='?'){
			p[i]='a';
		}
	}
	for(int i=idx;i<idx+lt;i++){
		if(S[i]=='?'){
			p[i]=T[i-idx];
		}
		if(S[i]!='?' && S[i]!=T[i-idx]){
			return false;
		}
	}
	for(int i=idx+lt;i<ls;i++){
		if(S[i]=='?'){
			p[i]='a';
		}
	}
	return true;
}

int main(){
	string S,T,P;
	cin>>S>>T;
	int ls=S.size(), lt=T.size();

	int cur=0;
	for(int i=0;i<=ls-lt;i++){
		if(restore(S,T,i,P)){
			pw[cur]=P;
			cur++;
		}
	}

	if(cur){
		sort(pw,pw+cur);
		cout<<pw[0]<<endl;
	}
	else{
		cout<<"UNRESTORABLE\n";
	}

	return 0;
}

Measured memory_bytes: 256