akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}

int main(){
    ll n,m=0,num;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n) {
        cin>>a[i];
        if(m<a[i]){
            m=a[i];
            num=i;
        }
    }
    sort(range(a));
    rep(i,0,n)
    if(i!=num) cout<<m<<endl;
    else cout<<a[n-2]<<endl;
}

Measured memory_bytes: 3200
fun main(args: Array<String>) {
    var n = readLine()!!.toLong()
    if (n % 2 == 1L) {
        println(0)
        return
    }
    var ans = 0L
    while (n > 0) {
        ans += n / 5 / 2
        n /= 5
    }
    println(ans)
}


Measured memory_bytes: 31904
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
lnt par[10000];
struct edge{lnt u,v,cost;};
vector<edge> es;
bool cmp(const edge& a,const edge& b){
	return a.cost<b.cost;
}
P mat[10000];
lnt n,m;
void init(){
	for(int i=0;i<n;i++) par[i]=i;
}

lnt find(lnt x){
	if(par[x]==x) return x;
	else return par[x]=find(par[x]);
}

bool same(lnt x,lnt y){
	return find(x)==find(y);
}

void unite(lnt x,lnt y){
	par[find(x)]=find(y);
	return;
}
double ans=0;
int main()
{
	cin>>n>>m;
	init();
	for(lnt i=0;i<n;i++){
		cin>>mat[i].first>>mat[i].second;
	}
	lnt x,y;
	for(lnt i=0;i<m;i++){
		cin>>x>>y;
		x--;
		y--;
		es.push_back({x,y,-(mat[x].first-mat[y].first)*(mat[x].first-mat[y].first)-(mat[x].second-mat[y].second)*(mat[x].second-mat[y].second)});
		ans+=sqrt(-es[i].cost);
	}
	sort(es.begin(),es.end(),cmp);
	for(lnt i=0;i<m;i++){
		edge e=es[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			ans-=sqrt(-e.cost);
		}
	}
	cout<<fixed<<ans<<endl;
}

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

rev1 = (N//100) * 100 + (N//100) * 10 + (N//100)
rev2 = (N//100 +1) * 100 + (N//100+1) * 10 + (N//100+1)

if N <= rev1 <= rev2:
  print(rev1)
else:
  print(rev2)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("3 5 -1");
            //12
            //8
            //10
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("1 1 1 2 0");
            //4
            //4
            //4
            //2
            //4
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("-679 -2409 -3258 3095 -3291 -4462");
            //21630
            //21630
            //19932
            //8924
            //21630
            //19288
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        var AList = new List<int>();
        AList.Add(0);
        AList.AddRange(AArr);
        AList.Add(0);

        long CostSum = 0;
        for (int I = 1; I <= AList.Count - 1; I++) {
            CostSum += Math.Abs(AList[I] - AList[I - 1]);
        }

        for (int I = 1; I <= AList.Count - 2; I++) {
            int PrevVal = AList[I - 1];
            int CurrVal = AList[I];
            int NextVal = AList[I + 1];

            int Cost1 = Math.Abs(PrevVal - CurrVal);
            int Cost2 = Math.Abs(CurrVal - NextVal);
            int Cost3 = Math.Abs(PrevVal - NextVal);

            Console.WriteLine(CostSum - Cost1 - Cost2 + Cost3);
        }
    }
}


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

Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cins(s);
    int n=0;
    for(char c : s)
        n+=c-'0';

    if(n%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3660
A = []
C = []
ans = "No"
3.times do
  A << gets.chomp.split(' ').map(&:to_i)
  C << [0,0,0]
end
n = gets.to_i
n.times do
  b = gets.to_i
  3.times do |i|
    3.times do |j|
      C[i][j] = 1 if A[i][j] == b
    end
  end
end

# 横ビンゴチェック
C.each do |c|
  ans = "Yes" if c.all?(1)
end

# たてビンゴチェック
3.times do |i|
  ans = "Yes" if [C[0][i],C[1][i],C[2][i]].all?(1)
end

# ななめ
ans = "Yes" if [C[0][0], C[1][1], C[2][2]].all?(1)
ans = "Yes" if [C[0][2], C[1][1], C[2][0]].all?(1)
puts ans

Measured memory_bytes: 14380
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
int a,b;
cin>> a>> b;
if(a>=6 and a<=12)
cout<<b/2<<endl;
else if(a>12)
cout<<b<<endl;
else if(a<=5)
cout<<0<<endl;
return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n; 
    cin >> n;
    
    ll ans = 0;
    rep(i,n-1) {
        ans += i+1;
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 2e5+10;

char s[maxn];
int a[maxn],dp[maxn],best[(1<<26)];

int main(){
	scanf("%s",s);
	int len = strlen(s);
	for(int i=0; i<len; i++)
		a[i+1] = (a[i]^(1<<(s[i]-'a')));
	memset(dp,INF,sizeof dp);
	memset(best,INF,sizeof best);
	dp[0] = 0;
	best[0] = 0;
	for(int i=1; i<=len; i++){
		int new_a = a[i];
		for(int bit=-1; bit<26; bit++){
			if(bit>=0) new_a = a[i]^(1<<bit);
			dp[i] = min(dp[i],best[new_a]+1);
		}
		best[a[i]] = min(best[a[i]],dp[i]);
	}
	cout << dp[len] << endl;

    return 0;
}

Measured memory_bytes: 264320
#include <stdio.h>
#define true 1
#define false 0
int hantei(char *,char *,int kazu);
int main(){
  int kazu,i,j,k[100],gensui[100],temp,moji,mini,minimoji,l,head,headmoji;
  char mark,a[100],kin[100];
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++){
    scanf(" %c%d",&a[i],&k[i]);
  }
  for(i=0;i<kazu;i++){
    kin[i]=a[i];
    gensui[i]=k[i];
  }
  for(i=0;i<kazu;i++){
    for(j=kazu-1;j>i;--j){
      if(k[j]<k[j-1]){
	moji=a[j-1];
	temp=k[j-1];
	a[j-1]=a[j];
	k[j-1]=k[j];
	a[j]=moji;
	k[j]=temp;	
      }
    }
  }
  
  for(i=0;i<kazu-1;i++)
    {
      mini=gensui[i];
      minimoji=kin[i];
      l=i;
      for(j=i+1;j<kazu;j++)
	{
	  if(gensui[j]<mini){
	    mini=gensui[j];
	    minimoji=kin[j];
	    l=j;
	  }
	}
      if(i!=l){
	head=gensui[i];
	headmoji=kin[i];
	gensui[i]=gensui[l];
	kin[i]=kin[l];
	gensui[l]=head;
	kin[l]=headmoji;
      }
    }        
  for(i=0;i<kazu;++i){
    if(i>0)printf(" ");
    printf("%c%d",a[i],k[i]); 
  }
  printf("\n");
     printf("Stable\n");
  for(i=0;i<kazu;++i){
    if(i>0)printf(" ");
    printf("%c%d",kin[i],gensui[i]);     
  }
  printf("\n"); 
  if(hantei(a,kin,kazu)==1)printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}

int hantei(char x[],char y[],int kazu)
{
  int i;
  for(i=0;i<kazu;i++)
    {
    if(x[i]!=y[i])return false;
    }
      return true;  
}



Measured memory_bytes: 2108
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U>& p) {
  os << p.first << " " << p.second;
  return os;
}
template<class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template<class T>
ostream &operator<<(ostream &os, const vector< T > &v) {
  rep(i, v.size())
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<class T>
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
#line 2 "a2.cpp"

int main() {
  ll n = 3;
  vl a(n);
  cin >> a;
  ll sum = 0;
  rep(i, n) {
    sum += a[i];
  }

  if (a[0] == a[1] and a[1] == a[2]) {
    if (a[0]%2 == 1) {
      cout << 0 << el;
    } else {
      cout << -1 << el;
    }
    return 0;
  }

  ll ans = 0;
  while (all_of(all(a), [](ll x){ return x%2 == 0; })) {
    rep(i, n) {
      a[i] = (sum-a[i])/2;
    }
    ans++;
  }
  cout << ans << el;
}


Measured memory_bytes: 256
n, x, m = map(int, input().split())
mn = min(n, m)
P = [] # value of pre & cycle
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check
for i in range(mn):
    if X[x] > -1:
        pre_len = X[x]
        cyc_len = len(P) - pre_len
        nxt_len = (n - pre_len) % cyc_len
        pre = sum(P[:pre_len])
        cyc = (sum_p - pre) * ((n - pre_len) // cyc_len)
        nxt = sum(P[pre_len: pre_len + nxt_len])
        print(pre + cyc + nxt)
        exit()
    X[x] = i
    P.append(x)
    sum_p += x
    x = x*x % m
print(sum_p)


Measured memory_bytes: 13348
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  long long N;
  cin >> N;
  vector<long long> a(N+1,0);
  for(int i = 1;i < N + 1;i++){
    cin >> a.at(i);
  }
  vector<bool> b(N + 1,false);
  long long M = 0;
  for(long long i = N;i >= 1;i--){
    long long c = 0;
    for(long long j = 2*i;j <= N;j+= i){
      c += b.at(j);
    }
    b.at(i) = (c % 2 != a.at(i));
    M += b.at(i);
  }
  cout << M << endl;
  for(int i = 1;i < N + 1;i++){
    if(b.at(i)){
      cout << i << " ";
    }
  }
  cout << endl;
}

/*
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N+1);
  for(int i = 0;i < N;i++){
    cin >> a.at(i);
    b.at(i) = 0;
  }
  b.at(N+1) = 0;
  int M = 0;
  /*for(int i = N - 1;i >= 0;i--){
    int count = 0;
    for(int j = i;j < N;j++){
      count += b.at(j);
    }
    if(count%2 != a.at(i)){
      b.at(i) = abs(a.at(i) - count);
      M ++;
    }
  }
  for(int i = N - 1;i >= 0;i--){
    int count = 0;
    for(int j = 2*i;j <= N;j+=i){
      count += b.at(j);
    }
    if(count%2 != a.at(i)){
      b.at(i) = abs(a.at(i) - count);
      M ++;
    }
  }
  cout << M << endl;
  if(M != 0){
  for(int i = 0;i < N;i++){
    if(b.at(i) != 0){
      cout << i + 1 << " ";
    }
  }
  cout << endl;
}
}
*/


Measured memory_bytes: 4848
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

cnt = [0]*(max(A)+2)
cnt[0] = 3
ans = 1
for a in A:
	ans *= cnt[a] - cnt[a+1]
	cnt[a+1] += 1
	ans %= mod

print(ans)

Measured memory_bytes: 22488
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        double ans = 0;

        for(int i = 0;i < num;i++){
            double x = sc.nextDouble();
            String s = sc.next();

            if(s.equals("JPY")){
                ans += x;
            }else{
                ans += x*380000;
            }

        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22868
n,k = map(int, input().split())
array = list(map(int, input().split()))

one_tento = 0
for i in range(n-1):
    for j in range(i+1,n):
        if array[i] > array[j]:
            one_tento += 1
one_tento = int(one_tento)

two_tento = 0
for i in range(n):
    for j in range(n):
        if array[i] > array[j]:
            two_tento += 1
two_tento = int(two_tento)

result1 = (one_tento * k) % (7 + 10**9)
result2 = ((two_tento % (7 + 10**9)) * ((k * (k - 1) // 2) % (7 + 10**9))) % (7 + 10 **9)
result3 = (result1 + result2) % (7 + 10**9)
print(int(result3))


Measured memory_bytes: 41836
h,w = map(int,input().split())
route = []
for i in range(h):
    A = list(map(int,input().split()))
    if i%2 == 0:
        for j in range(w):
            route.append([i+1,j+1,A[j]])
    else:
        for j in range(w-1,-1,-1):
            route.append([i+1,j+1,A[j]])
cnt = 0
res = []
for i in range(h*w-1):
    if route[i][2] % 2 == 1:
        route[i+1][2] += 1
        res.append([route[i][0],route[i][1],route[i+1][0],route[i+1][1]])
        cnt += 1
print(cnt)
for i in range(cnt):
    print(*res[i])

Measured memory_bytes: 53688
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
inline int read()
{
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+c-'0';c=getchar();}
	return t*f;
}
int n,b[maxn],t[maxn],a[maxn];
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		b[i]=read();
		t[b[i]]++;
		if(b[i]>i){puts("-1");return 0;}
	}
	if(t[1]==0)
	{
		puts("-1");return 0;
	}
	int cnt=0;int alfa=n;
	while(1){
		int flag=0;
		for(int i=n;i;i--){
			if(b[i]==i){
				flag=1;
				a[++cnt]=i;
				for(int j=i;j<n;j++)
				b[j]=b[j+1];n--;
				break;
			}
		}
		if(flag==0){cnt=-1;break;}
		if(cnt==alfa)break;
	//	for(int i=1;i<=n;i++)printf("%d ",b[i]);
		//puts("");
	}
	if(cnt==alfa){
		for(int i=alfa;i;i--)printf("%d\n",a[i]);
	}
	else puts("-1");
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())

lcm = lambda x, y: x * y // gcd(x, y)
a -= 1
ans = b - (b // c + b // d - b // lcm(c, d)) - a + (a // c + a // d - a // lcm(c, d))
print(ans)


Measured memory_bytes: 5048
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007;
LL A[100000];
int main() {
	LL N;
	cin >> N;
	LL sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	LL a = N*(N + 1) / 2;
	if (sum%a) {
		cout << "NO" << endl;
		return 0;
	}
	LL k = sum / a;
	for (int i = 0; i < N; i++) {
		LL d = A[(i + 1) % N] - A[i];
		if (d > k || (k - d) % N) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int f(int n, int k) {

    if (n % k == 0)
        return n / k;
    if (n < k) 
        return 0;

    int dt = n / k + 1;
    int sup = k * (n / k) + 1; // 恰好越过sup
    int DT = ((n - sup) / dt + 1) * dt;

    return f(n - DT, k);
}
int n, a[202], k[202];
int main() {
    int sum = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        scanf("%d %d", &a[i], &k[i]);
        sum ^= f(a[i], k[i]);
    }
    printf("%s\n", !sum ? "Aoki" : "Takahashi");
}

Measured memory_bytes: 384
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,h;
  cin >> n >> h;

  vector<int> a(n),b(n);
  REP(i,n) cin >> a[i] >> b[i];
  
  int mx = 0;
  REP(i,n) mx = max(mx,a[i]);

  sort(b.rbegin(),b.rend());

  int ans = 0;
  REP(i,n){
    if(b[i]>mx) h -= b[i], ans++;
    if(h <= 0) break;
  }

  if(h>0) ans += h/mx + (h%mx>0);

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 10000
int main(void){
	int x[N]={0};
	for(int i=0;i<N;i++){
		scanf("%d",&x[i]);
		if(x==0)break;
		printf("Case %d: %d\n",i+1,x[i]);
	}
return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)
#define pb push_back

#define test if(!true)
#define N 100007
#define MOD (ll)(1e9 + 7)


int main()
{
    int x, a;
    cin >> x >> a;

    if(x < a)
    {
        cout << 0 << "\n";
    }
    else
    {
        cout << 10 <<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int n,m;
ll k;
ll x[100001];
int a[100001],g[100001],gk[100001],T[100001];
ll ans[100001];

int main(){
	cin>>n;
	FOR(i,0,n) cin>>x[i];
	ROF(i,0,n-1) x[i+1]-=x[i];
	cin>>m>>k;
	FOR(i,0,n-1) g[i]=i;
	FOR(i,0,m){
		cin>>a[i];
		swap(g[a[i]-2],g[a[i]-1]);
	}
	FOR(i,0,n-1){
		if(T[i]>0) continue;
		int st=i,t=0;
		do{
			st=g[st];
			t++;
		}while(i!=st);
		st=i;
		do{
			st=g[st];
			T[st]=t;
		}while(i!=st);
	}

	fill(gk,gk+n-1,-1);
	FOR(i,0,n-1){
		if(gk[i]!=-1) continue;
		int kmod=k%T[i];
		int st=i;
		FOR(j,0,kmod){
			st=g[st];
		}
		int st2=i;
		FOR(j,0,T[i]){
			gk[st2]=st;
			st2=g[st2];
			st=g[st];
		}
	}
	ans[0]=x[0];
	FOR(i,0,n-1){
		ans[i+1]=ans[i]+x[gk[i]+1];
	}
	/**
	FOR(i,0,n-1) cout<<g[i]<<" \n"[i==n-2];
	FOR(i,0,n-1) cout<<T[i]<<" \n"[i==n-2];
	FOR(i,0,n-1) cout<<gk[i]<<" \n"[i==n-2];
	**/
	FOR(i,0,n){
		co(ans[i]);
	}
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int index = n / 2;
  char string[n + 1];
  scanf("%s", string);

  if (n % 2 == 1)
  {
    printf("No\n");
    return 0;
  }
  for (int i = 0; i < n / 2; i++)
  {
    if (string[i] == string[index])
    {
      index++;
    }
    else
    {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 1656
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;


long long T[10000] = {}, A[10000] = {};

int main(){
	long long N;
	cin >> N;
	for (long long i = 0; i < N; i++) {
		cin >> T[i] >> A[i];
	}

	long long T1 = T[0], T2 = A[0];
	for (long long i = 1; i < N; i++) {
		long long tmp1 = T1 / T[i];
		long long tmp2 = T2 / A[i];
		if (T1%T[i] != 0) {
			tmp1++;
		}
		if (T2%A[i] != 0) {
			tmp2++;
		}
		long long tmp = max(tmp1, tmp2);
		T1 = T[i] * tmp;
		T2 = A[i] * tmp;

	}
	cout << T1 + T2 << endl;

	return 0;
}

Measured memory_bytes: 256
$H, $W = gets.chomp.split.map(&:to_i)
$maze = []
$ans = 0
$H.times do
    $maze << gets.chomp.split("")
end

def update_ans(dist)
    dist.each do |row|
        row.each do |e|
            next unless e
            $ans = $ans > e ? $ans : e
        end
    end
end

def bfs(sx, sy)
    queue = [[sx, sy]]
    reach = Array.new($H).map{Array.new($W, nil)}
    reach[sy][sx] = 0
    until queue.empty?
        x, y = queue.shift
        dist = reach[y][x]
        [
            [x-1, y],
            [x+1, y],
            [x, y-1],
            [x, y+1]
        ].each do |x, y|
            next if x < 0 || $W <= x || y < 0 || $H <= y
            next if reach[y][x]
            if $maze[y][x] == "#" then
                reach[y][x] = -1
                next
            end
            queue << [x, y]
            reach[y][x] = dist+1
        end
    end
    update_ans(reach)
end

$W.times do |i|
    $H.times do |j|
        next if $maze[j][i] == "#"
        bfs(i, j)
    end
end

puts $ans

Measured memory_bytes: 14388
#include <iostream>

int main()
{
	int N, A, B;
	int X[5];
	int n,m,i,sum,SUM;
	SUM = 0;

	scanf("%d %d %d", &N, &A, &B);

	for (n = 1; n <= N; n++) {

		sum = 0;
		int m = n;
		//printf("%d", m);
		for (i = 1; m > 0 ; i++) {
			X[i] = m % 10;
			m = m / 10;
			sum = sum + X[i];
		}

		if ((A <= sum) & (sum <= B)) {
			SUM = SUM + n;
		}
	}

	printf("%d",SUM);
	return 0;

}

Measured memory_bytes: 256
s1 = input()
s2 = input()
set1 = set()
li = []
for i in range(len(s1)):
    set1.add((s1[i],s2[i]))
set1 = list(set1)
while set1:
    a = set1.pop()
    #print(set1,a,len(set1))
    for i in range(len(set1)):
        if (a[0] != set1[i][0] and a[1] == set1[i][1]) or (a[0] == set1[i][0] and a[1] != set1[i][1]):
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    vi a(3); for(auto& e : a) cin >> e;
    sort(_all(a));
    int res = 0;
    for(auto& e : a){
        int cur = (a[2] - e) / 2;
        res += cur;
        e += cur * 2;
    }

    sort(_all(a));
    if(a[0] == a[2]){}
    else if(a[0] == a[1]){
        res += 1;
    }
    else {
        res += 2;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

int D;
vector<int> c;
vector<vector<int>> s;
vector<int> solution;
vector<int> last(26);
vector<ll> type_score(26);

unsigned int xor128() {
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t;
    t = x ^ (x << 11);
    x = y; y = z; z = w;
    return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}

ll evaluate(vector<int>& sol) {
    fill(ALL(last), 0);

    REP(i, 26) type_score[i] = 0;

    REP(d, D) {
        int j = sol[d] - 1;
        last[j] = d + 1;
        REP(i, 26) {
            type_score[i] -= (d + 1 - last[i]) * c[i];
        }
        type_score[j] += s[d][j];
    }


    ll score = 1e6;
    REP(i, 26) score += type_score[i];

    return max(score, 0ll);
}

void simulated_annealing() {

    auto begin_time = chrono::steady_clock::now();
    auto cur_time = begin_time;
    ll time_elapsed = 0;
    const ll DURATION = 1900;

    double temperature = 1;

    vector<int> cur_state = solution;

    ll cur_score = evaluate(cur_state);
    ll best_score = cur_score;

    int iter = 0;

    while (true) {
        // check the time and update the temperature
        if (iter % 100 == 0) {
            cur_time = chrono::steady_clock::now();
            time_elapsed = chrono::duration_cast<chrono::milliseconds>(cur_time - begin_time).count();
            if (time_elapsed > DURATION) break;
            temperature = (double) (DURATION - time_elapsed) / DURATION;
        }

        // get the next state
        // pick a day and change it to other type
        int d = xor128() % D;
        int i = cur_state[d];
        int j = xor128() % 26 + 1;
        cur_state[d] = j;

        // calculate the score of the next state
        ll next_score = evaluate(cur_state);

        const ll R = 10000;
        bool force_next = temperature > (double) (xor128() % R) / R;

        if (next_score > cur_score || force_next) {
            cur_score = next_score;
        } else {
            // roll back the change
            cur_state[d] = i;
        }

        // save the best state
        if (cur_score > best_score) {
            solution = cur_state;
            best_score = cur_score;
        }

        iter++;
    }
}

void greedy() {
    fill(ALL(last), 0);

    for (int d = 0; d < D; d++) {
        int j = 0, score = 0;
        for (int i = 0; i < 26; i++) {
            int nscore = s[d][i] + (d - last[i]) * c[i] * 5;
            if (nscore > score) {
                j = i;
                score = nscore;
            }
        }
        last[j] = d + 1;
        solution[d] = j + 1;
    }
}

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

    cin >> D;
    c.resize(26);
    REP(i, 26) cin >> c[i];
    s.resize(D, vector<int>(26));
    REP(i, D) REP(j, 26) cin >> s[i][j];
    solution.resize(D);

    greedy();
    simulated_annealing();

    REP(d, D) cout << solution[d] << endl;
}


Measured memory_bytes: 3664
/*input
4 3
2 2 2 2
*/
#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 ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repi(i,a,b) for(ll i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define clr(x) memset(x, 0, sizeof(x))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
//#define ordered_set tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update>;

ll sub(ll a, ll b){return (a-b+hell)%hell;}
ll add(ll a, ll b){return (a+b)%hell;}
ll mul(ll a, ll b){return (a*b)%hell;}
vector<ll>adj[100005];
bool vis[100005];
ll siz,edges;
void dfs(ll i)
{
	vis[i]=1;
	//siz++;
	for(ll j=0;j<adj[i].size();j++)
	{		
		edges++;
		if(!vis[adj[i][j]])
			dfs(adj[i][j]);
	}
}
const ll mod = 1000000007;
ll mpow(ll base, ll exp) {
  base %= mod;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

int main()
{
fIO;
ll n,sum=0,t=1,m,ans,a,b,c;

//cin >> t;
while(t--){
	cin>>n>>m;
	vi a(n);
	rep(i,0,n){cin>>a[i];sum+=a[i];}
	double ss=ceil(sum*1.0/(1.0*4*m));
	
	sort(all(a));
	reverse(all(a));
	rep(i,0,m){
		if(a[i]<ss){cout<<"No";
		return 0;}
	}
	cout<<"Yes";














}
	
}


Measured memory_bytes: 2560
S=input()
i=len(S)
ans="NO"
while(True):
    if(i==0):
        ans="YES"
        break
    if(i>=5 and S[i-5:i]=="dream"):
        i-=5
    elif(i >=5 and S[i-5:i]=="erase"):
        i-=5
    elif(i>=6 and S[i-6:i]=="eraser"):
        i-=6
    elif(i>=7 and S[i-7:i]=="dreamer"):
        i-=7
    else:
        break
print(ans)

Measured memory_bytes: 3188
function Main(input) {
  input = input.split("\n");
  var l1 = input[0];
  var l2 = input[1];
  var a = l1.substr(0,1);
  var b = l1.substr(1,1);
  var c = l1.substr(2,1);
  var d = l2.substr(0,1);
  var e = l2.substr(1,1);
  var f = l2.substr(2,1);
  var ans="NO";
  if(a==f&&b==e&&c==d){
    ans="YES";
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
// y=k(1<=k<=n)上で、ロボAとロボBのそれぞれのボールとの距離の最小値を求めればよい.
// この処理をy=1,2,...,nに対して行う.
#include<iostream>
using namespace std;
int main() {
  int n,k; cin >> n >> k;
  int ans=0;
  for(int i=1;i<=n;i++){
    int x; cin >> x;
    if(2*x<=k) ans += 2*x;
    else ans += 2*(k-x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const double inf = 1e9;
const int MAX_N = 500;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n)rep(j,i) {
        ans = max(ans,abs(a[i]-a[j]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let mx = Array.fold_left max arr.(0) arr in
  let mn = Array.fold_left min arr.(0) arr in
  Printf.printf "%d\n" (mx-mn)

Measured memory_bytes: 3772
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = sc.nextInt();
        }
        int max = 0;
        for (int l = 0 ; l < n - 1 ; l++) {
            int count = 0;
            while (l < n - 1 && h[l] >= h[l + 1]) {
                l++;
                count++;
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }


}

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




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)

int main()
{
    inll(a);
    inll(b);

    ll c = a*b;
    cout<<c;   
}

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

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	if(S[K-1] ==  'A') {
		S[K-1] = 'a';
	}
	else if(S[K-1] ==  'B') {
		S[K-1] = 'b';
	}
	else {
		S[K-1] = 'c';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int kaizyo( int x )
{
int tmp = x;
for( int i = 1; i < x-1 ;++i )
tmp *= x-i;
return tmp;
}

int main(void){
  int n, m, ssum=0, tmp;
  int k[30];
  int a[30][30];
  int sum[31] = {0};
  bool Yes = true;
  scanf("%d %d", &n , &m);
  rep(i, n){
    Yes = true;
    scanf("%d", &k[i]);
    rep(ii,k[i]){
      scanf("%d", &tmp);
      sum[tmp]++;
    }
  }

  rep(i, m + 1){
    if(sum[i] == n) {ssum++;}
  }
  printf("%d", ssum);
  
  

}


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

int main()
{
    int N;
    pair<int, int> A[100000];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        pair<int, int> temp;
        temp.second = i;
        cin >> temp.first;
        A[i] = temp;
    }
    sort(A, A + N);
    int result = 0;
    for(int i = 0; i < N; i++)
        if(abs(A[i].second - i) % 2 != 0)
            result++;
    cout << result / 2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: u64,
        a: u64,
        b: u64,
    );
    let ab = a+b;
    let quot = n / ab;
    let mut sum = quot * a;
    let rem = n % ab;
    if rem < a {
        sum += rem;
    } else {
        sum += a;
    }
    println!("{}", sum)

}



Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	string s;
	while (1){
		stack<char> sc;
		getline(cin, s);
		if (s[0] == '.'&&s.length() == 1)break;
		for (int i = 0; s[i] != '.'; i++){
			if (s[i] == '(' || s[i] == '[') sc.push(s[i]);
			if (s[i] == ')'){
				if (!sc.empty()&&sc.top() == '(')sc.pop();
				else {
					sc.push('!');
					break;
				}
			}
			if (s[i] == ']'){
				if (!sc.empty() && sc.top() == '[')sc.pop();
				else {
					sc.push('!');
					break;
				}
			}
		}
		if (sc.empty())cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

Measured memory_bytes: 1176
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
    

N=int(input())
d=make_divisors(N)
#print(d)
L=len(d)

if L%2==1:
    index=L//2+1
    m=d[index-1]
    sm=str(m)
    print(len(sm))
else:
    index1=L//2
    index2=L//2+1
    m1=d[index1-1]
    m2=d[index2-1]
    sm1=str(m1)
    sm2=str(m2)
    print(max(len(sm1),len(sm2)))



Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    long N = sc.nextLong();
    int[] n = new int[61];
    for(int i = 0; i < 61; i++) {
      n[i] = (int)(N % 2);
      N /= 2;
    }
    long[][] dp = new long[61][3];
    if(n[60] == 0) {
      dp[60][0] = 1;
    } else {
      dp[60][0] = 1;
      dp[60][1] = 1; 
    }
    for(int i = 59; i >= 0; i--) {
      dp[i][2] = (3 * dp[i + 1][2]) % MOD;
      for(int j = 0; j < 3; j++) {
        int c = 2 + n[i] - j;
        if(c >= 2) {
          dp[i][2] = (dp[i][2] + dp[i + 1][1]) % MOD;
        } else {
          dp[i][c] = (dp[i][c] + dp[i + 1][1]) % MOD;
        }
      }
      for(int j = 0; j < 3; j++) {
        int c = n[i] - j;
        if(c < 0) {
        } else {
          dp[i][c] = (dp[i][c] + dp[i + 1][0]) % MOD;
        }
      }
    }
    long ans = dp[0][0]; 
    ans = (ans + dp[0][1]) % MOD;
    ans = (ans + dp[0][2]) % MOD;
    System.out.println(ans);
  }
}

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

int main()
{
  int h,m,s, Sec;

  cin >> Sec; 

  s= Sec % 60;  
  Sec /= 60;    
  m= Sec % 60;  
  h = Sec / 60; 

  cout << h << ":"<< m << ":" << s << endl;

  return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <limits.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;


const char* YesNo(bool b)
{
	if (b)
	{
		return "Yes";
	}
	else
	{
		return "No";
	}
}

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

	int k500 = X / 500;
	X -= k500 * 500;
	int k5 = X / 5;
	int ans = k500 * 1000 + k5 * 5;
	cout << ans << endl;
}

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

int main(){
  double A,B;
  cin >>A>>B;
  for(int i=1;i<1100;i++){
    if((floor(i*0.08)==A)&&(floor(i*0.1)==B)){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

       
   

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

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

    double pay = 100.0;
    for(int i = 0; i < week; i++)
    {
        pay = ceil(pay * 1.05);
    }
    cout << static_cast<int>(pay * 1000) << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<< endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, M);
  int l = -1;
  int r = INF;
  rep(i, 0, M) {
    VAR(int, li, ri);
    l = max(l, li);
    r = min(r, ri);
  }
  print(max(r - l + 1, 0));
}


Measured memory_bytes: 256