akhauriyash/Code-Regression huggingface dataset:
def main():
    
    import collections

    N = int(input())

    def factorization(num):
        factorize = []
        while (num % 2 == 0):
            num //= 2
            factorize.append(2)
        
        division = 3
        
        while (division * division <= num):
            
            if (num % division == 0):
                factorize.append(division)
                num //= division
            else:
                division += 2
            
        if (num != 1):
            factorize.append(num)
        
        return (factorize)
    
    def count_div(n):
        cnt = 0
        sub = 0
        
        while (n > 0):
            sub += 1
            n -= sub
            if (n >= 0):
                cnt += 1

        return(cnt)

    facts = factorization(N)
    CTR_facts = collections.Counter(facts).most_common()
    
    ans = 0
    
    for i in range(len(CTR_facts)):
        v = CTR_facts[i][1]
        
        tmp = count_div(v)
        ans += tmp
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  if(n+1==m)
  {
    for(int i=0;i<n;i++)
      if(s[i]!=t[i]){
        cout<<"No\n";
        return 0;}
    cout<<"Yes\n";
  }
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3604
import sys
from collections import Counter as cc
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


class UnionFind():
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.height = [0]*n

    def get_root(self, i):
        if self.parent[i] == i:
            return i
        else:
            self.parent[i] = self.get_root(self.parent[i])
            return self.parent[i]
        
    def unite(self, i, j):
        root_i = self.get_root(i)
        root_j = self.get_root(j)
        if root_i != root_j:
            if self.height[root_i] < self.height[root_j]:
                self.parent[root_i] = root_j
            else:
                self.parent[root_j] = root_i
                if self.height[root_i] == self.height[root_j]:
                    self.height[root_i] += 1
    
    def is_in_group(self, i, j):
        if self.get_root(i) == self.get_root(j):
            return True
        else:
            return False


def main():
    n, m, k= mi()   
    e = [0]*n
    uf = UnionFind(n)     
    for i in range(m):
        a, b = mi()
        a-=1
        b-=1
        e[a]-= 1
        e[b]-= 1
        uf.unite(a,b)
    
    
    for _ in range(k):
        a,b = mi()
        a-=1
        b-=1
        if uf.is_in_group(a,b):
            e[a] -= 1
            e[b] -= 1
        
    for i in range(n):
        uf.get_root(i)
    s = cc(uf.parent)
    for i in range(n):
        x = uf.get_root(i)
        e[i] += s[x]-1
    print(*e)




if __name__ == '__main__':
    main()

Measured memory_bytes: 22448
N, M = map(int, input().split())
pref_and_year = []
for i in range(M):
    p, y = map(int, input().split())
    pref_and_year.append((p, y))

sorted_indices = sorted(range(len(pref_and_year)),
                        key=lambda k: pref_and_year[k][1])
sorted_perf_and_year = sorted(pref_and_year, key=lambda x: x[1])
count = [0] * N
res = []
for i, x in zip(sorted_indices, sorted_perf_and_year):
    count[x[0]-1] += 1
    auth_number = str(x[0]).zfill(6) + str(count[x[0]-1]).zfill(6)
    res.append((i, auth_number))
res = sorted(res, key=lambda x: x[0])
for x in res:
    print(x[1])



Measured memory_bytes: 89816
L,R=map(int,input().split())
l=L%2019
r=R%2019
#print(l,r)
if l<r and L//2019 == R//2019:
    ans=10**18
    for i in range(l,r):
        for j in range(l+1,r+1):
            if ans>(i*j)%2019:
                ans=(i*j)%2019
    print(ans)
elif L//2019<R//2019:
    print(0)


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

int main() {
    int A, B; cin >> A >> B;
    string S; cin >> S;
    bool ok = true;
    if (S.length() != A+B+1) ok = false;
    for (int i = 0; i < S.length(); i++) {
        if (i == A) {
            if (S[i] != '-') ok = false;
        }
        else if (S[i] == '-') ok = false;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])


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

using namespace std;

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

int used[26];

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


class IHC{
public:
	vector<int> solve(int _D, vector<int> _c, vector<vector<int>> _s){
		init(_D,_c,_s);

		//geneRes();
        greedy();

		int score = calcScore(res);
//		cerr << "score: " << score << endl;

		return makeSolution(res);
	}
		
private:
	int D;
	vector<int> c;
	vector<vector<int>> s;
	vector<int> res;

	void greedy(void){
		vector<P> sorted; sorted.clear();
		rep (i, D){
			rep (j, 26){
				sorted.push_back(P(-s[i][j], i * 100 + j));
			} // end rep
		} // end rep
		sort(ALL(sorted));
		memset(used, -1, sizeof(used));
		rep (i, D){
			P curr = sorted[i];
			int d = curr.second / 100;
			int index = curr.second % 100;
			used[index] = d;
			res[d] = index;
		} // end rep

        rep (i, D){
            if (res[i] == -1){
                int maxV = 0;
                int ind = -1;
                rep (j, 26){
                    if (s[i][j] > maxV){
                        maxV = s[i][j];
                        ind = j;
                    } // end if
                } // end rep
                res[i] = ind;
            } // end if
        }
	}

	int calcScore(vector<int> res){
		int score = 0;
		rep (i, D){
			score += s[i][res[i]];
		} // end rep

		rep (i, 26){
			if (used[i] != -1){
				score -= c[i] * (D - used[i]); 
			} // end if 
		} // end rep
		return score;
	}

	vector<int> makeSolution(vector<int> res){
		vector<int> ret(D, 0);
		rep (i, D){
			ret[i] = res[i] + 1;
		} // end rep
		return ret;
	}

	void geneRes(void){
		memset(used, -1, sizeof(used));
		rep (i, D){
			res[i] = Rand() % 26;
			used[res[i]] = i;
		} // end rep
	}

	void init(int _D, vector<int> _c, vector<vector<int>> _s){
		D = _D;
		c = _c;
		s = _s;
		res.clear(); res.resize(D, -1);
	}
};

int main()
{
	IHC ihc;

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int D; cin >> D;
	vector<int> c(26, 0);
	rep (i, 26){
		cin >> c[i];
	} // end rep
	vector<vector<int>> s(D, vector<int>(26, 0));
	rep (i, D){
		rep (j, 26){
			cin >> s[i][j];
		} // end rep
	} // end rep

	vector<int> ret = ihc.solve(D,c,s);
	rep (i, (int)ret.size()){
		cout << ret[i] << endl;
	} // end rep

	return 0;
}


Measured memory_bytes: 3968
h, w = map(int, input().split())
lst = [input() for _ in range(h)]

res = 0
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if lst[j][i] == '.':
            if i == 0:
                L[j][i] = 1
            else:
                L[j][i] = L[j][i-1] + 1

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

for i in reversed(range(w)):
    for j in reversed(range(h)):
        if lst[j][i] == '.':
            if i == w-1:
                R[j][i] = 1
            else:
                R[j][i] = R[j][i+1] + 1

                
for i in range(h):
    for j in range(w):
        res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
        
print(res)

Measured memory_bytes: 180868
n,d = map(int,input().split())
num = [[0]*d for i in range(d)]
a = 0
for i in range(n):
  x,y = map(int,input().split())
  x %=d
  y%=d
  num[x][y] += 1
  a = max(a,num[x][y])
x=1
while x*x<a:
  x += 1
r = (x-1)*d
a = x-1
dai = d-1
syo = 0
anum = [[[0]*d for i in range(d)]for i in range(3)]
rui = [[[0]*(2*d+1) for i in range(2*d+1)]for i in range(3)]
for i in range(d):
  for j in range(d):
    z = num[i][j]
    if z > (a+1)**2:
      anum[0][i][j]=1
      anum[1][i][j]=1
      anum[2][i][j]=1
    elif z> a*(a+1):
      anum[1][i][j]=1
      anum[2][i][j]=1
    elif z > a*a:
      anum[1][i][j]=1
for x in range(3):
  for i in range(1,2*d+1):
    for j in range(1,2*d+1):
      rui[x][i][j]+=rui[x][i-1][j]+rui[x][i][j-1]-rui[x][i-1][j-1]+anum[x][(i-1)%d][(j-1)%d]
def cheak(kon):
  for i in range(1,d+1):
    for j in range(1,d+1):
      if rui[0][i+kon][j+kon] - rui[0][i - 1][j+kon] - rui[0][i+kon][j - 1] + rui[0][i - 1][j - 1]:
        continue
      if rui[1][i+d-1][j+d-1] - rui[1][i+kon+1 - 1][j+d-1] - rui[1][i+d-1][j+kon+1 - 1] + rui[1][i+kon+1 - 1][j+kon+1 - 1]:
        continue
      if rui[2][i+d-1][j+kon] - rui[2][i+kon+1 - 1][j+kon] - rui[2][i+d-1][j - 1] + rui[2][i+kon+1 - 1][j - 1]:
        continue
      if rui[2][i+kon][j+d-1] - rui[2][i - 1][j+d-1] - rui[2][i+kon][j+kon+1 - 1] + rui[2][i - 1][j+kon+1 - 1]:
        continue
      return 1
  return 0 
kon = (dai+syo)//2
while True:
  if dai-syo <= 1:
    if cheak(syo) == 1:
       dai = syo
    break
  kon = (dai+syo)//2
  c = cheak(kon)
  if c == 1:
    dai = kon
  else:
    syo = kon
print(dai+r)


Measured memory_bytes: 204012
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  cout << n/3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
 
#define INF 1000000000000000000

ll n;
ll a[401];
ll dp[401][401];

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

    cin >> n;

    fr(i,1,n)
    {
        cin >> a[i];
    }

    fr(i,2,n)
    {
        fr(j,1,n-i+1)
        {
            ll l = j;
            ll r = j+i-1;

            ll sum = 0;
            ll x = INF;
            fr(k,l,r-1)
            {
                x = min(x,dp[l][k]+dp[k+1][r]);
            }
            fr(k,l,r)
            {
                sum = sum + a[k];
            }
            dp[l][r] = x + sum;
        }
    }

    cout << dp[1][n] << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
    int a, b;

    scanf("%d %d", &a, &b);

    if(a >= 2 && a <= 13 && b >= 2 && b <= 13){
        if (a > b)
        printf("Alice");
        else if (a < b)
        printf("Bob");
        else
        printf("Draw");
    }
    else if(a == 1 && b != 1)
        printf("Alice");
    else if(a != 1 && b == 1)
        printf("Bob");
    else if(a == 1 && b == 1)
        printf("Draw");

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    vector<int> vec(3);
    vec[0]=a;
    vec[1]=b;
    vec[2]=c;
    sort(vec.begin(),vec.end());
    int ans = 0;
    ans+=(vec[2]-vec[1]);
    vec[0]+=ans;
    ans+=(vec[2]-vec[0])/2;
    if((vec[2]-vec[0])%2==1)ans+=2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 
 
public class Main{
  
  public static void main (String [] args){
    Scanner scanner = new Scanner(System.in);     
    int n = scanner.nextInt();
    int a [ ] = new int [n];
    int t = 0;
    
    for(int i = 0;i <n;i++) {
				a[i]=scanner.nextInt();
    }
    for(int i = 1; i < n-1; i++) {
      if((a[i-1] < a[i]) && (a[i] < a[i+1])){
        t++;  
      
      } else if ((a[i-1] > a[i]) && (a[i] > a[i+1])) {
        t++;
       
      }
    }
    System.out.println(t);  
    scanner.close();
  }
  
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

struct Item {
    int value;
    int weight;
};

int main()
{
    int N, W;
    cin >> N >> W;

    Item items[N + 1];
    for(int i = 1; i <= N; i++)
        cin >> items[i].value >> items[i].weight;

    int dp[N + 1][W + 1]; // dp[i][w]:i番目までのitemを(何度でも)使った重み制限wでの最大価値
    for(int i = 0; i <= W; i++)
        dp[0][i] = 0;
    for(int i = 1; i <= N; i++)
        dp[i][0] = 0;

    for(int i = 1; i <= N; i++)
    {
        for(int w = 1; w <= W; w++)
        {
            if(w >= items[i].weight) // i番目のitemを1つ使えるならば，使ってみる
                dp[i][w] = max(dp[i - 1][w],
                        dp[i][w - items[i].weight] + items[i].value); // N×Wの行列上のi行目の左から順に埋まっていくことから，i番目のitemを使えるだけ使ってみるように左から更新されていく仕組みになっている
            else
                dp[i][w] = dp[i - 1][w];
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7028
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;

string s;
int sum, mul;

map<P1,P> memo;

P dfs(int x, int S, int X){
  
  if(S>sum||(S==sum&&X>mul)) return P(0,0);
  
  if(x==s.size()){
    if(S<sum) return P(1,0);
    if(S==sum&&X<mul) return P(0,1);
    return P(0,0);
  }
  
  if(memo.count(P1(x,P(S,X)))) return memo[P1(x,P(S,X))];
  
  P res=P(0,0);
  
  for(int i=0;i<10;i++){
    P r=dfs(x+1, S+i, X*(i+1));
    res.first+=r.first;
    res.second+=r.second;
  }
  
  return memo[P1(x,P(S,X))]=res;
}

map<P,int> memo2[500][3];

int dfs2(int x, int S, int X, int flag){
  
  if(S>sum||X>mul) return 0;
  if(S+9*(s.size()-x)<sum) return 0;
  
  if(x==s.size()){
    if(S==sum&&X==mul&&flag) return 1;
    return 0;
  }
  
  if(memo2[S][flag].count(P(x,X))) return memo2[S][flag][P(x,X)];
  
  int res=0;
  
  for(int i=0;i<10;i++){
    if(flag==0&&i>s[x]-'0') continue;
    if(flag==0&&i<s[x]-'0') res+=dfs2(x+1, S+i, X*(i+1), 1);
    else res+=dfs2(x+1, S+i, X*(i+1), flag);
  }
  
  return memo2[S][flag][P(x,X)]=res;
}

signed main(){
  
  cin>>s;

  mul=1;
  for(int i=0;i<s.size();i++){
    sum+=s[i]-'0';
    mul*=(s[i]-'0'+1);
  }
  
  P ans=dfs(0,0,1);
 
  cout<<ans.first+ans.second+dfs2(0,0,1,0)<<endl;
  
  return 0;
}

Measured memory_bytes: 38872
h, w = list(map(int, input().split()))
field = [[0 for _ in range(w)] for _ in range(h)]
dp = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    field[i] = list(input())

dp[0][0] = 1

for i in range(h):
    for j in range(w):
        # 左に行けるとき
        if j + 1 < w and field[i][j+1] != "#":
            dp[i][j+1] += dp[i][j]
        # 下に行けるとき
        if i + 1 < h and field[i+1][j] != "#":
            dp[i+1][j] += dp[i][j]

print(dp[h-1][w-1]%(10**9+7))

    


Measured memory_bytes: 254812
h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(h)]

for _ in range(100):
    for u in range(10):
        for v in range(10):
            for w in range(10):
                c[u][w] = min(c[u][w], c[u][v] + c[v][w])

ans = 0
for ai in a:
    for aij in ai:
        if abs(aij) != 1:
            ans += c[aij][1]
print(ans)

Measured memory_bytes: 42332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	int a, b;
	cin >> a >> b;
	if(a == 4 || a == 6 || a == 9 || a == 11) a = 4;
	else if(a != 2) a = 1;
	
	if(b == 4 || b == 6 || b == 9 || b == 11) b = 4;
	else if(b != 2) b = 1;
	
	if(a == b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

// namespace utils
namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }
}
// end namespace utils

class Heap {

  public:
    Heap() {
      W.push_back(0);
    }

    vector<int> W;
    bool check(int);
    void maxHeapify(int);
    void rmaxHeapify(int);
    void buildHeap();
    void insert(int);
    int parent(int);
    int left(int);
    int right(int);
    int pop();
};

void Heap::insert(int v) {
  W.push_back(v);
  rmaxHeapify(W.size()-1);
}

int Heap::pop() {
  int result = W[1];
  // cout << result << endl;
  W[1] = W[W.size()-1];
  W.resize(W.size()-1);
  maxHeapify(1);
  return result;
}

bool Heap::check(int i) {
  if (1 <= i && i < (int)W.size()+1) return true;
  else return false;
}

void Heap::buildHeap() {
  for (int i=((int)W.size()-1)/2; i>0; i--) {
    maxHeapify(i);
  }
}

void Heap::maxHeapify(int i) {
  int l = left(i);
  int r = right(i);

  int largest;
  if (l <= (int)W.size()-1 && W[l] > W[i]) largest = l;
  else largest = i;
  if (r <= (int)W.size()-1 && W[r] > W[largest]) largest = r;

  if (largest != i) {
    swap(W[i], W[largest]);
    maxHeapify(largest);
  }
}

void Heap::rmaxHeapify(int i) {
  if (i == 1) return;
  int p = parent(i);

  if (W[p] < W[i]) {
    swap(W[i], W[p]);
    rmaxHeapify(p);
  }
}

int Heap::parent(int i) {
  return i/2;
}

int Heap::left(int i) {
  return i*2;
}

int Heap::right(int i) {
  return i*2+1;
}


int main() {
  Heap heap = Heap();
  string s;
  int k;

  while (cin >> s) {
    // cout << s << endl;
    // utils::print(heap.W);


    if (s == "insert") {
      cin >> k;
      heap.insert(k);
    } else if (s == "extract") {
      cout << heap.pop() << endl;
    } else {
      // rep (i, heap.W.size()) cout << heap.W[i] << endl;
    }
  }
}

Measured memory_bytes: 7104
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
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 STR(): return input()
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 = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
if len(s) < 26:
    for i in range(26):
        tmp = chr(i + ord('a'))
        if not tmp in s:
            print(s + tmp)
            exit()
if len(set(s)) == 26:
    for i in reversed(range(len(s))):
        for j in range(ord(s[i]) + 1, ord('z') + 1):
            if not chr(j) in s[:i]:
                print(s[:i] + chr(j))
                exit()
    print(-1)
    exit()

Measured memory_bytes: 59628
#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>>;
const int MOD = 1000000007;
const double pi = acos(-1);

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    else return gcd(b,a%b);
}

template <typename T>
struct RSQ {

    //初期化
    const T INF = numeric_limits<T>::max();
    int n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    RSQ(int n_) : n(), dat(n_ * 4, 0) { // 葉の数は 2^x の形
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }

    //値の更新
    void update(int i, T x) {
        i += n-1;
        dat[i] = x;
        while(i > 0) {
            i = (i-1)/2;
            dat[i] = gcd(dat[i*2+1],dat[i*2+2]);
        }
    }

    //任意区間の最小値
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return 0;
        else if(a <= l && r <= b) return dat[k];
        else {
            T v1 = query_sub(a,b,2*k+1,l,(l+r)/2);
            T v2 = query_sub(a,b,2*k+2,(l+r)/2,r);
            return gcd(v1,v2);
        }
    }
};

int main() {
    int N; cin >> N;
    RSQ<ll> S(N);
    REP(i,N) {
        ll a; cin >> a;
        S.update(i,a);
    }
    ll ans = 0;
    REP(i,N) {
        chmax(ans,gcd(S.query(0,i),S.query(i+1,N)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6372
// input macro
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

// body
fn main() {
    input! {
        n: isize,
        l: isize
    };
    let sum = l * n + ((n - 1) * n / 2);
    let mut min: isize = 10000;
    for i in 1..(n + 1) {
        if min.abs() > (l + i - 1).abs() {
            min = l + i - 1
        }
    }
    println!("{}", sum - min);
}


Measured memory_bytes: 4352
import math

N = int(input())

ans = [0 for i in range(N)]
for x in range(1, int(math.sqrt(N))+1):
    for y in range(1, int(math.sqrt(N))+1):
        for z in range(1, int(math.sqrt(N))+1):
            tmp = x*x+y*y+z*z+x*y+y*z+z*x
            if tmp <= N:
                ans[tmp-1] += 1

for i in range(N):
    print(ans[i])

Measured memory_bytes: 9264
//
// Created on 2020/05/03.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    ll ans_a;
    ll ans_b;
    int x;
    cin>>x;
    vector<ll>pow_list;

    for (ll i = 0; pow(i,5) < LINF ; ++i) {
        pow_list.push_back(pow(i,5));
    }

    bool find = false;
    for (int j = 0; j < pow_list.size(); ++j) {
        if(find) break;
        ll add = x+pow_list[j];
        ll sub = x-pow_list[j];
        for (int i = 0; i < pow_list.size(); ++i) {
            if(pow_list[i] == add){
                ans_a = i;
                ans_b = j;
                find = true;
                break;
            }else if(pow_list[i] == sub){
                ans_a = i;
                ans_b = -j;
                find = true;
                break;
            }else if(-pow_list[i] == add){
                ans_a = -i;
                ans_b = j;
                find = true;
                break;
            }else if(-pow_list[i] == sub){
                ans_a = -i;
                ans_b = -j;
                find = true;
                break;
            }
        }
    }

    cout<<ans_a<<" "<<ans_b<<endl;
    return 0;
}

Measured memory_bytes: 4240
#include <iostream>
using namespace std;
typedef long long ll;

ll A, B, C, D;

ll u(ll x,ll y){
    if(x < y)
        swap(x, y);
    ll t = x * y;
    ll r = x % y;
    while(r != 0){
        x = y;
        y = r;
        r = x % y;
    }
    return t / y;
}

int main(){
    cin >> A >> B >> C >> D;
    ll s = u(C, D);
    A--;
    A = A - (A / C + A / D - A / s);
    B = B - (B / C + B / D - B / s);
    cout << B - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define ld long double
#define print(a,n) rep(i,1,n)cout <<a[i] <<" ";
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// stoll(s);
int main()
{
   BRAHAMASTRA
   ll t; t=1;
//    cin >>t;
   while(t--)
   {
      ll n; cin >>n;
      if(n%1000 !=0)
      {
          ll rem = n/1000+1;
          cout <<rem*1000-n<<endl;
      }
      else cout <<0<<endl;
   }
}



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

int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string ans = "";
  rep(i, N){
    ans += S[i];
    ans += T[i];
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
def fib(n, memo={}):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = fib(n-1, memo)+fib(n-2, memo)
        return memo[n]


def main():
    n = int(input())
    print(fib(n))


if __name__ == '__main__':
    main()



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

using ll = long long;

const ll MOD = 998244353;

int main() {
    int A, B;
    cin >> A >> B;
    cout << "42 99" << endl;
    rep(i, 21) {
        rep(j, 99) {
            if (i % 2 == 0 || j % 2 == 1) {
                cout << ".";
                continue;
            }
            int r = (B - 1) / 50;
            int c = (B - 1) % 50;
            if (i / 2 < r) {
                cout << "#";
                continue;
            }
            if (i / 2 > r) {
                cout << ".";
                continue;
            }
            if ((j / 2) < c) cout << "#";
            else cout << ".";
        }
        cout << endl;
    }
    rep(i, 21) {
        rep(j, 99) {
            if (i % 2 == 0 || j % 2 == 1) {
                cout << "#";
                continue;
            }
            int r = (A - 1) / 50;
            int c = (A - 1) % 50;
            if (i / 2 < r) {
                cout << ".";
                continue;
            }
            if (i / 2 > r) {
                cout << "#";
                continue;
            }
            if ((j / 2) < c) cout << ".";
            else cout << "#";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int main(){
    ll S;
    cin >>S;
    ll a=ceil(sqrt(S));
    ll b= a*a-S;
    cout <<0<<" "<<0<<" "<<a<<" "<<b<<" "<<1<<" "<<a<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//const ll MOD  = 998244353;
//ll MOD;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}



int main(void){
  ll N;
  cin >> N;
  vector<string> S(N);
  rep(i, N) cin >> S[i];
  rep(i, N){
    sort(S[i].begin(), S[i].end());
  }
  sort(S.begin(), S.end());
  S.pb("#");
  ll ans = 0;
  ll cnt = 1;
  rep(i, N){
    if(S[i] == S[i+1]) cnt++;
    else{
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, k, c, ans;
int main() {
	ll i, j;
	cin >> n;
	k = n;
	for(i=2; i*i<=n; i++) {
		for(c=0; k%i==0; c++, k/=i);
		for(j=1; j<=c; j++) {
			c -= j;
			ans++;
		}
	}
	if(k>1) ans++;
	cout << ans;
	return 0;
}

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

int main() {
  int N, Y;
  cin >> N;
  string color;
  for (int i = 0; i < N; i++) {
    cin >> color; 
    if (color == "Y") { 
      Y = true;
      break;
    }
    Y = false;
  }
  if (Y)
    cout << "Four" << endl;
  else 
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i,N)  cin >> A.at(i);
  rep(i,N)  cin >> B.at(i);

  vector<vector<int>> dp((1<<N),vector<int>(N,1e9));
  rep(i,N)  dp.at((1<<i)).at(i)=0;
  REP(bit,1,(1<<N)){
    int cnt=0;
    rep(i,N)  if(bit&(1<<i))  cnt++;
    vector<int> used_sum(N,0);
    rep(i,N)  if(bit&(1<<i))  used_sum.at(i)++;
    for(int i=N-2;i>=0;i--) used_sum.at(i)+=used_sum.at(i+1);

    rep(i,N){
      int c;
      if(abs(cnt-1-i)%2==0) c=A.at(i);
      else  c=B.at(i);

      rep(j,N){
        if(bit&(1<<j))  continue;
        int nc;
        if(abs(cnt-j)%2==0) nc=A.at(j);
        else  nc=B.at(j);
        if(c>nc)  continue;

        chmin(dp.at(bit | (1<<j)).at(j),dp.at(bit).at(i) + used_sum.at(j));
      }
    }
  }
  int ans=1e9;
  rep(i,N)  chmin(ans,dp.at((1<<N)-1).at(i));
  if(ans==1e9)  ans=-1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 29796
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  rep(i,si){
    if(s[i]=='h' && s[i+1]=='i'){
      i++;
    }
    else{
      cout<<"No";
      return(0);
    }
  }
  cout<<"Yes";
  return(0);
}


Measured memory_bytes: 256
from math import sqrt
x = int(input())

if (sqrt(1 + 8*x) - 1)%2 == 0:
    x_ = (sqrt(1 + 8*x) - 1)//2 
else:
    x_ = (sqrt(1 + 8*x) - 1)//2 +1

print(int(min(x, x_)))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(void){
   string a;
   int b=1;
   cin>>a;
    size_t n = a.length();
   for(int i=0; i<n; i++){
       if((i%2)==0){
         if(a[i]=='L'){          
                     b=0;
          }
       }else{
          if(a[i]=='R'){
            
                     b=0;              
             
          }
        
       }
   }

if(b==1){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<string> s={"sat","sun","mon","tue","wed","thu","fri"};
  int x;
  cin >> x;
  cout << s[(x-9+14)%7] << endl;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int num1=c/b;
    if(c%b!=0)num1+=1;

    int num2=a/d;
    if(a%d!=0){
        num2+=1;
    }
    if(num1<=num2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    vector<bool> broken(N, false);
    ll dp[N+2] = {};
    dp[0] = 1;
    rep(i, M){
        int a; cin >> a;
        broken[a] = true;
    }
    for(int i = 0; i <= N-1; i++){
        if(!broken[i]){
            dp[i+1] += dp[i]; dp[i+1] %= mod;
            dp[i+2] += dp[i]; dp[i+2] %= mod;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        MyPoint[] p1 = new MyPoint[n];
        MyPoint[] p2 = new MyPoint[n];

        for(int i = 0; i<n; i++) {
            p1[i] = new MyPoint(sc.nextInt(), sc.nextInt());
        }
        for(int i = 0; i<n; i++) {
            p2[i] = new MyPoint(sc.nextInt(), sc.nextInt());
        }

        Arrays.sort(p1,(ac, bc)->(ac.x - bc.x));
        Arrays.sort(p2,(ac, bc)->(ac.x - bc.x));

        int cnt = 0;
        for(int i = 0; i<n; i++) {
            int maxYIndex = 0;
            int maxY = -1;
            boolean f = false;
            MyPoint p = p2[i];
            for(int j = 0; j<n; j++) {
                if(p1[j].x<p.x && p1[j].y<p.y) {
                    f = true;
                    if(maxY < p1[j].y) {
                        maxY = p1[j].y;
                        maxYIndex = j;
                    }
                }
            }
            if(f) {
                p1[maxYIndex].x = 201;
                p1[maxYIndex].y = 201;
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}
class MyPoint {
    int x, y;
    public MyPoint(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 28360
a = [int(input()) for _ in range(6)]
count = 0
for i in range(5):
    for j in range(i+1, 5):
        if abs(a[i] - a[j]) > a[5]:
            count += 1
            break
        else:
            continue
    break

if count == 0:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for X in range(0,101):
    for Y in range(0,101):
        f=True
        H=xyh[0][2]+abs(xyh[0][0]-X)+abs(xyh[0][1]-Y)
        for i in range(1,n):
            x,y,h=xyh[i]
            if h!=max(H-abs(x-X)-abs(y-Y),0):
                f=False
                break
        if f:
            print(X,Y,H)
            break

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
using namespace std;

struct tree {
	vector<int> children;
	int depth;
	int parent;
	string type; // root, leef, internal node
};

tree trees[100000];

int calc_depth(int n) {
	for (vector<int>::iterator i = trees[n].children.begin(); i < trees[n].children.end(); i++) {
		trees[*i].depth = trees[n].depth + 1;
		calc_depth(*i);
	}
}

int main(void) {
	// ??\????????°
	int num;

	cin >> num;

	for (int i = 0; i < num; i++) {
		trees[i].parent = -1;
		trees[i].depth = 0;
	}

	// ?????¨?????????????????\??????
	for (int i = 0; i < num; i++) {
		int node, children;
		cin >> node >> children;
			for (int j = 0; j < children; j++) {
				int child;
				cin >> child;
				trees[node].children.push_back(child);
				trees[child].parent = node;
		}
	}

	// depth????±???????
	for (int i = 0; i < num; i++) {
		if (trees[i].parent == -1) {
			calc_depth(i);
		}
	}

	for (int i = 0; i < num; i++) {
		if (trees[i].parent == -1) {
			trees[i].type = "root";
		} else if (trees[i].children.size() == 0) {
			trees[i].type = "leaf";
		} else {
			trees[i].type = "internal node";
		}
	}

	for (int i = 0; i < num; i++) {
		cout << "node " << i << ": parent = " << trees[i].parent;
		cout << ", depth = " << trees[i].depth << ", " << trees[i].type;
		cout << ", [";
		for (int j = 0; j < trees[i].children.size(); j++) {
			cout << trees[i].children[j];
			if (j != trees[i].children.size() - 1) {
				cout << ", ";
			}
		}
		cout << "]" << endl;
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	//vecto<int> a(n);
	int ans = 0;
	rep(i,n) {
		int a;
		cin >> a; 
		if ((i+1)%2 == 1 && a%2 == 1) ans++;
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3588
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1110111110111
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair < int , pii>              
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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


  int H, W;
  cin >> H >> W;
  REP(i, H + 2) {
    REP(j, W + 2) {
      if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
        cout << '#';
      } else {
        char c;
        cin >> c;
        cout << c;
      }
    }
    cout << endl;
  }

  return 0;
}

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

int main(){
  int A,B,C;  cin >> A >> B >> C;
  int K;  cin >> K;
  int mx = max(max(A,B),C);

  int sum = A + B + C - mx;

  cout << (int)pow(2,K)*mx + sum  << endl;


}

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

int N;
string S;

int main() {
    cin >> N >> S;

    int ans = 0;
    for (int i = 0; i <= 999; i++) {
        string str = to_string(i);
        if (i <= 99) str = "0" + str;
        if (i <= 9) str = "0" + str;
        
        int p = 0;
        for (int j = 0; j < N; j++) {
            if (str[p] == S[j]) {
                p++;
            }

            if (p == 3) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,a) FOR(i,0,a)
#define X real() 
#define Y imag()
namespace std{
	
typedef complex<int> cl;
	bool operator<(const cl& a, const cl& b){
	return a.X == b.X ? a.Y < b.Y : a.X < b.X;
	}
	bool operator>(const cl& a, const cl& b){
	return a.X == b.X ? a.Y > b.Y : a.X > b.X;
	}
}
using namespace std;
const int INF=1<<30;



int main() {
	int n,x,y,minium=INF;
	cin >> n;
	vector<cl> vcl;
	REP(i,n){
		scanf("%d",&x);
		scanf("%d",&y);
		vcl.push_back(cl(x,y));
	}
	sort(vcl.begin(),vcl.end());
	REP(i,n)
		FOR(j,i+1,n)
			if((int)pow(vcl[i].X-vcl[j].X,2)<=minium)
				minium=min(minium,norm(vcl[i]-vcl[j]));
			else 
				break;
	cout << minium << endl;
	// your code goes here
	return 0;
}

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

int main(){
	int a, sum = 0;

	for(int i = 0; i < 5; i++){
		cin>>a;
		if(a < 40) a = 40;
		sum += a;
	}

	cout<<sum/5<<endl;
	

	return 0;
}



Measured memory_bytes: 3100
using System;

public class s{
 static void Main(){
   int[] hw = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
   int[] hw2 = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
   Console.WriteLine((hw[0]-hw2[0])*(hw[1]-hw2[1]));
 }
}


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

int main() {
    int a, b, ans;
    cin >> a >> b;
    if(b % a) ans = b - a;
    else ans = a + b;
    cout << ans << endl;
}

Measured memory_bytes: 256