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

using namespace std;
using ll = long long;

vector<int> par1, par2;

int root1(int x) {
  if (par1[x] == x) {
    return x;
  }
  return par1[x] = root1(par1[x]);
}

void unite1(int x, int y) {
  x = root1(x);
  y = root1(y);
  if (x == y) {
    return;
  }
  par1[x] = y;
}

bool same1(int x, int y) {
  return root1(x) == root1(y);
}

int root2(int x) {
  if (par2[x] == x) {
    return x;
  }
  return par2[x] = root2(par2[x]);
}

void unite2(int x, int y) {
  x = root2(x);
  y = root2(y);
  if (x == y) {
    return;
  }
  par2[x] = y;
}

bool same2(int x, int y) {
  return root2(x) == root2(y);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, l;
  cin >> n >> k >> l;
  par1 = vector<int>(n + 1);
  par2 = vector<int>(n + 1);
  for (int i = 1; i <= n; i++) {
    par1[i] = i;
    par2[i] = i;
  }
  for (int i = 0; i < k; i++) {
    int p, q;
    cin >> p >> q;
    unite1(p, q);
  }
  for (int i = 0; i < l; i++) {
    int r, s;
    cin >> r >> s;
    unite2(r, s);
  }
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= n; i++) {
    mp[make_pair(root1(i), root2(i))]++;
  }
  for (int i = 1; i <= n; i++) {
    if (i < n) {
      cout << mp[make_pair(root1(i), root2(i))] << " ";
    } else {
      cout << mp[make_pair(root1(i), root2(i))] << endl;
    }
  }
  return 0;
}

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

using namespace std;

struct Event {
    int t, d, a;
    Event() {}
    Event(int _t, int _d, int _a) : t(_t), d(_d), a(_a) {}
    bool operator<(const Event& _oth) const {
        return t < _oth.t;
    }
};

void solve() {
    int R, K;
    cin >> R >> K;
    vector<Event> es;
    for (int _ = 0; _ < K; _++) {
        int t; cin >> t;
        es.emplace_back(t, -1, 0);
    }
    int Q; cin >> Q;
    for (int _ = 0; _ < Q; _++) {
        int t,a;
        cin >> t >> a;
        es.emplace_back(t, 1, a);
    }
    sort(es.begin(), es.end());
    
    int l = 0, r = R, x = 0;
    int t = 0, d = -1;
    for (auto& e: es) {
        x += d * (e.t - t); t = e.t; d *= e.d;
        l = min(max(l,-x), -x+R);
        r = min(max(r,-x), -x+R);

        if (e.d > 0) {
            int a = min(max(e.a, l), r);
            cout << (a + x) << "\n";
        }
    }
}

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


Measured memory_bytes: 4980
N, K = map(int, input().split())
t = [[0,0] for i in range(N)]
for i in range(N):
    a,b = map(int, input().split())
    t[i] = (a, b)
_k = 0
t = sorted(t, key=lambda t: t[0])

for i in range(N):
    _k += t[i][1]
    if _k >= K:
        print(t[i][0])
        break


Measured memory_bytes: 19572
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int e[12];
    for (int i = 0; i < 12; i++) {
        cin >> e[i];
    }
    sort(e, e + 12);
    if (e[0] == e[1] && e[1] == e[2] && e[2] == e[3] &&
        e[4] == e[5] && e[5] == e[6] && e[6] == e[7] &&
        e[8] == e[9] && e[9] == e[10] && e[10] == e[11]) {
        cout << "yes" << endl;            
    } else {
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include<cstdio>
#include<iostream>
using namespace std;
int na,nb,m,x,y,c,a[100005],b[100005],aminn=1<<30,bminn=1<<30,ans=1<<30;
int main(){
	scanf ("%d%d%d",&na,&nb,&m);
	for (register int i=1;i<=na;++i){
		scanf ("%d",&a[i]);
		if (a[i]<aminn) aminn=a[i];
	}
	for (register int i=1;i<=nb;++i){
		scanf ("%d",&b[i]);
		if (b[i]<bminn) bminn=b[i];
	}
	ans=aminn+bminn;
	for (register int i=1;i<=m;++i){
		scanf ("%d%d%d",&x,&y,&c);
		if (a[x]+b[y]-c<ans){
			ans=a[x]+b[y]-c;
		}
	}
	printf ("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	
	vector<int> x = {a, b, c, d, e};

	int result = 0;
	int remain_mod = 10;

	for (int i = 0; i < 5; i++) {
		result += (x[i] + 9) / 10 * 10;
		int mod = x[i] % 10;
		if (mod != 0 && remain_mod > mod) {
			remain_mod = mod;
		}
	}

	if (remain_mod != 10) {
		result -= (10 - remain_mod);
	}

	cout << result;
}


Measured memory_bytes: 256
from bisect import bisect_right
from random import randint
from copy import deepcopy


def calculate_score(i: int, last_i, S, D: int, C: list, T):
    rst = 0
    for d in range(1, D + 1):
        down = C[i] * (d - last_i[d])
        up = S[d][i] if i == T[d] else 0
        rst += up - down
    return rst


def create_last_i(i, T, D):
    _last_i = [0] * (D + 1)
    for d in range(1, D + 1):
        if T[d] == i:
            _last_i[d] = d
        else:
            _last_i[d] = _last_i[d - 1]
    return _last_i


def main():
    Z = 26
    D = int(input())
    C = list(map(int, input().split()))
    S = [tuple([None] * Z)] + [tuple(map(int, input().split())) for _ in range(D)]

    last = [0] * Z
    T = [0]
    for d in range(1, D + 1):
        maxScore = -float('inf')
        cntst = 0
        for i in range(26):
            tmp = last[i]
            last[i] = d
            up = S[d][i]
            down = sum(C[j] * (d - last[j]) for j in range(Z))
            score = up - down
            if maxScore < score:
                cntst = i
                maxScore = score
            last[i] = tmp
        last[cntst] = d
        T.append(cntst)

    last = [None] * Z
    V = [0] * Z
    for i in range(Z):
        last[i] = create_last_i(i, T, D)
    for i in range(Z):
        V[i] = calculate_score(i, last[i], S, D, C, T)

    score = sum(V)
    # maxScore = score
    # maxT = deepcopy(T)
    # print('Initial Score: ', score)

    max_iter = 5 * (10 ** 4)
    for _ in range(max_iter):
        d = randint(1, D)
        q = randint(0, Z - 1)

        p = T[d]
        if p == q:
            continue

        T[d] = q
        last_p = create_last_i(p, T, D)
        last_q = create_last_i(q, T, D)

        Vp = calculate_score(p, last_p, S, D, C, T)
        Vq = calculate_score(q, last_q, S, D, C, T)
        if V[p] + V[q] < Vp + Vq:
            score -= V[p] + V[q]
            score += Vp + Vq
            V[p] = Vp
            V[q] = Vq
            last[p] = last_p
            last[q] = last_q
        else:
            T[d] = p

    # if score > maxScore:
    for i in range(1, D + 1):
        print(T[i] + 1)
    # else:
    #     for i in range(1, D + 1):
    #         print(maxT[i] + 1)
    # # print(score)
    # for d in range(1, D + 1):
    #     print(T[d] + 1)


if __name__ == "__main__":
    main()


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

int main()
{
 string s,t;
 cin>>s>>t;
 int cnt=0;
 for(int i=0; i<s.size(); i++)
 {
  if(s[i]==t[i])
     cnt++;
 }
 cout<<cnt<<endl;
 return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}

void main()
{
  int n; readV(n);
  int[] l, r; readC(n, l, r);

  auto t = 0;
  foreach (li, ri; lockstep(l, r))
    t += ri-li+1;
  writeln(t);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
char str[1100][82];
int main(){
	int a;
	bool sen=false;
	while(scanf("%d",&a),a){
		if(sen)printf("----------\n");
		sen=true;
		gets(str[0]);
		for(int i=0;i<a;i++)gets(str[i]);
		for(int i=0;i<a;i++)for(int j=0;j<80;j++)if(!str[i][j])str[i][j]=' ';
		map<int,int>m;
		for(int i=0;i<a;i++)for(int j=0;j<80;j++){
			if(str[i][j]=='*'){
				int L=j;
				int R=j;
				for(int k=j;k<80;k++){
					if(str[i][k]!='*')break;
					str[i][k]=' ';R=k;
				}
				int t=R-L+1;
				int row=i;
				for(int k=i+1;k<a;k++){
					int to=-1;
					if(L&&str[k][L-1]=='*')to=L-1;
					else if(str[k][L]=='*')to=L;
					else if(L<79&&str[k][L+1]=='*')to=L+1;
					if(to==-1)break;
					row=k;L=to;
					str[row][L]=' ';
				}
				row=i;
				for(int k=i+1;k<a;k++){
					int to=-1;
					if(R<79&&str[k][R+1]=='*')to=R+1;
					else if(str[k][R]=='*')to=R;
					else if(R&&str[k][R-1]=='*')to=R-1;
					
					if(to==-1)break;
					row=k;R=to;
					str[row][R]=' ';
				}
				int S=(R-L+1+t)*(row-i+1)/2;
				if(m.count(S))m[S]++;
				else m[S]=1;
				for(int k=L;k<=R;k++)str[row][k]=' ';
		//		for(int k=0;k<a;k++)printf("%s\n",str[k]);printf("\n");
			}
		}
		for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
			printf("%d %d\n",(*it).first,(*it).second);
		}
	}
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
const int maxn =2e5+100;
int N,Q;
int val[maxn],ans[maxn],done[maxn];
vector<int> ac[maxn];
void dfs(int u,int v){
     int tempv = v+val[u];
     ans[u] = tempv;
     done[u] = 1;
     //fuck1(u,tempv);
     for(auto e:ac[u]){
        if(done[e])continue;
        dfs(e,tempv);
     }
}
int main(){
    int N,Q;
    read(N),read(Q);
    for(int i= 1;i<=N-1;i++){
        int a,b;
        read(a),read(b);
        ac[a].PB(b);
        ac[b].PB(a);
    }
    for(int i = 1;i<=Q;i++){
        int a,c;
        read(a),read(c);
        val[a]+=c;
    }
    dfs(1,0);
    for(int i = 1;i<=N;i++){
        if(i!=1)printf(" ");
        printf("%d",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 21760
#include <iostream>

using namespace std;

int main ()
{
	int n,m,l;
	long A[105][105],B[105][105],C[105][105];
	cin >> n >> m >> l;



	for (int a = 0; a < n; a++)
	{
		for (int b = 0; b < m; b++)
		{
			cin >> A[a][b];
		}
	}


	for (int b = 0; b < m; b++)
	{
		for (int c = 0; c < l; c++)
		{
			cin >> B[b][c];
		}
	}





	for (int a = 0; a < n; a++)
	{
		for (int c = 0; c < l; c++)
		{
			for (int b = 0; b < m; b++)
			{
				C[a][c] += A[a][b] * B[b][c];
			}
		}
	}




	for (int a = 0; a < n; a++)
	{
		for (int c = 0; c < l; c++)
		{
			if( c != l-1){
			                cout << C[a][c] <<" ";
			            }else{
			                cout << C[a][c] << endl;
			            }

		}
	}
	return 0;
}

Measured memory_bytes: 3336
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

using namespace std;
int n;
vector<int> a, b;

int main() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int Max = a[n - 1], cnt = 0, m = n - Max, Min = a[0], minCnt = 0;
	b.resize(Max);
	for (int i = 0; i < n; i++) {
		if (a[i] == Max)
			cnt++;
		if (a[i] == Min)
			minCnt++;
		b[a[i] - 1]++;
	}
	if (minCnt < 1 || minCnt > 2) {
		cout << "Impossible" << endl;
		return 0;
	}
//	cout << b[Min - 1] << " ";
	for (int i = Min; i < Max; i++) {
		if (b[i] < 2) {	
			cout << "Impossible" << endl;
			return 0;
		}
	//	cout << b[i] << " ";
	}
//	cout << endl;
	if (Max % 2 == minCnt % 2) {
		cout << "Impossible" << endl;
		return 0;
	}

	cout << "Possible" << endl;
//	cout << Min << " " << Max << endl;
//	cin >> n;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define LL long long
using namespace std;
LL n,a,b,h[100050];
bool judge(LL x)
{
    LL S=x*b;
    LL M=a-b;
    LL sum=0;
    for(int i=n-1;i>=0;i--)
    {
        if(h[i]>S)
        {
           if((h[i]-S)%M)
             sum+=(h[i]-S)/M+1;
            else
             sum+=(h[i]-S)/M;
        }

    }
    if(sum<=x)
        return true;
    return false;
}
int main()
{
    scanf("%lld %lld %lld",&n,&a,&b);
      LL  max1=0;
        for(int i=0;i<n;i++)
        {
          cin>>h[i];
          max1+=h[i]/b+1;
        }
       LL head=1;
        sort(h,h+n);
        while(head<max1)
        {
            LL mid=(max1+head)/2;
            if(judge(mid))
                max1=mid;
            else
                head=mid+1;
        }
        cout<<head<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  vector<char> bot[9];
  bot[0].push_back('.');
  bot[0].push_back(',');
  bot[0].push_back('!');
  bot[0].push_back('?');
  bot[0].push_back(' ');
  bot[1].push_back('a');
  bot[1].push_back('b');
  bot[1].push_back('c');
  bot[2].push_back('d');
  bot[2].push_back('e');
  bot[2].push_back('f');
  bot[3].push_back('g');
  bot[3].push_back('h');
  bot[3].push_back('i');
  bot[4].push_back('j');
  bot[4].push_back('k');
  bot[4].push_back('l');
  bot[5].push_back('m');
  bot[5].push_back('n');
  bot[5].push_back('o');
  bot[6].push_back('p');
  bot[6].push_back('q');
  bot[6].push_back('r');
  bot[6].push_back('s');
  bot[7].push_back('t');
  bot[7].push_back('u');
  bot[7].push_back('v');
  bot[8].push_back('w');
  bot[8].push_back('x');
  bot[8].push_back('y');
  bot[8].push_back('z');
  int n;
  cin >> n;
  for (int z = 0; z < n; z++) {
    string s;
    cin >> s;
    int len = s.size();
    string res = "";
    int index = 0;
    while (index < len) {
      while (index < len and s[index] == '0') index++;
      if (index >= len) break;
      int c = 0;
      char ch = s[index];
      index++;
      while (ch == s[index]) {
	c++;
	index++;
      }
      res += bot[ch-'1'][c%bot[ch-'1'].size()];
      index++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1224
using System;

namespace Volume0_0011
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = Convert.ToInt32(Console.ReadLine());
            int n = Convert.ToInt32(Console.ReadLine());

            int[] lot = new int[w+1];
            for (int i = 1; i < w+1; i++) lot[i] = i;

                for (int i = 0; i < n; i++)
                {
                    String[] inputs = Console.ReadLine().Split(',');
                    int a = Convert.ToInt32(inputs[0]);
                    int b = Convert.ToInt32(inputs[1]);

                    lot[0] = lot[a];
                    lot[a] = lot[b];
                    lot[b] = lot[0];
                }
                for (int i = 1; i < w + 1; i++) Console.WriteLine(lot[i]);
        }
    }
}

Measured memory_bytes: 5656
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;

    vl v(26);
    rep(i, 4) {
        v[s[i] - 'A']++;
    }

    sort(rall(v));

    if(v[0] == 2 && v[1] == 2) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC069
{
    class ProblemB
    {

        static void Main(string[] args)
        {
            string input = Console.ReadLine().ToString();

            string first = input.Substring(0, 1);
            string end = input.Substring(input.Length - 1, 1);
            int n = input.Substring(1, input.Length - 2).Length;

            Console.WriteLine(first + Convert.ToString(n) + end);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";

///summary : とりあえず貪欲法
int vmax(std::vector<int> v)
{
	int ans = 0;
	int maxVal = INT_MIN;       // 整数最小値
	for (int i = 0; i < (int)v.size(); i++) {
		if (v[i] > maxVal) {
			maxVal = v[i];
			ans = i;
		}
	}
	return ans;
}

int checker(const vector<int>& t, const int D, const vector<int>& c, const vector<vector<int>> s) {
	vector<int> last(26, -1);
	int satisfy = 0;
	rep(date, D) {
		last[t[date]] = date;
		satisfy += s[date][t[date]];
		rep(i, 26) satisfy -= c[i] * (date - last[i]);
	}
	return satisfy;
}

vector<int> SetAns() {
	/// normal_input
	int D;
	cin >> D;

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	rep(i, 26) cin >> c[i];
	rep(i, D) rep(j, 26) cin >> s[i][j];;
	
	/// main_process
	vector<int> t(D);
	rep(i, D) t[i] = vmax(s[i]);

	//候補の最適化
	int val = -1;
	vector<int> rN(2);
	int maxVal = checker(t, D, c, s);
	rep(_i, 1000) {
		vector<int> tmpAns = t;
		rep(_j, 10) {
			rN[0] = rand() % D;
			rN[1] = (rand() % (D- 1));

			//change
			tmpAns[rN[0]] += rN[1];
			tmpAns[rN[0]] %= D;
		}
		int tmpVal = checker(t, D, c, s);

		if (tmpVal > maxVal) {
			t = tmpAns;
			maxVal = tmpVal;
		}
	}

	return t;
}

int main() {
	vector<int> ans = SetAns();
	for (const auto& i : ans) {
		cout << i + 1 << endl;
	}
	//cout << ans << endl;
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    int ans = 0;
    rep(i, M) {
        int A;
        cin >> A;
        if (A < X) ans++;
    }

    cout << min(ans, M - ans) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
using namespace std;
typedef pair<int,int> P;

int main(){
    int w,e,ans,ch=0;
    int to[1000];
    to[0]=0;
    for(int i=1;i<=999;i++){
        to[i]=to[i-1]+i;
    }
    cin>>w>>e;
    for(int i=1;i<=999;i++){
        for(int j=1;j<to[i];j++){
            if(w==to[i]-j){
                if(e==to[i+1]-j){
                ans=j;
                ch=1;
                }
            }
            if(ch==1) break;
        }
        if(ch==1) break;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    cout << min(n,k)*x + max(0,n-k)*y;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int num1 = 0;
	int num2 = 0;
	rep(i, n) if (s[i] == 'E') num2++;
	int ans = inf;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'E') num2--;
		int tmp = num1 + num2;
		mins(ans, tmp);
		if (s[i] == 'W') num1++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

void solve(){
    int n,k;
    cin >> n >> k;
    vector<int>v(n+5),p,ne;
    FOR(i,1,n+1){
        cin >> v[i];
        if(v[i] >= 0)p.pb(v[i]);
        else ne.pb(-v[i]);
    }
    if(n == k){
        int ans = 1;
        FOR(i,1,n+1)if(v[i] < 0)ans *= (v[i]+mod)%mod,ans %= mod;
        else ans *= v[i],ans %= mod;
        cout << ans << "\n";
        return ;
    }
    sort(ne.begin(),ne.end(),greater<int>());
    sort(p.begin(),p.end(),greater<int>());
    int ans = 1;
    if(!sz(p)){
        if(k%2 != 0){
            sort(ne.begin(),ne.end());
            FOR(i,0,k){
                ne[i] = (-1*ne[i]+mod)%mod;
                ans *= ne[i],ans %= mod;
            }
        }
        else {
            FOR(i,0,k)ans *= ne[i],ans %= mod;
        }
    }
    else {
        int nt = min((sz(ne)/2)*2,k),pt;
        if(nt%2)nt--;
        pt = k-nt;
        while(nt >= 2 && pt+1 < sz(p) && ne[nt-1]*ne[nt-2] <= p[pt]*p[pt+1]){
            pt += 2;
            nt -= 2;
        }
        ans = 1;
        FOR(i,0,pt)ans *= p[i],ans %= mod;
        FOR(i,0,nt)ans *= ne[i],ans %= mod;
    }
    cout << ans << "\n";
}

signed main()
{
    showoff;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 6960
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
int main()
{
	double num;
	while(cin>>num&&num>=0){
		num*=1<<4;
		if(num!=(double)(int)num||(int)num>=(1<<12)){
			cout<<"NA"<<endl;
		}else{
			int n=(int)num;
			for(int i=11;i>=0;i--){
				printf((n>>i)&1?"1":"0");
				if(i==4)printf(".");
			}
			printf("\n");
		}
	}
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << vec[i] << endl;
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll a_sum = 0;
    ll tmp_a_sum;
    ll pn_needed = 0;
    // P N型
    rep(i, n) {
        tmp_a_sum = a_sum + a[i];
        if (i % 2 == 0) {
            if (tmp_a_sum > 0) {
                a_sum = tmp_a_sum;
            } else {
                pn_needed += (abs(tmp_a_sum) + 1);
                a_sum = 1;
            }
        } else {
            if (tmp_a_sum < 0) {
                a_sum = tmp_a_sum;
            } else {
                pn_needed += (abs(tmp_a_sum) + 1);
                a_sum = -1;
            }
        }
    }
    // N P型
    a_sum = 0;
    ll np_needed = 0;
    
    rep(i, n) {
        tmp_a_sum = a_sum + a[i];
        if (i % 2 == 1) {
            if (tmp_a_sum > 0) {
                a_sum = tmp_a_sum;
            } else {
                np_needed += (abs(tmp_a_sum) + 1);
                a_sum = 1;
            }
        } else {
            if (tmp_a_sum < 0) {
                a_sum = tmp_a_sum;
            } else {
                np_needed += (abs(tmp_a_sum) + 1);
                a_sum = -1;
            }
        }
    }

    cout << min(np_needed, pn_needed) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

vector<int>g[N];
int dp[N];
int rec(int u){
	if(dp[u]!=-1)return dp[u];
	if(g[u].size()==0)return 0;
	int ans = 0;
	for(auto x:g[u]){
		ans = max(ans,rec(x));
	}
	dp[u]=ans+1;
	return dp[u];
}

int main()
{	

	int n,m;
	cin >> n >> m;
	FOR(i,1,m){
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
	}	
	FOR(i,1,n)dp[i]=-1;
	int ans = 0;
	FOR(i,1,n)ans = max(ans,rec(i));
	cout << ans;

	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  ll N,K;
  cin>>N>>K;
  VI A(N),F(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>F[i];
  sort(all(A));
  sort(all(F));
  ll ok=A[N-1],ng=-1;
  ok*=F[N-1];
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    vector<ll> B(N);
    rep(i,N) B[i]=mid/F[i];
    sort(all(B));
    ll X=1,sum=0;
    rep(i,N){
      if(A[i]>B[i]) sum+=(A[i]-B[i]);
    }
    if(sum>K) X=0;
    if(X){
      ok=mid;
    }else{
      ng=mid;
    }
  }
  cout<<ok<<endl;
}




Measured memory_bytes: 3428
// ABC053B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	//string A;
	//string Z;
	int a, z;
	cin >> s;
	int N;
	N = s.size();
	
	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'A')
		{
			a = i + 1;
			break;
		}
	}

	reverse(s.begin(), s.end());
	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'Z')
		{
			z = N-i;
			break;
		}
	}
	int length= z - a + 1;

	cout << length << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します
 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
//
int pnt(char, int);
int p[3];
int main(){
    int n, k;
    string s;
    cin >> n >> k >> p[0] >> p[1] >> p[2] >> s;
    int ans = 0;
    int dp[n][3];
    for(int i = 0; i < k; i++){
        for(int j = 0; j < 3; j++) dp[i][j] = pnt(s[i], j);
        for(int j = 0;; j++){
            if(i + (j + 1) * k >= n){
                ans += max(dp[i + j * k][0], max(dp[i + j * k][1], dp[i + j * k][2]));
                break;
            }
            dp[i + (j + 1) * k][0] = max(dp[i + j * k][1], dp[i + j * k][2]) + pnt(s[i + (j + 1) * k], 0);
            dp[i + (j + 1) * k][1] = max(dp[i + j * k][0], dp[i + j * k][2]) + pnt(s[i + (j + 1) * k], 1);
            dp[i + (j + 1) * k][2] = max(dp[i + j * k][0], dp[i + j * k][1]) + pnt(s[i + (j + 1) * k], 2);
        }
    }
    cout << ans;
}
int pnt(char c, int a){
    if(c == 's' && a == 0) return p[0];
    if(c == 'p' && a == 1) return p[1];
    if(c == 'r' && a == 2) return p[2];
    return 0;
}

Measured memory_bytes: 1664
a = list(map(int,input().split()))
n = a[0]
m = a[1]

if n ==1:
    if m ==1:
        print(0)
    else:
        print(int(m*(m-1)/2))
else:
    if m == 1:
        print(int(n*(n-1)/2))
    else:
        print(int(m*(m-1)/2 + n*(n-1)/2))

Measured memory_bytes: 38256
n = int(input())
a = list(map(int,input().split()))
wa = []
wa2 = []
#for i in range(n):
#    wa.append(sum(a[0:i+1]))
#    wa2.append(sum(a[-1:-(i+2):-1]))
s = 0
s1 = 0
for i in range(n):
    s +=a[i]
    wa.append(s)
    s1 +=a[-(i+1)]
    wa2.append(s1)

ans = 10**10
for i in range(n-1):
    if ans > abs(wa[i] - wa2[-(i+2)]):
        ans = abs(wa[i] - wa2[-(i+2)])
print(ans)

Measured memory_bytes: 31628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, val=0;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(x*x<=(K-x)*(K-x)) val+=2*x;
    else if (K>x) val+=2*(K-x);
    else val+=2*(x-K);
  }
  cout << val << endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc139/tasks/abc139_e
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647;
const LL mod = 1000000007ll;
 
int N;
vector<vector<int>> A;//選手iがj番目に戦う相手をA[i][j]とおく
 
int ans = 0;
 
void solve(){
	vector<pair<int,int>> q;//試合を格納するキュー
	//vectorをキューのように扱ってみる
	//工夫次第でqueueより制約は強いが追加、消去がO(1)でできる
	auto check = [&](int i){//選手iが試合できるかを調べて、できるならキューに格納
		//A[i](i番目の選手が戦う相手の集合)が空ならそもそも試合できないのでreturn
		if(A[i].size()==0) return;
		int j = A[i].back();//iの対戦相手をjとおく
		if(A[j].back()==i){//jの次の相手がiなら
			pair<int,int> fight(i,j);
			if(fight.second<fight.first) swap(fight.first,fight.second);
			q.push_back(fight);
		}
	};
	for(int i=0;i<N;i++){
		check(i);
	}
	while(q.size()>0){
		ans++;
		//vectorにおける重複要素の除去方法
		//まずソート
		sort(q.begin(),q.end());
		//それからerase関数を呼び出す　これで重複が削除できる
		q.erase(unique(q.begin(),q.end()),q.end());
		vector<pair<int,int>> prevQ;
		swap(prevQ,q);
		for(auto p : prevQ){
			int i = p.first;
			int j = p.second;
			A[i].pop_back();//A[i]の末尾の要素を削除
			A[j].pop_back();
		}
		for(auto p : prevQ){
			int i = p.first;
			int j = p.second;
			check(i);
			check(j);
		}
	}
	//リストが全部からになってたら日数を出力
	for(int i=0;i<N;i++){
		if(A[i].size()!=0){
			ans = -1;
			return;
		}
	}
}
 
int main(){
	cin >> N;
	A = vector<vector<int>>(N,vector<int>(N-1));
	for(int i=0;i<N;i++){
		for(int j=0;j<N-1;j++){
			cin >> A[i][j];
			A[i][j]--;//選手の番号を0始まりにする
		}
		//vectorは先頭からの消去は遅く、末尾からの消去は早い
		//このためあらかじめ配列を逆向きにしておく
		reverse(A[i].begin(),A[i].end());
	}
 
	solve();
 
	cout << ans << endl;
	return 0;
}

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

static uint64_t Gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;
    while (m % n != 0)
    {
        temp = n;
        n = m % n;
        m = temp;
    }
    return n;
}

static uint64_t Lcm(uint64_t m, uint64_t n)
{
    return m * n / Gcd(m,n);
}

int main(int argc, const char * argv[]) {
    uint64_t A, B, C, D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    
    uint64_t count = B - A + 1;
    
    uint64_t Cans = B / C - (A - 1) / C;
    uint64_t Dans = B / D - (A - 1) / D;
    uint64_t L = Lcm(C, D);
    uint64_t Lans = B / L - (A - 1) / L;
    
    cout << count - (Cans + Dans - Lans) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    string s;cin>>s;
    if(s[0]!=s[1]||s[1]!=s[2]||s[0]!=s[2])cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
N, D = map(int, input().split())
X = []
ans = 0
for i in range(N):
    X.append(list(map(int, input().split())))

for i in range(N-1):
    for j in range(i+1, N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d])**2
        dist = dist**(1/2)
        if dist.is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 3064
def main():
	n , m = map(int , input().split())
	deg = [0 for i in range(n+2)]
	for i in range(m):
		x , y = map(int , input().split())
		deg[x]+=1
		deg[y]+=1
	f=0
	for i in range(1, n+1):
		if deg[i]%2==1:
			f = 1
	if f:
		print("NO")
	else:
		print("YES")
if __name__=="__main__":
	main()

Measured memory_bytes: 79504
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,bool> Pair;

int main(){

ll N,M;

cin >> N >> M;

vector<ll> H(N+1,0);
vector<ll> A,B;
vector<Pair> D(N+1);
A = B = vector<ll>(M+1,0);

for(ll i = 1;i <= N;++i)     cin >> H[i];

for(ll i = 1;i <= N;++i){
    D[i].first = 0;
    D[i].second = false;
}
for(ll i = 1;i <= M;++i){

  cin >> A[i] >> B[i];

// B → A
  if(H[A[i]] >= H[B[i]]){
      
      D[B[i]].first++;

  } 
// A → B
  if(H[B[i]] >= H[A[i]]){

      D[A[i]].first++;

  }

//    cout << "A = " << D[A[i]].first << " #" << A[i] << " :::" << " B = " << D[B[i]].first << " #" << B[i] << endl;

}

ll ans = 0;

for(ll i = 1;i <= N;++i){

    if(D[i].first == 0) ++ans;

}

cout << ans << endl;

return 0;

}   


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;

    cout << ((a - 2 * b < 0) ? 0 : a - 2 * b) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll a,b;
	cin>>a>>b;
	cout<<a*b;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3692
a,b,c=gets.chomp.split.map(&:to_i)
ans=0
while(a%2==0 and b%2==0 and c%2==0)
    if (a==b and b ==c)
        puts -1
        exit
    end
    a,b,c=(b+c)/2, (a+c)/2, (b+a)/2
    ans += 1
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[2005],sum=0;
	cin>>n;
	for(int i=0;i<n;sum+=a[i++]) cin>>a[i];
	bitset<4000005> bs(1);
	for(int i=0;i<n;++i) bs |= bs<<a[i];
	for(int i=(sum+1)/2;i<=sum;++i)
		if(bs[i]) return cout<<i,0;
}

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

int S(int n) {
    int x = 0;

    while(1) {
        x += n % 10;
        n /= 10;
        if(n == 0) {
            break;
        }
    }

    return x;
}

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

    if(N % S(N) == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

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

using namespace std;

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

	double rate = 380000.0;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		double x;
		string u;
		cin >> x >> u;

		if (u == "JPY")
		{
			sum += x;
		}
		else
		{
			sum += x * rate;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    double l;
    cin>>l;
    l /= 3;
    cout<<ps(l*l*l,12);
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
  int n;
  cin >> n;
  n*=2;
  vector<int>l(n);
  for(int i=0;i<n;i++)cin >> l[i];
  sort(l.begin(),l.end());

  int sum=0;
  for(int i=0;i<n;i+=2){
    sum+=l[i];
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
#print(F)
#print(P)

ans = -(10**10)
for i in range(1,1<<10):
  A = [0 for _ in range(10)]
  for j in range(10):
    A[j] = (i & (1<<j)) >>j
  #print(A)
  profit = 0
  for j in range(N):
    c = 0
    for f,a in zip(F[j],A):
      c += f*a
    profit += P[j][c]
  ans = max(ans,profit)
print(ans)


Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string s,t;
  cin >> s >> t;
  
  int n=s.size();
  vector<char> x(n),y(n);
  
  for(int i=0;i<n;i++){
    x[i]=s[i];
    y[i]=t[i];
  }
  
  for(int i=0;i<n;i++){
    char b=y[n-1];
    for(int j=n-2;j>=0;j--){
      y[j+1]=y[j];
    }
    y[0]=b;
    if(x==y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


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

#define FOR(i, a, b) for (unsigned long long i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

typedef unsigned long long LL;

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

    LL X, Y, tmp;
    cin >> X >> Y;

    FOR(i, 1, int(1000000000000000001 / X)){
        if ((X * i) % Y == 0){
            cout << "-1\n";
            return 0;
        }
        else{
            cout << X * i << "\n";
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var S = sc.ReadStr();
        var ans = new int[S.Length];
        var r = 0;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'R') r++;
            else
            {
                ans[i - 1] += (r + 1) / 2;
                ans[i] += r / 2;
                r = 0;
            }
        }
        var l = 0;
        for (int i = S.Length - 1; i >= 0; i--)
        {
            if (S[i] == 'L') l++;
            else
            {
                ans[i + 1] += (l + 1) / 2;
                ans[i] += l / 2;
                l = 0;
            }
        }
        for (int i = 0; i < S.Length; i++)
        {
            if (i > 0) Console.Write(' ');
            Console.Write(ans[i]);
        }
        Console.WriteLine();
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

int main(){
  int N;
  cin>>N;
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(N==i*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int N;
	cin >> N;

	if(N==1){
		cout << "Hello World" << endl;
		return 0;
	}

	int A,B;
	cin >> A >> B;
	cout << A+B << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

x,y = ns().split()
hx = {"A":1, "B":2, "C":3, "D":4, "E":5, "F":6}

if hx[x] > hx[y]:
    print(">")
elif hx[x] < hx[y]:
    print("<")
else:
    print("=")


Measured memory_bytes: 3064
K = int(input())
N = 10
a = 0
l = 9*K
if(K==7 or K==1):
  a+=1
  print(1)
else:
  for i in range(1,10**6):
    N = (10*N)%l
    if (N*7-7)%l==0:
      print(i+1)
      a +=1
      break
  if(a == 0):
    print(-1)

Measured memory_bytes: 9132