akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = MAP()
A = [LIST() for i in range(M)]
C = [LIST() for i in range(K)]

tree = UnionFind(N)
block = defaultdict(list)
friend = defaultdict(list)

for a, b in A:
    tree.union(a-1, b-1)
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)

for c, d in C:
    block[c-1].append(d-1)
    block[d-1].append(c-1)

for i in range(N):
    block_num = 0
    for b in block[i]:
        # iを含む木の中にbが含まれているかどうか
        if tree.same(i, b):
            block_num += 1

    ans = tree.size(i) - 1 - len(friend[i]) - block_num
    print(ans, end=" ")
print()





Measured memory_bytes: 109396
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

// (K-1)C(i-1) * (N-K+1)C(i)

type combi struct {
	fac  []int
	finv []int
	inv  []int
	mod  int
}

func (c *combi) init(n int, m int) {
	c.fac = make([]int, n)
	c.finv = make([]int, n)
	c.inv = make([]int, n)
	c.mod = m

	c.fac[0] = 1
	c.fac[1] = 1
	c.finv[0] = 1
	c.finv[1] = 1
	c.inv[1] = 1
	for i := 2; i < n; i++ {
		c.fac[i] = c.fac[i-1] * i % c.mod
		c.inv[i] = c.mod - c.inv[c.mod%i]*(c.mod/i)%c.mod
		c.finv[i] = c.finv[i-1] * c.inv[i] % c.mod
	}
}

func (c *combi) combi(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return c.fac[n] * (c.finv[k] * c.finv[n-k] % c.mod) % c.mod
}

func answer2(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	var c combi
	mod := int(1e9) + 7
	c.init(n+1, mod)
	for i := 0; i < k; i++ {
		//if n-k >= i && k-1 >= i {
		//debugf("i: %d, n:%d, k:%d\n", i, n, k)
		b := c.combi(k-1, i)
		r := c.combi(n-k+1, i+1)
		debugf("%d: %d * %d = %d\n", i, b, r, (b*r)%mod)
		_, _ = fmt.Fprintf(writer, "%d\n", (b*r)%mod)
		//} else {
		//	break
		//}
	}
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	m := max(n-k+3, k+3)
	mod := uint64(1e9) + uint64(7)
	dp := make([][]uint64, m)
	for i := 0; i < m; i++ {
		dp[i] = make([]uint64, m)
	}
	for i := 0; i < m; i++ {
		dp[i][0] = 1
		dp[0][i] = 1
	}
	for i := 1; i < m; i++ {
		for j := 1; j < m; j++ {
			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod
		}
	}
	//debugf("%v\n", dp)

	for i := 0; i < k; i++ {
		if n-k-i >= 0 && k-i-1 >= 0 {
			debugf("%d: %d * %d = %d\n", i, dp[n-k-i][i+1], dp[k-i-1][i], (dp[n-k-i][i+1]*dp[k-i-1][i])%mod)
			_, _ = fmt.Fprintf(writer, "%d\n", (dp[n-k-i][i+1]*dp[k-i-1][i])%mod)
		} else {
			_, _ = fmt.Fprintf(writer, "0\n")
		}
	}

}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 33920
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
using namespace std;

#define MAXN 1000000

int N, A[MAXN];
int W[MAXN];

int merge_and_count(int l, int r) {
    if (l+1 >= r) return 0;
    if (l+2 == r) {
        if (A[l] <= A[l+1]) return 0;
        swap(A[l], A[l+1]);
        return 1;
    }
    int m = (l+r)/2;
    int cl = merge_and_count(l, m);
    int cr = merge_and_count(m, r);
    int c = 0;
    int i = l, j = m;
    int k = l;
    while (i < m && j < r) {
        if (A[i] <= A[j]) W[k++] = A[i++];
        else {
            W[k++] = A[j++];
            c += m-i;
        }
    }
    while (i < m) {
        W[k++] = A[i++];
    }
    while (j < r) W[k++] = A[j++];
    assert(k == r);
    copy(W+l, W+r, A+l);
    return cl+cr+c;
}

int main(void) {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        for (int i = 0; i < n; i++) cin >> A[i];
        cout << merge_and_count(0, n) << endl;
    }
    return 0;
}

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

using i64 = int_fast64_t;

signed main(){

  i64 n,k;
  cin>>n>>k;
  vector<i64> a(n);
  for(auto& ai:a)cin>>ai;

  i64 res = 0;
  for(int i=62;i>=0;--i){
    if((res|(1LL<<i))>k)continue;
    int cnt = 0;
    for(auto& ai:a)cnt+=((ai>>i)&1);
    if(cnt<=n/2)res|=(1LL<<i);
  }
  i64 ans = 0;
  for(auto& ai:a)ans+=ai^res;
  cout<<(ans)<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <cctype>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
int read()
{
	int out = 0;
	char c;
	while (!isdigit(c = getchar()));
	for (; isdigit(c); c = getchar()) out = out * 10 + c - '0';
	return out; 
}
 
const int N = 5010;
const int M = 205;
const int B = 1000;
const int MAXOP = 2.12e9;
 
int n, m, d[N], w[N][M], mx[M], cnt;
ll ans, res[N], blres[N];
 
ll calc(int x)
{
	if (res[x]) return res[x];
	ll out = 0, tmp = 0;
	memset(mx, 0, sizeof(mx));
	cnt += (n - x + 1) * m;
	for (int i = x; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
		    int wij = w[i][j];
		    int & mxj = mx[j];
			if (wij > mxj)
			{
				tmp += wij - mxj;
				mxj = wij;
			}
		}
		out = max(out, tmp);
		tmp -= d[i];
	}
	ans = max(ans, out);
	return res[x] = out;
}
 
void sa(int l, int r, double speed)
{
	int cur = (l + r) >> 1;
	double t = 1e3;
	
	while (t > 0.001)
	{
		ll old = calc(cur);
		ll range = ceil(t);
		int rl = max((ll) l, cur - range);
		int rr = min((ll) r, cur + range);
		int nxt = rand() % (rr - rl + 1) + l;
		ll delta = old - calc(nxt);
		//if (calc(nxt) > old) cerr << exp(-delta / t) << endl;
		if (exp(-delta / t) > (double) rand() / RAND_MAX) cur = nxt;
		t *= speed;
		if (cnt > MAXOP) break;
	}
	
	blres[l] = max(blres[l], calc(cur));
}
 
int main()
{
	int* qwq = new int;
	srand(time(0) ^ (ll) qwq ^ 114514);
	
	n = read();
	m = read();
	
	for (int i = 1; i < n; ++i) d[i] = read();
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			w[i][j] = read();
		}
	}
	
	if ((ll) n * n * m <= MAXOP) for (int i = 1; i <= n; ++i) calc(i);
	
	else
	{
		/*double sp = 0.8;
		int eq = 0;
		while (cnt < MAXOP)
		{
			int old = cnt;
			sa(1, n, sp *= 1.01);
			if (cnt == old)
			{
				if (++eq > 10) break;
			}
			else eq = 0;
		}*/
		
		/*ll best = 0;
		
		while (cnt < MAXOP / 2)
		{
			int old = cnt;
			for (int i = 1; i <= n; i += B)
			{
				sa(i, min(i + B - 1, n), 0.6);
				best = max(best, blres[i]);
			}
			if (cnt == old) break;
		}*/
		sa(1, n, 0.9);
		
		int eq = 0; 
		while (cnt < MAXOP)
		{
			int old = cnt;
			for (int i = 1; i <= n; i += B)
			{
				sa(i, min(i + B - 1, n), 0.77);
			}
			if (cnt == old)
			{
				if (++eq > 100) break;
			}
			else eq = 0;
		}
	}
	
	cout << ans;
	
	return 0;
}

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 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;
}

typedef long long ll;

#define MAX_N 10000
#define ORD_MONEY 1000000000000000

struct Edge {
    int to;
    ll weight_yen;
    ll weight_sunuke;
    Edge(int t, ll y, ll s)
        : to(t)
        , weight_yen(y)
        , weight_sunuke(s)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<ll, int> P; // first:最短距離，second:頂点番号

void dijkstra(int s, int V, Graph_e G, ll* d, bool mode)
{ // mode=trueならsから，falseならtから
    fill(d, d + V, INF_64);
    d[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que; // 距離が小さいものから取り出せるように
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second; //更新した頂点の中で距離が最小の頂点
        if (d[v] < p.first) {
            continue;
        }

        for (auto e : G[v]) {
            if (mode) {
                if (d[e.to] > d[v] + e.weight_yen) {
                    d[e.to] = d[v] + e.weight_yen;
                    que.push(P(d[e.to], e.to));
                }
            } else {
                if (d[e.to] > d[v] + e.weight_sunuke) {
                    d[e.to] = d[v] + e.weight_sunuke;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }
}

int main()
{
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;

    Graph_e G(n);
    ll d_s[n];
    ll d_t[n];

    rep(i, m)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        G[u].push_back(Edge(v, a, b));
        G[v].push_back(Edge(u, a, b));
    }
    // どこかで両替したら以降はずっとsunuke
    //
    // 両替を都市iで行う場合，
    // sからiに円による支払いで移動する際の最小金額（yen)
    // iからtにsunukeによる支払いで移動する際の最小金額（sunuke）
    // の和になる
    // tからiにスヌークによる支払いで移動する際の最小金額とiからtにスヌークによる支払いで移動する際の最小金額は同じ
    // これらをダイクストラ法でそれぞれ求めれば良い

    dijkstra(s, n, G, d_s, true);
    dijkstra(t, n, G, d_t, false);

    ll d_sum[n];
    ll ans[n];
    rep(i, n)
    {
        d_sum[i] = d_s[i] + d_t[i];
    }

    ll min = INF_64;
    for (int i = n - 1; i >= 0; i--) {
        if (d_sum[i] < min) {
            min = d_sum[i];
        }
        ans[i] = ORD_MONEY - min;
    }

    rep(i, n)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 20220
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int A,B,C,K;
int main(){
    cin>>A>>B>>C>>K;
    bool flag=0;
    for(int i=0;i<K;++i){
        if(A>=B){
            B*=2;
        }
        else if(B>=C){
            C*=2;
        }
        if(A<B && B < C){
            flag=1;
            break;
        }
    }
    if(flag==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

int main(void){
  string S;
  cin >> S;
  for(int i = 0; i < S.length(); i++){
    if(i % 2 == 1 && S[i] == 'R'){
      cout << "No";
      return 0;
    }
    if(i % 2 == 0 && S[i] == 'L'){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#define N 20001
using namespace std;
struct set{
  int t;
  int s;
  int d;
};
int main(){
  int n,m,i,j,cnt,source,destination,start,end[N],flag;
  struct set data[N];
  while(1){
    for(i=1;i<N;i++) end[i]=0;
    end[1]=1;
    cin >> n >> m;
    if(n==0&&m==0) break;
    for(i=0;i<m;i++){
      cin >> data[i].t >> data[i].s >> data[i].d;
    }
    for(i=0;i<m;i++){
      for(j=1;j<m;j++){
    if(data[j].t<data[j-1].t) swap(data[j],data[j-1]);
      }
    }
    for(i=0;i<m;i++){
      if(end[data[i].s]==1) end[data[i].d]=1;
    }
    cnt=0;
    for(i=1;i<=n;i++) if(end[i]==1) cnt++;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1472
def main():
    N = input()
    hitoketa = int(N[len(N)-1])
    
    if hitoketa == 3:
        print("bon")
    elif hitoketa == 0 or hitoketa == 1 or hitoketa == 6 or hitoketa == 8:
        print("pon")
    else:
        print("hon")
    #a = list(map(int, input().split()))
    #print(a)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();

            int len = S.length();
            char[] scs = new char['z' - 'a' + 1];
            char[] tcs = new char['z' - 'a' + 1];
            for (int i = 0; i < len; i++) {
                char sa = S.charAt(i);
                char ta = T.charAt(i);
                int si = sa - 'a';
                int ti = ta - 'a';
                if (scs[ti] == 0) {
                    scs[ti] = sa;
                }
                if (tcs[si] == 0) {
                    tcs[si] = ta;
                }
                if (scs[ti] != sa || tcs[si] != ta) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 26836
S=input()
Q=int(input())
query=[]
for _ in range(Q):
    query.append(input().split())

flag = True
t=""
u=""

for i in query:
    if i[0]=="1":
        u,t=t,u
        flag = not flag
#        S=S[::-1]
    else:
        if i[1]=="1":
            t+=i[2]
        else:
            u+=i[2]
if flag:
    print(t[::-1]+S+u)
else:
    print(t[::-1]+S[::-1]+u)

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 9223372036854775800;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 62;
const long double PI = 3.141592653589793;
const int DIGITSIZE = 18;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
int x8[] = {1, 1, 1, -1, -1, -1, 0, 0};
int y8[] = {1, 0, -1, 1, 0, -1, 1, -1};
bool takeTestCases = 0;
bool printCaseNo = 0;

void getac(int T) {
	ll n, x, m;
	cin >> n >> x >> m;
	map < int , ll > arr;
	arr[1] = x;

	map < int , int > mp;
	mp[x] = 1;
	ll startCycle = -1;
	ll ans = x;
	if (n == 1) {
		cout << x << '\n'; return;
	}

	for (int i = 2; i <= n; i++) {
		arr[i] = 0;
		ll val = arr[i - 1] * arr[i - 1];

		val %= m;
		if (mp[val] == 0) {
			mp[val] = i;
			ans += val;
			arr[i] = val;
		} else {
			ll cycleLength = i - mp[val];
			startCycle = mp[val];
			ll remValues = n - i + 1;
			ll totalCycles = remValues / cycleLength;
			ll totalCycleVal = 0;
			ll remCycle = remValues - cycleLength * totalCycles;
			//debug(cycleLength, i, remCycle, remValues, startCycle, totalCycles);
			int k = 0;
			for (int j = startCycle; j < i; j++) {
				if (k < remCycle) {
					ans += arr[j];
					k++;
				}
				totalCycleVal += arr[j];

			}

			ans += totalCycleVal * totalCycles;
			break;
		}
	}
	// for (int i = 1; i <= n; i++) {
	// 	cout << arr[i] << ' ';
	// }
	cout << ans << '\n';
}
int  main()
{

	fastio;
	int t = 1;
	if (takeTestCases) { cin >> t; }
	int t_t = 1;
	while (t--) {
		if (printCaseNo)
		case (t_t);
		getac(t_t);
		t_t++;
	}
	cerr << "Total time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
	return 0;
}


Measured memory_bytes: 9164
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j]=0

ans='No'
#tate
for i in range(3):
  if a[0][i]+a[1][i]+a[2][i]==0:
    ans='Yes'
#yoko
for i in range(3):
  if sum(a[i])==0:
    ans='Yes'
#naname
if a[0][0]+a[1][1]+a[2][2]==0 or a[0][2]+a[1][1]+a[2][0]==0:
  ans='Yes'
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] abc = Console.ReadLine().Split().Select(long.Parse).ToArray();

        string ans = "Yes";
        //abcがすべて等しい場合
        if (abc[0] == abc[1] && abc[0] == abc[2] && abc[1] == abc[2])
        {
            ans = "No";
        }

        //abcがすべて異なる場合
        if (abc[0] != abc[1] && abc[0] != abc[2] && abc[1] != abc[2])
        {
            ans = "No";
        }

        Console.WriteLine(ans);
    }
}

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

inline void swap(int *a,int *b){
  int *tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main()
{
  int i,j,max;
  int a[5];

  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]){
    for(i=0;i<4;i++){
      max = i;
      for(j=i+1;j<5;j++){
	if(a[max]<a[j])max = j;
      }
      swap(a[i],a[max]);
    }
    for(i=0;i<4;i++)cout << a[i] << " ";
    cout << a[4] << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define all(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*
2d pointer array
int **dp;
in main function
int row,col;
dp=new int*[n];
rep(i,n)dp[i]=new int[m]
*/
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n,d;
  cin>>n>>d;
  int arr[n][d];
  rep(i,n)
  {
    rep(j,d)cin>>arr[i][j];
  }
  int ans=0;
  rep(i,n){
      repre(j,i+1,n-1)
      {
        int dist=0;
        repre(k,0,d-1)dist+=(arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
        int temp=sqrt(dist);
        if(temp*temp==dist)ans++;
      }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	int n;
	cin >> n;
	int x[n][n];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> x[i][j];
		}
	}
	int maxi = 0;
	int tmp = 0;
	for (int i = 0; i < n; i++) {
		if (x[i][0] == x[i][1]) tmp++;
		else {
			maxi = max(maxi, tmp);
			tmp = 0;
		}
	}
	maxi = max(maxi, tmp);
	if (maxi >= 3) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 3684
//a.c A-Rated for Me
#include<stdio.h>

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

    if(r<1200){
        printf("ABC\n");
    }else if(r<2800){
        printf("ARC\n");
    }else{
        printf("AGC\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{

	int N;
	scanf("%d", &N);

	if (N / 10 == 111)
		printf("Yes");
	else if (N / 10 == 222)
		printf("Yes");
	else if (N / 10 == 333)
		printf("Yes");
	else if (N / 10 == 444)
		printf("Yes");
	else if (N / 10 == 444)
		printf("Yes");
	else if (N / 10 == 555)
		printf("Yes");
	else if (N / 10 == 666)
		printf("Yes");
	else if (N / 10 == 777)
		printf("Yes");
	else if (N / 10 == 888)
		printf("Yes");
	else if (N / 10 == 999)
		printf("Yes");

	else {

		while (1) {
			N = N - 1000;
			if (N < 1000) break;
		}
		if (N == 999)
			printf("Yes");
		else if (N == 888)
			printf("Yes");
		else if (N == 777)
			printf("Yes");
		else if (N == 666)
			printf("Yes");
		else if (N == 555)
			printf("Yes");
		else if (N == 444)
			printf("Yes");
		else if (N == 333)
			printf("Yes");
		else if (N == 222)
			printf("Yes");
		else if (N == 111)
			printf("Yes");
		else if (N == 0)
			printf("Yes");

		else
			printf("No");
	}

	return 0;




	

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
int N,L,S,B,X=INF;
int main(void){
    scanf("%d%d",&N,&L);
    F(N){
        S+=L+i;
        if(abs(X)>abs(L+i))X=L+i;
    }
    printf("%d\n",S-X);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

//最大公約数
	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	//素数判定
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}
	
	int check(int N, int a, int b) {
		int A,B,i;
		if (a > b) {
			A = a;
			B = b;
		}
		else {
			A = b;
			B = a;
		}
		for (i = N / b; i > 0; i--) {
			if ((N - b * i) % a == 0) {
				return i;
			}
		}
		return 0;
	}
	//コンビネーション(n,r)
	ull combination(int n, int r) {
		if (r * 2 > n) r = n - r;
		ull dividend = 1;
		ull divisor = 1;
		for (int i = 1; i <= r; ++i) {
			dividend *= (n - i + 1);
			divisor *= i;
		}
		return dividend / divisor;
	}

	void Swap(int* left, int* right)
	{
		int temp = *left;
		*left = *right;
		*right = temp;
	}

int main() {
	string b;
	cin >> b;
	if (b == "A")
		cout << "T";
	else if (b == "C")
		cout << "G";
	else if (b == "G")
		cout << "C";
	else if (b == "T")
		cout << "A";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
dic={"x":"y","y":"x"}

a = list(input())
X,Y = map(int,input().split())

direction = "x"
cersol = 0
while cersol < len(a) and a[cersol] == "F":
    cersol+=1
    X -= 1#これは確定した動きなので目的地をずらす方が楽

move = {"x":[],"y":[]}

while cersol < len(a):
    if a[cersol]=="T":#ターンならターン
        direction=dic[direction]
        cersol+=1

    count = 0
    while cersol < len(a) and a[cersol] == "F":
        count+=1
        cersol+=1
    
    move[direction].append(count)


able = {0:0}
preable = {0:0}
for i in move["x"]:
    able={}
    for j in preable:
        able[j+i]=0
        able[j-i]=0
    preable=able


ableX = able

able = {0:0}
preable = {0:0}
for i in move["y"]:
    able = {}
    for j in preable:
        able[j+i]=0
        able[j-i]=0
    preable=able

if (X in ableX)and(Y in able):
    print("Yes")
else:
    print("No")


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void dijkstra(vector<pii> graph[],vector<int> &dist,int start){ //distは初期化しておくこと
    typedef pair<int,int> pii;
    priority_queue<pii,vector<pii>,greater<pii>> que;
    dist[start]=0;
    que.push(make_pair(0,start));
    while(!que.empty()){
        pii p=que.top();
        que.pop();
        int v=p.second;
        if(p.first>dist[v]) continue;
        for(auto &e:graph[v]){
            int cost=e.first,u=e.second;
            if(dist[v]+cost<dist[u]){
                dist[u]=dist[v]+cost;
                que.push(make_pair(dist[u],u));
            }
        }
    }
}

void solve_(int n){
    vector<int> a(n),b(n);
    for(auto &x:a) cin >> x;
    for(auto &x:b) cin >> x;

    vector<pii> graph[201]; //[0,n):1つ目のビル,[n,2*n):2つ目のビル,2*n:ゴール
    rep(floor,0,n){
        int type=a[floor];
        vector<pii> &cur_node=graph[floor];
        if(floor==n-1&&type!=2) cur_node.push_back(make_pair(0,2*n));
        if(type==0||(type==1&&(floor==n-1||a[floor+1]!=1))){
            cur_node.push_back(make_pair(1,n+floor));
            if(floor+1<n) cur_node.push_back(make_pair(1,n+floor+1));
            if(floor+2<n) cur_node.push_back(make_pair(1,n+floor+2));
        }else if(type==1){
            cur_node.push_back(make_pair(0,floor+1));
        }else{
            cur_node.push_back(make_pair(0,floor-1));
        }
    }
    rep(floor,0,n){
        int type=b[floor];
        vector<pii> &cur_node=graph[n+floor];
        if(floor==n-1&&type!=2) cur_node.push_back(make_pair(0,2*n));
        if(type==0||(type==1&&(floor==n-1||b[floor+1]!=1))){
            cur_node.push_back(make_pair(1,floor));
            if(floor+1<n) cur_node.push_back(make_pair(1,floor+1));
            if(floor+2<n) cur_node.push_back(make_pair(1,floor+2));
        }else if(type==1){
            cur_node.push_back(make_pair(0,n+floor+1));
        }else{
            cur_node.push_back(make_pair(0,n+floor-1));
        }
    }

    int ans=inf;
    vector<int> dist(2*n+1,inf);
    dijkstra(graph,dist,0);
    ans=min(ans,dist[2*n]);
    fill(dist.begin(),dist.end(),inf);
    dijkstra(graph,dist,n);
    ans=min(ans,dist[2*n]);

    if(ans==inf) cout << "NA" << endl;
    else cout << ans << endl;
}

void solve(){
    dump(inf);
    int n;
    while(cin >> n,n) solve_(n);
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1212
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($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 {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: usize = 1e9 as usize + 7;
fn main() {
    input!{
        n: usize,
        s: chars,
    }
    let mut cnt = HashMap::new();

    for c in s {
        *cnt.entry(c).or_insert(0) += 1;
    }

    let mut ans = 1;
    for (_, v) in cnt {
        //dbg!(&v);
        ans *= (v + 1);
        ans %= MOD;
    }
    ans -= 1;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int a[N],b[N],num[N];
int x[100][100];
ll n,m,k;
int main()
{
    scanf("%lld%lld",&n,&m);
 
    if(n%2019==0||m%2019==0) 
	{
		cout<<0<<endl;
		return 0;
	}
	int x1=n/2019;
    int y1=m/2019; 
    
    if(y1>x1)
	{
		cout<<0<<endl;
		return 0;
	}
 
	ll ans=2020;
	for(ll i=n;i<=m;i++)
	{
		for(ll j=i+1;j<=m;j++)
			ans=min((i%2019*j%2019)%2019,ans);
	}
	
   cout<<ans<<endl;
    return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long digit = 1;
    for(int i= 2;i<=sqrt(n);i++){
        if(n%i == 0)digit = i;
    }
    cout << to_string(n/digit).length() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#define ll unsigned long long
ll factor[300]; 
ll memory[300];
int primefac(ll num){
    int i = 0,sum,n=0;
    while(*(factor+i) != 0){
        sum =1;
        while(num % *(factor+i)==0){
            num /= *(factor+i);
            memory[*(factor+i)] +=1;
        }
        i++;
    }
    return sum;
}


int elast(ll number){    
    ll tmp=0;
    int flag=0;
    *factor = 2;
    for(int i=3;i <= number;i++){
        flag=0;
        for(int j=0;j <= tmp ;j++){
            if(i % (*(factor+j)) == 0){
                flag=1;
                break;
            }
        }
        if(flag)continue;
        tmp += 1;
        *(factor+tmp) = i;
    }
        return tmp+2;
}

ll nCr(int n,int r){
  ll val=1;
  int i;
  if(r==0)return 1;
  for(i=0;i<n-r;i++){
		val *= (n-i);
		val /= (i+1);
	}
  return val;
}

int main(){
    ll three=0,nago=0,nigo=0,igo=0;
    ll five=0,N,i,j,sum=0;
    memset(factor ,0, sizeof(factor));
    memset(memory,0,sizeof(memory));
    scanf("%llu",&N);
    elast(N);
    for(i=1;i<N;i++){
      primefac(i+1);
    }
    for(i=0;i<N;i++){
      if(memory[i]+1>=75)nago++;
      if(memory[i]+1>=25)nigo++;
      if(memory[i]+1>=15)igo++;
      if(memory[i]+1>=5){
        five++;
        three++;
      }
      else if(memory[i]+1>=3){
        three++;
      }
    }
    if(three>=2){
     sum += nCr(five,2)*(three-2);
     sum +=nago;
     sum += nigo*(three-1);
     sum += igo*(five-1);
    }
    printf("%llu",sum);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<tuple>
#include<utility>

using namespace std;



int main() {

	int n, m;
	cin >> n >> m;

	cout << (n - 1) * (m - 1) << endl;

	return 0;
}




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

using ll=long long;
using namespace std;

int main(){
    int n;
    cin>>n;
    
    bool flag=true;
    int i=1;
    while(flag){
        if(pow(2,i)>n){
            i--;
            flag=false;
            continue;
        }
        i++;
    }
    
    cout<<pow(2,i)<<endl;
    return 0;
}


Measured memory_bytes: 4184
#include <iostream>
#include <vector>
#include <queue>

#define SIZE 1000
#define INF  10000

using P = std::pair< int, int >;

int H, W, ans;
int dh[4] = { 0,  1,  0, -1};
int dw[4] = { 1,  0, -1,  0};
std::queue< P > que;
char a[SIZE][SIZE];

void solve() {
    while (!que.empty()) {
        int  n = que.size();
        bool f = false;
        for (int i=0; i<n; ++i) {
            P q = que.front();
            que.pop();
            for (int j=0; j<4; ++j) {
                int hh = q.first + dh[j], ww = q.second + dw[j];
                if (0 <= hh && hh < H && 0 <= ww && ww < W && a[hh][ww] == '.') {
                    a[hh][ww] = '#';
                    f = true;
                    que.push( std::make_pair(hh, ww) );
                }
            }
        }
        if (f) ++ans;
    }
}

int main() {
    std::cin >> H >> W;
    for (int h=0; h<H; ++h) {
        for (int w=0; w<W; ++w) {
            std::cin >> a[h][w];
            if (a[h][w] == '#') que.push( std::make_pair(h, w) );
        }
    }
    solve();
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 9360
#include<bits/stdc++.h>
#define rep(q,a,b) for(int q=a,q##_end_=b;q<=q##_end_;++q)
#define dep(q,a,b) for(int q=a,q##_end_=b;q>=q##_end_;--q)
#define mem(a,b) memset(a,b,sizeof a )
#define debug(a) cerr<<#a<<' '<<a<<"___"<<endl
using namespace std;
void in(int &r) {
	static char c;
	r=0;
	while(c=getchar(),!isdigit(c));
	do r=(r<<1)+(r<<3)+(c^48);
	while(c=getchar(),isdigit(c));
}
const int mn=200005;
int last[mn],n,ans[mn],val[mn];
const int mod=1e9+7;
int main(){
	in(n);
	rep(q,1,n)in(val[q]);
	int ct=0;
	rep(q,1,n)if(val[q]!=val[q-1])val[++ct]=val[q];
	n=ct;
	ans[1]=1;
	last[val[1]]=1;
	rep(q,2,n){
	    ans[q]=(ans[last[val[q]]]+ans[q-1])%mod;
	    last[val[q]]=q;
	}
//	rep(q,1,n)cout<<ans[q]<<endl;
	cout<<ans[n];
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      string N = System.Console.ReadLine();
      long sum = 0;
      for(int i = 0; i < N.Length; i++){
        sum = sum + long.Parse(N[i].ToString());
      }
      if(sum % 9 == 0){
      	Console.WriteLine("Yes");
      }else{
      	Console.WriteLine("No");
      }
	}
}

Measured memory_bytes: 21784
N = int(input())
H = list(map(int, input().split()))

dp = [0 for _ in range(N+1)]

for i in range(N):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i-1] + abs(H[i] - H[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[N-1])


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

using namespace std;

bool sosu(int n)
{
	if(n == 1)
	{
		return false;
	}
	if(n == 2)
	{
		return true;
	}
	
		
	for(int i = 2; i < (n/2) + 1; i++)
	{
		if((n % i) == 0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	
	vector<int> s;
	int cnt = 0;
	for(int k = 1; k <= 100000; k++)
	{
		if(k == 1 || k == 2)
		{
			s.push_back(cnt);
			continue;
		}
		
		bool flag = true;
		for(int i = 2; i < (k/2) + 1; i++)
		{
			if((k % i) == 0)
			{
				flag = false;
				s.push_back(cnt);
				break;
			}
		}
		if(flag == true)
		{
			if(sosu((k+1)/2) == true)
			{
				s.push_back(++cnt);
			}
			else
			{
				s.push_back(cnt);
			}
		}
	}
	
	int ans[n] = {0};
	for(int i = 0; i < n; i++)
	{
		int l, r;
		cin >> l >> r;
		
		ans[i] = s[r - 1] - s[l - 2];
	}
	
	for(int i = 0; i < n; i++)
	{
		cout << ans[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S; cin >> S;
    veci cnt(3);
    REP(i,S.size()) cnt[S[i]-'a']++;
    sort(cnt.begin(),cnt.end());
    bool ok = true;
    REP(i,2) {
        for(int j = i+1; j < 3; j++) {
            if(abs(cnt[i]-cnt[j]) > 1) ok = false;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3748
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	int ans = 0;
	makei(N);
	rep(N) {
		makei(l);
		makei(r);
		ans += r - l + 1;
	}
	say(ans);
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
cnt=[0]*9
for i in a:
  cnt[min(i,3200)//400]+=1
print(max(len(cnt)-cnt.count(0)-min(cnt[-1],1),1),len(cnt)-cnt.count(0)+max(0,cnt[-1]-1))

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine().Trim().Split(' ');
            Console.WriteLine($"A{S[1][0]}C");
        }
    }
}


Measured memory_bytes: 25956
#include<stdio.h>
#include <string.h>
#define N 100000

char S[N]={};

int main(void)
{ scanf("%s",S);
  int len,i,count1,count2;
 len=strlen(S);
char C[N];
 for(i=0;i<len;i++){if(i%2==0)C[i]='1';else C[i]='0';}C[i+1]='\0';
 for(i=0;i<len;i++){if(S[i]!=C[i])count1++;}
 for(i=0;i<len;i++){if(i%2==0)C[i]='0';else C[i]='1';}C[i+1]='\0';
 for(i=0;i<len;i++){if(S[i]!=C[i])count2++;}
 if(count1>count2)printf("%d\n",count2);else printf("%d\n",count1);
}

Measured memory_bytes: 384
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
#include<unordered_map>
int main(){
    unordered_map<LL,int>H;
    int N; R(N);
    LL v=0,an=0;
    H[0]=1;
    REP(i,N){
        int x; R(x);
        v+=x;
        an+=H[v];
        H[v]++;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 8520
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
# 同一の集合の判定
def same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False
# 集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x

# 集合の数
def uCnt(x):
    return -par[find(x)]

N, M = map(int, input().split())
par = [-1 for i in range(N)]
tmp = ((N * (N - 1)) // 2)
ab = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * M
ans[M - 1] = tmp
for i in range(M - 1, 0, -1):
    fa = find(ab[i][0] - 1)
    fb = find(ab[i][1] - 1)
    ans[i - 1] = ans[i]
    if fa != fb:
        ans[i - 1] -= uCnt(fa) * uCnt(fb)
        unite(ab[i][0] - 1, ab[i][1] - 1)

for i in ans:
    print(i)

Measured memory_bytes: 34600