akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int N; cin>>N;
    int V[30],C[30];
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        if(V[i]-C[i]>0){
            ans+=V[i]-C[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DFaceProducesUnhappiness {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      string s; cin >> s;
      int ans = 0;
      rep(i, n-1) {
        if (s[i] == s[i+1]) {
          ans++;
        }
      }
      cout << min(n-1, ans+(2*k)) << endl;
    }
};

signed main() {
  DFaceProducesUnhappiness solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    int check;
    scanf("%d",&n);
    if(n<3||10000<n){
        return 0;
    }
    int i=1;
    int x,x2;
    for(i=1;i<=n;i++){
        x=i;
        x2=x/10;
        if(x%3==0){
            printf(" %d",i);
        }
        else if(x%10==3){
            printf(" %d",i);
        }
        else{
            check=1;
            while(check==1){
                x2=x/10;
                x=x2;
                if(x2>0){
                    if(x2%10==3){
                        printf(" %d",i);
                        check=0;
                    }
                }
                else{
                    check=0;
                }
            }
            
            
        }
    
        
    }
    printf("\n");
}


Measured memory_bytes: 2104
import sys
sys.setrecursionlimit(10**9)
T=int(input())

def dfs(n):
  if n in dic:
    return dic[n]  
  
  m2=n%2
  if m2==0:
    score_a1=A+dfs(n//2)
    score_a2=A+dfs(n//2)
  else:
    score_a1=m2*D+A+dfs((n-m2)//2)
    score_a2=m2*D+A+dfs((n+(2-m2))//2)

  m3=n%3
  if m3==0:
    score_b1=B+dfs(n//3)
    score_b2=B+dfs(n//3)
  else:
    score_b1=m3*D+B+dfs((n-m3)//3)
    score_b2=(3-m3)*D+B+dfs((n+(3-m3))//3)

  m5=n%5
  if m5==0:
    score_c1=C+dfs(n//5)
    score_c2=C+dfs(n//5)
  else:
    score_c1=m5*D+C+dfs((n-m5)//5)
    score_c2=(5-m5)*D+C+dfs((n+(5-m5))//5)

  score_d=n*D
  ret=min(score_a1,score_a2,score_b1,score_b2,score_c1,score_c2,score_d)
  dic[n]=ret
  return ret

for _ in range(T):
  N,A,B,C,D=map(int,input().split())
  dic={0:0,1:D}
  answer=dfs(N)
  print(answer)

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

int main(){
    string S; cin>>S;
    sort(S.begin(), S.end());

    if(S[0]==S[1] && S[2]==S[3] && S[0] != S[2]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;
struct BIT{
	int a[100010];
	void init(){
		memset(a,0,sizeof(a));
	}
	int lowbit(int x){
		return x&(-x);
	}
	void add(int x,int val){
		for(;x<=n;x+=lowbit(x)) a[x]+=val;
	}
	int sum(int x){
		int re=0;
		for(;x>0;x-=lowbit(x)) re+=a[x];
		return re;
	}
}T;
int a[100010][3],rev0,rev1,anti0,anti1;
//rev: ×Ô×ªµÄ´ÎÊý
//anti: ÄæÐò¶Ô 
int main(){
	n=read();int i,tmp;
	for(i=1;i<=n;i++) a[i][0]=read();
	for(i=1;i<=n;i++) a[i][1]=read();
	for(i=1;i<=n;i++) a[i][2]=read();
	for(i=1;i<=n;i++){
		if((a[i][0]%3==0&&a[i][1]==a[i][0]-1&&a[i][2]==a[i][1]-1)||(a[i][2]%3==0&&a[i][0]==a[i][1]-1&&a[i][1]==a[i][2]-1)) continue;
		puts("No");return 0;
	}
//	cout<<"pass availability test\n";
	T.init();
	for(i=1;i<=n;i+=2){
		if(a[i][0]%3==0) rev1++,tmp=a[i][0]/3;
		else tmp=a[i][2]/3;
		if((tmp&1)==0){
			puts("No");return 0;
		}
		anti1+=((i+1)>>1)-T.sum(tmp-1)-1;
		T.add(tmp,1);
	}
	T.init();
	for(i=2;i<=n;i+=2){
		if(a[i][0]%3==0) rev0++,tmp=a[i][0]/3;
		else tmp=a[i][2]/3;
		if((tmp&1)==1){
			puts("No");return 0;
		}
		anti0+=(i>>1)-T.sum(tmp-1)-1;
		T.add(tmp,1);
	}
//	cout<<anti0<<' '<<rev0<<' '<<anti1<<' '<<rev1<<'\n';
	if((rev1&1)==(anti0&1)&&(rev0&1)==(anti1&1)) puts("Yes");
	else puts("No");
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define MIN INT_MIN
#define MAX INT_MAX
#define PB push_back
#define MP make_pair
#define rep(j,n,jj) for(int i=j;i<n;i+=jj)
#define modd 1000000007
using namespace std;
void solve();
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    time_t start,end;
    time(&start);
    solve();
    time(&end);
    double t= double(end - start); 
/*    cout << fixed */
/*         << t<< setprecision(5)<<endl;*/
    return 0; 
}

void solve(){
	int r;
	cin>>r;
	cout<<2*M_PI*r<<"\n";
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n, m;
	int t_point, t_sum, h_point, h_sum;
	int deffer;
	while( 1 ){
		t_sum = 0;
		h_sum = 0;
		t_point = -1;
		h_point = -1;
		cin >> n >> m;
		vector<int> t(n);
		vector<int> h(m);
		if( n == 0 && m == 0 ) break;
		for( int i = 0; i < n; i++ ){
			cin >> t[i];
			t_sum += t[i];
		}
		for( int i = 0; i < m; i++ ){
			cin >> h[i];
			h_sum += h[i];
		}
		for( int i = 0; i < n; i++ ){
			for( int j = 0; j < m; j++ ){
				if( t_sum - h_sum == 2 * ( t[i] - h[j] ) && deffer > t_point + h_point ){
					t_point = t[i];
					h_point = h[j];
					deffer = t_point + h_point;
				}
			}
		}
		if( t_point == -1 ){
			cout << -1 << endl;
		}else{
			cout << t_point << ' ' << h_point << endl;
		}
		t.clear();
		h.clear();
	}
}

Measured memory_bytes: 1200
import sys
a = sys.stdin.readline().rstrip()
if a == 'SUN':
  print(7)
elif a == 'MON':
  print(6)
elif a == 'TUE':
  print(5)
elif a == 'WED':
  print(4)
elif a == 'THU':
  print(3)
elif a == 'FRI':
  print(2)
else:
  print(1)


Measured memory_bytes: 2940
n = int(input())
s = ['' for i in range(n)]
for i in range(n):
    s[i] = sorted(input())
ss = sorted(s)

ans = 0
i = 0
while i < n-1:
    if i < n-1 and ss[i] == ss[i+1]:
        count = 2
        if i < n-2 and ss[i+1] == ss[i+2]:
            i+=1
            while i < n-1 and ss[i] == ss[i+1]:
                count+=1
                i+=1
            i-=1
        ans+=(count*(count-1)//2)
    i+=1
print(ans)

Measured memory_bytes: 25480
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            double ans;
            if (A * A * B / 2 < C)
            {
                ans = A * A * B - C;
                ans /= (double)(A * A * A);
                ans *= 2;

                Console.WriteLine(Math.Atan(ans) * 180 / Math.PI);
            }
            else
            {
                ans = 2 * C;
                ans /= (double)(A * B * B);

                Console.WriteLine((Math.PI / 2 - Math.Atan(ans)) * 180 / Math.PI);
            }


        }
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;



int main() {
  ll n; cin >> n;
  cout << n * n;
  return 0;
}

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

int main(){

	int h,w,n;cin>>h>>w;cin>>n;
	vector<int>a(n);
	for(auto&& w:a)cin>>w;
	int hw[h][w];
	fill(hw[0],hw[h],0);
	int x=0,y=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<a[i];j++){
		 
			hw[x][y]=(i+1);
     //     	cerr<<x<<" "<<y<<" "<<i+1<<endl;
			if((y==0 && x%2==1)||(y==w-1 && x%2==0))++x;
			else if (x%2==0) ++y;
			else         --y;
	}	
}
	for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){	
		cout<<hw[i][j]<<" ";
	}
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e,f;
	double x=0,y=0;
	
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		x=1000*(c*e-f*b)/(a*e-d*b);
		y=1000*(a*f-d*c)/(a*e-d*b);
		if(x>0)
		{
			x=(int)(x+0.5);
		}
		else
		{
			x=(int)(x-0.5);
		}
		if(y>0)
		{
			y=(int)(y+0.5);
		}
		else
		{
			y=(int)(y-0.5);
		}
		
		printf("%.3f %.3f\n",x/1000,y/1000);
	}
	
	return 0;
}

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

int main() {
	int N;
	while(cin >> N, N) {
		vector<vector<int> > v;
		v.resize(N);
		for(int i = 0; i < v.size(); i++) {
			v[i].resize(N);
			for(int j = 0; j < v[i].size(); j++)
				v[i][j] = 0;
			int M;
			cin >> M;
			for(int j = 0; j < M; j++) {
				int p;
				cin >> p; p--;
				v[i][p] = 1;
			}
		}
		vector<int> l;
		int K;
		cin >> K;
		for(int i = 0; i < K; i++) {
			int tmp;
			cin >> tmp; tmp--;
			l.push_back(tmp);
		}

		int res = -1;
		int cnts = 0;
		for(int i = 0; i < v.size(); i++) {
			int flg = true;
			for(int j = 0; j < l.size(); j++) {
				if(v[i][l[j]] == 0) flg = false;
			}
			if(flg) {
				res = i;
				cnts++;
			}
		}
		if(cnts == 1)
			cout << res+1 << endl;
		else
			cout << -1 << endl;
	}
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vector<tuple<string,int,int>> res(n+1);
    rep(i,n){
        cin>>get<0>(res[i])>>get<1>(res[i]);
        get<2>(res[i])=i+1;
    }
    get<0>(res[n])="zzzzzzzzzzz";
    get<1>(res[n])=101;
    get<2>(res[n])=n+1;
    sort(all(res));
    stack<tuple<string,int,int>> ans;
    rep(i,n){
        ans.push(res[i]);
        if(get<0>(res[i])!=get<0>(res[i+1])){
            while(!ans.empty()){
                cout<<get<2>(ans.top())<<endl;
                ans.pop();
            }
        }
    }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   ll n; scanf("%lld",&n);
   ll coeff=1,res=0;
   while(n){
      res+=coeff;
      n/=2; coeff*=2;
   }
   printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 256
n = int(input())
value_list = list(int(x) for x in input().split())
cost_list = values = list(int(x) for x in input().split())
sum_v = 0
sum_c = 0

for i in range(n):
    if value_list[i] > cost_list[i]:
        sum_v += value_list[i]
        sum_c += cost_list[i]
    else:
        pass

ans = sum_v - sum_c
print(ans)

Measured memory_bytes: 3064
while True:
    num = input()
    if int(num) == 0: break
    if len(set(num)) == 1:
        print("NA")
        continue
    cnt = 0
    while num != "6174":
        cnt += 1
        L = ''.join(sorted(num))
        S = ''.join(reversed(sorted(num)))
        num = str(int(S) - int(L)).zfill(4)
    print(cnt)


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

int main() {
	int n;
	cin>>n;
	int dp[n][3]={0};
	int a[n][3];
	
	for(int i=0;i<n;i++)
	for(int j=0;j<3;j++)cin>>a[i][j];
	
	dp[n-1][0]=max(a[n-1][1],a[n-1][2]);
	dp[n-1][1]=max(a[n-1][0],a[n-1][2]);
	dp[n-1][2]=max(a[n-1][1],a[n-1][0]);
	
	for(int i=n-2;i>=0;i--)
	{
	    dp[i][0]=max(a[i][1]+dp[i+1][1],a[i][2]+dp[i+1][2]);
	    dp[i][1]=max(a[i][0]+dp[i+1][0],a[i][2]+dp[i+1][2]);
	    dp[i][2]=max(a[i][1]+dp[i+1][1],a[i][0]+dp[i+1][0]);
	}
	int ans=max(dp[0][0],max(dp[0][1],dp[0][2]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string S;


signed main(){
    cin >> S;

    if(S[2] == S[3] and S[4] == S[5]) Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main()
{
long long int a=0,b=0,w=0,flag,i,str1=0,str2=0;

scanf("%lld%lld%lld",&w,&a,&b);
if(abs(a-b)<=w)
{
printf("0");
}
else{
    printf("%lld",abs(a-b)-w);
}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void) {
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  int maxa = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] > maxa) maxa = a[i];
  }
  int ans = 0;
  sort(b.begin(), b.end(), greater<int>());
  for (int i = 0; i < n; i++) {
    if (b[i] > maxa && h > 0) {
      h -= b[i];
      ans++;
    }
  }
  if (h > 0) {
    ans += (h + maxa - 1) / maxa;
  }
  cout << ans << endl;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  char x, y;
  cin >> x >> y;
  if (x == y) cout << "=";
  else if (x < y) cout << "<";
  else cout << ">";
}

int main()
{
  fastio;
  solve();

  return 0;
}

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



int main(){
  int n;
  cin>>n;
  vector<int>s(30,52);
  vector<int>kari(30,0);
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    for(int j=0;j<t.size();j++){
      kari.at(t.at(j)-'a')++;
    }
    for(int j=0;j<27;j++){
      s.at(j)=min(s.at(j),kari.at(j));
      kari.at(j)=0;
    }
  }
  for(int i=0;i<26;i++){
    int S=s.at(i);
    for(int j=0;j<S;j++){
      cout << char(i+'a');
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
 
int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));

  REP(y, h)REP(x, w) cin >> grid[y][x];

  function<bool(int, int)> check = [&](int y, int x) {
    return y >= 0 && y < h && x >= 0 && x < w;
  };

  REP(y, h)REP(x, w){
    if(grid[y][x] == '#'){
      bool flag = false;
      REP(i, 4){
        if(check(y + dy[i], x + dx[i])){
          flag |= grid[y + dy[i]][x + dx[i]] == '#';
        }
      }
      if(!flag){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) cin>>a[i];
  set<int>s;
  rep(i,n) s.insert(a[i]);
  if(s.size()==n)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

typedef long long ll;
const int MAX_N = 100000;

int main() {
	int N;
	ll H, a[MAX_N], b[MAX_N];

	std::cin >> N >> H;
	for(int i = 0; i < N; ++i) {
		std::cin >> a[i] >> b[i];
	}
	std::sort(a, a + N, std::greater<ll>());
	std::sort(b, b + N, std::greater<ll>());

	ll max_a = a[0], ans = 0;
	for(int i = 0; i < N; ++i) {
		if(H > 0 and b[i] >= max_a) {
			H -= b[i];
			++ans;
		} else break;
	}
	if(H > 0) {
		ans += H / max_a;
		if(H % max_a > 0) ++ans;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<int> uset;

int main( int argc, char* argv[] ){
  int N;
  cin >> N;
  vector<int> P(N,0);
  for( int i=0; i<N; ++i ){
    cin >> P[i];
  }
  vector<bool> check(N,false);
  set<int> buf;
  for( int i=0; i<N; ++i ){
    if( buf.count( P[i]+1 ) == 0 ){
      check[P[i]-1] = true;
    }
    buf.insert( P[i] );
  }
  vector<int> cnt(N,0);
  for( int i=N-2; i>=0; --i ){
    if( check[i] ){
      cnt[i] = cnt[i+1]+1;
    }
  }
  for( int i=1; i<=N; ++i ) cerr << i; cerr << endl;
  for( auto b : check ) cerr << b ? "o" : "x"; cerr << endl;
  for( auto x : cnt ) cerr << x; cerr << endl;
  int tmp = *max_element( cnt.begin(), cnt.end() );
  cout << (N-tmp-1) << endl;
  return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N = 0, K = 0, ans = 0;
	int h[100000] = { 0 };
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (h[i] >= K) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	ll n;
	slld(n);
	ll ans = (powmod(10,n)-2*powmod(9,n))%MOD;
	ans=(ans+MOD)%MOD;
	ans=(ans+powmod(8,n))%MOD;
	cout<<ans;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans = "";
		if(a <= b) {
			for(int i = 0; i < b; i++) {
				ans += Integer.toString(a);
			}
		} else {
			for(int i = 0; i < a; i++) {
				ans += Integer.toString(b);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23252
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), max = sc.nextInt(), min_cost = 1001;
        int[] c = new int[n], t = new int[n];
        for(int i = 0; i < n; i++){
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
        }
        for(int j = 0; j < n; j++){
        	if(t[j] <= max)
        		min_cost = Math.min(min_cost, c[j]);
        }
        System.out.println(min_cost == 1001 ? "TLE" : min_cost);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define mid ((l+r)>>1)
using namespace std;
const int inf=0x3f3f3f3f;
const int N=200005;
int T[N<<2],tag[N<<2],n,a[N],sum0[N],sum1[N],Q,head;
struct node{int l,r;}q[N];
bool operator < (const node &A,const node &B)
{return A.l<B.l||A.l==B.l&&A.r<B.r;}
void down(int k)
{
  if (tag[k])
  { 
    tag[k<<1]+=tag[k];tag[k<<1|1]+=tag[k];
    T[k<<1]+=tag[k];T[k<<1|1]+=tag[k];
    tag[k]=0;
  }
}
void ins(int k,int l,int r,int x,int y)
{
  if (l==r) {T[k]=min(T[k],y);return;}
  down(k);
  if (x<=mid) ins(k<<1,l,mid,x,y);
  else ins(k<<1|1,mid+1,r,x,y);
  T[k]=min(T[k<<1],T[k<<1|1]);
}
void add(int k,int l,int r,int L,int R,int x)
{
   if (L<=l&&r<=R) {T[k]+=x;tag[k]+=x;return;}
   down(k);
   if (L<=mid) add(k<<1,l,mid,L,R,x);
   if (R>mid) add(k<<1|1,mid+1,r,L,R,x);
   T[k]=min(T[k<<1],T[k<<1|1]);
}
int qry(int k,int l,int r,int L,int R)
{
   if (L<=l&&r<=R) return T[k];
   down(k);int ans=inf;
   if (L<=mid) ans=min(ans,qry(k<<1,l,mid,L,R));
   if (R>mid) ans=min(ans,qry(k<<1|1,mid+1,r,L,R));
   return ans;
}
int main()
{
  scanf("%d",&n);
  for (int i=1;i<=n;i++) 
  {
     scanf("%d",&a[i]);sum0[i]=sum0[i-1];sum1[i]=sum1[i-1];
     if (!a[i]) sum0[i]++;else sum1[i]++;
  }
  scanf("%d",&Q);
  for (int i=1;i<=Q;i++) scanf("%d%d",&q[i].l,&q[i].r);
  sort(q+1,q+Q+1);
  head=1;memset(T,inf,sizeof(T));
  ins(1,0,n,0,0);
  for (int i=1;i<=n;i++)
  {
    while (head<=Q&&q[head].l==i) ins(1,0,n,q[head].r,qry(1,0,n,0,q[head].r)),head++;
    if (a[i]) add(1,0,n,0,i-1,1);else add(1,0,n,0,i-1,-1);
  }
  printf("%d\n",qry(1,0,n,0,n)+sum0[n]);
  return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n, m; scanf("%lld %lld", &n, &m);
	ll res = min(n, m / 2);
	if(2 * n < m) res += (m - 2 * n) / 4;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, d;
    cin >> n >> d;
    cout << ((n + (2 * d)) / (2 * d + 1)) << endl;
    return 0;
}


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

int m[100][101];
int dp[101][100][100];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        m[i][0] = 0;
        for(int j = 1; j <= n; j++){
            cin >> m[i][j];
            m[i][j] += m[i][j-1];
        }
    }
    int max_v = -10000000;
    for(int i = 0; i < n; i++){
        for(int k = 0; k < n; k++){
            for(int j = 0; j <= k; j++){
                dp[i+1][j][k] = m[i][k+1] - m[i][j];
                dp[i+1][j][k] = max(dp[i+1][j][k],
                                    dp[i][j][k] + dp[i+1][j][k]);
                if( dp[i+1][j][k] > max_v ) max_v = dp[i+1][j][k];
            }
        }
    }
    cout << max_v << endl;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

vector<int>c;
int d;vector<vector<int>>s;
vector<int>last;
int calc(int t,int day){
       int k=0;
        k+=s[day][t];
        last[t]=day+1;
        for (int j = 0; j < 26; ++j)k-=c[j]*(day+1-last[j]);
        return k;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin >>d;
    c.resize(26);
    for (int i = 0; i <26; ++i) cin >>c[i];
    s.assign(d,vector<int>(26));
    for (int i = 0; i < d; ++i)for (int j = 0; j < 26; ++j) cin >>s[i][j];
    int score=0;
    last.assign(26,0);
    vector<int>t(d);
    for (int day = 0; day < d; ++day) {
        int now=-INF;
        for (int i = 0; i < 26; ++i) {
           if(now<calc(i,day)){
               now=calc(i,day);
               t[day]=i+1;
           }
        }
        score+=now;
    }
    for (int i = 0; i < d; ++i) {
        cout<<t[i]<<endl;
    }
//    cout <<score<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
const int val[]={0,1,2,6,24,120,720,5040};
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	int n,a[10],b[10];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&b[i]);
	int a_=0;
	reverse(a,a+n);
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		for(int j=i-1;j>=0;j--)
			cnt+=(a[i]>a[j]);
		a_+=(cnt*val[i]);
	}
	int b_=0;
	reverse(b,b+n);
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		for(int j=i-1;j>=0;j--)
			cnt+=(b[i]>b[j]);
		b_+=(cnt*val[i]);
	}
	int ans=abs(a_-b_);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}



ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den=den*i%MOD;
  ll num=1;
  while(K--){
    num=num*N%MOD;
    N--;
  }
  return num*minv(den,MOD)%MOD;
}

ll n,a,b;

int main(){FAST;
cin>>n>>a>>b;
ll tot = mpow(2LL,n,MOD)-1;
tot+=MOD;
tot%=MOD;


tot-=ncr(n,a);
tot+=MOD;
tot%=MOD;

tot-=ncr(n,b);
tot+=MOD;
tot%=MOD;

cout<<tot;

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int a[7],b,x,y,z,c[7];
	
	for(int i=0;i<6;i++){
		
		scanf("%d",&a[i]);
		c[i]=a[i];
	}
	scanf("%d",&b);
	
	for(int i=0;i<b;i++){
		///a????????¨?????????///
		for(int i=0;i<6;i++){
			a[i]=c[i];
		}
		
		scanf("%d %d",&x,&y);
		
		
		/////////??????x?????????/////////
		
		for(int i=0;x!=a[0];i++){
			if(i==4) break;
			z=a[0];
			a[0]=a[4];
			a[4]=a[5];
			a[5]=a[1];
			a[1]=z;
		}
		if(x!=a[0]){
			for(int i=0;x!=a[0];i++){
				if(i==4) break;
				z=a[0];
				a[0]=a[2];
				a[2]=a[5];
				a[5]=a[3];
				a[3]=z;
			}
		}
		//printf("%d\n\n",a[0]);
		
		/////////?????????y?????????/////////
		
		for(int i=0;y!=a[1];i++){
			if(i==4) break;
			
			z=a[1];
			a[1]=a[3];
			a[3]=a[4];
			a[4]=a[2];
			a[2]=z;
		}
		//printf("%d\n\n",a[1]);
		
		printf("%d\n",a[2]);
	}
	return 0;
}
	

Measured memory_bytes: 2696
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string str;
    cin >> str;
    char c[2] = {0};
    c[0] = str[0];
    int f = 1,s = 1;
    bool flg = false;
    for(int i = 1;i < 4;i++){
        if(c[0] != str[i]){
            if(c[1] == '\0'){
                c[1] = str[i];
            }else if(c[1] != str[i]){
                flg = true;
                break;
            }else{
                s++;
            }
        }else{
            f++;
        }
        if( f > 2 || s > 2){
            flg = true;
            break;
        }
        
    }
    
    if(flg){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
l=L()
q=N()
ans=sum(l)
import collections
c=collections.Counter(l)
for i in range(q):
    B,C=NM()
    bi=c[B]
    ans+=bi*(C-B)
    print(ans)
    c[B]=0
    c[C]+=bi

Measured memory_bytes: 23720
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b;
    cin>>a>>b;
    int ret = b;
    for (int i = 0; i < a-1; ++i)
    {
        ret*=b-1;
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(x) for x in input().split()]

if(n<3):
    print(0)
    exit()
l.sort(reverse=True)
ln = len(l)
cnt = 0
for i in range(ln):
    for j in range(i+1,ln):
        for k in range(j+1,ln):
            a,b,c = l[i],l[j],l[k]
            if(a==b or b==c or a==c):
                continue
            if(a<(b+c)):
                cnt += 1

print(cnt)

Measured memory_bytes: 9184
import sys

def is_harshad_number(x):
    return not x % sum(list(map(int, list(str(n)))))

n = int(sys.stdin.readline().rstrip())

def main():
    return 'Yes' if is_harshad_number(n) else 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD = 1e9 + 7;



int main(){
  int w,h,k,ans=10101010;
  string s[11];
  cin>>h>>w>>k;rep(i,h){cin>>s[i];}
  rep(b,1<<(h-1)){
    int c[11]={},sum=0;
    bool success=1;
    rep(i,w){
      bool f=0,f1=0;
      int c2[11]={},n=0;
      rep(j,h){
        c2[n]+=s[j][i]-'0';
        c[n]+=s[j][i]-'0';
        if(c2[n]>k){
          f1=1;
          break;
        }
        if(c[n]>k){
          f=1;
        }
        if(b&(1<<j))n++;
      }
      if(f1){
        success=0;
        break;
      }
      if(f){
        sum++;
        rep(j,h){
          c[j]=c2[j];
        }
      }
      f1=0;
    }
    
    rep(i,h-1){
      if(b&(1<<i))sum++;
    }
    if(success)MIN(ans,sum);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
N,S=map(int,input().split())
A= list(map(int,input().split()))
mod=998244353
c=0
M=[[0 for t in range(S+1)] for j in range(N)]
M[0][0]=2
if A[0]<=S:
 M[0][A[0]]=1
if A[0]==S:
 c+=1
for i in range(1,N):
 M[i][0]+=(i+2)
 for k in range(1,S+1):
  M[i][k]+=M[i-1][k]
  M[i][k]%=mod
  if k>=A[i] :
   M[i][k]+=M[i-1][k-A[i]]
   M[i][k]%=mod
 c+=M[i][S]
 c%=mod
print(c)


Measured memory_bytes: 120156
#include <bits/stdc++.h>
using namespace std;
/* 
   kD_Tree
   build:O(n log^2(n))
   search:O(n^(1-1/K)+A)
   K:次元数 A:領域に含まれる点の数
*/


class KDT{
public:
  typedef long long ll; /*型に注意!!!!*/
  struct node{
    vector<ll> point;
    int l,r;
    node(){}
    node(vector<ll> point):point(point){l=r=-1;}
  };
  int K;// K:次元数
  vector<vector<ll> > P;// それぞれの要素はK+1個(各次元の値と固有ID)
  vector<node> G;
  int ok = 0;

  KDT(int K=2):K(K),ok(0){};
  
  void add_point(vector<ll> a/*座標*/){ 
    static int id = 0;
    if((int)a.size() < K+1) a.push_back(id++);
    assert((int)a.size() == K+1);
    P.push_back(a);
  }
  
  int build(int depth=0,int l=0,int r=-2){
    if(r == -2) r = (int)P.size()-1,ok = 1;
    if(l>r) return -1;
    int D=depth%K; // D:ソートする基準の次元
    sort(P.begin()+l,P.begin()+r+1,[&](const vector<ll> &A,const vector<ll> &B){return A[D]<B[D];});

    int m=(l+r)/2,res=G.size();
    G.push_back(node(P[m]));
    int vl=build(depth+1,l,m-1);
    int vr=build(depth+1,m+1,r);
    G[res].l=vl; G[res].r=vr;
    return res;
  }

  vector<vector<ll> > points;//searchの座標集合と固有ID
  void search(int x,int depth,const vector<ll> &ld,const vector<ll> &ru){
    if(P.empty()) return;
    bool f=true;
    for(int i=0;i<K;i++)
      if(G[x].point[i]<ld[i]||ru[i]<G[x].point[i]) f=false;
    
    if(f) points.push_back(G[x].point);
    
    int D = depth%K;// D:ソートする基準の次元
    if(G[x].point[D]<=ru[D]&&G[x].r!=-1) search(G[x].r,depth+1,ld,ru);
    if(ld[D]<=G[x].point[D]&&G[x].l!=-1) search(G[x].l,depth+1,ld,ru);
  }

  
  //[0,K)の要素が座標,K番目の要素が固有IDになっている。
  vector<vector<ll> > search(vector<ll> ld/*左下*/,vector<ll> ru/*右上*/){
    assert(ok);
    points.clear();
    search(0,0,ld,ru);
    return points;
  }
};

int main(){
  int n;
  cin>>n;

  KDT kdt;
  for(int i=0;i<n;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    kdt.add_point({x,y});
  }

  kdt.build();
  int q;
  cin>>q;
  while(q--){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    auto point = kdt.search({a,c},{b,d});
    vector<int> ans;
    for(auto &p:point) ans.push_back(p.back());
    sort(ans.begin(),ans.end());
    for(int i=0;i<(int)ans.size();i++) printf("%d\n",ans[i]);
    printf("\n");
  }
  
}



Measured memory_bytes: 60088
#![allow(non_snake_case)]
// 解説を見た。
use proconio::input;
// use std::collections::HashMap;

fn calc(_N: i64, _M: i64, _Q: i64, abcds: &[(i64, i64, i64, i64)], As: &[i64]) -> i64 {
    return abcds
        .iter()
        .map(|(a, b, c, d)| if As[*b as usize - 1] -
            As[*a as usize - 1] == *c
        {
            *d
        } else {
            0
        })
        .sum();
}

fn main() {
    input! {
        N: i64,
        M: i64,
        Q: i64,
        abcds: [(i64, i64, i64, i64); Q],
    }

    // Mが少ないから、全探索いけるのでは?
    // 単調非減少 10^10くらい? 間に合わじ
    // → 全探索で間に合うらしいです。まじ?

    // 数学の問題だね、重複ありの組み合わせは「しきり」を使って考える
    // 1 ||||| 2 3 4 5 6 7 8 9 ... (M-1)
    // (M + N - 1)_C_N
    // 最大で19C10 → 10万くらい これなら間に合うわー

    // うっ、どうやって書くんだ?
    // しきりを挟むindexをPsで表現する
    let mut stack: Vec<Vec<i64>> = Vec::new();
    stack.push(Vec::new());

    let mut ans = 0i64;

    // スタックからpopして、N個に満たなかったら単調非減少を維持しつつ新しい値をpushする
    while !stack.is_empty() {
        let top = stack.pop().unwrap();

        let len = top.len();
        if len == N as usize {
            // 解決フェーズ
            let As: Vec<i64> = top.iter()
                .enumerate()
                .map(|(ind, &val)| val - ind as i64 + 1)
                .collect();
            let score = calc(N, M, Q, &abcds, &As);

            if score > ans {
                ans = score;
            }
        } else {
            // 追加フェーズ
            let tail: Option<&i64> = if len == 0 { None } else { top.get(len - 1) };
            for i in (*tail.unwrap_or(&-1) + 1)..(N + M - 1) {
                // 新しい配列を生成する点に注意
                let mut new = top.clone();
                new.push(i);
                stack.push(new);
            }
        }

    }

    println!("{}", ans);
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>

int main()
{
	double x;
	cin >> x;
	for (double a = -1000; a < 1000; a++)
	{
		for (double b = -1000; b < 1000; b++)
		{
			if (pow(a, 5) - pow(b, 5) == x)
			{
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    vector<int> v(5);
    rep(i, 5) cin >> v[i];

    int ans = 1001001001;
    rep(i, 5)
    {
        int res = 0;
        rep(j, 5)
        {
            if (i == j)
            {
                res += v[j];
            }
            else
            {
                res += (v[j] + 9) / 10 * 10;
            }
        }
        ans = min(res, ans);
    }

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


Measured memory_bytes: 3624
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007



void Solve()
{
	int n;
	cin>>n;
	
	ll sum=0;
	f(i,1,n)
	{
		if(i%3 !=0 && i%5!=0 ) sum+=i;
	}
	cout<<sum;
}


signed main() 
{
	speed		
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	Solve();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3692
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class program{
    public static void Main(){
        while(true){
            var n = int.Parse(Console.ReadLine());
            if(n == 0) break;
            var s = Console.ReadLine().Split(' ').Select(_ => double.Parse(_)).ToList();
            var m = s.Sum()/n;
            var sd = s.Select(value => (value - m) * (value - m)).Sum()/n;

            Console.WriteLine(Math.Sqrt(sd));
        }
    }
}



Measured memory_bytes: 18340
N = gets.to_i
V = Array.new(N+1).map{Array.new}
(N-1).times{
  a, b, c = gets.chomp.split(" ").map(&:to_i)
  V[a] << [b, c]
  V[b] << [a, c]
}
Q, K = gets.chomp.split(" ").map(&:to_i)
q = []
Q.times{
  q << gets.chomp.split(" ").map(&:to_i)
}

C = Array.new(N+1)
C[K] = 0
bef = [K]
until bef.empty? do
  nxt = []
  bef.each{|a|
    V[a].each{|b, c|
      if C[b].nil? || C[b] > (c+C[a]) then
        C[b] = c+C[a]
        nxt << b
      end
    }
  }
  bef = nxt
end

puts q.map{|x, y| C[x] + C[y]}.join("\n")


Measured memory_bytes: 33972
import java.util.Scanner;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int X = scan.nextInt();
    int Y = scan.nextInt();
    scan.close();
    
    int[] scores = {0,300000,200000,100000};
    int score_x = X<=3 ? scores[X] : 0;
    int score_y = Y<=3 ? scores[Y] : 0;
    int add = X==1&&Y==1 ? 400000 : 0;
    System.out.println(score_x + score_y + add);
  }
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;
    vector<string> s(n);

    rep(i, n) cin >> s[i];

    map<char, int> mp;
    mp['M'] = 0;
    mp['A'] = 1;
    mp['R'] = 2;
    mp['C'] = 3;
    mp['H'] = 4;

    vll c(5, 0);

    rep(i, n) {
        if (mp.count(s[i][0]))
            c[mp[s[i][0]]]++;
    }
    ll ans = 0;

    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += c[i] * c[j] * c[k];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5888
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[x];
        long[] b = new long[y];
        long[] c = new long[z];
        for (int i = 0 ; i < x ; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0 ; i < y ; i++) {
            b[i] = sc.nextLong();
        }
        for (int i = 0 ; i < z ; i++) {
            c[i] = sc.nextLong();
        }
        long[] d = new long[x * y];
        int index = 0;
        for (int i = 0 ; i < x ; i++) {
            for (int j = 0 ; j < y ; j++) {
                d[index] = a[i] + b[j];
                index++;
            }
        }
        Arrays.sort(d);

        int xy = Math.min(x * y, k);
        long[] temp = new long[xy];
        for (int i = 0 ; i < xy ; i++) {
            temp[i] = d[x * y - 1 - i];
        }

        long[] e = new long[xy * z];
        index = 0;
        for (int i = 0 ; i < xy ; i++) {
            for (int j = 0 ; j < z ; j++) {
                e[index] = temp[i] + c[j];
                index++;
            }
        }

        Arrays.sort(e);

        for (int i = 0 ; i < k ; i++) {
            System.out.println(e[e.length - 1 - i]);
        }
    }

}

Measured memory_bytes: 60936
#include <stdio.h>
int main(void){
    int a,b,i,sum=0;
    
    scanf("%d %d",&a,&b);
    
    for(i=0;i<2;i++){
    if(a>b){
    sum+=a;
    a--;
    }
    else{
    sum+=b;
    b--;
    }
    }
    
    printf("%d",sum);
    return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    ll A, B; cin >> A >> B;

    if(A > B) {
        cout << 0 << endl;
        return 0;
    }
    if(n == 1){
        if(A == B){
            cout << 1 << endl;
        }
        else {
            cout << 0 << endl;
        }
        return 0;
    }

    ll a = A * (n - 2);
    ll b = B * (n - 2);
    cout << b - a + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 200000
#define INF 1000000000
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))

int a[N];

int main(){
	int n,x;
	int maxv=-INF;
	int minx=INF;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(i==0)minx=x;
		else {
			maxv=MAX(maxv,x-minx);
			minx=MIN(x,minx);
		}
	}

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


Measured memory_bytes: 2144