akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn search(pcs: &[Vec<usize>], i: usize, ss: usize, pp: usize, flags: &mut [bool], f: &mut FnMut(usize, usize, &[bool])) {
    if i == pcs.len() {
        f(pp, ss, flags);
        return;
    }
    let p = pcs[i][0];
    let c = pcs[i][1];
    let s = p * 100 * (i + 1) + c;
    flags[i] = true;
    search(pcs, i+1, s + ss, p + pp, flags, f);
    flags[i] = false;
    search(pcs, i+1, ss, pp, flags, f);
}

fn main() {
    input!{
        d: usize,
        g: usize,
        pcs: [[usize; 2]; d],
    }
    let mut ans = 100000000000;
    let mut flags = vec![false; d];
    search(&pcs, 0, 0, 0, &mut flags, &mut |p, s, flags| {
        if s >= g {
            ans = min(ans, p);
            // println!("p={} s={} g={} fgs={:?}", p, s, g, flags);
        } else {
            // 中途半端パターン
            let remain = g - s;
            let mut ok = false;
            let mut ii = 0;
            for i in (0..d).rev() {
                if !flags[i] {
                    if pcs[i][0] * (i + 1) * 100 >= remain {
                        ii = i;
                        ok = true;
                    }
                    break;
                }
            }

            if ok {
                let mut num = remain / (100 * (ii + 1));
                if remain % (100 * (ii + 1)) != 0 { num += 1 };
                ans = min(ans, p + num);
                // println!("p={} s={} g={} fgs={:?}", p+num, s+(100 * num * (ii + 1)), g, flags);
            }
        }
    });
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
arr = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(arr[1] - arr[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(arr[i-1] - arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]))

print(dp[-1])

Measured memory_bytes: 85044
#include <stdio.h>

#define INF 1111111111

int N, M, X;
int C[16];
int A[16][16];

int main(void) {
	int i, j;
	int search, smax;
	int answer = INF;
	if (scanf("%d%d%d", &N, &M, &X) != 3) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &C[i]) != 1) return 1;
		for (j = 0; j < M; j++) {
			if (scanf("%d", &A[i][j]) != 1) return 1;
		}
	}
	smax = 1 << N;
	for (search = 0; search < smax; search++) {
		int cost = 0;
		int rikaido[16] = {0};
		int ok = 1;
		for (i = 0; i < N; i++) {
			if ((search >> i) & 1) {
				cost += C[i];
				for (j = 0; j < M; j++) rikaido[j] += A[i][j];
			}
		}
		for (i = 0; i < M; i++) ok = ok && rikaido[i] >= X;
		if (ok && cost < answer) answer = cost;
	}
	printf("%d\n", answer < INF ? answer : -1);
	return 0;
}


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

int main(){


  while(1){

    int T;
    cin>>T;

    
    if(T == 0){
      break;
    }
    
    for(int i=0;i<9;i++){

      int y;
      cin>>y;

      T=T-y;

    }

    

    cout<<T<<endl;
  }   
  
  return 0;
}





Measured memory_bytes: 3084
import math
A, B = map(int, input().split())
if B < A:
    A, B = B, A
a = []
while A % 2 == 0:
    a.append(2)
    A //= 2
f = 3
while f * f <= A:
    if A % f == 0:
        a.append(f)
        A //= f
    else :
        f += 2
if A != 1:
    a.append(A)
ans = 0
for i in set(a):
    if B % i == 0:
        ans += 1
print(ans+1)


Measured memory_bytes: 38512
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		char[] s=sc.next().toCharArray();
		int q=sc.nextInt();
		SegTree st=new SegTree(n);
		for(int i=0; i<n; i++){
			st.set(i,s[i]-'a');
		}
		for(int i=0; i<q; i++){
			int a=sc.nextInt();
			if(a==1){
				int b=sc.nextInt()-1;
				char c=sc.next().charAt(0);
				st.set(b,c-'a');
			}else{
				int b=sc.nextInt()-1;
				int c=sc.nextInt();
				System.out.println(Integer.bitCount(st.query(b,c)));
			}
		}
	}
	static class SegTree{
		int n=1;
		int[] v;
		
		public SegTree(int n) {
			while(this.n<n)this.n*=2;
			v=new int[2*this.n-1];
		}
		
		void set(int k,int val) {
			k+=n-1;
			v[k]=1<<val;
			while(k>0) {
				k=(k-1)/2;
				v[k]=v[2*k+1]|v[2*k+2];
			}
		}
		
		int query(int a,int b) {
			return query(0,n,a,b,0);
		}
		
		int query(int l,int r,int a,int b,int k) {
			if(r<=a||b<=l)return 0;
			else if(a<=l&&r<=b)return v[k];
			else {
				int vl=query(l,(l+r)/2,a,b,2*k+1);
				int vr=query((l+r)/2,r,a,b,2*k+2);
				return vl|vr;
			}
		}
	}
}


Measured memory_bytes: 64144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, c;
	cin >> a >> b >> c;
	if (4 * a * b < (c - a - b) * (c - a - b) && c - a - b > 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3548
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long mod = 1e9 + 7;
map<long long, int> prime_factor(long long n) {
    map<long long, int> ret;

    for (long long i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return ret;
}
long long mod_pow(long long a, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

long long mod_inv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

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

    vector<long long> arr(n);
    vector<map<long long, int>> vec;
    vector<long long> count(1000000);
    rep(i, n) {
        cin >> arr[i];
        vec.push_back(prime_factor(arr[i]));
    }

    for (auto mp: vec) {
        for (auto pn: mp) {
            count[pn.first] = max(count[pn.first], (long long)pn.second);
        }
    }

    long long l = 1;
    for (int i= 2; i <= 1000000; i++) {
        if (count[i]) {
            l *= mod_pow(i, count[i]);
            l %= mod;
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (l * mod_inv(arr[i])) % mod;
        ans %= mod;
    }

    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 11452
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
p1,p2,p3 = 0,0,0
pin = []
for i in range(n):
	p1 += abs(x[i] - y[i])
	p2 += abs(x[i] - y[i])**2
	p3 += abs(x[i] - y[i])**3
	pin.append(abs(x[i] - y[i]))
p2 = p2**(1/2)
p3 = p3**(1/3)
pinf = max(pin)
print(p1)
print(p2)
print(p3)
print(pinf)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll N,K,X,Y;
  cin>>N>>K>>X>>Y;
  ll ans=0;
  if(N<=K){  ans=X*N;}else{
      ans=K*X+(N-K)*Y;
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 200000
#define ll long long
using namespace std;

int main(){
    ll k;
    cin>>k;
    string s;
    cin>>s;
    
    ll l=s.size();
    
    if (k>=l) cout<<s<<endl;
    
    else{
        for (ll i=0; i<k; i++) cout<<s[i];
        cout<<"..."<<endl;
    }
    

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
	while (true) {
		string s;
		cin >> s;
		if (s == "-")break;
		int shuf;
		cin >> shuf;
		for (int i = 0; i < shuf; i++) {
			int num;
			cin >> num;
			s = s.substr(num) + s.substr(0, num);
		}
		cout << s << endl;
	}
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAX_N=11000;
const int MOD=1e9+7;
string S;
int D;

ll dp[MAX_N][111];

ll dfs(int pos, int m, bool limit)
{
	if(pos==(int)S.length()) return m==0;
	if(!limit && dp[pos][m]!=-1) return dp[pos][m];
	ll res = 0;
	int ub = limit ? S[pos]-'0' : 9;
	for(int i=0;i<=ub; ++i){
		res = (res + dfs(pos+1, (m+i)%D, (limit && i==ub)))%MOD;
	}
	res %= MOD;
	if(!limit) dp[pos][m]=res;
	return res;
}

void solve()
{
    memset(dp, -1, sizeof(dp));
	int ans = dfs(0, 0, true) % MOD;
	cout << (ans-1+MOD)%MOD << endl;
}

int main()
{
	cin >> S >> D;
	solve();
	return 0;
}

Measured memory_bytes: 10624
#include<iostream>
 
using namespace std;
 
int main()
{
	int n;
	int *a;
	long long ans = 0;
 
	cin >> n;
 
	a = new int[n];
 
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
 
	int sum = 0;
	long long opr1 = 0,opr2 = 0;
 
	for(int i=0;i<n;i++)
	{
		sum += a[i];
		if(i%2 == 1 && sum <= 0)
		{
			int add = 1 - sum;
			sum += add;
			opr1 += add;
		}
		else if(i%2 == 0 && sum >= 0)
		{
			int add = -1 - sum;
			sum += add;
			opr1 += (add*-1);
		}
	}
 
	sum = 0;
 
	for(int i=0;i<n;i++)
	{
		sum += a[i];
		if(i%2 == 0 && sum <= 0)
		{
			int add = 1 - sum;
			sum += add;
			opr2 += add;
		}
		else if(i%2 == 1 && sum >= 0)
		{
			int add = -1 - sum;
			sum += add;
			opr2 += (add*-1);
		}
	}
 
	ans = min(opr1,opr2);
 
	cout << ans << endl;
 
	delete(a);
 
	return 0;
}

Measured memory_bytes: 640
// 084 B - Postal Code 2017/12/30
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    int len=s.size();
    bool ans=true;
    while(true){
        if(len!=a+b+1) {ans=false; break;}
        if(s[a]!='-') {ans=false; break;}
        rep(i ,a){
            if(s[i]<'0' || s[i]>'9') { ans=false; break; }
        }
        for(int i=a+1;i<len;++i){
            if(s[i]<'0' || s[i]>'9') { ans=false; break;}
        }
        break;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long[] pref = new long[N];
		long[] suff = new long[N];
		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextLong();
		}
		pref[0]=arr[0]; //Prefix and suffix sums using a dp approach
		suff[N-1]=arr[N-1];
		for (int i = 1; i < N; i++) {
			long prev = pref[i-1];
			long cur = arr[i];
			pref[i]=GCD(prev,cur);
		}
		for (int i = N-2; i >=0; i--) {
			long prev = suff[i+1];
			long cur = arr[i];
			suff[i]=GCD(prev,cur);
		}
		long ans = pref[N-1]; //Assuming max GCD is GCD of entire tuple to begin with
		ans=Math.max(ans, suff[1]);//Excluding first number
		ans=Math.max(ans, pref[N-2]);//Excluding last number
		for (int cur = 1; cur < N-1; cur++) {
			int prefIndex = cur-1;
			int suffIndex = cur+1;
			long L = pref[prefIndex];
			long R = suff[suffIndex];
			ans=Math.max(ans, GCD(L,R)); //Excluding intermediate elements
		}
		System.out.println(ans);
	}
	public static long GCD(long a, long b) { //Euclidean GCD
		if (a==0||b==0) return Math.max(a, b);
		return GCD(Math.max(a, b)%Math.min(a, b),Math.min(a, b));
	}
}

Measured memory_bytes: 63120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nk[0];

            var carriage = Enumerable.Range(0, n).Select(e => int.Parse(Console.ReadLine())).ToArray();
            var begin = Math.Max(carriage.Max(), carriage.Sum() / nk[1]);

            var isOK = false;
            for(var p = begin; !isOK; ++p)
            {
                var truck = new long[nk[1]];
                var currentTruck = 0;
                isOK = true;
                for(var k = 0; k < carriage.Length; ++k)
                {
                    if(truck[currentTruck] + carriage[k] > p)
                    {
                        currentTruck++;
                        if (currentTruck == truck.Length)
                        {
                            isOK = false;
                            break;
                        }
                    }
                    truck[currentTruck] += carriage[k];
                }
                if (isOK) Console.WriteLine(p);
            }
        }
    }
}



Measured memory_bytes: 35024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

ll a, b, c, d;

map<ll, ll> m;

ll floor(ll a, ll b) {
    return a / b;
}
ll ceil(ll a, ll b) {
    return (a + b - 1) / b;
}

ll solve(ll x) {
    if (x == 0) return 0;
    if (x == 1) return d;
    if (m.count(x)) return m[x];

    ll l2 = floor(x, 2) * 2;
    ll r2 =  ceil(x, 2) * 2;
    ll l3 = floor(x, 3) * 3;
    ll r3 =  ceil(x, 3) * 3;
    ll l5 = floor(x, 5) * 5;
    ll r5 =  ceil(x, 5) * 5;

    ll res = 1e18;
    if (x < res / d) res = x * d;
    chmin(res, abs(l2 - x) * d + a + solve(l2 / 2));
    chmin(res, abs(r2 - x) * d + a + solve(r2 / 2));
    chmin(res, abs(l3 - x) * d + b + solve(l3 / 3));
    chmin(res, abs(r3 - x) * d + b + solve(r3 / 3));
    chmin(res, abs(l5 - x) * d + c + solve(l5 / 5));
    chmin(res, abs(r5 - x) * d + c + solve(r5 / 5));

    m[x] = res;
    return res;
}

int main() {
    int t; cin >> t;
    rep(_, t) {
        m.clear();
        ll n;
        cin >> n >> a >> b >> c >> d;
        cout << solve(n) << endl;
    }
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o'){
      cout << "vowel" << endl;
  }else{
      cout << "consonant" << endl;
  }
  
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, m, c;
	cin >> n >> m >> c;
	vi b;
	int ans = 0;
	for (int i = 0; i < m; i++) {
		int e; cin >> e;
		b.pb(e);
	}
	for (int i = 0; i < n; i++) {
		int s = c;
		for (int j = 0; j < m; j++) {
			int e; cin >> e;
			s += b[j]*e;
		}
		if (s > 0) ans++;
	}
	cout << ans << ende;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
#define pb push_back

int main(void)
{
    string a,b,c;
    cin >> a >> b >> c;
    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]);
    return 0;
}

Measured memory_bytes: 256
package main

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

type town struct {
	a int
	b int
}

func main() {
	n := readi()
	n %= 10
	if n == 0 || n == 1 || n == 6 || n == 8 {
		fmt.Println("pon")
	} else if n == 3 {
		fmt.Println("bon")
	} else {
		fmt.Println("hon")
	}
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

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

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


Measured memory_bytes: 1856
#include<iostream>
#define min(x,y)(x > y ? y : x)
#define ABS(x)(x<0 ? (-1)*x : x)
using namespace std;
int main(){
	long long int n=0;
	int data[200000];
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++){
		cin>>data[i];
		sum+=data[i];
	}
	sum-=data[0];
	long long int ans=ABS((sum-data[0]));
	long long int A=data[0];
	for(int i=1;i<(n-1);i++){
		A+=data[i];
		sum-=data[i];
		ans=min(ABS((A-sum)),ans);
		long long int T=A-data[i];
		long long int K=sum+data[i];
		ans=min(ABS((T-K)),ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    dp = [[0 for j in range(M+1)] for i in range(N+1)]
    for i in range(N+1):
        dp[i][0] = i
    for j in range(M+1):
        dp[0][j] = j

    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                dp[i+1][j+1] = min(dp[i][j], dp[i+1][j] + 1, dp[i][j+1] + 1)
            else:
                dp[i+1][j+1] = min(dp[i][j], dp[i+1][j], dp[i][j+1]) + 1
    print(dp[N][M])


if __name__ == '__main__':
    main()



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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  auto N = in();
  auto L = in<ll>();
  auto A = in<ll>(N);
  int maxi = 0;
  ll maxv = 0;
  REP(i, N - 1) {
    if (chmax(maxv, A[i] + A[i + 1])) { maxi = i; }
  }
  if (maxv < L) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  rep(i, maxi) { cout << i + 1 << endl; }
  rrep(i, maxi, N - 1) { cout << i + 1 << endl; }
  return 0;
}


Measured memory_bytes: 1664
class Node():
    def __init__(self, key, priority, parent, left, right):
        self.key = key
        self.priority = priority
        self.parent = None
        self.left = None
        self.right = None

def RightRotate(t):
    s = t.left
    t.left = s.right
    s.right = t
    return s

def LeftRotate(t):
    s = t.right
    t.right = s.left
    s.left = t
    return s

def insert(t, key, priority):
    if t == None:
        return Node(key, priority, None, None, None)
    
    if key == t.key:
        return t
    
    if key < t.key:
        t.left = insert(t.left, key, priority)
        if t.priority < t.left.priority :
            t = RightRotate(t)
    
    if key > t.key:
        t.right = insert(t.right, key, priority)
        if t.priority < t.right.priority:
            t = LeftRotate(t)

    return t

def delete(t, key):
    if t == None:
        return None
    if key < t.key:
        t.left = delete(t.left, key)
    elif key > t.key:
        t.right = delete(t.right, key)
    else:
        return _delete(t, key)
    
    return t

def _delete(t, key):
    if t.left == None and t.right == None:
        return None
    elif t.left == None:
        t = LeftRotate(t)
    elif t.right == None:
        t = RightRotate(t)
    else:
        if t.left.priority > t.right.priority:
            t = RightRotate(t)
        else:
            t = LeftRotate(t)
    return delete(t, key)

def find(t, key):
    if t == None:
        print("no")
        return 

    if key == t.key:
        print("yes")
    elif key < t.key:
        find(t.left, key)
    elif key > t.key:
        find(t.right, key)

def print_inorder(t):
    if t == None:
        return
    
    print_inorder(t.left)
    print(" "+str(t.key), end = "")
    print_inorder(t.right)

def print_preorder(t):
    if t == None:
        return 
    print(" "+str(t.key), end = "")
    print_preorder(t.left)
    print_preorder(t.right)

def Main():
    N = int(input())
    t = None

    for i in range(N):
        ope, *arg = input().split()

        if ope == "insert":
            key, priority = map(int, arg)
            t = insert(t, key, priority)

        elif ope == "delete":
            key = int(arg[0])
            t = delete(t, key)

        elif ope == "find":
            key = int(arg[0])
            find(t, key)

        elif ope == "print":
            print_inorder(t)
            print()
            print_preorder(t)
            print()

Main()


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int x;cin>>x&&x;){
		for(int i=1,sum=0;;i++){
			sum+=i;
			if(sum>=x){
				cout<<i<<endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
     
typedef long long ll;
     
const int maxn = 1e5+5;

string s, cnt1, cnt2;
int ans = 1;

int main() {
    	
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	cin >> s;
	
	cnt1 = s[0];
	for (int i = 1; i < s.size(); i ++) {
		cnt2 = s[i];
		if (cnt2 == cnt1) {
			if (i != s.size() - 1) {
				ans ++, i ++;
				cnt1 = s[i] + s[i - 1];
			}
		}
		else {
			ans ++;
			cnt1 = s[i];
		}
	}
	
	cout << ans;
	
    return 0;

}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

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

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

int main() {

    int n;
    cin >> n;
    
    vector<ll> T(n);
    REP(i, n) cin >> T[i];

    ll t = T[0];
    for(int i = 1; i < n; i++) {
        t = lcm(t, T[i]);
    }

    cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,ans=0; cin>>N;
  vector<int64_t> S(N);
  rep(i,N) cin>>S.at(i);
  for(int64_t i=1;i<N;i++){
    if(S.at(i)<S.at(i-1)){
      ans+=S.at(i-1)-S.at(i);
      S.at(i)=S.at(i-1);
    }
  }
  cout<<ans;   
}


Measured memory_bytes: 4788
#include <iostream>
#define max 10

int main() {
    int i = 0;
    char s[max+1], x;
    while (std::cin >> x) {
        if (x == 'B') {
            i--;
            if (i < 0) i = 0;
        }
        else
        s[++i] = x;
    }
    for (int j = 1; j <= i; j++)
        std::cout << s[j];
    return 0;
}


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

int main(){
  int n,count;
  char ch[201];

  while(cin>>n){
    if(n==0)break;
    n=2*n;
    count=0;
    for(int i=0;i<n;i++)
      cin>>ch[i];

    for(int i=0;i+3<=n;i+=4)
      if((ch[i]=='l' && ch[i+1]=='u')&&(ch[i+2]=='r' && ch[i+3]=='u'))count++;
      else if((ch[i]=='l' && ch[i+1]=='d')&&(ch[i+2]=='r' && ch[i+3]=='d'))count++;
      else if((ch[i]=='r' && ch[i+1]=='u')&&(ch[i+2]=='l' && ch[i+3]=='u'))count++;
      else if((ch[i]=='r' && ch[i+1]=='d')&&(ch[i+2]=='l' && ch[i+3]=='d'))count++;
    cout<<count<<endl;
  }
  return 0;
}

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

c = [abs(a[i] - b[i]) for i in range(n)]

for p in range(1, 4):
    ans = 0
    for d in c:
        ans += d ** p
    print("{:.6f}".format(ans ** (1 / p)))

print("{:.6f}".format(max(c)))


Measured memory_bytes: 5672
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;

using namespace std;

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

    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3] || S[3] == S[4])
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


int main(){
    int k;
    cin >> k;
    if(k%2==0){ cout << -1 << endl; return 0;}

    bool flag = false;
    ll ten = 1, tenm = 0;
    for(int i = 1; i <= k; i++){
        tenm = 0;
        ten *= 10;
        ten %= (9 * k);
        tenm += ten - 1;
        tenm %= (9 * k);
        if((7*tenm) % (9*k) == 0){
            cout << i << endl;
            flag = true;
            break;
        }
    }
    if(!flag) cout << -1 << endl;

}

Measured memory_bytes: 3600
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int            long long int
#define ull            unsigned int
#define ld             long double
#define pb             push_back
#define pa             pair<int,int>
#define ppa            pair<pair<int,int>,int>
#define pap            pair<int,pair<int,int>>
#define v1d            vector<int>
#define v2d            vector<vector<int> >
#define vpa            vector<pair<int,int>>
#define M              1000000007
#define MN             LLONG_MIN
#define MX             LLONG_MAX
#define ff             first
#define ss             second
#define endl           "\n"
#define v1s            vector<string>
#define all(v)         v.begin(),v.end()
#define S(v)           sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forIloop(i,n)  for(auto i=0;i<n;i++);
#define forDloop(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
#define isEven(n)  (!n & 1);
const int MOD = 1e9 + 7;
// bool isEven(int n){
//     return (!(n & 1));
// }
// int popcount(int num){
//     num = num - ((num >> 1) & 0x55555555);
//     num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
//     return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
// }
// int powerOfTwo(int n){
//     return 1 << n;
// }

// int arr[1000001];
// bool temet = false;


void codeforce2(){
    string s; cin>>s;
    vector<string> temp{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int index = find(temp.begin(), temp.end(), s) - temp.begin();
    cout << 7 - index << endl;
    return;
    
    
}




int32_t main(){

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // Lucario();
    //codeforceContest();
    //hackerEarth();
    //codeChef();
    codeforce2();

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

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

using namespace std;

int main()
{
    int i, j;
    int n; cin >> n;
    vector<string> s(n); for (i=0; i<n; i++) cin >> s[i];
    int m; cin >> m;
    vector<string> t(m); for (i=0; i<m; i++) cin >> t[i];
    int max_point = 0, point = 0;
    bool different = true;
    vector<string> str(1, s.at(0));
    int str_len = str.size();

    for (i=1; i<n; i++)
    {
        different = true;
        str_len = str.size();
        for (j=0; j<str_len; j++)
        {
            if (str.at(j) == s.at(i)) {different = false; break;}
        }
        if (different) str.push_back(s.at(i));
    }
    for (i=0; i<m; i++)
    {
        different = true;
        str_len = str.size();
        for (j=0; j<str_len; j++)
        {
            if (str.at(j) == t.at(i)) {different = false; break;}
        }
        if (different) str.push_back(t.at(i));
    }

    str_len = str.size();
    for (i=0; i<str_len; i++)
    {
        point = 0;
        for (j=0; j<n; j++)
        {
            if (s.at(j) == str.at(i)) point++;
        }
        for (j=0; j<m; j++)
        {
            if (t.at(j) == str.at(i)) point--;
        }
        if (max_point < point) max_point = point;
    }
    cout << max_point << endl;
}

Measured memory_bytes: 3540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class A {
    static void Main(string[] args) {
        var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = st[0];
        int R = st[1];
        if (N >= 10) {
            Console.WriteLine(R);
            return;
        } else {
            int x = R + 100 * (10 - N);
            Console.WriteLine(x);
        }



    }
}

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

#set():集合でリストとは異なり要素は順番をもたず、重複した要素は取り除かれます。

D=set()
a=[]
b=[]

for i in range(N):
    A,B=input().split()
    #print(A,B)
    #A,B=input().split() これがinsert AAA ならA=insert B=AAA
    a.append(A)
    b.append(B)

for i in range(N): 
    if a[i]=="insert":
        D.add(b[i])
    elif a[i]=="find":
        if b[i] in D:
            print("yes")
        else:
            print("no")



Measured memory_bytes: 149960
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
cin>>n;
ll a[n+1],b[n],su=0;
f(i,0,n+1)
{cin>>a[i];
su+=a[i];
}
f(i,0,n)
cin>>b[i];
ll i=0,ans=0;
while(i<n)
{  ll y,x;
   y=b[i];
   x=a[i]+a[i+1];
   if(y<x)
   {
       ll v=x-y;
       if(v>a[i+1])
       {
        ans+=v-a[i+1];
        a[i]=0;
       }
       else
       {   a[i]=0;
           a[i+1]=v;
       }
   }
   else
   {
       a[i]=0;
       a[i+1]=0;
   }
    i++;
}
ans+=a[n];
c(su-ans);
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,T;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>T;
	int ans=inf;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		if(b<=T){
			ans=min(ans,a);
		}
	}
	if(ans==inf){
		cout<<"TLE"<<endl;
	}else cout<<ans<<endl;
	return 0;
}


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

int main(){

  int A, B;
  cin >> A >> B;

  vector<int> ans;
  ans.push_back(A+B);
  ans.push_back(A-B);
  ans.push_back(A*B);

  sort(ans.begin(), ans.end(), std::greater<int>());

  cout << ans[0] << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=0; i<=n; i++)
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; }
typedef int64_t lint;

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> w(N);
	vector<int> v(N);
	rep(i, N) {
		cin >> w.at(i) >> v.at(i);
	}

	int a=0, b=0, c=0, x, y, z;
	vector<vector<lint>> dp(N+1, vector<lint>(W+1));
	rep(i, N) {
		rep1(j, W) {
			if (j-w.at(i) >= 0) chmax(dp[i+1][j], dp[i][j-w.at(i)] + v.at(i));
			chmax(dp[i+1][j], dp[i][j]);
		}
	}
	cout << dp[N][W] << '\n';
}

Measured memory_bytes: 83160
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String a = sc.next(),b=sc.next(),c=sc.next();
        int ptA=0,ptB=0,ptC=0;

        char next = 'a';
        while(true){
            if(next == 'a'){
                if(ptA==a.length())break;
                next=a.charAt(ptA);
                ptA++;

            }else if(next =='b'){
                if(ptB==b.length())break;
                next=b.charAt(ptB);
                ptB++;

            }else{
                if(ptC==c.length())break;
                next = c.charAt(ptC);
                ptC++;

            }
        }

        if(next =='a')next='A';
        else if(next=='b')next='B';
        else next='C';
        System.out.println(next);




    }
}


Measured memory_bytes: 22612
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
    constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int main(){
	init();

	int n;cin>>n;
	stringv s(n);cin>>s;

	sort(s);

	int ans=n;
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1]) ans--;
	}cout<<ans;
}

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

int main() {

	long N, Q; cin >> N >> Q;

	string S; cin >> S;
	long countac[100009]; countac[1] = 0;

	for (int i = 2; i <= N; i++) countac[i] = (S[i - 2] == 'A' && S[i - 1] == 'C') ? countac[i - 1] + 1 : countac[i - 1];

	long l[100009], r[100009]; for (int i = 1; i <= Q; i++) cin >> l[i] >> r[i];
	
	for (int i = 1; i <= Q; i++) cout << countac[r[i]] - countac[l[i]] << endl;

}

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

int maxhappiness( vector<vector<int>> &day , int n){
 int dp[n][3];

 dp[0][0]=day[0][0];
 dp[0][1]=day[0][1];
 dp[0][2]=day[0][2];
 
 for(int i=1;i<n;i++)
 {
  dp[i][0]=max(dp[i-1][1]+day[i][0],dp[i-1][2]+day[i][0]) ;
  dp[i][1]=max(dp[i-1][0]+day[i][1],dp[i-1][2]+day[i][1]) ;
  dp[i][2]=max(dp[i-1][1]+day[i][2],dp[i-1][0]+day[i][2]) ;	
 
 }

return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) ;

}

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

vector<vector<int>> day(n,vector<int>(3));

for(int i=0;i<n;i++)
{
	for(int j=0;j<3;j++)
	 { int x; cin>>x; day[i][j]=x; }
}

cout<<maxhappiness(day , n) ;



	return 0;
}

Measured memory_bytes: 6912
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)
	x := getInt()
	K := LCM(x, 360)
	out(K / x)
}


Measured memory_bytes: 1772