akhauriyash/Code-Regression huggingface dataset:
import std;

bool calc(int a, int b, int c, int d) {
    int x = (c + b - 1) / b;
    int y = (a + d - 1) / d;
    return x <= y;
}

void main() {
    int a, b, c, d; scan(a, b, c, d);
    writeln(calc(a, b, c, d) ? "Yes" : "No");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3636
import itertools
h,w,k=map(int, input().split()) 
s=[list(input()) for i in range(h)]
a=[[0]*w for i in range(h)]
count=0
count2=0
ans=0
x=0
k=0
for i in range(h):
    if s[i].count('#')==0:
        continue
    count=0
    ans+=1
    for j in range(w):
        if s[i][j]=='.':
            a[i][j]=ans
            
        if s[i][j]=='#':
            count+=1
            if count==2:
                ans+=1
                count=1
            a[i][j]=ans
           
for i in range(h):
    if a[i][0]!=0:
        x=i
    else:
        a[i]=a[x]

for i in range(h):
    if a[i][0]==0:
        count2+=1
    if a[i][0]!=0:
        for j in range(count2):
            a[j]=a[i]
        break
        
for i in range(h):
    print(*a[i])
        
    
        
        
        
    

        
        
    
        
        
        
        
        


            
                    
                    
                
                
            
            
        




    
    
    
    

Measured memory_bytes: 8272
#include <bits/stdc++.h>
    using namespace std;
     
    vector<string>A, B;
     
    int main()
    {
        int N, M;
        cin>>N>>M;
       
        string inp;
        for(int i = 0; i < N; i++)
        {
            cin>>inp;
            A.push_back(inp);
        }
        for(int i = 0; i < M; i++)
        {
            cin>>inp;
            B.push_back(inp);
        }
        int i, j, k, l;
        int ans = 0;
        for(i = 0; i + M - 1 < N; i++)
        {
            for(j = 0; j + M - 1 < N; j++)
            {
                 for(k = 0; k < M; k++)
                 {
                     for(l = 0; l < M; l++)
                     {
                             if(A[i + k][j + l] != B[k][l]) break;
                     }
                     if(l < M) break;
                 }
                 if(k == M) ans++;
            }
        }
        if(ans) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 3

int n,M[MAX+1][MAX+1];
int D[MAX+1],colr[MAX+1],Q[MAX+1];
int tail,head;

void bfs(int);
void enqueue(int);
int dequeue(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n+1;i++){
    for(j=0;j<n+1;j++){
      M[i][j] = 0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);

    for(j=1;j<=k;j++){
      scanf("%d",&v);
      M[u][v] = 1;
    }
  }

  bfs(1);

  return 0;
}

void bfs(int s){
  int i,u,v;

  for(i=0;i<n+1;i++){
    colr[i] = WHITE;
    D[i] = INF;
  }

  colr[s] = GRAY;
  D[s] = 0;
  enqueue(s);

  while(head != tail ){
    u = dequeue();

    for(v=1;v<=n;v++){
      if(M[u][v] == 1 && colr[v] == WHITE){
        colr[v] = GRAY;
        D[v] = D[u] + 1;
        enqueue(v);
      }
    }
    colr[u] = BLACK;
  }

  for(i=1;i<=n;i++){
    printf("%d %d\n",i,(D[i] == INF) ? (-1) : D[i]);
  }
}  
       
void enqueue(int x){
  Q[tail] = x;
  tail = (tail +1) % (MAX+1);
}

int dequeue(void){
  int x;

  x = Q[head];
  head = (head + 1) % (MAX +1);
  return x;
}
  


Measured memory_bytes: 2108
# 初期入力
N = int(input())
A = list(map(int, input().split()))

#
from collections import Counter
jousi_0 = {i:0 for i in range(1,N+1)} # 上司の人数を０で初期化
jousi = Counter(A) # 上司の人数

for i,v in jousi.items(): # 0人も含めて数える
    jousi_0[i] = v

for i in jousi_0.values():
    print(i)

Measured memory_bytes: 54192
function main(input) {
  const args = input.split(' ');
  const A = parseInt(args[0], 10);
  const B = parseInt(args[1], 10);
  let tmp = A;
  let ans = 0;
  
  while(tmp <= B) {
    ary = tmp.toString().split('');
    if(ary[0] === ary[4] && ary[1] === ary[3]) {
      ans++;
    }
    tmp++;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 37564
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(K[int(input())-1])

Measured memory_bytes: 3060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var K = cin.ReadLong;
            var X = cin.ReadLong;

            var Left = Max(X - (K - 1), -1000000);
            var Right = Min(X + (K - 1), 1000000);

            for(long i = Left; i < Right; i++) {
                Console.Write(i);
                Console.Write(" ");
            }
            Console.Write("{0}\n", Right);
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
h,w = map(int, input().split())
s = [list(input().replace(".","0")) for i in range(h)]
x = [1,1,0,-1,-1,-1,0,1]
y = [0,1,1,1,0,-1,-1,-1]

for i in range(h):
    for j in range(w):
        if s[i][j] == "0":
            for k in range(8):
                if 0 <= j+y[k] < w and 0 <= i+x[k] < h and s[i+x[k]][j+y[k]] == "#":
                    s[i][j] = str(int(s[i][j])+1)
                    
for i in range(h):
    print("".join(s[i]))

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

int main(){
	string s ;
	int h,n ;
	while(1){
		cin >> s ;
		if(s=="-") break ;
		cin >> n ;
		for(int i=0;i<n;i++){
			cin >> h ;
			string t,u ;
			for(int j=0;j<s.size();j++){
				if(j<h) t += s.at(j) ;
				else u += s.at(j) ;
			}
			s = u+t ;
		}
		cout << s << endl ;
	}
}


Measured memory_bytes: 3196
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <tuple>
# include <functional>
# include <utility>
# define INF 1000000000
# define MOD 1000000000+7
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	s.erase(s.begin() + s.size() - 1);
	string a, b;
	for (int i = 1; i <= n; i++) {
		if (s.size() % 2 == 0) {
			a = s.substr(s.size() / 2);
			b = s.substr(0, s.size() / 2);
			if (a == b) {
				cout << n - i << endl;
				break;
			}
		}
		s.erase(s.begin() + s.size() - 1);
	}
}



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

int A[107];
int B[107];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    for (int i = 0; i < N; i++) scanf("%d", &B[i]);

    int ans = 0;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
        int tmpsum = sum;
        for (int j = i; j < N; j++) {
            tmpsum += B[j];
        }
        ans = max(tmpsum, ans);
    }

    cout << ans << "\n";
}


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

t, a = map(int, input().split())

for i in range(N - 1):
    nt, na = map(int, input().split())
    p = max((t + nt - 1) // nt, (a + na - 1) // na)
    t = nt * p
    a = na * p
print(t + a)


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputList = Console.ReadLine().Split(' ').Select(value => int.Parse(value));

			var stringList = new List<string>();

			for(int i = 0; i < inputList.First(); i++)
			{
				stringList.Add(Console.ReadLine());
			}

			stringList.Sort();

			foreach (var value in stringList)
			{
				Console.Write(value);
			}

			Console.WriteLine();
		}
	}
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

void dfs(int pos, int a, int b, int c, int mp);

int l[8];
int n;
int A, B, C;
int res = INF;

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

    cin >> n >> A >> B >> C;

    for( int i = 0; i < n; ++i ) {
        cin >> l[i];

    }

    dfs(0, 0, 0, 0, 0);
    cout << res - 30 << endl;

    return 0;
}

void dfs(int pos, int a, int b, int c, int mp) {
    if( pos == n ) {
        if( a == 0 || b == 0 || c == 0 ) {
            return;

        }
        mp += abs(a - A) + abs(b - B) + abs(c - C);
        res = min(res, mp);
        return;
    }

    dfs(pos + 1, a + l[pos], b, c, mp + 10);
    dfs(pos + 1, a, b + l[pos], c, mp + 10);
    dfs(pos + 1, a, b, c + l[pos], mp + 10);
    dfs(pos + 1, a, b, c, mp);

    return;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#define rep(i,n) for(i = 0; i < n; i++)
using namespace std;

int main(){
    int n,i,j;
    int h[101];
    int h2[101];
    cin>>n;
    rep(i,n) cin>>h[i];
    rep(i,n) h2[i] = 0;

    long long ans = 0;//temp水やり回数
    bool zenkaiMizuyari;
    bool ikkaidemoMizuyari = true;
    while(ikkaidemoMizuyari){
        zenkaiMizuyari = false;
        ikkaidemoMizuyari = false;
        rep(i,n){
            if(h2[i] < h[i]) {
                if(!zenkaiMizuyari) ans++;
                zenkaiMizuyari = true;
                ikkaidemoMizuyari = true;
                h2[i]++;
            }
            else {
                zenkaiMizuyari = false;
            }
        }
    }

    //check
    rep(i,n){
        if(h[i] != h2[i]) cout << "error in " << i << endl;
    }

    cout << ans << endl;
}

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

int main(){
  int n, m;  cin >> n >> m;
  vector<vector<int>> g(n+1);
  while(m--){
    int a, b;  cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> dist(n+1, 1e9);  dist[1] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pque;
  pque.push({0, 1});
  while(!pque.empty()){
    auto now = pque.top();  pque.pop();
    if(dist[now.second] < now.first)  continue;
    for(auto next : g[now.second])
      if(now.first + 1 < dist[next]){
	dist[next] = now.first + 1;
	pque.push({dist[next], next});
      }
  }

  printf("%s\n", dist[n]<=2 ? "POSSIBLE" : "IMPOSSIBLE");

  return 0;
}
  


Measured memory_bytes: 16800
import math
N = int(input())
total = N/2*(N+1)

f = math.floor(N/3)
f = (3*f+3)*f/2
b = math.floor(N/5)
b = (5*b+5)*b/2
fb = math.floor(N/15)
fb = (15*fb+15)*fb/2

print(int(total-f-b+fb))


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
ll MOD = 1e9+7;

ll modpow(ll a, ll n, ll MOD){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll a,b,c,zero=0,azero=0,bzero=0;
    map<pair<ll,ll>,vector<int>> g;
    rep(i,n){
        cin >> a >> b;
        if(a==0 && b == 0){
            zero++;
        }
        else if(a==0 || b ==0){
            if(a==0) azero++;
            else bzero++;
        }
        else{
            c = __gcd(abs(a),abs(b));
            a /= c;
            b /= c;
            pair<ll,ll> p(a,b),pp(-b,a),ppp(-a,-b),pppp(b,-a);
            if(g.count(p)) g[p][0]++;
            else if(g.count(pp)) g[pp][3]++;
            else if(g.count(ppp)) g[ppp][2]++;
            else if(g.count(pppp)) g[pppp][1]++;
            else g[p] = {1,0,0,0};
        }
    }
    ll ans, sum;
    ans = ((modpow(2,azero,MOD)-1) + (modpow(2,bzero,MOD)-1) + 1) % MOD;
    vector<int> cnt;
    for(auto p:g){
        cnt = p.second;
        sum = 1;
        rep(i,4) sum = (sum + modpow(2,cnt[i],MOD)-1) % MOD;
        rep(i,2) sum = (sum + (modpow(2,cnt[i],MOD)-1) * (modpow(2,cnt[i+2],MOD)-1) % MOD) % MOD;
        ans = ans * sum % MOD;
    }
    print((ans-1+zero+MOD)%MOD);
    return 0;
}

Measured memory_bytes: 25444
freq=Array.new(6, 0)
n=gets.to_i

n.times {
  h=gets.to_f
  case
    when h<165.0
      freq[0]+=1
    when h<170.0
      freq[1]+=1
    when h<175.0
      freq[2]+=1
    when h<180.0
      freq[3]+=1
    when h<185.0
      freq[4]+=1
    else
      freq[5]+=1
  end
}

freq.each_index { |i|
  puts "#{i+1}:" << '*' * freq[i]
}

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

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define SZ(a) (int)((a).size())
#define F first
#define S second


int main(){
  int n;
  while(cin >> n,n){
    int appx[1000]={};
    int appy[1000]={};
    int dx[] = {0,1,0,-1};
    int dy[] = {-1,0,1,0};
    rep(i,n-1){
      int ni,di;
      cin >> ni >> di;
      appx[i+1] = appx[ni]+dx[di];
      appy[i+1] = appy[ni]+dy[di];
    }
    
    cout 
         << *max_element(appy,appy+n) - *min_element(appy,appy+n) +1<< " "
    << *max_element(appx,appx+n) - *min_element(appx,appx+n) +1<< endl;
  }
}

Measured memory_bytes: 1164
package main

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

func main() {
	var (
		S      = strings.Split(ReadLine(), "")
		T      = strings.Split(ReadLine(), "")
		Result int
	)

	for i, s := range S {
		if s == T[i] {
			Result++
		}
	}

	fmt.Println(Result)
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 640
n,y = map(int,input().split())
huku = y//10000
higuchi = y // 5000
flag = False
for i in range(huku+1):
    for j in range(higuchi+1):
        nokori = y - (10000*i + 5000*j)
        if nokori < 0:
            break
        l = nokori // 1000
        #print(i,j,l)
        if i+j+l == n:
            if 10000*i + 5000*j + 1000*l==y:
                flag = True
                ans1 = i
                ans2 = j
                ans3 = l
                #print(i,j,l)

if flag ==True:
    print(ans1,ans2,ans3)
else:
    print("-1 -1 -1")


Measured memory_bytes: 40812
N,M,X = map(int,input().split())
li = [list(map(int,input().split())) for i in range(N)]
ans = 10**9

for i in range(2**N):#bit全探索
    case = []
    for j in range(N):
        if ((i >> j) & 1):
            case.append(li[j])
    result = [sum(list(map(lambda x:x[i], case))) for i in range(1,M+1)]
    if min(result)>=X:
        ans = min(ans,sum(list(map(lambda x:x[0], case))))

if ans == 10**9:
    print("-1")
else:
    print(ans)

Measured memory_bytes: 9176
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    exit()

dep = h // 2
wid = w // 2

if h % 2 == 0:
    print(dep * w)
else:
    print((dep + 1) * (w - wid) + dep * wid)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

int main()
{
    fastio;
    map<ll,ll>ta,tb;
    ll n=0;
    cin>>n;
    ll ar[n]={0};
    for(ll i=0;i<n;++i) cin>>ar[i];
    for(ll i=0;i<n;++i){
        ll x=i-ar[i],y=i+ar[i];
        if(x>=0) ta[x]++;
        if(y<n) tb[y]++;
    }
    ll ans=0;
    for(ll i=0;i<n;++i) ans+=ta[i]*tb[i];
    cout<<ans;
    
}

Measured memory_bytes: 30160
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
vector<string> ans;



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

	cin >> n;

	rep(i, 1<<n) {
		if (i % 2 == 0)continue;
		int cnt = 0;
		rep(j, n)if (i >> j & 1)cnt++;

		vector<string> p;
		p.push_back(string());
		int c = 0;
		rep(j, n) {
			vector<string> q;
			if (i >> j & 1) {
				c++;
				for (const string& s : p) {
					q.push_back(s + (char)('a' + c - 1));
				}
				p.swap(q);
			}
			else {
				for (const string &s : p) {
					rep(k, c) {
						q.push_back(s + (char)('a' + k));
					}
				}
				p.swap(q);
			}
		}
		for (const string& s : p)ans.push_back(s);
	}


	sort(all(ans));
	for (const string& s : ans)cout << s << endl;


	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1){
    cout << "Odd" << endl;
  }
  
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    int correct = 0, penalty = 0;

    std::map<int, pair<int, int> > answerMap;
    for(int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if(answerMap.count(p) == 0) {
            if(s == "AC") {
                answerMap[p].first = 1;
                answerMap[p].second = 0;
            } else {
                answerMap[p].first = 0;
                answerMap[p].second = 1;
            }
        } else {
            if(s == "AC") {
                answerMap[p].first++;
            } else {
                if(answerMap[p].first == 0) {
                    answerMap[p].second++;
                }
            }
        }
    }

    for(auto x : answerMap) {
        int i = x.first;
        correct += answerMap[i].first > 0 ? 1 : 0;
        penalty += answerMap[i].first > 0 ? answerMap[i].second : 0;
    }
    cout << correct << " " << penalty << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,i,j;
  cin>>n;
  for(i=1;i<=3;i++)
  {
	 k=n%10;
     n=n/10;
     //cout<<k<<" "<<n<<endl;
     if(k==7)
     {
       cout<<"Yes";
       break;
     }
  }
  if(i==4)
  {
    cout<<"No";
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

void solve() {
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    for (int i = 0; i < min(k, 400); ++i) {
        vector<int> b(n + 1);
        for (int i = 0; i < n; ++i)
            ++b[max(0, i - a[i])], --b[min(n, i + a[i] + 1)];
        for (int i = 1; i < n; ++i)
            b[i] += b[i - 1];
        b.pop_back();
        a.swap(b);
    }
    
    for (int i = 0; i < n; ++i)
        cout << a[i] << ' ';
    cout << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}



Measured memory_bytes: 4748
#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<ll, ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647    //int値の最大値
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

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 gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}
int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> A(n);
    rep(i, n)
    {
        cin >> A[i];
    }
    sort(ALL(A));
    reverse(ALL(A));
    int count = 0;
    rep(i, n)
    {
        if (i == 0)
        {
            count++;
            ans += A[i];
        }
        else
        {
            if (count + 2 <= n - 1)
            {
                count += 2;
                ans += A[i]*2;
            }
            else
            {
                ans += A[i] * (n - 1 - count);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int nums[10];
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a;
		for(int j = 0; j < 10; j++){
			cin >> a;
			nums[j] = a;
		}
		int l = 0, r = 0;
		for(int i = 0; i < 10; i++){
			int minimum = min(l, r);
			int maximum = max(l, r);
			if(nums[i] < minimum){
				cout << "NO" << endl;
				break;
			}
			if(nums[i] > maximum){
				if(l > r){
					l = nums[i];
				} else {
					r = nums[i];
				}
			} else {
				if(nums[i] > l){
					l = nums[i];
				}else if(nums[i] > r){
					r = nums[i];
				}
			}
			if(i == 9)
				cout << "YES" << endl;
		}
	}
	return 0;
}

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


class UnionFind {
public:
    // parent node index if not root index
    // minus size of the tree if root index
    std::vector<int> data;
    UnionFind( int n ) {
        data.resize( n, -1 );
    }
    int find( int x ) {
        if ( data[x] < 0 ) {
            return x;
        } else {
            int r = find( data[x] );
            data[x] = r;
            return r;
        }
    }
    void unite( int x, int y ) {
        int r = find( x );
        int s = find( y );
        if ( r != s ) {
            data[r] += data[s];
            data[s] = r;
        }
    }
    int size( int x ) {
        int r = find(x);
        return -data[r];
    }
};


ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    int x, y;
    UnionFind uf(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> x >> y;
        uf.unite(x,y);
    }
    unordered_map<int, vector<ll>> m;
    for ( int i = 0; i < N; i++ ) {
        m[uf.find(i)].push_back(A[i]);
    }
    ll ans = 0;
    vector<ll> r;
    for ( auto p : m ) {
        auto vs = p.second;
        sort(vs.begin(), vs.end());
        ans += vs[0];
        for ( int i = 1; i < vs.size(); i++ ) {
            r.push_back(vs[i]);
        }
    }
    if ( m.size() == 1 ) return 0;
    if ( r.size() < m.size() - 2 ) return -1;
    sort(r.begin(), r.end());
    for ( int i = 0; i < m.size() - 2; i++ ) {
        ans += r[i];
    }
    return ans;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) {
        cout << "Impossible"  << "\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 10276
#include<stdio.h>
int main()
{
    char sentence[101];
    scanf("%s",sentence);
    int i,j;
    int count=0;
    int center=0;
    for(i=0;sentence[i]!=0;i++);
    for(j=0;j<i/2;j++){
        if(sentence[j]!=sentence[i-1-j]){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
 
int Hash[244140625];
char s[13];  

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(){
  int sum = 0, p = 1;
  
  for(int i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}

int main(){
  int n;
  char com[7];
 
  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);
 
    if(com[0] == 'i'){
      Hash[getKey()] = 1;
    }else{
      if(Hash[getKey()]){
        puts("yes");
      }else{
        puts("no");
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 39040
n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

sum = 0
cnt = [0] * p
cnt[0] = 1
n = len(s)
for i in range(n):
    d = s[i] * pow(10, i, p)
    sum = (sum + d) % p
    cnt[sum] += 1

ans = 0
if p in [2, 5]:
    if p == 2:
        ok_list = [0, 2, 4, 6, 8]
    if p == 5:
        ok_list = [0, 5]

    for i in range(n):
        d = s[i]
        if d in ok_list:
            ans += n - i
           
else:
    for i in range(p):
        ans += cnt[i] * (cnt[i]-1) // 2


print(ans)

Measured memory_bytes: 6560
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

bool used[1000][1000][1000];

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    long long a[x];
    long long b[y];
    long long c[z];
    for(int i = 0; i < x; i++){
        cin >> a[i];
    }
    for(int i = 0; i < y; i++){
        cin >> b[i];
    }
    for(int i = 0; i < z; i++){
        cin >> c[i];
    }
    sort(a, a+x, std::greater<>());
    sort(b, b+y, std::greater<>());
    sort(c, c+z, std::greater<>());

    priority_queue<pair<long long, pair<int, pair<int, int> > > > q;
    used[0][0][0] = true;
    q.push(make_pair(a[0]+b[0]+c[0], make_pair(0, make_pair(0, 0))));
    int count = 0;
    while(count < k){
        pair<long long, pair<int, pair<int, int> > > p = q.top();
        q.pop();

        cout << p.first << endl;
        int a1 = p.second.first;
        int b1 = p.second.second.first;
        int c1 = p.second.second.second;

        // cerr << a[a1] << " " << b[b1] << " " << c[c1] << endl;

        if(a1+1 < x && !used[a1+1][b1][c1]){
            used[a1+1][b1][c1] = true;
            q.push(make_pair(a[a1+1]+b[b1]+c[c1], make_pair(a1+1, make_pair(b1, c1))));
        }
        if(b1+1 < y && !used[a1][b1+1][c1]){
            used[a1][b1+1][c1] = true;
            q.push(make_pair(a[a1]+b[b1+1]+c[c1], make_pair(a1, make_pair(b1+1, c1))));
        }
        if(c1+1 < z && !used[a1][b1][c1+1]){
            used[a1][b1][c1+1] = true;
            q.push(make_pair(a[a1]+b[b1]+c[c1+1], make_pair(a1, make_pair(b1, c1+1))));
        }
        count++;
    }

    
    return 0;
}


Measured memory_bytes: 973312
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> A(N);
    REP(i,N)cin >> S[i] >> A[i];
    string X;
    cin >> X;
    int a = 0;
    REP(i,N){
        if(S[i].compare(X)==0){
            FOR(j,i+1,N)a+=A[j];
        }
    }
    cout << a << endl;
    return 0;
}

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

using namespace std;

int ar[200005];
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];
	bool ok = 1;
	if(ar[1] != 0) ok = 0;
	for(int i = 2; i <= n; i++)
		if(ar[i] > ar[i - 1] + 1) ok = 0;
	if(ok == 0){
		cout << -1;
		return 0;
	}
	int pos = 1;
	long long ans = 0;
	ar[n + 1] = 1e9 + 7;
	while(pos <= n){
		if(ar[pos] == 0){
			pos++;
			continue;
		}
		int t = ar[pos];
		while(ar[pos + 1] == ar[pos] + 1){
			pos++;
			t++;
			
		}
		ans += t;
		pos++;
	}
	cout << ans;
}

Measured memory_bytes: 1024
#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 fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


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


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int n;

void solve(string s,int id,string ans)
{
    if(id==n)
    {
        cout<<ans<<endl;
        return;
    }

    for(int i=0;i<n;i++)
    {
        if(s[i]!='?')
            solve(s,id+1,ans+s[i]);
        else
        {
            s[i]='a'+i;
            solve(s,id+1,ans+s[i]);
            s[i]='?';
            break;
        }
    }
}

int32_t main()
{
    fast;
    cin>>n;
    string s="";
    for(int i=0;i<n;i++)
        s+='?';
    string ans="";
    solve(s,0,ans);
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#define MOD 1000000007LL
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	int x, y, z;
	cin>>n>>x>>y>>z;
	ll s=1<<(x+y+z);
	ll all=1;
	for(int i=0; i<n; i++) all=all*10%MOD;
	ll dp[41][131073]={};
	dp[0][0]=1;
	for(int i=0; i<n; i++){
		for(ll k=0; k<s; k++){
			for(int a=1; a<=10; a++){
				ll k0=(k<<a)|(1<<(a-1));
				k0%=s;
				if(k0&(1<<(z-1)) && k0&(1<<(y+z-1)) && k0&(1<<(x+y+z-1))) continue;
				dp[i+1][k0]+=dp[i][k];
				dp[i+1][k0]%=MOD;
			}
		}
	}
	ll sum=0;
	for(int k=0; k<s; k++) sum=(sum+dp[n][k])%MOD;
	cout<<(all-sum+MOD)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 42240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const double PI=acos(-1.0);
int main(){
	double r;
	scanf("%lf",&r);
	printf("%.5lf",2.0*r*PI);
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;

int main() {
  map<ii, ll> cc;
  ll h, w, n;
  cin >> h >> w >> n;
  ll count[10]; memset(count, 0, sizeof count);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    for (int j = -2; j <= 0; j++) {
      for (int k = -2; k <= 0; k++) {
        if (a+j >= 0 && b+k >= 0 && a+j+2 < h && b+k+2 < w) {
          int d = ++cc[ii(a+j, b+k)];
          if (d-1 == 0) {
            sum++;
          } else {
            --count[d-1];
          }
          ++count[d];
        }
      }
    }
  }
  count[0] = (h-3+1)*(w-3+1)-sum;
  for (int i = 0; i < 10; i++) {
    cout << count[i] << endl;
  }
}


Measured memory_bytes: 56448
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int a,b;
    cin>>a>>b;
    if(a%b==0)cout<<0<<endl;
    else cout<<1<<endl;
    
}



    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000007
#define MOD 998244353
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(max(a * c, a * d), max(b * c, b * d));
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    
    int N, arr[100000], dp[100000];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> arr[i];
        dp[i] = 1000000001;
    }
    dp[0] = 0;
    for (int i = 0; i < N; i++){
        for (int j : {i + 1, i + 2}){
            if (j < N) {
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
        }
    }
    cout << dp[N - 1];

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

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

    unordered_set<string> set;
    char previous = -1;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;

        if (set.count(s)) {
            cout << "No" << endl;
            return 0;
        }

        if (previous != -1) {
            if (s[0] != previous) {
                cout << "No" << endl;
                return 0;
            }
        }

        previous = s[s.length() - 1];
        set.insert(s);
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

int main(){
    int n,l;
    string s[200];
    cin >> n >> l;
    for(int i = 0;i< n;i++)cin >> s[i];
    sort(s,s+n);
    for(int i = 0;i< n;i++)cout << s[i];
    cout << endl;
    
    return 0;
}

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

int main() {
    int N, M, ans=0;
    cin >> N;
    string s;
    map<string, int> mp;

    for(int i=0; i<N; i++){
	cin >> s;
	mp[s]++;
    }
    cin >> M;

    for(int i=0; i<M; i++){
	cin >> s;
	mp[s]--;
    }
    for( auto i = mp.begin(); i != mp.end(); i++ ){
	ans = max(ans, i->second);
      // cout << i->first << " " << i->second << "\n";
  }


    cout << ans << endl;
} 




Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))

sum = 0
min = 100
all = 0

for i in range(N):
    all = all + W[i]

for i in range(N):
    sum = sum + W[i]
    if min > abs(2*sum - all):
        min = abs(2*sum - all)
        
print(min)

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

int main(){
	string str;
	cin >> str;
	int n = 0;
	int w = 0;
	int s = 0;
	int e = 0;
	for(int i = 0; i < str.length(); i++){
		if(str[i] == 'N')n++;
		else if(str[i] == 'W')w++;
		else if(str[i] == 'S')s++;
		else e++;
	}
	if(n == 0 && s == 0){
		if(w > 0 && e > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}else if((n > 0 && s == 0) || (n == 0 && s > 0)) cout << "No" << endl;
	else{
		if(w > 0 && e > 0)cout << "Yes" << endl;
		else if(w == 0 && e == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n,x=map(int,input().split())
L=input()
l=L.split()
count=0
ans=1
for i in range(len(l)):
    l[i]=int(l[i])
for j in range(len(l)):
    count=count+l[j]
    if count>x:
        break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double[] a = new double[]{sc.nextDouble(), sc.nextDouble(), sc.nextDouble(), sc.nextDouble()};
        double x = a[2] - a[0], y = a[3] - a[1];
        System.out.println(Math.sqrt(x * x + y * y));
    }
}

Measured memory_bytes: 28048
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
ll h,w,a,b;
map<ll,ll> c;
multiset<ll> d;

int main(){
  cin>>h>>w;
  rep(i,w)c[i]=i;
  rep(i,w)d.insert(0);
  rep(i,h){
    cin>>a>>b;
    a--;
    auto e=c.lower_bound(a);
    ll m=-1;
    while(e!=c.end() && e->first<=b){
      m=max(m,e->second);
      ll x=(e->first)-(e->second);
      d.erase(d.find(x));
      c.erase(e++);
    }
    if(m!=-1 && b<w){
      d.insert(b-m);
      c[b]=m;
    }
    cout<<(d.empty() ? -1 : *d.begin()+i+1)<<endl;
  }
}


Measured memory_bytes: 25460
#include <bitset>
#include <iostream>

int main()
{
    unsigned int price;
    unsigned int numHates;
    std::bitset<10> hates;
    std::cin >> price >> numHates;
    for(std::size_t i = 0; i != numHates; i++)
    {
        unsigned int buf;
        std::cin >> buf;
        hates.set(buf);
    }
    unsigned int div = 1;
    while(price / div)
    {
        unsigned int digit;
        while(hates.test(digit = (price / div % 10)))
        {
            price = ((price / div) + 1) * div;
            if(hates.test(0))
            {
                unsigned int candidate = 1;
                while(hates.test(candidate))
                    candidate++;
                for(unsigned int i = 1; i != div; i *= 10)
                {
                    price += i * candidate;
                }
            }
        }
        div *= 10;
    }
    std::cout << price << std::endl;
    return 0;
}


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

// #LIB#

using namespace std;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll p, q, r;
  cin >> p >> q >> r;
  cout << min(p + q, min(q + r, r + p)) << endl;
}


Measured memory_bytes: 3644
N=int(input())
a=list(map(int,input().strip().split()))
b=list(map(int,input().strip().split()))

#累積和
A=[]
B=[]
suma=0
sumb=0
for n in range(N):
    suma+=a[n]
    A.append(suma)
for n in reversed(range(N)):
    sumb+=b[n]
    B.append(sumb)

MAX=0
for n in range(N):
    MAX=max(MAX,A[n]+B[N-n-1])
print(MAX)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans = "";
  for(int i = 0; i < ty - sy; i++) ans += 'U';
  for(int i = 0; i < tx - sx; i++) ans += 'R';
  for(int i = 0; i < ty - sy; i++) ans += 'D';
  for(int i = 0; i < tx - sx + 1; i++) ans += 'L';
  for(int i = 0; i < ty - sy + 1; i++) ans += 'U';
  for(int i = 0; i < tx - sx + 1; i++) ans += 'R';
  ans += "DR";
  for(int i = 0; i < ty - sy + 1; i++) ans += 'D';
  for(int i = 0; i < tx - sx + 1; i++) ans += 'L';
  ans += 'U';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i;
	char c[21];
	scanf("%s",&c);

	for(i= strlen(c)-1 ; i >= 0 ; i--)
	{
		printf("%c",c[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524