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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  ll result = 0, left = 0;
  rep(i,N) {
    if (A[i]==0) { left=0; continue; }
    A[i] += left;
    result += A[i]/2;
    left = A[i]%2;
  }
  cout << result << endl;
  return 0;
}

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

int main(){
    int a,b,c,buf;
    //cout<<"please input 2 numbers.\n"<<endl;
    cin >>a>>b>>c;
    if (a>b){
        buf=a;
        a=b;
        b=buf;
    }
    if (b>c){
        buf=b;
        b=c;
        c=buf;
    }
    if (a>b){
        buf=a;
        a=b;
        b=buf;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	cout << yorn(s.size()>=4&&s.at(0)=='Y'&&s.at(1)=='A'&&s.at(2)=='K'&&s.at(3)=='I') << endl ;
}


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

public class Main{
	
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int x=sc.nextInt();
		
		for(long a=-1000;a<=1000;a++) {
			for(long b=-1000;b<=1000;b++) {
				long a5=a*a*a*a*a;
				long b5=b*b*b*b*b;
				if(a5-b5==x) {
					pw.println(a+" "+b);
					pw.flush();
					return;
				}
			}
		}
		
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 36932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI A(N);
    REP(i,N) cin >> A[i];
    int ans = 0;
    int d = 0;
    int pre = -1;
    int cnt = 0;
    while(cnt < N){
        if(pre == -1){
            pre = A[cnt];
            cnt++;
        }else{
            if(pre == A[cnt]){
                pre = A[cnt];
                cnt++;
            }else{
                if(d == 0){
                    if(A[cnt]-A[cnt-1] > 0){
                        pre = A[cnt];
                         d = 1;
                         cnt++;
                    }else{
                        pre = A[cnt];
                        d = -1;
                        cnt++;
                    }
                }else{
                    if(A[cnt]-A[cnt-1] > 0 && d == 1){
                        pre = A[cnt];
                        cnt++;
                    }else if(A[cnt]-A[cnt-1] < 0 && d == -1){
                        pre = A[cnt];
                        cnt++;
                    }else{
                        d = 0;
                        pre = -1;
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans+1 << endl;

}


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

const int N=200000;

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

stack<char>sta;
int ans;

void Get_ans(){
  for (int i=1;i<=n;++i)
	!sta.empty()&&sta.top()=='S'&&s[i]=='T'?sta.pop():sta.push(s[i]);
  ans=sta.size();
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back

const int N = 1e5;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INFL = 1e15;

int main(){
  int n, k;
  scanf("%d%d", &n, &k);
  if(k == 0){
    printf("%lld\n", 1LL * n * n);
    return 0;
  }
  LL tot = 0;
  for(int i = k + 1; i <= n; ++i){
    int sisa = n - (i - 1);
    tot += i - k;
    tot += 1LL * (sisa / i) * (i - k);
    int mod = sisa % i;
    tot += max(0, mod - k);

   // fprintf(stderr, "%d: %lld\n", i, tot);
  }
  printf("%lld\n", tot);
  return 0;
}

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

int main(){
    int x, y;
    cin >> x >> y;
    int t, k;

    t = (4*x-y)/2;
    k = x-t;

    /*cout << t << " " << k << endl;*/

    if(t+k == x && y == 2*t + 4*k && t >=0 && k >= 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

int main() {
  string s, t;

  cin >> s;
  cin >> t;

  int cnt = (int)t.size();
  for(int i = 0; i <= s.size() - t.length(); i++) {
    int tmp = 0;
    for(int j = 0; j < t.size(); j++)
      if(t[j] != s[j+i])
        tmp++;

    cnt = min(cnt, tmp);
  }

  cout << cnt;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        sum+=b-a+1;

    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3580
#include<stdio.h>

int main(void){
	int a,b,c,i,x;
	scanf("%d %d %d",&a,&b,&c);
	i=a;
	while(1){
		if(c%i==0){
			x++;
		}
		i++;
		if(b<i){
			break;
		}
	}
	printf("%d\n",x);
	
return 0;
}	


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

int main() {
    ll h,w;
    cin>>h>>w;
    vector<vector<ll>> path(h,vector<ll>(w,0));
    rep(i,h){
        string str;
        cin>>str;
        rep(j,w){
            if(str[j]=='#'){
                path[i][j]=1;
            }
        }
    }
    ll max=0;
    ll width=0;
    vector<ll> heis(w,0);
    rep(i,h){
        rep(j,w){
            if(path[i][j]==0){
                if(width==0){
                    ll k=1;
                    while(true){
                        width++;
                        if(j+k>w-1){
                            break;
                        }
                        if(path[i][j+k]==1){
                            break;
                        }
                        k++;
                    }
                }
                if(heis[j]==0){
                    ll k=0;
                    while(true){
                        heis[j]++;
                        if(i+k>h-1){
                            break;
                        }
                        if(path[i+k][j]==1){
                            break;
                        }
                        k++;
                    }
                    heis[j]--;
                }
                if(heis[j]+width>max){
                    max=heis[j]+width-1;
                }
            }else {
                width=0;
                heis[j]=0;
            }
        }
        width=0;
    }
    cout<<max<<endl;
}


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

int main()
{
    char x, y, ans = '=';
    cin >> x >> y;
    if (x < y)
        ans = '<';
    if (x > y)
        ans = '>';
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
import math
from functools import reduce

def li():
    return [int(x) for x in input().split()]

N, D = li()
P = []
for i in range(N):
    x, y = li()
    P.append((x,y))

ans = 0
for p in P:
    if p[0]**2 + p[1]**2 <= D**2:
        ans += 1

print(ans)

Measured memory_bytes: 86864
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  long A,B;
  vector<pair<long,long>>C;
  rep(i,N){
    in(A,B);
    C.pb(mp(B,A));
  }
  sort(all(C));
  long cnt=0,t=0;
  rep(i,N){
    if(t+C[i].sd<=C[i].ft){
      t+=C[i].sd;
      cnt++;
    }
  }
  out(cnt==N?"Yes":"No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 6128
N = int(input())
height = [int(i) for i in input().split()]
box = [0]

for x in range(1 ,N):
    if(height[x] >= height[x-1] + box[x-1]):
        box.append(0)
    if(height[x] < height[x-1] + box[x-1]):
        box.append(- height[x] + height[x-1] + box[x-1])

sum = 0
for t in box:
    sum += t
print(sum)

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef vector<int> vi;
typedef long long ll;
#define all(c) begin(c),end(c)

auto solve() {
    int N, K;
    cin >> N >> K;
    vector<vi> edges(N);
    vector<pair<int,int>> edge_memo(N-1);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        edges[a].push_back(b);
        edges[b].push_back(a);
        edge_memo[i] = make_pair(a,b);
    }

    // get diameter
    function<int(int, int)> node_len = [&](int v, int prev) -> int {
        int mlen = 0;
        for (auto &&cv: edges[v]) {
            if (cv != prev)
                mlen = max(mlen, node_len(cv, v));
        }
        return 1 + mlen;
    };
    int d = 0;
    for (auto &&re: edges[0])
        d += node_len(re, 0);

    function<int(int, int, int)> child_count = [&](int v, int prev, int sum) -> int {
        int c = 0;
        for (auto &&cv: edges[v]) {
            if (cv != prev && sum < K/2)
                c += child_count(cv, v, sum + 1);
        }
        return 1 + c;
    };

    if (K % 2 == 0) {
        // traverse all the nodes
        int res = 0;
        REP(center, N) {
            int cc =child_count(center, -1, 0);
            res = max(res, cc);
        }
        return N - res;
    } else {
        // traverse all the edges
        K--;
        int res = 0;
        for(auto&& c_edge: edge_memo) {
            int lhs = child_count(c_edge.first, c_edge.second, 0);
            int rhs = child_count(c_edge.second, c_edge.first, 0);
            res = max(res, lhs+rhs);
        }
        return N - res;
    }
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> s(2);
  cin >> s[0] >> s[1];
  for (int i = 0; i < s[0].size();i++){
    cout << s[0][i] << flush;
    if(s[1].size()==i){
      break;
    }
    cout << s[1][i] << flush;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3576
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int a[3][3], c[3][3], n;
    string ans = "No";
    
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            cin >> a[i][j];
            c[i][j] = 0;
        }
    }
    
    cin >> n;
    
    int b[n];
    
    for(int i=0; i<n; i++)
    {
        cin >> b[i];
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
            {
                if(b[i] == a[j][k]) c[j][k] = 1;
                if((c[0][0] == 1 && c[0][1] == 1 && c[0][2] == 1) || (c[1][0] == 1 && c[1][1] == 1 && c[1][2] == 1) || (c[2][0] == 1 && c[2][1] == 1 && c[2][2] == 1) || (c[0][0] == 1 && c[1][0] == 1 && c[2][0] == 1) || (c[0][1] == 1 && c[1][1] == 1 && c[2][1] == 1) || (c[0][2] == 1 && c[1][2] == 1 && c[2][2] == 1) || (c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) || (c[2][0] == 1 && c[1][1] == 1 && c[0][2] == 1))
                {
                    ans = "Yes";
                    break;
                }
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    int H = scanner.nextInt();
    int N = scanner.nextInt();
    long sum = 0;
    for (int i = 0; i < N; i++) {
      sum += scanner.nextInt();
    }
    System.out.println(H <= sum ? "Yes" : "No");
  }
}

Measured memory_bytes: 48604
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	char c;
	cin>>c;
	if(c=='A') cout<<'T';else
	if(c=='T') cout<<'A';else
	if(c=='C') cout<<'G';else
	cout<<'C';
	rt0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;
const long long int INF = 99999999999999999;


int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	string str;
	long long int n, m, res = 0, cou = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		res += m + i;
	}
	if (m>=0) {
		cout << res - m;
	}
	else if(n>-m){
		cout << res;
	}
	else {
		cout << res - m - n+1;
	}
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


def get(V, n):
    if n >= len(V):
        yield V
    else:
        yield V[:n]
        for i in range(1, n):
            yield V[:n-i] + V[-i:]
        yield V[-n:]


def main():
    N, K = MI()
    V = MIL()
    ans = 0

    for i in range(max(K//2, 1), K + 1):
        # 左右からi個まで取る
        for vs in get(V, i):
            # K-i個まで、負を捨てる
            vs = sorted(vs)
            for j, v in enumerate(vs):
                if v >= 0: break
            ans = max(ans, sum(vs[min(K-i, j):]))
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 5716
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n, m;
    char a[50][50], b[50][50];
    while (cin >> n >> m) {
        FOR(i,0,n) FOR(j,0,n)
            cin >> a[i][j];
        FOR(i,0,m) FOR(j,0,m)
            cin >> b[i][j];
        bool exist = false;
        FOR(i,0,n) FOR(j,0,n) {
            bool match = true;  
            FOR(k,0,m) FOR(l,0,m) {
                if (a[i+k][j+l] != b[k][l])
                    match = false;
            }
            if (match)
                exist = true;
        }
        if (exist)
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main(){
  
  int n,sum;
  int count_sum;

  while(1){
    count_sum = 0;
    cin >> n >> sum;

    if(n==0 && sum==0){
      break;
    }else{
      for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
          for(int k=j+1; k<=n; k++){
            if((i+j+k)==sum){
              count_sum++;
            }
          }
        }
      }
    }

    cout << count_sum << endl;
  }
}

Measured memory_bytes: 1160
x = int(input())
primes = [True for _ in range(2*x)]
for i in range(2,len(primes)):
    if primes[i]:
        index = 2
        while i * index < len(primes):
            primes[i * index] = False
            index+=1

for num in range(2,len(primes)):
    if primes[num] and num >= x:
        print(num)
        break

Measured memory_bytes: 4632
#import sys
n,k = map(int, input().split( ))

s = input()

#if n ==1:
#    print(0)
#    sys.exit()

ans = n-1
tmp = 0
for i in range(n-1):
    if s[i] != s[i+1]:
        ans -= 1
        
ans += 2*k
print(min(ans,n-1))
        



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

int main() {
    int N, K;
    cin >> N >> K;
    int h[100010];
    for (int i=0; i<N; i++) {
        cin >> h[i];
    }

    long dp[101000];
    for (int i=0; i<100010; i++) {
        dp[i] = 1100000000;
    }
    dp[0] = 0;
    for (int i=0; i<N-1; i++) {
        for (int k=1; k<=K && i+k<N; k++) {
            if (dp[i+k] > dp[i] + abs(h[i+k]-h[i])) {
                dp[i+k] = dp[i] + abs(h[i+k]-h[i]);
            }  
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;

  vector<int> p(D), c(D);
  rep(i, D) cin >> p[i] >> c[i];

  int ans = 1e9;
  int sum, cnt;

  rep(i, 1 << D) {
    sum = 0;
    cnt = 0;
    rep(j, D) {
      if (i & 1 << j) {
        sum += 100 * (j + 1) * p[j] + c[j];
        cnt += p[j];
      }
    }
    if (sum >= G)
      ans = min(ans, cnt);
  }

  sum = 0;
  cnt = 0;
  for (int i = D - 1; i >= 0; i--) {
    for (int j = 0; j < p[i]; j++) {
      sum += 100 * (i + 1);
      if (j == p[i] - 1)
        sum += c[i];
      cnt++;
      if (sum >= G)
        ans = min(ans, cnt);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
x,y=0,0
for i in range(n):
  a,b,c=map(int,input().split())
  if c==1:x=max(x,a)
  elif c==2:w=min(w,a)
  elif c==3:y=max(y,b)
  else:h=min(h,b)
print(max((w-x),0)*max((h-y),0))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define DigFor(i, Dig) for(int i = 0; i < Dig; i++) 
using namespace std;

int Str2Num(string s)
{
	stringstream ss;
	ss << s;
	int num;
	ss >> num;
	return num;
}
string Num2Str(int num)
{
	stringstream ss;
	ss << num;
	return ss.str();
}
int main()
{
	string inp;
	int dig;

	while (cin >> inp >> dig)
	{
		int max = 0, min = 0, onum[22] = { 0 };

		onum[0] = Str2Num(inp);
		if (onum[0] == 0 && dig == 0) { break; }
		DigFor(i, 21)
		{
			int snum = inp.size();
			if (snum < dig)
			{
				DigFor(j, (dig - snum))
				{
					inp.push_back('0');
				}
			}
			sort(inp.begin(), inp.end());
			min = Str2Num(inp);
			reverse(inp.begin(), inp.end());
			max = Str2Num(inp);
			inp = Num2Str(max - min);
			onum[i + 1] = max - min;
		}
		int brnum = 0;
		DigFor(j, 21)
		{
			if (brnum == 1) { break; }
			DigFor(i, 21)
			{
				if (onum[j] == onum[i] && i != j)
				{
					brnum += 1;
					printf("%d %d %d\n" , j, onum[i], i - j);
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBattle solver = new BBattle();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBattle {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int hA = in.nextInt();
            int sA = in.nextInt();
            int hB = in.nextInt();
            int sB = in.nextInt();
            while (true) {
                hB -= sA;
                if (hB <= 0) {
                    out.println("Yes");
                    return;
                }
                hA -= sB;
                if (hA <= 0) {
                    out.println("No");
                    return;
                }
            }

            //out.print("Case #"+ testNumber + ": ");
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

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

    }
}



Measured memory_bytes: 32656
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) const { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

using mint = modint<1000000007>;

mint dp[1010][1010];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int h, w;
  cin >> h >> w;
  vstr board(h);
  rep(i, h) cin >> board[i];
  rep(i, h) {
    if (board[i][0] == '#') break;
    dp[i][0] = 1;
  }
  rep(i, w) {
    if (board[0][i] == '#') break;
    dp[0][i] = 1;
  }
  reps(i, h - 1) reps(j, w - 1) {
    if (board[i][j] == '#') continue;
    dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
  }
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}


Measured memory_bytes: 5248
import sys
sys.setrecursionlimit(10000000)

mod = 10 ** 9 + 7
def pow(a, n):
    if n == 0:
        return 1
    if n == 1:
        return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1:
        tmp = (tmp * a) % mod
    return tmp

n = int(input())
print()
print((((pow(10, n) - 2 * pow(9, n) + mod ** 2) % mod) + pow(8, n)) % mod)

Measured memory_bytes: 9200
'use strict'

function main(input) {

    input = input.split('\n')
    const n = ~~input[0]
    const x = input[1].split(' ').map(v => ~~v)
    const x2 = x.slice(0).sort((a, b) => a - b)

    const mid = x2[n / 2]
    const mid2 = x2[n / 2 - 1]

    let ans = ''
    for (let i = 0; i < n; i++) {
        if (x[i] < mid) ans += mid+'\n'
        else ans += mid2+'\n'

    }

    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 68940
import numpy as np

n = int(input())
s = np.array(list(input()))

l = s.size

dp = np.zeros(l, dtype=np.int16)
ans = 0
for i, e in enumerate(s, 1):
    dp_prev = dp.copy()
    mx = np.arange(1, l + 1) - i
    idx = np.hstack([np.full(i, False), s[i:] == e]).astype(np.bool)
    idx_prev = np.roll(idx, -1)
    dp = np.zeros(l, dtype=np.int16)
    dp[idx] = np.minimum(dp_prev[idx_prev] + 1, mx[idx])
    ans = max(ans, dp.max())

print(ans)


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

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

using namespace std;

int main() {
	
	int n;
	long long ans = 0;
	cin >> n;
	vector<long long> a(n + 1);
	vector<long long> b(n);
	rep(i, n+1) cin >> a[i];
	rep(i,n) cin >> b[i];

	rep(i, n) 
		if (a[i] > b[i]) {
			ans += b[i];
		}
		else {
			ans += a[i];
			if (a[i + 1] > b[i] - a[i]) {
				ans += b[i] - a[i];
				a[i + 1] -= (b[i] - a[i]);
			}
			else {
				ans += a[i + 1];
				a[i + 1] = 0;
			}
		}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int   N,X1,X2,B1,C1;
  float A,B,C;

  cin >> N;

 A=N/1.08;

 X1=floor(A);
 X2=ceil(A);
 B=X1*1.08;
 B1=floor(B);
 C=X2*1.08;
 C1=floor(C);


 if(X1==X2){
  cout<<X1;
   }
  else if(B1==N) {
  cout<<X1;
  }
  else if(C1==N){
  cout<<X2;
  }
 else{
 cout<<":(";
 }
return 0;
}


   

 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  int n;
  cin >> n;
  int odd[n+1];
  int cur[n+1];
  int cumsum = 0;
  for (int i=1; i<=n; i++){
      cin >> odd[i];
  }
  vector<int> ones;
  for (int i=n; i>=2; i--){
      int cursum = 0;
      for (int j=i+i; j<=n; j+=i){
          cursum += cur[j];
      }
      if (odd[i] == 1){
          if (cursum%2 == 1){
              cur[i] = 0;
          }else{
              cur[i] = 1;
          }
      }else{
          if (cursum%2 == 1){
              cur[i] = 1;
          }else{
              cur[i] = 0;
          }
      }
      cumsum += cur[i];
      if (cur[i] == 1){
          ones.push_back(i);
      }
  }
  if (odd[1] == 1){
      if (cumsum%2 == 1){
          cur[1] = 0;
      }else{
          cur[1] = 1;
      }
  }else{
      if (cumsum%2 == 1){
          cur[1] = 1;
      }else{
          cur[1] = 0;
      }
  }
  if (cur[1] == 1){
      ones.push_back(1);
  }
  cout << ones.size() << '\n';
  for (int i : ones){
      cout << i << " ";
  }
  return 0; 
}


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

//string s[110],t[110];

int main() {
  int N;
  int A=0;
  int Alice=0,Bob=0,count=0;
  int memo;
  int flag =1;
  int a[110];//vector<int> a[110];//
  cin >> N;
  for(int i=0;i<N;i++) cin >> a[i];
  
  while(count <= N){
    for(int i=0;i<N;i++){
      if(A<=a[i]){
        A = a[i];
        memo = i;
      }
    }
    if(count%2==0){
      Alice += A;
      a[memo] = 0;
      A = 0;
      count++;
    }
    else if(count%2==1){
     Bob += A;
      a[memo] = 0;
      count++; 
      A = 0;
    }
    
  }
  
  cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int n,k,x,y;

int main(){
  string s;
  int ans=0;
  cin >> s;
  n=s.length();
  string tmp="";
  REP(i,n){
    if (tmp!=s.substr(i,1)){
      ans++;
      tmp=s.substr(i,1);
    }else{
      if (i+1==n){
        break;
      }
      tmp=s.substr(i,2);
      i++;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MX=2e5+5;
const int M=1e9+7;
long long n,p,q,r,x;
long long f(long long x,long long y){
    long long k=1;
    while(y){
        if(y&1) k = ((k%M)*(x%M))%M;
        y>>=1;
        x = ((x%M)*(x%M))%M;
    }
    if(k<0) k+=M; 
    return k;
}
int main()
{
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x;
        p+=x;
        p%=M;
        q+=x*x;
        q%=M;
    }
    r=f(2,M-2);
    p = ((p%M)*(p%M))%M;
    if(p<0) p+=M;
    p = ((p%M)-(q%M))%M;
    p = ((p%M)*(r%M))%M;;
    if(p<0) p+=M;
    cout << p;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)j; i<(int)n; i++)
int main() {
  const int MAX_NM=50,MAX_DIST=200000000;
  int n,m,a[MAX_NM],b[MAX_NM],c[MAX_NM],d[MAX_NM];

  cin>>n>>m;
  rep(i,0,n) cin>>a[i]>>b[i];
  rep(i,0,m) cin>>c[i]>>d[i];

  rep(i,0,n){
    int dist=MAX_DIST,nearest=1;
    rep(j,0,m){
      int currentdist=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(dist>currentdist){
        dist=currentdist;
        nearest=j+1;
      }
    }
    cout<<nearest<<endl;
  }
}

Measured memory_bytes: 256
import heapq

n = int(input())
ab = [[int(i) for i in input().split()] for j in range(n)]
cd = [[int(i) for i in input().split()] for j in range(n)]

ab.sort(reverse=True)
cd.sort(reverse=True)

#print(ab,cd)

hq = []
tmp = 0
ans = 0

for i in range(n):
    while tmp <= n-1 and ab[i][0] < cd[tmp][0]:
        hq.append(cd[tmp][1])
        hq.sort()
        tmp += 1
    #print(hq)
    if len(hq) > 0:
        for j in range(len(hq)):
            if hq[j] > ab[i][1]:
                del hq[j]
                ans += 1
                break
            """
            elif hq[j] <= ab[i][1]:
                break
            else:
                continue
            """
        
print(ans)

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

int main(){
    int N;
    cin >> N;
    int B[N-1];
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }

    int ans = B[N-2];
    //cout << ans << endl;

    for(int i=N-2;i>0;i--){
        ans += min(B[i],B[i-1]);
        //cout << ans << endl;
    }

    ans += B[0];

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
import bisect
n = int(input())
lis = list(map(int, input().split()))
lis = sorted(lis)

a = bisect.bisect(lis, 0)
su = 0
mi = 10**10

for b in lis:
    su += abs(b)
    mi = min(mi, abs(b))

if a % 2 == 0:
    print(su)
else:
    print(su - 2 * mi)


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

int main(){
	int n, m, sum=0;
	cin >> n >> m;
	int a[m];
	
	for (int i=0; i<m; i++)
		cin >> a[i];
	
	for (int i=0; i<m; i++)
		sum += a[i];	
	
	if (sum > n)
		cout << "-1";
	else
		cout << (n-sum);
	
	return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int main() {
    int H,W,K;
    cin>>H>>W>>K;
    vector<vector<int>> c(H,vector<int>(W));
    rep(i,H)rep(j,W){
        char C;
        cin>>C;
        if(C=='#')c.at(i).at(j)=1;
    }
    int ans=0;
    rep(i,power(2,H)){
        rep(j,power(2,W)){
            vector<int> tate(H),yoko(W);
            rep(k,H){
                if(i & 1<<k){tate.at(k)=1;}
            }
            rep(k,W){
                if(j & 1<<k){yoko.at(k)=1;}
            }
            int count=0;
        rep(k,H)rep(l,W){
            if(tate.at(k) && yoko.at(l) && c.at(k).at(l)){
                count++;
            }
        }
        if(count==K)ans++;
        }
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string s, t;

int main()
{
	in>>s>>t;
	std::sort(s.begin(),s.end());
	std::sort(t.rbegin(),t.rend());
	if(s<t)out<<"Yes"<<std::endl;
	else out<<"No"<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define mxx 100005
#define endl "\n"
const ll mod=1e9+7;

ll a=1e18;

int main()
{
    ll k;
    cin>>k;
    string s;
    cin>>s;

    if(s.size()<=k)
        cout<<s<<endl;
    else
    {
        for(int i=0; i<k; i++)
            cout<<s[i];
        cout<<"...\n";
    }

    return 0;
}


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

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    map<ll,ll> pf;
    rep(i,N){
        auto P = prime_factorize(A[i]);;

        for(auto p : P){
            pf[p.first] = max(pf[p.first], p.second);
        }
    }

    mint lcm = 1;
    for(auto p : pf){
        rep(i,p.second){
            lcm *= p.first;
        }
    }
   
    mint ans = 0;
    rep(i,N){
        ans = ans+lcm/A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4104
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	bricks := make([]int,n)
	
	target := 1
	for i,_ := range bricks {
		fmt.Scan(&bricks[i])
		if bricks[i] == target {
			target++
		}
	}
	ans := n - (target - 1)
	
	if ans == n {
		fmt.Println("-1")
	} else {
		fmt.Println(ans)
	}
	
}

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

int main() {
  int n,m;
  cin >> n >> m;
  int h[n],g[n];
  for(int i=0; i<n; i++){
    cin >> h[i];
    g[i] = h[i];
  }
  for(int i=0; i<m; i++){
    int a,b;
    cin >> a >> b;
    if(h[a-1]>h[b-1]){
      g[b-1]=0;
    } else if(h[a-1]<h[b-1]){ 
      g[a-1]=0;
    } else {
      g[a-1]=0;
      g[b-1]=0;
    }
  }
  int count=0;
  for(int i=0; i<n; i++){
    if(g[i]>0) count++;
  }
  cout << count << endl;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, p;
ll w[100000], b[100000];
ll z[100000];

int main(){
    cin >> n >> p;
    rep(i,n) cin >> w[i] >> b[i];
    rep(i,n) z[i] = (100-p)*w[i]+p*b[i];
    sort(z, z+n, greater<ll>());
    ll sum = 0;
    rep(i,n) sum -= p*b[i];
    rep(i,n) {
        sum += z[i];
        if (sum >= 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}
































Measured memory_bytes: 2560
n, k = input().split()
n = int(n)
k = int(k)
p = list(map(int, input().split()))

exp = 0
for i in range(k):
 exp += (1 + p[i]) / 2
 exp_true = exp

for i in range(n-k):
 exp += (1 + p[i+k]) / 2
 exp -= (1 + p[i]) / 2
 if exp_true < exp:
   exp_true = exp

print(exp_true)

Measured memory_bytes: 71792