akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Bridge> list = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			list.add(new Bridge(sc.nextInt(), sc.nextInt()));
		}
		Collections.sort(list, new Comparator<Bridge>() {
		public int compare(Bridge b1, Bridge b2) {
			if (b1.end == b2.end) {
				return b1.start - b2.start;
			} else {
				return b1.end - b2.end;
			}
		}
		});
		int count = 0;
		while (list.size() > 0) {
			Bridge b = list.get(0);
			while (list.size() > 0) {
				Bridge out = list.get(0);
				if (out.start >= b.end) {
					break;
				}
				list.remove(0);
			}
			count++;
		}
		System.out.println(count);
	}
	
	static class Bridge {
		int start;
		int end;
		public Bridge(int start, int end) {
			this.start = start;
			this.end = end;
		}
		
		public int hashCode() {
			return start + end * 1000;
		}
		
		public boolean equals(Object o) {
			Bridge b = (Bridge) o;
			return b.start == start && b.end == end;
		}
	}
}


Measured memory_bytes: 91688
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}
double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}
xy_t projection(xy_t p, xy_t b) {
  return b*dot_product(p,b)/norm(b);
}

xy_t P[110];
int main() {
  int N = 0;
  double x, y;
  while (scanf("%lf,%lf", &x, &y) != EOF)
    P[N++] = xy_t(x,y);
  double sum = 0.0;
  for (int i = 0; i + 2 < N; ++i) {
    xy_t a = P[0], b = P[i+1], c = P[i+2];

    sum += cross_product(b-a, c-a)/2.0;
  }
  printf("%.6f\n", abs(sum));
}



Measured memory_bytes: 3212
#include<stdio.h>
 
struct dice{
  int s1[6];
  int jmen[24],zmen[24];
};
   struct dice D;
int main(){

  int i,j,n;
 
  for(i=0;i<6;i++)
    scanf("%d",&D.s1[i]);
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&D.jmen[i],&D.zmen[i]);
 
  
    if(D.jmen[i] == D.s1[0]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[1]){
      if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[2]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[0]);
    }
    else if(D.jmen[i] == D.s1[3]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[5]);
    }
    else if(D.jmen[i] == D.s1[4]){
      if(D.zmen[i] == D.s1[0])printf("%d\n",D.s1[2]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[5]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[0]);
      else if(D.zmen[i] == D.s1[5])printf("%d\n",D.s1[3]);
    }
    else if(D.jmen[i] == D.s1[5]){
      if(D.zmen[i] == D.s1[1])printf("%d\n",D.s1[3]);
      else if(D.zmen[i] == D.s1[2])printf("%d\n",D.s1[1]);
      else if(D.zmen[i] == D.s1[3])printf("%d\n",D.s1[4]);
      else if(D.zmen[i] == D.s1[4])printf("%d\n",D.s1[2]);
    }
  }
  return 0;
}


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

int main()
{
	int N; cin >> N;
	vector<int>A(N), B(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];

	long long a=0, b=0;
	for (int i = 0; i < N; i++) {
		if (A[i] > B[i])b += A[i] - B[i];
		else if (A[i] < B[i])a += (B[i] - A[i])/2;
	}

	if (a >= b)cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>

using namespace std;

struct Memo
{

  int count;
  bool flag;

  Memo()
  {
    count = 0;
    flag = false;
  }

};

int ProgressNumberOfYears(Memo memo[][4], int step_num, int step_kind)
{

  int kind_count = 0;


  if(step_num == 0) return 1;
  else if(step_num < 0)  return 0;
  else if(memo[step_num][step_kind].flag)  return memo[step_num][step_kind].count;
  for(int i = 1; i < 4; ++i)
    {
      kind_count = kind_count + ProgressNumberOfYears(memo,step_num - i,i);
    }

  memo[step_num][step_kind].count = kind_count;
  memo[step_num][step_kind].flag = true;

  return kind_count;

}

int main()
{

  int step_num;
  Memo memo[31][4];

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(memo,step_num,0)/10/365 + 1<< endl;

  return 0;

}

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

bool isntin(vector<int> &vec, int val){
    for(auto &&n : vec){
        if(n == val) return false;
    }
    return true;
}

int main(){
    int x, n, x1, result = 1024;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    if(isntin(p, x)){
        cout(x);
        return 0;
    }

    for(int i=x; i<=101; ++i){
        if(isntin(p, i)){
            result = i;
            break;
        }
    }
    for(int i=0; i<x; ++i){
        if(isntin(p, i) && result - x >= x - i){
            result = i;
            break;
        }
    }
    cout(result);    
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    int A2=A,B2=B;
    A=min(A2,B2),B=max(A2,B2);
    if(A<C && C<B) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main() {
    unsigned long long X, Y;
    cin >> X >> Y;

    unsigned long long count = 0;
    for (unsigned long long n = X; n <= Y; n *= 2) {
        count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
x = len(s)
y = len(t)
dp = [[0]*(y+1) for _ in range(x+1)]
for i in range(x):
    for j in range(y):
        if s[i] == t[j]: dp[i+1][j+1] = dp[i][j] + 1
        else: dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
        
# for i in range(x+1): print(dp[i])
ans = ""
i = x
j = y
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]: i -= 1
    elif dp[i][j] == dp[i][j-1]: j -= 1
    else:
        ans = s[i-1]+ans
        i -= 1
        j -= 1
print(ans)

Measured memory_bytes: 112220
N = int(input())
A = list(map(int,input().split()))

nowi = 0
nowj = 0
prej = -1

nowX = 0
nowS = 0
ans = 0

while nowj < N:
    #print(nowS,nowX,0)
    nowS += A[nowj]
    nowX ^= A[nowj]
    if nowX == nowS:
        nowj += 1
    else:
        #print(prej,nowi,nowj,(prej - nowi+1)*(nowj - prej - 1) + (nowj - prej - 1)*(nowj - prej)//2)
        ans += (prej - nowi+1)*(nowj - prej - 1) + (nowj - prej - 1)*(nowj - prej)//2
        prej = nowj - 1
        while nowS != nowX:
            #print(nowS,nowX,1)
            nowS -= A[nowi]
            nowX ^= A[nowi]
            nowi += 1
        nowj += 1
ans += (prej - nowi+1)*(nowj - prej - 1) + (nowj - prej - 1)*(nowj - prej)//2
print(ans)

Measured memory_bytes: 77900
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(){

    string a, b;
    cin >> a >> b;

    string num = "";
    num += a;
    num += b;

    int x = stoi(num); 
    double root = sqrt(x);

    // cout << " root : " << root << " x : " << x << endl;

    string ans = ((root-(int)root)!=0) ? "No" : "Yes";

    cout << ans << endl; 



    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int s[3] = {};
	REP(i, n) {
		int tmp;
		cin >> tmp;
		if (tmp <= a) {
			s[0]++;
		}
		else if (tmp <= b) {
			s[1]++;
		}
		else s[2]++;
	}
	cout << min({ s[0],s[1],s[2] }) << endl;
	return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int n;

int main() {
	read(n);
	if (n == (n & -n)) {
		printStr("No");
		return 0;
	}
	printStr("Yes");
	std::vector<int> ans;
	if (n & 1) {
		for (int i = 2; i < n; i += 2) {
			ans.push_back(i);
		}
	} else {
		int x = n & -n, y = n ^ x;
		ans.push_back(x ^ 1);
		ans.push_back(y);
		for (int i = 2; i < n; i += 2) {
			if (i != x && (i ^ 1) != x && i != y && (i ^ 1) != y) {
				ans.push_back(i);
			}
		}
		print(x, ' '), print(n);
		print(y, ' '), print(n + n);
	}
	int lst1 = 1, lst2 = 1;
	for (int v : ans) {
		print(lst1, ' '), print(v);
		print(v, ' '), print(v ^ 1);
		lst1 = v ^ 1;
		print(lst2, ' '), print(n + (v ^ 1));
		print(n + (v ^ 1), ' '), print(n + v);
		lst2 = n + v;
	}
	print(ans[0] ^ 1, ' '), print(n + 1);
}


Measured memory_bytes: 6112
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    long[] a;
    long N;
    private void solve() {
        N = nextLong();

        a = new long[5];
        long min = Long.MAX_VALUE;
        for(int i = 0;i < 5;i++) {
            a[i] = nextLong();
            min = Math.min(min, a[i]);
        }

        long ans = 5;
        N = Math.max(N - min, 0);
        ans += N / min;
        ans += (N % min > 0 ? 1 : 0);
        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22484
#include<stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if (a + b == 15){
		printf("+\n");
	}
	else if (a * b == 15){
		printf("*\n");
	}
	else{
		printf("x\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int candy;

  while(scanf("%d", &candy) != EOF){

    while(candy > 39)
      candy -= 39;

    if(candy < 10)
      printf("3C0%d\n", candy);
    else
      printf("3C%d\n", candy);
  }

  return 0;
}

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

long int divide_sum(long int N){
    int digits;
    long int Ncp=N;
    for(int i=0; i<10;i++) {
        if(Ncp/10==0) {
            digits=i;
            break;
        } else {
            Ncp /= 10;
        }
    }

   long int sum=0;
   if(N/10==0) return N;
   sum += N;
    long int divide_digit=10;
    long int patarn=1;
    for(int i=0;i<digits;i++) {
        sum += (N/divide_digit)*patarn + divide_sum(N%divide_digit);
        divide_digit*=10;
        patarn*=2;

    }

    return sum;
}

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

  vector<int> num(4);
  for(int i=0;i<4;i++) {
      if(N.at(i)=='0') num.at(i)=0;
      if(N.at(i)=='1') num.at(i)=1;
      if(N.at(i)=='2') num.at(i)=2;  
      if(N.at(i)=='3') num.at(i)=3;  
      if(N.at(i)=='4') num.at(i)=4;  
      if(N.at(i)=='5') num.at(i)=5;  
      if(N.at(i)=='6') num.at(i)=6;  
      if(N.at(i)=='7') num.at(i)=7;  
      if(N.at(i)=='8') num.at(i)=8;  
      if(N.at(i)=='9') num.at(i)=9;  
  }

  while(1){
  if(num.at(0)+num.at(1)+num.at(2)+num.at(3)==7) {
      cout << num.at(0) << "+" << num.at(1) << "+" << num.at(2) << "+" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)-num.at(1)+num.at(2)+num.at(3)==7) {
      cout << num.at(0) << "-" << num.at(1) << "+" << num.at(2) << "+" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)+num.at(1)-num.at(2)+num.at(3)==7) {
      cout << num.at(0) << "+" << num.at(1) << "-" << num.at(2) << "+" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)-num.at(1)-num.at(2)+num.at(3)==7) {
      cout << num.at(0) << "-" << num.at(1) << "-" << num.at(2) << "+" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)+num.at(1)+num.at(2)-num.at(3)==7) {
      cout << num.at(0) << "+" << num.at(1) << "+" << num.at(2) << "-" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)-num.at(1)+num.at(2)-num.at(3)==7) {
      cout << num.at(0) << "-" << num.at(1) << "+" << num.at(2) << "-" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)+num.at(1)-num.at(2)-num.at(3)==7) {
      cout << num.at(0) << "+" << num.at(1) << "-" << num.at(2) << "-" << num.at(3) << "=7" << endl;
      break;
  }
  if(num.at(0)-num.at(1)-num.at(2)-num.at(3)==7) {
      cout << num.at(0) << "-" << num.at(1) << "-" << num.at(2) << "-" << num.at(3) << "=7" << endl;
  }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
struct Union_Find{
  vi par,size;
  Union_Find(int N):par(N),size(N,1){
    rep(i,0,N) par[i]=i;
  }
  int root(int X){
    if(par[X]==X) return X;
    return par[X]=root(par[X]);
  }
  int unite(int X,int Y){
    int RX=root(X),RY=root(Y);
    if(RX==RY) return 0;
    par[RX]=RY;
    int ret=(size[RX]+size[RY])*(size[RX]+size[RY]-1)/2-size[RX]*(size[RX]-1)/2-size[RY]*(size[RY]-1)/2;
    size[RY]+=size[RX];
    size[RX]=0;
    return ret;
  }
  void output(){
    rep(i,0,par.size()) cout<<root(i)<<" ";
    cout<<endl;
  }
};
signed main(){
  int N,M; cin>>N>>M;
  vi A(M),B(M);
  rep(i,0,M) cin>>A[i]>>B[i];
  vi ans(M);
  reverse(ALL(A));
  reverse(ALL(B));
  Union_Find tree(N);
  int sum=0;
  rep(i,0,M){
    ans[i]=sum;
    sum+=tree.unite(A[i]-1,B[i]-1);
  }
  reverse(ALL(ans));
  rep(i,0,M) cout<<N*(N-1)/2-ans[i]<<endl;
  }



Measured memory_bytes: 5248
import itertools
s = input()
a,b,c,d = s
op = ["+","-"]

for op1,op2,op3 in itertools.product(op,repeat = 3):
    ans = a + op1 + b + op2 + c + op3 + d
    if eval(ans) == 7:
        print(ans + "=7")
        break
    else:
        pass

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

const int MX = 2005;
bool d[3][3][MX]; // [最初の文字列][次の文字列][ずれ幅]

int main() {
  vector<string> s(3);
  rep(i, 0, 3) {
    cin >> s[i];
  }

  sort(All(s));
  int ans = MX * 3;

  do {
    rep(i, 0, 3) {
      rep(j, 0, 3) {
        if (i >= j) continue;
        rep(k, 0, s[i].size()) { // 最初の文字列の長さまででいい
          bool ok = true;
          rep(ni, k, s[i].size()) {
            int nj = ni - k;
            if (nj >= s[j].size()) break;
            if (s[i][ni] == '?' || s[j][nj] == '?') continue;
            if (s[i][ni] != s[j][nj]) ok = false;
          }
          d[i][j][k] = ok;
        }
      }
    }

    auto f = [&](int i, int j, int k) {
      if (k >= s[i].size()) return true;
      return d[i][j][k];
    };

    rep(x, 0, MX) {
      rep(y, 0, MX) {
        if (!f(0, 1, x)) continue; // 0,1をxずらしてだめ
        if (!f(1, 2, y)) continue; // 1,2をyずらしてだめ
        if (!f(0, 2, x+y)) continue; // 0,2をx+yずらしてだめ
        int now = 0;
        // 右端が2の文字列とは限らない!
        now = max<int>(now, s[0].size());
        now = max<int>(now, x+s[1].size());
        now = max<int>(now, x+y+s[2].size());
        ans = min(ans, now);
      }
    }
  } while (next_permutation(All(s)));

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;

int main() {
    int h, w;
    cin >> h >> w;
    map<int,int> s;
    multiset<int> vals;
    rep(i,w) s[i] = i;
    rep(i,w) vals.insert(0);
    rep(i,h) {
        int l, r;
        cin >> l >> r;
        --l;
        auto it = s.lower_bound(l);
        int mr = -1;
        while (it != s.end() && it->first <= r) {
            mr = max(mr, it->second);
            int x = it->first - it->second;
            vals.erase(vals.find(x));
            s.erase(it++);
        }
        if (mr != -1 && r < w) {
            vals.insert(r - mr);
            s[r] = mr;
        }
        int ans = -1; 
        if (vals.size() > 0) {
            ans = *vals.begin() + (i+1);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 22308
using System;

class Class3
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int X = int.Parse(input[0]);
        int Y = int.Parse(input[1]);

        string result = "Yes";

        if ((4 * X - Y) < 0 || ((4*X - Y) % 2) >= 1)
        {
            result = "No";
        }

        if ((-2 * X + Y) < 0 || ((-2 * X + Y) % 2) >= 1)
        {
            result = "No";
        }

        Console.WriteLine(result);

    }
}


Measured memory_bytes: 27532
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll bc(ll i)
{
    if(i==0)
    return 1;
    ll st=1;
    for(ll j=1;j<=i;j++)
    st*=2;
    return st;
}
void solve()
{
   
      ll n;
      cin>>n;
      double x=-1+sqrt(1+8*n);
      x/=2;
      ll y=(int)x;
      if(y==x)
       cout<<y<<endl;
       else
       cout<<y+1<<endl;
      
}
int main()
{
  ll t;
  //cin>>t;
  t=1;
  while(t--)
  {
      solve();
  }
   
   
   
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    int pair1, pair2, score1, score2;
    int sco[101] = {0};
    int gre = 1;
    int team[101];

    cin >> n;

    for (int i = 0; i < ((n * (n - 1)) / 2); i++) {
        cin >> pair1 >> pair2 >> score1 >> score2;

        if (score1 > score2) {
            sco[pair1] += 3;
        }
        else if (score1 < score2) {
            sco[pair2] += 3;
        }
        else {
            sco[pair1]++;
            sco[pair2]++;
        }
    }
    for (int i = 1; i <= n; i++) {
        int cur = sco[i];
        for (int j = 1; j <= n; j++) {
            if (cur < sco[j]) {
                gre++;
            }
        }
        team[i] = gre;
        gre = 1;
    }

    for (int i = 1; i <= n; i++) {
        cout << team[i] << endl;
    }
}



Measured memory_bytes: 3088
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  numberOfElements <- VM.replicate n 1

  rank <- VM.replicate n (0 :: Int)

  let getRoot i xs = do
        j <- VM.read assocs i
        if i == j
          then return (i, xs)
          else getRoot j (i:xs)

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify i j = do
        (i',xs) <- getRoot i []
        (j',ys) <- getRoot j []
        ri <- VM.read rank i'
        rj <- VM.read rank j'
        k <- case compare ri rj of
               EQ -> do let !k = min i' j'
                        VM.write rank k (ri + 1)
                        return k
               LT -> return j'
               GT -> return i'
        VM.write assocs i' k
        VM.write assocs j' k
        forM_ xs (\l -> VM.write assocs l k)
        forM_ ys (\l -> VM.write assocs l k)
        if i' == j'
          then return 0
          else do
          n1 <- VM.read numberOfElements i'
          n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

main = do
  [n,m] <- map read . words <$> getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    [a,b] <- map read . words <$> getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 7036
n = int(input())
stop = int(n**0.5) + 1
min_count = 10 ** 100
for a in range(1, stop):
    if n % a != 0:
        continue
    else:
        b = n // a
    count = a + b - 2
    if count < min_count:
        min_count = count
print(min_count)

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

int X , Y, Z, K;
vector<long long> A;
vector<long long> B;
vector<long long> C;
vector<long long> AB;
vector<long long> ABC;

int main() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    B.resize(Y);
    C.resize(Z);
    for (int i = 0; i < X ; ++i) cin >> A[i]; 
    for (int i = 0; i < Y ; ++i) cin >> B[i]; 
    for (int i = 0; i < Z ; ++i) cin >> C[i]; 
    for (int i = 0; i < X ; ++i) for (int j = 0; j < Y; ++j) AB.push_back(A[i] + B[j]);
    sort(AB.begin(), AB.end(), greater<long long>());
    for (int i = 0; i < min(K, X * Y) ; ++i) for (int j = 0; j < Z; ++j) ABC.push_back(AB[i] + C[j]);
    sort(ABC.begin(), ABC.end(), greater<long long>());
    for (int i = 0; i < K ; ++i) cout << ABC[i] << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>p(n);
  rep(i,n) cin >> p[i];
  sort(p.rbegin(), p.rend());
  int ans = p[0]/2;
  for (int i = 1; i < (n); ++i){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> H(N);
  rep(i,N) cin>>H[i];
  sort(all(H));
  ll ans=0;
  rep(i,max(0,N-K)) ans+=H[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A == B) {
		cout << C << endl;
	}
	else if (A == C) {
		cout << B << endl;
	}
	else if (B == C) {
		cout << A << endl;
	}
	
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
an = list(map(int, input().split()))

ai = max(an)
tmpdiff = 10**9
aj = 0
for a in an:
    if ai > a and abs(ai/2-a) < tmpdiff:
        tmpdiff = abs(ai/2-a)
        aj = a

print(ai,aj)


Measured memory_bytes: 14052
import math
def is_prime(x):
    if x < 2: return False  # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True  # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False  # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    pri = 7
    step = 4
    while pri <= math.sqrt(x):
        if x % pri == 0: return False

        pri += step
        step = 6 - step

    return True

Q = int(input())

prime = [0] * 100002
prime[0] = 0
prime[1] = 0
prime[2] = 0
num = 3

while num < 100002:
    prime[num] = prime[num - 1]
    if is_prime(num) and is_prime((num + 1) // 2):
        prime[num] += 1
    num += 1
ans = []

for i in range(Q):
    a, b = map(int, input().split())
    ans.append(prime[b] - prime[a-1])

for i in range(Q):
    print(ans[i])




Measured memory_bytes: 8596
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int f(ll x)
{
    int ret=0;
    while(x)
    {
        ret++;
        x/=10;
    }
    return ret;
}
const int mod=1e9+7;
ll quick(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
ll getcnt(int l)
{
    return (quick(10,l)-quick(10,l-1)+mod)%mod;
}
int main()
{
    int s;
    cin>>s;
    int l=1;
    int cur=0;
    ll ans=0;
    for(int r=1;;r++)
    {
        cur+=f(r);
        while(cur>s)
        {
            cur-=f(l);
            l++;
        }
        if(l>=10000000) break;
        if(cur==s)
            ans++;
    }
    int len=s/8;
    ans+=len;
    ans%=mod;
    for(int i=1;i*i<=s;i++)
    {
        if(s%i==0)
        {
            if(i<=len)
                ans=(ans+getcnt(s/i)-i+mod)%mod;
            if(i*i!=s)
            {
                if(s/i<=len)
                    ans=(ans+getcnt(i)-s/i+mod)%mod;
            }
        }
    }
    print(ans);
}

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

template<class T>inline void readin(T &res) {
	static char ch;T flag = 1;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;
	res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	res*=flag;
}

int len, tot, aa[100100], cnt;
char ss[100100];
int main() {
	scanf("%s",ss);
	len = strlen(ss);
	for( int i = 0; i < len; i++ ) if(ss[i]!='x') aa[tot++]=i;
	for( int i = 0; i < tot; i++ ) if(ss[aa[i]]!=ss[aa[tot-1-i]]) {printf("-1\n");return 0;}
	int i = 0, j = len-1;
	while(i<j) {
		if(ss[i]=='x'&&ss[j]!='x') cnt++, i++;
		else if(ss[i]!='x'&&ss[j]=='x') cnt++, j--;
		else i++, j--;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main() {
	int x, ans=0, total=0;
	cin >> x;

	for (int i = 0; i < 100000; i++) {		
		total += i;
		ans++;
		
		if (total >= x) {
			cout << ans-1 << endl;
			break;
		}
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll arr[MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N, M; cin >> N >> M;

    FOR(i, 1, N+1) cin >> arr[i];

    bitset<MX+1> mk; mk.reset();
    FOR(i, 1, M+1) {
        int a, b; cin >> a >> b;

        if (arr[a] > arr[b]) {
            mk[b] = true;
        } else {
            if (arr[a] == arr[b]) mk[b] = true;
            mk[a] = true;
        }
    }



    cout << N-mk.count() << "\n";
}


Measured memory_bytes: 4460
#include <bits/stdc++.h>
// g++ test.cpp && ./a.out <in
#pragma GCC optimize("O3")
using namespace std;
#define fi first
#define se second
#define pb push_back
#define loop(i, a, b) for (int i=a; i<(b); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<int,int> pi;
const int INF = 1e9;
const int MOD = 1000000007;

void test_case() {	
	int a,b,c;
	cin>>a>>b>>c;
	int k; cin>>k;
	int ans = 0;
	while(a>=b){
		b*=2;
		ans++;
	}
	while(b>=c){
		c*=2;
		ans++;
	}
	if(ans<=k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		test_case();
	}
	return 0;
}

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------

void solve() {
    int n;
    cin >> n;

    cout << (n/500)*1000 + ((n%500)/5)*5 << endl;    

    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int n,m,q;
  cin>>n>>m>>q;
  vector<array<int,4> > Q(q);
  int an = 0;
  vector <int> v;
  forn(i,q) forn(j,4) { cin>>Q[i][j]; Q[i][j]-=j<=1;}
  function<void(int)> dfs = [&](int u){
  	if(v.size()==n){
		int ma = 0;
		an = max(an, accumulate(all(Q), ma, [&](int k, array<int,4> z){
			return v[z[1]] - v[z[0]] == z[2]? k + z[3]: k;
		}));
		return;
	}
	for(int i = u; i<=m ;i++){
		v.pb(i);
		dfs(i);
		v.pop_back();
	}
  };
  dfs(1);
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 3676
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
int a[N],n;
vector<int> adj[N];
int solve(int node){
  vector<int> v;
  for(auto x : adj[node]){
    v.push_back(1 + solve(x));
  }
  sort(v.rbegin(),v.rend());
  int mx = 0;
  for(int i = 0; i < v.size(); i++)mx=max(mx,i+v[i]);
  return mx;
}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n;

  f(i,2,n+1){
    cin >> a[i];
    adj[a[i]].push_back(i);
  }

  cout << solve(1) << '\n';


  return 0;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

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

  string s,t; cin >> s >> t;
  int a,b; cin >> a >> b;
  string u; cin >> u;
  if(s==u) a--;
  if(t==u) b--;
  cout << a <<" "<< b << endl;

  return 0;
}



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

int main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int counter = 0;

    for (int i = 0; i < A+1; i++)
    {
        for (int j = 0; j < B+1; j++)
        {
            for (int k = 0; k < C+1; k++)
            {
                if (500 * i + 100 * j + 50 * k == X)
                {
                    counter++;
                }
            }
        }
    }

    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;

int main(void){
  string s;
  cin >> s;
  if(*(s.end()-1) == 's'){
    cout << s + "es" << endl;
  }else{
    cout << s + "s" << endl;
  }
  
  return 0;
}

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

double p1[2]={0.0,0.0},p2[2]={100.0,0.0};

#define A 1.0471975511965

void koch(int d,double p1[],double p2[]){
	if(d==0){return;}
	double p3[2],p4[2],p5[2];
	p3[0]=p1[0]+(p2[0]-p1[0])*1.0/3.0;
	p3[1]=p1[1]+(p2[1]-p1[1])*1.0/3.0;
	p5[0]=p1[0]+(p2[0]-p1[0])*2.0/3.0;
	p5[1]=p1[1]+(p2[1]-p1[1])*2.0/3.0;
	p4[0]=(p5[0]-p3[0])*cos(A)-(p5[1]-p3[1])*sin(A)+p3[0];
	p4[1]=(p5[0]-p3[0])*sin(A)+(p5[1]-p3[1])*cos(A)+p3[1];
	koch(d-1,p1,p3);
	cout<<p3[0]<<' '<<p3[1]<<endl;
	koch(d-1,p3,p4);
	cout<<p4[0]<<' '<<p4[1]<<endl;
	koch(d-1,p4,p5);
	cout<<p5[0]<<' '<<p5[1]<<endl;
	koch(d-1,p5,p2);
}

int main(){
	int n;
	cin>>n;
	cout<<p1[0]<<' '<<p1[1]<<endl;
	koch(n,p1,p2);
	cout<<p2[0]<<' '<<p2[1]<<endl;
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast_I_O ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 1e9+7 , INF = 1e9 ,  mx = 100005 ;
main()
{
    fast_I_O;
    int i,j,n,m,x,y,sum=0,p=0,l,k,mn=LLONG_MAX,mx=LLONG_MIN;
    cin>>n;
    cout<<!n;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000010
using namespace std;

int gcd(int a, int b, int c){
	int ans;
	ans = __gcd(a, __gcd(b, c));
	return ans;
}

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

	ll k, sum = 0;
	cin >> k;
	for(int a=1; a<=k; a++){
		for(int b=1; b<=k; b++){
			for(int c=1; c<=k; c++){
				sum += gcd(a, b, c);
			}
		}
	}
	cout << sum;

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    int n;
    cin >> n;
    vector<ll> v(n);
    for(ll& x : v) cin >> x;
    sort(v.rbegin(),v.rend());
    
    priority_queue<long long> spaces;

    long long ans = 0;
    spaces.push(v[0]);

    for(int i = 1; i < n; ++i)
    {
        ans += spaces.top();
        spaces.pop();
        spaces.push(v[i]);
        spaces.push(v[i]);
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 6896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll X, Y, ans = 0;

	cin >> X >> Y;

	while (X <= Y) {
		ans++;
		X *= 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# coding=utf-8
 
class Node:
    def __init__(self, ID, left, right):
        ### information for output ###
        self.id = ID
        self.parent = -1
        self.sibling = -1
        self.degree = -1
        self.depth = 0
        self.height = 0
        self.type = None
 
        ### other information ###
        self.left_child = left
        self.right_child = right
 
def calc_depth(i):
    global node_list
 
    if node_list[i].depth != 0:
        return node_list[i].depth
 
    depth = 0
    if node_list[i].parent != -1:
        depth = calc_depth(node_list[i].parent) + 1
 
    node_list[i].depth = depth
    return depth
 
 
def calc_height(i):
    global node_list
 
    if node_list[i].height != 0:
        return node_list[i].height
 
    h1 = h2 = 0
    if node_list[i].right_child != -1:
        h1 = calc_height(node_list[i].right_child) + 1
    if node_list[i].left_child != -1:
        h2 = calc_height(node_list[i].left_child) + 1
 
    height = max(h1, h2)
    node_list[i].height = height
    return height
 
n = int(input())
data = [tuple(map(int, input().split())) for x in range(n)]
node_list = []
 
for data_row in data:
    ID, left, right = data_row
    node = Node(ID, left, right)
    node_list.append(node)
 
node_list.sort(key = lambda node: node.id)
 
for i, node in enumerate(node_list):
    left = node.left_child
    right = node.right_child
    degree = 0
 
    ### child information ###
    if left != -1:
        degree += 1
        node_list[left].parent = i
        node_list[left].sibling = right
 
    if right != -1:
        degree += 1
        node_list[right].parent = i
        node_list[right].sibling = left
 
    ### self information ###
    node.degree = degree
 
for i in range(n):
    calc_depth(i)
    calc_height(i)
 
    node = node_list[i]
 
    if node.depth == 0:
        node.type = 'root'
    elif node.height == 0:
        node.type = 'leaf'
    else:
        node.type = 'internal node'
 
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.id, node.parent, node.sibling, node.degree, node.depth, node.height, node.type))

Measured memory_bytes: 7868
n = int(input())
a = list(map(int,input().split()))
ans = 1
up = down = False
for i in range(n-1):
    if a[i] < a[i+1]:
        if up:continue
        up = True
        if down:
            ans+=1
            up = down = False
    elif a[i] > a[i+1]:
        if down:continue
        down = True
        if up:
            ans+=1
            up = down = False
print(ans)

Measured memory_bytes: 62704
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i > 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t int64;
typedef int64_t ll;

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;


class E {
	const int MOD{ 1000000007 };
	string l;
	int n;
	vector<vector<ll>> dp;
public:
	E()
	{
		cin >> l;
		n = SZ(l);
		dp.resize(2, vector<ll>(n + 1, 0));
		dp[0][0] = 1;
	}
	void solve()
	{
		REP(i, n)
		{
			if (l[i] == '0')
			{
				dp[0][i + 1] = dp[0][i];
				dp[1][i + 1] = 3 * dp[1][i] % MOD;
			}
			else
			{
				dp[0][i + 1] = 2 * dp[0][i] % MOD;
				dp[1][i + 1] = (dp[0][i] + 3 * dp[1][i]) % MOD;
			}

		}
		ll ans{ (dp[0][n] + dp[1][n]) % MOD };
		cout << ans << endl;
	}
};


int main()
{
	E solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

p = int(input())
a = [int(i) for i in input().split()]

ret = [0] * p
fac = [1]
inv = [1]
for i in range(1, p) :
    fac.append(fac[-1] * i % p)
    inv.append(pow(fac[-1], p - 2, p))

for i in range(p) :
    if a[i] == 0 :
        continue
    ret[0] += 1
    power = 1
    for j in range(p-1, -1, -1) :
        ret[j] += -fac[p-1]*inv[p-1-j]*inv[j]*power%p
        ret[j] %= p
        power *= -i
        power %= p
print(' '.join(map(str, ret)))

Measured memory_bytes: 43068