akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define int long long

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

int N, x;
int ap[200001];

class Comparator {
public:
    bool operator()(const int &a, const int &b) {
        return a > b;
    }
};

set<int> fo;
set<int, Comparator> re;

signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        ap[a] = i;
    }
    fo.insert(0);
    fo.insert(N + 1);
    re.insert(0);
    re.insert(N + 1);
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int cur = ap[i];
        int l = *re.lower_bound(cur);
        int r = *fo.lower_bound(cur);
        ans += i * (cur - l) * (r - cur);
        fo.insert(cur);
        re.insert(cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20608
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll t = x / d;

    x -= min(t, k) * d;
    k -= min(t, k);
    if (k%2 == 0) {
        cout << x << endl;
    } else {
        cout << abs(x - d) << endl;
    }

return 0;
}

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

int dp[305][305][305];
string s;

int my(int l,int r,int k)
{
	if (dp[l][r][k]!=0)
	{
		return dp[l][r][k];
	}
	else if (l==r)
	{
		dp[l][r][k]=1;
		return 1;
	}
	else if (l+1==r)
	{
		if (s[l]==s[r]||k>0)
		{
			dp[l][r][k]=2;
			return 2;
		}
		else
		{
			dp[l][r][k]=1;
			return 1;
		}
	}
	int ans=max(my(l+1,r,k),my(l,r-1,k));
	if (s[l]==s[r])
	{
		ans=max(ans,my(l+1,r-1,k)+2);
	}
	else if (k>0)
	{
		ans=max(ans,my(l+1,r-1,k-1)+2);
	}
	dp[l][r][k]=ans;
	return ans;
}

int main(int argc, char const *argv[])
{
	int k;
	cin>>s>>k;
	cout<<my(0,s.size()-1,k)<<endl;
	return 0;
}


Measured memory_bytes: 110848
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
x,a = map(int,input().split())

ans = 0 if x<a else 10

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100001
#define MAXN 1000000007
#define pb push_back
#define f first
#define s second
#define INF 2e18

vector<vector<int>>adj;
vector<bool> vis;
int ct=0;
void init(int n)
{
    adj.resize(n+1);
    vis.resize(n+1);
}
void dfs(int v)
{
    vis[v] = true;
    ct++;
    for(int i=0; i<adj[v].size();i++)
    {
        if(!vis[adj[v][i]])
        dfs(adj[v][i]);
    }
}
int main()
{
    int n,m;    cin>>n>>m;
    init(n);
    while(m--)
    {
        int a, b; 
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        if(!vis[i])
        {
            dfs(i);
            ans=max(ans, ct);
            ct=0;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int N, S = 0, R;
  int count = 0;
  cin >> N;
  R = N;
  double d = N;
  
  while (true) {
    count++;
    d /= 10;
    if (d < 1){
      break;
    }
  }
  
  for (int i = 0; i < count; i++) {
    int D = 1;
    for (int j = 1; j < count - i; j++) {
    	D *= 10;
    }
  	S += R / D;
    R %= D;
  }
  
  if (N % S == 0) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
unittest
{
	assert( [ "1 1" ].parse.expand.solve == 3800 );
	assert( [ "10 2" ].parse.expand.solve == 18400 );
	assert( [ "100 5" ].parse.expand.solve == 608000 );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	auto pu = 1.0f / pow( 2, m );
	auto tu = 1900.0f * m + 100 * ( n - m );
	
	auto c = 0f;
	auto pr = 1.0f;
	for( auto i = 1; true; i++ )
	{
		auto p = pr * pu;
		auto t = tu * i;
		auto pt = p * t;
		
		c += pt;
		pr -= p;
		if( pt < 0.1 ) break;		// 適当に打ち切り
	}
	c = c.ceil;
	if( c % 10 != 0 ) c+= 10 - c % 10;		// 途中で打ち切った分の補正
	
	return c;
}


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

using namespace std;

int main() {
    while (1) {
        int dp[17][17] = { 0 };
        int field[17][17] = { 0 };
        int h, w;

        cin >> w >> h;
        if (w == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
            }
        }
        for (int j = 0; j < w; j++) {
            if (field[0][j] != 1) {
                dp[0][j] = 1;
            }
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (dp[i][j] > 0) {
                    if (field[i][j] == 0) {
                        if (i != h - 1 && j != 0 && field[i + 1][j - 1] == 0) {
                            dp[i + 1][j - 1] += dp[i][j];
                        }
                        if (field[i + 1][j] != 1) {
                            dp[i + 1][j] += dp[i][j];
                        }
                        if (i != h - 1 && j != w - 1 && field[i + 1][j + 1] == 0) {
                            dp[i + 1][j + 1] += dp[i][j];
                        }
                    }
                    else if (field[i][j] == 2) {
                        if (i == h - 1) {
                            dp[i + 1][j] += dp[i][j];
                        }
                        else if (field[i + 2][j] != 1){
                            dp[i + 2][j] += dp[i][j];
                        }
                    }
                }
            }
        }
        
        int ans = 0;
        for (int j = 0; j < w; j++) {
            ans += dp[h][j];
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    static int M = 998244353;

    public static void main(String[] args) {
        int N = in.i();
        int[] D = in.ii(N);
        long ans = D[0] == 0 ? solve(N, D) : 0;
        out.println(ans);
    }

    static long solve(int N, int[] D) {
        int[] a = new int[N];
        int max = 0;
        a[0]++;
        for (int i = 1; i < N; i++) {
            int d = D[i];
            if (max < d) max = d;
            a[d]++;
        }
        long ans = a[0] == 1 ? solve2(a, max) : 0;
        return ans;
    }

    static long solve2(int[] a, int max) {
        long ans = 1;
        int v = a[1];
        for (int i = 2; i <= max; i++) {
            ans = ans * pow(v, a[i]) % M;
            v = a[i];
        }
        return ans;
    }

    static long pow(long a, int b) {
        long c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c = c * a % M;
            }
            a = a * a % M;
            b >>= 1;
        }
        return c;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36776
import scala.math._

// longでrangeの作り方

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 c = sc.next
//  val list = List.fill(3)(sc.next)

  val vowels = "aeiou"
  val ans = if (vowels.contains(c)) "vowel" else "consonant"

  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: 25532
#include <bits/stdc++.h>
using namespace std;

void solve(int x, int y){
  for(int i=0; i<y; i++){
    string s = to_string(x);
    cout<<s;
  }
}

int main() {
  int a,b;
  cin>>a>>b;
  if(a<=b){
    solve(a,b);
  }
  else solve(b,a);
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vector<int>c(n);
    vector<int>s(n);
    vector<int>f(n);
    vector<int>ans;
    rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
    for(int _s=0;_s<n;_s++){
        int cnt=0;
        for(int i=_s;i<n-1;i++){
            if(cnt<=s[i])cnt=s[i]+c[i];
            else{
                for(;;){
                    if(cnt%f[i]==0)break;
                    else cnt++;
                }
                cnt+=c[i];
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 256
/*
 * by purple
 * at 12-01-01 10:58:09
 */

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

#define sz(x) ((int)((x).size()))
#define out(x) printf(#x" %d\n", x)
#define rep(i,n) for(int i=0;i<(n);++i)
#define repf(i,a,b) for(int i=(a);i<=(b);++i)

const int maxn = 100 + 10;

char s[maxn];
bool st[maxn];
int top;

int main() {
    while (cin.getline(s, maxn)) {
        if (strcmp(s, ".") == 0) {
            break;
        }
        top = -1;
        bool f = true;
        for (int i = 0; s[i]; ++i) {
            if (s[i] == '[') {
                st[++top] = true;
            } else if (s[i] == ']') {
                if (top == -1 || st[top] != true) {
                    f = false;
                    break;
                }
                --top;
            } else if (s[i] == '(') {
                st[++top] = false;
            } else if (s[i] == ')') {
                if (top == -1 || st[top] != false) {
                    f = false;
                    break;
                }
                --top;
            }
        }
        if (top != -1) {
            f = false;
        }
        puts (f? "yes" : "no");
    }
    return 0;
}

Measured memory_bytes: 832
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    int N; cin >> N;

    int total = 0;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
        total += L[i];
    }

    sort(L.begin(), L.end());

    bool ok = false;
    if (total-L[N-1] > L[N-1]) {
        ok = true;
    }
    
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
L,N=map(int,input().split())
X=[int(input()) for i in range(N)]
X=[0]+X
Y=[0]
for i in range(N,0,-1):
    Y.append(L-X[i])
sum_X=[0]*(N+1)
sum_Y=[0]*(N+1)
for i in range(1,N+1):
    sum_X[i]=X[i]+sum_X[i-1]
    sum_Y[i]=Y[i]+sum_Y[i-1]
ans=0
for i in range(N//2+1,N+1):
    j=N-i
    num_1=2*(sum_Y[j]+sum_X[i]-sum_X[i-j])-Y[j]
    if i!=j:
        num_2=2*(sum_Y[j]+sum_X[i]-sum_X[i-j-1])-X[i]
    ans=max(ans,num_1,num_2)
X,Y=Y[:],X[:]
sum_X,sum_Y=sum_Y[:],sum_X[:]
for i in range(N//2+1,N+1):
    j=N-i
    num_1=2*(sum_Y[j]+sum_X[i]-sum_X[i-j])-Y[j]
    if i!=j:
        num_2=2*(sum_Y[j]+sum_X[i]-sum_X[i-j-1])-X[i]
    ans=max(ans,num_1,num_2)
if N%2==0:
    num_1=2*(sum_X[N//2]+sum_Y[N//2])-X[N//2]
    num_2=2*(sum_X[N//2]+sum_Y[N//2])-Y[N//2]
    ans=max(ans,num_1,num_2)
print(ans)

Measured memory_bytes: 76876
Q = int(input())
AB = [list(map(int, input().split())) for _ in range(Q)]

for a,b in AB:
  if a==b:
    print(2*(a-1))
  else:
    a, b = min(a,b), max(a,b)
    sq = int((a*b)**0.5)
    print(a-1 + sq - a + (a*b-1)//sq -1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	ll D;
	cin >> H >> W >> D;
	vll A(H, vl(W, 0));
	vpll B(H * W);
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> A[i][j];
			B[A[i][j] - 1] = mp(i, j);
		}
	}
	cin >> Q;
	vl sum(H * W);
	for (i = 0; i < H*W; i++) {
		if (i >= D) sum[i] = sum[i - D] + abs(B[i].first - B[i-D].first) + abs(B[i].second - B[i - D].second);
		else sum[i] = 0;
	}
	for (i = 0; i < Q; i++) {
		ll l, r;
		cin >> l >> r;
		l--; r--;
		cout << sum[r] - sum[l] << endl;
	}
}

Measured memory_bytes: 3968
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))+[0]
ans=0
bn,ba=0,0
for i in a:
    ans+=b[i-1]
    if bn+1==i:
        ans+=ba
    bn=i
    ba=c[i-1]
print(ans)

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::vector<int> v(3);Inparray(v,3);
  sort(All(v));
  flag2func(v[0]+v[1]==v[2]);
}


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

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

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

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n;
    cin>>n;

    vi v(n+1);
    rep(i,1,n+1) cin>>v[i];

    int dp[n+1];
    dp[1] = 0;
    if(n==1){
        cout<<"0\n";
        return;
    }
    if(n==2){
        cout<<abs(v[1]-v[2]);
        return;
    }
    dp[2] = abs(v[1]-v[2]);
    dp[3] = min(abs(v[1]-v[3]), abs(v[1]-v[2])+abs(v[2]-v[3]));
    for(int i = 4;i<=n;i++){
        dp[i] = min(dp[i-1]+abs(v[i-1]-v[i]), dp[i-2]+abs(v[i-2]-v[i]));
    }
    cout<<dp[n];
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

typedef long long ll;

const ll MAX = 110000;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline long long factorial(T N) {
    int ans = 1;
    for (int i = 1; i <= N; ++i) {
        ans *= i;
    }
    return ans;
}

vector<int> x(10), y(10);

double distance(int i, int j) {
    double dx, dy;
    dx = x[i] - x[j];
    dy = y[i] - y[j];
    return pow(pow(dx, 2) + pow(dy, 2), 0.5);
}

int main() {
    int N; cin >> N;
    vector<int> v(N);
    int fac = 1;
    double sum = 0.0;
    //初期条件
    x[0] = 0; y[0] = 0;
    
    for (int i = 1; i <= N; ++i) cin >> x[i] >> y[i];

    //ノード(0 ~ N-1) を作成
    for (int i = 0; i < N; ++i) {
        v[i] = i + 1;
    }
    //N!の計算
    fac = factorial(N);
    //ノード(i), ノード(i + 1)までの、エッジの総和を計算
    do {
        for (int i = 0; i < N-1; ++i) {
            sum += distance(v[i], v[i + 1]);
        }
    } while (next_permutation(v.begin(), v.end())); //順列
    //エッジの平均値を計算・出力(浮動小数点6桁以下)
    cout << fixed << setprecision(6) << (sum / fac) << '\n';

    return 0;
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define MAX 100005
#define wa cout<<"wa"<<endl;

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main(){
	int n;
	cin>>n;
	int ans=0,l,r;
	FOR(i,0,n){
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int x;
	cin >> x;
	if(x < 1200)cout << "ABC";
	else cout << "ARC";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main () {
    let mut pqr = String::new();
    stdin().read_line(&mut pqr).unwrap();
    let mut pqr: Vec<isize> = pqr.trim().split_whitespace().flat_map(str::parse).collect();
    pqr.sort();
    println!("{}", pqr[0] + pqr[1]);
}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = ri() - (i + 1)
	}
	sort.Ints(c)
	b := c[len(c)/2]
	ans := 0
	for _, cc := range c {
		ans += abs(cc - b)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2176
N,T=input().split(' ')
N=int(N)
T=int(T)
a=list()
for i in range(N):
    c,t=input().split(' ')
    c=int(c)
    t=int(t)
    a.append((c,t))

minValue=0x3FF

for it in a:
    if it[1]>T:
        continue
    if it[0]<minValue:
        minValue=it[0]
if(minValue==0x3FF):
    print("TLE")
else:
    print(minValue)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int N;
vector<vector<int>> G;
vector<int> d;
vector<int> f;
vector<bool> seen;
int t = 1;

void dfs(int u) {
    seen[u] = true;
    d[u] = t++;

    for (auto nv : G[u]) {
        if (seen[nv]) continue;
        dfs(nv);
    }

    f[u] = t++;
}

int main() {
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N; i++) {
        int u, k; cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v; cin >> v;
            v--;
            G[u].push_back(v);
        }
    }
    d.resize(N);
    f.resize(N);
    seen.assign(N, false);

    for (int v = 0; v < N; v++) {
        if (seen[v]) continue;
        dfs(v);
    }

    for (int v = 0; v < N; v++) {
        cout << v + 1 << " " << d[v] << " " << f[v] << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;

    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll find(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return siz[find(x)];
    }
};

int main(){
    ll N, M; cin >> N >> M;
    UnionFind uf(N);
    rep(i, M){
        ll a, b; cin >> a >> b;
        uf.merge(a - 1, b - 1);
    }
    ll ans = 0;
    rep(i, N){
        chmax(ans, uf.size(i));
    }
    pt(ans);
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int cnt = 0;
	for(int i = 0; i <= A; i++){
		for(int j = 0; j <= B; j++){
			for(int k = 0; k <= C; k++){
				int P = i * 500 + j * 100 + k * 50;
				if(P == X)cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	YesNo(A <= C&&C <= B);
	return 0;
}

Measured memory_bytes: 256
a, b = map(str, input().split())

if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')

Measured memory_bytes: 8980
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

int main(){
    int n,m,p;
    cin >> n >> m >> p;
    while(n > 0){
        vector<int> x(n);
        rep(i, n) cin >> x[i];
        int sum = accumulate(all(x), 0);
        if(x[m-1] == 0) cout << 0 << endl;
        else cout << sum*(100-p)/x[m-1] << endl;
        cin >> n >> m >> p;
    }

}




Measured memory_bytes: 3080
import sys
imput = sys.stdin.readline

N,M = map(int,input().split())
V = [0 for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    V[a-1] += 1
    V[b-1] += 1
print('YES' if all([v%2==0 for v in V]) else 'NO')

Measured memory_bytes: 4724
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
l = len(str(n)) - 1
if n % 10**l == 0:
    if str(n)[0] == '1':
        print(10)
    else:
        ans = 0
        for i in str(n):
            ans += int(i)
        print(ans) 
else:
    ans = 0
    for i in str(n):
        ans += int(i)
    print(ans)



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

int main() {
  int A, B, K;
  bool flag = false;
  
  cin >> K;
  cin >> A >> B;
  
  for(int i = A; i <= B; i++) {
    if (i % K == 0) {
      flag = true;
      break;
    }  
  }  
  
  if (flag) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }  
}  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,x=0; cin>>n>>m;
    if(n>=m) {x+=n; n--;}
    else {x+=m; m--;}
    if(n>=m) {x+=n; n--;}
    else {x+=m; m--;}
    cout<<x<<endl;
    
}


Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    a, b = map(int, input().split())
    S.append((a-b, a+b))

S = sorted(S, key=lambda x: x[1])
res = 0
cur = -1e9
for i in range(N):
    if cur <= S[i][0]:
        res += 1
        cur = S[i][1]

print(res)

Measured memory_bytes: 19028
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回

string f(ll n) {
    if (n == 0) return "";
    n--;
    return f(n/26) + string(1, 'a' + (n%26));
}

int main() {
    ll n;
    cin >> n;
    string ans;
    while(n) {
        n--;
        ans += 'a' + n % 26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m,d;
    cin >> m >> d;
    int ans = 0;
    repf(i,1,m+1){
        repf(j,1,d+1){
            int d1 = j % 10, d2 = j / 10;
            if (d1*d2==i && d1>=2 && d2>=2)
                ans++;
        }
    }
    cout << ans << ENDL;
}

Measured memory_bytes: 256
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def resolve():
    N, M = map(int, input().split())

    res = 0
    if N >= 2:
        res += combinations_count(N, 2)
    if M >= 2:
        res += combinations_count(M, 2)
    print(res)


if __name__ == "__main__":
    resolve()

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

void Main()
{
	char b; cin >> b;
	char res;
	switch (b)
	{
	case 'A':
		res = 'T';
		break;
	case 'T':
		res = 'A';
		break;
	case 'C':
		res = 'G';
		break;
	case 'G':
		res = 'C';
		break;
	default:
		break;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
    int n,d; cin >> d >> n;
    int S = 1; for (int i = 0; i < d; i++) S *= 100;
    cout << (n<=99 ? S*n: S*101) << endl;
    // int D, N; cin >> D >> N;
 
	// int S = 1; for (int i = 0; i < D; i++) S *= 100;
	// if (N <= 99) {
	// 	cout << S * N << endl;
	// }
	// else {
	// 	cout << S * 101 << endl;
	// }
	// return 0;
}

Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/dsu>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

int main() {
    int n,q; cin >> n >> q;
    ac::dsu uf(n);
    rip(i,q,0) {
        int id, u, v; cin >> id >> u >> v;
        if(id == 0) {
            uf.merge(u, v);
        }
        else  {
            if(uf.same(u,v)) {
                printf("1\n");
            }
            else {
                printf("0\n");
            }
        }
    }
}

Measured memory_bytes: 3968
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> set = new HashSet<String>();

        String prev = sc.next();
        set.add(prev);
        String curr = null;
        for (int i = 2; i <= N; i++) {
            curr = sc.next();

            if (set.contains(curr)) {
                System.out.println("No");
                return;
            }
            set.add(curr);

            int np = prev.length();
            if (prev.charAt(np - 1) != curr.charAt(0)) {
                System.out.println("No");
                return;
            }
            prev = curr;
        }

        System.out.println("Yes");

        return;
    }

}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <vector>
#include <algorithm>

using namespace std;
int main()
{
	string S;
	cin >> S;
	
	if(S == "0") {
		//printf("No\n");
		//return 0;
	}
	
	int len = S.length();
	int sum = 0;
	for(int i = 0; i < len; i++) {
		char ss = S[i];
		sum += atoi(&ss);
	}
	if(sum % 9 == 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
    return 0;

}

Measured memory_bytes: 3736
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    for i in range(H):
        if i % 2 == 0:
            if W % 2 == 0:
                print('#.' * (W // 2))
            else:
                print('#.' * (W // 2) + '#')
        else:
            if W % 2 == 0:
                print('.#' * (W // 2))
            else:
                print('.#' * (W // 2) + '.')
    print()

Measured memory_bytes: 7628
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  A = readint()
  B = readint()

  s = 0
  for i in N:-1:1
    t = min(A[i+1],B[i])
    s += t
    if t < B[i]
      t2 = min(A[i], B[i]-t)
      A[i] -= t2
      s += t2
    end
  end
  println(s)


end



main()

Measured memory_bytes: 208008
#include <iostream>

using namespace std;

int main(void){
  int n,k;

  cin >> n >> k;
  while(k--){
    int x,y;
    cin >> y >> x;
    y -= 1; x -= 1;
    if(y > n/2) y = n - y - 1;
    if(x > n/2) x = n - x - 1;
    if(y > x) swap(x,y);
    if(y%3 == 0){
      cout << 1 << endl;
    }else if(y%3==1){
      cout << 2 << endl;
    }else{
      cout << 3 << endl;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, q;
    cin >> n >> q;

    ll black = (ll)(n - 2) * (n - 2);
    vector<int> a(n, n), b(n, n);
    int H = n, W = n;
    while (q--) {
        int dir, x;
        cin >> dir >> x;
        if (dir == 1) {
            if (x < W) {
                for (int i = x; i < W; i++) {
                    b[i] = H;
                }
                W = x;
            }
            black -= b[x] - 2;
        }
        else {
            if (x < H) {
                for (int i = x; i < H; i++) {
                    a[i] = W;
                }
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << '\n';
}


Measured memory_bytes: 4796
from collections import Counter

n = int(input())

pf = []

for i in range(2, n+1):
    f = i
    cnt = 2
    while True:
        if not f % cnt:
            pf.append(cnt)
            f //= cnt
            if f == 1: break
        else: cnt += 1
          
c = Counter(pf)
ans = 1
for v in c.values():
    ans *= v+1

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


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        char[] input = nstr().toCharArray();
        int len = input.length;

        char[] s = new char[len+1];
        System.arraycopy(input, 0, s, 1, input.length);
        
        final int MOD_2 = 13;
        long[][] dp = new long[len+1][MOD_2];
        
        dp[0][0] = 1;
        for (int i = 1; i <= len; i++) {
            for (int rem = 0; rem < MOD_2; rem++) {
                for (int digI = 0; digI <= 9; digI++) {
                    if (s[i] != '?' && (s[i]-'0') != digI) {
                        continue;
                    }
                    int newRem = (rem*10 + digI) % MOD_2;
                    dp[i][newRem] += dp[i-1][rem];
                    dp[i][newRem] %= MOD;
                }
            }
        }
        System.out.println(dp[len][5]);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }
    
    private static String nstr() {
        return sc.next();
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, M;
    cin >> N >> M;

    ll sM = sqrt(M) + 3;
    ll res = 0;
    for(ll x=1;x<=sM;x++){
    	if(M%x==0){
    		if(M/x>=N) chmax(res, x);
    		if(x>=N) chmax(res, M/x);
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    char str[5];
    int i;
    cin >> str;
    
    for(i=0;i<3;i++){
        if( str[i] == str[i+1]){
            break;
        }
    }
    if( i == 3){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256