akhauriyash/Code-Regression huggingface dataset:
stay_day = int(input())
first_stay_day = int(input())
first_stay_cost = int(input())
second_stay_cost = int(input())

if stay_day <= first_stay_day:
    cost = first_stay_cost * stay_day
elif stay_day > first_stay_day:
    cost = first_stay_cost * first_stay_day + second_stay_cost * (stay_day - first_stay_day)

print(cost)

Measured memory_bytes: 2940
def main():
    A = [int(i) for i in input().split()]
    A.sort()
    B = [A[2]-A[0], A[2]-A[1]]
    ans = 0
    if all(b % 2 == 0 for b in B):
        ans += sum(b//2 for b in B)
    elif all(b % 2 == 1 for b in B):
        ans += sum((b-1)//2 for b in B) + 1
    else:
        ans += sum(b//2 for b in B) + 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
d = {}
m = 0
mw = ''
for w in raw_input().lower().split():
    if w in d:
        d[w] += 1
    else:
        d[w] = 1
    if len(w) > m:
        m = len(w)
        mw = w
print max(d.keys(), key=lambda x:d[x]), mw

        

Measured memory_bytes: 6240
S = ' ' + input()
even_pat = ['R','U','D']
odd_pat = ['L','U','D']

flag = True

for i in range(1,len(S)):
    if i % 2 == 1:
        if not(S[i] in even_pat):
            flag = False
            break
    
    else:
        if not(S[i] in odd_pat):
            flag = False
            break

print('Yes' if flag else 'No')

Measured memory_bytes: 3060
/*....
     
 "Be not afraid of GROWING slowly, be afraid only of STANDING Still"
                                                                     
....*/
#include<bits/stdc++.h>
#define Abhi_921 ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define fi(i,j,n) for(int i=j;i<n;i++)
#define fd(i,j,n) for(int i=j;i>n;i--)
#define print(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define printe(v) for(auto &i:v){cout<<i<<' ';}cout<<endl;
#define deb(n1) cout<<n1<<endl;
#define pb push_back
#define eb emplace_back
#define vi vector<ll>
#define vll vector<pair<ll,ll>>
#define umap unordered_map<ll,ll>
using namespace std;
const long long mod=1e9+7;
int n,a[100005];
int dp[100005];
ll solve(int i){
    if(i==n-1) return 0; 
    if(dp[i]!=-1) return dp[i];
    int l=abs(a[i]-a[i+1])+solve(i+1);
    int r=INT_MAX;
    if(i+2<n){
    r=abs(a[i]-a[i+2])+solve(i+2);
    }
    return dp[i]=min(l,r);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
Abhi_921;
int t;
t=1;
while(t--){
cin>>n;
fi(i,0,n) cin>>a[i];
memset(dp,-1,sizeof(dp));
cout<<solve(0);
}
return 0;
}

Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(a) (int)a.size()
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef db T;
struct P{
  T x,y; P(){} P(T x,T y):x(x),y(y){}
  P operator - (const P&b) const {return P(x-b.x,y-b.y);}
  P operator + (const P&b) const {return P(x+b.x,y+b.y);}
  T operator * (const P&b) const {return x*b.x+y*b.y;}
  P operator * (const T&k) const {return P(x*k,y*k);}
};
T norm(P a){return a*a;}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}
P reflect(P p,P a,P b){return proj(p,a,b)*2-p;}

P a, b, p;

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	cin >> a.x >> a.y >> b.x >> b.y;
	int q;
	cin >> q;
	cout << setiosflags(ios::fixed);
	cout << setprecision(10);
	while(q--) {
		cin >> p.x >> p.y;
		P r = reflect(p, a, b);
		cout << r.x << " " << r.y << endl;
	}
	return 0;
}


Measured memory_bytes: 3324
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[]a=new int[n];
        int[]b=new int[n];
        int[]c=new int[n-1];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt()-1;
        }
        for(int i=0;i<n;i++){
            b[i]=sc.nextInt();
        }
        for(int i=0;i<n-1;i++){
            c[i]=sc.nextInt();
        }
        int index=-2;
        int ans=0;
        for(int i=0;i<n;i++){
            ans+=b[a[i]];
            if(index+1==a[i]){
                ans+=c[a[i]-1];
            }
            index=a[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22228
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e12;
const ll inf=1e18;
const ll ms=10000000;
fast;
ll n,m,ans;
string s;
void solve()
{
    cin>>s;
    ll i=0,j=s.size()-1;
    while(i<j)
    {
        if(s[i]!=s[j])
            ans++;
        i++;j--;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define one cout<<"-1"<<endl;
#define pi 3.141592653589793238
#define mod 1000000007
#define intmx INT_MAX 
#define intmi INT_MIN
int d[10000];
void solve(){
    int n,x;
    cin>>n>>x;
    int l[n],cnt=1;
    d[0]=0;
    ff(i,0,n){
        cin>>l[i];
        d[i+1]=d[i]+l[i];
        if(d[i+1]<=x)
        cnt++;
    }
    cout<<cnt<<endl;
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] nks = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nks[0];
        var k = nks[1];
        var s = nks[2];

        long count = 0;
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
        {
            if (count < k)
            {
                ans[i] = s;
                count++;
            }
            else
            {
                if (s == Math.Pow(10,9))
                {
                    ans[i] = s- 1;
                }
                else
                {
                    ans[i] = s + 1;
                }
                
            }
        } 

        for (int i = 0; i < n; i++)
        {
             Console.Write(ans[i] + " ");
        }
    }
}

Measured memory_bytes: 17972
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b,c,d = LI()
print(max(a*b,c*d))
#B

#C
"""
def factor(n):
    i = 2
    m = n
    while m >= i:
        while m%i == 0:
            m //= i
            d[i] += 1
            d[i] %= mod
            if m < i:break
        i += 1
n = I()
d = defaultdict(int)
for i in range(2,n+1):
    factor(i)
ans = 1
for i in d.values():
    ans *= i+1
    ans %= mod
print(ans)
"""

#D
"""
n,a,b = LI()
x = LI()
ans = 0
for i in range(n-1):
    if a*(x[i+1]-x[i]) > b:
        ans += b
    else:
        ans += a*(x[i+1]-x[i])
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    long long int n,a,b;
    cin>>a>>b>>n;
    long long int x;
    if(b!=n)
        x=min(b,n);
    else
        x=n-1;
    if(n==1)
    {
        if(b==1)
            cout<<0;
        else
            cout<<a/b;
    }
    else if(b==1)
        cout<<0;
    else if(a==b)
    {
        cout<<x;
    }
    else
    {
        long long int ans;
        if(x==b)
        {
            x--;
            ans=((a*x)/b-a*(x/b));
        }
        else
        {
            ans=((a*x)/b-a*(x/b));
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N+1);
    A[0] = INF;
    for (ll i = 1; i <= N; i++) {
        cin >> A[i];
    }   

    sort(ALL(A), greater<ll> ());

    vector<ll> S(N+1);
    S[0] = 0;
    for (ll i = 1; i < N+1; i++) {
        S[i] = A[i] + S[i-1];
    }

    ll ans = P;

    for (ll k = P+1; k < N+1; k++) {
        if(A[k] + M < A[P]){
            break;
        }
        if(M*N + (k-P) * A[k] - S[k-1] + S[P-1] >= M*V){
            ans++;
        }
    }
    printf("%lld\n", ans);



}

Measured memory_bytes: 4804
import sys
from heapq import*
from collections import*

input=sys.stdin.readline


p=defaultdict(lambda: -1)
class UNION_FIND(object):
    def __init__(self,n):
        
        self.parent=defaultdict(lambda: -1)

    def root(self,x):
        if type(self.parent[x])!=tuple:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]
 
    def size(self,x):
        return -self.parent[self.root(x)]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]
        self.parent[y]=x
        return True
def compute_mst_kruskal(max_v, edges, flip):
    edges.sort(key=lambda x: x[2],reverse=flip)
    #print(edges)
    uf = UNION_FIND(max_v)
    mst = []
    for (a,b,c) in edges:
        if uf.root(a)!= uf.root(b):
            uf.union(a,b)
            mst.append(c)
    return mst


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

x=sorted(points,key=lambda x:x[0])
y=sorted(points,key=lambda x:x[1])
#print(x,y)


edges = []
for i in range(1,n):
    (a,b),(c,d)=x[i-1],x[i]
    (e,f),(g,h)=y[i-1],y[i]
    heappush(edges,((a,b),(c,d),abs(a-c)))
    heappush(edges,((e,f),(g,h),abs(f-h)))
#print(edges)
mst = compute_mst_kruskal(n, edges , 0) #0が最小化
print(sum(mst))


Measured memory_bytes: 89408
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(20)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    string S;
    cin >> S;
    if(S.size() == 3){
        reverse(all(S));
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;

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

  int l = 0;
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') cnt++;
    else {
      if (cnt == 0) l++;
      else cnt--;
    }
  }

  int r = cnt;
  string res = "";
  for (int i = 0; i < l; i++) res += '(';
  res += s;
  for (int i = 0; i < r; i++) res += ')';
  cout << res << endl;
  return 0;
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int a=0,b=0,c=0,d=0;
  rep(i,n){
    string s;
    cin >> s;
    if(s=="AC"){
      a++;
    }
    else if(s=="WA"){
      b++;
    }
    else if(s=="TLE"){
      c++;
    }
    else if(s=="RE"){
      d++;
    }
  }
  cout << "AC x "<< a <<endl;
  cout << "WA x "<< b <<endl;
  cout << "TLE x "<< c <<endl;
  cout << "RE x "<< d <<endl;

  return 0;

}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,a,sum,i;
while(~scanf("%d",&n))
{sum=0;
    if(n==1)
    {
        printf("Hello World\n");
    }
    if(n==2)
    {
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        sum=sum+a;
    }
    printf("%d\n",sum);
}
}
   }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> cnt(10,vector<ll>(10,0));
    for(ll i=1;i<=n;i++){
        ll a,b;
        b=i%10;
        a=i;
        while(a/10>0) a/=10;
        cnt[a][b]++;
    }
    ll sum=0;
    for(ll i=1;i<10;i++){
        for(ll j=1;j<10;j++){
            sum+=cnt[i][j]*cnt[j][i];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,d[111]={},i,j,c=1;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&d[i]);

	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			if(d[i]<d[j]){
				d[i]+=d[j];
				d[j]=d[i]-d[j];
				d[i]=d[i]-d[j];
			}
	for(i=0;i<n-1;i++)
		if(d[i]>d[i+1])
			c++;
	printf("%d",c);
	return 0;
}

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

bool f(int t,int x,int y){
    return (t+x+y)%2;
}

int main() {
    int n; cin >> n;
    vector<int> t(n),x(n),y(n);
    rep(i,n){
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    bool a=0;

    int T=0,X=0,Y=0;

    rep(i,n){
        if(f(t.at(i),x[i],y[i]) || t[i]-T<abs(X-x[i])+abs(Y-y[i]) ){
            cout << "No" << endl;
            return 0;
        }
        else {
            T=t[i];
            X=x[i];
            Y=y[i];
        }
    }

    cout << "Yes" << endl;

}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            char[] S = Console.ReadLine().ToCharArray();

            int count = N;

            for(int i = 1; i < N; i++)
            {
                if (S[i] == S[i - 1])
                {
                    count -= 1;
                }
            }

            Console.WriteLine(count);
        }

    }
}

Measured memory_bytes: 13536
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll n,k;cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    ll ans= 0;
    for(int i=0;i<k;i++) ans+=arr[i];
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3660
import java.io.*;
import java.util.*;



public class Main {

    static MyScanner ob = new MyScanner();
    static   PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    static int N ;
    static int [] A;
     static char[][] arr = new char[100][1000];
    public static void main(String args[]) throws IOException {
     int A = ob.nextInt(); int B = ob.nextInt();
     pw.println(A*B);
        
      pw.flush();
        
    }

  
    static boolean check (int i, int j,int n ,int m){
        if(j+1<m){
            if(arr[i][j]=='.'&&arr[i][j+1]=='.'){
                return true;
            }
            return false;
        }
        return false;
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> d(n, vector<int>(2));
  rep(i,n)rep(j,2) cin >> d[i][j];
  rep(i,n-2){
    if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3632
import math
ops = []
kekka = []

while True:
    op = [e for e in input().split()]
    if op[1]=="?":
        break
    ops.append(op)

for i in range(len(ops)):
    if ops[i][1]=="+":
        sum = int(ops[i][0]) + int(ops[i][2])
        kekka.append(sum)
    elif ops[i][1]=="-":
        hiku = int(ops[i][0]) - int(ops[i][2])
        kekka.append(hiku)
    elif ops[i][1]=="*":
        kakeru = int(ops[i][0]) * int(ops[i][2])
        kekka.append(kakeru)
    elif ops[i][1]=="/":
        waru = math.floor(int(ops[i][0]) / int(ops[i][2]))
        kekka.append(waru)

for j in kekka:
    print(int(j))


Measured memory_bytes: 5680
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int x;cin>>x;
    if(x>=400&&x<=599)cout<<8;
    if(x>=600&&x<=799)cout<<7;
    if(x>=800&&x<=999)cout<<6;
    if(x>=1000&&x<=1199)cout<<5;
    if(x>=1200&&x<=1399)cout<<4;
    if(x>=1400&&x<=1599)cout<<3;
    if(x>=1600&&x<=1799)cout<<2;
    if(x>=1800&&x<=1999)cout<<1;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>

int main(){
  int n,i,tmp;
  std::cin >> n;
  int h[100000];
  std::string ans="Yes";
  std::cin >> h[0];
  for (i = 1; i < n; ++i){
    std::cin >> tmp;
    if (tmp==h[i-1]){
      --n;
      --i;
    }
    else h[i]=tmp;
  }
  for (i = 0; i < n-1; i++) {
    if(h[i]-h[i+1]>1){
      ans="No";
      i=n;
    }else if(h[i]-h[i+1]==1)h[i]--;
  }
  for (i = 0; i < n-1; ++i){
    if(h[i]>h[i+1]){
      ans="No";
      i=n;
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    string S;
    cin >> S;
 
    vector<string> tokens = {"dream", "dreamer", "erase", "eraser"};
 
    while (S.size() > 0) {
        bool hit = false;
        for(int i=0; i<tokens.size(); i++) {
            string t = tokens[i];
            if (S.size() >= t.size() && S.substr(S.size() - t.size(), t.size()) == t) {
                S = S.substr(0, S.size() - t.size());
                hit = true;
                break;
            }
        }
        if (!hit) {
            cout << "NO" << endl;;
            return 0;
        }
    }
 
    cout << "YES" << endl;;
    return 0;
}


Measured memory_bytes: 3760
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] X = new int[N][D];
		int count = 0;
		for(int i=0;i<N;i++){
		    for(int j=0;j<D;j++){
		        X[i][j] = sc.nextInt(); 
		    }
		}
		
		for(int i=0;i<N-1;i++){
		    for(int j=i+1;j<N;j++){
		        int sum = 0;
		        for(int k=0;k<D;k++){
		            sum += Math.pow(X[i][k]-X[j][k],2);
		        }
		        double result = Math.sqrt(sum);
		        if(result == (int)result)count++;
		    }
		}
		System.out.println(count);
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  rep (i, N) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  map<string, int> m;
  rep (i, N) {//比較の部分はVectorだとTLEになる。メモリ節約でmapを使う！
    m[s[i]]++;
  }
  int64_t ans = 0;
  for (auto x : m) {
    uint64_t s = x.second;
    ans += s*(s-1)/2ll;
  }
  cout << ans << endl;

}


Measured memory_bytes: 18176
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int a[200010];
int main(){
    int n,i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(j=n;j>=1;j-=2) printf("%d ",a[j]);
    if(j==-1) j=2;
    else j=1;
    for(;j<=n;j+=2) printf("%d ",a[j]);
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  string S;
  cin >> S;
  int out;
  if (S == "SUN") {
    out = 7;
  } else if (S == "MON") {
    out = 6;
  } else if (S == "TUE") {
    out = 5;
  } else if (S == "WED") {
    out = 4;
  } else if (S == "THU") {
    out = 3;
  } else if (S == "FRI") {
    out = 2;
  } else if (S == "SAT") {
    out = 1;
  }

  cout << out << endl;

  return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
if a%2==0 and b%2==0:
    print("Even")
elif a%2==1 and b%2==0:
    print("Even")
elif a%2==0 and b%2==1:
    print("Even")
elif a%2==1 and b%2==1:
    print("Odd")

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;

		if (i % 2 == 1 && a % 2 == 1) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<algorithm>
using namespace std;
long long Get(long long a){
    int i;
    for(i=0;;i++){
        if((1ll<<i) > a)return (1ll<<i);
    }
}
long long Calc(long long A, long long B){
    if(A==0)return Get(B);
    long long M, t;
    M = Get(A);
    if(M > B)return Calc(A-M/2,B-M/2);
    if(M*2 <= B){
        while(M*2<=B)M*=2;
        t = Get(B-M);
        return t + M-A + min(M-t, M-A);
    }
    t = Get(B-M);
    return t + M-A + min(M-t,M-A);
}
int main(){
    long long A, B;
    scanf("%lld%lld",&A,&B);
    printf("%lld\n",Calc(A,B));
}

Measured memory_bytes: 128
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int a;
string s;

int main() {
  init_ios();
  cin >> a >> s;
  if (a >= 3200)
    cout<<s<<"\n";
  else
    cout<<"red\n";
}

Measured memory_bytes: 892
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int w,h,sx,sy,sum;
char mp[21][21];

int dfs(int y,int x){
  if(0<=y&&y<h&&0<=x&&x<w&&(mp[y][x]=='.'||mp[y][x]=='@')){
    mp[y][x]='$';
    sum++;
    rep(i,4){
      dfs(y+dy[i],x+dx[i]);
    }
  }
  return sum;
}

signed main(){
 
  while(cin>>w>>h,w){
    rep(i,h)rep(j,w){
      cin>>mp[i][j];
      if(mp[i][j]=='@'){
        sy=i;sx=j;
      }
    }
    sum=0;
    cout<<dfs(sy,sx)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c - (a-b)) << endl;
}


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


int main(){
    int A, B, K,C,count=0,ans;
    cin >> A >> B >> K;
    C=min(A,B);
    for (int i = C; i > 0; i--)
    {
        if(A%i==0 && B%i==0){
            count++;
            if(count==K){
                ans=i;
            }
        }

    }
    cout << ans << endl;
    
}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

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

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,x,t; cin >> n >> x >> t;

    int cnt=0;
    int ans=0;
    while(cnt<n){
        cnt+=x;
        ans+=t;
    }
    cout << ans ENDL;
    return 0;
}

Measured memory_bytes: 5980
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N;
	cin >> N;

	ll t = 1;
	ll a = 1;

	repn(i, N) {
		ll T, A;
		cin >> T >> A;

		ll k = max((t - 1) / T + 1, (a - 1) / A + 1);
		t = T * k;
		a = A * k;
	}

	cout << t + a;


	system("PAUSE");
}

Measured memory_bytes: 504
// 和風いろはちゃんイージー
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  
  string s;
  
  cin >> s;
  s[5]=' ';
  s[13]=' ';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import bisect

N=int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
r=(XY[0][0]+XY[0][1])%2
for i in range(N):
    if r != (XY[i][0]+XY[i][1])%2:
        print(-1)
        sys.exit()

sumtwo=[]
mul = 2
for i in range(31):
    sumtwo.append(mul - 1)
    mul*=2


maxtwo=0
i_two=0
for i in range(N):
    if maxtwo < abs(XY[i][0])+abs(XY[i][1]):
        i_two = bisect.bisect_left(sumtwo, abs(XY[i][0])+abs(XY[i][1]))
        maxtwo = sumtwo[i_two]
ans=[2**i for i in range(i_two+1)]
if r==0:
    ans=[1]+ans
    i_two+=1
print(i_two+1)
print(*ans)
ans.reverse()

for i in range(N):
    ans2 = []
    nowx,nowy=XY[i]
    for j in range(i_two+1):
        if abs(nowx) < abs(nowy):
            if nowy < 0:
                ans2.append("D")
                nowy += ans[j]
            else:
                ans2.append("U")
                nowy -= ans[j]
        else:
            if nowx < 0:
                ans2.append("L")
                nowx += ans[j]
            else:
                ans2.append("R")
                nowx -= ans[j]
    ans2.reverse()
    print("".join(ans2))


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int N = 1005;
int n,a[N][N],id[N*N][2],tot;
int book[N][N],ans,tmp,dis[N*N];
struct edge{
	int node ,next;
}e[N*N*2];
int head[N*N],in[N*N],t;
queue<int> q;
void add(int x,int y)
{
	e[++tot].node=y; e[tot].next=head[x];
	head[x]=tot;
}
void topsort()
{
	for(int i=1;i<=t;i++)
	if(!in[i]) q.push(i),++tmp,dis[i]=1;
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		for(int i=head[u];i;i=e[i].next)
		{
			int v=e[i].node;
			dis[v]=dis[u]+1;
			in[v]--;
			if(!in[v]) { q.push(v); ++tmp; } 
		}
	}
	if(tmp<t) { printf("-1\n"); return ; }
	for(int i=1;i<=t;i++)
	ans=max(ans,dis[i]);
	printf("%d\n",ans); 
	return ;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)
		{
			scanf("%d",&a[i][j]);
			if(!book[i][j]&&!book[j][i])
			{
				id[++t][0]=i; id[t][1]=j;
				book[i][j]=t; book[j][i]=t;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=2;j<n;j++)
		 add(book[i][a[i][j-1]],book[i][a[i][j]]),in[book[i][a[i][j]]]++;
	}
	topsort();
	return 0;
}

Measured memory_bytes: 35328
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    int a[n], b[n], c[n];
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(a,a+n); sort(b,b+n); sort(c,c+n);

    ll ans = 0;
    rep(i,n){
        int m = b[i];
        ans += (lower_bound(a,a+n,m)-a)*(n-(upper_bound(c,c+n,m)-c));
    }
    cout<<ans<<endl; return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long int dp[2][100001];
long long int mod=1e9+7;
long long int dfs(int node,int parent,int color,vector<int > Tree[])
{
    if(Tree[node].size()==1&&node!=1)
    {
        return 1; 
    }
    if(dp[color-1][node]!=-1)
    return dp[color-1][node];
    int i;
    long long int ans=1;
    for(i=0;i<Tree[node].size();i++)
    {
        if(Tree[node][i]!=parent)
        {
            if(color==1)
            ans*=dfs(Tree[node][i],node,2,Tree);
            else 
            ans*=dfs(Tree[node][i],node,2,Tree)+dfs(Tree[node][i],node,1,Tree);
        }
        ans%=mod;
    }
    return dp[color-1][node]=ans%mod;
}

int main()
{
  int n;
  cin>>n;
  vector<int > Tree[n+1];
  int i,x,y;
  memset(dp,-1,sizeof(dp));
  for(i=0;i<n-1;i++)
  {
    cin>>x>>y;
    Tree[x].push_back(y);
    Tree[y].push_back(x);
  }
long long int  ans=dfs(1,1,2,Tree)+dfs(1,1,1,Tree);
  //vector<bool> visited(n+1,false);
  cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 20164
#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 all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

ll lpow(ll p, ll q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q % 2) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}

int main() {

	string s;
	cin >> s;

	ll mod[13];
	mod[0] = 1;
	rep1(j, 12)mod[j] = 0;

	int k = 1;

	rep1(i, s.size()) {

		ll copy[13];
		rep(j, 13)copy[j] = 0;

		if (s[s.size() - i] == '?')rep(l,10)rep(j, 13)copy[(j + k * l) % 13] += mod[j];
		else {
			int l = s[s.size() - i] - '0';
			rep(j, 13)copy[(j + k * l) % 13] += mod[j];
			
		}
		rep(j, 13)mod[j] = copy[j] % MOD;
		k *= 10;
		k %= 13;
	}

	cout << mod[5] << endl;
}

Measured memory_bytes: 512
N = int(input())
C = sorted(list(map(int, input().split())))
P = int(1e9+7)

ans=0
inv2 = pow(2, P-2, P)
powa = inv2
powb = pow(2, N-1, P)
for i, c in enumerate(C):
    powa = (2*powa) % P
    powb = (inv2*powb) % P
    if i == N - 1:
        ans = (ans + powa * c)%P
    else:
        ans = (ans + powa * powb * (N - i + 1) * c) % P
print((ans*pow(2, N))%P)


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

void print(char c){
  cout << c;
}

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx;
  int y = ty - sy;
  print('D');
  for(int i=0;i<x+1;i++){
    print('R');
  }
  for(int i=0;i<y+1;i++){
    print('U');
  }
  print('L');
  for(int i=0;i<y;i++){
    print('D');
  }
  for(int i=0;i<x;i++){
    print('L');
  }
  for(int i=0;i<y;i++){
    print('U');
  }
  for(int i=0;i<x;i++){
    print('R');
  }
  print('U');
  for(int i=0;i<x+1;i++){
    print('L');
  }
  for(int i=0;i<y+1;i++){
    print('D');
  }
  print('R');
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

a,b=map(int,input().split())
print(max(a+b,a-b,a*b))

Measured memory_bytes: 38396
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b,a % b);
}
int combination(int n, int k){
    int spaceOptimize[k+1];
    memset(spaceOptimize, 0, sizeof(spaceOptimize));
    spaceOptimize[0] = 1;
    for(int i=1;i<=n; i++){
        for(int j= min(i,k);j>0;j--){
            spaceOptimize[j] = spaceOptimize[j] + spaceOptimize[j-1];
        }
    }
    return spaceOptimize[k];
}
int count_permutation(int arr[], int n){
    int a[n];
    for(int i=0;i<n;i++){
        a[i] = i+1;
    }
    int count = 0;
    do {
        count++;
        if (equal(a, a + n, arr)){
            return count;
        }
    } while (next_permutation(a, a + n));
    return 0;
}

signed main(){
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r", stdin);
#endif
    fastIO

    int n;
    cin >> n;
    int a[n],b[n-1];
    memset(a, 0, sizeof(a));
    for(int i=0;i<n-1;i++){
        cin >> b[i];
        if(i == 0){
            a[i] = b[i];
            a[i+1] = b[i];
        }else{
            a[i+1] = b[i];
            if(a[i] > b[i]){
                a[i] = b[i];
            }
        }
    }
    int sum = 0;
    for(int i=0;i<n;i++){
//        cout << a[i] << " ";
        sum += a[i];
    }
//    cout << endl;
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<vector>
    #include<math.h>
    #include<iomanip>
    using namespace std;
     
     
    int main(){
    	string s;
    	cin>>s;
    	int N=s.size();
     
    	long long ans=0;
     
    	for(int bit=0;bit<(1<<(N-1));bit++){
    		long long sum=0;
     
    		for(int j=0;j<N;j++){
    			sum *=10;
    			sum +=s.at(j)-'0';
     
    			if(bit &(1<<j)){
    				ans+=sum;
    				sum=0;
    			}
    		}
    		ans += sum;
    	}
    	cout << ans <<endl;
     
    	return 0;
     
    }

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

int main() {
  string s, t; cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans += s.at(i) != t.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

int main() {
  int x; cin >> x;
  if (x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- Coding: utf-8 -*-
INF = 1001001001
n, m = map(int, input().split())
 
def bfs(sv, to_list):
  dist = [INF for i in range(n)]
  hist = [-1 for i in range(n)]
  q = []
  dist[sv] = 0
  q.append(sv)
  while len(q) > 0:
    v = q[0]
    del q[0]
    for j in to_list[v]:
      if dist[j] != INF:
        continue
      hist[j] = v
      dist[j] = dist[v] + 1
      q.append(j)
  min_cycle = INF
  min_hist = -1
  for i in range(n):
    if i == sv:
      continue
    for j in to[i]:
      if j == sv:
        if min_cycle > dist[i]:
          min_cycle = dist[i]
          min_hist = i
  res = []
  temp_v = min_hist
  if min_cycle < INF:
    while temp_v > -1:
      res.append(temp_v)
      temp_v = hist[temp_v]
  else:
    res = [1 for i in range(n+1)]
  return res
    
 
to = [[] for i in range(m)]
for i in range(m):
  a, b = map(int, input().split())
  to[a-1].append(b-1)
if len(to) == 0:
  print(-1)
else:  
  c = [bfs(i, to) for i in range(n)]
  ans = [1 for i in range(n+1)]
  for i in range(n):
    if len(ans) > len(c[i]):
      ans = c[i]
  if len(ans) == n + 1:
    print(-1)
  else:
    print(len(ans))
    for v in ans[::-1]:
      print(v+1)

Measured memory_bytes: 58584
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int total_sec;
    cin >> total_sec;
    int hours = total_sec/3600;
    int minutes = (total_sec%3600)/60;
    int seconds = (total_sec%60);
    cout << hours << ':' << minutes << ':' << seconds << endl;
}



Measured memory_bytes: 3092
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	cin >> n >> k;

	if(k%n==0){
		cout << n+k << endl;
	}
	else cout << k-n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
	typedef long long int ll; 
     
    int main() {
      int n;
      cin >> n; 
      vector<int> p(n);
      for(int i=0; i<n; i++){
        cin>> p.at(i); 
      }
      int count=0; 
      for(int i=1; i<=n-2; i++){
        if( (p.at(i-1) > p.at(i))&& (p.at(i) > p.at(i+1))) count++; 
        if( (p.at(i-1) < p.at(i))&& (p.at(i) < p.at(i+1))) count++; 
      }
	  cout<< count <<endl; 
    }

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int x1 = n[0];
        int y1 = n[1];
        int x2 = n[2];
        int y2 = n[3];
        int dx = x2 - x1;
        int dy = y2 - y1;

        int x3 = x2 - dy;
        int y3 = y2 + dx;
        int x4 = x1 - dy;
        int y4 = y1 + dx;
        Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
    }
}


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


#define MAX_N 100002
#define MAX_M 100002

int N,M;
int dp[MAX_N];
vector<int> G[MAX_N];

int longestPath(int i){
    if(dp[i] > 0){
        return dp[i];
    }
    int be = 0;
    for(auto j = G[i].begin(); j != G[i].end(); j++){
        be = max(be,longestPath(*j)+1);
    }
    return dp[i] = be;
}
int main() {
    scanf("%d %d",&N,&M);

    for(int i = 0; i < M; i++){
        int x,y;
        scanf("%d %d",&x,&y);
        G[x-1].push_back(y-1);
    }
    int be = 0;
    for(int i = 0; i < N; i++){
        be = max(be,longestPath(i));
    }
    cout << be;
}

Measured memory_bytes: 8192
N = int(input())
A = list(map(int,input().split()))
C = {}
cnt = 0
for i in range(N):
    a = A[i]
    if a>N:
        cnt += 1
    else:
        if a not in C:
            C[a]=0
        C[a] += 1
for a in C:
    if a>C[a]:
        cnt += C[a]
    elif a<C[a]:
        cnt += C[a]-a
print(cnt)

Measured memory_bytes: 85432