akhauriyash/Code-Regression huggingface dataset:
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val m,n = sc.nextInt
  val m2,n2 = sc.nextInt
//  val h = List.fill(n)(sc.nextInt)

  val ans = if (m != m2) 1 else 0

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27324
def main():
    N = int(input())
    S = input()

    str_list = list()
    for s in S:
        str_list.append(s)

    str_uni_list = {}
    for str in str_list:
        if (str in str_uni_list) is False:
            str_uni_list[str] = 1
        else:
            str_uni_list[str] += 1

    list_val = []
    for i in str_uni_list.values():
        list_val.append(i)

    rem = 1
    for v in list_val:
        rem *= (v + 1)

    ans = rem - 1

    print(ans % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> ans(n+1,0);
    ll a = sqrt(n)+1;
    rep(x,1,a){
        rep(y,1,a){
            rep(z,1,a){
                ll s = x*x+y*y+z*z+x*y+y*z+z*x;
                if (s <= n) ans[s]++;
            }
        }
    }
    rep(i,n) PRINT(ans[i+1]);
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	vector<string>v;
	int n,i,ma=0;
	string s[maxn];
	scanf("%d",&n);
	for(i=1;i<=n;i++)cin>>s[i];
	sort(s+1,s+1+n);
	s[n+1]=s[n]+'a';
	int sum=1;
	for(i=2;i<=n+1;i++)
	{
		if(s[i]==s[i-1])sum++;
		else
		{
			if(sum>ma)v.clear(),ma=sum;
			if(ma==sum)v.push_back(s[i-1]);
			sum=1;
		}
	}
	for(string ss:v)cout<<ss<<endl;
}

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

int main() {
  ll N,P;
  cin >> N >> P;
  ll ans = 1;
  for (ll i = 2; i*i <= P; i++) {
    if (P % i == 0) {
      ll count = 0;
      ll Q = P;
      while (Q % i == 0) {
        Q /= i;
        count++;
      }
      if (count >= N) ans = i;
    }
  }
  
  if (N == 1) ans = P;
  
  cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int n;
		cin >> n;
		vector<int> h(n);
		for(int j=0;j<n;j++){
			cin >> h[j];
		}
		
		int ans0 = 0;
		int ans1 = 0;
		for(int j=0;j<n-1;j++){
			int d = h[j+1]-h[j];
			if(d>0){
				ans0=max(ans0,d);
			}else{
				ans1=max(ans1,-d);
			}
		}
		cout << ans0 << " " << ans1 << endl;
	}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1196
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

d = ni()
c = na()
s = []

for i in range(d):
    ss = na()
    s.append(ss)

c = np.array(c) # 満足度の下がりやすさ
s = np.array(s) # i日目jコン
s_t = s.T # iコンj日目
last = np.zeros(26)

# 評価関数
# 得になった分+その日の満足度
# n: 日数, 
def eva(n, cc, ss):
    r = np.random.rand()/2+1
    return (d-n)*cc + 30*ss*r

score = 0

for i in range(d): # i日目(0-indexed)
    last += 1 # 一日分追加
    tow = c * last # 満足下がる値 
    sc = -100000
    M = -1
    for j in range(26):
        k = eva(i, tow[j], s[i][j])
        if sc < k:
            sc = k
            M = j
    last[M] = 0
    score -= np.dot(c,last)
    score += s[i][M]
    print(M+1)

#print(score)

Measured memory_bytes: 27444
#include <bits/stdc++.h>
#define ll long long
using namespace std;
set <char> st;
int main()
{
    string s;
    cin >> s;
    int len = s.size();
    for(int i = 0; i < len; i++){
        st.insert(s[i]);
    }
    if(st.size() == len) cout << "yes" << "\n";
    else cout << "no" << "\n";
    return 0;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef char* String;

String string_input(void){
    int i,len;
    char buf[101];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=strlen(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int main(void){
    int N;
    scanf("%d",&N);

    String* s;
    NEW(s,N);
    int* t;
    NEW(t,N);
    for(int i=0;i<N;i++){
        s[i]=string_input();
        scanf("%d",&t[i]);
    }

    String X=string_input();

    int index;
    for(int i=0;i<N;i++){
        if(strcmp(s[i],X)==0){
            index=i;
            break;
        }
    }

    long ans=0;
    for(int i=index+1;i<N;i++) ans+=t[i];
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 128
from math import gcd
from functools import reduce
from collections import defaultdict


def calc_factor(n):
    # O(N log log N)
    min_factor = list(range(n + 1))
    for i in range(2, n + 1):
        if min_factor[i] == i:
            for j in range(2 * i, n + 1, i):
                min_factor[j] = i
    return min_factor


def calc_prime_factor(n, min_factor):
    # O(log N)
    ctr = defaultdict(int)
    while n > 1:
        div = min_factor[n]
        while n % div == 0:
            ctr[div] += 1
            n //= div
    return ctr


N = int(input())
X = list(map(int, input().split()))

min_factor = calc_factor(10 ** 6 + 10)
pairwise = True
appeared = set()
for v in X:
    primes = calc_prime_factor(v, min_factor)
    for n in primes:
        if n in appeared:
            pairwise = False
        appeared.add(n)

if pairwise:
    print("pairwise coprime")
elif reduce(gcd, X) == 1:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 191704
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*4
#define mod 1000000007
#define ll long long
int red[nn];int n;int ca[nn];
int from[nn],to[nn];int tak[nn];int siz[nn];
int main()
{
	cin>>n;int m;cin>>m;for(int i=1;i<=n;i++) siz[i]=1;
	for(int i=1;i<=m;i++) scanf("%d%d",&from[i],&to[i]),tak[from[i]]++;
	red[1]=1;
	for(int i=1;i<=m;i++)
	{
		siz[from[i]]--,siz[to[i]]++;
		if(red[from[i]]) red[to[i]]=1;
		if(siz[from[i]]==0) red[from[i]]=0;
	}
	int cnt=0;for(int i=1;i<=n;i++) cnt+=red[i];
	cout<<cnt;
	return 0;
} 


Measured memory_bytes: 5120
arr=gets.chomp.split(//)
n=gets.to_i
    flag=true
n.times do
    m,f,c=gets.chomp.split
    m=m.to_i
    f=f.to_i
    if m==1
        flag = !flag
    else
        f = 3-f if !flag
        arr.push(c) if f==2
        arr.unshift(c) if f==1
    end
end

puts  flag ? arr.join : arr.reverse.join


Measured memory_bytes: 30844
package main

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

func main() {
	scan_init()
	n := scanInt()
	// a := make([]int, n)
	count := 0
	for i:=1; i<=n;i++ {
		a := scanInt()
		if (i%2 == 0) {
			continue
		} else if (a%2 != 0) {
			count ++
		}
	}
	fmt.Println(count)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, m, x = map(int, input().split())
    ca = [list(map(int, input().split())) for i in range(n)]
    ans = float("inf")
    subsc = []  #選ばれている本
    for i in range(1 << n):
        for j in range(n):
            if (i >> j)&1:
                subsc.append(ca[j])
        flag = True
        cost = 0 #係る金額
        unst = 0 #各アルゴリズムの理解度
        if len(subsc) == 0:
            continue  
        for j in range(1,m+1):
            for k in range(len(subsc)):
                unst += subsc[k][j]
            if unst < x:
                flag = False #一つでもクリアできなければFalseになるはず
            unst = 0
        for j in range(len(subsc)):
            cost += subsc[j][0]
        if flag:
            ans = min(ans, cost)
        flag = True
        cost = 0
        subsc = []
    if ans == float("inf"):
        ans = -1
    print(ans)

if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 9860
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    /*if(n == 1) {
        cout << 1 << endl;
        return 0;
    }*/

    vector<int> broken(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        broken[a] = 1;
    }

    vector<int> dp(n+1);
    dp[0] = 1;
    dp[1] = 1;
    if(broken[1]) {
        dp[1] = 0;
    }

    for(int i = 2; i <= n; i++) {
        if(broken[i]) {
            continue;
        }

        dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= mod;
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		int h;
		int m;
		double shortHand, longHand;
		double deg;
		cin>>h;cin.ignore(1);cin>>m;
		longHand = m*6;
		shortHand = 30*h+0.5*m;
		deg = fabs(shortHand-longHand);
		if(deg>180.0)
			deg = 360.0-deg;
		if(deg<30.0){
			cout<<"alert\n";
		}else if(deg>=90.0&&deg<=180.0){
			cout<<"safe\n";
		}else{
			cout<<"warning\n";
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
using uint = unsigned int;

uint N, K;

int main() {
  scanf("%u%u", &N, &K);
  
  string buf;
  getline(cin, buf);

  printf("%u\n", (uint)ceil((double)(N - 1) / (double)(K - 1)));
	return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

struct bangumi_t{
	int s;
	int t;
	int c;
};

int compare_channel(const void *a, const void *b) {//降順と昇順あってる？？
	struct bangumi_t *A = (struct bangumi_t *)a;
	struct bangumi_t *B = (struct bangumi_t *)b;
	if(A->c - B->c >0){
		return 1;
	}else if(A->c - B->c <0){
		return -1;
	}else{
		return 0;
	}
}


int main(void)
{
	//変数の宣言
	int n;
	int a[25];
	int b[25];
	int c[25];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	
	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
//		scanf_s("%d",&b[i]);
	}

	for(i=0;i<n-1;i++){
		scanf("%d",&c[i]);
//		scanf_s("%d",&c[i]);
	}


/*	for(i=0;i<n;i++){
//		scanf("%d",&c[i]);
		scanf_s("%d",&c[i]);
		d[i]=0;
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<n;i++){
		sum=sum+b[i];
		if(i!=n-1&&a[i+1]-a[i]==1) sum=sum+c[a[i]-1];
	}

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	printf("%d",sum);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



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

int main(){
  int N,T,H,L,t[110],h[110];

  cin >> N >> T >> H >> L;
  for(int i=0;i<N;i++){
    cin >> t[i] >> h[i];
  }
  int res = 0,index = 0;
  while(true){
    if(t[index] > 0){
      t[index]--;
      res+=10;
      T++;
    }
    else if(h[index] > 0){
      h[index]--;
      res+=100;
      H++;
    }
    else {
      cout << index+1 << endl;
      break;
    }

    if(T > L){
      cout << index+1 << endl;
      break;
    }

    if(res >= 90){
      res -= 90;
      if(T < res/10){
	cout << index+1 << endl;
	break;
      }
      T-=res/10;
      t[index] += res/10;
      res = 0;
    }

    //cout << "index  = " << index << ",t["<<index<<"] = "<< t[index] << ",h["<<index<<"] = " << h[index] << endl;
      index++;
    if(index >= N)index = 0;
  }

  return 0;
}

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

int main() {
  int A, B, ans;
  cin  >> A >> B;
  int i = 0;
  while(true){
    if(1+(i-1)*(A-1)>=B){
      ans = i-1;
      break;
     }
    else i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> a, vector<long long> b){
	rep(i, N) {
		a[i] -= b[i];
	}
	ll s = 0;
	rep(i, N) {
		s += a[i];
	}
	ll p = 0, m = 0;
	rep(i, N) {
		if (a[i] > 0) m += a[i];
		if (a[i] < 0 && (-a[i])%2 == 0) p += (-a[i])/2;
		if (a[i] < 0 && (-a[i])%2 == 1) {
			p += (-a[i])/2+1;
			m++;
		}
	}
	// cout << p << " " << m << endl;
	if (p >= m) cout << "Yes" << endl; else cout << "No" << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	vector<long long> b(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&b[i]);
	}
	solve(N, a, b);
	return 0;
}



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

typedef pair<int,int> ii;
int h, w, n;
map <ii, bool> mp, ex;
long long ans[11];

void solve(int x, int y) {
	if (ex.count(ii(x, y))) return;
	if (x <= 0 || y <= 0 || x + 2 > h || y + 2 > w) return;
	ex[ii(x, y)] = true;
	int res = 0;
	for (int i = 0; i <= 2; ++i) for (int j = 0; j <= 2; ++j) {
		if (mp.count(ii(x + i, y + j))) ++res;
	}
	++ans[res];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> h >> w;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x, y; cin >> x >> y;
		mp[ii(x, y)] = 1;
	}

	for (map<ii, bool>::iterator it = mp.begin(); it != mp.end(); ++it) {
		int x = (it -> first).first, y = (it -> first).second;
		solve(x - 2, y - 2);
		solve(x - 2, y - 1);
		solve(x - 2, y);
		solve(x - 1, y - 2);
		solve(x - 1, y - 1);
		solve(x - 1, y);
		solve(x, y - 2);
		solve(x, y - 1);
		solve(x, y);
	}

	long long sum = 0;
	for (int i = 0; i <= 9; ++i) sum += ans[i];
	ans[0] += 1LL * (h-2) * (w-2) - sum;

	for (int i = 0; i <= 9; ++i) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, answer=1;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  for (int i=0; i<N-1; i++){
    if(d.at(i) > d.at(i+1))
      answer ++;
    else
      continue;
  }
  cout << answer << endl;
}

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


using namespace std;
typedef long long ll;

const ll MOD=998244353;
ll n,a[330]={0},sum=0;
ll dp[2][310][90010]={0};

ll power(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	else if (b == 1) {
		return a % MOD;
	}
	else if (b % 2 == 0) {
		ll c = power(a, b / 2);
		return (c*c) % MOD;
	}
	else {
		ll c = power(a, b / 2);
		return (((c*c) % MOD)*a) % MOD;
	}
}

signed main() {
	cin>>n;
    for(int i=0;i<n;++i){
        cin>>a[i];
        sum+=a[i];
    }

    dp[0][0][0]=1;
    ll s1=0;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=sum;++j){
            if(j-a[i-1]>=0){
                dp[0][i][j]+=dp[0][i-1][j-a[i-1]];
            }
            dp[0][i][j]+=2*dp[0][i-1][j];
            dp[0][i][j]%=MOD;
            if((sum+1)/2<=j&&i==n)s1=(s1+dp[0][i][j])%MOD;
        }
    }

    dp[1][0][0]=1;
    ll s2=0;
    if(sum%2==0){
        for(int i=1;i<=n;++i){
            for(int j=0;j<=sum;++j){
                if(j-a[i-1]>=0){
                    dp[1][i][j]+=dp[1][i-1][j-a[i-1]];
                }
                dp[1][i][j]+=dp[1][i-1][j];
                dp[1][i][j]%=MOD;
                if(sum/2==j&&i==n)s2=(s2+dp[1][i][j])%MOD;
            }
        }
    }

    ll res=power(3,n);
	res=(res+MOD-3*s1)%MOD;
    res=(res+MOD+3*s2)%MOD;

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


Measured memory_bytes: 425472
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,k=0,i,j,m=0;
  cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                ll p=__gcd(i,j);
                m+=__gcd(p,k);
            }
        }
    }
    cout<<m<<endl;

}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

int howManyWays(int n, int x){
    int S = 0;
    for (int i=1;i<=n;i++){
        for (int j=i+1;j<=n;j++){
            for (int k=j+1;k<=n;k++){
                if(i+j+k == x){
                S++;
                }
            }
        }
    }
    return S;
}

int main(){
    int n, x;
    cin >> n >> x;
    while(n!=0 || x!=0){
        cout << howManyWays(n,x) <<endl;
        cin >> n >> x;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 52
#define MMAX 52

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

int A[NMAX],B[NMAX],C[NMAX],N,M,W,H,ans,dp[MMAX] = {};
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (int i = 0; i < M; ++i)
	{
		dp[A[i]]++;
		dp[B[i]]++;
	}
}

void debug(){

}

void answer(){
	for (int i = 0; i < N; ++i)
	{
		cout << dp[i+1] << endl;
	}
}

int main(){
	cin >> N >> M;
	for (int i = 0; i < M; ++i)
	{
		cin >> A[i] >> B[i];
	}
	
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200003;
ll n,a,ans=0,p=-1,r=1,k=0;
vector<ll> v;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	v.pb(0);
	FOR(i,0,n){
		cin>>a;
		k+=a;
		v.pb(k);
	}
	SORT(v);
	FOR(i,0,v.size()){
		ll p=NUM(v,v[i]);
		p--;
		ans+=(p*(p+1))/2;
		i+=(p);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int N = input.nextInt();
			int[] A = new int[N];
			int[] B = new int[N];
			int[] C = new int[N];
			
			for(int i = 0; i < A.length; ++i){
				A[i] = input.nextInt();
			}
			
			for(int i = 0; i < B.length; ++i){
				B[i] = input.nextInt();
			}
			
			for(int i = 0; i < C.length; ++i){
				C[i] = input.nextInt();
			}
			
			Arrays.sort(A);
			Arrays.sort(B);
			Arrays.sort(C);
			
			long[] CLargerB = new long[N];
			for(int b = 0 , c = 0; b < B.length; ++b){
				while(c < C.length && C[c] <= B[b]){
					++c;
				}
				
				CLargerB[b] = C.length - c;
			}
			
			for(int i = C.length - 1; i > 0; --i){
				CLargerB[i - 1] += CLargerB[i];
			}
			
			long ways = 0;
			for(int a = 0, b = 0; a < A.length; ++a){
				while(b < B.length && B[b] <= A[a]){
					++b;
				}
				
				if(b < B.length){
					ways += CLargerB[b];
				}
			}
			
			System.out.println(ways);
		}
	}
 
}

Measured memory_bytes: 95448
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    char c;
    cin >> c;
    printf("%c",c+1);

    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

ll a, b, t;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                    

inline void Solve () {
   cin >> a >> b >> t;
   cout << (t / a) * b;
   
}                                     

int main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


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

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int a, b;
    cin >> a >> b;
    int res = 0;
    while (res * a - res + 1 < b) res++;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
 
 
signed main(){
    int N;
    int H[57];
    cin >> N;
    REP(i,N){cin >> H[i];}
    int now=0;
    int Ans=0;
    REP(i,N){
        if(H[i]>=now){
            Ans++;
            now=H[i];
        }
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii             pair<int , int >
#define inf             1000000011
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n")
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define pcs(a)          printf("Case %d: ", a)
#define mp              make_pair
#define vi              vector<int >
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define sz              size()
#define pb              push_back
#define mem(a, b)       memset((a), (b), sizeof(a))
#define all(X)          (X).begin(), (X).end ()
#define lg2(n)          (31-__builtin_clz(n))
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
#define x               first
#define y               second
#define lc              (2*i)
#define rc              (2*i+1)

typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1,0};int dy[]={0,1,1,1,0,-1,-1,-1,0};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (n & (1<<pos))>>pos;} //typecast 1 in case of int
//int  on(int n, int pos) {return n | (1<<pos);} //typecast 1 in case of int
//int  off(int n, int pos) {return n & ~(1<<pos);} //typecast 1 in case of int
//bool operator < (const data &d) const{return cost<d.cost;} //reverse in priority queue

const int M = 500010, mod = 1000000007;

string tostr(int n)
{
    string a;
    while (n > 0)
    {
        a += (n % 10) + '0';
        n /= 10;
    }
    return a;
}

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("/home/lochness/Documents/in.txt", "r", stdin);
////    freopen("/home/lochness/Documents/in.txt", "w", stdout);
//#endif
//    ios_base::sync_with_stdio(false);


    int n;
    string a, b;

    in(n);
    a = tostr(n);
    b = a;
    reverse(all(b));

    if (a == b) printf("Yes\n");
    else printf("No\n");

    return 0;
}



Measured memory_bytes: 256
//***********************
//*** writer : Alan Hu **
//***********************
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include<cstring>
#include<cmath>
using namespace std;
     
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n;
int a[105];
const int inf=123450660;

int main()
{
	int ans=0;
	cin>>n;
	rept(i,0,n) cin>>a[i];
	rept(i,0,n-1)
	{
		if (a[i]==a[i+1])
		{
			a[i+1]=inf-i;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


int dfs(string s,int depth){
	int ans = depth;
	for(int i = 0 ; i + 3 <= s.size() ; i++){
		if( s[i] == '1' and s[i+1] == '0' and s[i+2] == '1' ){
			string t = s;
			t[i] = t[i+2] = '0';
			t[i+1] = '1';
			ans = max(dfs(t,depth+1), ans);
		}
	}
	return ans;
}


string S;
int nxt[510010];


int dp[510010][11];

// 0: 101*
//    ^
// 1: 101*
//     ^
// 2: 101*
//
// 3: 1111
//

int dfs(int x,int cond){
	if( dp[x][cond] != -1 ) return dp[x][cond];
	if( x >= S.size() - 2 ) return 0;
	
	int c = S[x] == '1';
	int l = nxt[x] - x;
	int ans = 0;
	if( cond == 0 ){
		if(c){
			ans = max(ans, dfs(x+1,1));
			
			assert( S[x+l] == '0' );
			if( S[x+l+1] == '1' ){
				ans = max(ans, dfs(x+l+2,0) + l);
			}
		}
		ans = max(ans, dfs(x+1,0));
	}else if( cond == 1 ){
		if( c == 0 ){
			ans = max(ans, dfs(x+1,2));
		}
		ans = max(ans, dfs(x,0));
	}else if( cond == 2 ){
		if( c == 1 ){
			ans = max(ans, dfs(x+1,2) + 1);
			ans = max(ans, dfs(x+1,1));
		}
		ans = max(ans, dfs(x,0));
	}
	return dp[x][cond] = ans;
}

int greedy(string s){
	memset(dp,-1,sizeof(dp));
	s = "00" + s + "00";
	S = s;
	int last[2] = {};
	last[0] = last[1] = s.size();
	for(int j = s.size() - 1  ; j >= 0 ; j--){	
		last[s[j]-'0'] = j;
		nxt[j] = last[!(s[j]-'0')];
	}
	return dfs(0,0);
	
	
}
string rstr(){
	string w;
	for(int i = 0 ; i < 10000 ; i++) w += rand() % 2 + '0';
	return w;
}
void solve(long long N, string s){
	cout << greedy(s) << endl;
	/*
	while(true){
		s = rstr();
		cout << greedy(s) << endl;
		if( greedy(s) != dfs(s,0) ){
			cout << s << endl;
			cout << greedy(s) << endl;
			cout << dfs(s,0) << endl;
			return;
		}else cout << "ok" << " " << greedy(s) << " " << dfs(s,0) << endl;
	
	}
	*/
}

int main(){	
	string s;
	long long N;
	scanf("%lld",&N);
	cin >> s;
	solve(N, s);
	return 0;
}


Measured memory_bytes: 103812
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int main(){
    int k, a, b;
    cin >> k >> a >> b;


    bool flag = false;
    repp(i, a, b){
        if(i % k == 0) flag = true;
    }

    if(flag) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3596
n = int(input().strip())
a = list(map(int, input().split()))
q = int(input().strip())
bcs = [tuple(map(int, input().split())) for _ in range(q)]

dic = {}
for elem in a:
    if dic.get(elem):
        dic[elem] += 1
    else:
        dic[elem] = 1

ans = sum(a)

for b, c in bcs:
    if dic.get(b):
        diff = (c - b) * dic[b]
        if dic.get(c):
            dic[c] += dic[b]
        else:
            dic[c] = dic[b]
        dic[b] = 0
        ans += diff
    print(ans)


Measured memory_bytes: 103040
def f():
 for c in range(n):
  for d in a[c+1:]:
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    if[d[p[0]],d[p[5]]]==a[c][::5]:
     b=[d[i]for i in p[1:5]]*2
     for k in range(4):
      if b[k:k+4]==a[c][1:5]:return"No"
 return"Yes"
n=int(input())
a=[input().split()for _ in[0]*n]
for b in a:b[3:5]=b[4],b[3]
print(f())


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  rep(i, a, min(a+k-1, b)+1) cout << i << endl;
  rep(i, max(b-k+1, a+k), b+1) cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int s, w;
    cin >> s >> w;
    string ans = "unsafe";
    if(w < s) ans = "safe";
    cout << ans << endl;
    return 0;
}

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

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

ll Q;
ll A, B;

bool check(ll x){
	//cout << x << endl;
	if(x%2LL == 1LL){
		ll l1 = x/2LL;
		if(A <= l1) l1++;
		ll l2 = x/2LL+1LL;
		if(A <= l2) l2++;
		ll r1 = x/2LL+1LL;
		if(B <= r1) r1++;
		ll r2 = x/2LL;
		if(B <= r2) r2++;
		//cout << l1 << " " << r1 << endl << l2 << " " << r2 << endl;
		return A*B > max(l1*r1, l2*r2);
	}else{
		x--;
		ll l2 = x/2LL+1LL;
		if(A <= l2) l2++;
		ll r2 = x/2LL+1LL;
		if(B <= r2) r2++;
		//cout << l2 << " " << r2 << endl;
		return A*B > l2*r2;
	
	}
}

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

	cin >> Q;

	for (int i = 0;i < Q;i++){
		cin >> A >> B;
		ll low = 0LL, high = INT_MAX;
		while(high-low > 1LL){
			ll mid = (high+low)/2LL;
			if(check(mid)) low = mid;
			else high = mid;
		}
		low--;
		cout << low << endl;
	}

	return 0;

}


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

int main() {
    string s;
    cin >> s;
    int a = 0;
    int z = 0;
    for (int i=0; i<(int)s.size(); ++i) {
        if (s.at(i) == 'A') {
            a = i;
            break;
        }
    }

    for (int j=(int)s.size()-1; a < j; --j) {
        if (s.at(j) == 'Z') {
            z = j;
            break;
        }
    }
    cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    cout << *max_element(all(A)) - *min_element(all(A)) << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  string s;
  for(int i=0;i<3;i++){
    cin>>s;
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    cout<<s[0];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int N , keep;
  int max = 0 , min = 1000000000;
  scanf("%d",&N);

  for(int i = 0 ; i < N ; i++){

    scanf("%d", &keep);

    min = (keep < min) ? keep : min;
    max = (max < keep) ? keep : max;

  }

  printf("%d", max - min);

  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i, n) for (ll i=0;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  llc(a);
  llc(b);
  ll r,x=a*b,t;
  if(a<b){
    t = a;
    a = b;
    b = t;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
cout << x/b << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

main = do
  [s] <- getString
  putStrLn $ if s !! 2 == s !! 3 && s !! 4 == s !! 5 then "Yes" else "No"


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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 100005;

ll n, k;
ll a[maxn];
ll dp[maxn];

ll go (ll rem){
    if (rem == 0) return 0;
    ll &ret = dp[rem];
    if (ret != -1) return ret;
    ret = 0;
    for (ll i = 0; i < n; i++){
        if (rem >= a[i])
            ret |= (go (rem - a[i]) == 0);
    }
    return ret;
}

int main(){
//    filein;
    memset (dp, -1, sizeof dp);
    scanf ("%lld %lld", &n, &k);
    for (ll i = 0; i < n; i++)
        scanf ("%lld", &a[i]);
    ll ans = go (k);
    cout << (ans == 0 ? "Second" : "First") << endl;
	return 0;
}


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

int main() {
int A; int B; int C;
  cin>>A>>B>>C;
  int N=1; //counter
  if(A==B){
   if(A!=C) N++;
  }
  else {
    if(A==C)
      N++;
    else if(B==C)
      N++;
    else N+=2;
  }
  cout<<N<<endl;
}

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


int main() {
    int N;
    cin >> N;
    vector<ll> V(87);
    V[0] = 2;
    V[1] = 1;
    rep2(i,2,87) {
        V[i] = V[i - 1] + V[i - 2];
    }
    cout << V[N] << endl;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

bool f(string s) {
    string rs = s;
    reverse(all(rs));
    return s == rs;
}

int main() {
    int A,B;
    cin >> A >> B;
    int ans = 0;
    for(int i=A;i<=B;++i){
        string s = to_string(i);
        if(f(s)) ++ans;
    }

    cout << ans << endl;
}

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

bool sub() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) return false;
  string t = s.substr(0, s.size() / 2);
  return s == t + t;
}

int main() {
  cout << (sub() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
'''Snippets for factorization.
Available functions:
- run_prime_factorization: Run prime factorization.
'''


def run_prime_factorization(max_number: int) -> dict:
    '''Run prime factorization.
    Args:
        max_number: Int of number (greater than 1).
    Returns:
        A dictionary's items ((base, exponent) pairs).
    Landau notation: O(log n)
    '''

    from math import sqrt

    ans = dict()
    remain = max_number

    for base in range(2, int(sqrt(max_number)) + 1):
        if remain % base == 0:
            exponent_count = 0

            while remain % base == 0:
                exponent_count += 1
                remain //= base

            ans[base] = exponent_count

    if remain != 1:
        ans[remain] = 1

    return ans


def main():
    n = int(input())
    mod = 10 ** 9 + 7
    ans = 1
    d = dict()

    for i in range(2, n + 1):
        f = run_prime_factorization(i)

        for fi in f.keys():
            if fi not in d.keys():
                d[fi] = 1
            else:
                d[fi] += f[fi]

    for value in d.values():
        ans *= value + 1
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())

c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    a = input()
    if(a == 'AC'):
        c0 += 1
    elif(a == 'WA'):
        c1 += 1
    elif(a == 'TLE'):
        c2 += 1
    elif(a == 'RE'):
        c3 += 1

print('AC x ' + str(c0))
print('WA x ' + str(c1))
print('TLE x ' + str(c2))
print('RE x ' + str(c3))



Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    vector<vector<int>>a(3,vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    int b[n];
    rep(i,n){
        cin>>b[i];
    }
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(a[i][j]==b[k]){
                    a[i][j]=0;
                }
            }
        }
    }
    if((a[0][0]==a[0][1]&&a[0][1]==a[0][2])||(a[1][0]==a[1][1]&&a[1][1]==a[1][2])||
    (a[2][0]==a[2][1]&&a[2][1]==a[2][2])||(a[0][0]==a[1][0]&&a[1][0]==a[2][0])||
    (a[0][1]==a[1][1]&&a[1][1]==a[2][1])||(a[0][2]==a[1][2]&&a[1][2]==a[2][2])||
    (a[0][0]==a[1][1]&&a[1][1]==a[2][2])||(a[0][2]==a[1][1]&&a[1][1]==a[2][0])){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const int maxn = 505;
typedef pair<ll, ll>par;
const ll mod = 1e9+7;

ll pot( ll b, ll e ){
    ll ret = 1;
    while( e ){
        if( e & 1 )
            ret *= b;
        b *= b;
        e >>= 1;
    }
    return ret;
}

int col[maxn][maxn], dp[maxn][maxn], mf[4] = {1, -1, 0, 0}, mc[4] = {0, 0, 1, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm

    int n;
    cin >> n;

    for( int i = 1; i <= n; i++ )
        for( int j = 1; j <= n; j++ )
            col[i][j] = 1, dp[i][j] = min({i-1, n-i, j-1, n-j});

    int p;
    ll sol = 0;
    for( int l = 1; l <= n*n; l++ ){

        cin >> p;
        int f = (p-1)/n + 1, c = p % n;
        if( c == 0 ) c = n;

        sol += dp[f][c];
        queue<par>q;
        q.push({f, c});
        col[f][c] = 0;
        int nf, nc;
        while( !q.empty() ){
            f = q.front().fi, c = q.front().se;
            q.pop();
            for( int i = 0; i < 4; i++ ){
                nf = f + mf[i], nc = c + mc[i];
                if( nf < 1 || nf > n || nc < 1 || nc > n )continue;
                if( dp[nf][nc] > dp[f][c] + col[f][c] ){
                    dp[nf][nc] = dp[f][c] + col[f][c];
                    q.push({nf, nc});
                }
            }
        }

    }

    cout << sol << "\n";
    return 0;
}


Measured memory_bytes: 5648