akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;
 
#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                     x.begin(),x.end()
#define MAX                     1e9
#define MIN                     -1e9
#define max(x,y)                (x>y)?x:y
#define min(x,y)                (x<y)?x:y
#define mid(l,r)                (l+(r-l)>>1)
#define mina(a)                    *min_element(a.begin(), a.end())
#define maxa(a)                    *max_element(a.begin(), a.end())
#define PI                      acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>             mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>              pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>              vi;
typedef  vector<string>          vs;
typedef  vector<char>             vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

ll dp[1004][1004];

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int h,w;
    cin>>h>>w;
    memset(dp,0,sizeof(dp));

    char grid[h+5][w+5];
    loop(i,0,h)
        loop(j,0,w)
            cin>>grid[i][j];

    dp[0][0]=1;
    loop(i,1,h)
    {
        if(grid[i][0]=='.') dp[i][0] = dp[i-1][0];
    }
    loop(i,1,w)
    {
        if(grid[0][i]=='.') dp[0][i] = dp[0][i-1];
    }
    loop(i,1,h)
    {
        loop(j,1,w)
        {
            if(grid[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }

    int ans = dp[h-1][w-1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9088
s = input()
pos = 0
str_len = len(s)
count = 0
seq_a = 0
seq_bc = 0

while pos < str_len:
    if s[pos] == "A":
        while pos < str_len and s[pos] == "A":
            seq_a += 1
            pos += 1
        if pos+1 < str_len and s[pos] == "B" and s[pos + 1] == "C":
            while pos < str_len and s[pos] == "B" and pos + 1 < str_len and s[pos + 1] == "C":
                seq_bc += 1
                pos += 2
            count += seq_a * seq_bc
            if pos < str_len and s[pos] != "A":
                seq_a = 0
            seq_bc = 0
        else:
            pos += 1
            seq_a = 0
    else:
        pos += 1
        seq_a = 0

print(count)


Measured memory_bytes: 3500
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-12
#define MOD 998244353ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n;
	string s;
	cin >> n >> s;

	vector<vector<int>> v(n + 1, vector<int> (3, 0));
	fore(i, 1, n + 1)
	{
		v[i] = v[i - 1];
		if (s[i - 1] == 'R')
			v[i][0]++;
		else if (s[i - 1] == 'G')
			v[i][1]++;
		else
			v[i][2]++;
	}

	ll otv = 0;

	fr(i,n,0)
		fr(j, i, 0)
	{
		int rng = i - j;
		set<char> ost = { 'R', 'G', 'B' };

		if (s[i] != s[j])
		{
			ost.erase(s[i]);
			ost.erase(s[j]);

			if (*ost.begin() == 'R')
			{
				otv += v[j][0] - ((j - rng < 0 || s[j - rng] != 'R') ? 0 : 1);
			}
			else if (*ost.begin() == 'G')
			{
				otv += v[j][1] - ((j - rng < 0 || s[j - rng] != 'G') ? 0 : 1);
			}
			else
			{
				otv += v[j][2] - ((j - rng < 0 || s[j - rng] != 'B') ? 0 : 1);
			}
		}
	}

	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}

}

Measured memory_bytes: 3808
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(K + 1):
        for Y in range(K + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N,X = map(int,input().split())
L_li = input().split()
for i in range(len(L_li)):
    L_li[i] = int(L_li[i])

D = [0]*(N+1)
for i in range(1,N+1,1):
    D[i] = D[i-1] + L_li[i-1]
print(len([i for i in D if i <= X]))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	enum priorityFigure{
		S(0),H(1),C(2),D(3);

		private int priority;
		private priorityFigure(int priority){
			this.priority = priority;
		}
	}
	public static void main(String[] args) throws IOException{
		int num, insertionPoint;
		String[] str, list;
		list = new String[52];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		num = Integer.parseInt(br.readLine());
		for(int i = 0; i < num; i++){
			str = br.readLine().split(" ");
			if(str[0].equals("S")){
				insertionPoint = priorityFigure.S.priority * 13;
			}else if(str[0].equals("H")){
				insertionPoint = priorityFigure.H.priority * 13;
			}else if(str[0].equals("C")){
				insertionPoint = priorityFigure.C.priority * 13;
			}else{
				insertionPoint = priorityFigure.D.priority * 13;
			}
			list[Integer.parseInt(str[1]) + insertionPoint - 1] = str[1];
		}
		for(int i = 0; i < 52; i++){
			if(list[i] == null){
				String figure;
				if(i / 13 == priorityFigure.S.priority){
					figure = "S";
				}else if(i / 13 ==  priorityFigure.H.priority){
					figure = "H";
				}else if(i / 13 == priorityFigure.C.priority){
					figure = "C";
				}else{
					figure = "D";
				}
				if((i + 1) % 13 == 0){
					num = 13;
				}else{
					num =(i + 1) % 13;
				}
				builder.append(figure + " " + num + "\n");
			}
		}
		if(builder.length()!=0){
			builder.delete(builder.length() - 1, builder.length());
			System.out.println(builder);
		}
		br.close();
	}
}

Measured memory_bytes: 24492
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath> 
#include <tuple>

//pair sort firstに揃う

#define int long long
#define double long double
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define incin2(n,m) int (n),(m); cin >> (n)>>(m);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
namespace Mathf
{
    const int INF = 1000000000000;
    const double PI = 3.14159274;
    const double Rad2Deg = 57.29578;
    const double log2(double a,double b);
    const double log2(double a,double b){
        return log(b)/log(a);
    }
} // namespace Mathf

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}
template <typename T1,typename T2> bool Comp (pair<T1,T2> a,pair<T1,T2> b){
    if(a.first!=b.first){
        return a.first<b.first;//first昇順
    }
    if(a.second!=b.second){
        return a.second > b.second;//second降順
    }else{
        return  true;
    }
}
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    incin2(n,y);
    int a,b,c;
    int flag = 0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(1000*j+5000*i+10000*(n-i-j)==y && (n-i-j)>=0){
                cout<<(n-i-j)<<'\t'<<i<<'\t'<<j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<'\t'<<-1<<'\t'<<-1<<endl;
    return 0;
}
 

Measured memory_bytes: 256
(defun kuku (i j)
  (cond ((= j 10) 
            nil)
        ((= i j) 
            (cons (* i j) (kuku 1 (+ j 1))))
        (T 
            (cons (* i j) (kuku (+ i 1) j)))))

(let ((n (read)))
  (if (find n (kuku 1 1))
      (princ "Yes")
      (princ "No")))

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> a(m,vector<int>(3));
  rep(i,m){
    int x,y;
    cin >> x >> y;
    a[i][0]=x;
    a[i][1]=y;
    a[i][2]=i;
  }
  sort(a.begin(),a.end());
  int checker=a[0][0],cnt=0;
  rep(i,m){
    cnt++;
    if(a[i][0]==checker){
      a[i][1]=cnt;
    }else{
      checker=a[i][0];
      a[i][1]=1;
      cnt=1;
    }
    swap(a[i][0],a[i][2]);
  }
  sort(a.begin(),a.end());
  rep(i,m){
    printf("%06d", a[i][2]);
    printf("%06d\n", a[i][1]);
  }
  
  return 0;
}

Measured memory_bytes: 8812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;

vector< vector<char> > chars = {
	{ '.', ',', '!', '?', ' ' },
	{ 'a', 'b', 'c' },
	{ 'd', 'e', 'f' },
	{ 'g', 'h', 'i' },
	{ 'j', 'k', 'l' },
	{ 'm', 'n', 'o' },
	{ 'p', 'q', 'r', 's' },
	{ 't', 'u', 'v' },
	{ 'w', 'x', 'y', 'z' }
};

int main()
{
	int n; cin >> n;
	rep(i, 0, n)
	{
		string s; cin >> s;

		int back = -1;
		int click_num = 0;
		string ans = "";
		rep(j, 0, s.length())
		{
			int num = s[j] - '0';
			if (num == 0)
			{
				if (back < 0) continue;
				ans += chars[back][click_num % chars[back].size()];
				back = -1;
			}
			else
			{
				if (back < 0)
				{
					back = num - 1;
					click_num = -1;
				}

				click_num++;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    set<string> st;

    rep(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }

    cout<<st.size()<<endl;
}




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

X = 0
for i in range(2,N):
    X ^= A[i]

S = A[0]+A[1]

c = 0
l = []
for i in range(40):
    if 2**i&X==2**i:
        c += 2**i
    else:
        l.append(2**i)

S -= c
a = 0
b = 0
for n in l:
    if 2*n&S==2*n:
        a += n
        b += n
if a+b==S:
    for i in range(40,-1,-1):
        if 2**i&c==2**i and a+2**i<A[0]:
            a += 2**i   
    if a != 0:      
        ans = max(A[0]-a,-1)
    else:
        ans = -1
else:
    ans = -1
print(ans)


Measured memory_bytes: 62200
import itertools
import fractions
def main():
  a,b,c = map(int, input().split())
  ma = a + (b*10 + c)
  ma = max(ma,(a*10+b)+c)
  ma = max(ma,(c*10+a)+b)
  ma = max(ma,(c*10+b)+a)
  ma = max(ma,(a*10+c)+b)
  ma = max(ma,(b*10+a)+c)
  print(ma)
if __name__ == '__main__':
  main()

Measured memory_bytes: 5176
#include<stdio.h>

int main()
{
    int N, i, s=1, count=0;

    scanf("%d", &N);

    for(i=1; i<=N; i++){
        if(1*s <= i && i < 10*s){
            count++;
            if(i == (10*s-1))
                s *=100;
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

int h,w;
int a[1400][1400];
int dp[1400][1400];
int solve()
{
  int ans = 0;
  REP(i,h) REP(j,w)
  {
    dp[i][j] = (a[i][j]+1)%2;
    ans |= dp[i][j];
  }
  FOR(i,1,h-1) FOR(j,1,w-1)
  {
    if(a[i][j]) dp[i][j] = 0;
    else
    {
      dp[i][j] = min({dp[i-1][j],dp[i][j-1],dp[i-1][j-1]})+1;
      ans = max(ans,dp[i][j]);
    }
  }
  return ans;
}

int main()
{
  cin >> h >> w;
  REP(i,h) REP(j,w)
  {
    int t; cin >> t;
    a[i][j] = t;
  }
  int k = solve();
  cout << k*k << endl;
  return 0;
}

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

int main(){
	int L, N;
	string S[110];

	cin>>N>>L;
	
	for(int i = 0; i < N; i++)
		cin>>S[i];
	sort(S, S+N);
	
	for(int i = 0; i < N; i++)
		cout<<S[i];
	cout<<endl;
	
  return 0;
}

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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = GetLong();
            var A = GetLongArray();
            long Q = GetLong();
            var replace = new long[Q][];
            for (int i = 0; i < Q; i++)
            {
                replace[i] = GetLongArray();
            }

            var sum = new long[Q + 1];
            var dic = new Dictionary<long, long>();
            for(int i = 0; i <= 1e5; i++)
            {
                dic.Add(i, 0);
            }
            for(int i = 0; i < N; i++)
            {
                sum[0] += A[i];
                dic[A[i]]++;
            }

            for(int i = 0; i < Q; i++)
            {
                long temp;
                temp = dic[replace[i][0]];
                sum[i + 1] = sum[i] + temp * (replace[i][1] - replace[i][0]);
                dic[replace[i][0]] = 0;
                dic[replace[i][1]] += temp;
            }

            for(int i = 1; i <= Q; i++)
            {
                Console.WriteLine(sum[i]);
            }
        }

        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


Measured memory_bytes: 53720
# -*- coding: utf-8 -*-
"""
C - Attention

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, S):
    ans = float('inf')
    left_w = -1
    left_e = 0
    right_w = S.count('W')
    right_e = S.count('E')

    prev_ch = 'W'
    for ch in S:
        if prev_ch == 'W':
            left_w += 1
        else:
            left_e += 1
        if ch == 'W':
            right_w -= 1
        else:
            left_w -= 1
        prev_ch = ch
        c = left_w + right_e
        ans = min(ans, c)
    return ans


def main(args):
    N = int(input())
    S = input().strip()
    ans = solve(N, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3956
n,m = gets.split.map(&:to_i)
# 学生の座標
people = []
n.times{
  people << gets.split.map(&:to_i)
}
# pointの座標
point = []
m.times{
  point << gets.split.map(&:to_i)
}
for j in 0..n-1
# min & point/index gets
for i in 0..m-1
cal = (people[j][0] - point[i][0]).abs + (people[j][1] - point[i][1]).abs
if i == 0
  min = cal
  check_point = i + 1
end
if min > cal
  min = cal
  check_point = i + 1
end
end
puts check_point
end

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    cout << x + y/2;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>M;
    vec p(M), Y(M);
    rep(i,M) cin>>p[i]>>Y[i];
    vec ord(M);
    rep(i,M) ord[i] = i;
    sort(ord.begin(),ord.end(),[&](ll x, ll y){
        return Y[x] < Y[y];
    });
    //rep(i,M) cout<<ord[i]<<endl;
    vec num(N+1,0);
    vp ans(M);
    rep(i,M){
        ans[ord[i]].fi = p[ord[i]];
        ans[ord[i]].se = ++num[p[ord[i]]];
    }
    rep(i,M){
        ll temp = ans[i].fi;
        for(int j = temp; j < 100000; j *= 10){
            cout<<0;
        }
        cout<<temp;
        temp = ans[i].se;
        for(int j = temp; j < 100000; j *= 10){
            cout<<0;
        }
        cout<<temp;
        cout<<endl;
    }
}


Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<string>
#include<list>


using namespace std;


int main()
{
	int n;
	string t;
	list<char> l;

	ios::sync_with_stdio(false);

	cin >>n;

	for (int i = 0; i != n; ++i)
	{
		cin >> t;
		l.push_back(t.at(0));
		for (unsigned int j = 1; j != t.size();++j)
		{
			if (t.at(j) == '>')
			{
				if (find(l.begin(),l.end(),t.at(j + 1)) == l.end())
				{
					l.push_back(t.at(j + 1));
				}
				
			}
			else if(t.at(j)=='<')
			{
				if (find(l.begin(), l.end(), t.at(j + 2)) == l.end())
				{
					l.push_front(t.at(j + 2));
				}
			}
		}
		for (list<char>::iterator it=l.begin(); it != l.end(); ++it)
		{
			cout << *it;
		}
		cout << endl;
		l.clear();
	}

	return 0;

}


Measured memory_bytes: 3252
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007LL
#define PI acosl(-1)

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	vector<int> pre(n);
	pre[0] = arr[0];
	for (int i = 1; i < n; i++)
		pre[i] = pre[i - 1] + arr[i];
	auto pref = [&](int i, int j) {
		if (i == 0)
			return pre[j];
		else
			return pre[j] - pre[i - 1];
	};
	// dp[i][j] -> minimum total cost to combine arr[i:j]
	vector<vector<int>> dp(n, vector<int>(n, LLONG_MAX));
	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = i; j < n; j++)
		{
			if (i == j)
			{
				dp[i][j] = 0;
			}
			else
			{
				for (int k = i; k < j; k++)
				{
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + pref(i, j));
				}
			}
		}
	}
	cout << dp[0][n - 1];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 4472
class Integer
  
  attr_accessor :mod
  @@mod = 10 ** 9 + 7
  @@h = Hash.new
  
  alias_method :primitive_add, :+
  def +(other)
    self.primitive_add(other) % @@mod
    # res %= @@mod if res < 0 || res >= @@mod
    # res
  end
  
  alias_method :primitive_minus, :-
  def -(other)
    self.primitive_minus(other) % @@mod
    # res %= @@mod if res < 0 || res >= @@mod
    # res
  end
  
  alias_method :primitive_times, :*
  def *(other)
    self.primitive_times(other) % @@mod
  end
  
  def /(other)
    @@h[other] ||= other.pow(@@mod-2, @@mod)
    self * @@h[other] % @@mod
  end
end

n, k = gets.to_s.split.map{|e|e.to_i}

ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.reduce(:+)

puts ans

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

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

const int maxn = 1e5 + 11;

int N;
multiset<int> grps;

int main() {

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

  cin >> N;

  for (int i = 0; i < N; i++) {
    int x; cin >> x;
    if (grps.empty() || *grps.begin() >= x) {
      grps.insert(x);
    } else {
      auto ptr = grps.lower_bound(x);
      --ptr;
      grps.erase(ptr);
      grps.insert(x);
    }
  }

  cout << grps.size() << "\n";

  return 0;
}


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


int main(void){
    // Your code here!
    int a,b,x;
    double theta;
    cin >> a >> b >> x;
    cout << fixed << setprecision(10);
    if(x > a*a*b/2)
        theta = atan(2.0/pow(a,3)*(a*a*b-x))*180/M_PI;
    else if(x == a*a*b/2)
        theta = atan((double)b/a)*180/M_PI;
    else
        theta = atan((double)a*b*b/(2*x))*180/M_PI;
    cout << fixed << setprecision(10);
    cout << theta << endl;
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <set>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> IR;

int N;
set<int> SE;

int main() {
	S(N);
	
	bool b = false;
	R(i, N) {
		int n;
		S(n);
		if (SE.find(n) == SE.end()) {
			SE.insert(n);
		}
		else {
			b = true;
			break;
		}
	}

	if (b) printf("NO");
	else printf("YES");
}



Measured memory_bytes: 9600
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int x=in();
	vector<int> a(n);
	trav(i,a)i=in();
	int ans=0;
	if(a[0]>x){ans+=a[0]-x;a[0]=x;}
	for(int i=0;i<n-1;i++)
	{
		if(a[i]+a[i+1]>x)
		{
			int d=a[i+1]+a[i]-x;
			a[i+1]-=d;
			ans+=d;
		}
	}
	cout<<ans;
	
}

Measured memory_bytes: 4040
use std::io::BufReader;
use std::io::BufRead;
use std::io;
use std::io::prelude::*;
use std::i32;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());
    let mut s = String::new();
    let mut cost = 0;
    let mut costs: Vec<i32> = Vec::new();

    reader.read_line(&mut s);

    let input: Vec<i32> = s.split_whitespace().map(|s| s.parse().unwrap()).collect();

    for i in 0..3 {
        for j in 0..3 {
            for k in 0..3 {
                if i != j && j != k && k != i {
                    let x = input[i] - input[j];
                    let y = input[j] - input[k];
                    costs.push((x.abs() + y.abs()));
                }
            }
        }
    }
    println!("{}", costs.iter().min().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;
long long cur[200100];
long long sum[200100];
const int mod = 1e9+7;
int main()
{
    long long ans = 0;
    int n;
    scanf("%d",&n);
    sum[0] = 0;
    for(int i = 1;i <= n;i++) {
        scanf("%lld",&cur[i]);
        sum[i] = cur[i] + sum[i-1];
    }
    for(int i = 1;i <= n;i++) {
        ans += ((sum[n]-sum[i])%mod)*cur[i];
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6932
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll n,k;
	ull sum=0;
	cin >> n >> k;
	ll p[n];
	cinf(p,n);
	sort(p,p+n);
	rep(i,k){
		sum+=p[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >>n;
  string s,t; cin>>s>>t;
  rep(i,n)
  cout << s[i] << t[i];
  cout << '\n';
  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);
        String inputString = scanner.next();
        if (inputString.charAt(2) == inputString.charAt(3) && inputString.charAt(4) == inputString.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int c = A * B;
        int d =  Math.max(A-B, A + B);


        System.out.println(Math.max(c, d));
    }
}

Measured memory_bytes: 23252
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int H,W;cin>>H>>W;
  int h,w;cin>>h>>w;

  int res = H*W;
  res -= h*W;
  res -= H*w;
  res += h*w;

  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, size;
	long count = 1;
	int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383,389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,};
	int primeNum[sizeof(prime)/sizeof(prime[0])] = {0};

	size = sizeof(prime)/sizeof(prime[0]);
	scanf("%d", &n);
	for(int i=2; i <= n; i++) {
		int temp = i;
		for(int j=0; i >= prime[j] && j < size; j++) {
			while(!(temp % prime[j])) {
				temp /= prime[j];
				primeNum[j]++;
			}
			if(temp == 1)
				break;
		}
	}

	for(int i=0; i < size; i++) {
		if(primeNum[i])
			count = count*(primeNum[i]+1) % 1000000007;
	}
	printf("%ld", count);

	return 0;
}


Measured memory_bytes: 128
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of array of char;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);
    a:=700;
    if s[1]='o' then
      a:=a+100;
    if s[2]='o' then
      a:=a+100;
    if s[3]='o' then
      a:=a+100;

    Writeln(a);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) { 
        Scanner sc = new Scanner(System.in); 
        int a = sc.nextInt(); 
        int b = sc.nextInt(); 
        int c = sc.nextInt(); 
        int d=0;
        if(a>b){
            d=a;
            a=b;
            b=d;
        }
        if(b>c){
            d=b;
            b=c;
            c=d;
        }
        if(a>b){
            d=a;
            a=b;
            b=d;
        }
        System.out.printf("%d %d %d\n", a, b, c);
    }
}


Measured memory_bytes: 26492
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#define INF 2000000
using namespace std;
typedef long long ll;//声明// 
int main()
{  int n,t=0;
   cin>>n;
   while(n)
   {  t=n%10;
      n=n/10;
       if(t==7)
         break;
   }
   if(t==7)
   cout<<"Yes";
   else
   cout<<"No";
   
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    ll D,T,S;
    cin >> D >> T >> S;
    if(D<=T*S)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3600
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    if (b * 10 + c) % 4 == 0 {
        println!("YES")
    } else {
        println!("NO")
    }
}


Measured memory_bytes: 4352
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t count[4] = { 0,0,0,0 };

	for (size_t i = 0; i < 3; i++) {
		size_t a, b;
		scanf("%zu %zu", &a, &b);
		if (i < 2) {
			scanf("\n");
		}

		count[a - 1]++;
		count[b - 1]++;
	}
	
	size_t edgeCount[4] = { 0,0,0,0 };
	for (size_t i = 0; i < 4; i++) {
		edgeCount[count[i]]++;
	}

	puts(((edgeCount[1] == 2 && edgeCount[2] == 2) ? "YES" : "NO"));

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int MaxN = 1e6;
const int INF = 1 << 30;

int x, y;
int a[20];
int main()
{
	a[1] = 1, a[3] =  1, a[5] = 1, a[7] = 1, a[8] = 1, a[10] = 1, a[12] = 1;
	a[4] = 2, a[6] = 2, a[9] = 2, a[11] = 2;
	a[2] = 3;
	while(scanf("%d %d", &x, &y) != EOF)
	{
		if(a[x] == a[y]) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 128
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque([])
for i in range(n):
  if n%2 == 0:
    if i%2 == 0:
      b.append(a[i])
    else:
      b.appendleft(a[i])
  if n%2 != 0:
    if i%2 == 0:
      b.appendleft(a[i])
    else:
      b.append(a[i])
print(*b)

Measured memory_bytes: 25540
#include <iostream>
#include <cstdint>

using namespace std;

int main(int argc, char const* argv[]) {
	uint32_t a, b, k;
	cin >> k;
	cin >> a >> b;

	uint32_t n = a / k;

	if (a % k == 0) {
		cout << "OK" << endl;
		return 0;
	}

	if ((n + 1) * k <= b) {
		cout << "OK" << endl;

	} else
		cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a;
		String mark;
		int[] s = new int[13];int[] h = new int[13];
		int[] c = new int[13];int[] d = new int[13];
		for (int b=0;b<n;b++){
			mark=sc.next();
			a=sc.nextInt();
			if (mark.equals("S")){
				s[a-1]=1;
			}else if (mark.equals("H")){
				h[a-1]=1;
			}else if (mark.equals("C")){
				c[a-1]=1;
			}else if (mark.equals("D")){
				d[a-1]=1;
			}
		}
		for (int e=0;e<13;e++){
			if (s[e]==0){
				System.out.println("S "+(e+1));
			}
		}
		for (int f=0;f<13;f++){
			if (h[f]==0){
				System.out.println("H "+(f+1));
			}
		}
		for (int g=0;g<13;g++){
		if (c[g]==0){
			System.out.println("C "+(g+1));
			}
		}
		for (int i=0;i<13;i++){
			if (d[i]==0){
				System.out.println("D "+(i+1));
			}
		}
	}
}

Measured memory_bytes: 18056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=305;
const ll inf=(1ll<<40)-1;
int n;
ll A[maxn][maxn];
#define MP make_pair
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%lld",&A[i][j]);
    bool can=true;
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(A[i][k]+A[k][j]<A[i][j]) {
                    can=false;break;
                }
            }if(!can) break;
        }if(!can) break;
    }
    if(!can) {printf("-1\n");exit(0);}
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                if(i!=k && k!=j && i!=j && A[i][k]+A[k][j]==A[i][j]) {
                    A[i][j]=A[j][i]=inf;
                }
    ll sum=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            sum+=(A[i][j]==inf?0:A[i][j]);
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 1000000007
using namespace std;
namespace ywy{
	int c[4044][4044],f[4044][4044],g[4044][4044];
	inline void pre(int n){
		c[0][0]=1;for(register int i=1;i<=n;i++){
			c[i][0]=1;for(register int j=1;j<=i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%p;
		}for(register int i=0;i<=n;i++){
			g[i][0]=c[i][0];for(register int j=1;j<=n;j++)g[i][j]=(g[i][j-1]+c[i][j])%p;
		}for(register int i=0;i<=n;i++){
			f[i][0]=g[i][0];for(register int j=1;j<=n;j++)f[i][j]=(f[i][j-1]+g[i][j])%p;
		}
	}
	void ywymain(){
		int A,B;cin>>A>>B;pre(A+B);ll ans=0;for(register int t=1;t<=A+1;t++){
			for(register int i=0;i<t;i++){
				if(i==0){
					ans++;continue;
				}ans=(ans+(ll)c[B-1][i]*f[i-1][t-i-1])%p;
			}
		}cout<<ans<<endl;
	}
}
int main(){
	ywy::ywymain();return(0);
}

Measured memory_bytes: 191232
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    for (int i=1; i<n; i++) {
        if (a[i-1]<=a[i]) continue;
        ans += a[i-1]-a[i];
        a[i] += a[i-1]-a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    h.push_back(0);
    int ans = 0;
    rep(i, 100){
        bool f = 0;
        int tmp = 0;
        rep(j, n+1){
            if(h[j] > 0){
                f = 1;
                h[j]--;
            }else{
                if(f) tmp++;
                f = 0;
            }
        }
        ans += tmp;
        // cout << tmp << endl;
        if(tmp == 0) break;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >

int N,W;
const int maxn=100009;
int w[105];
int v[105];
ll dp[105][maxn];
ll ans(int item,int weight)
{
    if(dp[item][weight]!=-1)
    {
        return dp[item][weight];
    }
    if(weight<=0)
    {
        return 0;
    }
    if(item==N)
    {
        if(weight<w[N])
        {
            return 0;
        }
        else
        {
            return v[N];
        }
    }
    if(w[item]<=weight)
    {
        return dp[item][weight]=max(ans(item+1,weight),ans(item+1,weight-w[item]) + v[item]);
    }
    else
    {
        return dp[item][weight]=ans(item+1,weight);
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>W;
    for(int i=1;i<=N;i++)
    {
        cin>>w[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<ans(0,W)<<"\n";

    return 0;
}






Measured memory_bytes: 82304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int [] dp = new int [n];

        dp[n-1] = 0;

        for (int i = n - 2; i >= 0; i--) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 1 ; j <= k && j + i < n; j++) {
                dp[i] = Math.min(dp[i],(Math.abs(arr[i] - arr[i+j]) + dp[i+j]));
            }
        }
        System.out.println(dp[0]);
    }
}


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

int main() {
  int N,Z=0,A=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    Z+=a;
    A=max(A,a);
  }
  cout<<Z-A/2<<endl;
}

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

using namespace std;
using ll = long long;

#define endl "\n"
#define pb push_back

const int MAX = 10e5;

ll counter[MAX] = {0};

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

	int k, x;
	cin >> k >> x;
	for(int i = x - k + 1; i <= x + k - 1; i++) {
		cout << i << " ";
	}
}


Measured memory_bytes: 256
import java.util.*;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int n = sc.nextInt();
		double temp = 0;
		int ans = 0;
		if(n == 100) {
			temp = 101 * Math.pow(n, d);
			ans = (int)temp;
		}
		else{temp = Math.pow(100, d) * n;
		ans = (int)temp;
		}
		System.out.println(ans);
     }
}

Measured memory_bytes: 23252
#if 0
date +%Y.%m.%d

题解先咕着。
        ▁▃▄▄▄▃▃▃▃▄▶
      ▗▇▀▔    ▔▔▔▔
     ▄▛   ▃▅━━■▄▂
    ▟▊   ▐▘     ▀▙
   ▟▜▌   ▐▖   ▋  ▐▍
  ▟▘ ▜   ▝▀▇▆●▘  ▐▌
▗▟▘   ▜▃       ▁▅▛
▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔   CopyRight :)
      ▔▔▔▔▔▔
#endif
#include <cstdio>
#include <algorithm>
#include <map>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const ll inf = 1000000000000000000;
std::map<ll, ll> f;
ll a, b, c, d;

ll dp (ll n) {
	if (f.count(n)) return f[n];
	return f[n] = std::min({
			n <= inf / d ? n * d : inf,
			dp(n / 2) + (n % 2) * d + a,
			dp(n / 2 + 1) + (2 - n % 2) * d + a,
			dp(n / 3) + (n % 3) * d + b,
			dp(n / 3 + 1) + (3 - n % 3) * d + b,
			dp(n / 5) + (n % 5) * d + c,
			dp(n / 5 + 1) + (5 - n % 5) * d + c,
			});
}

int main () {
	int q = read;
	while (q --) {
		ll n = read;
		read(a, b, c, d);
		f.clear();
		f[0] = 0;
		f[1] = d;
		f[2] = std::min(d + a, d + d);
		printf("%lld\n", dp(n));
		/* for (int i = 1; i <= 12; i ++) */
		/* 	debug("%lld\n", dp(i)); */
	}
}


Measured memory_bytes: 4536
#include<stdio.h>

int main(void)
{
	int x, a, b;
	int m;
	scanf("%d %d %d", &x, &a, &b);
	
	a = x - a;
	b = x - b;
	
	if(a < 0){
		a = 0 - a;
	}
	if(b < 0){
		b = 0 - b;
	}
	
	m = a;
	if(b < m){
		printf("B");
	}else{
		printf("A");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>

using namespace std;

int main(){
    int n;
    cin >> n;

    vector<long> x(n+1);
    long a[n];

    x[0] = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        x[i+1]=a[i];
    }

    sort(x.begin(), x.end());

    // for(int i=0; i<n+1; i++) cout << x[i] << " ";
    // cout << endl;
    for(int i=0; i<n; i++){
        //x.erase(x.begin()+i); 
        // cout << a[i] << endl;
        for(int j=0; j<n; j++){
            if(a[i] <= x[n/2]){
                cout << x[n/2+1] << endl;
                break;
            }else if(a[i] >= x[n/2+1]){
                cout << x[n/2] << endl;
                break;
            }
        }
        //x.insert(x.begin()+i, a[i]);
    }
}

Measured memory_bytes: 5376
n = int(input())
a = list(map(int, input().split()))
l = []
r = []
for i in range(n):
    if i%2 == 0:
        r.append(a[i])
    else:
        l.append(a[i])
if n%2 == 0:
    ans = l[::-1] + r
else:
    ans = r[::-1] + l
print(*ans)

Measured memory_bytes: 25156
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    ll n; cin >> n;
    if (n < 2 || (n & 1) != 0) {
        cout << 0 << endl;
        return 0;
    }
    n >>= 1;
    ll ans = 0;
    for (int i = 1; ll(pow(5, i)) <= n; i++) {
        ans += n / ll(pow(5, i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
# frozen_string_literal: true

n = gets.chomp[-1].to_i

h = {}
h[2] = h[4] = h[5] = h[7] = h[9] = 'hon'
h[0] = h[1] = h[6] = h[8] = 'pon'
h[3] = 'bon'

puts h[n]


Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  int X;
  cin >> X;
  //入力終了

  //各硬貨の枚数に関して全探索
  int ans = 0;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
	//ぴったりX円になる
	if(500*i+100*j+50*k == X)
	  ans++;
      }
    }
  }

  //解答
  cout << ans << endl;

  return 0;
}


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

int main() {
	int n;
	scanf("%d", &n);
	char s[n + 1];
	scanf("%s", s);
	
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			int a[n + 2];
			a[0] = i;
			a[1] = j;
			for (int k = 1; k <= n; k++) a[k + 1] = a[k] ^ a[k - 1] ^ (s[k % n] == 'x');
			if (a[0] != a[n] || a[1] != a[n + 1]) continue;
			for (int k = 0; k < n; k++) printf("%c", a[k] ? 'W' : 'S');
			puts("");
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 768
n = int(input())

al = list(map(int,input().split()))
absl = []
minus = 0
for a in al:
    absl.append(abs(a))
    if a < 0:
        minus += 1

if minus % 2 == 0:
    print(sum(absl))
else:
    print(sum(absl) - 2 * min(absl))



Measured memory_bytes: 65184
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int cnt,a;
  cnt=a=0;
  cin >> s;
  for (int i=0;i<s.size();i++){
    
  if(s.at(i)=='A' || s.at(i)=='T' || s.at(i)=='G' || s.at(i)=='C'  )
    cnt++;

  else if (cnt>=a){
    a=cnt; 
    cnt=0;
  }
  
  }
  if(s.at(s.size()-1)=='A' || s.at(s.size()-1)=='T' || s.at(s.size()-1)=='G' || s.at(s.size()-1)=='C'  )
  cout << max(a,cnt) << endl;
  else
cout << a << endl;

}

Measured memory_bytes: 256