akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		long ans = 1;
		long c[] = new long[102100];
		c[0] = 3;

		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(str[i]);
			ans = ans * c[x] % 1000000007;
			c[x]--;
			c[x + 1]++;
		}

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


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

int sum_digits(int num){
	int dig(0), ans(0);
	while(num){
		dig = num % 10;
		ans += dig;
		num /= 10;
	}
	return ans;
}

int main()
{
	int N,A,B,ans(0),t;
	cin >> N >> A >> B;
	for(int i(1);i <= N;++i){
		t = sum_digits(i);
		if(A <= t && t <= B) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define FOR(i, a, n) for(int i=a; i<n; i++)
#define RFOR(i, a, n) for(int i=n-1; i>=a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 0, n)

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int l = b - a, r = c - b;
	if (l == r) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n, a;
	string s;
	vector<bool> S(13, false);
	vector<bool> H(13, false);
	vector<bool> C(13, false);
	vector<bool> D(13, false);

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s >> a;
		if (s == "S")
			S[a-1] = true;
		else if (s == "H")
			H[a-1] = true;
		else if (s == "C")
			C[a-1] = true;
		else
			D[a-1] = true;
	}

	vector<bool>::iterator it;
	it = S.begin();
	for (int i = 1; it != S.end(); i++, it++)
		if (*it == false)
			cout << "S " << i << endl;
	it = H.begin();
	for (int i = 1; it != H.end(); i++, it++)
		if (*it == false)
			cout << "H " << i << endl;
	it = C.begin();
	for (int i = 1; it != C.end(); i++, it++)
		if (*it == false)
			cout << "C " << i << endl;
	it = D.begin();
	for (int i = 1; it != D.end(); i++, it++)
		if (*it == false)
			cout << "D " << i << endl;
	return 0;
}

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

int main(void){
	int n, k, ans=0;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		ans += 2*min(abs(x),abs(k-x));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//蟻本を基にした
//強連結成分分解(比較的実装しやすい方)
//2-SAT(xかつyの充足判定)への利用や,有向グラフを縮約してDAGにする効果がある.
//DAGになればDPやトポロジカルソートができるようになる.
using namespace std;
typedef long long ll;
const int MAXV=1e5+5;
int V;//頂点数
bool visited[MAXV];
vector<int> G[MAXV];//有向グラフの隣接リスト表現
vector<int> rG[MAXV];//↑のグラフの辺を逆向きにしたグラフ
vector<int> vs; //帰りがけ順の並び
int cmp[MAXV];//属する強連結成分のトポロジカル順序
void add_edge(int from,int to)
{
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v)
{
  visited[v]=true;
  for(int i=0;i<G[v].size();i++)
    {
      if(!visited[G[v][i]]) dfs(G[v][i]);
    }
  vs.push_back(v);
}

void rdfs(int v,int k)
{
  visited[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++)
    {
      if(!visited[rG[v][i]]) rdfs(rG[v][i],k);
    }
}

int scc()
{
  memset(visited,0,sizeof(visited));
  vs.clear();
  for (int v = 0; v < V; ++v)
    {
      if(!visited[v])dfs(v);
    }
  memset(visited,0,sizeof(visited));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)
    {
      if(!visited[vs[i]])rdfs(vs[i],k++);
    }
  return k;
}

int main(void)
{
  int E,Q;
  memset(cmp,0,sizeof(cmp));
  cin >> V >> E;
  for(int i=0;i<MAXV;i++)
    {
      G[i].clear();
      rG[i].clear();
    }
  for (int i = 0; i < E; ++i)
    {
      int fro,to;
      cin >> fro >> to;
      add_edge(fro,to);
    }
  scc();
  cin >> Q;
  for(int i=0;i<Q;i++)
    {
      int u,v;
      cin >> u >> v;
      if(cmp[u]==cmp[v]) cout << 1 << endl;
      else cout << 0 << endl;
    }
}




Measured memory_bytes: 9344
#include <iostream>

using namespace std;

int main() {
  long long int X;

  cin >> X;

  long long int i= 100, count = 0;;
  do {
    if (i >= X) {
      break;
    }
    count++;
  } while (i *= 1.01);

  cout << count << endl;

  return 0;

}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
  int n;
  cin >> n;
  REP(i,n){
    string o, m;
    cin >> o >> m;
    reverse(o.begin(), o.end());
    REP(j,(int)o.size()){
      if(o[j] == 'J'){
        m = m[m.size()-1] + m.substr(0,m.size()-1);
      }else if(o[j] == 'C'){
        m = m.substr(1,m.size()-1) + m[0];
      }else if(o[j] == 'E'){
        int x = m.size()/2;
        if(m.size() & 1)
          m = m.substr(x+1,x) + m[x] + m.substr(0,x);
        else
          m = m.substr(x,x) + m.substr(0,x);
      }else if(o[j] == 'A'){
        reverse(m.begin(), m.end());
      }else if(o[j] == 'P'){
        REP(k,(int)m.size()){
          if(isdigit(m[k])){
            m[k]--;
            if(!isdigit(m[k]))
              m[k] = '9';
          }
        }
      }else if(o[j] == 'M'){
        REP(k,(int)m.size()){
          if(isdigit(m[k])){
            m[k]++;
            if(!isdigit(m[k]))
              m[k] = '0';
          }
        }
      }
    }
    cout << m << endl;
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int m;
	static int nMin;
	static int nMax;
	static int gap;
	static int maxNum;
	static int score;

	static int[] scores;

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		while(true){
			m = sc.nextInt();
			nMin = sc.nextInt();
			nMax = sc.nextInt();

			if(m==0){
				break;
			}

			scores = new int[m];
			for(int i=0;i<m;i++){
				score = sc.nextInt();
				scores[i]=score;
			}

			int maxGap =0;
			maxNum =1;
			int index = 0;
			if(nMin==0||nMin==1){
				index = 1;
			}
			else{
				index = nMin-1;
			}

			for(int i=index;i<nMax+1;i++){
				gap = scores[i-1]-scores[i];

				if(gap>=maxGap){
					maxGap = gap;
					maxNum = i;
				}

				if(i==index){
					maxGap = 0;
				}
			}

			System.out.println(maxNum);

		}

	}

}

Measured memory_bytes: 56576
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<numeric>
typedef long long ll;
using namespace std;

int main() {
	ll N;
	cin >> N;
	
	ll a[200000];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int B = 0;
	int now = 0;
	int i = 1;
	int j = 0;
	for (int j = 0; j < N;j++) {
		if (a[j] == i) {
			/*B += ((j-1) - now);
			now = j;*/
			i++;
		}
		else {
			B++;
			/*if (j == N - 1) {
				B += (j - now);
			}*/
		}
	}
	if (i == 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << B << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, double.Parse);
        Array.Sort(a);
        var ans = (a[0] + a[1]) / 2d;
        for (int i = 2; i < n; i++)
            ans = (ans + a[i]) / 2d;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11348
#include<iostream>
using namespace std;
int W,H;
int t[50][50];
void visit(int h,int w){
  t[h][w]=0;
  for(int nh=h-1;nh<h+2;nh++){
    for(int nw=w-1;nw<w+2;nw++){
      if(t[nh][nw]==1&&0<=nh&&0<=nw&&nh<H&&nw<W)visit(nh,nw);
    }
  }
}

int main(void){
  int a,b,c,n;
  while(1){
    cin>>W>>H;
    c=0;
    if(W==0&&H==0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>t[i][j];
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(t[i][j]==1){
	  c++;
	  visit(i,j);
	}
      }
    }
    cout<<c<<endl;
  }
}

Measured memory_bytes: 1348
a,b,c,d=map(int,input().split())
if a==c:
    print(min(b,d))
elif a<c:
    if b>d:
        print(d-c)
    else:
        print(max(0,b-c))
else:
    if b<d:
        print(b-a)
    else:
        print(max(0,d-a))

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

class UnionFind:
    def __init__(self, size):
        self.rank = [0] * size
        self.par = range(size)
        self.g_num = size

    def find(self, x):
        if x == self.par[x]: return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return

        self.g_num -= 1
        if (self.rank[x] > self.rank[y]):
            self.par[y] = x
        else:
            self.par[x] = y
            if (self.rank[x] == self.rank[y]): self.rank[y] += 1

    def group_num(self):
        return self.g_num

N, M = map(int, raw_input().split())
L = [map(int, raw_input().split()) for i in xrange(N)]

sp = [-1]*M
uf = UnionFind(N)
for i in xrange(N):
    k = L[i][0]
    for j in xrange(1, k + 1):
        if sp[L[i][j] - 1] == -1:
            sp[L[i][j] - 1] = i
        else:
            uf.unite(sp[L[i][j] - 1], i)

print "YES" if uf.group_num() == 1 else "NO"



Measured memory_bytes: 22052
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

import sys

for Z in range(X+1,Y+1):
    if max(x) < Z and Z <= min(y):
        print("No War")
        sys.exit()
        
print("War")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
void solve(){
      int n,m;cin>>n>>m;
      int total=0;
        f(i,0,m){
      	int x;cin>>x;
      	 total+=x;
      }
       cout<<max(-1,n-total);
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 3692
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int r,g,b,num;
    cin>>r>>g>>b;
    num=r*100+g*10+b;
    if (num%4==0){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    cout<<endl;
}


Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim ab As Integer() = Cin.IntArr()
    Dim a AS Integer = ab(0)
    Dim b As Integer = ab(1)
    Dim ans As String = ""
    If a < b Then
      ans = New String(a.ToString(), b)
    Else
      ans = New String(b.ToString(), a)
    End If
    Console.WriteLine(ans)
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 13140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using vlll = vector<vector<vector<ll>>>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
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; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class ACirclePond {
public:
	void solve(std::istream& in, std::ostream& out) {
	    double r;
	    in >> r;
	    out << fixed << setprecision(10) << 2*M_PI*r << enl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	ACirclePond solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3796
#include<stdio.h>
#define MAX 100000

int partition(int*,int ,int);

int main(){
  int n,i,q;
  int A[MAX];
  
  scanf("%d",&n);

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

  q = partition(A,0,n-1);

  for(i=0;i<q;i++){
    printf("%d",A[i]);
    printf(" ");
  }
  
  printf("[%d] ",A[q]);
    
  for(i=q+1;i < n;i++){
    printf("%d",A[i]);
    if(i < n-1){
      printf(" ");
    }
  }

  printf("\n");

  return 0;
}
    

  int partition(int *A,int p,int r){
    int x,j,i;
    int chg;
    x = A[r];
    i = p-1;
    for(j = p;j<r;j++){
    if(A[j] <= x){
      i++;
      chg = A[i];
      A[i] = A[j];
      A[j] = chg;
    }
    }
    chg = A[i+1];
    A[i+1] = A[r];
    A[r] = chg;
    return i+1;
  }

Measured memory_bytes: 992
import collections

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

L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]

countL = collections.Counter(L)

countR = collections.Counter(R)


print(sum([countL[n] * countR[n] for n in countL.keys()]))

Measured memory_bytes: 63504
#include <cstdio>
#include <numeric>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
#include <deque>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define fill(x,y) memset(x,y,sizeof(x))
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> inline T sqr (T x) { re x * x; }

#define filename ""

int n;
int m;

int main () {
	string s;
	cin >> s;
	cout << s.substr (0, 4) << " " << s.substr (4, 8) << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  double N;
  cin>>N;
  cout << N*2*3.14159265358979 << endl;
  return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int r;
    cin >> r;
    cout << (r * r) << endl;
    
    return 0;
}


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

#define int long long int 

int32_t main()
{

    int c[3][3];
    int a[3][3];
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
          cin>>c[i][j];
    
    for(int i=1;i<3;i++)
        for(int j=0;j<3;j++)
        a[i][j]=c[i][j]-c[i-1][j];
    

    for(int j=0;j<3;j++)
    a[0][j]=c[0][j]-c[2][j];

    int f=1;
    for(int i=0;i<3;i++)
        for(int j=0;j<2;j++)
            if(a[i][j]!=a[i][j+1])
            f=0;

  
      
    if(f)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

}


Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))

dp = [{} for _ in range(N + 2)]
dp[0][0] = 0
dp[-1][0] = 0

for i in range(1, N + 1):
    f = (i - 1) // 2
    t = (i + 1) // 2
    for j in range(f, t + 1):
        var1 = dp[i - 2][j - 1] + A[i - 1] if j - 1 in dp[i - 2] else -float('inf')
        var2 = dp[i - 1][j] if j in dp[i - 1] else -float('inf')
        dp[i][j] = max(var1, var2)

print(dp[N][N // 2])


Measured memory_bytes: 98216
N = int(input())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))

satisfaction = 0

for i in range(N):
    satisfaction += B_list[A_list[i] - 1]
    if (i != N-1 and A_list[i + 1] == A_list[i] + 1):
        satisfaction += C_list[A_list[i]-1]

print(satisfaction)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		ll N, H, W; scanf("%lld %lld %lld", &N, &H, &W);
		vector<ll> x(N); for (int i = 0; i < N; i++) scanf("%lld", &x[i]);
		vector<ll> Wind(N * W + 1);
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				Wind[i * W + x[i]]++;
				Wind[i * W + x[i] + W]--;
			}
			else {
				Wind[i * W - x[i]]++;
				Wind[i * W - x[i] + W]--;
			}
		}
		for (int i = 0; i < N * W; i++) {
			Wind[i + 1] += Wind[i];
		}
		ll res = 0;
		for (int i = 0; i < N * W; i++) res += H * (Wind[i] == 0);
		cout << res << "\n";
	}
	return 0;

}



Measured memory_bytes: 3336
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  double n,a[5],t;
  long long res;
  int i;
  cin >> n;
  for(i=0;i<5;i++)
    cin >> a[i];
  t=*min_element(a,a+5);
  res=(long long)ceil(n/t)+4;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
li = []
for _ in range(n):
    li.append(list(map(int,input().split())))
li = sorted(li, key=lambda x:x[1])
time = 0
for a,b in li:
    time += a
    if time > b:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 55256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// vectorの要素を検索
bool vector_exist(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index!=vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  if (N==0) {
    cout << X << endl;
    return 0;
  }
  int i = 0;
  while (true) {
    if (!vector_exist(p, X-i)) {
      cout << X-i << endl;
      break;
    }
    else if (!vector_exist(p, X+i)) {
      cout << X+i << endl;
      break;
    }
    else i++;
  }
  return 0;
}

Measured memory_bytes: 3636
/*
 * main.cpp
 *
 *  Created on: 2020/07/21
 *      Author: 113896
 */

#include <iostream>
#include <vector>

using namespace std;

void printVector(vector<int> A, bool newline=true) {
	for (int i = 0; i < (int)A.size(); i++) {
		cout << A[i];
		if (i != (int)A.size()-1) cout << " ";
	}
	if (newline) {
		cout << endl;
	}
}

void insertionSort(vector<int> A) {
	for (int i = 1; i < (int)A.size(); i++) {
		printVector(A);
		int key = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > key) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
	}
	printVector(A);
}

int main() {

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

	insertionSort(data);

	return 0;
}





Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s[3]={"Sunny","Cloudy","Rainy"};
  	string str;
  	cin>>str;
  	if(str==s[0])	cout<<s[1]<<"\n";
  	else if(str==s[1])cout<<s[2]<<"\n";
    else cout<<s[0]<<"\n";
}

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

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

Measured memory_bytes: 3584
n = int(input())
num = len(str(n))
if num == 1:
    ans = n
else:
    if num&1==1:
        ans = (n%(10**(num-1)))+1+(n//(10**(num-1))-1)*(10**(num-1))
        num -=2
    else:
        ans = 0
        num -= 1
    n %= 10**num
    while num>0:
        ans += 9*(10**(num-1))
        num -=2
        n %= 10**num
print(ans)

Measured memory_bytes: 9236
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=2e5+10;
ll N,K;
ll A[MAXN];
map<ll,int>cnt;
int main()
{
    // freopen("in.txt","r",stdin);
    cin>>N>>K;
    for(int ii=1;ii<=N;ii++){
        cin>>A[ii];
        A[ii]+=A[ii-1];
    }
    cnt[0]=1;
    ll ans=0;
    for(int ii=1;ii<=N;ii++){
        if(ii>=K){
            cnt[(A[ii-K]-(ii-K)+3*K)%K]--;
        }
        ans+=cnt[(A[ii]-ii+3*K)%K];
        cnt[(A[ii]-ii+3*K)%K]++;
    }
    cout<<ans;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
string s;
long long dp[2];
long long powe[100100];
const long long MOD=1e9+7;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	powe[0]=1LL;
	for(int i=1;i<=s.size();i++)
		powe[i]=(powe[i-1]*3LL)%MOD;
	int q=0;
	long long ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'){
			dp[0]=(dp[0]+powe[q])%MOD;
		}
		if(s[i]=='B'){
			dp[1]=(dp[1]+dp[0])%MOD;
		}
		if(s[i]=='C'){
			ans=(ans+dp[1])%MOD;
		}
		if(s[i]=='?'){
			ans=(ans*3+dp[1])%MOD;
			dp[1]=(dp[1]*3+dp[0])%MOD;
			dp[0]=(dp[0]*3+powe[q])%MOD;
			q++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int sum = 0;
  cin >> A >> B;
  for (int i = A; i < B+1; i++) {
    if ((i / 10000 == i % 10) && (((i % 10000) / 1000) == ((i % 100) / 10))) sum++;
  }
  cout << sum << endl;  
}

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



vector<pair<int, int>> edge[100000];

long long dis[100000];



void dfs(int u, vector<pair<int, int>> edge[],long long d=0, int par = -1) {
	dis[u] = d;
	for (int i = 0; i<(int)edge[u].size(); i++) {
		if (edge[u][i].first == par)continue;
		dfs(edge[u][i].first, edge, d+edge[u][i].second,u);
	}
}






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

	int n;
	cin>>n;
	rep(i,n-1){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		edge[a].emplace_back(b,c);
		edge[b].emplace_back(a,c);
	}
	int q,k;
	cin>>q>>k;
	k--;
	dfs(k,edge);
	rep(i,q){
		int x,y;
		cin>>x>>y;
		cout << dis[x - 1] + dis[y-1]<<endl;
	}

	return 0;
}

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

using namespace std;

long long a[300000], b[300000], c[300000], s[300000];

int main()
{
  int N, M;

  cin >> N;
  for(int i = 0; i < N; i++) cin >> a[i];
  
  cin >> M;
  for(int i = 0; i < M; i++) cin >> b[i];
  for(int i = 0; i < M; i++) cin >> c[i];
  
  sort(a, a + N);
  for(int i = 0; i < N; i++) s[i+1] = s[i] + a[i];
  
  for(int i = 0; i < M; i++){
    int idx = upper_bound(a, a + N, b[i]) - a;
    if(c[i] <= s[idx]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 10540
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        
        int[] a = new int[A];
        int[] b = new int[B];
        int minA = Integer.MAX_VALUE;
        int minB = Integer.MAX_VALUE;
        for(int i = 0; i < A; i++){
            a[i] = Integer.parseInt(sc.next());
            if(a[i] < minA) minA = a[i];
        }
        for(int i = 0; i < B; i++){
            b[i] = Integer.parseInt(sc.next());
            if(b[i] < minB) minB = b[i];
        }
        
        int min = minA + minB;
        for(int i = 0; i < M; i++){
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            int d = a[x-1] + b[y-1] - c;
            if(d < min) min = d;
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 67292
import math
n=int(input())
ls=list(map(int,input().split()))

s=sum(ls)/n

if abs(math.ceil(s)-s)<0.5:
    t=math.ceil(s)
else:
    t=math.floor(s)


ans=0
for i in ls:
    ans+=(t-i)**2
print(ans)

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

int main()
{
	int n;
	cin >> n;
	std::vector<int> a(n + 1);
	std::vector<int> b(n + 1);
	std::vector<int> c(n);
	int sum = 0;
	int pre = 0;
	a[0], b[0], c[0] = 0;
	for (int i = 1; i < n + 1; ++i)
	{
		cin >> a[i];
	}
	for (int i = 1; i < n + 1; ++i)
	{
		cin >> b[i];
	}
	for (int i = 1; i < n ; ++i)
	{
		cin >> c[i];
	}
	for (int i = 1; i < n+1; ++i)
	{
		sum += b[a[i]];
		if (a[i] == pre+1)
		{
			sum += c[pre];
		}
		pre = a[i];
		
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

int gcd(int a,int b);
  
signed main(){
    int n;
    cin >> n;
    int ans = 0;
    erep1(i,n){
        erep1(j,n){
            erep1(s,n){
                ans += gcd(gcd(i,j),s);
            }
        }
    }
    cout << ans << endl;
}

int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcd(a%b,b);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  bool allm=true;

  int sum=0;

  vector<int> s(N);
  rep(i,N){
    cin>>s[i];
    if(s[i]%10) allm=false;
    sum+=s[i];
  }

  if(allm){
    cout<< 0<<"\n";
    return;
  }

  if(sum%10){
    cout<< sum<<"\n";
    return;
  }


  SORT(s);

  rep(i,N){
    if(s[i]%10){
      sum-=s[i];
      break;
    }
  }

  cout<< sum<<"\n";



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


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int H = cin.nextInt();
        int W = cin.nextInt();
        int[,] a = new int[H, W];
        bool[] h = new bool[H];
        bool[] w = new bool[W];

        for (int i = 0; i < H; i++)
        {
            string s = cin.nextString();
            for (int j = 0; j < W; j++)
            {
                if (s[j] == '.')
                {
                    a[i, j] = 0;
                }
                else
                {
                    a[i, j] = 1;
                    h[i] = true;
                    w[j] = true;
                }
            }
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (h[i] && w[j])
                {
                    if (a[i, j] == 0)
                    {
                        Console.Write(".");
                    }
                    else
                    {
                        Console.Write("#");
                    }
                }
            }
            if (h[i])
            {
                Console.Write("\n");
            }
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13268
/* while(!success_achieved())
      work_hard();

   code by:aman_ayush
  */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int col[100001];

void bfs(int n,vpi v[])
{
    col[1]=0;
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int r=q.front();
        q.pop();
        for(int i=0;i<v[r].size();i++)
        {
            int ch=v[r][i].first;
            int w=v[r][i].second;
            if(col[ch]==-1)
            {
                 col[ch]=col[r]+w;
                 q.push(ch);
            }
        }
    }
}
int main()
{
    fast;
     for(int i=0;i<=100000;i++)
      col[i]=-1;
      int n;
      cin>>n;
      vpi v[n+1];
      for(int i=1;i<n;i++)
      {
          int p,q,w;
          cin>>p>>q>>w;
          v[p].pb({q,w});
          v[q].pb({p,w});
      }
      bfs(n,v);
      for(int i=1;i<=n;i++)
      {
          if(col[i]%2)
           cout<<1<<"\n";
           else
            cout<<0<<"\n";
      }
     return 0;
}

Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		int rest = n % k;
		if (rest == 0) {
			System.out.println("0");
		} else {
			System.out.println("1");
		}

		sc.close();
	}
}

Measured memory_bytes: 22608
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

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

void Main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2] && s[0] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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


Measured memory_bytes: 256
N,M,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
maxX = max(x)
minY = min(y)
if maxX < minY:
    print("No War")
else:
    print("War")

Measured memory_bytes: 9016
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int main(void)
{
	int t;
	string num;
	string temp;
	int x;
	int sum,Asum;
	int minn;
	int eq;
	int i1;

	while(1){
		cin>>t>>num;
		if(t==0 && num=="0") break;

		vector<int> v(num.size()+1,0);
		vector<int> Avec;
		minn=1000000;
		eq=-1;

		while(1){
			temp=num[0];
			sum=0;

			for(i1=1;i1<num.size();i1++){
				if(v[i1]==0){
					temp+=num[i1];
				}
				if(v[i1]==1){
					istringstream istr(temp);
					istr >> x;
					sum+=x;
					temp=num[i1];
				}
			}

			istringstream istr(temp);
			istr >> x;
			sum+=x;

			if(t>=sum){
				x=t-sum;
				if(minn==x) eq=x;
				else if(minn>x) {
					minn=x;
					Asum=sum;
					Avec.clear();
					Avec.reserve(v.size());
					copy(v.begin(),v.end(),back_inserter(Avec));
				}	
			}

			v[1]++;
			for(i1=1;i1<num.size();i1++){
				if(v[i1]==2) {
					v[i1]=0;
					v[i1+1]++;
				}
			}
			if(v[num.size()]==1) break;
		}

		if(minn==eq) cout<<"rejected"<<endl;
		else if(minn==1000000) cout<<"error"<<endl;
		else {
			cout<<Asum<<" ";
			temp=num[0];
			for(i1=1;i1<num.size();i1++){
				if(Avec[i1]==0){
					temp+=num[i1];
				}
				if(Avec[i1]==1){
					cout<<temp<<" ";
					temp=num[i1];
				}
			}
			cout<<temp<<endl;
		}

		
	}

	return 0;
}

Measured memory_bytes: 1232
N = int(input())
A = {}
for s in input().split():
    n = int(s)
    if n in A:
        A[n] += 1
    else:
        A[n] = 1

def main():
    a_len = len(A.keys())
    counts = A.values()
    even = [c for c in counts if c % 2 == 0]
    ans = a_len if len(even) % 2 == 0 else a_len - 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22252
#include <iostream>
#include <string>
#define llint long long
#define inf 1e18

using namespace std;

string s, t;
llint n, m;
llint A, E, S, R;
llint dp[105][105];

llint calc(llint r)
{
	s = "#" + s, t = "#" + t;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			if(i+1 <= n && j+1 <= m && s[i+1] == t[j+1]) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]);
			else{
				if(i+1 <= n){
					if(i >= n - r) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + E-R);
					else dp[i+1][j] = min(dp[i+1][j], dp[i][j] + E);
				}
				if(j+1 <= m) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + A);
				if(i+1 <= n && j+1 <= m) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + S);
			}
		}
	}
	s = s.substr(1), t = t.substr(1);
	
	return dp[n][m];
}

int main(void)
{
	while(1){
		cin >> s;
		if(s == "#") break;
		cin >> t >> A >> E >> S >> R;
		n = s.size(), m = t.size();
		
		llint ans = inf;
		for(int i = 0; i < n; i++){
			ans = min(ans, calc(i) + i*R);
			s = s.substr(1) + s[0];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3236
var
	K:Longint;
	L,R,M:int64;
function check(T:int64):Longint;
var
	dp:Array[1..12,0..1,0..9]of Longint;
	dpz:Array[1..12,0..1]of Longint;
	S:String;
	ls,i,j,k,l,nj,lim,sum,llim,rlim:Longint;
begin
	S:='';
	while T>0 do begin
		S:=Chr(T mod 10+48)+S;
		T:=T div 10;
	end;
	ls:=length(S);
	for i:=1 to ls+1 do for j:=0 to 1 do begin
		for k:=0 to 9 do dp[i,j,k]:=0;
		dpz[i,j]:=0;
	end;
	dpz[1,0]:=1;
	for i:=1 to ls do begin
		for j:=0 to 1 do begin
			if j=0 then lim:=ord(S[i])-48 else lim:=9;
			inc(dpz[i+1,1],dpz[i,j]);
			for l:=1 to lim do begin
				nj:=j;
				if l<lim then nj:=1;
				inc(dp[i+1,nj,l],dpz[i,j]);
			end;
			for k:=0 to 9 do begin
				if dp[i,j,k]=0 then continue;
				llim:=k-1;if llim<0 then llim:=0;
				rlim:=k+1;if rlim>lim then rlim:=lim;
				for l:=llim to rlim do begin
					nj:=j;
					if l<lim then nj:=1;
					inc(dp[i+1,nj,l],dp[i,j,k]);
				end;
			end;
		end;
	end;
	sum:=0;
	for k:=0 to 9 do for i:=0 to 1 do begin
		inc(sum,dp[ls+1,i,k]);
	end;
	check:=sum;
end;
begin
	read(K);
	L:=0;
	R:=3234566667;
	while R-L>1 do begin
		M:=(L+R)div 2;
		if check(M)>=K then R:=M else L:=M;
	end;
	writeln(R);
end.


Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int n,q,com,x,y;
int *parent,*club,*rank;

int find(int x){
	if(x == parent[x])return x;
	else{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x,int y){
	return find(x) == find(y);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);

	if(x == y)return;

	if(rank[x] < rank[y]){
		parent[x] = y;
	}else{
		parent[y] = x;
		if(rank[x] == rank[y])rank[x]++;
	}
}

int main(){

	int N,M,K,tmp,left,right;
	scanf("%d %d %d",&N,&M,&K);

	parent = new int[N+1];
	club = new int[N+1];
	rank = new int[N+1];
	for(int i = 1; i <= N; i++){
		parent[i] = i;
		club[i] = -1;
		rank[i] = 0;
	}

	int ans = 0;

	for(int loop = 1; loop <= K; loop++){
		scanf("%d",&tmp);

		if(tmp == 1){
			scanf("%d %d",&left,&right);

			if(ans == 0){

				if(club[find(left)] == -1 && club[find(right)] == -1){
					unite(left,right);
				}else if(club[find(left)] == -1 && club[find(right)] != -1){
					club[find(left)] = club[find(right)];
					unite(left,right);
				}else if(club[find(left)] != -1 && club[find(right)] == -1){
					club[find(right)] = club[find(left)];
					unite(left,right);
				}else{
					if(club[find(left)] != club[find(right)]){
						ans = loop;
					}else{
						unite(left,right);
					}
				}
			}
		}else{
			scanf("%d %d",&left,&right);

			if(ans == 0){
				if(club[find(left)] == -1){
					club[find(left)] = right;
				}else{
					if(club[find(left)] == right){
						//Do nothing
					}else{
						ans = loop;
					}
				}
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}

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

struct node{
  int par, left, right;
};

node t[10000];
int n, d[10000], h[10000];

void set_depth(int u, int cost){
  if(u == -1) return;
  d[u] = cost;
  set_depth(t[u].left, cost + 1);
  set_depth(t[u].right, cost + 1);
}

int set_height(int u){
  int h1 = 0, h2 = 0;
  if(t[u].left != -1) h1 = set_height(t[u].left) + 1;
  if(t[u].right != -1) h2 = set_height(t[u].right) + 1;
  return h[u] = max(h1, h2);
}

int get_sibling(int u){
  if(t[u].par == -1) return -1;
  if(t[t[u].par].left != u && t[t[u].par].left != -1) return t[t[u].par].left;
  if(t[t[u].par].right != u && t[t[u].par].right != -1) return t[t[u].par].right;
  return -1;
}

int main(){

  int id, l, r;

  cin >> n;
  for(int i = 0; i < n; i++) t[i].par = -1;
  for(int i = 0;i < n; i++){
    cin >> id >> l >> r;
    t[id].left = l;
    t[id].right = r;
    if(l != -1) t[l].par = id;
    if(r != -1) t[r].par = id;
  }
  int root;
  for(int i = 0; i < n; i++) if(t[i].par == -1) root = i;

  set_depth(root, 0);
  set_height(root);

  for(int i = 0; i < n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", t[i].par);
    printf("sibling = %d, ", get_sibling(i));
    int deg = 0;
    if(t[i].left != -1) deg++;
    if(t[i].right != -1) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", d[i]);
    printf("height = %d, ", h[i]);
    if(t[i].par == -1) printf("root\n");
    else if(t[i].left == -1 && t[i].right == -1) printf("leaf\n");
    else printf("internal node\n");
  }
}


Measured memory_bytes: 3172
#!/usr/bin/node
(function() {
  var T=[];
  var S=[];
  var stdin = process.openStdin();
  stdin.setEncoding('utf8');

  var rec=function(x,y){
    if(0<=x&&x<T[0].length&&0<=y&&y<T.length&&T[y][x])
      T[y][x]=0,rec(x-1,y),rec(x+1,y),rec(x,y-1),rec(x,y+1),
      rec(x-1,y-1),rec(x+1,y-1),rec(x-1,y+1),rec(x+1,y+1);
  }

  stdin.on('data', function(input) {
    var i=0,len,ref,x=[];
    ref=input.split("\n");
    for(len=ref.length;i<len;i++){
    	if(ref[i]=='')continue;
    	var y=ref[i].split(" ");
    	for(var j=0;j<y.length;j++)y[j]=parseInt(y[j])
    	x.push(y);
    }
    if(x.length>2||!isNaN(x[1]))S=x;
    else S.push(x[0]);
  });

  stdin.on('end', function(z) {
    var i,j,r;
    for(;;){
      r=0;
      var h=(S.shift())[1];
      if(!h)break;
      T=S.slice(0,h);
      for(i=0;i<T[0].length;i++)for(j=0;j<T.length;j++)if(T[j][i])r++,rec(i,j);
      console.log(r);
      S=S.slice(h);
    }
  });
}).call(this);

Measured memory_bytes: 10164
def main():
    N = int(input())
    ans = "No"
    flg = False
    for i in range(1, 10):
        for j in range(1, 10):
            if N == i * j:
                ans = "Yes"
                flg = True
                break
        if flg:
            break
    print(ans)
    return


main()


Measured memory_bytes: 2940