akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;//StreamWriterのために必要
using System.Collections.Generic;//List型を使うために必要

namespace dotnetproj
{
    class Program
    {
        static void Main(string[] args)
        {
            int maxcount = 0;
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            var strList = new List<int>();
            foreach(string str in input){
                strList.Add(int.Parse(str));
            }
            while(true){
                int devCount=0;
                foreach(int c in strList){//odd or even
                    if(c%2==0) {
                        devCount++;
                    }
                }
                if(devCount==N){
                    maxcount++;
                    //Console.WriteLine(strList[0]);
                    //Console.WriteLine(strList[1]);
                   for(int i=0;i<N;i++){
                       strList[i]=strList[i]/2;
                   } 
                }
                else
                {
                    Console.WriteLine(maxcount);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

struct P {
	int64_t x;
	int64_t y;
	int64_t p;
};

int64_t val[1 << 15] = {};
int64_t rem[1 << 15] = {};
int pos[1 << 15][15] = {};

int64_t evaluate(vector<P>& ps, int s, int64_t v, bool is_x)
{
	int64_t sum = 0;
	FOR_LT(i, 0, ps.size()) {
		if (s & (1 << i)) {
			if (is_x) {
				sum += abs(ps[i].x - v) * ps[i].p;
			}
			else {
				sum += abs(ps[i].y - v) * ps[i].p;
			}
		}
	}
	return sum;
}

int64_t dp[16][(1 << 15)];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	vector<P> ps(n);
	FOR_LT(i, 0, n) {
		auto& p = ps[i];
		cin >> p.x >> p.y >> p.p;
	}

	val[0] = 0;
	rem[0] = 0;
	FOR_LT(i, 1, (1 << n)) {
		int64_t vmin = INT64_MAX;
		FOR_LT(j, 0, n) {
			if (i & (1 << j)) {
				vmin = min(vmin, evaluate(ps, i, ps[j].x, true));
				vmin = min(vmin, evaluate(ps, i, ps[j].y, false));
			}
		}
		val[i] = vmin;

		int c = 0;
		FOR_LT(j, 0, n) {
			if (i & (1 << j)) {
				pos[i][c] = (1 << j);
				c++;
			}
		}


		int64_t vrem = 0;
		FOR_LT(j, 0, n) {
			if (i & (1 << j)) {
				vrem += min(abs(ps[j].x), abs(ps[j].y)) * ps[j].p;
			}
		}
		rem[i] = vrem;
	}

	FOR_LT(i, 0, (1 << n)) {
		dp[0][i] = rem[i];
	}

	FOR_LE(i, 1, n) {
		FOR_LT(j, 0, (1 << n)) {
			dp[i][j] = INT64_MAX;
			int k = j;
			for (int k = j; k != 0; k = (k - 1) & j) {
				dp[i][j] = min(dp[i][j], dp[i - 1][k] + val[j - k]);
			}
			dp[i][j] = min(dp[i][j], dp[i - i][0] + val[j]);
		}
	}

	FOR_LE(i, 0, n) {
		cout << dp[i][(1 << n) - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 10064
import java.util.Scanner;

class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }

        sc.close();
    }

}


Measured memory_bytes: 26104
#include<bits/stdc++.h>
#define re register
#define M 998244353
#define int long long
inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,k,a[1000002],ans,b[10000002],dp[10000002],f[10000002];
char s[1000002];
signed main(){
	n=read();
	for(re int i=1;i<=n;++i){
		for(re int j=1;i*j<n;++j)++ans;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE    
		freopen("input.txt", "r", stdin);     
		freopen("output.txt", "w", stdout);
	#endif

//----------------------------------------------------//
double l;
cin>>l;
double xx = (l*l*l)/27;
cout<<fixed<<setprecision(6)<<xx;





 






	#ifndef ONLINE_JUDGE
   		cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif

return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,i,k,max=-1,c=0;
  cin>>n;
  long long a[n];
  for(i=0;i<n;i++)
      {
        cin>>a[i];
      }
  k=*max_element(a,a+n);   
  for(i=0;i<n;i++)
  {
  	if(a[i]==k)
  	c++;
   } 
  //cout<<k;
  for(i=0;i<n;i++)
  {
    if(a[i]<k)
    {
      if(max<a[i])
      {
        max=a[i];
      }
    }
  }
if(c>1)
{
	max=k;
}
  for(i=0;i<n;i++)
  {
    if(a[i]==k)
      cout<<max<<endl;
    else
      cout<<k<<endl;
  }
  return 0;
}

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

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

    if(M == 0){
        cout << "Yes" << endl;
        return 0;
    }

    std::vector<std::vector<pair<int, int>>> link(N);
    for(int i = 0;i < M;i++){
        int L, R, D;
        cin >> L >> R >> D;
        link[L-1].push_back(pair<int, int>(R-1, D));
        link[R-1].push_back(pair<int, int>(L-1, -D));
    }

    std::vector<bool> houmon(N, false);
    for(int start = 0;start < N;start++){
        if(houmon[start]) continue;

        std::vector<int> x(N, 0);
        stack<int> s;

        s.push(start);
        while(!s.empty()){
            int n1 = s.top();
            s.pop();
            houmon[n1] = true;
            for(auto&& n2 : link[n1]){
                if(houmon[n2.first]){
                    if(x[n2.first] != x[n1] + n2.second){
                        cout << "No" << endl;
                        return 0;
                    }
                }else{
                    x[n2.first] = x[n1] + n2.second;
                    s.push(n2.first);
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main() {
	long long int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n <= k) {
		cout << x*n << endl;
	} else {
		cout << x*k+y*(n-k) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct node{
    int p,l,r;
}Node;
Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL)
        return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL)
        return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u){
    if(u == NIL)
        return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}
int main(void){
    int i,v,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        T[i].p=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l != NIL)
            T[l].p=v;
        if(r != NIL)
            T[r].p=v;
    }
    for(i=0;i<n;i++)
        if(T[i].p == NIL)
            root=i;
    puts("Preorder");
    preParse(root);
    puts("");
    puts("Inorder");
    inParse(root);
    puts("");
    puts("Postorder");
    postParse(root);
    puts("");
    return 0;
}


Measured memory_bytes: 2124
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         ll a,b;
        cin>>a>>b;
        cout<<(a+b-1)/b;
         



      }
      
}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b)
{
	if(a.second<b.second)
	 return true;
	else
	 return false;
}
int main()
{
	int n;
	pair<int,int> p[100100];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int t;
		cin>>t;
		p[i].first=i;
		p[i].second=t;
	} 
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;i++)
	 cout<<p[i].first<<" ";
	return 0;
	
} 

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N,W,iw,iv;
ll DP[101][100001];
ll max(ll a, ll b) {
  if (a>b) return a; return b;
}

int main() {
  cin >> N >> W;
  for (ll i = 0; i < N; i++) {
    cin >> iw >> iv;
    for (ll w = 0; w <= W; w++) {
      if (w < iw) {
        DP[i+1][w] = DP[i][w];
      } else {
        DP[i+1][w] = max(DP[i][w], DP[i][w - iw] + iv);
      }
    }
  }
  cout << DP[N][W] << endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int K,N;
    cin >> K >> N;
    vector<int>A(N);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    int mx = 0;
    for(int i = 0; i < N; i++) {
        if(i) {
            sum+=A[i]-A[i-1];
            mx = max(mx,A[i]-A[i-1]);
        }
    }
    sum+=K-A[N-1]+A[0];
    mx = max(mx,K-A[N-1]+A[0]);
    cout << sum-mx << endl;
}


Measured memory_bytes: 4804
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    double T,X;
    double A;
    cin >> T >> X;
    cout << T/X << endl;

    return 0;
}



Measured memory_bytes: 256
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,sum;
int main()
{
	fast;
	cin>>n;
	int n1=n;
	while (n1!=0)
	{
		sum+=n1%10;
		n1/=10;
	}
	if (n%sum==0)
	   cout<<"Yes";
	else
	   cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
#include <vector>
#include <set>
#include <map>

int main()
{
    while (true)
    {
        int m, f, r;
        std::cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
        {
            return 0;
        }

        if (m == -1 || f == -1)
        {
            std::cout << "F\n";
        }
        else if (m + f >= 80)
        {
            std::cout << "A\n";
        }
        else if (m + f >= 65)
        {
            std::cout << "B\n";
        }
        else if (m + f >= 50)
        {
            std::cout << "C\n";
        }
        else if (m + f >= 30)
        {
            if (r >= 50)
            {
                std::cout << "C\n";
            }
            else
            {
                std::cout << "D\n";
            }
        }
        else
        {
            std::cout << "F\n";
        }
    }
}


Measured memory_bytes: 3084
import math
a,b,x = map(int,input().split())
if x >= a*a*b/2:
    value = (b-(x/a**2))/(a/2)
    atan = math.degrees(math.atan(value))
    print(atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*b*b)))
    print(90-atan)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int a,i,j,k,n,p[50000];

  for(i=1;i<50000;i++) p[i]=1;
  for(i=2;i<=224;i++) if(p[i]) for(j=2;i*j<=50000;j++) p[i*j]=0;

  while(scanf("%d",&n),n!=0){
    a=0;
    for(i=2;i<n/2+1;i++){
      if(p[i] && p[n-i]) a++;
    }
    printf("%d\n",a);
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  int a,b;
  cin >> a >> b;
  int res = 0;
  if(a < b)swap(a,b);
  res += a;
  a--;
  res += max(a,b);
  cout << res << endl;

  



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define DEB 0

/*
real	0m2.093s  --> 
real	0m2.000s
*/
const int dx[] = {1,0,-1,0}; //r,d,l,u
const int dy[] = {0,1,0,-1};

int w,h,sx,sy,home,last;
int field[16][16];
int num[16][16];
int hS[25],hx[25],hy[25],edge[25][4][25]; //[src][dir][dest]
//int memo[885777];
map<int,int> msi;

inline bool isnotgoal(int s){
  return (((last&s)) == last);
}
inline bool isnot(int s){
  rep(i,home)if( !(s&(1<<i)) ){
    if( (hS[i]&s)==hS[i] ) return true;
  }
  return false;
}
inline bool inside(int x, int y){
  return (x<0 || y<0 || x>=w || y>=h);
}

int dfs(int S){
  int src = S&((1<<5)-1);
  int x = hx[src];
  int y = hy[src];
  int s = S>>5;

  if( (1<<home)-1 == s ){ //âÎÉßêé
    return 1;
  }
  if( isnotgoal(s) ){ //³ïÉßé½ßÌÆðÁïµ½©Ç¤©
    return 0;
  }
  if( msi.count(S) ){ //ùÉÊÁ½óÔ
    return msi[S];
  }
  
  // v[gªu¯È¢ÆÌL³
  /*
    1831764
    ari  :: msi_sz: 885661  >0:376369  ==0:509292  already>0:222390 , already==0:408636
    nari :: msi_sz:1028771  >0:376369  ==0:652402  already>0:222390 , already==0:565310
   */
  
  if( s>0 && ((s&(s-1))!=0) && isnot(s&~(1<<src)) ){
    return 0;
  }
  
  
  int ret = 0;
  rep(k,4){
    for(int j=0; edge[src][k][j]!=-1; j++){
      int dest = edge[src][k][j];
      int nx = hx[dest];
      int ny = hy[dest];
      if( field[ny][nx]==1 ){
	field[ny][nx] = 0;
	ret += dfs(((s|(1<<dest))<<5)|dest);
	field[ny][nx] = 1;
	break;
      }
    }
  }
  return msi[S]=ret;
}

int main(){

  while(scanf("%d%d",&w,&h),w|h){
    msi.clear();
    memset(num,-1,sizeof(num));
    memset(edge,-1,sizeof(edge));
    memset(hS,0,sizeof(hS));
    home = last = 0;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
	if( field[i][j]==1 ){
	  hx[home]=j; hy[home]=i;
	  num[i][j] = home;
	  home++;
	}
      }
    }
    hx[home] = sx;
    hy[home] = sy;

    // other homes
    rep(i,home){
      rep(k,4){
	int sz = 0;
	for(int j=1; j<20; j++){
	  int tx = hx[i] + dx[k]*j;
	  int ty = hy[i] + dy[k]*j;
	  if( inside(tx,ty) ) break;
	  if( field[ty][tx]==1 ){
	    hS[i] |= (1<<num[ty][tx]);
	    edge[i][k][sz++] = num[ty][tx];
	  }
	}
      }
    }

    //last homes
    rep(k,4){
      int sz = 0;
      for(int i=1; i<20; i++){
	int tx = sx + dx[k]*i;
	int ty = sy + dy[k]*i;
	if( inside(tx,ty) )break;
	if( field[ty][tx]==1 ){
	  last |= (1<<num[ty][tx]);
	  edge[home][k][sz++] = num[ty][tx];
	}
      }
    }
    printf("%d\n",dfs(home));
#if DEB
    map<int,int> tmp;
    map<int,int>::iterator it;
    for(it=msi.begin(); it!=msi.end(); it++){
      tmp[it->second]++;
    }
    for(int i=0; i<10; i++){
      printf("%d: %d\n",i,tmp[i]);
    }
#endif
  }
  

  return 0;
}

Measured memory_bytes: 27000
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <queue>
#include <assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    for(int i=1;;i++){
        if(x*i%360==0){
            cout << i << endl;
            return 0;
        }
    }
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B, C;
signed main() {
    cin >> A >> B >> C;
    if (A < C && C < B || A > C && C > B) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
def main():
  n = int(input())
  xy = [map(str, input().split()) for _ in range(n)]
  x, y = [list(i) for i in zip(*xy)]
  ans_list=list(range(0,n))
  for i in range(0,n):
    min=i
    for j in range(i+1,n):
      if x[ans_list[min]]>x[ans_list[j]] or (x[ans_list[min]]==x[ans_list[j]] and int(y[ans_list[min]])<int(y[ans_list[j]])):
        min=j
    
    if ans_list[min]!=ans_list[i]:
      tmp=ans_list[i]
      ans_list[i]=ans_list[min]
      ans_list[min]=tmp
    print(ans_list[i]+1)
  
main()

Measured memory_bytes: 9168
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;
ll n;
ll ans;
ll cnt;
string now;
string s[100005];

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        cin>>s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s, s + n);
    for(ll i = 0; i < n; i++)
    {
        if(now == s[i])
        {
            cnt++;
        }
        else
        {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            now = s[i];
        }
    }
    ans += cnt * (cnt - 1) / 2;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
long gcd(long a, long b) {
  while (b != 0) {
    long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long lcd(long a, long b) {
  long g = gcd(a, b);
  return (a * b) / g;
}
int main() {
  long a, b;
  while (cin >> a >> b) {
    cout << gcd(a, b) << " " << lcd(a, b) << endl;
  }
}

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

string S;
int main(){
    cin >> S;
    int pat_1 = 0, pat_2 = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] - '0' == (i % 2)){
            pat_2++;
        }else{
            pat_1++;
        }
    }
    cout << min(pat_1, pat_2) << endl;
}


Measured memory_bytes: 512
H, W = map(int,input().split())
List = [list("." +input()+ ".") for i in range(H)]
B = ["."]*(W+2)
List.insert(0,B)
List.append(B)

for i in range(1,H+1):
  for j in range(1,W+1):
    if List[i][j]=="#" and List[i-1][j]==List[i][j-1]\
        ==List[i][j+1]==List[i+1][j]==".":
      print("No")
      break
  else:
    continue
  break  

else:print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

#define ll long long;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);

  cout << s.size() << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	string a,b,c;
	cin >> a >> b >> c;
	ll ans=0;
	for(ll i=0; i<n; i++){
		if(a[i]==b[i] && a[i]!=c[i]) ans++;
		else if(a[i]==c[i] && a[i]!=b[i]) ans++;
		else if(a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]) ans+=2;
		else if(b[i]==c[i] && a[i]!=b[i]) ans++;
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


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

int main(){
    int n, m, i, s = 0;
    cin >> n >> m;
    int x[m], l[m-1];
    for(i=0; i<m; i++){
        cin >> x[i];
    }
    sort(x, x+m);
    for(i=0; i<m-1; i++){
        l[i] = x[i+1]-x[i];
    }
    sort(l, l+m-1);
    for(i=0; i<m-n; i++){
        s += l[i];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  cout << min((n % k), k - (n % k)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std; 
    using ll = long long;
    using P = pair<int,int>; // 1 つの証言を表す構造体 // 「人」と「0 or 1」
    using Graph = vector<vector<int>>;
    
    
    int main() {
    int n;
    string s;	
    cin >> n >> s;
    int ans = 0;
    
    rep(i,10){
    	rep(j,10){
    		rep(k,10){
    		int count = 0;
    			rep(l,n){
    				if(count == 0){
    					if(s[l]- '0' == i)	count++;
    					else if(l > n-2)	break;
    				} else if(count == 1){
    					if(s[l]- '0' == j)	count++;
    					else if(l > n-1)	break;
    				}else{
    					if(s[l]- '0' == k){
    						ans++;
    						break;
    					}
    					
    				}
    			}
    		}
    	}
    }
    cout << ans << endl; 
     return 0;
    }
    

Measured memory_bytes: 384
a,b,c,d = map(int,input().split())
if a==b:
    if c==d:
        print("yes")
    else:
        print("no")
elif b==c:
    if a==d:
        print("yes")
    else:
        print("no")
elif c==d:
    if a==b:
        print("yes")
    else:
        print("no")
elif a==d:
    if b==c:
        print("yes")
    else:
        print("no")
else:
    print("no")
        


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

int64_t c[100001];

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

    int n;
    int64_t k;
    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        c[a] += b;
    }

    int64_t m = 0;
    for (int i = 1; i <= 100000; i++) {
        m += c[i];
        if (m >= k) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

main(){
  int N;
  int A[101], B[101], C[101];
  
  cin >> N;

  for ( int i = 1; i <= N; i++ ) A[i] = B[i] = C[i] = false;

  int k, p;
  cin >> k;
  for ( int i = 0; i < k; i++ ) { cin >> p; A[p] = true; }
  cin >> k;
  for ( int i = 0; i < k; i++ ) { cin >> p; B[p] = true; }
  cin >> k;
  for ( int i = 0; i < k; i++ ) { cin >> p; C[p] = true; }

  int ans = 0;
  for ( int i = 1; i <= N; i++ ){
    if (!A[i] && C[i] || B[i] && C[i]) ans++;
  }

  cout << ans << endl;
}




Measured memory_bytes: 3104
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, cnt = 0;
    cin >> n;
    if (n % 2) cout << 0 << endl;
    else {
        cnt += (n /= 10);
        while (n) cnt += (n /= 5);
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;
struct state { ull x; int zero, pre, dist, remain; };
bool operator<(const state& s1, const state& s2) { return s1.dist + s1.remain > s2.dist + s2.remain; }
int a, dist[16][16], goals[16], goals2[16]; ull s, goal = 1147797409030816545;
int dir[4] = { 1, 0, -1, 0 };
inline int getheuri(ull x) {
	int ret1 = 0;
	for (int i = 0; i < 16; i++) {
		int ww = ((x >> (i * 4)) & 15);
		if (!ww) continue;
		ret1 += dist[i][goals2[ww]];
	}
	int ret2 = 0;
	for (int i = 0; i < 16; i++) {
		for (int j = i + 1; j < 16; j++) {
			int ww1 = ((x >> (i * 4)) & 15);
			int ww2 = ((x >> (i * 4)) & 15);
			if (((ww1 + 15) & 15) > ((ww2 + 15) & 15)) ret2++;
		}
	}
	int ret = max(ret1, ret2 / 3 + ret2 % 3);
	return ret;
}
int solve() {
	if (s == goal) return 0;
	int zz = -1;
	for (int i = 0; i < 16; i++) {
		if (!((s >> (i * 4)) & 15)) zz = i;
	}
	int rr = getheuri(s);
	priority_queue<state> que;
	que.push(state{ s, zz, -99, 0, rr });
	while (!que.empty()) {
		state a = que.top(); que.pop();
		ull v = a.x; int z = a.zero;
		for (int i = 0; i < 4; i++) {
			if (abs(i - a.pre) == 2) continue;
			int dx = dir[i], dy = dir[i ^ 1];
			int e = z + dy * 4 + dx;
			int g = ((v >> (e << 2)) & 15);
			if (0 <= e && e < 16 && (e & 3) - (z & 3) == dx) {
				ull w = v;
				w -= ((1ULL * g) << (e << 2));
				w += ((1ULL * g) << (z << 2));
				int xx = getheuri(w);
				if (w == goal) return a.dist + 1;
				que.push(state{ w, e, i, a.dist + 1, xx });
			}
		}
	}
	return -1;
}
int main() {
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < 16; j++) {
			dist[i][j] = abs((i >> 2) - (j >> 2)) + abs((i & 3) - (j & 3));
		}
	}
	for (int i = 0; i < 15; i++) goals[i] = i + 1; goals[15] = 0;
	for (int i = 0; i < 16; i++) goals2[goals[i]] = i;
	for (int i = 0; i < 16; i++) {
		cin >> a;
		s += ((1ULL * a) << (i * 4));
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 51944
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

struct data_t {
    string city;
    int score;
    int num;

    bool operator<( const data_t& right ) const {
        return city == right.city ? score > right.score : city < right.city;
    }
};

int N;
vector<data_t> T;
int main(void){
    cin >> N;
    REP(i,N){
        data_t t;
        cin >> t.city >> t.score;
        t.num = i+1;
        T.push_back(t);
    }
    sort(T.begin(), T.end());
    REP(i, T.size()) cout << T[i].num << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register int
#define LL long long
#define maxn 2000007
#define inf 1000000000
#define mod 100000007
#define	QAQ freopen ("cantor.in", "r", stdin); freopen ("cantor.out", "w", stdout);
using namespace std;
inline int rf(){int r,s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;%>
int main()
{
	//QAQ 
	int a=rf(),b=rf();
	if(a<=2*b) {printf("0"); return 0;}
	else {printf("%d",a-2*b); return 0;}
	
	
	
	
    return 0;
}
/*
We Secure. We Contain. We Protect
We programme. We submit. We accepted


JXU4RDc3JXU3ODAxJXVGRjBDJXU2NzAwJXU4RDc3JXU3ODAxJXVGRjBDJXU1MjFEJXU4RDVCJXU5MDFBJXU4RkM3JXVGRjAx
10
1 2 3 1 2  3 4 6 2 3


*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

string beautify(string str) {
	string ret = "";
	for (int i = 0; i < str.size(); ++i) {
		char c = str[i];
		if ('a' <= c && c <= 'z') ret += c;
		else if ('A' <= c && c <= 'Z') ret += (char)(c-'A'+'a');
	}
	return ret;
}

int main() {
	string str; cin >> str;
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		string op; cin >> op;
		int a, b; cin >> a >> b;
		if (op == "print") {
			cout << str.substr(a, b-a+1) << endl;
		}
		else if (op == "reverse") {
			reverse(str.begin()+a, str.begin()+b+1);
		}
		else if (op == "replace") {
			string p; cin >> p;
			str = str.substr(0, a) + p + str.substr(b+1);
		}
	}
}

Measured memory_bytes: 1228
S = input()

if S == "":
	print("NO")

while True:
	for subS in ["dream","dreamer","erase","eraser"]:
		if S[-len(subS):] == subS:
			S = S[:-len(subS)]
			break
		else:
			continue
			
		
	else:
		print("NO")
		exit()
		
	if S == "":
		print("YES")
		exit()

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100001

//Binary Indexed Tree (Fenwick Tree)
template<class T>
class BIT {
public:
	vector<T> v;
	BIT(int n) :v(n + 1, 0) {}
	//[1,i]??????
	//e.g. [i,j]?????? : sum(j)-sum(i-1)
	T sum(int i) {
		T sum = 0;
		for (; i > 0; i -= i&-i)
			sum += v[i];
		return sum;
	}
	//[1,i]????????§???
	T query(int i) {
		T M = 0;
		for (; i > 0; i -= i&-i) {
			M = max(M, v[i]);
			//cout << "query i:" << i << " M:" << M << endl;
		}
		return M;
	}
	//v[i]??¨????????????????´??????´??°
	void update(int i, T x) {
		for (; i < v.size(); i += i&-i) {
			//cout << "update i:" << i << " x:" << x << " v.size():" << v.size() << endl;
			v[i] = max(v[i], x);
		}
	}
};

int main() {
	ll n; cin >> n;
	BIT<ll> BIT(n);
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		BIT.update(x, BIT.query(x - 1) + x);
		//cout << endl;
		//for (int j = 1; j <= n; j++) {
		//	cout << BIT.v[j] << " ";
		//}
		//cout << endl;
	}


	cout << n*(n + 1) / 2 - BIT.query(n) << endl;
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  VI xs(3);
  cin >> xs;
  RSORT(xs);

  cout << xs[0]*10+xs[1]+xs[2] << endl;

  return 0;
}


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

int main(){
  int cou1,cou2,n,m;
  string ans,str;
  pair<string,string> hen[11111];
  while(1){
    ans = "";
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      cin >> hen[i].first >> hen[i].second;
    }
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> str;
      for(int j=0;j<n;j++){
	if(hen[j].first == str){
	  str = hen[j].second;
	  break;
	}
      }
      ans += str;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1532
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())

uf = UnionFind(N)

for i in range(M):
    A,B=map(int,input().split())
    uf.union(A-1,B-1)

print(max([uf.size(i) for i in range(N)]))

Measured memory_bytes: 93252
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int ans = 0;
			for (int i = 0; i < n / 4; i++)
				ans += scanner.nextInt();
			System.out.println(ans);
		}
	}
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d %d" , &n , &m);
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 100000;
LL n, k;
vector<LL> v[M], A, B;

int main() {
	cin >> n >> k;
	inc(i, n) {
		LL t, d;
		cin >> t >> d;
		t--;
		v[t].PB(d);
	}
	
	inc(t, M) {
		sort(RALL(v[t]));
		inc(i, v[t].size()) { (i == 0 ? A : B).PB(v[t][i]); }
	}
	sort(RALL(A));
	sort(RALL(B));
	
	vector<LL> SA(A.size() + 1); inc(i, A.size()) { SA[i + 1] = SA[i] + A[i]; }
	vector<LL> SB(B.size() + 1); inc(i, B.size()) { SB[i + 1] = SB[i] + B[i]; }
	
	LL ans = 0;
	inc1(i, k) {
		if(i > A.size() || k - i > B.size()) { continue; }
		
		LL x = i;
		setmax(ans, SA[i] + SB[k - i] + x * x);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
// struct bbk{
//     int a,b,c,d;
// };
// bbk arr[15];

int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    if(c<b){
        cout<<(a*c)/b<<endl;
    }
    else{
        cout<<(a*(b-1))/b<<endl;
    }
}

Measured memory_bytes: 3636
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    n = int(input().rstrip())
    v_list = [int(x) for x in input().rstrip().split(" ")]

    v_list.sort()

    ans = v_list[0]
    for i in range(1, len(v_list)):
        ans = (ans + v_list[i]) / 2

    print(ans)



if __name__ == "__main__":
    resolve()


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

int main() {
  int N, M, K[N], i, j, point = 0, c = 0;
  cin >> N >> M;
  int f[N][M];
  
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++)
      f[i][j] = 0;
  }
  
  for (i = 0; i < N; i++) {
    cin >> K[i]; //i番目の人は、M個中、K[i]個の食べ物が好き。
    int A[N][K[i]];
    for (j = 0; j < K[i]; j++) {
      cin >> A[i][j];
      //i番目の人は、M個中、A[i][0], A[i][1], ... ,A[i][K[i] - 1]番目の食べ物が好き。
      f[i][A[i][j] - 1] = 1;
    }
  }
  for (j = 0; j < M; j++) {
    point = 0;
    for (i = 0; i < N; i++)
      point += f[i][j];
    if (point == N)
      c++;
  }
  cout << c;
  return 0;
}
    

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

#define pb(a) push_back(a)
#define INF 1145141919810
#define mod 1000000007

typedef long long ll;

const int dsize = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[dsize],fac[dsize];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<dsize;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<dsize;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

int main() {
	int K=in();ll a[K];
	for (int i=0;i<K;i++) a[i]=in();
	ll mi=2,ma=2;
	for (int i=1;i<=K;i++) {
		ll x=a[K-i];
		if (mi%x) {
			mi=mi-mi%x+x;
		}
		ma=ma-ma%x+x-1;
		if (ma<mi) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << mi << " " << ma << endl;
	return 0;
}
    

Measured memory_bytes: 1024
#include <iostream>

using lli = long long int;

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

constexpr int MAX_SIZE_ = 200000;
constexpr int ALPHABET_NUMBER = 'Z' - 'A' + 1;
char str[MAX_SIZE_ + 2];
lli ALPHABET[ALPHABET_NUMBER];

int main(void){
    scanf("%s", str); int n = strlen(str);
    REP(i, ALPHABET_NUMBER) ALPHABET[i] = 0;
    REP(i, n) ALPHABET[str[i] - 'a']++;
    lli res = 0;
    REP(i, ALPHABET_NUMBER) res += (ALPHABET[i] * (n - ALPHABET[i]));
    (res >>= 1)++;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <cstdlib> 
#include <math.h>
#define gap cout<<endl;
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define INF 1<<30
#define present(c,x) ((c).find(x) != (c).end())
const int N=20000;
std::vector<int> fact(3000,1);
int k;
string n;
int pow(int a, int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a);
        b/=2;
        a=(a*a);
    }
    return ans;
}
 
 
 
 
int nCr(int x, int y)
{
    if(y>x)
        return 0;
    if(y==0) return 1;
    if(x==y) return 1;
    if(x==0&&y==0) return 1;
    
     //cout<<x<<" "<<y<<endl;
    if(y==1) return x;
    if(y==2){
        return x*(x-1)/(2);
    }
    if(y==3){
        return x*(x-1)*(x-2)/(6);
    }
    return 1;
    //cout<<fact[]<<endl;
    //if(num2==0) cout<<x<<" "<<y<<endl;
    
}
int fu(string s,int k){
    if(k<=0) return 1;
    int len=sz(s);
    if(len==0) return 0;
    int tmp,tmp2,tmp3;
    tmp=tmp3=tmp2=0;
    //cout<<tmp<<endl;
    if(k>len) return 0;
    if(s[0]=='0') return fu(s.substr(1),k);
    if(s[0]>'0') tmp=nCr(len-1,k)*(pow(9,k));
    tmp3=(s[0]-'0'-1)*(nCr(len-1,k-1))*(pow(9,k-1));
    
    if(len>=1) {string s2=s.substr(1);
         tmp2=(fu(s2,k-1));}
     
 
    return tmp2+tmp3+tmp;
 
}
 
 
int main(){
    
     
    cin>>n>>k; 
    int ans=fu(n,k);
    cout<<ans<<endl;
}

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

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>D( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[i];
	}
	double maxans = 1, minans = 0;
	for( size_t idx = 0; idx < 40; idx++ ) {
		double midans = ( maxans + minans ) / 2;
		set<int>prev;
		prev.insert( 1 );
		for( size_t i = 0; i < N; i++ ) {
			double minvalue = D[i] * ( 1. - midans );
			double maxvalue = D[i] * ( 1. + midans );
			set<int>next;
			for( auto one : prev ) {
				for( int j = minvalue / one + 1; j <= maxvalue / one; j++ ) {
					next.insert( j*one );
				}
			}
			prev = next;
		}
		if( prev.size() ) {
			maxans = midans;
		} else {
			minans = midans;
		}

	}
	cout << fixed << setprecision( 20 ) << minans << endl;
}

Measured memory_bytes: 10748