akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  for(int i=0; i<N; i++) cin >> T.at(i);
  
  sort(T.begin(), T.end());
  int res = 0;
  for(int i=N-1; i>=0; i--) {
    for(int j=i-1; j>=0; j--) {
        int n = T.at(i) - T.at(j);
        auto l = upper_bound(T.begin(), T.end(), n);
        int num = j - (l - T.begin());
        if (num > 0) res += num;
    }
  }
  
  cout << res << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

int main() {
	string s; cin >> s;
	int ans = 0;
	int c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			c++;
			ans = max(c, ans);
		}
		else {
			c = 0;
		}
	}

	cout << ans << endl;





}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
L = []
x=0
for a in A:
    x ^= a
    L.append(x)
R = []
x=0
for a in reversed(A):
    x ^= a
    R.append(x)
for i in range(n):
    x = 0
    if i>0:
        x^=L[i-1]
    if i<n-1:
        x^=R[n-1-(i+1)]
    print(x, end="")
    if i==n-1:
        print("")
    else:
        print(" ",end="")

Measured memory_bytes: 119652
S=list(map(int,input().split()))

if S[1]==0:
  print(S[0])
else:
  N=list(map(int,input().split()))
  k=S[0]
  t=S[0]
  s=0
  u=1
  while k in N != True:
    if s==0:
      k=t-u
      s=1
    else:
      k=t+u
      s=0
      u+=1
  print(k)
      

Measured memory_bytes: 61740
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=100000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}

struct unionfind{
    vector<ll> d;
    unionfind(ll x):d(x,-1){}
    ll root(ll x) {return d[x]<0?x:d[x]=root(d[x]);}
    ll size(ll x) {return -d[root(x)];};
    bool unite(ll x,ll y) {x=root(x),y=root(y); if(x!=y){if(d[x]>d[y])swap(x,y);d[x]+=d[y];d[y]=x;}return x!=y;}
    bool find(ll x,ll y) {return root(x)==root(y);}
};

int main(){
  ll n;
  cin>>n;
  cout<<180*(n-2);
}

Measured memory_bytes: 256
if __FILE__ == $0
  while line = gets
    weight = line.to_f
    rank_names = [
      "light fly",
      "fly",
      "bantam",
      "feather",
      "light",
      "light welter",
      "welter",
      "light middle",
      "middle",
      "light heavy",
      "heavy"]
    rank_threshold = [
      48.00,
      51.00,
      54.00,
      57.00,
      60.00,
      64.00,
      69.00,
      75.00,
      81.00,
      91.00]
    rank = -1
    rank_threshold.each_with_index do |th, idx|
      if weight <= th
        rank = idx
        break
      end
    end
    if rank == -1
      puts "heavy"
    else
      puts rank_names[rank]
    end
  end
end

Measured memory_bytes: 6088
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;



signed main(){
    int q;
    cin >> n >> q;
    vector<priority_queue<int>> a(n);
    REP(i,q){
        int t;
        cin >> t;
        switch (t)
        {
        case 0:
            int x,y;
            cin >> x >> y;
            a[x].push(y);
            /* code */
            break;
        case 1:
            cin >> x;
            if(a[x].empty()) break;
            print(a[x].top());
            break;
        case 2:
            cin >> x;
            if(a[x].empty()) break;
            a[x].pop();
            break;
        default:
            break;
        }
    }


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

// デバッグを消し忘れるな！！！

int main() {
    string s; cin >> s;
    cout << s.substr(0, 3) << endl;


    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t,n,i,ans,cnt,j,k;
        int a[5];
        for(i=1;i<=5;i++)
        {
            cin>>a[i];
        }
        for(i=1;i<5;i++)
        {
            if(a[i]==0)
                break;
        }
        cout<<i;

}


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


int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    vector<lint> m,p;
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    lint minus=0,zero=0,plus=0;
    rep(i,N){
        if(A[i]<0) minus++,m.push_back(-A[i]);
        if(A[i]==0) zero++;
        if(A[i]>0) plus++,p.push_back(A[i]);
    }
    sort(p.begin(),p.end());
    sort(m.begin(),m.end());
    lint minusp,zerop,plusp;
    minusp=minus*plus;
    zerop=zero*plus+zero*minus+(zero*(zero-1))/2;
    plusp=(minus*(minus-1))/2+(plus*(plus-1))/2;
    int hugou=0;
    if(K<=minusp) hugou=-1;
    else if(K<=minusp+zerop) hugou=0;
    else hugou=+1;
    if(hugou==0) cout << 0 << endl;
    else if(hugou==-1){
        lint hi=1e18,lo=0;
        lint ans=0,count=0;
        while(hi-lo>1){
            ans=0,count=0;
            lint mid=(hi+lo)/2;
            rep(i,m.size()){
                auto itr=lower_bound(p.begin(),p.end(),(mid+m[i]-1)/m[i]);
                count+=p.size()-(itr-p.begin());
            }
            (count>=K?lo:hi)=mid;
            ans=mid;
        }
        cout << -lo << endl;
    }
    else{
        K=(N*(N-1))/2+1-K;
        lint hi=2e18,lo=0;
        lint ans=0,count=0;
        while(hi-lo>1){
            ans=0,count=0;
            lint mid=(hi+lo)/2;
            rep(i,m.size()){
                auto itr=lower_bound(m.begin(),m.end(),(mid+m[i]-1)/m[i]);
                count+=m.size()-(itr-m.begin());
                if(itr-m.begin()<=i) count--; 
            }
            rep(i,p.size()){
                auto itr=lower_bound(p.begin(),p.end(),(mid+p[i]-1)/p[i]);
                count+=p.size()-(itr-p.begin());
                if(itr-p.begin()<=i) count--;
            }
            count/=2;
            (count>=K?lo:hi)=mid;
            ans=mid;
        }
        cout << lo << endl;
    }
}

Measured memory_bytes: 4084
#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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<int> A1(N);
    vector<int> A2(N);

    REP(i,N) {
        cin >> A1[i];
    }

    REP(i,N) {
        cin >> A2[i];
    }

    reverse(ALL(A2));

    int maxi = 0;
    FOR(i,1,N+1) {
        int a1 = 0;
        REP(j,i){
            a1 += A1[j];
        }
        int a2 = 0;
        REP(j,N+1-i) {
            a2 += A2[j];
        }

        chmax(maxi,a1+a2);
    }

    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
T = ''
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(words)):
    words[i] = words[i][::-1]
for i in S[::-1]:
    T += i
    for q in words:
        if T == q:
            T = ''
if T == '':
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		int X = in.nextInt();
		int Y = in.nextInt();
		
		if (N <= K)
			System.out.println(N*X);
		else 
			System.out.println((K*X)+(Y*(N-K)));	
	}
}

Measured memory_bytes: 21716
module ABC125

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_B

  ! constants for this <program>
  integer, parameter, private :: num_jewels_max = 20

  ! variables for this <module>
  integer, private :: num_jewels
  integer, private :: benefit

  ! arrays for this <module>
  integer, dimension(1:num_jewels_max), private :: value, cost

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer :: benefit_each

    ! support variables for this <subroutine>
    integer :: iter

    ! STEP.01
    ! read out the number of     the jewels
    ! read out the value  of     the jewels
    ! read out the cost   to get the jewels
    read(unit=INPUT_UNIT, fmt=*) num_jewels
    read(unit=INPUT_UNIT, fmt=*) value(1:num_jewels)
    read(unit=INPUT_UNIT, fmt=*) cost (1:num_jewels)

    ! STEP.02
    ! calculate the maximum benefit
    benefit_each = 0

    do iter = 1, num_jewels, 1
      benefit_each = value(iter) - cost(iter)
      if (benefit_each .gt. 0) benefit = benefit + benefit_each
    end do

    ! STEP.02
    ! output the benefit
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') benefit

    ! STEP.END
    return

  end subroutine task_B

end module ABC125


program main

  ! <module>s to import
  use, non_intrinsic :: ABC125

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		if(n == 0){
			System.out.println(0);
			return;
		}
		while(n != 0){

			if(n % -2  == 0){
				sb.append("0");
				n /= -2;
			}
			else{
				sb.append("1");
				if(n < 0){
					n /= -2;
					n++;
				}else{
					n /= -2;
				}
			}
		}
		String xx = sb.reverse().toString();
		System.out.println(xx);



	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

const int N=8,FREE=-1,NOT_FREE=1;
int row[8],col[8],dpos[15],dneg[15];
bool X[8][8];

void initialize(){
    for(int i=0;i<N;++i){
        row[i]=col[i]=FREE;
    }
    for(int i=0;i<2*N-1;++i){
        dpos[i]=dneg[i]=FREE;
    }
}

void printBoard(){
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(X[i][j]){
                if(row[i]!=j) return;
            }
        }
    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            cout<<(row[i]==j?"Q":".");
        }
        cout<<endl;
    }
}

void recursive(int i){
    if(i==N){
        printBoard(); return;
    }

    for(int j=0;j<N;++j){
        if(NOT_FREE==col[j]
        || NOT_FREE==dpos[i+j]
        || NOT_FREE==dneg[i-j+N-1]
        ) continue;

        row[i]=j; col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
        recursive(i+1);
        row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}

int main(){

    initialize();

    for(int i=0;i<N;i++){
        for(int j=0;j<N;++j){
            X[i][j]=false;
        }
    }

    int k; cin>>k;
    for(int i=0;i<k;++i){
        int r,c; cin>>r>>c;
        X[r][c]=true;
    }

    recursive(0);
}


Measured memory_bytes: 3124
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <bitset>
#include <string>
#include <time.h>
using namespace std;
long double esp=1e-11;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p) memset(p,0,sizeof(p))
#define memf(p) memset(p,0x3f,sizeof(p))
#define memn(p) memset(p,-1,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
typedef long long int LL;
const long double PI = acos((long double)-1);
const LL INF=0x3f3f3f3f3f3f3f3fll;
const int MOD = 1000000007;
const int maxn=3010000;
LL tr[maxn][2];
LL sum[maxn];
int N;
void update(int x,LL val,int f)
{
    for (; x&&x<=N; x+=x&-x)
		tr[x][f]+=val;
}
LL query(int x,int f)
{
    x++;
    LL sum=0;
    for (; x; x^=x&-x)
		sum+=tr[x][f];
    return sum;
}
void update(int l,int r ,LL val, int f)
{
    update(l+1,val,f);
    update(r+1+1,-val,f);
}
LL ans[1100];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("inlay.in", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //map<long long int,int>ma;                 %I64d
    //vector<int>::iterator iter;
    //memset(m,0,sizeof(int));
    //for(int x=1;x<=n;x++)
    //for(int y=1;y<=n;y++)
    //scanf("%d%d",&a,&b);
    //scanf("%d",&a);
    //printf("%d\n",ans);
    mem(tr);
    int X,Y,Z,A,B,C,n,tem;
    scanf("%d%d%d%d%d%d%d",&X,&Y,&Z,&A,&B,&C,&n);
    N=X+Y+Z;
    for(int y=0;y<=Y-1;y++)
    {
        tem=abs(y-B);
        update(tem+0,tem+Z-C-1,1,0);
        update(tem+1,tem+C,1,0);
    }
    mem(sum);
    for(int d=0;d<=N;d++)
    {
        sum[d]=query(d,0);      //printf("%d %d\n",d,sum[d]);
        if(!sum[d])break;
        update(d+0,d+X-A-1,sum[d],1);
        update(d+1,d+A,sum[d],1);
    }
    mem(ans);
    for(int d=0;d<=N;d++)
        ans[d%n]+=query(d,1);
    for(int x=0;x<n;x++)
        printf("%lld%c",ans[x],(x<n-1)?' ':'\n');
    return 0;
}

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

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

      int d,t,s;
    cin >> d >> t >> s;
    
    if(t*s >= d)
      cout << "Yes" << '\n';

    else
      cout << "No" << '\n';  

      return 0;
  }

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

using namespace std;

int main() {
    int n;
    cin >> n;
    string arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int same = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            if (arr[i] == arr[j]) {
                same = 1;
            }
        }
    }
    
    int flag = 0;

    for (int i = 0; i < n - 1; i++) {
        if (arr[i][arr[i].size() - 1] != arr[i+1][0]) {
            flag = 1;
        }
    }

    if (flag == 0 && same == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    ll q;
    cin >> s;
    cin >> q;
    string k;
    string h;
    ll flag = 0;
    for (ll i = 0; i < q; i++)
    {
        int p;
        cin >> p;
        if (p == 1)
        {              //このとき反転させられる。→どっち向きになったのかの情報を持っておく。
            flag += 1; //これが奇数の時には反転している。
        }
        else if (p == 2)
        {
            int y;
            cin >> y;
            char f;
            cin >> f;
            if ((y + flag) % 2 == 1)
            {
                k= f + k; //これは本来の文字列の向きの先頭につける者。
            }
            else
            {
                h = h + f;
            }
        }
    }
    if (flag % 2 == 1)
    {
        reverse(s.begin(), s.end());
        reverse(k.begin(),k.end());
		reverse(h.begin(),h.end());
        cout << h+s+k << endl;
        return 0;
    }
    cout << k+s+h << endl;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    int i = s.length() - 1;
    while(i > 0){
        if(i - 4 >= 0 && s.substr(i - 4, 5) == "dream") i -= 5;
        else if(i - 6 >= 0 && s.substr(i - 6, 7) == "dreamer") i -= 7;
        else if(i - 4 >= 0 && s.substr(i - 4, 5) == "erase") i -= 5;
        else if(i - 5 >= 0 && s.substr(i - 5, 6) == "eraser") i -= 6;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

using namespace std;

const int N = 5e5 + 5;

string s;
long long f[N];
vector<pair<int, bool>> v;

void go() {
  for (int i = 1; i < N; i++) {
    f[i] = i + f[i - 1];
  }
}

int main() {
  go();
  cin >> s;
  int c = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1]) {
      c++;
    } else {
      v.push_back({c, s[i - 1] == '>'});
      c = 1;
    }
  }
  v.push_back({c, s.back() == '>'});
  long long sum = 0, last = 0;
  for (auto x : v) {
    if (x.second) {
      if (!last) {
        sum += f[x.first];
      } else {
        if (x.first >= last) {
          sum += f[x.first];
        } else {
          sum += last;
          sum += f[x.first - 1];
        }
      }
      last = 0;
    } else {
      sum += f[x.first - 1];
      last = x.first;
    }
  }
  if (last) sum += last;
  cout << sum << '\n';
  return 0;
}

/**

< > > > < < > < < < < < > > > <
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1

**/


Measured memory_bytes: 6908
import sys

def resolve():
    H, W = map(int, input().split(" "))
    cols = [input() for i in range(H)]
    skip_cols = []
    skip_rows = []
    for i, col in enumerate(cols):
        if col.replace(".", "") == "":
            skip_cols.append(i)
    for j in range(W):
        for col in cols:
            if col[j] == "#":
                break
        else:
            skip_rows.append(j)
    for i, col in enumerate(cols):
        if i in skip_cols:
            continue
        for j, c in enumerate(col):
            if j in skip_rows:
                continue
            sys.stdout.write(c)
        sys.stdout.write("\n")
    return

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 39280
s = gets.chomp.chars.map(&:to_s)
res = 0
res_arr = []
s.each do |i|
  if i == 'A' || i == 'C' || i == 'G' || i == 'T'
    res += 1
    res_arr << res
  else
    res = 0
    res_arr << 0
  end
end
puts res_arr.max

Measured memory_bytes: 1788
#include <stdio.h>
#include<string.h>
#define ll long long



int main() {
    int a[100010];
    int n , m ,i,j;
    scanf("%d",&n);
    for ( i = 1; i <=n; i++) {
        scanf("%d",&a[i]);
    }

    scanf("%d",&m);
    for ( i = 1; i <=m; i++) {
        int p,q;
        scanf("%d%d",&p,&q);
        int temp=a[p];
        a[p] = q;
        ll t  = 0;
        for ( j = 1; j<=n; ++j) {

            t+= a[j];
        }
        printf("%lld\n",t);
        a[p]=temp;
    }
}

Measured memory_bytes: 128
import math
input = raw_input
a, b = map(int, input().split(" "))

#out10 = max(125*a, 100*b)
out = int(math.ceil(max(12.5*a, 10*b)))
#if out10 < min(125*a+125, 100*a+100):
max_lim = min(12.5*(a+1), 10*(b+1))
if out < max_lim:
    pass
else:
    out = -1
print(out)

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

ll N;
vector<ll> A;

void solve() {
  ll tmp = 0;
  int i_max = 0;
  for (int i = 0; i < N; i++) {
    if (tmp < A[i]) {
      tmp = A[i];
      i_max = i;
    }
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    if (i == i_max) {
      cout << A[N - 2] << '\n';
    } else {
      cout << A[N - 1] << '\n';
    }
  }
}

int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 3200
s = ["", input()]
q = int(input())

for _ in range(q):
  que = input().split()
  if que[0] == "1":
    s = s[::-1]
  else:
    s[int(que[1])-1] += que[2]

print("".join(list(s[0])[::-1]) + s[1])


Measured memory_bytes: 12280
n,t,e=map(int,input().split())
x=list(map(int,input().split()))
xi=x[:]
x.insert(0,0)
xi.sort()
for i in xi:
    if t-(t//i*i)<=e or abs(t-((t//i+1)*i))<=e:
        print(x.index(i))
        break
else:print(-1)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
        	String num = input.nextLine();
        	System.out.println(roman(num));
        }
    }

    public static int roman(String num){
    	int sum = 0;
    	for(int i = 0 ; i < num.length() ; i++){
    		if(num.charAt(i) == 'M'){
    			sum += 1000;
    		}else if(num.charAt(i) == 'D'){
    			if(i+1 <= num.length()-1){
					if(num.charAt(i+1) == 'M'){
						sum += 500;
						i++;
					}else{
						sum += 500;
					}
    			}else{
    				sum += 500;
    			}
    		}else if(num.charAt(i) == 'C'){
    			if(i+1 <= num.length()-1){
    				if(num.charAt(i+1) == 'M'){
    					sum += 900;
    					i++;
    				}else if(num.charAt(i+1) == 'D'){
    					sum += 400;
    					i++;
    				}else{
    					sum += 100;
    				}
    			}else{
    				sum += 100;
    			}
    		}else if(num.charAt(i) == 'X'){
    			if(i+1 <= num.length()-1){
    				if(num.charAt(i+1) == 'M'){
    					sum += 990;
    					i++;
    				}else if(num.charAt(i+1) == 'D'){
    					sum += 490;
    					i++;
    				}else if(num.charAt(i+1) == 'C'){
    					sum += 90;
    					i++;
    				}else if(num.charAt(i+1) == 'L'){
    					sum += 40;
    					i++;
    				}else{
    					sum += 10;
    				}
    			}else{
    				sum += 10;
    			}
    		}else if(num.charAt(i) == 'L'){
    			if(i+1 <= num.length()-1){
    				if(num.charAt(i+1) == 'M'){
    					sum += 950;
    					i++;
    				}else if(num.charAt(i+1) == 'D'){
    					sum += 450;
    					i++;
    				}else if(num.charAt(i+1) == 'C'){
    					sum += 50;
    					i++;
    				}else{
    					sum += 50;
    				}
    			}else{
    				sum += 50;
    			}
    		}else if(num.charAt(i) == 'V'){
    			if(i+1 <= num.length()-1){
    				if(num.charAt(i+1) == 'M'){
    					sum += 995;
    					i++;
    				}else if(num.charAt(i+1) == 'D'){
    					sum += 495;
    					i++;
    				}else if(num.charAt(i+1) == 'C'){
    					sum += 95;
    					i++;
    				}else if(num.charAt(i+1) == 'L'){
    					sum += 45;
    					i++;
    				}else if(num.charAt(i+1) == 'X'){
    					sum += 5;
    					i++;
    				}else{
    					sum += 5;
    				}
    			}else{
    				sum += 5;
    			}
    		}else if(num.charAt(i) == 'I'){
    			if(i+1 <= num.length()-1){
    				if(num.charAt(i+1) == 'M'){
    					sum += 999;
    					i++;
    				}else if(num.charAt(i+1) == 'D'){
    					sum += 499;
    					i++;
    				}else if(num.charAt(i+1) == 'C'){
    					sum += 99;
    					i++;
    				}else if(num.charAt(i+1) == 'L'){
    					sum += 49;
    					i++;
    				}else if(num.charAt(i+1) == 'X'){
    					sum += 9;
    					i++;
    				}else if(num.charAt(i+1) == 'V'){
        					sum += 4;
        					i++;
    				}else{
    					sum += 1;
    				}
    			}else{
    				sum += 1;
    			}
    		}
    	}
    	return sum;
    }
}

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

using namespace std;

// Topological sorted graph
struct TopologicalGraph
{
  vector< vector<int> > graph;
  vector<int> order;
  TopologicalGraph(int sz):graph(sz){}
  TopologicalGraph(vector< vector<int> > graph):graph(graph){}
  void add_edge(int from, int to)
  {
    graph[from].push_back(to);
  }
  bool visit(int u, vector<int>& color)
  {
    color[u] = 1;
    for(int v : graph[u]) {
      if(color[v] == 2) continue;
      if(color[v] == 1) return false;
      if(!visit(v, color)) return false;
    }
    order.push_back(u);
    color[u] = 2;
    return true;
  }
  bool sort()
  {
    vector<int> color((int)graph.size(), 0);
    for(int i = 0; i < (int)color.size(); i++) {
      if(color[i] == 0 && !visit(i, color)) return false;
    }
    reverse(order.begin(), order.end());
    return true;
  }
  void print_order()
  {
    for(int i = 0; i < (int)order.size(); i++) cout << order[i] << endl;
  }
};

int main()
{
  int V, E; cin >> V >> E;
  TopologicalGraph graph(V);
  while(E--) {
    int s, t; cin >> s >> t;
    graph.add_edge(s, t);
  }
  graph.sort();
  graph.print_order();
  return 0;
}

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

int main() {
    int n, m, a, b, x, y;
    cin >> n >> m >> a >> b;
    for(int i=0; i<n; i++) {
        cin >> x;
        if(x>a) a = x;
    }
    for(int i=0; i<m; i++) {
        cin >> y;
        if(y<b) b = y;
    }

    if(b>a) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    H, W = LI()
    g = []
    for _ in range(H):
        g.append(S())
    dp = [[inf for _ in range(W)] for __ in range(H)]

    if g[0][0] == '#':
        dp[0][0] = 1
    else:
        dp[0][0] = 0

    for r in range(H):
        for c in range(W):
            if r == 0 and c == 0:
                if g[r][c] == '#':
                    dp[r][c] = 1
                else:
                    dp[r][c] = 0
 
            cand1, cand2 = inf, inf
            if r-1 >= 0:
                if g[r-1][c] == '.' and g[r][c] == '#':
                    dp[r][c] = min(dp[r][c], dp[r-1][c] + 1)
                else:
                    dp[r][c] = min(dp[r][c], dp[r-1][c])
            if c-1 >= 0:
                if g[r][c-1] == '.' and g[r][c] == '#':
                    dp[r][c] = min(dp[r][c], dp[r][c-1] + 1)
                else:
                    dp[r][c] = min(dp[r][c], dp[r][c-1])
    print(dp[-1][-1])
main()



Measured memory_bytes: 69740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  char a, b;
  cin >> a >> b;
  if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
  	cout << "H" << "\n";
  }else {
  	cout << "D" << "\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,k,s,s1;

    scanf("%d%d",&a,&b);

    k=(a+b)/2;

    s=abs(a-k);
    s1=abs(b-k);

    if(s==s1&&a!=b)
    {
        printf("%d\n",k);
    }

      else
    {
        printf("IMPOSSIBLE\n");
    }

    return 0;
}

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

void solve(vector<vector<int>> &G, map<pair<int, int>, int> &c, int &K, int ci, int i) {
    int cj = 0;
    for (int j : G[i]) {
        map<pair<int, int>, int>::iterator it = c.find({i, j});
        if (it->second == 0) {
            cj++;
            if (cj == ci) cj++;
            it->second = cj;
            c.find({j, i})->second = cj;
            solve(G, c, K, cj, j);
        }
    }
    K = max(K, cj);
}

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

    int N;
    cin >> N;
    vector<pair<int, int>> edges(N - 1);
    vector<vector<int>> G(N + 1);
    map<pair<int, int>, int> c;
    for (int i = 0; i < N - 1; i++) {
        cin >> edges[i].first >> edges[i].second;
        G[edges[i].first].push_back(edges[i].second);
        G[edges[i].second].push_back(edges[i].first);
        c[{edges[i].first, edges[i].second}] = 0;
        c[{edges[i].second, edges[i].first}] = 0;
    }

    int K = 0;
    solve(G, c, K, 0, 1);

    cout << K << '\n';
    for (pair<int, int> e : edges)
        cout << c.find(e)->second << '\n';

    return 0;
}

Measured memory_bytes: 19328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int coun=0;
  while(1){
 
    int n;
    int ma=10000000;
    cin >> n;
    if(n==0)break;
    if(coun)cout << endl;
    coun++;
    int a[4];
    int co=0;
    for(int i=0;i<4;i++){
      cin >> a[i];
      co+=a[i];
    }
    int c;
    int m;
    int ii,jj,kk,ll;
    for(int i=0;i<=a[0];i++){
      for(int j=0;j<=a[1];j++){
	for(int k=0;k<=a[2];k++){
	  for(int l=0;l<=a[3];l++){
	    c=co-i-j-k-l;
	    m=i*10+j*50+k*100+l*500;
	    m-=n;
	    if(m<0)continue;
	    int c2=0;
	    if(m/500&&l)continue;
	    c2+=m/500;
	    m%=500;
	    if(m/100&&k)continue;
	    c2+=m/100;
	    m%=100;
	    if(m/50&&j)continue;
	    c2+=m/50;
	    m%=50;
	    if(m/10&&i)continue;
	    c2+=m/10;
	    m%=10;
	    int turi=c+c2;
	    if(ma>turi){
	      ma=turi;
	      ii=i;
	      jj=j;
	      kk=k;
	      ll=l;
	    }
	  }
	}
      }
    }
    if(ii)cout << 10 << " " << ii<<endl;
    if(jj)cout << 50 << " " << jj<<endl;
    if(kk)cout << 100 << " " << kk<<endl;
    if(ll)cout << 500 << " " << ll<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, w;
	cin >> n >> w;
	struct { int v, w; } item[101];
	for (int i = 1; i <= n; i++) {
		cin >> item[i].v >> item[i].w;
	}
	int dp[101][10001] = {};
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			if (item[i].w <= j)
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-item[i].w] + item[i].v);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 5116
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	int n;
	cin >> n;
	if (n > 999) {
		cout << "ABD" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] + a[i - 1] > x) {
			ans += a[i] + a[i - 1] - x;
			a[i] -= min(a[i], a[i] + a[i - 1] - x);
			a[i - 1] -= a[i] + a[i - 1] - x;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	char N[4];
	int flag, i, j, K, M, P=0, S, T, U;
	scanf("%[0-9] %d%*c", &N, &K);
	char D[K], *ptr;
	for (i=0;i<K;i++) {
		scanf("%[0-9]%*c", &D[i]);
	}
	
	char Di[4];
	T = atoi(N);
	while (1) {
		flag = 0;
		U = T;
		for (i=4;i>=0;i--) {
			Di[i] = U%10;
			U /= 10;
			if (!U) break;
		}
		for (;i<5;i++) {
			if ((ptr = memchr(D, Di[i]+48, K)) != NULL) flag += 1;
		}
		if (!flag) break;
		T++;
	}
	printf("%d\n", T);
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Gcd(line[0], line[1]));
    }

    public static long Gcd(long a, long b)
    {
        if (b > a) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, (a % b));
    }
}



Measured memory_bytes: 18444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 110;
const ll INF = 2e9+10;

ll n;
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    //ios_base::sync_with_stdio(false);

    cin >> n;
    if(n & 1ll)cout << 0 << "\n";
    else{
        ll ans = 0;
        for(ll i = 10;i <= n;i *= 5ll) ans += n / i;
        cout << ans << "\n";
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
n = int(input())
numbers = map(int, input().split())

ans = [[0] * n for i in range(n)]

numbers = sorted(numbers, reverse=False)

for x, i in enumerate(numbers):
    ans[0][x] = i 

#print("input to for")
#print(ans)

for x, ansc in enumerate(ans):
    #print("x times")
    #print(x)
    if ansc.count(0) == n - 1:
        print(ansc[n-1])
        break
    for y, i in enumerate(ansc):
        if i != 0 and y == 0:
            #print("first run")
            ansc[1] = (float(ansc[0]) + ansc[1]) / 2
            ansc[0] = 0
            break
        else:
            #print("second run")
            if y > 0:
                if ansc[y-1] == 0 and ansc[y] != 0:
                    ansc[y+1] = (float(ansc[y]) + ansc[y+1]) / 2
                    ansc[y] = 0
                    break
        #print("y=")
        #print(y)
        #print(ansc)
    #print("before")
    #print(ans)
    ans[x+1] = sorted(ans[x+1], reverse=False, key=float)
    ans[x+1] = ansc
    

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
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; }


using namespace std;

int64_t popcnt(int64_t n)
{
	int64_t c = 0;
	c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
	c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333);
	c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f);
	c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff);
	c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff);
	c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff);
	return(c);
}

signed main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> mapData;
	rep(i, H) {
		vector<int> v;
		rep(j, W) {
			char c;
			cin >> c;
			v.push_back(c - '0');
		}
		mapData.push_back(v);
	}

	int ans = LL_HALFMAX;

	// y の切り方を全探索
	rep(y, 1 << (H - 1)) {
		int cand = popcnt(y);
		int yCut = popcnt(y);
		int compressedNum = yCut + 1;
		vector<vector<int>> compressed(compressedNum);

		rep(x, W) {
			int sum = 0;
			int compInd = 0;
			rep(yInd, H) {
				sum += mapData[yInd][x];
				// この行の下で切るなら
				if ((y & (1 << yInd)) || yInd == H - 1) {
					compressed[compInd].push_back(sum);
					compInd++;
					sum = 0;
				}
			}
		}

		vector<int> ySum(compressedNum, 0);
		bool ok = true;
		rep(x, W) {
			rep(yInd, compressedNum) {

				// 1マスでKを超えてたらNG
				if (compressed[yInd][x] > K) {
					ok = false;
				}

				// 今見てる奴を入れてダメになる場合は、その手前で切る
				if (ySum[yInd] + compressed[yInd][x] > K) {
					cand++;
					rep(j, compressedNum) {
						ySum[j] = compressed[j][x];
					}
					break;
				}
				else {
					ySum[yInd] += compressed[yInd][x];
				}
			}
		}

		if (ok) {
			chmin(ans, cand);
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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 int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,vis[1003];
ld dist[1003],x[1003],y[1003],r[1003],x1,yy;
vector<pair<int , ld>> adj[1003];

ld getdist( int i, int j ){
        return  sqrt(( x[i]-x[j] )*( x[i] - x[j] ) + ( y[i] - y[j] )*( y[i] - y[j] ) );
}

void djikstra( int s ){

priority_queue<pair<int , ld>> q;
q.push( {0, s} );
for(int i=1;i<=n+1;i++){
        dist[i] = 1e18;
}
while(!q.empty()){
        s = q.top().second;q.pop();
        if(vis[s])continue;
        vis[s]=1;
        for(auto t:adj[s]){
                if( dist[t.fs] > dist[s]+t.sc ){
                        dist[t.fs] = dist[s]+t.sc;
                        q.push({ -dist[t.fs], t.fs });
                }
        }
}

}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        cin >> x[0] >> y[0] >> x1 >> yy;
        cin >> n;
        x[n+1]=x1;
        y[n+1]=yy;
        for(int i=1;i<=n;i++){
                cin >> x[i] >> y[i] >> r[i];
        }
        for(int i=0;i<=n+1;i++){
                for(int j=i+1;j<=n+1;j++){
                        ld d =  max( (ld)0 ,  getdist( i, j ) - (r[i]+r[j]));
                        adj[i].pb( {j, d} );
                        adj[j].pb( {i, d} );
                }
        }
        djikstra( 0 );
        cout << fixed << setprecision(12);
        cout << dist[n+1] << endl;

return 0;
}
///....


Measured memory_bytes: 42768
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<bitset>
#include<queue>
#define lson (rt << 1)
#define rson (rt << 1 | 1)
const int maxn = 100+50;
const int maxm = 4e5 + 10;
const int inf_max = 0x3f3f3f;
using namespace std;
typedef long long ll;
ll a;
int main()
{
    cin>>a;
    ll ans = 0,cur = 100;
    while(cur < a) {
        ans++;
        double tt = cur;
        cur += (ll)(tt * 0.01);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }else if(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> even,odd;
    for(int i=1;i<=100001;i++){
        if(i%2==0)  even[i]=0;
        else    odd[i]=0;
    }
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i%2==0)  even[a[i]]++;
        else    odd[a[i]]++;
    }
    int Maxeven=0,Maxodd=0,even1=0,even2=0,odd1=0,odd2=0,iterE,iterO;
    for(int i=1;i<=100001;i++){
        if(Maxeven<even[i]){
            even1=i;
            Maxeven=even[i];
        }
        if(Maxodd<odd[i]){
            odd1=i;
            Maxodd=odd[i];
        }
    }
    Maxeven=0,Maxodd=0;
    for(int i=1;i<=100001;i++){
        if(i!=even1&&Maxeven<even[i]){
            even2=i;
            Maxeven=even[i];
        }
        if(i!=odd1&&Maxodd<odd[i]){
            odd2=i;
            Maxodd=odd[i];
        }
    }
/*
    for(int i=0;i<n;i++){
        if(i%2==0){
            cout << even[a[i]] << " ";
        }else{
            cout << odd[a[i]] << " ";
        }
    }
    cout << endl;
    cout << even1 << " " << odd1 << endl;
    cout << even2 << " " << odd2 << endl;
*/
    if(even1!=odd1){
        cout << n-even[even1]-odd[odd1] << endl;
    }else{
        cout << min(n-even[even2]-odd[odd1],n-even[even1]-odd[odd2]) << endl;
    }

    return 0;
}

Measured memory_bytes: 9984
import sys
import collections


def alg_duplicate_combination_mod(n, r, mod):
    n = n + r - 1
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    ls = []
    for i in range(2, int(m ** 0.5) + 1):
        while True:
            if m % i == 0:
                ls.append(i)
                m //= i
            else:
                break
    if m != 1:
        ls.append(m)
    t = 1
    ls = collections.Counter(ls)
    for k, v in ls.items():
        t *= alg_duplicate_combination_mod(n, v, mod)
        t %= mod
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

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

    vector<ll> x(n);
    ll sa = 0;
    rep(i, 0, n) {
        if (i % 2 == 0) sa += a[i];
        else sa -= a[i];
    }
    x[0] = sa / 2;
    rep(i, 1, n) {
        x[i] = a[i-1] - x[i-1];
    }
    rep(i, 0, n-1) cout << 2*x[i] << " ";
    cout << 2*x[n-1] << endl;
}

Measured memory_bytes: 2944