akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;

void main() {
  string str = readln.chomp;
  string[4] ss = ["dream", "erase", "eraser", "dreamer"];

  // array.lengthの返り値の型はulongなので
  // intに代入しようとすると(dmd64 v2.070.1では)CEになる
  int p = str.length.to!int;

  while (p > 0) {
    bool flag = false;

    if (str[p - 1] == 'r') {
      for (int i = 2; i < 4; ++i) {
        if (p < ss[i].length.to!int) {
          break;
        }

        if (ss[i] == str[(p - ss[i].length.to!int)..p]) {
          p -= ss[i].length.to!int;
          flag = true;
          break;
        }
      }
    }
    else if (str[p - 1] == 'e' && p >= 5) {
      if (str[(p - ss[1].length.to!int)..p] == ss[1]) {
        flag = true;
        p -= ss[1].length.to!int;
      }
    }
    else if (str[p - 1] == 'm' && p >= 5) {
      if (str[(p - ss[0].length.to!int)..p] == ss[0]) {
        flag = true;
        p -= ss[0].length.to!int;
      }
    }

    if (!flag) {
      writeln("NO");
      return;
    }
  }

  writeln("YES");

  return;
}

Measured memory_bytes: 508
#include "stdio.h"
#include <iostream>

using namespace std;

static int MAX_N = 100;

void trace(int n, int* num) {
	for(int i = 0; i < n - 1; i ++) {
		printf("%d ", num[i]);
	}
	printf("%d\n", num[n - 1]);
}

int  bobbleSort(int n, int* num) {
	int count = 0;
	for(int i = 0; i < n - 1; i ++) {
		for(int j = n - 1; j >= i; j --) {
			if(num[j] < num[j - 1]) {
				int temp = num[j];
				num[j] = num[j - 1];
				num[j - 1] = temp;
				count ++;
			}
		}
	}
	return count;
}

int main() {
	int n, num[MAX_N];
	scanf("%d", &n);
	for(int i = 0; i < n; i ++) {
		scanf("%d", &num[i]);
	}
	int count = bobbleSort(n, num);
	trace(n, num);
	printf("%d\n", count);
}

Measured memory_bytes: 3236
#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b && b!=c){
		printf("Yes\n");
	}
		else if(a==c && b!=a){
		printf("Yes\n");
	}
		else if(b==c && a!=b){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  int C[N], S[N], F[N];
  for(int i=1;i<=N-1;i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  for(int s=1;s<=N-1;s++){
    int ti = S[s] + C[s];
    for(int i=s+1;i<=N-1;i++){
      if(ti > S[i]){
        if(ti %F[i] == 0) ti += C[i];
        else ti = F[i] * (ti/F[i] + 1) + C[i];
      }else{
        ti = S[i] + C[i];
      }
    }
    cout << ti << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef tuple<ll, ll, ll> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll ans = LINF;
    for(ll i = 1; i*i <= N; i++){
        if(N%i != 0) continue;
        ll j = N/i;
        chmin(ans, i-1 + j-1);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            String str = in.next();

            String subA = str.substring(0, a);
            String subB = str.substring(a + 1);

            if (str.charAt(a) == '-' &&
                    !subA.contains("-") &&
                    !subB.contains("-")) {
                out.print("Yes");
            } else {
                out.print("No");
            }
        }

    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e18+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=500001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
int db(int n)
{
    int i=0;
    int j=0;
    while(n>0)
    {
        int r=n%10;
        n=n/10;
        j+=(1<<i)*r;
        i++;
    }
    return j;
}
int main()
{
   
    
   
   int n,i,j,l;
   cin>>n;
   int a[n][2];
   for(i=0;i<n;i++)
   {
    cin>>a[i][0]>>a[i][1];
   }
   j=0;
   for(i=0;i<n-2;i++)
   {
       if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
        j=1;
   }
   if(j)
    cout<<"Yes";
else
    cout<<"No";

}

Measured memory_bytes: 3632
from sys import stdin


def main() -> None:
    n, a, b = [int(next_str()) for _ in range(3)]
    ans = 0

    for i in range(1, n + 1):
        sum_of_digits_i = sum_of_digits(i)
        if a <= sum_of_digits_i <= b:
            ans += i

    print(ans)


def sum_of_digits(a: int) -> int:
    result = 0
    while a != 0:
        result += a % 10
        a //= 10
    return result


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    string s;
    cin>>s;
    int n=(int)s.size();
    int cnt=0;
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='T' && cnt<=0 ) {
            ans++;
        }
        else if(s[i]=='T') cnt--;
        else if(s[i]=='S') cnt++;
    }
    cout<<ans*2<<endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int H,W;
int N;
int a[10001];
int c[101][101];
int main(){
    cin>>H>>W;
    cin>>N;
    REP(i,N){
        cin>>a[i];
    }
    int cc=0;
    REP(i,N){
        while(1){
           if(a[i]==0)break;
           c[cc/W][cc%W]=i+1;
           cc++;
           a[i]--;
        }
    }
    REP(i,H){
        if(i%2==0){
           REP(j,W){
               cout<<c[i][j];
               if(j==W-1){
                  cout<<endl;
               }else{
                  cout<<" ";
               }
           }
        }else{
           for(int j=W-1;j>=0;j--){
               cout<<c[i][j];
               if(j==0){
                  cout<<endl;
               }else{
                  cout<<" ";
               }
           }
        }
    }
    return(0);
}

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

namespace TestTemplate
{
    class Program
    {
        static void Main()
        {
            var a = ReadInt();
            var sum = 1;
            for (int i = 0; i < a-1; i++)
            {
                sum += i + 2;
            }
            Console.WriteLine(sum.ToString());
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadInt() => int.Parse(ReadLine());
        public static int[] ReadIntArray() => ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        public static string[] ReadStrArray() => ReadLine().Split(' ').ToArray();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct Parser{
    typedef string::const_iterator itr;
    itr begin;
    map<string,int> mp;
    T ans;
    Parser(const string &s,const map<string,int> &mp):mp(mp){
        begin=s.begin();
        ans=Molecule(begin);
    }
    T Molecule(itr &begin){
        T ret=0;
        while(*begin!='\0'){
            if('A'<=*begin&&*begin<='Z'){
                T tmp=Atom(begin);
                if('1'<=*begin&&*begin<='9'){
                    tmp*=Number(begin);
                }
                ret+=tmp;
            }else if(*begin=='('){
                consume(begin,'(');
                T tmp=Molecule(begin);
                while(*begin!=')'){
                    tmp+=Molecule(begin);
                }
                consume(begin,')');
                tmp*=Number(begin);
                ret+=tmp;
            }else{
                break;
            }
        }
        return ret;
    }
    T Atom(itr &begin){
        string Letter;
        Letter+=*begin;
        consume(begin,*begin);
        if('a'<=*begin&&*begin<='z'){
            Letter+=*begin;
            consume(begin,*begin);
        }
        if(mp.at(Letter)){
            return mp[Letter];
        }
        throw;
    }
    T Number(itr &begin){
        T ret=0;
        while(1){
            ret*=10;
            ret+=*begin-'0';
            consume(begin,*begin);
            if('0'<=*begin&&*begin<='9'){
                continue;
            }else{
                return ret;
            }
        }
    }
    void consume(itr &begin,char expected){
        if(*begin==expected){
            begin++;
        }else{
            fprintf(stderr,"Expected: '%c' Got: '%c'\n",expected,*begin);
            fprintf(stderr,"Rest string is ");
            while(*begin){
                fprintf(stderr,"%c",*begin++);
            }
            fprintf(stderr,"\n");
        }
    }
};

void solve(const map<string,int> &mp){
    string s;
    while(cin>>s&&s!="0"){
        try{
            Parser<int> p(s,mp);
            cout<<p.ans<<endl;
        }
        catch(...){
            cout<<"UNKNOWN"<<endl;
            solve(mp);
        }
    }
}

int main(){
    map<string,int> mp;
    string s;
    while(cin>>s&&s!="END_OF_FIRST_PART"){
        cin>>mp[s];
    }
    solve(mp);
    return 0;
}



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

int sn(int n) {
  int k;
  k = n % 10;
  return k;
}

int ln(int n) {
  int x;
  x = log10(n);
  int y = 1;
  for (int i = 0; i < x; i++) {
    y *= 10;
  }
  return n / y;
}

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(10, vector<int>(10));
  for (int i = 1; i <= N; i++) {
    A.at(ln(i)).at(sn(i)) += 1;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += A.at(i).at(j) * A.at(j).at(i);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main( )
{
     int n;
     cin>>n;
     int t, nxt = 1, cnt = 0;
     for (int i = 0; i < n; i++) {
     cin >> t;
     if (t == nxt)
         nxt++;
     else
         cnt++;
}
cout << (cnt == n ? -1 : cnt);
}

Measured memory_bytes: 3520
h, w = map(int, input().split())
s = [input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            sum = 0
            for a in range(max(i-1, 0), min(i+2, h)):
                for b in range(max(j-1, 0), min(j+2, w)):
                    if s[a][b] == "#":
                        sum += 1
            print(sum, end="")
        else:
            print("#", end="")
    print()


Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>

int main()
{
    int r;
    int D;
    int x;
    int X[11];

    scanf("%d %d %d", &r, &D, &x);

    X[0] = x;

    for (int i = 1; i <= 10; i++) //FOR分の中に　;　を使う。
    {
        X[i] = X[i - 1] * r - D;
        printf("%d\n", X[i]); //文字列のと変数との間に　,　を忘れがち！！
    }
    return 0;
}

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

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

struct insert_t {
	int num;
	llong int kosu;
} ;

int compare_insert(const void *a, const void *b) {
  struct insert_t *A = (struct insert_t *)a;
  struct insert_t *B = (struct insert_t *)b;
  return A->num - B->num;
}



int main(void)
{
	//変数の宣言
	int n;
	long int k;
	static struct insert_t insert[100010];
	
	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	llong int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %ld",&n,&k);
	
	for(i=0;i<n;i++){
		scanf("%d %lld",&insert[i].num,&insert[i].kosu);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	qsort(insert, n, sizeof(struct insert_t), compare_insert);
	
	for(i=0;i<n;i++){
		count=count+insert[i].kosu;
		if(count-k>=0){
			printf("%d",insert[i].num);
			return 0;
		}
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("error");
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 3324
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	if (A[0] != 0) cout << -1 << endl;
	else {
		long long ans = 0;
		for (int i = 1; i < N; ++i) {
			if (A[i] - A[i - 1] >= 2) {
				ans = -1;
				break;
			}
			if (i == N - 1 || A[i + 1] - A[i] != 1) {
				ans += A[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
const int N = 2e5;
const long long INF = 2e12;
using namespace std;
int n,a[N + 5],p[N + 5];
long long ans,k;
int cmp(int x,int y)
{
    return x > y;
}
int check(long long x)
{
    long long m = k,now;
    for (int i = 1;i <= n;i++)
        if (1ll * a[i] * p[i] > x)
        {
            now = x / p[i];
            now = a[i] - now;               
            if (m < now)
                return 0;
            if (now > 0)
                m -= now;
        }
    return 1;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for (int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    for (int i = 1;i <= n;i++)
        scanf("%d",&p[i]);
    sort(a + 1,a + n + 1);
    sort(p + 1,p + n + 1,cmp);
    long long l = 0,r = INF,mid;
    while (l <= r)
    {
        mid = l + r >> 1;
        if (check(mid))
            r = mid - 1,ans = mid;
        else
            l = mid + 1;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
string = input()

left = ""
right = ""

left = string[0:len(string)//2]
right = string[len(string)//2 + 1 if len(string)%2==1 else 0:len(string)]

right = right[::-1]

count = 0
for i in range(len(left)):
    count += 1 if left[i] != right[i] else 0

print(count)


Measured memory_bytes: 3060
N = int(input())
A_list = [int(input()) for i in range(N)]
A_list_soretd = sorted(A_list)
result_max = A_list_soretd[-1]
result_max2 = A_list_soretd[-2]

for a in A_list:
    if result_max == a:
        print(result_max2)
    else:
        print(result_max)

Measured memory_bytes: 14112
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a*100+b*10+c)%4==0){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
sticks = list(map(int, input().split()))
sticks.append(0)
sticks.sort()
sticks.reverse()
ans = []

def find(sticks):

  for i in range(n):
    if sticks[i] == sticks[i+1] == sticks[i+2] and not sticks[i+3] == sticks[i]:
      continue
    elif sticks[i] == sticks[i+1]:
      ans.append(sticks[i])
  
  if len(ans) <= 2:
    ans.append(0)
    ans.append(0)
  return ans[0] * ans[1]
print(find(sticks))

Measured memory_bytes: 14244
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int N=405;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin>>n>>m;
    V<bitset<N>> poss(n);
    F(i,n) {
        poss[i].set();
        poss[i][i] = false;
    }
    F(k,m) {
        int a,b; cin>>a>>b;
        a--, b--;
        if (poss[a][b]) {
            bitset<N> tmp = poss[b];
            poss[b] &= poss[a];
            poss[a] &= tmp;
        } else {
            poss[a].reset();
            poss[b].reset();
        }
        F(i,n) {
            poss[i][a] = poss[a][i];
            poss[i][b] = poss[b][i];
        }
    }
    int cnt=0;
    F(i,n) F(j,n) if (i<j && poss[i][j])
        cnt++;
    P(cnt);
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

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

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;

int n;
ll dp[2][N], a[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(5) << fixed;

	cin >> n;

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

	for(int i = 0; i <= n; ++i)
		dp[0][i] = dp[1][i] = -1;

	dp[0][0] = 0;


	for(int i = 1; i <= n; ++i)
	for(int j = 0; j < 2; ++j){
		int x = a[i] - j;
		for(int k = 0; k < 2; ++k)
			if(k <= x && k <= a[i + 1])
				dp[k][i] = max(dp[k][i], dp[j][i - 1] + k + (x - k) / 2);
	}

	cout << max(dp[0][n], dp[1][n]);

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;

int main (){
    long N, A, B;
    cin >> N >> A >> B;
    long ans = 0;;

    long num_set;
    long num_res;

    long C = A + B;
    if(C|= 0){
        num_set = N/(A+B);
        num_res = N%(A+B);
    }
    ans = num_set * A + min(num_res, A);
   
   cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	N := readint()
	for i := 0; i < 1000; i++ {
		if i*1000 >= N {
			fmt.Println(i*1000 - N)
			break
		}
	}
}

func readline() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

func lcm(v1, v2 int) int {
	if v1 > v2 {
		v1, v2 = v2, v1
	}
	for v1 != 0 {
		v1, v2 = v2%v1, v1
	}
	return v2
}

func gcd(v1, v2 int) int {
	return v1 * v2 / lcm(v1, v2)
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }


Measured memory_bytes: 2488
#include <stdio.h>

int main(void) {
	int n, i;
	int max = 0;
	int min = 1000;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		int tmp;
		scanf("%d", &tmp);
		if(tmp > max)
			max = tmp;
		if(min > tmp)
			min = tmp;
	}
	printf("%d\n", max - min);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
#include<tuple>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define fi first
#define se second
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	map<ll, ll> m;
	rep(i, n) {
		ll a;
		cin >> a;
		m[i+1] = a;
	}
	for (auto p : m) {
		if (m[p.second] == p.first) ans++;
		//cout << ans << endl;
	}
	cout << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 6528
import sys
input = sys.stdin.readline


N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, w = map(int, input().split())
    graph[a-1].append((b-1, w))
    graph[b-1].append((a-1, w))

def dfs(s):
    stack = [s]
    Color = [-1]*N
    Color[s] = 0
    while stack:
        p = stack.pop()
        for np, w in graph[p]:
            if Color[np] == -1:
                Color[np] = Color[p]^(w%2)
                stack.append(np)
    return Color

if __name__ == "__main__":
    Color = dfs(0)
    print(*Color, sep="\n")


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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,i,j,k,cnt=0;
	cin >> n;
	vector<int> v(n);
	for(i=0;i<n;i++)
		cin >> v[i];
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{
			if(v[i]==v[j])
				continue;
			for(k=j+1;k<n;k++)
			{
				if(v[i] == v[k] or v[j] == v[k])
					continue;
				else if(v[i]+v[j]>v[k] and v[j]+v[k]>v[i] and v[k]+v[i]>v[j])
					cnt++;
			}
		}
	}
	cout << cnt << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 3652
(defun cb (accum cell)
    (let ((result (+ (car cell) (cadr cell))))
        (cond ((< result accum) result)
            (t accum))))

(defun solve (p q r)
    (declare (optimize (speed 3) (safety 0))
        (fixnum p q r))
    (let* ((lst `((,p ,q) (,q ,r) (,p ,r)))
              (result (reduce #'cb lst :initial-value 100000)))
        (print result)))

(solve (read) (read) (read))


Measured memory_bytes: 5220
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int a,b;
	int ans;
	
	//データの読み込み
	scanf("%d %d",&a,&b);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	ans = (a-1)*(b-1);
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    double T,A;
    cin >> T>>A;

    cout << T/A;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const int MOD = 1000000007;
const int maxSize = 200001;
long long inv[maxSize];
long long fact[maxSize];
long long factInv[maxSize];
map<pair<int, int>, pair<long long, long long>> mp;

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

long long calcInv(long long a){
    return modPow(a, MOD-2);
}

pair<long long, long long> search(const vector<vector<int>>& g, int pos, int prev){
    if(mp.count(make_pair(pos, prev))) return mp[make_pair(pos, prev)];
    if(mp.count(make_pair(pos, -1))){
        auto all = mp[make_pair(pos, -1)];
        auto part = search(g, prev, pos);
        all.first = (all.first * factInv[g.size()-1]) % MOD;
        all.first = (all.first * fact[g.size()-1-part.second]) % MOD;
        all.first = (all.first * fact[part.second]) % MOD;
        all.first = (all.first * calcInv(part.first)) % MOD;
        all.second -= part.second;
        return mp[make_pair(pos, prev)] = all;
    }
    long long res = 1;
    long long allSize = 0;
    for(auto& t : g[pos]){
        if(t == prev) continue;
        auto pr = search(g, t, pos);
        allSize += pr.second;
        res = (res * pr.first) % MOD;
        res = (res * factInv[pr.second]) % MOD;
    }
    res = (res * fact[allSize]) % MOD;
    return mp[make_pair(pos, prev)] = make_pair(res, allSize+1);
}

int main(){
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
    int N;
    while(cin >> N){
        vector<vector<int>> g(N);
        for(int i=0;i<N-1;i++){
            int a, b; cin >> a >> b;
            --a; --b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        mp.clear();
        vector<pair<int, int>> vp;
        for(int i=0;i<N;i++) vp.emplace_back(g[i].size(), i);
        sort(vp.rbegin(), vp.rend());
        vector<int> res(N);
        for(auto& p : vp) res[p.second] = search(g, p.second, -1).first;
        for(auto& t : res) cout << t << endl;
    }
}

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

int main () {
    int D,N;
    cin >> D >> N;
    if ((D == 0) && (N != 100)) {
        cout << N << endl;
    } else if ((D == 1) && (N != 100)) {
        cout << N*100 << endl;
    } else if ((D == 2) && (N != 100)) {
        cout << N*10000 << endl;
    } else if ((D == 0) && (N == 100)) {
        cout << 101 << endl;
    } else if ((D == 1) && (N == 100)) {
        cout << 10100 << endl;
    } else if ((D == 2) && (N == 100)) {
        cout << 1010000 << endl;
    }
}

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

int main() {
  vector<int> a(5);
  
  for(int i = 0; i < 5; i++){
    cin >> a.at(i);
  }
  
  int k;
  cin >> k;
  
  bool ans = true;
  int bre = 0;
  
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++){
      if(max(a.at(i),a.at(j))-min(a.at(i),a.at(j))>k){
        ans = false;
        bre = 1;
      }
    }
    if(bre==1){
      break;
    }
  }
  
  if(ans){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
  
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int k; cin >> k;
    int odd = (k+1)/2;
    int even = k/2;
    cout << odd*even << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int lcs(const string& x, const string& y)
{
	int n = x.size();
	int m = y.size();

	int dp[n+1][m+1];
	for (int i = 0; i < n+1; i++)
		dp[i][0] = i;

	for (int j = 0; j < m+1; j++)
		dp[0][j] = j;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int di = dp[i][j-1]+1;
			int dd = dp[i-1][j]+1;

			if (x[i-1] == y[j-1])
				dp[i][j] = min(min(di, dd), dp[i-1][j-1]);
			else
				dp[i][j] = min(min(di, dd), dp[i-1][j-1]+1);
		}
	}

	return dp[n][m];
}

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

	string x, y;

	cin >> x>> y;
	cout << lcs(x, y) << endl;

	return 0;
}

Measured memory_bytes: 7104
n, m = map(int, input().split())
a = list(map(int,input().split()))
a = sorted(a, reverse=True)
count = 1

for i in range(m):
    if a[i] >= sum(a)/(4*m):
        count = count * 1
    else:
        count = count * 0
if count == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
from collections import defaultdict

n = int(input())
s = []
for i in range(n):
    s.append(list(str(input())))

alphabet = set(s[0])

for i in range(1, n):
    alphabet = alphabet & set(s[i])

count_min = defaultdict(lambda: 10**9)
for a in sorted(alphabet):
    for i in range(n):
        count_min[a] = min(count_min[a], s[i].count(a))

ans = ""

for k, v in sorted(count_min.items()):
    for i in range(v):
        ans += k
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B, C; cin >> A >> B >> C;
  if (A+B>=C) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;



int main(){
    int64_t n ;
    cin >> n ;
    vector<pair<int,int> > prime(0,pair<int,int>()) ;
    int64_t icopy = n ;
        for (size_t j = 2; j < sqrt(n)+1; j++)
        {
            while(1){            
                if (n % j == 0)
                {
                    prime.push_back(make_pair(j,1)) ;
                    n /= j ;
                    while (n % j == 0)
                    {
                        prime.at(prime.size()-1).second ++ ;
                        n /= j ;
                    }
                    
                }else
                {
                    break ;
                }
                
                if (icopy == 1)
                {
                    break ;
                }
                
            }
            
        }
        
    int ans = (n > 2) ;
    for (size_t i = 0; i < prime.size(); i++)
    {
        int j = 1 ;
        while (prime.at(i).second >= j)
        {
            ans ++ ;
            prime.at(i).second -= j ;
            j ++ ;
        }
         
    }
    cout << ans << endl ;
}

Measured memory_bytes: 3724
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)

table = {}
cmemo = {}

$memo = {}

def fact(n)
  return $memo[n] if $memo[n] != nil
  result = if (n <= 1) then 1 else fact(n - 1) * n end
  $memo[n] = result
  $memo[n]
end

def c(n,k)
  return 0 if n < k
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

# def c(n, r)
#   return 0 if n < r
#   (fact(n) / (fact(r) * fact(n - r))).to_i
# end

A.each do |a|
  table[a] = 0 if table[a] == nil
  table[a] += 1
end

total = 0
table.each do |k, v|
  total += c(v, 2)
end

A.each do |a|
  result = total
  result -= c(table[a], 2)
  result += c(table[a]-1, 2)
  puts result
end

Measured memory_bytes: 30860
#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; cin >> S;
  int A, B, C, D;
  vector<char> op(3);
  vector<int> a(4);
  int sum;
  
  rep(i,4){
    a[i] = S[i] - '0';
  }
  
  for(int bit =0; bit <(1 << 3); bit++){
    sum = a[0];
    
    rep(i,3){
      if(bit &(1 << i)){
        sum += a[i+1];
        op[i] = '+';
      }
      else{
        sum -= a[i+1];
        op[i] = '-';
      }
    }
    if(sum == 7){
      break;
    }
  }
  cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
}
    
  


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let x: u64 = sc.read();
    let mut cur = 100;
    for i in 1.. {
        cur += cur / 100;
        if cur >= x {
            println!("{}", i);
            return;
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int> > v;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}
	sort(v.rbegin(), v.rend());

	int total = v[0].second+1;
	for (int i = 1; i < N; i++) {
		total += min(v[i - 1].first - v[i].first, v[i].second - v[i-1].second);
	}
	if (v[(int)v.size() - 1].first != 1) {
		total += v[(int)v.size() - 1].first - 1;
	}
	cout << total << endl;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  vector<int> ans(4);
  double dense = 0;
  for(int i = 0; i < 31;i++){
    for(int j = 0; j < 31; j++){
      int water = 100*A*i+100*B*j;
      if(water>F) continue;
      for(int c = 0; water+c*C<=F;c++){
        for(int d = 0; water+c*C+d*D<=F;d++){
          if((A*i+B*j)*E<C*c+D*d) continue;
          double p = (double)(C*c+D*d)/(A*i+B*j);
          if(chmax(dense,p)) {
            ans[0]=i;
            ans[1]=j;
            ans[2]=c;
            ans[3]=d;
          }
        }
      }
    }
  }
  int w = A*ans[0]*100+B*ans[1]*100;
  int sug = C*ans[2]+D*ans[3];
  if(w+sug==0)w=A*100;
  cout<<w+sug<<" "<<sug<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*input*/
	int n;
	cin >> n;
	float x[10];
	string u[10];
	for(int i = 0; i < n; i++){
		cin >> x[i] >> u[i];
	}

	/*calc*/
    double ans = 0;
    int sum_jpy = 0;
    float sum_btc = 0.0;
    for(int i = 0; i < n; i++){
   		if(u[i] == "JPY") sum_jpy += x[i];
   		else{
   			sum_btc += x[i];
   		}
    }
    ans = sum_jpy + sum_btc * 380000.0;

    /*output*/
	cout<< ans <<endl;
    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if(c>=a){
        if(c<=b)
            cout << "Yes";
        else
        {
            cout << "No";
        }
    }
    else
    {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 2019;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    ll N = S.size();

    vector<ll> A(N+1, 0);
    ll bai = 1;
    REP(i, N){
        A[i+1] = ((S[i]-'0') * bai + A[i])%2019;
        bai *= 10;
        bai %= 2019;
    }
    //cout << A << endl;

    map<ll, ll> mp;
    REP(i, N+1) mp[A[i]]++;

    ll res = 0;
    for(auto x: mp){
        ll val = x.second;
        res += val * (val-1) / 2;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5152
#include <stdio.h>
#include <stdlib.h>

int main(){
  int A[100];
  int N, i, j, temp, number=0, flag=1;

  scanf("%d", &N);
  if(N < 1 || 100 < N)
    exit(1);

  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
    if(A[i] < 0 || 100 < A[i])
      exit(2);
  }

  while(flag){
    flag = 0;
    i = 0;
    for(j = N - 1; i < j; j--){
      if(A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	flag = 1;
	number++;
      }
    }
    i++;
  }

  for(i = 0; i < N-1; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[i]);
  printf("%d\n", number);

  return 0;
}

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

using namespace std;

int main() {
  int n, m, x;
  
  cin >> n >> m >> x;
  vector< vector <int>> a(n, vector<int> (m));
  vector<int> c(n);
  for(int i = 0; i < n ; i++ ){
    cin >> c[i];
    for(int j = 0; j < m ; j++ ){ cin >> a[i][j]; }
    
  }
  
  int ans = int(1e6 * 2);
  int all = 1 << n;
  
  for(int mask=0; mask < all; mask++ ){
    vector<int> level(m);
    int cost = 0;
    for(int i=0; i < n; i++){
      if((mask>>i) & 1){
        cost += c[i];
        for(int j=0; j < m; j++){
          level[j] += a[i][j];
        }
      }
    }
    bool achieve = true;
    for (int j = 0; j < m; j++){
      if(level[j] < x ){ achieve = false; }
    }
    
    if(achieve){ ans = min(ans, cost); }
  }
  if (ans==int(1e6 * 2)){cout << "-1" << endl;}
  else{cout << ans << endl;}
  
  return 0;
}

Measured memory_bytes: 3644
n = int(input())
lis = []
for i in range(n):
    l = []
    a = int(input())
    for j in range(a):
        x, y = map(int,input().split())
        l.append([x-1,y])
    lis.append(l)
    
ho_maxcnt = 0
for i in range(1, 2**n):
    ho_cnt = bin(i).count("1")
    if ho_cnt <= ho_maxcnt: continue
    is_ok = True
    for j in range(n):
        jhonest = (i >> j) & 1
        if jhonest == 0:
            continue
        for say in lis[j]:
            if ((i >> say[0]) & 1) ^ say[1]:
                # Mujun
                is_ok = False
                break
        if not is_ok:
            break
    if not is_ok:
        continue
    if ho_cnt > ho_maxcnt:
        ho_maxcnt = ho_cnt
print(ho_maxcnt)


Measured memory_bytes: 3064