akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n = I()
    a = LI()
    t = 0
    c = a[0]
    r = 1
    for b in a[1:]:
        if c == b:
            continue
        if t==0:
            t = c-b
        elif t * (c-b) < 0:
            r += 1
            t = 0

        c = b

    return r


print(main())


Measured memory_bytes: 16652
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <functional>
#include <iostream>
#include <numeric>
#define SIZE 10005
 
using namespace std;
typedef long long int ll;
// typedef pair <int,int> P;
 
int pair[SIZE];
 
int main()
{
	int n;
    long long int sum = 0;
    int count = 0;
    std::cin >> count;
    long long int value[count];
    int zero_count = 0;
    for (int i = 0; i < count; i++)
    {
        std::cin >> value[i];
        if (value[i] <= 0){
            zero_count += 1;
            value[i] *= -1;
        }
    }
    std::sort(value, value+count);
    for (int i = 1; i < count; i++)
    {
        sum = sum + value[i];
    }
    if (zero_count % 2 == 1)
    {
        sum -= value[0];
    }else {
        sum += value[0];
    }
	std::cout << sum << std::endl;

    return 0;
    
}

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

int main(){
  int x;
  int out=0;
  cin >> x;
  if(x<=599){
    out=8;
  }else if(x<=799){
    out=7;
  }else if(x<=999){
    out=6;
  }else if(x<=1199){
    out=5;
  }else if(x<=1399){
    out=4;
  }else if(x<=1599){
    out=3;
  }else if(x<=1799){
    out=2;
  }else{
    out=1;
  }
  cout << out <<endl;
  return(0);
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
void resolver();
inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline std::vector<T> read_vector()
{
    size_t n;
    std::cin >> n;
    std::vector<T> ret(n);
    for (T& i : ret) {
        std::cin >> i;
    }
    return ret;
}
void t_case()
{
    i64 t;
    std::cin >> t;
    while (t--) {
        resolver();
    }
}
void single_case()
{
    resolver();
}

int main(int argc, char* argv[])
{
    fast_io();
    // t_case();
    single_case();
}

i64 gcd(i64 __m, i64 __n)
{
    while (__n != 0) {
        i64 __t = __m % __n;
        __m = __n;
        __n = __t;
    }
    return __m;
}

void resolver()
{
    using namespace std;

    i32 k;
    cin >> k;
    i64 sum = 0;
    for (i32 i = 1; i <= k; i++) {
        for (i32 j = 1; j <= k; j++) {
            for (i32 t = 1; t <= k; t++) {
                sum += gcd(gcd(i, j), t);
            }
        }
    }

    cout << sum;
}


Measured memory_bytes: 3192
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

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

ll gcd( ll a, ll b )
{
	 if (b == 0)
		  return a;
	 else
	 {
		  return gcd( b, a % b );
	 }
}
int a[200005];
int n, cnt;
bool func(int x)
{
	int l = x;
	for (int i = n - 1; i >= 0; i--)
	{
		if (a[i] == l)
			l--;
	}
	if (l == 0)
		return true;
	else
		return false;

}
void solve()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			cnt++;
		}
	}
	if (cnt == 0)
	{
		cout << "-1";
		return;
	}
	int lo = 0, hi = n, mid;
	int ans = 0;
	while (lo <= hi)
	{
		mid = (lo + hi) / 2;
		if (func(mid))
		{
			lo = mid + 1;
			ans = mid;
		}
		else
			hi = mid - 1;
	}
	cout << n-ans;
}
int main()
{
	 int t = 1;
	 //cin >> t;
	 while (t--)
	 {
		  solve();
	 }
	 return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int m;
vector <int> v[100000];
vector <int> w[100000];
vector <int> z[100000];
vector <int> l[100000];
vector <int> r[100000];
map <int, int> mp[100000];

long long dfs(int x, int y) {
    int i;
    
    if (mp[x].count(y)) return mp[x][y];
    
    if (z[x].size() == 0) {
        long long ans = 1;
        
        for (i = 0; i < v[x].size(); i++) {
            if (v[x][i] == y) {
                z[x].push_back(w[x].size());
                w[x].push_back(0);
            } else {
                w[x].push_back(dfs(v[x][i], x) + 1);
                ans = ans * w[x].back() % m;
            }
        }
        
        if (y == -1) {
            long long left = 1, right = 1;
            
            for (i = 0; i < v[x].size(); i++) {
                l[x].push_back(left);
                left = left * w[x][i] % m;
            }
            l[x].push_back(left);
            
            for (i = v[x].size() - 1; i >= 0; i--) {
                r[x].push_back(right);
                right = right * w[x][i] % m;
            }
            reverse(r[x].begin(), r[x].end());
            
            z[x].push_back(0);
        }
        
        return mp[x][y] = ans;
    } else if (w[x][z[x][0]] == 0) {
        int p = z[x][0];
        long long left = 1, right = 1;
        
        w[x][p] = dfs(v[x][p], x) + 1;
        
        for (i = 0; i < v[x].size(); i++) {
            l[x].push_back(left);
            left = left * w[x][i] % m;
        }
        l[x].push_back(left);
        
        for (i = v[x].size() - 1; i >= 0; i--) {
            r[x].push_back(right);
            right = right * w[x][i] % m;
        }
        reverse(r[x].begin(), r[x].end());
    }
    
    if (y == -1) {
        return mp[x][y] = l[x].back();
    } else {
        int p = lower_bound(v[x].begin(), v[x].end(), y) - v[x].begin();
        
        return mp[x][y] = (long long)l[x][p] * r[x][p] % m;
    }
}

int main() {
    int n, i, j;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < n - 1; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    for (i = 0; i < n; i++) sort(v[i].begin(), v[i].end());
    
    for (i = 0; i < n; i++) printf("%d\n", dfs(i, -1));
    
    return 0;
}


Measured memory_bytes: 56960
n, a, b = gets.strip.split.map(&:to_i)

# 各桁の和を求める
def digit_sum n
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a <= d[1] && d[1] <= b }
        .inject(0) { |sum, d| sum + d[0] }

puts ans

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int solve(int n, int a, int b) {
	int res = 0;
	for (int i = n; i >= 1; i--) {
		string str = to_string(i);

		int sum = 0;
		for (auto c : str) {
			sum += c - '0';
		}

		if (a <= sum && sum <= b) {
			res += i;
		}
	}

	return res;
}

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

	int n, a, b;
	cin >> n >> a >> b;

	cout << solve(n, a, b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MAX_K 1000

using namespace std;

int req[MAX_K*2+1][MAX_K*2+1][2],ss[MAX_K*2+1][MAX_K*2+1][2]; //[x][y][W:0 B:1]
int n,k;

int getrect(int x1,int y1,int x2,int y2,int c) {
    return (ss[x2][y2][c] + ss[x1][y1][c]) - (ss[x1][y2][c] + ss[x2][y1][c]);
}

int getcheck1(int x,int y,int c) {
    int ret = getrect(x,y,x+k,y+k,c) + getrect(0,0,x,y,c) + getrect(0,y+k,x,2*k,c) + getrect(x+k,0,2*k,y,c) + getrect(x+k,y+k,2*k,2*k,c);
    return ret;
}

int getcheck2(int x,int y,int c) {
    int ret = getrect(x,0,x+k,y,c) + getrect(0,y,x,y+k,c) + getrect(x+k,y,2*k,y+k,c) + getrect(x,y+k,x+k,2*k,c);
    return ret;
}

int main(void) {
    cin >> n >> k;
    for(int i = 0;i < n;i++) {
        int x,y,c;
        char ct;
        cin >> x >> y >> ct;
        if(ct == 'B')
            c = 1;
        else
            c = 0;
        req[x%(2*k)][y%(2*k)][c]++;
    }
    for(int x = 1;x <= 2*k;x++) {
        for(int y = 1;y <= 2*k;y++) {
            ss[x][y][0] = ss[x][y-1][0] + ss[x-1][y][0] - ss[x-1][y-1][0] + req[x-1][y-1][0];
            ss[x][y][1] = ss[x][y-1][1] + ss[x-1][y][1] - ss[x-1][y-1][1] + req[x-1][y-1][1];
        }
    }
    int ret = 0;
    for(int x = 0;x <= k;x++) {
        for(int y = 0;y <= k;y++) {
            ret = max(ret,max(getcheck1(x, y, 0) + getcheck2(x, y, 1),getcheck1(x, y, 1) + getcheck2(x, y, 0)));
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 62848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int n,x,sum = 0,rem,count = 0,date;
vector <int> m;

cin >> n >> x;

rep(i,n){
   cin >> date;
   m.push_back(date);
}

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

rep(i,n) sum += m[i];

rem = x-sum;

count = rem/m[0];

cout << count+n << endl;







//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const mxn = 1e5+90;


int mark[mxn],dis[mxn];
vector <int > adj[mxn];



void dfs(int v){
	if (dis[v]!=-1) 
		return;
	dis[v]=0;
	for (auto u : adj[v]){
		dfs(u);
		dis[v] = max(dis[v],dis[u]+1);
		
	}	
}
int  ans ; 
int main(){
	int n,m;
	cin>>n>>m;
	for (int i =1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
	}
	for (int i =1;i<=n;i++)
		adj[0].push_back(i);
	fill(dis,dis+mxn,-1);
	for (int i = 1;i<=n;i++){
		dfs(i);
	}
	for (int i =1;i<=n;i++)
		ans = max ( ans , dis[i] );
	cout<<ans;
	
}

Measured memory_bytes: 8696
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int m, c, sum;
		while ((m = s.nextInt()) != 0) {
			c = 1000 - m;
			sum = 0;
			while (c - 500 >= 0) { c -= 500; sum += 1; }
			while (c - 100 >= 0) { c -= 100; sum += 1; }
			while (c -  50 >= 0) { c -=  50; sum += 1; }
			while (c -  10 >= 0) { c -=  10; sum += 1; }
			while (c -   5 >= 0) { c -=   5; sum += 1; }
			while (c -   1 >= 0) { c -=   1; sum += 1; }
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int f(int a){return a*(a-1)/2;}
int main(void){
  int a,b;
  INI(a);
  INI(b);
  PRN(f(a)+f(b));
  return 0;
}


Measured memory_bytes: 128
N = int(input())
S = list(input())

alphabet = ['A', 'B', 'C', 'D', 'E', 'F',
            'G', 'H', 'I', 'J', 'K', 'L',
            'M', 'N', 'O', 'P', 'Q', 'R',
            'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
answer = []
for s in S:
    number = alphabet.index(s)
    while number + N >= 25:
        number = number - 26 
    answer.append(alphabet[number+N])
print(''.join(answer))


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long B = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        B ^= A[i];
    }
    for (int i = 0; i < N; ++i) cout << (B^A[i]) << endl;
}

Measured memory_bytes: 4800
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int a[5];
    float b[5];
    int minimum=10;
    int amari;
    int sum=0;
    for (int i=0;i<5;i++){
        cin>>a[i];
        b[i]=a[i]/10.0f;
        sum+=ceil(b[i])*10;
    }
    for (int i=0;i<5;i++){
        amari=a[i]%10;
        if(minimum>amari && amari!=0) minimum=amari;
    }
    sum-=10;
    sum+=minimum;
    cout<<sum<<endl;
}


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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    string S;
    char elem[] = {'k', 'e', 'y', 'e', 'n', 'c', 'e'};
    int counter = 0;

    cin >> S;

    if (S == "keyence") {cout << "YES" << endl; return 0;}
    while (S[counter] == elem[counter]) {
        counter++;
    }

    while (S[S.size()-(7-counter)] == elem[counter]) {
        counter++;
    }

    string ans = (counter == 8) ? "YES" : "NO";
    cout << ans << endl;

}


Measured memory_bytes: 3616
n, m = map(int, input().split())
# 壊れた場所を集合で持っておく
a = {int(input()) for _ in range(m)}
route = [0] * (n + 1)
# route[2]のために初期値は1とする
route[0] = 1
for i in range(1, n + 1):
    # 壊れた場所でないなら、そこまでのルート数を計算
    if not (i in a):
        if i == 1:
            route[i] = 1
        else:
            route[i] = (route[i - 1] + route[i - 2]) % (10 ** 9 + 7)
print(route[n])

Measured memory_bytes: 11884
# encoding: utf-8


import sys
import math

_input = sys.stdin.readlines()
depth = int(_input[0])
sin_60, cos_60 = math.sin(math.pi / 3), math.cos(math.pi / 3)


class Point(object):
    def __init__(self, x=0.0, y=0.0):
        """
        initialize the point
        """
        self.x = float(x)
        self.y = float(y)


def koch_curve(d, p1, p2):
    if not d:
        # print('end')
        return None

    # why can't it be like below?
    # s, t, u = Point(), Point, Point()
    s, t, u = (Point() for _ in range(3))

    s.x = (2 * p1.x + p2.x) / 3
    s.y = (2 * p1.y + p2.y) / 3

    t.x = (p1.x + 2 * p2.x) / 3
    t.y = (p1.y + 2 * p2.y) / 3

    u.x = (t.x - s.x) * cos_60 - (t.y - s.y) * sin_60 + s.x
    u.y = (t.x - s.x) * sin_60 + (t.y - s.y) * cos_60 + s.y

    koch_curve(d - 1, p1, s)
    print(format(s.x, '.8f'), format(s.y, '.8f'))

    koch_curve(d - 1, s, u)
    print(format(u.x, '.8f'), format(u.y, '.8f'))

    koch_curve(d - 1, u, t)
    print(format(t.x, '.8f'), format(t.y, '.8f'))

    koch_curve(d - 1, t, p2)


if __name__ == '__main__':
    p1_start, p2_end = Point(x=0, y=0), Point(x=100, y=0)
    print(format(p1_start.x, '.8f'), format(p1_start.y, '.8f'))
    koch_curve(depth, p1_start, p2_end)
    print(format(p2_end.x, '.8f'), format(p2_end.y, '.8f'))

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


void dfs(int start,vector<ll>&per,vector<ll>&score,vector<ll>&temp,vector<ll>&visited,ll pre){
	if(visited[start]==1)
		return;
	visited[start]=1;
	start=per[start];
	pre+=score[start];
	temp.push_back(pre);
	dfs(start,per,score,temp,visited,pre);
}



ll getMaxFrom(vector<ll> &data,int limit){
	ll ans=data[0];
	for(int i=0;i<limit;i++)
		ans=max(ans,data[i]);
	return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  
    
    int t;
  	t=1;

    while(t--){
 		int N,K;
 		cin>>N>>K;

 		vector<ll> per(N);
 		for(int i=0;i<N;i++){
 			cin>>per[i];
 			per[i]-=1;
 		}

 		vector<ll> score(N);
 		for(int i=0;i<N;i++)
 			cin>>score[i];

 		vector<vector<ll>> prefix;
 		for(int i=0;i<N;i++){
 			vector<ll> temp;
 			vector<ll> visited(N,0);
 			dfs(i,per,score,temp,visited,0);
 			prefix.push_back(temp);
 		}

 		ll ans=INT_MIN;
 		for(int i=0;i<N;i++){
 			if(K>prefix[i].size()){
 				if(prefix[i][prefix[i].size()-1]<=0){
 					ans=max(ans,getMaxFrom(prefix[i],prefix[i].size()));
 				}
 				else{
 					int len = prefix[i].size();
 					ll div = K/len;
 					ll rem = K%len;

 					ll profit1 = prefix[i][len-1]*(div-1);

 					profit1+=getMaxFrom(prefix[i],len);

 					if(rem!=0){
 						ll profit2 = prefix[i][len-1]*div;
 						profit2+= getMaxFrom(prefix[i],rem);

 						profit1 = max(profit1,profit2);
 					}

 					ans=max(ans,profit1);
 				}
 			}
 			else{
 				ans=max(ans,getMaxFrom(prefix[i],K));
 			}
 		}

 		cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 199120
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
using namespace std;

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

    int result = 700;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o')
        result += 100;
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;
int n,m,x,y,mx = 400000000,cnt,sum,c,a;
set <int> st;
vector <bool> v;
string s;
const double P = acos(-1.0);
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("collect.in", "r", stdin);
    //freopen("collect.out", "w", stdout);
    string s;
    cin >> s;
    bool e = 0,t = 0,y = 0;
    for (int i = 0; i < sz(s); i++){
        if (s[i] == s[sz(s) - 1  - i]){
            e = 1;
        }
        else {
            e = 0;
            break;
        }
    }
    for (int i =  0; i < ((sz(s) - 1) / 2); i++){
        if (s[i] == s[((sz(s) - 1) / 2) - 1 - i]){
            t = 1;
        }
        else {
            t = 0;
            break;
        }
    }
    for (int i = ((n + 3) / 2); i < sz(s); i++){
        if (s[i] == s[sz(s) - 1 - i]){
            y = 1;
        }
        else {
            y = 0;
            break;
        }
    }
    if (e == 1 && t == 1 && y == 1){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int id;
vector<int> cc_id;   
void dfs(vector<vector<int>> &G, int v, int &cnt) {
    cc_id[v] = id;
    cnt++;
    for (auto i : G[v]) {
        if (cc_id[i] != -1) continue;
        dfs(G, i, cnt);
    }
}
int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<int>> G(N);  
    vector<int> cc_num;  
    rep(i, M) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cc_id.assign(N, -1);  
    id = 0;
    rep(i, N) {
        if (cc_id[i] == -1) {
            int cnt = 0;
            dfs(G, i, cnt);
            cc_num.push_back(cnt);
            id++;
        }
    }
    vector<int> ans(N);
    rep(i, N) ans[i] = cc_num[cc_id[i]]-(int)G[i].size()-1;
    rep(i, K) {  
        int c,d;
        cin >> c >> d;
        c--;d--;
        if (cc_id[c] == cc_id[d]) {
            ans[c]--;
            ans[d]--;
        }
    }
    rep(i,N) cout << ans[i] << ' ';
    cout << endl;
}


Measured memory_bytes: 10444
#include<bits/stdc++.h>
using namespace std;
long long n,k,i,o,ans,m,i2;
bool a[10000009];
int main()
{
	cin>>n>>k;
	for(i=1;i<=k;i++)
	{
		cin>>m;
		for(i2=1;i2<=m;i2++)
		{
			cin>>o;
			a[o]=true;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]==false) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3596
//https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_a
//A - Where's Snuke?
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll H,W; cin>>H>>W;
    ll ah,aw;
    REP(h,H){
        REP(w,W){
            string s; cin>>s;
            if(s=="snuke") {
                ah=h;
                aw=w;
            }
        }
    }
    cout<<(char)('A'+aw)<<ah+1<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(str, input().split()))

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print(n - f[0][1] - s[0][1])
else:
    if len(f) == 1 or len(s) == 1:
        print(n // 2)
    else:
        print(n - max(f[0][1] + s[1][1], f[1][1] + s[0][1]))

Measured memory_bytes: 16228
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();    
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();
    let c: i64 = iter.next().unwrap().parse().unwrap();
    let d: i64 = iter.next().unwrap().parse().unwrap();
    let e: i64 = iter.next().unwrap().parse().unwrap();

    fn next_order_time(t: i64) -> i64 {
        ((t - 1) / 10 + 1) * 10
    }

    let mut ans = 0;
    let mut max_wait_time = 0;

    for t in [a,b,c,d,e].iter() {
        max_wait_time = std::cmp::max(max_wait_time, next_order_time(*t) - t);
        ans += next_order_time(*t);
    }
    
    println!("{}", ans - max_wait_time);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int maxl;
	int sum=0;
	for(int i=0;i<n;i++){
		int l;
		cin >> l;
		sum+=l;
		maxl=max(maxl,l);
	}
	if(maxl<(sum-maxl)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n, a[N], vis[N];
char s[N];

void solve(int x) {
	a[x] = 0;
	int t = x-1, now = 1;
	while (t>=0&&s[t+1]=='>') a[t--] = now++;
	t = x+1, now = 1;
	while (t<=n&&s[t]=='<') a[t++] = now++;
}

int main() {
	scanf("%s",s+1);
	n = strlen(s+1);
	if (s[1]=='<') solve(0);
	REP(i,1,n-1) if (s[i]=='>'&&s[i+1]=='<') solve(i);
	if (s[n]=='>') solve(n);
	REP(i,1,n) if (s[i]=='<'&&s[i+1]=='>') a[i] = max(a[i-1],a[i+1])+1;
	ll ans = 0;
	REP(i,0,n) ans += a[i];
	printf("%lld\n", ans);
}








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

int main()
{
	char grade;
	int m, f, r;

	for (int i = 0; i < 50; i++)
	{
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)
			return 0;
		else if (m == -1 || f == -1)
			grade = 'F';
		else if (m + f >= 80)
			grade = 'A';
		else if (m + f >= 65 && m + f < 80)
			grade = 'B';
		else if (m + f >= 50 && m + f < 65)
			grade = 'C';
		else if (m + f >= 30 && m + f < 50)
		{
			if (r >= 50)
				grade = 'C';
			else
				grade = 'D';
		}
		else
			grade = 'F';

		printf("%c\n", grade);
	}
}


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    string x(s.length(), 'x');
    cout << x << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import(
  "fmt"
  "math"
)

func main() {
  var N int
  var v int
  fmt.Scan(&N)
  ans := 2
//  fmt.Println(int(math.Sqrt(float64(N))))
  for i:=2; i<=int(math.Sqrt(float64(N))); i++{
    if (N-1)%i==0 {
	  ans +=2
	  if i*i == N-1 {
		ans -= 1
	  }
    } else if N%i == 0{
	  v = N
	  for{
		v /= i
		if v%i == 1{
		  ans++
		}
		if v%i != 0{
		  break
		}
	  }
	  v = N
	  for{
		v /= (N/i)
		if v%(N/i) ==1{
		  ans ++
		}
		if v%(N/i) != 0{
		  break
		}
	  }
	  if i*i == N{
		ans -= 1
	  }
	}
  }
  if N == 1{
	ans = 0
  }
  if N == 2{
	ans = 1
  }
  fmt.Println(ans)
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define MAX 999999999

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

typedef long long ll;

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

    int n, m;
    cin >> n >> m;

    map<int, vector<int>> ships;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        ships[b].push_back(a);
    }

    bool flag = false;
    for(auto start = ships[n].begin(); start != ships[n].end() && !flag; start ++){
        flag = (count(all(ships[*start]), 1) > 0);
    }

    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 19448
n, k = map(int, input().split())
a = input().split()

a = [int(m) for m in a]
t = a.index(min(a))

leftar = []
rightar = []
leftco = 0
rightco = 0
startco = 1
#左側
for i in range(1, k + 1):
    if (t - k + i) / (k - 1) <= 0:#マイナス、０のときは０とする
        leftar.append(leftco)
    elif (t - k + i) % (k - 1) == 0:
        p = int((t - k + i) / (k - 1))
        for j in range(1, p + 1):
            leftco += 1
        leftar.append(leftco)
        leftco = 0
    else:#割り切れないときは繰り上げ
        p = int((t - k + i) / (k - 1)) + 1
        for j in range(1, p + 1):
            leftco += 1
        leftar.append(leftco)
        leftco = 0
#右側
for i in range(1, k + 1):
    if (n - t - i) / (k - 1) <= 0:
        rightar.append(rightco)
    if (n - t - i) % (k - 1) == 0:
        q = int((n - t - i) / (k - 1))
        for j in range(1, q + 1):
            rightco += 1
        rightar.append(rightco)
        rightco = 0
    else:
        q = int((n - t - i) / (k - 1)) + 1
        for j in range(1, q + 1):
            rightco += 1
        rightar.append(rightco)
        rightco = 0

sumar = [x + y + startco for (x, y) in zip(leftar, rightar)]

print(min(sumar))

Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<T> vec(n);
  REP(i,n){
    ll a,b;
    cin>>a>>b;
    vec[i] = make_tuple(a+b,a,b);
  }
  VRSORT(vec);
  ll suma=0,sumb=0;
  REP(i,n){
      if(i%2==0){//高橋君
        suma+=get<1>(vec[i]);
      }
      else{
        sumb+=get<2>(vec[i]);
      }
  }
  cout<<suma-sumb<<endl;
}

Measured memory_bytes: 2560
#素数判定
def Is_Prime(N):
    if N<=1:
        return False
    k=2
    while k*k<=N:
        if N%k==0:
            return False
        k+=1
    return True

#次の素数
def Next_Prime(N):
    """
    Nを上回る自然数のうち,最小の素数

    N:自然数
    """
    T=N+1
    while not Is_Prime(T):
        T+=1
    return T

#---------------------------------------------------------------------
N=int(input())
if Is_Prime(N):
    print(N)
else:
    print(Next_Prime(N))


Measured memory_bytes: 62556
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
     
 ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  


int main()
{
	FAST;
	vector<int> arr[200002];

	int n;
	cin >> n;
	
	for(int i=0 ; i<n ; i++)
	{
	    int temp;
	    cin >> temp;
	    arr[temp].push_back(i);
	}   
	
	int last = -1;
	for(int i=1 ; i<=n ; i++)
	{
	    bool flag = false;
	    for(int j=0 ; j<arr[i].size() ; j++)
	    {
	        if(arr[i][j] > last)
	        {
	            last = arr[i][j];
	            flag = true;
	            break;
	        }
	    }
	    
	    if(!flag)
	    {
	        if(i == 1)
	            cout << "-1";
	        else
	            cout << n-(i-1);
	        return 0;
	    }
	}
	cout << "0";
	return 0;
}


Measured memory_bytes: 11264
function main (s) {
	s=s.split("\n");
	if(s[0][0]==s[1][2]&&s[0][2]==s[1][0]&&s[0][1]==s[1][1])console.log("YES\n");
	else console.log("NO\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
    vector<int> vec(3);
    for (int i = 0; i < 3; ++i) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    cout << vec.at(0) << " " << vec.at(1) << " " << vec.at(2) << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;


int n;
int a[N];

int used[N];

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	cin >> n;
	int d = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		d = max(d, a[i]);
	}
	multiset<int> need;
	if (d > n - 1) {
		cout << "Impossible" << endl;
		return 0;
	}
	for (int i = (d + 1) / 2; i <= d; i++) {
		need.insert(i);
		if (d % 2 == 0 && i + i == d) {
		} else need.insert(i);
	}
	for (int i = 0; i < n; i++) {
		auto it = need.find(a[i]);
		if (it != need.end()) {
			need.erase(it);
			used[i] = 1;
		}			
	}


	if (need.size() > 0) {
		cout << "Impossible" << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) if (used[i] == 0 && a[i] < (d + 1) / 2 + 1) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void solve()
{
	int a, b, n;
	while(cin >> a >> b >> n)
	{
		a %= b;
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			a *= 10;
			sum += a / b;
			a %= b;
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

bool check8(int& n) {
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) cnt++;
  }
  return cnt == 8 ? true : false;
}
int main() {
  int n;
  cin >> n;
  int total = 0;

  for (int i = 1; i <= n; i++) {
    if (i % 2 == 0) continue;
    if (check8(i)) {
      total++;
    }
  }
  cout << total << endl;

  return 0;
}

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

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(n);
	string s;
	cin >> s;
	for (char c: s)
	{
	    int x = c - 65;
	    x = (x + n) % 26;
	    cout << (char)(x + 65);
	}
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	string s;
	cin >> s;

	stack<char> ans;
	string f = "";
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'B'){
			if(!ans.empty()){
				ans.pop();
			}
		}else{
			ans.push(s[i]);
		}
	}

	while(!ans.empty()){
		f += ans.top();
		ans.pop();
	}
	reverse(f.begin(), f.end());
	cout << f << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                             
using namespace std;
 
#define MAX(a,b) a>b?a:b
int main()
{
    int x, y, t;
    cin >> x >> y;
    while(x+y)
    {
        t = MAX(x,y);
        x = x+y-t;
        y = t;
        cout << x << " " << y << endl;
        cin >> x >> y;
    }
    return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

    
    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
        int val1 = sc.nextInt();
        int val2 = sc.nextInt();
        int val3 = sc.nextInt();
        
        if(val1 < val2 && val2 < val3){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    
}


Measured memory_bytes: 26112
import java.util.*;

public class Main {
	static boolean f;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		/* 入力の受け取り
		 * String s = sc.next();
		 * int a = sc.nextInt();
		 * long a = sc.nextLong();
		 */
		
		// 文字列(String)を文字(char)に分解
		// char[] s_char = s.toCharArray();
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[] = new int[n];
		int sum_a = 0;
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
			sum_a += a[i];
		}
		
		int p;
		if(sum_a%(4*m) == 0)
			p = sum_a/(4*m);
		else
			p = sum_a/(4*m)+1;
		
		int tmp_m = 0;
		for(int i=0;i<n;i++) {
			if(a[i] >= p)
				tmp_m++;
			if(tmp_m >= m) {
				f = true;
				break;
			}
		}

		if(f)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21844
//22
#include<iostream>
#include<queue>

using namespace std;

struct S{
  int x,y,t;
  bool operator<(S a)const{
    return t>a.t;
  }
};

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    char g[100][100];
    priority_queue<S> que;
    for(int y=0;y<m;y++){
      for(int x=0;x<n;x++){
	cin>>g[y][x];
	if(x==0||y==0||x==n-1||y==m-1){
	  S is={x,y,g[y][x]=='#'};
	  que.push(is);
	}
      }
    }
    bool mem[100][100]={{}};
    for(;;){
      S c=que.top();
      if(g[c.y][c.x]=='&')break;
      que.pop();
      if(mem[c.y][c.x]++)continue;
      for(int i=0;i<4;i++){
	int d[]={0,1,0,-1,0};
	int ny=c.y+d[i];
	int nx=c.x+d[i+1];
	if(0<=nx&&nx<n&&0<=ny&&ny<m){
	  S ns={nx,ny,c.t+((g[c.y][c.x]=='.')&&(g[ny][nx]=='#'))};
	  que.push(ns);
	}
      }
    }
    cout<<que.top().t<<endl;
  }
  return 0;
}

Measured memory_bytes: 1460
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,double> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,x;
int a[100100];
int b[100100];
int main(){
	cin >> N >> x;
	for(int i=0;i<N;i++){
		cin >> a[i];
		b[i]=a[i];
	}
	for(int i=0;i<N-1;i++)b[i]+=b[i+1];
	ll ans = 0ll;
	for(int i=0;i<N-1;i++){
		if(b[i]>x){
			int c = min(a[i+1],b[i]-x);
			ans += c;
			b[i]-=c;
			b[i+1]-=c;
		}	
	}
	for(int i=0;i<N-1;i++)if(b[i]>x)ans += b[i]-x;
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N;

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

	cin >> N;

	int x = ceil(N/1.08);
	
	if(floor(x*1.08) == N)
		cout << x << "\n";
	else
		cout << ":(\n";

	return 0;		
}

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

int main() {
	int N;
	cin >> N;
	vector <int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	int count = 1;
	int max = H[0];
	for (int i = 1;i < N; i++) {
		if (max <= H[i]) {
			count += 1;
			max = H[i];
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
struct node
{
    string s;
    int x,num;

} a[105];
int cmp1(node a,node b)
{
    if(a.s==b.s)
    {
        return a.x>b.x;
    }
    else
    {
        return a.s<b.s;
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    int i;
    for(i=1; i<=n; i++)
    {
        cin>>a[i].s;
        scanf("%d",&a[i].x);
        a[i].num=i;
    }
    sort(a+1,a+n+1,cmp1);
    for(i=1; i<=n; i++)
    {
        printf("%d\n",a[i].num);
    }

    return 0;
}


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

int main() {
  int64_t n, a, b;
  cin >> n >> a >> b;
  int64_t repeat = n / (a + b);
  int64_t last;
  if (a < n % (a + b)) last = a;
  else last = n % (a + b);
  
  cout << repeat * a + last << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())
H = [int(i) for i in input().split()]
X = np.ones(N, np.bool)
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] == H[b]:
        X[a] = X[b] = False
    elif H[a] < H[b]:
        X[a] = False
    else:
        X[b] = False
print(np.count_nonzero(X))


Measured memory_bytes: 38464
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 2e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n, a[N], pref[N];

void solve()
{
    cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i], pref[i] = pref[i-1] + a[i];	
    ll ans=0;
    for (int i=1; i<n; ++i) {
    	ans += (((pref[n]-pref[i])%MOD)*(a[i])%MOD)%MOD;
    }nout(ans%MOD);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long f[1005][1005],n,m;
long long a[1005][1005];
char s;
main()
{
  cin>>n>>m;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    {
        cin>>s;
        if(s=='.')
            a[i][j]=1;
        if(s=='#')
            a[i][j]=0;
    }
    f[1][1]=1;
     for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    {
        if(a[i][j]==1)
            f[i][j]=(f[i-1][j]%mod+f[i][j-1]%mod+f[i][j]%mod)%mod;
            else f[i][j]=0;
    }
    cout<<f[n][m]%mod;
}


Measured memory_bytes: 16000
#include <iostream>
#include <stack>

using namespace std;

int main() {
	int W;
	while (cin >> W) {
		stack<int> ans;
		for (int i = 512; i >= 1; i /= 2) {
			if (W - i >= 0) {
				W -= i;
				ans.push(i);
			}
			if (W == 0)
				break;
		}
		int ifs = 1;
		while (ans.empty() != true) {
			if (ifs == 0)
				cout << " ";
			cout << ans.top(); ans.pop();
			ifs = 0;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n-1, ans = 0;
    while(1)
    {
        while(l<r&&s[l]=='R')
            ++l;
        while(l<r&&s[r]=='W')
            --r;
        if(l==r)
            break;
        swap(s[l],s[r]);
        ++ans;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> maze(h+2);
    for(int i=0;i<=h+1;i++){
        if ((i==0) || (i==h+1)) {
            string str(w+2,'.');
            maze[i] = str;
        }else{
            string s;
            cin >> s;
            maze[i] = '.'+s+'.';   
        }
    }
    
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if (maze[i][j] != '#'){
                int cnt = 0;
                if (maze[i-1][j-1]=='#') cnt += 1;
                if (maze[i-1][j]=='#') cnt += 1;
                if (maze[i-1][j+1]=='#') cnt += 1;
                if (maze[i][j-1]=='#') cnt += 1;
                if (maze[i][j+1]=='#') cnt += 1;
                if (maze[i+1][j-1]=='#') cnt += 1;
                if (maze[i+1][j]=='#') cnt += 1;
                if (maze[i+1][j+1]=='#') cnt += 1;
                maze[i][j] = char(cnt+'0');;
            }
        }
    }
    for(int i=1;i<=h;i++){
        string substr = maze[i].substr(1,w);
        cout << substr << endl;
    }

   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100000;
static const int INFTY=(1<<29);
vector<int>G[MAX]; //辺の情報
list<int>out; //出力の順序
bool V[MAX]; //そのノードに対して処理をしたか
int N; //ノードの数
int indeg[MAX]; //ノードの入次数

void bfs(int s){
  queue<int>q;
  q.push(s);
  V[s]=true;

  while(!q.empty()){
    int u=q.front(); q.pop();
    out.push_back(u);
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      indeg[v]--;
      if(indeg[v]==0&&!V[v]){
	V[v]=true;
	q.push(v);
      }
    }
  }
  
}

void tsort(){

  for(int i=0;i<N;i++){
    indeg[i]=0;
  }

  for(int u=0;u<N;u++){
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      indeg[v]++;
    }
  }

  for(int u=0;u<N;u++)
    if(indeg[u]==0&&!V[u]) bfs(u);

  for(list<int>::iterator it=out.begin();it!=out.end();it++){
    cout<<*it<<endl;
  }

}

int main(){
  int s,t,M;
  cin>>N>>M;

  for(int i=0;i<N;i++) V[i]=false;

  for(int i=0;i<M;i++){
    cin>>s>>t;
    G[s].push_back(t);
  }

  tsort();

  return(0);
}



Measured memory_bytes: 6256