akhauriyash/Code-Regression huggingface dataset:
N = int(input())
MAX = 10**4
ANS = [0]*(MAX+1)

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      k = x**2+y**2+z**2+x*y+y*z+z*x
      if(k <= MAX):
        ANS[k] += 1

for i in range(1, N+1):
  print(ANS[i])

Measured memory_bytes: 74272
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> d(N);
  for (int i = 0; i < N; ++i) std::cin >> d[i];
  std::sort(d.begin(), d.end());
  std::cout << d[N/2]  - d[N/2 - 1] << std::endl;
}


Measured memory_bytes: 640
#coding:utf-8

import queue



def main():
    a, b, m = map(int, input().split())
    ref = list(map(int, input().split()))
    ren = list(map(int, input().split()))
    minv = min(ref) + min(ren)
    
    for _ in range(m):
        x, y, c = map(int, input().split())
        minv = min(ref[x - 1] + ren[y - 1] - c, minv)
        
    print(minv)
    
    
if __name__ == '__main__':
    main()

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

int main(void)
{
    int A, B;
    cin >> A >> B;

    int sum = A * B;
    if (sum % 2 == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  int n;
  string s;
  cin >> n >> s;
  ll r = 0, b = 0, g = 0;
  rep(i,n) {
    if (s[i]=='R') r++;
    if (s[i]=='G') g++;
    if (s[i]=='B') b++;
  }

  ll ans = r * g * b;
  for (int j = 1; j < n; ++j) {
    for (int i = 0; i < j; ++i) {
      int k = 2 * j - i;
      if (k < n) {
        ans -= s[i] != s[j] and s[j] != s[k] and s[k] != s[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS=1e-10;
const ll INF=1000000000;
int main(){
    int e;
    while(cin>>e,e){
        int ans=INF;
        for(int z=0;z*z*z<=e;z++){
            for(int y=0;y*y<=e;y++){
                int x=e-(z*z*z)-(y*y);
                if(x<0){
                    continue;
                }
                ans=min(x+y+z,ans);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
import heapq
import sys

N, M = map(int, input().split())
tmp = [[] for _ in range(M + 1)]
for i in range(N):
    a, b = map(int, input().split())
    if M >= a:
        tmp[M - a].append(b)
ans = []
for i in range(M + 1):
    for j in tmp[i]:
        heapq.heappush(ans, j)
        if len(ans) > i + 1:
            heapq.heappop(ans)

print(sum(ans))

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

int main() {
	long long N;
	long long lp;
	cin >> N;
	cin >> lp;
	for (int i = 1; i < 5; ++i) {
		long long d;
		cin >> d;
		lp = min(lp, d);
	}
	cout << (N + lp - 1) / lp + 4 << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

// mod
int mod = 998244353;

struct mint {
    unsigned x;

    mint() : x(0) {}

    mint(signed sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    mint(signed long long sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    int get() const { return (int) x; }

    mint& operator+=(mint that) {
        if ((x += that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(mint that) {
        if ((x += mod - that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(mint that) {
        x = (unsigned long long) x * that.x % mod;
        return *this;
    }

    mint& operator/=(mint that) { return *this *= that.inverse(); }

    mint operator+(mint that) const { return mint(*this) += that; }

    mint operator-(mint that) const { return mint(*this) -= that; }

    mint operator*(mint that) const { return mint(*this) *= that; }

    mint operator/(mint that) const { return mint(*this) /= that; }

    mint inverse() const {
        long long a = x, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        return mint(u);
    }

    bool operator==(mint that) const { return x == that.x; }

    bool operator!=(mint that) const { return x != that.x; }

    mint operator-() const {
        mint t;
        t.x = x == 0 ? 0 : mod - x;
        return t;
    }
};
class FKnapsackForAllSubsets {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, S;
        cin >> N >> S;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        vector<vector<mint>> dp(N+1, vector<mint>(S + 3005));
        dp[0][0] = 1;
        REP(i, N) {
            REP(j, S+1) {
                // Tに入らない、Uに入らないとき
                dp[i+1][j] += dp[i][j] * 2;
                // Uに入るとき
                dp[i+1][j+A[i]] += dp[i][j];
            }
        }
        cout << dp[N][S].get() << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FKnapsackForAllSubsets solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 73648
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;
ll gcd(ll a, ll b) {
    if ( b == 0 ) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b ) {
    return a*(b/gcd(a,b));
}

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

  if ( S[0] != T[0] ) {
    cout << -1 << endl;
    return 0;
  }

  ll L = lcm(N,M);

  vector<ll>A(N-1),B(M-1);

  for ( int i = 0; i < N-1; i++ ) {
    A[i] = L/N*(i+1);
  }
  for ( int i = 0; i < M-1; i++ ) {
    B[i] = L/M*(i+1);
  }
  /*
  for ( int i = 0; i < N-1; i++ ) {
    cout << A[i] << " ";
  }
  cout << endl;

  for ( int i = 0; i < M-1; i++ ) {
    cout << B[i] << " ";
  }
  cout << endl;  
  */
  bool f = true;
  for ( int i = 0; i < N-1; i++ ) {
    if( binary_search(B.begin(),B.end(),A[i]) ) {
      auto tmp = lower_bound(B.begin(),B.end(),A[i])-B.begin();
      if ( S[i+1] != T[tmp+1] ) {
	f = false;
	break;
      }
    }
  }

  if (f) cout << L << endl;
  else cout << -1 << endl;
  return 0;
}


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

using std::cout;
using std::cin;
using std::endl;
using std::vector;

vector<int> make_table(vector<int> v) {
    vector<int> dp(1000000, 0);
    dp[1] = 1;
    int j;
    int min;
    for (int i = 2; i < dp.size(); i++) {
        //std::cout << "HERE" << std::endl;
        //std::cout << "I = " << i << std::endl;
        j = 0;
        min = 1e09;
        //std::cout << i << ", " << v[j] << ", " << dp[v[j]] << endl;
        while (i >= v[j]) {
            if (min > dp[i - v[j]]) {
                min = dp[i - v[j]];
            }
            j++; 
        }
        dp[i] = min + 1;
        //std::cout << "DP" << i << " = " << dp[i] << std::endl;
        //std::cout << "-------------------------=" << endl;
    }
    return dp; 
}

int main(void) {
    vector<int> all;
    vector<int> odd;

    int tetra = 0;
    int times = 1;
    while (1) {
        tetra = times * (times + 1) * (times + 2) / 6;
        all.push_back(tetra);
        if (tetra % 2 == 1) {
            odd.push_back(tetra);
        }
        times++;
        if (tetra > 1000000) {
            break;
        }
    }
    vector<int> dp_all = make_table(all);
    vector<int> dp_odd = make_table(odd);
    int input;
    while (1) {
        cin >> input;
        if (input == 0) {
            break;
        }
        cout << dp_all[input] << " " << dp_odd[input] << endl;
    }

    return 0;
}

Measured memory_bytes: 10620
a = int(input())#¥500
b = int(input())#¥100
c = int(input())#¥50
x = int(input())#price
#print(a,b,c,x)
cnt = 0
for i in range(c+1):
    for j in range(b+1):
        for k in range(a+1):
            if x == 50*i+100*j+500*k:
                cnt +=1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 100000000000009;
ll i;

int main(){
    ll N,M;
    cin>>N>>M;
    V a(M);
    rep(i,0,M)cin>>a.at(i);
    V ans(N+1,INF);
    ans.at(0)=1;
    rep(i,0,M)ans.at(a.at(i))=0;
    rep(i,1,N+1){
        if(ans.at(i)==INF){
            if(i==1){
                ans.at(i)=ans.at(i-1);
            }
            else ans.at(i)=(ans.at(i-1)+ans.at(i-2))%mod;
        }
    }
    cout<<ans.at(N)<<endl;
}



Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int[] a=new int[n];
			for(int i=0; i<n; i++) {
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			String s="";
			int num1=100000010,num2=100000010, num3=100000010;
			for(int i=0; i<4; i++) {
				for(int j=0; j<4; j++) {
					if(i==j) continue;
					s=String.valueOf(a[i])+String.valueOf(a[j]);
					int k=Integer.parseInt(s);
					if(num1>k) {
						num3=num2;
						num2=num1;
						num1=k;
					}else if(num2>k) {
						num3=num2;
						num2=k;
					}else if(num3>k){
						num3=k;
					}
				}
			}
			System.out.println(num3);

		}
	}
}


Measured memory_bytes: 39476
#include<stdio.h>
#include<string.h>
int main(){
  int h=0,i,j;
  int w[100],s[17],t=0,n,tmin;
  memset(s,0,sizeof(s));
  do{
    do{
      for(i=0;i<17;){
	for(;i<17&&s[i];i++);
	for(j=i;j<17&&s[j]==0;j++);
	if(j-i>=(h%5==1?5:2)){
	  for(j=0;j<(h%5==1?5:2);j++)
	    s[i+j]=h%2*17+h%3*3+19;
	  w[h]=t-h*5;
	  h++;
	  if(t<h*5){
	    for(j=0;j<17;j++)
	      s[j]=s[j]>5-t%5?s[j]-5+t%5:0;
	    t+=5-t%5;
	  }
	  break;
	}
	i=j;
      }
      if(h==100)
	break;
    }while(i!=17);
    tmin=42;
    for(j=0;j<17;j++){
      if(s[j]&&s[j]<tmin)
	tmin=s[j];
    }
    for(j=0;j<17;j++)
      s[j]=s[j]>tmin?s[j]-tmin:0;
    t+=tmin;
  }while(h<100);
  while(scanf("%d",&n)!=-1)
    printf("%d\n",w[n]);
  return 0;
}

Measured memory_bytes: 0
def gcd(a, b):
    tmp = a % b
    while tmp != 0:
        a, b = b, tmp
        tmp = a % b
    return b

N = int(input())
A = list(map(int, input().split()))

L = [0 for _ in range(N)]
R = [0 for _ in range(N)]

L[0], R[N - 1] = A[0], A[N - 1]

for i in range(N-1): # i=0,1,...N-2
    L[i + 1] = gcd(L[i], A[i + 1])
    R[N - i - 2] = gcd(R[N - i - 1], A[N - i - 2])

print(max(L[N-2], R[1], *(gcd(L[i], R[i+2]) for i in range(N-2))))

Measured memory_bytes: 14488
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    ans = input()
    if ans == 'AC':
        AC += 1
    elif ans == 'WA':
        WA += 1
    elif ans == 'TLE':
        TLE += 1
    elif ans == 'RE':
        RE += 1
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	long long A, B, K;
	cin >> A >> B >> K;
	if (A > K) A -= K;
	else if (A == K) A = 0;
	else {
		if (B < K - A) B = 0;
		else B -= K - A;
		A = 0;
	}
	cout << A << " " << B << endl;
	return 0;
}

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

int main()
{
    int N,ans=0;
    ll D,X,Y,D2,X2,Y2;
    cin>>N>>D;

    D2 = D*D;

    for(int i=1;i<=N;i++){
        cin>>X>>Y;
        X2=X*X;
        Y2=Y*Y;

        if(D2>=(X2+Y2)){
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
#define MAX 10000000

int S[MAX], T[MAX];
int n;

int  linearSearch(int key){
    int i;
  for(i = 0; i < n; i++){
      if(key == S[i]){
          return key;
      }
  }
  return -1;
}

int main(void){
  int i, q, a;
  int count = 0;

  scanf("%d\n", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d\n", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }

  for (i = 0; i < q; i++) {
    a = linearSearch(T[i]);
    if(a >= 0){
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        switch (in.nextLine()){
            case "SUN":
                System.out.println(7);
                break;
            case "MON":
                System.out.println(6);
                break;
            case "TUE":
                System.out.println(5);
                break;
            case "WED":
                System.out.println(4);
                break;
            case "THU":
                System.out.println(3);
                break;
            case "FRI":
                System.out.println(2);
                break;
            case "SAT":
                System.out.println(1);
                break;
        }
    }
}

Measured memory_bytes: 21844
n=int(input())
import heapq
q=[]

for i in range(n):
    x,l=map(int,input().split())
    heapq.heappush(q,(x+l,l))

largest=-float('inf')
c=0
while q:
    a,l=heapq.heappop(q)
    if largest<=a-2*l:
        largest=a
        c+=1
print(c)

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

int n;
void input();
vector<ll>vec;
void solve(){
    vector<ll>ans;
    ll a;
    for(int i=0;i<n;i++){
        if(i==0){
            a=vec[i];
            continue;
        }
        a^=vec[i];
    }
    for(int i=0;i<n;i++){
        cout<<(a^vec[i]);
        if(i!=n-1)cout<<" ";
    }
    cout<<"\n";
}

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

    input();solve();
}

void input(){
    cin>>n;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        vec.push_back(a);
    }
}


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

using namespace std;

int main(){
  int r, c, n;
  cin >> r >> c;
  vector<vector<int> > vec(101, vector<int>(101));
  
  int sumall = 0;
  for(int i = 0; i < r+1; i++){  
    int sumr = 0;
    for(int j = 0; j < c+1; j++){
      int sumc = 0;
      if(i == r){
        for(int k = 0; k < r; k++){
          sumc += vec.at(k).at(j);
        }
        vec.at(i).at(j) = sumc;
        cout << vec.at(i).at(j);
        if(j != c){
          cout << " ";
        }
      }else if(j == c) {
        vec.at(i).at(j) = sumr;
        sumall += sumr;
        cout << vec.at(i).at(j) << endl;
      } else {
        cin >> n;
        vec.at(i).at(j) = n;
        sumr += n;
        cout << vec.at(i).at(j);
        if(j != c){
          cout << " ";
        }
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6+7;
const int maxm = 2e6+7;
const ll mod = 998244353 ;
int n,m,ar[maxn];


int main()
{
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    int sum = a+b+c;
    printf("%d\n", sum - max(a, max(b,c)));




    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Array.IArray


main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- replicateM n $ do
    (a:_:ns) <- getInts
    return $ zip (zip (repeat a) ns) (repeat 1)
  mapM_ putStrLn $
    format $ solve n $ concat ns

getInts :: IO [Int]
getInts = map read . words <$> getLine

format :: Array (Int, Int) Int -> [String]
format arr = let ((_, _), (n, _)) = bounds arr in
               do
                 i <- [1..n]
                 let ns =
                       do
                         j <- [1..n]
                         return $ arr ! (i, j)
                 return $
                   unwords (map show ns)
                 
solve :: Int -> [((Int, Int), Int)] -> Array (Int, Int) Int
solve n ns = accumArray f 0 ((1, 1), (n, n)) ns
  where
    f :: Int -> Int -> Int
    f _ _ = 1

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

class abc123_B
{
    static void Main(string[] args)
    {
        var meals = Enumerable.Range(0, 5).Select(x => int.Parse(Console.ReadLine())).ToList();

        var mealsMinLastDigit = meals.OrderBy(m => (m-1)%10).First(); // -1 because 0 is top
        meals.Remove(mealsMinLastDigit);
        var mealsAligned = meals.Select(m => m%10==0 ? m : m/10*10+10).ToList();
        Console.WriteLine(mealsAligned.Sum() + mealsMinLastDigit);
        
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;
int n;
vector<int> g[N];
int dp[N];

void dfs(int v)
{
    vector<int> a;
    dp[v] = (int)g[v].size();
    for (int u : g[v])
    {
        dfs(u);
        a.push_back(dp[u]);
    }
    sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
    for (int i = a.size()-1; i >=0; i--)
        dp[v] = max(dp[v], a[i] + 1+ i);
    return;
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        int v;
        scanf("%d", &v);
        v--;
        g[v].push_back(i);
    }
    dfs(0);
    printf("%d\n", dp[0]);

    return 0;
}


Measured memory_bytes: 13952
#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 all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define abs(a) llabs(a)
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   long long n, a, b;
   cin >> n >> a >> b;

   if (abs(a - b) % 2 == 0)
      cout << abs(a - b) / 2 << '\n';
   else
   {
      long long x, y, z, w;
      x = a - 1;
      y = b - 1;
      z = n - a;
      w = n - b;
      if (max(x, y) <= max(z, w))
      {
         long long p = abs(x - y) / 2;
         cout << max(x, y) - p << '\n';
      }
      else
      {
         long long q = abs(z - w) / 2;
         cout << max(z, w) - q << '\n';
      }
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    while(true){
        // N, M, P ?????\???
        int n, m, p;
        cin >> n >> m >> p;

        // 0 0 0 ????????????
        if(n == 0 && m == 0 && p == 0)
            return 0;

        //x ?????\???
        vector<int> x(n);
        for(auto &a:x)
            cin >> a;

        // ????????????????????????
        if(x[m - 1] == 0){
            cout << 0 << endl;
            continue;
        }

        //????¨??????????
        int sum = accumulate(x.begin(), x.end(), 0) * 100;
        //?????????????????????
        double total = sum * (100 - p) / 100;
        //????????????
        int money = total / x[m - 1];

        cout << money << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;



ll A,B,ans;



int main() {


	cin >> A >> B;
	if (A > B) {
		cout << 2 * A - 1 << endl;
	}
	else if (B > A) {
		cout << 2 * B - 1 << endl;
	}
	else cout << 2 * A << endl;



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c,d,i=1;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1)
    {
        if(i%2==1){
            c=c-b;
                if(c<=0)
                    break;
        }
        else{
            a=a-d;
            if(a<=0)
                break;
        }
            i++;
    }
    if(a<=0)
        printf("No");
    else
        printf("Yes");
}


Measured memory_bytes: 1732
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll prime[1000001];
ll length = 0;
void insert(ll p) { prime[length] = p; length++; return; }
int main(){
	insert(2);
	for (ll i = 3; i < 1000000; i += 2) {
		for (ll j = 0; j < length; j++)
			if (i%prime[j] == 0)goto cont;
			else if (prime[j] > sqrt(i))break;
		insert(i);
	cont:;
	}
	ll n; while (cin >> n) {
		ll ans = 0;
		while (prime[ans] <= n&&ans < length) {
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
	"math"
)

var N, K int

func main() {
	fmt.Scan(&N, &K)
	var ans int = 1

	for i := 0; i < N; i++ {
		if ans+K < 2*ans {
			ans += K
		} else {
			ans *= 2
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 512
k = int(input())
k=k-1
num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num[k])

Measured memory_bytes: 3060
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    c = [input() for j in range(H)]
    st = [(h, w) for h in range(H) for w in range(W)]  # H*W個

    def bfs(sy, sx):
        que = deque()
        dist[sy][sx] = 0
        que.append((sy, sx))
        d = ((1, 0), (0, 1), (-1, 0), (0, -1))
        while que:
            uy, ux = que.popleft()
            for dy, dx in d:
                next_y = uy + dy
                next_x = ux + dx
                if not(0 <= next_y < H and 0 <= next_x < W):
                    continue
                if dist[next_y][next_x] != -1:
                    continue
                if c[next_y][next_x] == '#':
                    continue
                dist[next_y][next_x] = dist[uy][ux] + 1
                que.append((next_y, next_x))

    ans = 0
    for s in st:
        dist = [[-1]*W for h in range(H)]
        if c[s[0]][s[1]] == "#":
            continue
        bfs(s[0], s[1])
        for t in st:
            if s == t or c[t[0]][t[1]] == "#":
                continue
            ans = max(ans, dist[t[0]][t[1]])
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	string word;
	stack <int> S;
	int i,j;
	while (cin >> word){
		if (word == "+"){
			i = S.top();
			S.pop();
			j = S.top();
			S.pop();
			S.push(i + j);
		
		}
			
		else if (word == "-"){
			i = S.top();
			S.pop();
			j = S.top();
			S.pop();
			S.push(j - i);
		
		}
			
		else if (word == "*"){
			i = S.top();
			S.pop();
			j = S.top();
			S.pop();
			S.push(i * j);
		
		}
		else{
			int k = atoi(word.c_str());
			S.push(k);
		}
	}
	cout << S.top() << endl;
}		

Measured memory_bytes: 1200
var n,m,k,a,i,j,ans  :integer;
    s:array[1..30]of integer;
begin
  readln(n,m);
  for i:=1 to 30 do s[i]:=0;
  for i:=1 to n do begin
    read(k);
    for j:=1 to k do begin
      read(a);
      s[a]:=s[a]+1
    end;
    readln
  end;
  for i:=1 to m do if s[i]=n then ans +=1;
  write(ans)
  end.


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

int main() {
  int A , B , c;
  c=0;
  cin>>A>>B;
  for(int i=A ; i<=B ; i++){
    int d,e,f,g,h;
    d=i%10;
    e=(i-d)%100/10;
    f=(i-e*10-d)%1000/100;
    g=(i-f*100-e*10-d)%10000/1000;
    h=(i-g*1000-f*100-e*10-d)/10000;
    if(d==h && e==g){
      c++;
    }
  }
  cout<< c <<endl;
}
  

Measured memory_bytes: 3624
#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() {
    int X;
    cin >> X;

    int ans = 1;
    if (X == 1)
    {
        cout << ans << endl;
        return 0;
    }
    
    for (int i = 2; i * i<= X; i++)
    {
        int count = 0;
        int temp = X;
        while (temp / i > 0)
        {
            count++;
            temp /= i;
        }
        cerr << "i=" << i << " count=" << count << endl;
        ans = max(ans, (int)pow(i, count));
        
    }
    
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
	int R[MAX], i, n;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&R[i]);
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1; i<n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	printf("%d\n",maxv);
	
	return 0;
}


Measured memory_bytes: 2640
k=input().split()
k1=[int(i) for i in k]
if(abs(k1[0]-k1[2])<=k1[3]):
	print("Yes")
elif(abs(k1[0]-k1[1])<=k1[3] and abs(k1[1]-k1[2])<=k1[3]):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
n = gets.chomp.to_i
rod = gets.chomp.split(" ")
rod.map!(&:to_i)
rod.sort!{|a, b| (-1) * (a <=> b)}
pattern = []

for i in 0..rod.size-1 do
  if rod[i] == rod[i+1]
    pattern.push(rod[i])
    rod[i] = -1
    rod[i+1] = -1
  end
end

if pattern.size < 2
  puts "0"
else
  puts pattern[0] * pattern[1]
end


Measured memory_bytes: 9728
from collections import deque


dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]


H, W = map(int, input().split())
G = [input() for _ in range(H)]


# 色を変える前のマップ上の白色マスを数える
def count_white():
    res = 0
    for i in range(H):
        for j in range(W):
            if G[i][j] == '.':
                res += 1
    return res


# 色を変えずにスタートからゴールまでの最短歩数を数える
def minimum_step():
    dist = [[0] * W for _ in range(H)]
    dist[0][0] = 1
    que = deque([[0, 0]])

    # BFS
    while que:
        h, w = que.popleft()
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            if G[nh][nw] == '#':
                continue
            if dist[nh][nw]:
                continue
            dist[nh][nw] = dist[h][w] + 1
            que.append([nh, nw])
    return dist[H - 1][W - 1]


def main():
    step = minimum_step()
    print(count_white() - step if step else -1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 73872
open Batteries
(* 目的：入力を数値に置き換える *)
let gn = read_int()
let vlist = List.map int_of_string (String.split_on_char ' ' (read_line()))
let clist = List.map int_of_string (String.split_on_char ' ' (read_line()))

(* 計算するための関数 *)
let calc lst1 lst2 =
  (* 二つのリスト lst1 と lst2 から i番目の要素同士の組のリストを作る *)
  let rec hojo1 lst1 lst2 i =
    if i < gn then ((List.nth lst1 i), (List.nth lst2 i)) :: hojo1 lst1 lst2 (i + 1)
    else [] in
  (* リスト lst の要素に組の要素の和が0より大きいものだけを残す *)
  let hojo2 lst = List.filter (fun (v, c) -> (v - c) > 0) lst in
  (* リスト lst の要素の組の要素の差を取る *)
  let hojo3 lst = List.map (fun (v, c) -> v - c) lst in
  (* リスト lst の要素の合計を計算する *)
  let hojo4 lst = List.fold_right (+) lst 0 in
  hojo4 (hojo3 (hojo2 (hojo1 lst1 lst2 0)))

(* 答え *)
let answer = string_of_int (calc vlist clist)
let () = print_endline answer

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n;
	cin >> n;
	for(int h = 1;h <= 3500;h++){
		for(int w = 1;w <= 3500;w++){
			int si = 4 * h * w - n * (w + h),bo = h * w * n;
			if(si >= 1 && bo % si == 0){
				cout << h << " " << w << " " << bo / si << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    int n,m;

    cin >> n >> m;

    if(abs(n-m)>1){ cout << "0"; return 0; }

    long long a = 1;

    for(int i = 1;i <= n;i++)
        a = (a*i)%1000000007;

    for(int i = 1;i <= m;i++)
        a = (a*i)%1000000007;

    if(n-m==0) cout << (a*2)%1000000007;
    else cout << a;
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

map < int , int > cnt;
int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);


    int n;
    cin >> n;
    vector < int > v(n);
    f0(i,n){
        cin >> v[i];
        cnt[v[i]]++;
    }

    if(n&1){
        if(cnt[0]!=1){
            cout << "0" << endl;
            return 0;
        }else {
            for(int i=2; i<n ; i+=2){
                if(cnt[i]!=2){
                    cout << "0" << endl;
                    return 0;
                }
            }
            ll ans = 1LL;
        for(int i=1 ; i<=n/2 ; i++){
            ans = ((ans % MOD)*2)%MOD;
        }
        cout << ans << endl;
        }
    }else {
        for(int i=1; i<n ; i+=2){
                if(cnt[i]!=2){
                    cout << "0" << endl;
                    return 0;
                }
            }

        ll ans = 1LL;
        for(int i=1 ; i<=n/2 ; i++){
            ans = ((ans % MOD)*2)%MOD;
        }
        cout << ans << endl;
    }


    return 0;
}


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

ll l1[51][51];
ll dir[8][2]={{1,0},{0,1},{0,-1},{-1,0},{-1,1},{-1,-1},{1,-1},{1,1}};
map<ll,ll>di;


int main()
{
    ll n,k,m,a,b,s=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        s+=min(s,k);
    }
    cout<<s;
}


Measured memory_bytes: 256
#include <iostream>
#define NMAX 100
#define MMAX 50
using namespace std;
int px, py;

void rotate(int pic[MMAX][MMAX], int m){
  int tmp[MMAX][MMAX];
  for (int i=0;i<m;i++)
    for (int j=0;j<m;j++)
      tmp[i][j] = pic[m-j-1][i];
  for (int i=0;i<m;i++)
    for (int j=0;j<m;j++)
      pic[i][j] = tmp[i][j];
}

void searchPoints(int p[MMAX][MMAX], int w[NMAX][NMAX], int n, int m){
  int space = 0;
  for (int i=0;i<m;i++){
    if (p[0][i] == -1)
      space++;
    else
      break;
  }
  for (int i=0;i<=n-m;i++){
    for (int j=0;j<=n-m;j++){
      bool flag = true;
      for (int k=0;k<m;k++){
        for (int l=0;l<m;l++){
          if (p[k][l] == -1) continue;
          if (p[k][l] != w[i+k][l+j]) flag = false;
        }
      }
      if (flag){
        if ((i < py) || ((i==py) && (j+space < px))){
          px = j + space;
          py = i;
        }
      }
    }
  }
}


int main(){
  int n, m;
  while (cin >> n >> m && (!(n ==0 && m==0))){
    int pic[MMAX][MMAX];
    int window[NMAX][NMAX];
    px = 1000;
    py = 1000;
    for (int i=0;i<n;i++)
      for (int j=0;j<n;j++)
        cin >> window[i][j];
    for (int i=0;i<m;i++)
      for (int j=0;j<m;j++)
        cin >> pic[i][j];
    for (int i=0;i<4;i++){
      searchPoints(pic, window, n, m);
      rotate(pic, m);
    }
    if (px == 1000 && py == 1000)
      cout << "NA" << endl;
    else
      cout << px+1 << ' ' << py+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
from collections import defaultdict
from itertools import accumulate


def solve():
    N, K, *A = map(int, open(0).read().split())
    
    Acumsum = [0] + list(accumulate(A))
    si = [(Acumsum[i] - i) % K for i in range(N + 1)]
    counter = defaultdict(int)
    
    ans = 0
    for j in range(N):
        counter[si[j]] += 1
        if 0 <= j - K + 1:
            counter[si[j - K + 1]] -= 1
        ans += counter[si[j + 1]]
    print(ans)


if __name__ == '__main__':
    solve()


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string s){
    int rcnt = count(s.begin(), s.end(), 'R');
    int bcnt = count(s.begin(), s.end(), 'B');
    if(rcnt > bcnt) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string s;
    std::cin >> s;
    solve(N, s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>



int main() {
	constexpr long long int mod = 1000000007LL;
	int n, m; std::cin >> n >> m;
	if (std::max(n, m) > std::min(n, m) + 1) {
		std::cout << 0 << std::endl;
	}
	else {
		std::vector<long long int> factorial(std::max(n, m) + 1, 1LL);
		for (auto i = 2; i < factorial.size(); ++i) {
			factorial[i] = i * factorial[i - 1] % mod;
		}
		if (n == m) {
			std::cout << factorial[n] * factorial[m] % mod * 2 % mod << std::endl;
		}
		else {
			std::cout << factorial[n] * factorial[m] % mod << std::endl;
		}
	}
}

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

int main()
{
	int num1, num2;

	cin >> num1;

	cin >> num2;

	if (num1 < num2) {
		cout << "a < b" << endl;
	}
	else if (num1 > num2) {
		cout << "a > b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}

	return 0;
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

vector<double> cap(200000,0);

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

    int n;
    while(cin>>n,n){
        double l;cin>>l;
        double low=0,high=2000000;
        vector<double> v(200000,0);
        for(int i=0;i<n;i++){
            int st,gt;cin>>st>>gt;
            double u;cin>>u;
            for(int j=st+1;j<=gt;j++){
                v[j]=v[j+86400]=u;
            }
        }
        for(int k=0;k<100;k++){
                cap[0]=l;
                double mid=(low+high)/2;
                bool f=true;
                for(int i=1;i<=86400*2;i++){
                    cap[i]=min(l,cap[i-1]+(mid-v[i]));
                    if(cap[i]<0) f=false;
                }
                if(cap[86400]<=cap[86400*2] && f){
                    high=mid;
                }
                else{
                    low=mid;
                }
            }
        cout<<fixed<<setprecision(10)<<low<<endl;
    }
}


Measured memory_bytes: 6024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str=br.readLine();
        while(true){
            try{
                StringTokenizer st=new StringTokenizer(str," ");
                int sum=Integer.parseInt(st.nextToken())+Integer.parseInt(st.nextToken());
                System.out.println(String.valueOf(sum).length());
                str=br.readLine();
            }catch(Exception e){System.exit(0);}
        }
    }
    
}

Measured memory_bytes: 24100
s = gets.chomp
t = ["dream", "dreamer", "erase", "eraser"]
ans = "YES"
while !s.empty? do
  s_tmp_length = s.length
  t.map do |str|
    s.slice!(s.length - str.length, str.length) if s.end_with?(str)
  end
  if s_tmp_length == s.length then
    ans = "NO"
    break
  end
end
puts ans

Measured memory_bytes: 2044
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define clt(x) 63-__builtin_clzll(x)
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector<pair<ll,ll>>
#define maxq priority_queue<ll>
#define minq priority_queue<ll,vector<ll>, greater<ll>>
#define cont continue;
#define reto return 0;
#define sz size()
#define spmod 1116295198451
#define mod 1000000007
#define md 998244353 
#define N 2e5+10
//typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //pbds;
ll a[109];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n;
  cin>>n;
  ll i=0,j,k,ans=0;
  while(i<n)
    cin>>a[i++];
  sort(a,a+n);
  i=0;
  while(i<n)
  {
    j=i+1;
    while(j<n&&a[j]==a[j-1])
      j++;
    while(j<n)
    {
      k=j+1;
      while(k<n&&a[k]==a[k-1])
        k++;
      while(k<n)
      {
        if(a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[i]+a[k]>a[j])
          ans++;
        k++;
      }
      j++;
    }
    i++;
  }
  deb(ans)
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n,m; cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i,m) cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b));
	rep(i,n){
		int count = 0;
		rep(j,m){
			if (a[j] == i+1){
				count++;
			}
			if (b[j] == i+1){
				count++;
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 256
import math
def solve(numbers):
    min, max, sum=numbers[0],numbers[0],0
    
    for number in numbers:
        if min > number:
            min = number
        if max < number:
            max = number
        sum+=number
    print('{0} {1} {2}'.format(min,max,sum))
        
    
def answer():
    case = int(input())

    
    numbers = list(map(int,input().split()))
    solve(numbers)


if __name__ =='__main__':
    answer()


Measured memory_bytes: 6576
given = ["dreamer", "dream", "eraser", "erase"]
S = input()
while len(S) > 0:
    judge = [S.endswith(i) for i in given]
    if any(judge):
        target = given[judge.index(True)]
        S = S[:-len(target)]
        if len(S) == 0:
            print("YES")
            break
    else:
        print("NO")
        break


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

vector<vector<int>> A;
vector<int> visited;

void dfs(int s, int id) {
    stack<int> S;
    S.push(s);
    visited[s] = id;

    while (!S.empty()) {
        auto j = S.top();
        S.pop();

        auto& v = A[j];
        for (auto it = v.begin(); it != v.end(); ++it) {
            auto i = *it;
            if (visited[i] == -1) {
                visited[i] = id;
                S.push(i);
            }
        }
    }
}

int main() {
    int n;
    int m;
    cin >> n >> m;
    A.resize(n);
    visited.resize(n, -1);

    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        A[s].push_back(t);
        A[t].push_back(s);
    }
    for (int i = 0; i < A.size(); ++i) {
        if (visited[i] == -1)
            dfs(i, i);
    }

    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;

        if (visited[x] == visited[y]) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }

    return 0;
}

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

int dp[16][10][2][2];
vector<int> v;

int dpsolve(int pos, int cur, int zero, int f) {
    if (pos == (int)v.size()) return 1;
    
    if (dp[pos][cur][zero][f] != -1) return dp[pos][cur][zero][f];

    int res = 0, lim = v[pos];

    if (f == 1) lim = 9;

    for (int dgt = 0; dgt <= lim; dgt++) {
        int nzero = zero, nf = f;

        if (zero == 1 && dgt != 0) nzero = 0;
        if (f == 0 && dgt < lim) nf = 1;

        if (zero == 0) {
            if (abs(dgt - cur) <= 1) res += dpsolve(pos + 1, dgt, nzero, nf);
        }
        else {
            res += dpsolve(pos + 1, dgt, nzero, nf);
        }
    }

    return dp[pos][cur][zero][f] = res;
}

int solve(long long a) {
    v.clear();
    while (a > 0) {
        v.push_back(a % 10);
        a /= 10;
    }

    reverse(v.begin(), v.end());
    memset(dp, -1, sizeof(dp));

    return dpsolve(0, 0, 1, 0) - 1;
}


int main() {
    int k; scanf("%d", &k);
    
    long long lo = 1, hi = 10000000000000000;
    while (lo < hi) {
        long long mid = lo + (hi - lo) / 2;
        
        if (solve(mid) >= k) hi = mid;
        else lo = mid + 1;
    }
    
    printf("%lld", lo);
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
maxh = 0
cnt = 0
for i in range(n):
  if maxh - 2 >= h[i]:
    print("No")
    break
  else:
    maxh = max(maxh,h[i])
    cnt +=1
if cnt == n:
  print("Yes")
  

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

int a[5000];
int c[9];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= 3200) {
      ++cnt;
    } else {
      ++c[a[i] / 400];
    }
  }
  
  int mn = 0;
  int mx = 0;
  for (int i = 0; i < 8; ++i) {
    if (c[i]) {
      ++mn;
      ++mx;
    }
  }
  mx += cnt;
  if (mn == 0) mn = 1;
  cout << mn << ' ' << mx << endl;
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;
public class Main {	
	Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}

	public Main(){		
		while(in.hasNext())new AOJ0043();
	}
	
	boolean debug;
	
	boolean run(int[] num,int target){
		if(target==1)debug=true;
		else debug = false;
		
		//まず2個の数字を取る
		num[target]++;
//		System.out.println(target);
//		print(num);
		for(int i=1;i<10;i++)if(num[i]>=2){
//			if(debug)System.out.println("************"+" two cards dead= "+i);
			int[] num2 = Arrays.copyOf(num, num.length);
			num2[i]-=2;
			if(bfs(num2))return true;
		}
		return false;
	}
	void print(int[] num){
		for(int i=0;i<num.length-1;i++)System.out.print(num[i]+" ");
		System.out.println(num[num.length-1]);
	}
	
	boolean bfs(int num[]){//三枚のトリオを作成していく
//		if(debug)print(num);
		boolean sw = true;
		for(int i=0;i<10;i++)if(num[i]!=0)sw=false;
		if(sw)return true;
		
		//連番
		for(int i=1;i<=7;i++)if(num[i]>0&&num[i+1]>0&&num[i+2]>0){
			num[i]-=1;num[i+1]-=1;num[i+2]-=1;
			if(bfs(num))return true;
			num[i]++;num[i+1]++;num[i+2]++;
		}
		
		//三枚
		for(int i=1;i<10;i++)if(num[i]>=3){
			num[i]-=3;
			if(bfs(num))return true;
			num[i]+=3;
		}
		return false;
	}
	
	class AOJ0043{
		public AOJ0043() {
			String a = in.next();
			int[] input = new int[10];
			for(int i=0;i<13;i++)input[Integer.parseInt(a.charAt(i)+"")]++;
			boolean sw[] = new boolean[10];
			for(int i=1;i<10;i++)if(input[i]!=4){
				int[] num = Arrays.copyOf(input,input.length);
				sw[i]=run(num,i);
			}
			int last=0;
			for(int i=9;i>=0;i--)if(sw[i]){
				last=i;break;
			}
			for(int i=1;i<10;i++)if(sw[i]&&i!=last)System.out.print(i+" ");
			System.out.println(last);
		}
	}
	
}

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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for (auto& e : a) std::cin >> e;

    int M;
    std::cin >> M;
    std::vector<int> b(M);
    for (auto& e : b) std::cin >> e;

    std::vector<int> ans;
    std::set_union(a.begin(), a.end(),
                   b.begin(), b.end(),
                   std::back_inserter(ans));

    for (auto& e : ans) std::cout << e << std::endl;
    return 0;
}


Measured memory_bytes: 6428