akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn keta(x: u64) -> usize {
    let mut res = 0;

    let mut n = x;
    while n > 0 {
        res += 1;
        n /= 10;
    }
    res
}

fn main() {
    let n = get!(u64);

    let ans = (1..)
        .take_while(|&x| x * x <= n)
        .filter(|&x| n % x == 0)
        .map(|x| max(keta(x), keta(n / x)))
        .min()
        .unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ll x=a[i];
        ll count=0;
        for(int j=0;j<1000000;j++){
            if(x%2==0){
                x/=2;
                count++;
            }
            else{
                ans+=count;
                break;
            }
        }
        //cout<<count<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import math
n = int(input())

def dev(n,x):
    while n % x == 0:
        print ('',x,end='')
        n //= x
    return n

print ('{}:'.format(n),end='')
n = dev(n,2)
for x in range(3,int(math.sqrt(n))+1,2):
    if n == 1: break
    n = dev(n,x)
if n > 1:
    print ('',n)
else:
    print ('')


Measured memory_bytes: 5664
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
cnt = Counter(A)
Q = int(input())
#print(cnt)
for _ in range(Q):
    B, C = map(int, input().split())
    S -= B*cnt[B]
    S += C*cnt[B]
    cnt[C] += cnt[B]
    cnt[B] = 0
    print(S)

Measured memory_bytes: 94288
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=1000010;

signed main(){
    ll x,k,d;cin>>x>>k>>d;
    ll ans;
    if(x<0)x=-x;
    ll s=x/d;
    if(s+1<=k){
        if(s%2==k%2){
            ans=x%d;
        }else{
            ans=d-x%d;
        }
    }else if(s<=k){
        ans=x%d;
    }else{
        ans=x-d*k;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
function Main(input) {
  input = input.split("\n");
  S=input[0];
  var ans="NO";
  for(var i=0;i<S.length-1;i++){
    for(var j=0;j<S.length;j++){
      S2=S.slice(0,i)+S.slice(j,S.length);
      if(S2=="keyence"){
        ans="YES";
      }
    }
  }

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];  
    int p=0,now=0;
    for(int i = 0; i < n; i++) {
        p++;
        now=a[now]-1;
        if(now==1){
            cout << p << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3708
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	int x[1010], y[1010], z[1010];
	vector<int> v[8];

	cin >> N >> M;
	rep(i, 0, N)
	{
		cin >> x[i] >> y[i] >> z[i];
	}

	rep(i, 0, N)
	{
		v[0].push_back(x[i] + y[i] + z[i]);
		v[1].push_back(x[i] + y[i] - z[i]);
		v[2].push_back(x[i] - y[i] + z[i]);
		v[3].push_back(x[i] - y[i] - z[i]);
		v[4].push_back(-x[i] + y[i] + z[i]);
		v[5].push_back(-x[i] + y[i] - z[i]);
		v[6].push_back(-x[i] - y[i] + z[i]);
		v[7].push_back(-x[i] - y[i] - z[i]);
	}

	int ans = 0;
	rep(i, 0, 8)
	{
		sort(v[i].begin(), v[i].end());
		int t = 0;
		rrep(j, 0, N)
		{
			if (j + M < N)break;
			t += v[i][j];
		}
		chmax(ans, t);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c)
	fmt.Scan(&k)
	arr := make([]int, 3)
	arr[0] = a
	arr[1] = b
	arr[2] = c

	fmt.Println(judge(arr, k))
}

func judge(arr []int, k int) string{
	for i:=0; i<k; i++ {
		m := min(arr)

		if m == 0{
			if arr[0] == arr[1]{
				arr[1] = arr[1] * 2
			}else {
				arr[2] = arr[2] * 2
			}
		} else {
			arr[m] = arr[m] * 2
		}

		if arr[0] < arr[1] && arr[1] < arr[2]{
			return "Yes"
		}
	}
	return "No"
}

func min(arr []int) int {
	min := arr[0]
	var i int
	for s, v := range arr {
		if (v < min) {
			min = v
			i = s
		}
	}
	return i
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
  int x,a;
  cin >> x >> a;
  if(x < a){
    cout << 0 << endl;
  }
  else {
    cout << 10 << endl;
  }
  
}


  

  
    
  
  
 
 





















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 while(1){
  ll n,m;
  cin>>n>>m;
  if(n==0)break;
  vector<ll> h(n),w(m);
  for(ll i=0;i<n;i++)cin>>h[i];
  for(ll i=0;i<m;i++)cin>>w[i];
  map<ll,ll> hh;
  for(ll i=0;i<n;i++){
   ll sum = h[i];
   hh[sum]++;
   for(ll j=i+1;j<n;j++) sum+=h[j],hh[sum]++;
  }
  ll res = 0;
  for(ll i=0;i<m;i++){
   ll sum = w[i];
   res += hh[sum];
   for(ll j=i+1;j<m;j++) sum+=w[j],res+= hh[sum];
  }

  cout<<res<<endl;
 }
    return 0;
}



Measured memory_bytes: 26812
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a;
  int count=0;
  int i=0;
  cin>>n;
  n-=1;
  int b[n];
  for(i=0;i<n;i++){
    cin>>b[i];
  }
  for(i=1;i<n;i++){
    a=min(b[i-1],b[i]);
    count+=a;
  }
  cout<<count+b[0]+b[n-1]<<endl;
}

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vstring s(n);
    rep(i,n) cin>>s[i];
    set<string> st;
    for(auto e:s) st.insert(e);
    cout<<st.size()<<endl;

    return 0;

}

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

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

    map<int, int> mp;
    int d;
    for (int i = 0; i < n; i++)
    {
        cin >> d;
        mp[d]++;
    }
    
    int m;
    cin >> m;
    int t;
    for (int i = 0; i < m; i++)
    {
        cin >> t;

        if (mp[t] == 0) {
            cout << "NO" << endl;
            return 0;
        }
        else mp[t]--;
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 9600
a, b = map(int, input().split())

if a <= 0 <= b:
    ans = "Zero"
elif 0 < a < b:
    ans = "Positive"
else:
    if (b - a) % 2 == 1:
        ans = "Positive"
    else:
        ans = "Negative"

print(ans)


Measured memory_bytes: 2940
MOD = 10**9 + 7
n,m = gets.split.map(&:to_i)
dp = [1]*(n+1)
m.times do
  a = gets.to_i
  dp[a] = -1
end
dp[1] = 0 if dp[1] == -1
(n-1).times do |i|
  if dp[i+2] == -1
    dp[i+2] = 0
  else
    dp[i+2] = (dp[i+1] + dp[i]) % MOD
  end
end
p dp[n]


Measured memory_bytes: 2812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
	
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


struct P { int a, b; };
bool operator<(const P& a, const P& b)
{
	return a.b < b.b;
}
int main()
{
	int n, a[1024], b[1024];
	P p[1024];
	scanf("%d", &n);
	rep (i, n)
		scanf("%d%d", &p[i].a, &p[i].b);
	sort(p, p + n);

	const int INF = 1e8;
	static int dp[1024][1024];
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			dp[i][j] = INF;
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			min_swap(dp[i + 1][j], dp[i][j]);
			if (dp[i][j] + p[i].a <= p[i].b)
				min_swap(dp[i + 1][j + 1], dp[i][j] + p[i].a);
		}
	}
	int res = 0;
	for (int i = 0; i <= n; ++i)
		if (dp[n][i] != INF)
			res = i;
	printf("%d\n", res);
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
  ll n;cin>>n;
  ll er=n*(n+1)/2;
  ll sum=0;
  vector<ll> a(n),c(n);
  bool can=true;
  for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
  }
  if(sum%er!=0){
      cout<<"NO"<<endl;
      return 0;
  }
  //操作回数を決める
  ll times=sum/er;
  //区間の差を求める
  for(int i=0;i<n;i++)c[i]=a[(i+1)%n]-a[i]-times;
//区間は操作のたびに一つがn-1足されそれ以外が-1される
//つまり区間の差に操作回数を引いたものがn-1足されているのを除いたものである
//-1余分に引かれていることを考慮するとその値はnの倍数になることがわかる
//なぜなら用意した区間はちょうど0になる必要があるからだ
  for(int i=0;i<n;i++){
      if(c[i]>0)can=false;
      if(c[i]%n!=0)can=false;
  }
  if(can)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
  


Measured memory_bytes: 1792
const NMAX = 1000000;
type ary = array[1..NMAX] of integer;
var a,b  :ary;
    i,j,k,n  :longint;
    flag:boolean;

procedure sort(p,q :integer; var a,b :ary);
  var i, j, k, w :integer;
begin i := p; j := q; k:=a[(p+q) div 2];
  repeat
    while a[i] < k do i := i+1;
    while k < a[j] do j := j-1;
    if i <= j then begin
      w := a[i]; a[i] := a[j]; a[j] := w;
      w := b[i]; b[i] := b[j]; b[j] := w;
      i := i+1;  j := j-1
    end
  until i > j;
  if p < j then sort(p,j,a,b);
  if i < q then sort(i,q,a,b)
end;

begin
  readln(n);
  flag:=false;
  for i:=1 to n do readln(a[i],b[i]);
  sort(1,n,b,a);
  for i:=1 to n-1 do a[i+1]:=a[i+1]+a[i];
  for i:=1 to n do if b[i]<a[i] then flag:=true;
  if flag then writeln('No') else writeln('Yes')
end.


Measured memory_bytes: 4992
#include <iostream>

int main() {
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;

  int fare = 0;
  if ( A > B ) {
    fare += B;
  } else {
    fare += A;
  }
  if ( C > D ) {
    fare += D;
  } else {
    fare += C;
  }
  std::cout << fare << std::endl;

  return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int> v[2];
    int tmp=0;
    if(s[0]=='0') v[1].push_back(0); //v1 kara kazoeru
    for(int i = 0; i < n; i++)
    {
        if(i==0)
        {
            tmp=1;
        }
        else
        {
            if(s[i]==s[i-1])
            {
                tmp++;
            }
            else
            {
                v[s[i-1]-'0'].push_back(tmp);
                tmp=1;
            }
            
        }
        if(i==n-1)
        {
            v[s[i]-'0'].push_back(tmp);
        }
    }
    if(s[n-1]=='0') v[1].push_back(0); //v1 kara kazoeru
    if(v[0].size()<=k)
    {
        ans=s.size();
    }
    else
    {
        int tmp=0;
        for(int i = 0; i < k; i++)
        {
            tmp+=v[0][i]+v[1][i];
        }
        tmp+=v[1][k];
        ans=tmp;
        //cout<<ans<<endl;
        for(int i = 0; i+k < v[0].size(); i++)
        {
            tmp=tmp-v[0][i]-v[1][i];
            tmp+=v[0][i+k]+v[1][i+k+1];
            ans=max(ans,tmp);
            //cout<<i<<"\t"<<i+k<<"\t"<<tmp<<endl;
        }
        
    }
    

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

Measured memory_bytes: 1020
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N, K;
int kotae;
int ne[100001], H[100001], D;
int dfs(int A) {
	int d = 1;
	D++;
	for (int v = H[A]; v; v = ne[v]) {
		d = max(d, dfs(v) + 1);
	}
	D--;
	if (d >= K && D > 1) {
		kotae++;
		return 0;
	}
	else return d;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	N = getint();
	K = getint();

	if (getint() != 1) kotae++;
	for (int i = 2; i <= N; i++) {
		int a = getint();
		ne[i] = H[a];
		H[a] = i;
	}

	dfs(1);
	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int n;
int a[100005] = {0};
int b[100005] = {0};
int c[100005] = {0};

long long max3(long long x,long long y,long long z)
{
    if (x > y && x > z){
        return x;
    }
    else if (y > x && y > z){
        return y;
    }
    else {
        return z;
    }
}

int main()
{
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    long long dpa[100005];
    long long dpb[100005];
    long long dpc[100005];
    
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    
    for (int i = 1;i < n;i++){
        dpa[i] = max(dpb[i-1],dpc[i-1])+a[i];
        dpb[i] = max(dpc[i-1],dpa[i-1])+b[i];
        dpc[i] = max(dpa[i-1],dpb[i-1])+c[i];
    }
    
    cout << max3(dpa[n-1],dpb[n-1],dpc[n-1]) << endl;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long  n,p;
    cin >> n >> p;
    long long ans=1;
    for(long long i=2;i<=pow((long double)p,(long double)1/n);i++){
      if(n==1) {
        ans=p;
        break;
      }
        if(p%(long long)pow((long double)i,(long double)n)==0) ans=i;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


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

    long long times = N/(A+B);
    long long res = N%(A+B);

    long long ans;
    if(res > A){
        ans = A * (times + 1);
    }else{
        ans = A*times + res;
    }

    
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int out = 0;
	for (int j = 0; j < n; ++j) {
		if (j == n - 1) {
			out += v[j] / 2;
		} else {
			out += v[j];
		}
		
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
template<class T> inline void chmin(T & a, T b) { if (a > b) a = b; }

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

void solve() {
	long long A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
	const long long MAX = 100001;

	long long res = (1 << 30);
	for (int i = 0; i < MAX; i++) {
		chmin(res, ((i * 2 * C) + (max(0LL, X - i) * A) + (max(0LL, Y - i) * B)));
	}

	cout << res << endl;

}

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

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

int main() {
    int n,k,s; cin >> n >> k >> s;
    
    // 4 2 3
    // 1 1 1 1
    
    // 5 3 100
    // 100 100 100 1 1
    
    vector<int> ans;
    for(int i=0;i<k;++i) {
        ans.push_back(s);
    }
    int tmp = s;
    while (!(1 <= tmp && tmp <= 1e9) or tmp == s) tmp = (tmp + 1) % int(1e9);
    for(int i=k;i<n;++i) {
        ans.push_back(tmp);
    }
    
    cout<<ans[0];
    for(int i=1;i<n;++i) {
        cout<<" "<<ans[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3908
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int i,n;
  cin >> n;
  vector<char> s(n);
  for(i=0;i<n;i++) cin >> s[i];
  for(i=0;i<n;i++){
    if(s[i]=='Y'){
      cout << "Four" << "\n";
      return 0;
    }
  }
  cout << "Three" << "\n";
  return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int r = sc.nextInt();
		int max = -sc.nextInt();
		int ans = 0;
		int[] row = new int[r];
		for (int i = 0; i < r; i++) {
			row[i] = sc.nextInt();
		}
		for (int i = 0; i < h; i++) {
			int sum = 0;
			for (int j = 0; j < r; j++) {
				sum = sum + sc.nextInt() * row[j];
			}
			if (sum > max) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int result=0;
    if(n<=k){
        result=n*x;
    }else{
        result=k*x+(n-k)*y;
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-1 0171: Dice Puzzle
// 2017.8.17
// ?????????????????¢??¨??????????????????????????°

#include <stdio.h>
#include <ctype.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };

int con[9][4][3] = { {{0},{0},{0},{0} }, { {0},{0},{0},{0} }, { {1,4,3},{0},{0},{0} },
	{ {2,2,5},{0},{0},{0} }, { {1,2,5},{3,3,4},{0},{0} }, { {1,6,1},{0},{0},{0} },
	{ {2,6,1},{5,4,3},{0},{0} }, { {3,6,1},{6,2,5},{0},{0} }, { {4,6,1},{5,2,5},{7,3,4},{0} } };

char dice[9][8];
char kari[9][8], f[9];

int check(char c1, char c2)
{
	if (c1 <= 'Z' && c2 <= 'Z') return 0;
	if (c1 >= 'a' && c2 >= 'a') return 0;
	return toupper(c1) == toupper(c2);
}

int combi(int n)
{
	int i, j, k, n0, p, p0;
	if (n == 9) return 1;
	for (i = 1; i <= 8; i++) {
		if (f[i]) continue;
		for (j = 0; j < 24; j++) {
			for (k = 1; k <= 6; k++) kari[n][k] = dice[i][rot[j][k]];
			for (k = 0; con[n][k][0]; k++) {
				n0 = con[n][k][0], p = con[n][k][1], p0 = con[n][k][2];
				if (!check(kari[n0][p], kari[n][p0])) goto Next;
			}
			f[i] = 1;
			if (combi(n + 1)) return 1;
			f[i] = 0;
		Next:;
		}
	}
	return 0;
}

int main()
{
	int i;

	while (1) {
		for (i = 1; i <= 8; i++) {
			scanf("%s", dice[i] + 1);
			if (i == 1 && dice[i][1] == '0') return 0;
			f[i] = 0;
		}
		puts(combi(1) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}
 int main(){
     int N;
     cin >> N;
     vector<ll> A(N);
     rep(i,N) cin >> A[i];
     if (A[0]!=0){
         cout << -1 << endl;
         return 0;
     }
     ll ans=0;
     rep(i,N-1){
         int n=A[i]+1;
         if (A[i+1]>n){
             cout << -1 << endl;
             return 0;
         }
         if (A[i+1]<n){
             ans+=A[i];
         }
     }
     ans+=A[N-1];
     cout << ans << endl;
 }

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
 
typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;
 
bool TEST=false;
ll MOD = 1000000007;
 
void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
 
ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll gcd(ll x,ll y){
    while (y>0){
        x=x%y;
        swap(x,y);
    }
    return x;
}

v_bool primes(ll n){
    v_bool x(n+1,true);
    x[0]=false;x[1]=false;
    for (ll i=2;i<=n;i++){
        if (x[i]){
            for(ll j=i*2;j<=n;j+=i){
                x[j]=false;
            }
        }
    }
    return x;
}

ll A,B,C;
int main(){
  cin >> A >> B;
    C=gcd(A,B);
    ll c=C;
    ll ans=1;
    v_bool p=primes(1000000);
    for(ll i=2;i<p.size();i++){
        if (p[i]&&(C%i==0)) ans++;
        while(c%i==0)c/=i;
    }
    if (c>1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
char *P[]={"No","Yes"};
char f;

int a, b, i;
char c;
int main(){
	f=1;
	scanf("%d%d\n", &a, &b);
	for(i=0; i<a; i++){
		if(getchar()=='-'){f=0;}
	}
	if(getchar()!='-'){f=0;}
	for(i=0; i<b; i++){
		if(getchar()=='-'){f=0;}
	}
	puts(P[f]);
}


Measured memory_bytes: 128
#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 FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define FORE(i, a, n) for (i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define all(n) (n).begin(), (n).end()

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>

#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)

#define mod 1000000007
#define inf 1e18

#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// ############################################################################################

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2) res = (res * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return res % mod;
}

void a_k_s() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
}

double dp[301][301][301];

double solve(int x, int y, int z, int n) {
    if (x < 0 || y < 0 || z < 0) {
        return 0;
    }

    if (x == 0 && y == 0 && z == 0) {
        return 0;
    }

    if (dp[x][y][z] > -0.9) {
        return dp[x][y][z];
    }

    double exp = n + x * solve(x - 1, y, z, n) + y * solve(x + 1, y - 1, z, n) + z * solve(x, y + 1, z - 1, n);
    exp /= (x + y + z);

    return dp[x][y][z] = exp;
}

int main() {
    a_k_s();

    int n, x;
    cin >> n;
    memset(dp, -1, sizeof dp);

    int one = 0, two = 0, three = 0;

    FOR(i, 1, n + 1) {
        cin >> x;
        if (x == 1)
            one++;
        else if (x == 2)
            two++;
        else
            three++;
    }

    cout << fixed << setprecision(10) << solve(one, two, three, n) << endl;

    return 0;
}

Measured memory_bytes: 216900
#include <stdio.h>
#define INF 2000000000
int N, A[300002], diff;

void update(int i, int v){
  int d1 = 0, d2 = 0;
  if ( A[i-1] > A[i] ) d1++;
  if ( A[i] > A[i+1] ) d1++;
  A[i] = v;
  if ( A[i-1] > A[i] ) d2++;
  if ( A[i] > A[i+1] ) d2++;
  diff += (d2 - d1);
}

int solve(){
  int a, b, q, v1, v2, i;
  diff = 0;
  for ( i = 1; i <= N; i++ ) {
    if ( A[i-1] > A[i] ) diff++;
  }

  if ( diff == 0 ) return 0;

  scanf("%d", &q);
  for ( i = 1; i <= q; i++ ){
    scanf("%d %d", &a, &b);
    v1 = A[a];
    v2 = A[b];
    update(a, v2);
    update(b, v1);
    if ( diff == 0 ) return i;
  }

  return -1;
}

int main() {
  int i;
  scanf("%d", &N);
  for ( i = 1; i <= N; i++ ) scanf("%d", &A[i]);
  A[0] = -INF;
  A[N+1] = INF;
  printf("%d\n", solve());
  return 0;
}


Measured memory_bytes: 3028
sa=list(input())
sb=list(input())
sc=list(input())

sa_rev=sa[::-1]
sb_rev=sb[::-1]
sc_rev=sc[::-1]

turn="a"
while True:
  if turn=="a":
    if not sa_rev:
      print("A")
      break
    else:
      turn=sa_rev.pop()
  elif turn=="b":
    if not sb_rev:
      print("B")
      break
    else:
      turn=sb_rev.pop()
  elif turn=="c":
    if not sc_rev:
      print("C")
      break
    else:
      turn=sc_rev.pop() 

Measured memory_bytes: 3064
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P, X = [], []
ans = []
for i in range(M):
    p, x = map(int, input().split())
    p -= 1
    a = sum(T)
    a -= T[p]
    a += x
    ans.append(a)

for i in range(M):
    print(ans[i])

Measured memory_bytes: 3064
package main

import "fmt"

func main(){
	var a, b int
	for {
		fmt.Scan(&a, &b)
		if a == 0 && b == 0 {
			break
		}
		if a > b{
			b, a = a, b
		}
		fmt.Printf("%d %d\n", a, b)
	}
}


Measured memory_bytes: 1236
import sys
f = sys.stdin

from datetime import timedelta

def formatHHMMSS(delta):
    return '{:02d}:{:02d}:{:02d}'.format(delta.seconds // 3600, delta.seconds % 3600 // 60, delta.seconds % 60)

while True:
    leave_time = timedelta(hours=2)
    h, m, s = map(int, f.readline().split())
    if h == m == s == -1:
        break
    record_time =  timedelta(seconds=s, minutes=m, hours=h)
    leave_time -= record_time
    print(formatHHMMSS(leave_time))
    print(formatHHMMSS(leave_time * 3))

Measured memory_bytes: 7064
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

#define MAX_N 128
int G[MAX_N][MAX_N];
int n;
int sz[MAX_N];
int d[MAX_N];
int f[MAX_N];

int t;
void dfs(int v) {
	int i;
	if (d[v]) return;
	d[v] = t++;
	for (i = 0; i < sz[v]; i++) {
		dfs(G[v][i]);
	}
	f[v] = t++;
}

int main(int argc, char **argv)
{
	int i, j, u, k, v;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		sz[u] = k;
		for (j = 0; j < sz[u]; j++) {
			scanf("%d", &v);
			G[u][j] = v;
		}
	}


	t = 1;
	for (i = 1; i <= n; i++) {
		dfs(i);
	}

	for (i = 1; i <= n; i++) {
		printf("%d %d %d\n", i, d[i], f[i]);
	}

	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<bool>> rt(N,vector<bool> (N,false));
    vector<int> memo(N-1);
    iota(all(memo),1);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        rt[a-1][b-1] = true;
        rt[b-1][a-1] = true;
    }
    ll ans = 0;
    do {
        bool state = false;
        if(rt[0][memo[0]]){
            state = true;
            for(int i=1;i < N-1;i++){
                if(!rt[memo[i-1]][memo[i]]){
                    state = false;
                    break;
                }
            }
        }
        if(state) ans++;
    } while( next_permutation(memo.begin(), memo.end()) );     // 次の順列を生成

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//





//入力
int N;
ll h[100010];

//メモ用のDPテーブル
ll dp[100010];

ll rec(int i){
        //DPの値が更新されていたらそのままリターン
        if(dp[i] < IMF) return dp[i];

        //足場0のコストは0
        if(i == 0) return 0;

        //i-1, i-2 それぞれ試す
        ll res = IMF;
        chmin(res, rec(i-1)+abs(h[i] - h[i-1]));
        if(i > 1) chmin(res, rec(i-2) + abs(h[i] - h[i-2]));


        //結果をメモしながら返す
        return dp[i] = res;
}

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

        //初期化(最小化問題なのでIMFに初期化)
        for(int i = 0; i < 100010; i++) dp[i] = IMF;

        //答え
        cout << rec(N-1) << endl;
}

















































Measured memory_bytes: 6528
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] aArr = new int[n];

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        int res = 0;
        for (int i = 0; i < aArr.length; i++) {

            while (i+1<aArr.length && aArr[i] == aArr[i+1]) {
                // 一つ先の文字が同じだったらindexを次に進める
                i++;
            }

            if (i+1<aArr.length && aArr[i+1] > aArr[i]) {
                // 単調増加
                while (i+1<aArr.length && aArr[i+1] >= aArr[i]) {
                    // >=とすることで単調増加の数列の中での同じ数値をスキップしていく
                    i++;
                }
            } else if (i+1<aArr.length && aArr[i+1] < aArr[i]){
                // 単調減少
                while (i+1<aArr.length && aArr[i+1] <= aArr[i]) {
                    // <=とすることで単調増加の数列の中での同じ数値をスキップしていく
                    i++;
                }
            }

            res++;
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 48580
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K-a[i]:
    j-= 1
  ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 126844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
string s;
cin >> s;
for(int i=0;i<s.size()-8;i++){
    cout << s.at(i);
}
cout << 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 = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;



int main(){
  
  int n,m,k;
  cin >> n >> m >> k;
  vector<vector<int>> dp(n+1,vector<int>(m+1));
  dp[0][0] = 0;
  set<int> st;
  st.insert(0);
  rep(i,n){
    rep(j,m){
      dp[i+1][j] = dp[i][j]+m-j*2;
      st.insert(dp[i+1][j]);
      dp[i][j+1] = dp[i][j]+n-i*2;
      st.insert(dp[i][j+1]);
    }
  }
  if(st.count(k)>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 20288
from collections import Counter

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

if len(set(v)) <= 1:
    print(int(n/2))
    exit()

odd = [v[i] for i in range(0, n, 2)]
odd_val, odd_cnt = zip(*Counter(odd).most_common())

even = [v[i] for i in range(1, n, 2)]
even_val, even_cnt = zip(*Counter(even).most_common())

if even_val[0] != odd_val[0]:
    ans = n-even_cnt[0]-odd_cnt[0]
else:
    if (even_cnt[0] + odd_cnt[1]) >= (even_cnt[1] + odd_cnt[0]):
        ans = n-even_cnt[0]-odd_cnt[1]
    else:
        ans = n-even_cnt[1]-odd_cnt[0]
print(ans)


Measured memory_bytes: 25572
import java.util.Scanner;

class Vertex {
	int state;
	int distance;
	static final int INF = 1000000000;
	Vertex() {
		state = 0;
		distance = INF;
	}
}
public class Main {
	static int N;
	static int W[][];
	static  Vertex vertex[];

	private static int min(int a, int b) {
		if (a < b)
			return a;
		return b;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();

		W = new int[N][N];
		vertex = new Vertex[N];

		for (int i = 0; i < N; i++) {
			vertex[i] = new Vertex();
			for (int j = 0; j < N; j++) {
				W[i][j] = Vertex.INF;
			}
		}

		for (int i = 0; i < N; i++) {
			sc.nextInt(); // u を読み飛ばし
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int v = sc.nextInt();
				int c = sc.nextInt();
				W[i][v] = c;
			}
		}
		dijkstra(0);
		for (int i = 0; i < N; i++) {
			System.out.println(i + " " + vertex[i].distance);
		}
	}

	private static void dijkstra(int start) {
		vertex[start].distance = 0;

		int p = 0; // 確定頂点番号を保存する変数
		for (int step = 0; step < N; step++) {
			int minimum = Vertex.INF;
			for (int x = 0; x < N; x++) {
				if (vertex[x].state == 0 && vertex[x].distance < minimum) {
					p = x;
					minimum = vertex[x].distance;
				}
			}
			vertex[p].state = 1;
			for (int x = 0; x < N; x++)
				vertex[x].distance = min(vertex[x].distance, vertex[p].distance + W[p][x]);
		}

	}
}



Measured memory_bytes: 40192
// https://atcoder.jp/contests/abc163/tasks/abc163_c

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	fmt.Fscanf(in, "%d\n", &n)
	arr := make([]int, n+1)

	for i := 0; i < n-1; i++ {
		var temp int
		fmt.Fscanf(in, "%d ", &temp)
		arr[temp-1]++
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(out, arr[i])
	}
}


Measured memory_bytes: 6284
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans=1;
		for(int i=2;i<=n;i++){
			ans*=i;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 17160
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

bool isSame(int s, int t, int u, int sec, int min, int hour)
{
    vector<int> a(3), b(3);
    a[0] = s;
    a[1] = t;
    a[2] = u;
    b[0] = sec;
    b[1] = min;
    b[2] = hour;
    sort(a.begin(), a.end());

    for(int i=0; i<3; ++i){
        vector<int> c = b;
        for(int j=0; j<3; ++j){
            c[j] += a[i] - b[0] + 60;
            c[j] %= 60;
        }
        sort(c.begin(), c.end());
        if(a == c)
            return true;
    }
    return false;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> s(n), t(n), u(n);
        for(int i=0; i<n; ++i)
            cin >> s[i] >> t[i] >> u[i];

        queue<pair<int, int> > q;
        vector<int> m(n, 0);
        int numZero = n;
        int ret = -1;
        int len = INT_MAX;
        for(int i=0; i<12*60*60; ++i){
            int sec = i % 60;
            int min = i / 60 % 60;
            int hour = i / (60 * 12);

            for(int j=0; j<n; ++j){
                if(isSame(s[j], t[j], u[j], sec, min, hour)){
                    if(m[j] == 0)
                        -- numZero;
                    ++ m[j];
                    q.push(make_pair(i, j));
                }
            }

            while(numZero == 0){
                if(i - q.front().first < len){
                    len = i - q.front().first;
                    ret = q.front().first;
                }
                if(m[q.front().second] == 1)
                    ++ numZero;
                -- m[q.front().second];
                q.pop();
            }
        }

        for(int i=0; i<2; ++i){
            int sec = (ret + i*len) % 60;
            int min = (ret + i*len) / 60 % 60;
            int hour = (ret + i*len) / (60 * 12);
            ostringstream oss;
            oss << setfill('0');
            oss << setw(2) << (hour/5) << ':' << setw(2) << min << ':' << setw(2) << sec;
            cout << oss.str();
            if(i == 0)
                cout << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int l, r, d;
int main() {
	scanf("%d %d %d", &l, &r, &d);
	int cnt = 0;
	for (int i = l; i <= r; i++)
		if (i % d == 0)
			cnt++;
	printf("%d\n", cnt);
}

Measured memory_bytes: 1704
N ,W = map(int,input().split())
INF = float('inf')
w = [0] * N
v = [0] * N

for i in range(N):
    w[i],v[i] = map(int,input().split())
vsum = sum(v)
dp = [[INF] * (vsum + 1) for i in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(vsum + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])
ans = 0
for j in range(vsum + 1):
    if dp[N][j] <= W:
        ans = j
print(ans)


Measured memory_bytes: 250180