akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	a := intSliceScanner(n)
	b := intSliceScanner(n)
	stock := 0
	need := 0
	for i := 0; i < n; i++ {
		if a[i] > b[i] {
			need += a[i] - b[i]
		} else {
			stock += (b[i] - a[i]) / 2
		}
	}
	if need <= stock {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] div = str.split(" ");
		int[] divint = new int[div.length];
		for(int i = 0;i<div.length;i++){
			 divint[i] = Integer.parseInt(div[i]);
		}
		Arrays.sort(divint);
		for(int i = 0;i<div.length-1;i++){
			System.out.print(divint[i] + " ");
		}
		System.out.println(divint[div.length-1]);
		
	}	
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const ll INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    vector<ll> dp(100000000, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 1; i+j < N && j <= K; j++)
        {
            chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
        
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 784940
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    string s; cin>>s;
    bool c=false,f=false;
    REP(i,s.size()){
        if(s[i]=='C')c=true;
        if(s[i]=='F'&&c)f=true;
    }
    
    if(c&f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        //vector<vector<char>>s(51);
        int ans = 0;
        vector<string> s(n);
        for(int i=0;i<n;i++){
            string str;
            cin>>str;
            for(int j=0;j<str.size();j++){
                if(j==0)s[i].push_back(str[j]);
                else{
                    if(str[j-1]=='a' || str[j-1]=='i' || str[j-1]=='u' || str[j-1]=='e' || str[j-1]=='o')s[i].push_back(str[j]);
                }
            }
        }
        bool error = false;
        for(int i=0;i<n-1;i++){
            if(error) break;
            for(int k=i+1;k<n;k++){
                if(s[i]==s[k]){
                    ans=-1;
                    error = true;
                    break;
                }
                int flag=0;
                int a=min(s[i].size(),s[k].size());
                for(int j=0;j<a;j++){
                    if(s[i][j]!=s[k][j]){
                        ans=max(ans,j+1);
                        flag=1;
                        break;
                    }
                }
                if(flag==0)ans=max(ans,a+1);
            }
        }
            
        cout<<ans<<endl;
    }
}

            
            

Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N;
	double x;
	string u;
	double sum=0;
	
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> x >> u;
		if(u=="JPY"){
			sum += x;
		}else{
			sum += x*380000;
		}

	}

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

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

using namespace std;

int a[200005];
double ps[200005];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);

    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    for (int i = 1; i <= n; i++) {
        ps[i] = (1.0 * a[i] + 1.0) / 2;
        ps[i] += ps[i - 1];
    }

    double res = 0;
    for (int i = k; i <= n; i++) res = max(res, ps[i] - ps[i - k]);

    printf("%.12lf\n", res);
}


Measured memory_bytes: 6056
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[0]+list(map(int,input().split()))+[0]
    max=0
    for i in range(n+1):
        max+=abs(l[i+1]-l[i])
    for j in range(1,n+1):
        if l[j-1]<l[j]<l[j+1] or l[j-1]>l[j]>l[j+1]:
            print(max)
        else:
            x=abs(l[j+1]-l[j])
            y=abs(l[j]-l[j-1])
            z=abs(l[j+1]-l[j-1])
            print(max-x-y+z)
resolve()

Measured memory_bytes: 66848
#include<bits/stdc++.h>
using namespace std;
string s;
int k;
int main()
{
    cin>>k>>s;
    int l=s.length();
    string ans;
    if(l>k){
        string c="...";
        ans=s.substr(0,k);
        ans+=c;
    }else{
        ans=s;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;

ll n,k, ans;

int main(){
  cin >> n >> k;
  double ans = 0;
  rep(i,n){

    int t;
    if((i+1) < k) t = ceil( log((double)k/(double)(i+1))/log(2) );
    else t = 0;
    ans += powl(n, -1)*powl(2, -t);
    // cout << t << "\n";
  }
  printf("%.13f\n", ans);
}

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

int main(){
    string S, T, U;
    int A, B;

    std::cin >> S >> T;
    std::cin >> A >> B;
    std::cin >> U;

    if(U == S){
        A = A - 1;
    }else{
        B = B - 1;
    }

    std::cout << A << " " << B;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

typedef struct{ll x, y;} point;

int
main(int argc, char *argv[])
{
  int n, k;
  scanf("%d %d", &n, &k);
  point p[100];
  for (int i = 0; i < n; i++) scanf("%lld %lld", &p[i].x, &p[i].y);

  ll ans = LLONG_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int s = 0; s < n; s++) {
	for (int t = 0; t < n; t++) {
	  ll ymin = LLONG_MAX, ymax = LLONG_MIN;
	  ll xmin = LLONG_MAX, xmax = LLONG_MIN;
	  ymin = Min(p[i].y, Min(p[j].y, Min(p[s].y, p[t].y)));
	  ymax = Max(p[i].y, Max(p[j].y, Max(p[s].y, p[t].y)));
	  xmin = Min(p[i].x, Min(p[j].x, Min(p[s].x, p[t].x)));
	  xmax = Max(p[i].x, Max(p[j].x, Max(p[s].x, p[t].x)));
	  int cnt = 0;
	  for (int z = 0; z < n; z++) {
	    if (ymin <= p[z].y && p[z].y <= ymax &&
		xmin <= p[z].x && p[z].x <= xmax)
	      cnt++;
	  }
	  if (cnt >= k) ans = Min(ans, (xmax - xmin) * (ymax - ymin));
	}
      }
    }
  }

  printf("%lld\n", ans);

  return 0;
}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,i,p;
	cin >> n;

	p = sqrt(n);

	for(i=p;i>=1;i--)
	{
		if(n%i == 0)
		{
			p = n/i;
			cout << i-1+p-1 << "\n";
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct PalindromicTree{
  struct node{
    map<char, int> nxt;
    int len,suf,app,cnt;
    node(){}
    node(int len,int suf,int app,int cnt)
      :len(len),suf(suf),app(app),cnt(cnt){}
  };
  vector<node> v;
  vector<int> ord;
  int n,ptr;

  PalindromicTree(){}
  PalindromicTree(const string &s)
    :v(s.size()+10),n(2),ptr(1){

    v[0]=node(-1,0,-1,0);
    v[1]=node( 0,0,-1,0);

    for(int i=0;i<(int)s.size();i++) add_char(s,i);
    calc_order();
    calc_count();
  }

  bool add_char(const string &s,int pos){
    char ch=s[pos];
    int cur=ptr;
    while(1){
      int rev=pos-1-v[cur].len;
      if(rev>=0&&s[rev]==ch) break;
      cur=v[cur].suf;
    }

    if(v[cur].nxt.count(ch)){
      ptr=v[cur].nxt[ch];
      v[ptr].cnt++;
      return false;
    }
    ptr=n++;

    v[ptr]=node(v[cur].len+2,-1,pos-v[cur].len-1,1);
    v[cur].nxt[ch]=ptr;

    if(v[ptr].len==1){
      v[ptr].suf=1;
      return true;
    }

    while(1){
      cur=v[cur].suf;
      int rev=pos-1-v[cur].len;
      if(rev>=0&&s[rev]==ch){
        v[ptr].suf=v[cur].nxt[ch];
        break;
      }
    }
    return true;
  }

  void calc_order(){
    ord.clear();
    ord.push_back(0);
    ord.push_back(1);
    for(int i=0;i<(int)ord.size();i++)
      for(auto &p:v[ord[i]].nxt) ord.push_back(p.second);
  }

  void calc_count(){
    for(int i=(int)ord.size()-1;i>=0;i--)
      v[v[ord[i]].suf].cnt+=v[ord[i]].cnt;
  }
};


template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,p;
  RollingHash(){}
  RollingHash(const string &s){
    int n=s.size();
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+s[i])%MOD;
      p[i+1]=(ll)p[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*p[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};

//INSERT ABOVE HERE

signed main(){
  using ll = long long;
  string s,t;
  cin>>s>>t;

  PalindromicTree p1(s),p2(t);
  const int MOD = 1e9+7;
  const int BASE1 = 1777771;
  const int BASE2 = 1e6+3;
  RollingHash<int, MOD, BASE1> rs1(s),rt1(t);
  RollingHash<int, MOD, BASE2> rs2(s),rt2(t);

  const int MAX = 5e5+100;
  map<pair<int, int>, int> m1[MAX];
  for(int i=0;i<(int)p1.n;i++){
    PalindromicTree::node& u=p1.v[i];
    if(u.app<0) continue;
    auto p=make_pair(rs1.find(u.app,u.app+u.len),
                     rs1.find(u.app,u.app+u.len));
    m1[u.len][p]=u.cnt;
  }

  ll ans=0;
  for(int i=0;i<(int)p2.n;i++){
    PalindromicTree::node& u=p2.v[i];
    auto p=make_pair(rt1.find(u.app,u.app+u.len),
                     rt1.find(u.app,u.app+u.len));
    if(u.app<0||!m1[u.len].count(p)) continue;
    ans+=(ll)m1[u.len][p]*u.cnt;
  }

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



Measured memory_bytes: 42560
#include<iostream>
using namespace std;
int main() {
	int p, q, r;
	cin >> p >> q >> r;
	if (p <= r && q <= r) {
		cout << p + q;
		return 0;
	}
	if (p <= q && r <= q) {
		cout << p + r;
		return 0;
	}
	if (q <= p && r <= p) {
		cout << q + r;
		return 0;
	}
}

Measured memory_bytes: 256
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#g=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#a=[int(input()) for _ in range(k)]
h=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#m=[list(map(int,input().split()))for _ in range(n)]
#p=[list(input().split())for _ in range(h)]
#a=[input()for _ in range(n)]
tmp=h[0]
for i in range(1,n):
    if tmp<h[i]:
        tmp=h[i]
        tmp-=1
    if h[i]<tmp:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 14252
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

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

    int n = in.nextInt();
    int a = in.nextInt();
    int b = in.nextInt();

    int y = a / n;
    if (a % n == 0) System.out.println("OK");
    else if ((y + 1) * n <= b) System.out.println("OK");
    else System.out.println("NG");
  }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1) throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0) return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9') throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c)) c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int lb = 1, ub = 1000000000;
    while (lb != ub)
    {
        int t = (lb + ub) / 2;
        int count = 0;
        for (int i = 0; i < n; i++)
            count += (a[i] / t + (a[i] % t != 0) - 1);

        if (count <= k)
            ub = t;
        else
        {
            if (t == lb)
                break;
            lb = t;
        }
    }
    cout << ub << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  ll N;
  cin >> N;
  string r;
  while(0 < N) {
    N--;
    r += 97 + (char) (N % 26);
    N /= 26;
  }
  reverse(r.begin(), r.end());
  cout << r << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	long long a[n+1], b[n+1];
	a[0] = b[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i];
	}
	sort(a, a + n + 1);
	sort(b, b + n + 1);

	if(n % 2 == 1) {
		cout << b[(n+1)/2] - a[(n+1)/2] + 1 << endl;
	}
	else {
		long long mida = a[n/2] + a[n/2+1];
		long long midb = b[n/2] + b[n/2+1];
		cout << midb - mida + 1 << endl;
	}

}


Measured memory_bytes: 6720
n = int(input())
g = [set() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].add(b-1)
    g[b-1].add(a-1)

def dfs(s):
    visited = [-1]*n
    visited[s] = 0
    temp = [s]
    lst = []
    while temp:
        p = temp.pop()
        for a in g[p]:
            if visited[a] != -1:continue
            visited[a] = visited[p] + 1
            temp.append(a)
    return visited

lst0 = dfs(0)
lstn = dfs(n-1)
cnt = 0
for i in range(n):
    if lst0[i] <= lstn[i]: cnt += 1

if cnt > n - cnt: print('Fennec')
else:print('Snuke')

Measured memory_bytes: 46076
#include<stdio.h>
int main(void){
double x1,y1,x2,y2;
double l;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	
	l=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	
	printf("%lf\n", sqrt(l));
	
return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  rep(i,n){
	  cin>>A[i];
	}
	vector<int> B(n+1);
	B[0]=0;
	rep(i,n){
		B[i+1]=B[i]+A[i];
	  }
	int ans = 10000000;
	  rep(i,n){
		 int a,b;
		 b = B[n]-B[i];//bはi番目からn番目までの重りの総量
		 a = B[i]; 
		 int c = abs(b-a);
		 ans = min(ans,c);
		}

cout<<ans<<endl;
}


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

template<typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}

const int maxn = 1e5 + 11;

int n;
string s;

int main() {

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

  cin >> n;
  cin >> s;

  if (n % 2 == 1) {
    cout << "No" << endl;
  } else {
    int i = 0;
    int j = (n/2);
    while (i < j && j < n && s[i] == s[j]) {
      i++;
      j++;
    }
    if (i == (n/2) && j == n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }


  return 0;
}


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

//7, 5, 3から始め，それぞれ末尾に7, 5, 3を順に足していく
//753数出ない可能性=>判定して，okならcnt++
int main() {
    int N; cin >> N;
    int cnt = 0;
    using P = pair<ll, ll>;
    priority_queue<P, vector<P>, greater<P>> pq; 
    pq.push(P(3, 3));
    pq.push(P(5, 5));
    pq.push(P(7, 7));
    while(true) {
        P val = pq.top();
        pq.pop();
        if (val.first > N) break;
        if (val.second == 15) cnt ++;
        //データ追加
        if (val.second == 3) {
            pq.push(P(10*val.first+3, 3));
            pq.push(P(10*val.first+5, 8));
            pq.push(P(10*val.first+7, 10));
        }
        if (val.second == 5) {
            pq.push(P(10*val.first+3, 8));
            pq.push(P(10*val.first+5, 5));
            pq.push(P(10*val.first+7, 12));
        }
        if (val.second == 7) {
            pq.push(P(10*val.first+3, 10));
            pq.push(P(10*val.first+5, 12));
            pq.push(P(10*val.first+7, 7));
        }
        if (val.second == 8) {
            pq.push(P(10*val.first+3, 8));
            pq.push(P(10*val.first+5, 8));
            pq.push(P(10*val.first+7, 15));
        }
        if (val.second == 10) {
            pq.push(P(10*val.first+3, 10));
            pq.push(P(10*val.first+5, 15));
            pq.push(P(10*val.first+7, 10));
        }
        if (val.second == 12) {
            pq.push(P(10*val.first+3, 15));
            pq.push(P(10*val.first+5, 12));
            pq.push(P(10*val.first+7, 12));
        }
        if (val.second == 15) {
            pq.push(P(10*val.first + 3, 15));
            pq.push(P(10*val.first + 5, 15));
            pq.push(P(10*val.first + 7, 15));
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vi l(n);
  rep(i, n) cin >> l[i];
  sort(all(l), greater<int>());
  int ans = 0;
  rep(i, k) ans += l[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
# でました 「最大（この問題の場合は毎回右に移動する）で移動したとき、今より前の地点は、『今まで動いたiのいずれかを省く』ことで到達してたことにできる」というやつ（わかりにくい
# なので、xに到達した時点でそれまでの値はすべて実現可能という感じ

from math import ceil
x = int(input())
tmp = 0
for i in range(x + 1):
    tmp += i
    if tmp >= x:
        print(i)
        exit()

print("うんち！")

Measured memory_bytes: 9100
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

po = a[0]
ans = 0
for i in range(1,n):
    if po > a[i]:
        ans += po - a[i]
    elif po < a[i]:
        po = a[i]
print(ans)


Measured memory_bytes: 92236
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<list>
#include<set>
#include<map>
#include<stack>
# define PI 3.14159265358979323846
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
double node[maxn];

int main()
{
	ll n,k;
	cin>>n>>k;
	ll a = n%k;
	ll b = k-a;
	cout<<min(a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int Q;
    cin>>Q; ;
    rep(c,0,Q){
        string X,Y;
        cin>>X>>Y;
        int xs=X.size()+1;
        int ys=Y.size()+1;
        int dp[xs][ys];
        rep(i,0,xs)dp[i][0]=0;
        rep(j,0,ys)dp[0][j]=0;

        rep(i,1,xs){
            rep(j,1,ys){
                if(X[i-1]==Y[j-1])dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
        cout<<dp[xs-1][ys-1]<<endl;
    }
    return 0;
}





Measured memory_bytes: 7040
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			scanner.nextLine();
			DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
			LocalDate date = LocalDate.parse(s, dateTimeFormatter);
			LocalDate date0430 = LocalDate.of(2019, 4, 30);
			if (date.isAfter(date0430)) {
				System.out.println("TBD");
			} else {
				System.out.println("Heisei");
			}
		}
	}
}


Measured memory_bytes: 27344
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

typedef long long ll;


int main() {
    long long L, R; cin >> L >> R;
    if (R - L > 3000) cout << 0 << endl;
    else {
        long long res = 2018;
        for (long long i = L; i < R; ++i)
            for (long long j = i+1; j <= R; ++j)
                res = min(res, (i * j) % 2019);
        cout << res << endl;
    }
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, data):
        self.data = data

    def __eq__(self, value):
            
        for i in range(4):
            if self.data[0] == value.data[0]:
                for j in range(4):
                    if self.data == value.data:
                        return True
                    self.move('R')
            self.move('E')

        for i in range(4):
            if self.data[0] == value.data[0]:
                for j in range(4):
                    if self.data == value.data:
                        return True
                    self.move('R')
            self.move('N')
        return False

    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3], self.data[5], self.data[2] = \
                self.data[3],self.data[5], self.data[2], self.data[0] 
        elif direction == 'N':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[1],self.data[5], self.data[4], self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[4],self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2], self.data[5], self.data[3] = \
                self.data[2],self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1],self.data[2], self.data[4], self.data[3] = \
                self.data[2],self.data[4], self.data[3], self.data[1]

a = Dice(input().split())
b = Dice(input().split())

if a == b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6792
import string
s=string.ascii_lowercase
s+="C"
S=input()
buttanA=False
buttanB=False
buttanC=True


for i in range(len(S)):
    if S[0]=="A":
        buttanA=True
    if S[i]=="C" and 2<=i<len(S)-1:
        if buttanB==False:
            buttanB=True
        else:
            print("WA")
            exit()
    if S[i] not in s and 1<=i<len(S):
        buttanC=False

if buttanA==buttanB==buttanC==True:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 9908
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[100005];
LL sum[100005];
int main(){
    int n;
    LL m;
    scanf("%d%lld", &n, &m);
    for(int i=0;i<n;i++) scanf("%d", &a[i]);
    sort(a, a+n);
    for(int i=0;i<n;i++){
        sum[i] = a[i];
        if(i > 0) sum[i] += sum[i-1];
    }
    int lo = 2, hi = 2e5;
    LL ans = 0;
    while(lo <= hi){
        int mid = (lo+hi)/2;
        LL ways = 0, res = 0;

        for(int i=0;i<n;i++){
            int j = lower_bound(a, a+n, mid-a[i]) - a;
            int l = n-j;
            ways += l;
            if(j-1 >= 0) res += (sum[n-1] - sum[j-1]) + l*1ll*a[i];
            else res += sum[n-1] + l*1ll*a[i];
        }

        if(ways >= m){
            ans = res-mid*1ll*ways+mid*1ll*m;
            lo = mid+1;
        }
        else hi = mid-1;
    }
    printf("%lld\n", ans);
}

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

typedef long long ll;

int main(){
    ll L,R;
    cin >> L >> R;
    int ans=2018;
    if(R-L>=2019) ans=0;
    L%=2019;
    R%=2019;
    if(L>=R) ans=0;
    for(int i=L;i<R;i++){
        for(int j=i+1;j<=R;j++){
            ans = min(ans,i*j%2019);
        }
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 5;
vector< pair< int, int> > conn[N];

int dist[N];
bool seen[N];

int main() {
    int a, b;
    cin >> a >> b;
    if (b == 100) a = a * 1000 + b;
    else if (b >= 10) a = a * 100 + b;
    else a = a * 10 + b;
    int c = sqrt(a);
    if (c * c == a) puts("Yes");
    else puts("No");
}

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

struct V{
	int v;
	double t;
	V (int a = 0, double b = 0.0):v(a), t(b) {}
	V operator +(V o) { return V(v + o.v, (v * t + o.v * o.t) / (v + o.v)); }
	bool R(V o) { return t <= o.t; }
};

int main(){
	int n, l;
	scanf("%d%d", &n, &l);
	deque<V> T;
	T.push_back(V(l));
	double h = 0.0;
	f(i, 0, n){
		int a, b;
		scanf("%d%d", &a, &b);
		V c(b, a);
		int need = c.v;
		while (need){
			if (need >= T.back().v)need -= T.back().v, h -= T.back().v * T.back().t, T.pop_back();
			else h -= need * T.back().t, T.back().v -= need, need = 0;
		}
		h += c.v * c.t;
		while (!T.empty() && c.R(T.front()))c = c + T.front(), T.pop_front();
		T.push_front(c);
		printf("%.7lf\n", h / l);
	}
}

Measured memory_bytes: 17172
n = int(input())
w = list(input() for i in range(n))

back = w[0][-1]

for i in range(n):
    for j in range(i+1,n):
        if w[i] == w[j]:
            print("No")
            exit()

for i in range(1, n):
    pre = w[i][0]
    if pre != back:
        break
    back = w[i][-1]
    if i == n-1:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e6+9;

int n,a[N];
map<int,int>cnt;
bool ok=true;

void f(int n){
   set<int>s;
   for(int i=2;i*i<=n;i++){ 
       while(n%i==0){ 
           s.insert(i);
           n=n/i;
       }
   } 
   if(n>1)s.insert(n);
   for(auto x:s){
   	  cnt[x]++;
   	  if(cnt[x]>1)ok=false;
   }
}


int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int mx=-1;
    int g=0;
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	mx=max(mx,a[i]);
    	g=__gcd(g,a[i]);
    	f(a[i]);
    }
    if(ok){
    	cout<<"pairwise coprime";
    }
    else {
    	cout<<(g==1?"setwise coprime":"not coprime");
    }
}

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

int main(){
  int ans=0;
  string s;
  cin>>s;
  rep(i,4){
    if(s[i]=='+')ans++;
    if(s[i]=='-')ans--;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<vector<int>> C(N);
    int i,j;
    int m,c;
    for(i=0;i<N;i++) {
        cin >> m;
        for(j=0;j<m;j++) {
            cin >> c;
            C[i].push_back(c);
        }
    }
    priority_queue<int> q;
    long long ans = 0;
    for(i=0;i<N;i++) {
        for(j=0;j<C[N-i-1].size();j++)q.push(C[N-i-1][j]);
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 19076
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

int N, Q;
string s;

int goal(int pos, vector<char>& t, vector<char>& d) {
    REP(i, Q) {
        if (s[pos] == t[i]) {
            d[i] == 'L' ? pos-- : pos++;
        }

        if (pos < 0) {
            return 1;
        }

        if (pos >= N) {
            return 2;
        }
    }

    return 0;
}

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

    cin >> N >> Q;
    cin >> s;

    vector<char> t(Q), d(Q);
    REP(i, Q) {
        cin >> t[i] >> d[i];
    }

    if (goal(0, t, d) == 2 || goal(N - 1, t, d) == 1) {
        cout << 0 << endl;
        return 0;
    }

    int res = 0;

    if (goal(0, t, d) == 1) {
        int l = 0;
        int r = N - 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (goal(m, t, d) == 1) {
                l = m;
            } else {
                r = m;
            }
        }

        res += l + 1;
    }

    if (goal(N - 1, t, d) == 2) {
        int l = 0;
        int r = N - 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (goal(m, t, d) == 2) {
                r = m;
            } else {
                l = m;
            }
        }

        res += N - r;
    }

    cout << N - res << endl;

    return 0;
}


Measured memory_bytes: 960
import java.util.Scanner;
import java.math.BigDecimal;
import java.util.*;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        
        long BC = B / C;
        long AC = (A - 1) / C;
        long BD = B / D;
        long AD = (A - 1) / D;
        
        // GCD
        long x = C > D ? C : D;
        long y = C > D ? D : C;
        long a = 1;
        while(a != 0){
            a = x % y;
            x = y;
            y = a;
        }
        
        long N = C * (D / x);
        long BN = B / N;
        long AN = (A - 1) / N;
        
        System.out.println((B - (A - 1)) - (BC + BD - (AD + AC) - (BN - AN)));
    }
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
  int a,b;
  char op;
  cin>>a>>op>>b;
  while(op!='?'){
    if(op=='+'){
      cout<<a+b<<endl;
    }else if(op=='-'){
      cout<<a-b<<endl;
    }else if(op=='*'){
      cout<<a*b<<endl;
    }else if(op=='/'){
      cout<<a/b<<endl;
    }
    cin>>a>>op>>b;
  }
  return (0);
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<18)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll val[M],wt[M];
vector<pi > adj;
vector<pi > st[M];
bool mrk[M];

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

	ll n,m,p,mx,lim,i,j,k,v,c,l,ans,q;

	cin >> n;
	for(i=1;i<=n;++i)
		cin >> val[i] >> wt[i];
	mx = 1e5;
	lim = min(n+1,(1ll<<10));
	for(i=1;i<lim;++i)
	{
		mrk[i] = 1;
		v = i;
		adj.clear();
		while(v>0)
		{
			adj.pb({val[v],wt[v]});
			v = v/2;
		}
		m = adj.size();
		for(j=1;j<(1ll<<m);++j)
		{
			c = 0;
			v = 0;
			for(k=0;k<m;++k)
			{
				if((j>>k)&1ll)
				{
					c += adj[k].ss;
					v += adj[k].ff;
				}
			}
			if(c <= mx+5)
				st[i].pb(pi(-1*c,v));
		}
		sort(all(st[i]));
		m = st[i].size();
		// if(i == 3)
		// {
		// 	for(j=0;j<m;++j)
		// 		cout << -1*st[i][j].ff << " " << st[i][j].ss << "\n";
		// }
		for(j=m-2;j>=0;j--)
			st[i][j].ss = max(st[i][j].ss,st[i][j+1].ss);
	}

	cin >> q;
	while(q--)
	{
		cin >> v >> l;
		if(mrk[v])
		{
			auto it = lower_bound(st[v].begin(),st[v].end(),pi(-1*l,-5));
			if(it == st[v].end())
				cout << 0 << "\n";
			else
				cout << (*it).ss << "\n";
			continue;
		}

		ans = 0;

		adj.clear();
		while(mrk[v] == 0)
		{
			adj.pb({val[v],wt[v]});
			v = v/2;
		}
		
		p = v;
		auto it = lower_bound(st[p].begin(),st[p].end(),pi(-1*l,-5));
		if(it != st[p].end())
			ans = max(ans,(*it).ss);	

		m = adj.size();
		for(j=1;j<(1<<m);++j)
		{
			c = 0;
			v = 0;
			for(k=0;k<m;++k)
			{
				if((j>>k)&1)
				{
					c += adj[k].ss;
					v += adj[k].ff;
					if(c>l)
						break;
				}
			}
			if(c <= l)
			{
				// cout << j << " " << c << " " << v << endl;
				ans = max(ans,v);
				auto it = lower_bound(st[p].begin(),st[p].end(),pi(-1*(l-c),-5));
				if(it != st[p].end())
					ans = max(ans,v+(*it).ss);	
			}
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 24620
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra
    struct UnionFind {
        vector<int> par;
    
        UnionFind(int n) : par(n, -1) { }
    
        int root(int x) {
            if (par[x] < 0) return x;
            else return par[x] = root(par[x]);
        }
    
        bool issame(int x, int y) {
            return root(x) == root(y);
        }
    
        bool merge(int x, int y) {
            x = root(x); y = root(y);
            if (x == y) return false;
            if (par[x] > par[y]) swap(x, y); // merge technique
            par[x] += par[y];
            par[y] = x;
            return true;
        }
    
        int size(int x) {
            return -par[root(x)];
        }
    };

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,m;
        cin>>n>>m;
        UnionFind UF(n);
        rep(i,m){
            ll x,y,z;
            cin>>x>>y>>z;
            x--;y--;
            UF.merge(x,y);
        }
        umap<ll,ll> ma;
        rep(i,n){
            ma[UF.root(i)]++;
        }
        cout<<ma.size()<<endl;
    }

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int k ;
  cin>>k;
  VEC<int> t = {a,b,c};
  sort(ALL(t));
  LL sum = t[0]+t[1]+pow(2,k)*t[2];
  cout<<sum<<endl;
  

  return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        cin >>N;
        vector<ll> A(N, 0);
        vector<ll> B(N, 0);
        Rep0(i, N) {
                ll x, y;
                cin >>x >>y;
                A.at(i)=x+y;
                B.at(i)=x-y;
        }
        Sort(A);
        Sort(B);
        ll ANS=max(A.back()-A.front(), B.back()-B.front());
        cout <<ANS <<endl;
        return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
//#define abs Abs
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int SMOD = 1000000007;
const int NMOD = 1000000009;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
ll Abs(ll x){return (x<0 ? -x : x);}
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct xyz{
    xyz(){
        cin.tie(0), ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
    };
}xyzzy;


signed main(){
    int n;
    int l[10005];
    cin >> n;
    FOR(i,n){
        cin >> l[i];
    }
    sort(l,l+n,greater<int>());
    int ans = 0;
    iFOR(i,1,n){
        ans+=l[i];
    }
    if(ans>l[0]) cout <<"Yes\n";
    else cout << "No\n";

  return 0;
}


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

int solve(int k)
{
  int n = 1;
  while (n * (n + 1) <= k * 2)
  {
    n++;
  }
  return --n;
}

int main()
{
  long long N;
  cin >> N;
  if (N == 1)
  {
    cout << 0 << endl;
    return 0;
  }
  map<long long, int> mp;
  long long cnt = 0;
  for (int i = 2; i < 1000001; i++)
  {
    while (N % i == 0)
    {
      mp[i]++;
      N /= i;
    }
  }
  mp[N]++;
  long long ans = 0;
  for (auto p : mp)
  {
    if (p.first == 1)
    {
      continue;
    }
    ans += solve(p.second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632