akhauriyash/Code-Regression huggingface dataset:
value=[0]
weight=[0]
n,W=input().split()
n=int(n)
W=int(W)
for i in range(n):
	item=list(map(int,input().split()))
	value.append(item[0])
	weight.append(item[1])

dp=[[0 for j in range(W+1)] for i in range(n+1)]
for i in range(n+1):
	for j in range(W+1):
		if i==0:
			res=0
		elif j-weight[i]<0:
			res=dp[i-1][j]
		else:
			res=max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j])
		dp[i][j]=res
print(dp[n][W])

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


using namespace std;

int main()
{
string s,t;
cin >> s >> t;
int c=0;
for(int i=0;i<s.size(),i<t.size();i++)
{
    if(s[i]!=t[i])
    c++;
}
cout << c;


    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    string s;
    int k;
    cin>>s>>k;
    int memo=1;
    for(int i=0;i<k;i++){
        if(1!=(s[i]-'0')){
            memo=(s[i]-'0');
            break;
        }
    }
    cout<<memo<<endl;
}


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

int main(void) {
  int l;
  scanf("%d", &l);

  float edge = (float) l / (float) 3;
  printf("%Lf\n", (long double) edge * edge * edge);

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<char> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }

    int count = 1;

    for(int i = 0; i < N-1; i++){
        if(S.at(i) != S.at(i+1)){
            count++;
        }
    }

    cout << count << endl;

}

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

bool round_word(string s){
    int n = s.length();
    for(int i = 0; i < n/2; i++){
        if(s.at(i) != s.at(n-1-i)){
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.length();
    if(round_word(s) && round_word(s.substr(0,(n-1)/2)) && round_word(s.substr((n+3)/2-1))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# AGC003C - BBuBBBlesort!
def main():
    # reverse three elements <-> reverse left and right ones
    # -> the parities of indices of A doesn't change
    # find Ai which has different parities of indices in A and S
    N, *A = map(int, open(0).read().split())
    S = sorted(A)
    dif = set(A[::2]) ^ set(S[::2])
    # odd in A but even in S & even in A but odd in S -> // 2
    ans = len(dif) // 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 20964
#include <stdio.h>
int main(void){
    int r,c,i,j;
    int box[101][101];
    int sumsumsum=0;
   
    scanf("%d %d",&r,&c); 
    for(i=1;i<=r;i++){
        int sum=0;
        for(j=1;j<=c;j++){
                
            scanf("%d",&box[i][j]);
            printf("%d ",box[i][j]);
            sum+=box[i][j];
        }
        printf("%d\n",sum);
           
    }
       
       
      
    for(j=1;j<=c;j++){
        int sumsum=0;
        for(i=1;i<=r;i++){
            sumsum+=box[i][j];
        }    
         printf("%d ",sumsum);
        sumsumsum+=sumsum;
    }
    printf("%d\n",sumsumsum);
        
    return 0;   
}



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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010;

int n, m;
int dist[N];
int num[N];
PII stu[N];
struct Point{
    int x, y, idx;
}point[N];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        int x, y;
        cin >> x >> y;
        stu[i] = {x, y};
    }

    for(int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        point[i] = {x, y, i};
    }

    memset(dist, 0x3f3f3f3f, sizeof dist);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            int d = abs(stu[i].first - point[j].x) + abs(stu[i].second - point[j].y);
            if(d < dist[i])
            {
                dist[i] = d;
                num[i] = point[j].idx;
            }
        }

    for(int i = 1; i <= n; i++)
        cout << num[i] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N =cin.nextInt();
		while(N--!=0){
			String str = cin.next();
			char[] s = (str+"       ").toCharArray();
			int idx=0;
			String ans="";
			ans += s[idx++];
			while(true){
				if(idx>=str.length()){
					break;
				}
				if(s[idx]=='-'){
					idx++;idx++;
					if(!ans.contains(s[idx]+"")){
						ans = ans+s[idx];
					}
				}
				else{
					idx++;idx++;
					if(!ans.contains(s[idx]+"")){
						ans = s[idx]+ans;
					}
				}
				idx++;
			}
			System.out.println(ans);
			
		}
	}

}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll ans = 0, a, b; cin >> a >> b;
  ans += a;
  ans += (b / 2);
  fin(ans)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int h, w;
    cin >> h >> w;
    
    string MAP[h];
    for (int i = 0; i < h; ++i) cin >> MAP[i];
    
    int dp[h+1][w+1];
    memset(dp, 0x00, sizeof(dp));
    dp[1][0] = 1;
    
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1]) % mod;
            if (MAP[i][j] == '#') dp[i+1][j+1] = 0;
        }
    }
    
    cout << dp[h][w] << "\n";
    
    return 0;
}

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

const int maxn = 2e5 + 5;
std::map<std::string, int> mp;
std::string a;
int n, mx = 0;
typedef std::map<std::string,int>::iterator iter;
int main(){
	std::cin >> n;
	for(int i=1;i<=n;i++){
		std::cin >> a;
		mp[a] = mp[a] + 1;
	}
	for(iter it = mp.begin();it != mp.end(); ++it){
		mx = std::max(mx, it->second);
	}
	for(iter it = mp.begin();it != mp.end(); ++it){
		if(it->second == mx) std::cout << it->first << std::endl;
	}
	return 0;
}
	


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

typedef long long ll;
typedef double keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(){
    int x;

    scanf("%d", &x);

    int flag = 1;
    for(int i = 0; (x + i) < 100005; ++i){
        for(int j = 2; j <= (x + i) / 2; ++j){
            if(((x + i) % j) == 0){
                flag = 0;
                break;
            }else{
                flag = 1;
            }
        }
        if(flag == 1){
            printf("%d\n", x + i);
            return 0;
        }
    }

    return 0;
}


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

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

	if (S == "SUN") {
		cout << 7 << endl;
	}
	else if (S == "MON") {
		cout << 6 << endl;
	}
	else if (S == "TUE") {
		cout << 5 << endl;
	}
	else if (S == "WED") {
		cout << 4 << endl;
	}
	else if (S == "THU") {
		cout << 3 << endl;
	}
	else if (S == "FRI") {
		cout << 2 << endl;
	}
	else if (S == "SAT") {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
N = int(raw_input())
H = map(int,raw_input().split())
ans = "Yes"

for i in range(0,N-1):
  if H[i] == H[i+1]:
    continue
  elif H[i] <= H[i+1]-1:
    H[i+1] = H[i+1] - 1
  else:
    ans = "No"
    break
print ans

Measured memory_bytes: 11340
loop do
	n = gets.to_i
	break if n == 0
	scores = gets.split.map(&:to_i)
	sum = scores.inject(:+)
	average = sum.to_f / scores.size
	variance = scores.inject(0.0){|v, i| v + (i - average) ** 2.0} / n.to_f
	puts (variance ** (1.0/2)).round(5)
end

Measured memory_bytes: 8892
def main():
    S = input()

    while len(S) >= 5:
        if len(S) >= 7 and S[-7:] == "dreamer":
            S = S[:-7]
            continue

        if len(S) >= 6 and S[-6:] == "eraser":
            S = S[:-6]
            continue

        elif S[-5:] == "dream" or S[-5:] == "erase":
            S = S[:-5]
            continue

        else:
            break

    if len(S) == 0:
        print("YES")
    else:
        print("NO")

main()

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int n; cin >> n;
    string s; cin >> s;
    string gs = s;
    
    int l = 0,r = 0;
    rep(i,n){
        if(s[i] == '('){
            for(int j=i+1;j<n;j++){
                if(s[j] == ')'){
                    s[j] = 'e';
                    s[i] = 'e';
                    break;
                }
            }
        }else if(s[i] == ')'){
            for(int j=i-1;j>=0;j--){
                if(s[j] == '('){
                    s[j] ='e';
                    s[i] = 'e';
                    break;
                }
            }
        }
    }

    rep(i,n){
       if(s[i] == ')') r++;
       if(s[i] == '(') l++;
    }   
    string ans = "";
    rep(i,r) cout << '(';
    cout << gs;
    rep(i,l) cout << ')';
    cout << endl;
    return 0;
}

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

int main() {
	string S, T;
	cin >> S >> T;

	string ans=T;
  	for(auto c:S){
      ans.push_back(c);
    }
	cout << ans << endl;
}


Measured memory_bytes: 3568
import math

def calc_distance(p,q):
    sum = 0
    for i in range(d):
        sum = sum + (p[i] - q[i]) ** 2
    return math.sqrt(sum)


n,d = map(int,input().split())
matrix = [list(map(int,input().split())) for i in range(n)]

count = 0

for i in range(n):
    for j in range(n):
        if i < j:
            dist = calc_distance(matrix[i],matrix[j])
            if dist.is_integer() == True:
                count = count + 1

print(count)


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
char s[200001];
int main(){
    int n,a,b,c,d;
    scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s);
    a--;
    b--;
    c--;
    d--;
    int amax,bmax;
    for(amax=a;amax<n;amax++){
        if(s[amax]=='.')continue;
        if(amax+1<n&&s[amax+1]=='.')amax++;
        else break;
    }
    for(bmax=b;bmax<n;bmax++){
        if(s[bmax]=='.')continue;
        if(bmax+1<n&&s[bmax+1]=='.')bmax++;
        else break;
    }
    amax=std::min(amax,n-1);
    bmax=std::min(bmax,n-1);
    if(c<=amax&&d<=bmax){
        if(c<d)printf("Yes\n");
        else{
            int bothmin=std::max(a,b);
            int bothmax=std::min(c,d);
            if(bothmin<=bothmax){
                int len=0;
                for(int i=bothmin-1;i<=bothmax+1;i++){
                    if(s[i]=='.'){
                        len++;
                        if(len>=3)break;
                    }else{
                        len=0;
                    }
                }
                if(len>=3)printf("Yes\n");
                else printf("No\n");
            }else{
                printf("Yes\n");
            }
        }
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;
    cin>>n;
    vector<char> inner(10);
    vector<vector<char>> outer;
    REP(i,n){
        REP(j,10){
            cin>>inner[j];
        }
        sort(ALL(inner));
        outer.push_back(inner);
    }
    sort(ALL(outer));
    ll count=0;
    ll sum=0;
    REP(i,n){
        if(outer[i]==outer[i+1]){
            count++;
        }else{
            sum+=count*(count+1)/2;
            count=0;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 6836
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
before = -9

for i in a:
  ans += b[i - 1]
  if before + 1 == i:
    ans += c[before - 1]
  before = i

print(ans)



Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int alf[26];
    for(int i=0;i<26;i++)
    {
        alf[i] = 0;
    }
    while(1)
    {
        char c = getchar();
        if(c < 'a' || c > 'z')
        {
            break;
        }
        int tmp = c - 'a';
        alf[tmp]++;
    }
    
    for(int i=0;i<26;i++)
    {
        if(alf[i]%2)
        {
            puts("No");
            return 0;
        }
    }
    
    puts("Yes");
    return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int x = ni();
		if(x == 7 || x == 5 || x == 3) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21972
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	int W = 0, E = 0;
	rep(i, N) {
		if (S[i] == 'W')
			W++;
		else
			E++;
	}
	int Wdone = 0, Edone = 0; //調査済み
	int ans = N;
	rep(i, N) {
		if (S[i] == 'W') {
			W--;
		} else {
			E--;
		}
		ans = min(ans, Wdone + E);
		if (S[i] == 'W') {
			Wdone++;
		} else {
			Edone++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int n;
  cin>>n;
  VP a(n);
  rep(i,n)cin>>a[i].fi>>a[i].se;
  SORT(a);

  VP pass;
  rep(i,n){
    rep(j,n){
      int x=a[j].fi-a[i].fi;
      int y=a[j].se-a[i].se;
      pass.pb({x,y});
    }
  }

  int ans=LINF;
  for(auto&p:pass){
    V<bool> used(n,false);
    int res=0;
    rep(i,n){
      if(used[i])continue;
      used[i]=true;
      res++;
      int x=a[i].fi+p.fi;
      int y=a[i].se+p.se;
      rep(j,n){
        if(used[j])continue;
        if(a[j].fi==x && a[j].se==y){
          used[j]=true;
          x=a[j].fi+p.fi;
          y=a[j].se+p.se;
        }
      }
    }
    chmin(ans,res);
  }
  out(ans);
  
  
  return 0;
}


Measured memory_bytes: 384
/**
 *    author:  FromDihPout
 *    created: 2020-08-09
**/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int sum = a[i] + a[j];
            auto k = lower_bound(j + 1 + all(a), sum);
            int pos = k - a.begin();
            ans += pos - j - 1;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

ll count(ll x,ll y){
    return y-x;
}

int main(){
    ll x,y;
    cin>>x>>y;
    ll c[4];
    c[0] = count(x, y);
    c[1] = count(-x, y)+1;
    c[2] = count(x, -y)+1;
    c[3] = count(-x, -y)+2;
    sort(c, c+4);
    rep(i,4) if(c[i]>=0){
        cout << c[i] << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    ll cnt = 0;
    while (!b.empty() and b[0]>=a[0] and h>0) {
        cnt++;
        h -= b[0];
        b.erase(b.begin());
    }
    cnt += max(0LL, (h + a[0] - 1)) / a[0];
    cout << cnt << endl;
}

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

int main(){
    int n,m,c;cin >> n >> m >>c;
    vector<int> b(m);
    int a[n][m];

    for (int i=0;i<m;i++){
        cin >> b[i];
    }

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

    int count = 0;

    for (int i=0;i<n;i++){
        int result = c;
        for (int j=0;j<m;j++){
            result += a[i][j] * b[j];
        }

        if (result > 0){
            count++;
        }
    }

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

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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int MAXINT = 2147483647;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];
int head[MAXN];

string s[MAXN];

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

struct edge {
	int to, next;
}e[MAXN << 1];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

bool cmp(string x, string y) {
	return x < y;
}

int main(){
	int T;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
	}
	sort(s + 1, s + n + 1, cmp);
	for (int i = 1; i <= n; i++) {
		cout << s[i];
	}
	printf("\n");
	return 0;
}

/*

*/

//Flakire
//Lord Wang
//yxm9
//akdxl
//WYXak
//MifafaOvO
//AKarry5037
//deakX
//xyx
//Fraggay



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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	cin>> n;

	vi a(n+1);
	matrix x (20, vi(20));
	matrix y (20, vi(20));

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

	int ans = 0;
	for(int i = 1; i < (1 << n); ++i){
		bool flag = 1;

		for(int j = 1; j<=n; ++j){
			if(!(i & (1 << (j-1)))) continue;

			for(int k = 1; k<=a[j]; ++k)
				if(((i >> (x[j][k] - 1)) & 1) ^ y[j][k]) flag = 0;
		}
		if(flag) ans = max(ans, __builtin_popcount(i));
	}
	cout<< ans<< endl;
}
int32_t main(){
	fastio;
	solve();
	return 0;
}

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

int main() {
    int n, ans;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i <= n; i++) {
        int r = 0;
        while (r < i && s[n-i+r] == t[r]) r++;
        if (r == i) ans = n+n-i;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector] size: " << A.size() << endl;
    
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    cin >> N;

    vector<ll> x, y;
    x.reserve(N);
    y.reserve(N);

    FOR(i, 0, N){
        ll v;
        cin >> v;
        x.push_back(v);
        y.push_back(v);
    }

    sort(ALL(y));

    if(y[N/2] == y[N/2 - 1]){
        ll answer = y[N/2];
        FOR(i, 0, N){
            p(answer);
        }        
    }else{
        // 切り捨てが起こっていることに注意
        ll left = y[N/2 - 1];
        ll right = y[N/2];
        ll center = (left + right) / 2;
        FOR(i, 0, N){
            if(x[i] <= center){
                p(right);
            }else{
                p(left);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 5376
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 20000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.8+start:
        nt = [i for i in t]
        r = random.randrange(1,n+1)
        nt[i] = r
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
int main()
{
    ll k, s;
    ll ans = 0;
    cin >> k >> s;

    rep(h, k+1){
        rep(i, k+1){
            if (s - h - i <= k && s - h - i >= 0){
                ans++;
            }
        }
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int a, b;

		n = sc.nextInt();
		if (n == 2) {
			a = sc.nextInt();
			b = sc.nextInt();
			System.out.println(a + b);
		} else {
			System.out.println("Hello World");
		}

		sc.close();
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  vector<double> p(n);
  REP (i, n) cin >> p[i];
  vector<double> dp(n + 1);
  dp[0] = 1;
  REP (i, n) {
    for (int j = n - 1; j >= 0; j--) {
      dp[j + 1] += dp[j] * p[i];
      dp[j] = dp[j] * (1 - p[i]);
    }
  }
  double ans = 0;
  REPI (i, (n + 1) / 2, n + 1) {
    ans += dp[i];
  }
  cout << setprecision(15) << ans << endl;
}


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

using namespace std;

int main()
{
    string s;
    int i,j,k;

    int n;
    cin>>n;

    int ara[n];
    for(i=0;i<n;i++)cin>>ara[i];

    int ans=100000000;
    for(i=-100;i<101;i++){
        int rem=0;
        for(j=0;j<n;j++){
            rem += ((ara[j]-i)*(ara[j]-i));
        }
        ans = min(ans,rem);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
// ABC154D - Dice in Line

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
	}

	vector<double> A(N, 0);
	A.at(0) = (double)(p.at(0) + 1.0)/ 2.0;
	for (int i = 1; i < N; i++) {
		A.at(i) = (double)(p.at(i) + 1.0)/ 2.0 + A.at(i - 1);
	}

	double maximum, temp_max;

	maximum = A.at(K - 1);
	for (int i = K; i < N; i++) {
		temp_max = A.at(i) - A.at(i - K);
		maximum = max(maximum, temp_max);
	}

//	cout << maximum << endl;
	printf("%lf\n", maximum);

	return 0;
}


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

using namespace std;

int main()
{
string S, T ;
cin >> S>>T ;
int a=0 ;
if(S.at(0)==T.at(0))
    a++;
    if(S.at(1)==T.at(1))
        a++ ;
    if (S.at(2)==T.at(2))
        a++ ;


    cout << a ;






    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

string int_to_string(int x,int n) {
	string res;
	int y = 10;
	for (int i = 0; i < n; i++) {
		res.push_back('0' + (x % y) / (y / 10));
		y *= 10;
	}
	reverse(res.begin(), res.end());
	return res;
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> p(m);
	if (m > 0) {
		for (int i = 0; i < m; i++) {
			int s, c;
			cin >> s >> c;
			p[i] = make_pair(s, c);
		}
	}

	if (n == 1) {
		for (int i = 0; i < 10; i++) {
			bool flag = true;
			for (int j = 0; j < m; j++) {
				if (p[j].first != 1) {
					flag = false;
					break;
				}
				if (p[j].second != i) flag = false;
			}
			if (flag) {
				cout << i << endl;
				return 0;
			}
		}
		cout << -1 << endl;
		return 0;
	}

	int begin = 1;
	for (int i = 0; i < n - 1; i++) begin *= 10;
	for (int i = 10; i < 1000; i++) {
		if (i / begin > 0 && i / begin < 10) {
			string s = int_to_string(i, n);
			bool flag = true;
			for (int j = 0; j < m; j++) {
				if (s[p[j].first - 1] != '0' + p[j].second) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

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

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

ll n;
string a[10]={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};

int main(){
    IO;
    cin>>n;
    cout<<a[n%10];
}
    

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(void){
int n,h,w,s=0;
int a,b;
cin>>n>>h>>w;
for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a>=h&&b>=w){
        s++;
    }
}
cout<<s<<endl;
}


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

namespace EDPC
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = new int[N];
            int[] b = new int[N];
            int[] c = new int[N];
            int[,] DP = new int[N, 3];

            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            DP[0, 0] = input[0];
            DP[0, 1] = input[1];
            DP[0, 2] = input[2];

            for (int i = 1; i < N; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (j != k) DP[i, j] = Math.Max(DP[i, j], input[j] + DP[i - 1, k]);
                    }
                }
            }
            Console.WriteLine(Math.Max(DP[N - 1, 2], Math.Max(DP[N - 1, 0], DP[N - 1, 1])));
        }
    }
}


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

typedef long long ll;

int main(void)
{
    //freopen("input.txt", "r", stdin);

    ll a, b, x;
    cin >> a >> b >> x;

    ll cnt = 0;

    cnt = cnt + (b/x) - (a/x);
    if(a % x == 0)
        cnt++;

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 3632
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def divisors(n):
    lower = []
    upper = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)

    lower.extend(reversed(upper))
    return lower


def main():
    N, K, *A = map(int, read().split())

    total = sum(A)
    div = divisors(total)

    for d in reversed(div):
        vec = [a % d for a in A if a % d]
        if not vec:
            print(d)
            return
        vec.sort()
        M = len(vec)
        csum_sub = [0] * (M + 1)
        csum_add = [0] * (M + 1)
        for i in range(M):
            csum_sub[i + 1] = csum_sub[i] + vec[i]
            csum_add[i + 1] = csum_add[i] + d - vec[i]

        for i in range(1, M):
            if csum_sub[i] <= K and csum_sub[i] == csum_add[M] - csum_add[i]:
                print(d)
                return

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9572
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

//四捨五入
double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

using namespace std;

int main()
{
	int N;
	cin>>N;
	int *Xarray = new int[N]; 
	double sum = 0;
	long long int squareSum = 0;
	int P;
	for(int i = 0; i < N; i++){
		cin>>Xarray[i];
		sum += Xarray[i];
		squareSum += Xarray[i]*Xarray[i];
	}
	P = round( sum / N);
	cout<<N*P*P - 2*P*sum + squareSum<<endl;
	return 0;
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n;
    cin >> n;
    cout << n * (n + 1) / 2 << '\n';
    return 0;
}


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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int T2 = H2 * 60 + M2;
  int T1 = H1 * 60 + M1;
  int ans = T2 - T1 - K;
  cout << ans << endl;
}

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

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

  int num = 0;
  int max = 0;

  for(int i=0;i<s.size();i++) {
    if(s[i] == 'I') num++;
    if(s[i] == 'D') num--;
    if(num > max) max = num;
  }

  cout << max << endl;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  string s;
  cin >> s;

  reverse(all(s));
  REP(i, 4) { reverse(all(divide[i])); }
  bool can = true;

  for (int i = 0; i < s.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];

      if (s.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  cout << (can ? "YES" : "NO");
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int k,s,i,j,sum=0;
	scanf("%d %d",&k,&s);
	for(i=0;i<=k;i++)
	{
		for(j=0;j<=k;j++)
		{
			if((i+j)<=s&&(i+j)>=(s-k))
			{
				sum++;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}

bool sign(ll a){
    return a>=0;
}

int main(){
    dcl(a,b,c,d,n);
    if(a*2<b)b=a*2;
    if(b*2<c)c=b*2;
    if(c*2<d)d=c*2;
    cout<<n/2*d+n%2*c<<endl;
    
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 100

int main(){
  int n,u,k,v,M[N][N];
  int i,j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      M[i][j] = 0; 
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      M[u-1][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n-1; j++){
      printf("%d ",M[i][j]);
    }
    printf("%d\n",M[i][j]);
  }
  return 0;
}

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

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

using namespace std;
constexpr long long int mod = 1000000007, MOD = 998244353;
constexpr double PI = 3.14159265358979323846;
vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

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

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

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}
int main() {
	vector<int>s(50);
	s.at(1) = 1;
	for (size_t i = 2; i < 50; i++)
	{
		s.at(i) = s.at(i - 1) + i;
	}
	long long N;
	cin >> N;
	vector<pair<long long, long long>>U = prime_factorize(N);
	long long ans = 0;
	for (auto t:U)
	{
		for (size_t i = 1; i < 50; i++)
		{
			if (s.at(i) <= t.second)ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	// ���� ---------------------------------------------
	int D;
	cin >> D;

	vector<int> c(26, 0);
	for (int i = 0; i < c.size(); i++) {
		cin >> c[i];
	}

	vector<vector<int>> s(D, vector<int>(26, 0));
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s[i].size(); j++) {
			cin >> s[i][j];
		}
	}
	// ----------------------------------------------------


	// �×~�@ ---------------------------------------------
	// �X�R�A
	int score = 0;
	// ���̃X�R�A
	int dscore = 0;
	// �O���̃X�R�A
	int bscore = 0;
	// �R���e�X�g�����{�����ŋ߂̓��ɂ�
	vector<int> last(26, -1);
	// �R���e�X�g�̓���
	vector<int> day(D, 0);
	// ���ɂ��̃��[�v
	for (int i = 0; i < D; i++) {
		// ����܂ł̃X�R�A���i�[
		dscore = bscore;
		// 0�Ԗڂ̃R���e�X�g�̃X�R�A����Ƃ��Ċi�[
		score += s[i][0];
		last[0] = i;
		for (int k = 0; k < c.size(); k++) {
			score -= c[k] * (i - last[k]);
		}
		day[i] = 1;
		// �R���e�X�g�̃��[�v
		for (int j = 0; j < 26;  j++) {
			dscore += s[i][j];
			last[j] = i;
			for (int k = 0; k < c.size(); k++) {
				dscore -= c[k] * (i - last[k]);
			}
			if (dscore > score) {
				score = dscore;
				day[i] = j + 1;
			}
			// �O���̃X�R�A�ɖ߂�
			dscore = bscore;
		}
		// �X�R�A���i�[
		bscore = score;
	}

	// �o��
	for (int i = 0; i < day.size(); i++) {
		cout << day[i] << endl;
	}
	// ----------------------------------------------------

	/*
	// A ��� ----------------------------------------------------
	vector<int> t(D, 0);
	for (int i = 0; i < t.size(); i++) {
		cin >> t[i];
		t[i]--;
	}

	int ans = 0;

	for (int i = 0; i < t.size(); i++) {
		ans += s[i][t[i]];
		last[t[i]] = i;
		for (int j = 0; j < c.size(); j++) {
			ans -= c[j] * (i - last[j]);
		}
		cout << ans << endl;
	}
	// ----------------------------------------------------
	*/

	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <errno.h>
using namespace std;
int main()
{
    int type;
    cin>>type;
    if (type % 10 == 3){
        puts("bon\n");
    }
   else if (type % 10 == 2 || type % 10 == 4 || type % 10 == 5 || type % 10 == 7 || type % 10 == 9){
        puts("hon\n");
    }
    else{
        puts("pon\n");
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;
const double rate = 380000.0;

int main(){
	int N;
  	cin >> N;
	vector<pair<string, double>> C(N);
	rep(i, N)cin >> C[i].second >> C[i].first;
	double sum = 0;
	rep(i, N){
		if(C[i].first == "JPY"){
			sum += C[i].second;
		} else {
			sum += C[i].second * rate;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256