akhauriyash/Code-Regression huggingface dataset:
d = int(input())
if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

# n = 25 - int(input())
# print("Christmas" + "Eve" * n)

#かしこい

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int q;
    cin >> q;
    vector< pair<int, int> > p(q);

    for(int i = 0; i < q; i++){
        cin >> p[i].first >> p[i].second;
    } 

    if(x2-x1 == 0){
        for(int i = 0; i < q; i++){
            cout << x1 << " " << p[i].second << endl;
        }
        return 0;
    }

    double cfi, inv_cfi, cst;
    cfi = double(y2-y1)/(x2 - x1);
    //cout << cfi << endl;
    cst = y1 - cfi * x1;
    //cout << cst << endl;
    if(cfi == 0){
        for(int i = 0; i < q; i++){
            cout << p[i].first << " " << y1 << endl;
        }
        return 0;
    }

    inv_cfi = -1/cfi;
    //cout << inv_cfi << endl;

    for(int i = 0; i < q; i++){
        double cst_p, ans_x, ans_y;
        cst_p = p[i].second - inv_cfi * (p[i].first);
        //ans_x = (cst - cst_p) / inv_cfi + cfi*p[i].first/inv_cfi;
        //cout << cst_p << endl;
        ans_x = (cst_p - cst) / (cfi - inv_cfi);
        ans_y = inv_cfi*ans_x + cst_p;
        //cout << "ans_x:" << ans_x << "  ans_y:" << ans_y << endl;
        printf("%.10lf %.10lf\n", ans_x, ans_y);
    }
    
}


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>

using namespace std;

#define _USE_MATH_DEFINES

class Solution {
private:
public:
    bool has7(int num) {
        while (num)
        {
            if(num % 10 == 7) return true;
            num /= 10;
        }
        return false;
    }
};

int main() {
    int num;
    cin >> num;
    Solution sol;
    cout << (sol.has7(num) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
Q,H,S,D=map(int,input().split(' '))
N = int(input())
l1 = min(4*Q,2*H,S)
l2 = min(2*l1,D)
if N==1:
    print(l1)
elif N%2==0:
    print(N//2*l2)
else:
    print(N//2*l2+l1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n+m; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    cout << 180 * (N-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<b)return 0; a=b; return 1;}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    int h,w,k;
    cin>>h>>w>>k;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int ans = 1e9;
    for(int bit=0;bit<(1<<h-1);bit++){
        int cnt = 0;
        bool ng = false;
        vector<int> v;
        v.push_back(0);
        for(int i=0;i<h-1;i++){
            if((1<<i) & bit){
                v.push_back(0);
                cnt++;
            }
        }
        for(int j=0;j<w;j++){
            int now = 0;
            bool pos = 1;
            for(int i=0;i<h;i++){
                if(s[i][j]=='1'){
                    v[now]++;
                    if(v[now] > k){
                        pos = false;
                        break;
                    }
                }
                if((1<<i) & bit) now++;
            }
            if(pos) continue;
            cnt++;
            for(int i=0;i<v.size();i++) v[i] = 0;
            now = 0;
            pos = 1;
            for(int i=0;i<h;i++){
                if(s[i][j]=='1'){
                    v[now]++;
                    if(v[now] > k) pos = false;
                }
                if((1<<i) & bit)now++;
            }
            if(pos == false){
                ng = 1;
                break;
            }
        }
        if(!ng) chmin(ans,cnt);
    }
    cout << ans << endl;
    

    // h=1のとき試してみる
    
}

Measured memory_bytes: 256
n = int(input())
ans = list()
x = 0
for i in range(1, n+1):
    if i % 3 == 0:
        ans.append(' ' + str(i))
    else:
        x = i
        while (x > 0):
            if x % 10 == 3:
                ans.append(' ' + str(i))
                break
            else:
                x //= 10

print(''.join(ans))



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

using namespace std;

int main(void){
  map<int, int> m;
  for(int i = 0; i < 3; i++){
    int A;
    cin >> A;
    m[A]++;
  }
  for(auto itr = m.begin(); itr != m.end(); itr++){
    if(itr -> second == 2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2019年10月06日 星期日 10时52分21秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 3033;
struct Point {
    double x, y;
    Point(double xp=0, double yp=0): x(xp), y(yp) { }
    Point operator + (const Point& rhs) const { 
        return Point(x+rhs.x,y+rhs.y); 
    }
    Point operator - (const Point& rhs) const {
        return Point(x-rhs.x, y-rhs.y);
    }
    Point operator * (double k) const { return Point(x*k, y*k); }
};

const double PI = acos(-1);
Point Exp(double rad) {
    return Point(cos(rad), sin(rad));
}

double a[maxn];

int main() {
    int n;
    double T, L;
    scanf("%d%lf", &n, &L);
    for(int i = 1; i <= n; ++i) {
        scanf("%lf", &T);
        a[i] = 2.0 * PI * T / L;
    }

    Point res;
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j) {
            res = res + Exp((a[i]+a[j])/2.0) * double(n - j);
            res = res + Exp((a[i]+a[j])/2.0) * double(i - 1);
            res = res + Exp((a[i]+a[j])/2.0 + PI) * double(j - i - 1);
        }
    res = res * (6.0 / n / (n-1) / (n-2));
    printf("%.10f %.10f\n", res.x, res.y);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define forn(x, n) for (int x = 0; x < n; x++)
#define forr(x, n) for (int x = n; x >= 0; x--)
#define fore(x, a, b, c) for (int x = a; x <= c; x++)
#define forre(x, a, b, c) for (int x = a; x >= b; x -= c)
#define clr cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container) (container).begin(), (container).end()
#define rall(container) (container).rbegin(), (container).rend()
#define fi first
#define se second

using namespace std;

typedef long long i64; 
typedef vector<i64> vi64;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

int main(void) {
	int n, k, dig; scanf("%d %d", &n, &k);
	int can[10];
	memset(can, 1, sizeof(can));
	forn(i, k) {
		scanf("%d", &dig);
		can[dig] = 0;
	}
	while (1) {
		int temp = n, flag = 0;
		while (temp) {
			int x = temp % 10;
			if (!can[x]) {
				flag = 1; break;
			}
			temp /= 10;
		}
		if (!flag) {
			printf("%d\n", n);
			return 0;
		} else n += 1;
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    cout<<n/3<<newl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 1000; i++)
            {
                var color = Read();
                if (color == "0") break;

                string rhex = color[1].ToString()+color[2].ToString();
                int red = Convert.ToInt32(rhex, 16);

                string ghex = color[3].ToString() + color[4].ToString();
                int green = Convert.ToInt32(ghex, 16);

                string bhex = color[5].ToString() + color[6].ToString();
                int blue = Convert.ToInt32(bhex, 16);

                if (red < 128)
                {
                    if (green < 128)
                    {
                        if (blue < 128)
                        {
                            WriteLine("black");
                        }
                        else
                        {
                            WriteLine("blue");
                        }
                    }
                    else
                    {
                        if (blue < 128)
                        {
                            WriteLine("lime");
                        }
                        else
                        {
                            WriteLine("aqua");
                        }
                    }
                }
                else
                {
                    if (green < 128)
                    {
                        if (blue < 128)
                        {
                            WriteLine("red");
                        }
                        else
                        {
                            WriteLine("fuchsia");
                        }
                    }
                    else
                    {
                        if (blue < 128)
                        {
                            WriteLine("yellow");
                        }
                        else
                        {
                            WriteLine("white");
                        }
                    }
                }
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15828
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n, K; cin >> n >> K;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   V<V<int>> dp(n+1, V<int>(K+1));
   V<V<int>> sum(n+1, V<int>(K+2));
   dp[0][0] = 1;
   for (int k = 0; k <= K; k++) {
      sum[0][k+1] = sum[0][k] + dp[0][k];
   }
   for (int i = 0; i < n; i++) {
      for (int k = 0; k <= K; k++) {
         dp[i+1][k] = (((sum[i][k+1] - sum[i][max(k-a[i], 0LL)]) % MOD) + MOD) % MOD;
         sum[i+1][k+1] = (sum[i+1][k] + dp[i+1][k]) % MOD;
      }
   }
   cout << dp[n][K] << endl;

   return 0;
}


Measured memory_bytes: 159088
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int a = stdIn.nextInt();
	int b = stdIn.nextInt();
	double ave=(a+b)/2.0;
	int ans=(int)Math.ceil(ave);
	System.out.println(ans);
    }
}


Measured memory_bytes: 21204
import sys

f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

Measured memory_bytes: 30684
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
    
    int i, K, rem;
    cin >> K;
    rem = 0;
    
    for (i = 1; i <= K; i++){

        rem = rem * 10 + 7;
        rem = rem % K;
        if (rem == 0) break;
    }
    
    if (rem == 0){
        cout << i << "\n";
    } else {
        cout << "-1" << "\n";
    }

    return 0;
}



Measured memory_bytes: 3628
from itertools import permutations
from math import factorial, hypot

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

ans = 0
for ps in permutations(p,n):
    x1, y1 = ps[0]
    for i in range(n):
        x2,y2 = ps[i]
        ans += hypot(x1-x2, y1-y2)
        x1,y1 = x2,y2
ans /= factorial(n)
print(ans)

Measured memory_bytes: 42604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var magic = Enumerable.Repeat(0, 10).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        var map = Enumerable.Repeat(0, hw[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                for (int k = 0; k < 10; k++)
                    magic[j][k] = Min(magic[j][k], magic[j][i] + magic[i][k]);
        var res = map.Sum(x => x.Sum(y => y == -1 ? 0 : magic[y][1]));
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 15572
#include <stdio.h>

int ice[10];

int main(void)
{
	int n, num;
	int i;
	
	while (1){
		
		scanf("%d", &n);
				
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &num);
			ice[num]++;
		}
		for (i = 0; i < 10; i++){
			for (n = 0; n < ice[i]; n++){
				printf("*");
			}
			if (ice[i] == 0){
				printf("-");
			}
			printf("\n");
			ice[i] = 0;
		}
	}
	return (0);
}

Measured memory_bytes: 568
n,k= map(int, input().split())
p = list(map(int,input().split()))

count = 0
val = sum(p[0:k])
val_lis = [val]
mx_val = val
index = 0
mx_index = 0
for i,j in enumerate(p[k:]):
    val = val - p[index] + j
    val_lis.append(val)
    index +=1
    if val > mx_val:
        mx_index = index
        mx_val = val 
    
ans = 0
for i in range(k):
    ans += ((p[mx_index + i]+1.0)*(p[mx_index+i]))/ (p[mx_index+i] *2.0)
print(ans)  






Measured memory_bytes: 24808
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
char s[4001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int x;
    cin >> x;
    for (int A = -118; A <= 119; A++) {
        for (int B = -118; B <= 119; B++) {
            if (A * A * A * A * A - B * B * B * B * B == x) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int sq[505][505],sum[505][505];
int n,m,q,l,r;
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    memset(sq,0,sizeof(sq));
    memset(sum,0,sizeof(sum));
    for (int i=1; i<=m; i++) 
    {
        scanf("%d%d",&l,&r);
        sq[l][r]++;
    }
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            sum[i][j]=sum[i-1][j]+sum[i][j-1]
                     -sum[i-1][j-1]+sq[i][j];
    for (int i=1; i<=q; i++)
    {
        scanf("%d%d",&l,&r);
        int a=max(l,r), b=min(l,r);
        int ans=sum[a][a]-sum[a][b-1]-sum[b-1][a]+sum[b-1][b-1];
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2944
line=""
while(True):
    line = input().split()
    a=int(line[0])
    b=int(line[2])
    op=line[1]
    result=0
    if op=="?": break
    elif op=="+": result=a+b
    elif op=="-": result=a-b
    elif op=="*": result=a*b
    elif op=="/": result=a//b
    print(result)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll n,a,b,h[200001];
ll ok,ng,mid;
int solve(int x){
    ll g[200001];
    rep(i,n) g[i]=h[i];
    rep(i,n) g[i]-=x*b;
    ll sum=0;
    rep(i,n) sum+=(g[i]+a-b-1)/(a-b)*(g[i]>0);
    if(x>=sum) return 1;
    else return 0;
}
int search(){
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
}
int main(){
    cin>>n>>a>>b;
    rep(i,n) cin>>h[i];
    ng=0,ok=1e9;
    search();
    cout<<ok;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long

template<class T> ostream& operator<<(ostream &os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<" ]";
}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
ll mxm(){return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a,Args... args){return max(a,mxm(args...));}
ll mnm(){return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a,Args... args){return min(a,mnm(args...));}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
		const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vi vector<int>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define vld vector<ld>
#define vvld vector<vld>
#define I insert
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl "\n"
#define siz(a)	((int)(a).size())

const int mod=1e9+7;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

const int N=1e5+5;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;cin>>n;
	vll v(n+1);
	ll ans=0,a;
	for(ll i=0;i<n+1;i++)
		cin>>v[i];
	for(ll i=0;i<n;i++){
		cin>>a;
		ans+=min(a,v[i]);
		ll c=min(a,v[i]);
		a-=c;v[i]-=c;
		c=min(a,v[i+1]);
		ans+=c;
		v[i+1]-=c;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int A, B;
  cin >> A >> B;
  
  if(B%A)
  {
    cout << B-A << endl;
  }else{
    cout << B+A << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

// 1 1 1 1 1 5 4 5
// 1 1 5 5
// 1 1 1 4

int ans, n;
int o[100005], e[100005];

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

    REP(i, 1, n+1) {
    	int v;
    	scanf("%d", &v);
    	if (i % 2 == 0) e[v] += 1;
    	else o[v] += 1;
    }

    int omax = 0, second_omax = 0;
    int emax = 0, second_emax = 0;
    int eidx = -1, oidx = -1;

    REP(i, 1, 100001) {
    	if (o[i] > omax) {
    		second_omax = omax;
    		omax = o[i];
    		oidx = i;
    	} else if (o[i] > second_omax) {
    		second_omax = o[i];
    	}

    	if (e[i] > emax) {
    		second_emax = emax;
    		emax = e[i];
    		eidx = i;
    	} else if (e[i] > second_emax) {
    		second_emax = e[i];
    	}
    
    }
 

    if (eidx != oidx) {

    	ans += n - (omax + emax);
    } else {
    	ans += n - (second_omax + emax);
    	ans = min(ans, n - (omax + second_emax));
    }


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

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,ans = 0,cnt = 0;
    cin >> n;
    rep0(i, n){
        ll a;
        cin >> a;
        cnt += a;
        if(a == 0){
            ans += cnt / 2;
            cnt = 0;
        }
    }
    pf(ans + cnt / 2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>

using namespace std;
typedef long long ll;

int n;
ll t[3005], st[3005];

ll dp[3005][3005];

ll gsum(int l, int r) {
	return st[r]-st[l-1];
}

ll solve(int l, int r, int cp) {
	assert(l <= r);
	assert(cp == 0 || cp == 1);

	if (l == r) return t[l];
	if (dp[l][r] != -1) return dp[l][r];

	ll lres = t[l] + (gsum(l+1, r) - solve(l+1, r, cp^1));
	ll rres = t[r] + (gsum(l, r-1) - solve(l, r-1, cp^1));

	return dp[l][r] = max(lres, rres);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	ll tsum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i];
		st[i] = st[i-1]+t[i];
		tsum += t[i];
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			dp[i][j] = -1;
		}
	}
	ll ares = solve(1, n, 0);
	cout << (ares - (tsum-ares)) << "\n";
	return 0;
}

/*
	solve(l, r, cp) = max sum that player cp can get when ends are at (l, r)

	if l == r, return t[l]
	otherwise take the one
*/


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

int main(void){
    //入力
    long N,X;
    cin>>N>>X;
    vector<long> L(N);
    for(int i=0;i<N;+i++){
        cin>>L.at(i);
    }
    
    //計算
    long ans=1,D=0;
    for(int i=0;i<N;i++){
         D+=L.at(i);
         if(D<=X) ans++;
    }
    
    //出力
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<double,ll> dmp;
typedef pair<dmp,mp> mmp;
double inf =1e9;
struct edge{
	int to,d,c;
	edge(){}
	edge(int to,int d,int c):to(to),d(d),c(c){}
};

int main(){
    while(1){
	int n,m,s,t;
	cin>>n>>m;
	if(n==0)break;
	cin>>s>>t;
	s--,t--;
	vector<vector<edge> > g(n);
	for(int i=0;i<m;i++){
		int x,y,d,c;
		cin>>x>>y>>d>>c;
		x--,y--;
		g[x].push_back(edge(y,d,c) );
		g[y].push_back(edge(x,d,c) );
	}
	bool f = true;
	vector<vector<vector<bool> > > used(n,vector<vector<bool> >(n,vector<bool>(31,false) ) );
	priority_queue<mmp,vector<mmp>,greater<mmp> > q;
	q.push( mmp ( dmp( 0.0 , 0 ), mp( s , s )  ) );
	while(!q.empty() ){
	    mmp now = q.top();
	    q.pop();
	    double time = now.first.first;
	    ll speed = now.first.second;
	    ll nn = now.second.first;
	    ll prev = now.second.second;
	    //cout<<nn<<' '<<prev<<' '<<speed<<endl;
	    if( nn == t && speed == 1){
			printf("%0.10lf\n",time);
			f = false;
			break;
	    }
	    //if(used[nn][prev][speed])continue;
	    //used[nn][prev][speed] = true;
	    for(int i=0;i<g[nn].size();i++){
		ll next = g[nn][i].to;
		double dis = g[nn][i].d;
		ll c = g[nn][i].c;
		if(next == prev) continue;
		for(int j=-1;j<=1;j++){
			ll nspeed = speed + j;
			if( nspeed <= 0 || c < nspeed )continue;
			if( used[next][nn][nspeed] ) continue;
			used[next][nn][nspeed] = true;
			q.push( mmp( dmp( time + dis/nspeed , nspeed ) , mp(next,nn )  )  );
		}

	    }
	}
	if(f)cout<<"unreachable"<<endl;

    }	
	return 0;
}



Measured memory_bytes: 3728
#include <iostream>
using namespace std;
int n, k;
int main()
{
    cin >> n >> k;
    int dp[k + 2] = {0};
    int a[n + 2];
    for (int i = 1; i <= n; i++)
        cin >> a[i], dp[a[i]] = 1;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i >= a[j] && dp[i - a[j]] == 0)
                dp[i] = 1;
        }
        if (!dp[i])
            dp[i] = 0;
    }
    if (dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}

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

using namespace std;

int main(void)
{
	int n,rt=0,cnt=1;
	bool jud=false;

	cin>>n;

	int h[n];

	for(int i=0;i<n;i++){
		cin>>h[i];
		if(i>0){
			for(int j=0;j<rt;j++){
				if(h[i]>=h[i-1]){
					if(h[i]>=h[j]){
						jud=true;
					}
					else{
						jud=false;
						break;
					}
				}
				else{
					jud=false;
				}
			}
		}
		if(jud) cnt++;
		rt++;
	}

	cout<<cnt<<endl;

	return 0;
}


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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n;
        cin>>n;
        set<string>s;
        for(int i=0;i<n;i++){
            string str;
            cin>>str;
            s.insert(str);
        }
        cout<<s.size();
        return 0;
    }


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

int main() {
    int N, X; cin >> N >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<vector<int>> B(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        B[i][0] = A[i];
        for (int k = 1; k < N; k++) {
            B[i][k] = min(B[i][k - 1], A[(i - k + N) % N]);
        }
    }
    long long ans = 1LL << 60;
    for (int k = 0; k < N; k++) {
        long long tmp = 1LL * k * X;
        for (int i = 0; i < N; i++) {
            tmp += B[i][k];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16128
import java.util.Scanner;
     
    class Main{
    	public static void main(String arg[]) {
    		Scanner sc = new Scanner(System.in);
    		String S = sc.nextLine();
    		int A = Integer.parseInt(S.substring(0,1));
    		int B = Integer.parseInt(S.substring(1,2));
    		int C = Integer.parseInt(S.substring(2,3));
    		int D = Integer.parseInt(S.substring(3,4));
    		sc.close();
    	
			int ans = 0;
    		String[] ope = {"+","-"};
    		for(int i = 0; i < 2; i++) {
    			String ope1 = ope[i];
    			for(int j = 0; j < 2; j++) {
    				String ope2 = ope[j];
    				for(int k = 0; k < 2; k++) {
    					String ope3 = ope[k];
    					if(ope[i].equals("+")) {
    	    				ans = A + B;
    	    			}else {
    	    				ans = A - B;
    	    			}
    					if(ope[j].equals("+")) {
        					ans += C;
            			}else {
            				ans -= C;
            			}
    					if(ope[k].equals("+")) {
    						ans += D;
            			}else {
            				ans -= D;
            			}
    					if(ans == 7) {
    						String s = A + ope1 + B + ope2 + C + ope3 + D + "=7";
    						System.out.println(s);
    						System.exit(0);
    	    			}else {
    	    				ans = 0;
    	    			}
    				}
    			}
    		}
		}
    }

Measured memory_bytes: 25044
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int main(void)
{

	int x, a, b;
	cin >> x >> a >> b;

	cout << (x - a) % b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__ )
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define Size 1000111
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________


signed main()
{
   FAST();
   int a[102];
   int N;
   cin >> N;
   rep(i, N)cin >> a[i];


   sort(a, a+N, greater<int>());
   int cnt = 1;

   for(int i=1; i<N; ++i){
      if(a[i-1] != a[i]){++cnt;}
   }
   outl(cnt);
}



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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  int32 n = s.size();
  int32 ans = 0;
  REP(i,n)if(s[i] != t[i])++ans;
  ANS(ans);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

void fail(){
  puts("WA");
  exit(0);
}

int main(){
  string s;
  cin>>s;
  if(s[0]!='A')fail();
  int it = -1;
  REP(i,s.size())if(s[i]=='C'){
    it = i;break;
  }
  if(it == -1)fail();
  if(it == 1)fail();
  if(it == s.size()-1)fail();
  REP(i,s.size())if(i!=0 && i!=it){
    if(isupper(s[i]))fail();
  }
  puts("AC");
  return 0;
}


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

N, K = map(int, input().split())
s = input()

output = ''
for i in range(N):
    if i == K - 1 :
        if s[i] == 'A':
            output += 'a'
        elif s[i] == 'B':
            output += 'b'
        elif s[i] == 'C':
            output += 'c'
    else:
        output += s[i]

print(output)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
  long long n;
  cin >> n;
  long long a;
  long long ans = 0;
  for (int i = 1; i < n+1; i++){
    for (int j = 1; j < n+1; j++){
      a = gcd(i, j);
      for (int k = 1; k < n+1; k++){
        ans += gcd(a, k);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>

int N, A, B, C;
int l[11];
int INF = 1000000000;

int dfs(int cur, int a, int b, int c){
    int ret0, ret1, ret2, ret3;
    if(cur == N){
        if(a>0 && b>0 && c>0){
            return fabs(a-A)+fabs(b-B)+fabs(c-C)-30;
        }else{
            return INF;
        }
    }
    ret0 = dfs(cur + 1, a, b, c);
    ret1 = dfs(cur + 1, a+l[cur], b, c) + 10;
    ret2 = dfs(cur + 1, a, b+l[cur], c) + 10;
    ret3 = dfs(cur + 1, a, b, c+l[cur]) + 10;

    if(ret0<=ret1 && ret0<=ret2 && ret0<=ret3){
        return ret0;
    }else if(ret1<=ret0 && ret1<=ret2 && ret1<=ret3){
        return ret1;
    }else if(ret2<=ret0 && ret2<=ret1 && ret2<=ret3){
        return ret2;
    }else{
        return ret3;
    }
    
}

int main(){
    int i, j, k;
    int ans;

    scanf("%d %d %d %d", &N, &A, &B, &C);
    for(i=0; i<N; i++){
        scanf("%d", &l[i]);
    }

    ans = dfs(0, 0, 0, 0);

    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 128
one = Array.new(3).map{Array.new(10, 0)}
two = Array.new(3).map{Array.new(10, 0)}
three = Array.new(3).map{Array.new(10, 0)}
four = Array.new(3).map{Array.new(10, 0)}

n = STDIN.gets.to_i
for i in 1 .. n do
  input = STDIN.gets.split(" ")
  b = input[0].to_i
  f = input[1].to_i
  r = input[2].to_i
  v = input[3].to_i
  case b
  when 1 then
    one[f-1][r-1] += v
  when 2 then
    two[f-1][r-1] += v
  when 3 then
    three[f-1][r-1] += v
  when 4 then
    four[f-1][r-1] += v
  end
end

for i in 1 .. 4 do
  for j in 0 .. 2 do
    for k in 0 .. 9 do
      case i
      when 1 then
        print " " + one[j][k].to_s 
      when 2 then
        print " " + two[j][k].to_s
      when 3 then
        print " " + three[j][k].to_s
      when 4 then
        print " " + four[j][k].to_s
      end
    end
    print "\n"
  end
  if i != 4
    print "####################\n"
  end
end

Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
 
int main() {
  int a;
  int k,x,y=0,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  int n,ans=0;
  cin>>k>>n;
  vector<int> count(n,0);
  rep(i,n){cin>>m;
    count[i]=k-m;}
    y=k-count[0]+count[n-1];
  rep(i,n-1){
    count[i]-=count[i+1];
    y=max(y,count[i]);
  }
  //rep(i,n)ans+=count[i];
  cout<<k-y<<endl;
  
  
  
  //cout<<dp[x-1][y-1]<<endl;
 
  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = 0;

  repI(i, a, b+1) {
    ll div = 0;
    ll tmp = i;
    while(tmp!= 0) {
      div *= 10;
      div += tmp % 10;
      tmp /= 10;
    }
    if (div == i) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if (n==5 || n==7 || n==3) cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  string divide[4]={"dream","dreamer","erase","eraser"};

  reverse(S.begin(),S.end());
  for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

  bool can=true;
  for(int i=0;i<S.size();){
    for(int j=0;j<4;j++){
      string d=divide[j];
      if(S.substr(i,d.size())==d){
        i+=d.size();
        break;
      }
      else{
        if(j==3){can=false;
          i=S.size();
          break;
        }
      }
    }
  }

    if(can) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
  }





Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int calc(vector<string> s, int &i){
	int depth = s[i].length(), n = s.size();
	char c = s[i][depth-1];
	if (c == '+'){
		int res = 0;
		i++;
		while (s[i].length() == depth+1 && i < n){
			res += calc(s, i);
		}
		return res;
	}else if (c == '*'){
		int res = 1;
		i++;
		while (s[i].length() == depth+1 && i < n){
			res *= calc(s, i);
		}
		return res;
	}else{
		i++;
		return c - '0';
	}
}

int main(){
	int n;
	ifstream ifs("in.txt");
	while (cin >> n && n){
		vector<string> s(n+1);
		REP(i,n) cin >> s[i];
		int i = 0;
		cout << calc(s, i) << endl;
	}

    return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

long long ans1, ans2, ans3;
long long ans;

int main() {

	long long a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	ans1 = a*x + b*y;
	if (x > y)ans2 = 2 * c*y + a*(x - y);
	else ans2 = 2 * c*x + b*(y - x);
	ans3 = 2 * c*max(x, y);
	ans = min(ans1, ans2);
	ans = min(ans, ans3);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL) x = x->left;
  return x;
}

Node * treeSuccessor(Node *x) {
  if (x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while (y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y;
  Node *x;

  if (z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if (y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if (x != NIL) {
    x->parent = y->parent;
  }

  if (y->parent == NIL) {
    root = x;
  } else {
    if (y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if (y != z) {
    z->key = y->key;
  }

  free(y);
}

Node * find(Node *u, int k) {
  while (u != NIL && k != u->key) {
    if (k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    cin >> com;
    if ( com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "find") {
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } else if (com == "delete")  {
      scanf("%d", &x);
      treeDelete(find(root, x));
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 22032
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
     int a[10],i,judge;
     for(i=0;i<10;i++) cin >> a[i];
     judge = 0;
     do{
       judge = 1;
       for(i=0;i<9;i++){
         if(a[i]<a[i+1]){
           swap(a[i],a[i+1]);
           judge = 0;
         }
       }
     }while(!judge);
 
     for(i=0;i<3;i++)
       cout << a[i] << endl;
 
   return 0;
}

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

int main(){

  int N,a,max=0,min=1000;

  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a>max)max=a;
    if(a<min)min=a;
  }

  cout<<max-min<<endl;

  return 0;
}


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

using namespace std;

const int N = 500005;

int n, m, a[N], b[N], c[N];
bool vis[N];
long long value[N];
vector<pair<int, int> > V[N];

long long mn = 1e18;
long long mx = -1e18;

void DFS(int w) {
    mn = min(mn, value[w]);
    mx = max(mx, value[w]);
    vis[w] = true;
    for (int i = 0; i < (int)V[w].size(); i++) {
        int u = V[w][i].first;
        int weight = V[w][i].second;
        if (!vis[u]) {
            value[u] = value[w] + weight;
            DFS(u);
        }
    }
}

int main() {
    
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        V[a[i]].push_back({b[i], c[i]});
        V[b[i]].push_back({a[i], -c[i]});
    }
    
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            mn = 1e18;
            mx = -1e18;
            DFS(i);
            if (mx - mn > 1e9) {
                printf("No\n");
                return 0;
            }
        }
    }
    
    for (int i = 1; i <= m; i++) {
        if (value[b[i]] - value[a[i]] != c[i]) {
            printf("No\n");
            return 0;
        }
    }
    
    printf("Yes\n");
    
    return 0;
}

Measured memory_bytes: 30080
N = int(input())

returns = []
ans = [0,0,0,0]

for i in range(N):
    returns.append(input())

for j in range(N):
    if returns[j] == 'AC':
        ans[0] += 1
        continue
    if returns[j] == 'WA':
        ans[1] += 1
        continue
    if returns[j] == 'TLE':
        ans[2] += 1
        continue
    if returns[j] == 'RE':
        ans[3] += 1
        continue

print('AC x '+str(ans[0]))
print('WA x '+str(ans[1]))
print('TLE x '+str(ans[2]))
print('RE x '+str(ans[3]))

Measured memory_bytes: 16148