akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));
    int N = sc.nextInt();
    int max = Integer.MIN_VALUE;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int num = sc.nextInt();
        if (num > max) max = num;
        ans+=num;
    }
    ans -= max/2;
    System.out.println(ans);
  }

  /*
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

int main()
{
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
int main () {
  string a , b ;
  cin >> a >> b ;
  int pre = stoi(a)*pow(10,b.size()) + stoi(b) ;
  bool ans = false ;
  for(int i = 1 ; i < 2000 ; i++ ){
    if(pre==pow(i,2)) ans = true ;
    if(pre < pow(i,2)) break ;
  }
  if(ans) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<int> a(n + 1);
    a[0] = 0;
    for (int i = 0; i < n; i++) {
        a[i + 1] = a[i] + (s[i] == '#');
    }

    int r = n;
    for (int i = 0; i <= n; i++) {
        r = min(r, a[i] + n - i - (a[n] - a[i]));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1428
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);

    // Input
    int n = s.nextInt();
    int[] v = new int[n];
    for (int i = 0; i < n; i++) {
      v[i] = s.nextInt();
    }
    int[] c = new int[n];
    for (int i = 0; i < n; i++) {
      c[i] = s.nextInt();
    }

    // Solve
    int maxValue = 0;
    for (int i = 0; i < n; i++) {
      maxValue += Math.max(0, v[i] - c[i]);
    }

    // Output
    System.out.println(maxValue);
  }
}


Measured memory_bytes: 21844
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    ans = 0
    for i, ai in enumerate(a):
        if (i+1) % 2 and ai % 2:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int ll;
int main() {
    
    ll h, w, k, i, j, dap=0, l;
    char c[10][10], d[10][10];
    cin>>h>>w>>k;
    for(i=1;i<=h;i++)
    {
        scanf(" ");
        for(j=1;j<=w;j++)
        scanf("%c", &c[i][j]);
    }
    
    for(i=0;i<(1<<(h+w));i++)
    {
        for(j=1;j<=h;j++)
        {
            for(l=1;l<=w;l++)
            {
                d[j][l]=c[j][l];
            }
        }
        
        ll hogu=i;
        
        for(j=1;j<=h;j++)
        {
            if(hogu%2)
            {
                for(l=1;l<=w;l++)
                d[j][l]='.';
            }
            
            hogu/=2;
        }
        
        for(j=1;j<=w;j++)
        {
            if(hogu%2)
            {
                for(l=1;l<=h;l++)
                d[l][j]='.';
            }
            hogu/=2;
        }
        ll imsi=0;
        
        for(j=1;j<=h;j++)
        {
            for(l=1;l<=w;l++)
            {
                imsi+=(d[j][l]=='#');
            }
        }
        if(imsi==k)
        dap++;
    }
    
    
    
    cout<<dap;
    return 0;
}

Measured memory_bytes: 3760
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

def digit_sum(n,base=10):
    result = 0
    while n:
        result += n % base
        n //= base
    return result
n=int(input())
if n%digit_sum(n)==0:
    print("Yes")
else:
    print("No")

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d){
        cout << "Yes" << endl;
    }else if(abs(a-b)<=d&&abs(b-c)<=d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(void) {
  int a,b,c;
  cin >> a >> b >> c;
  if(a + b == c) {
    cout << "Yes" << endl;
  } else if (a + c == b) {
    cout << "Yes" << endl;
  } else if (b + c == a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

 class Main{
    
    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder sb = new StringBuilder("");
    static StringTokenizer stk = new StringTokenizer("");

    public static void main(String args[]){
        try{
            String s = bf.readLine();
            String t = bf.readLine();
            solver(s,t);
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public static void solver(String s, String t){
        int[][] dp = new int[s.length()][t.length()];

        for(int i=0;i<s.length();i++){ //for string s
            for(int j=0;j<t.length();j++){//for string t
                
                if(s.charAt(i) == t.charAt(j)){
                    dp[i][j] = 1 + ((i-1 >= 0 && j-1 >= 0) ? dp[i-1][j-1] : 0);
                }else{
                    dp[i][j] = Math.max((i-1 >= 0 ? dp[i-1][j] : 0),(j-1 >= 0 ? dp[i][j-1] : 0));
                }
                
            }
        }
        int slen = s.length()-1;
        int tlen = t.length()-1;

        StringBuilder sb  = new StringBuilder("");
        
        while(slen >= 0 && tlen >= 0){

            if((slen >= 0 && tlen >= 0) && s.charAt(slen) == t.charAt(tlen)){
                sb.append(s.charAt(slen));
                slen--;
                tlen--;
            }else{
                if(slen-1 >= 0 && tlen-1 >= 0){
                    if(dp[slen-1][tlen] > dp[slen][tlen-1] ){
                        slen--;
                    }else{
                        tlen--;
                    }
                }else if(slen-1 >= 0 && tlen-1 < 0){
                    slen --;
                }else if(slen-1 < 0 && tlen-1 >= 0){
                    tlen --;
                }else{
                    slen--;
                    tlen--;
                }
            }
        }


        System.out.println(sb.reverse().toString());
    }

    public static void printDpTable(int[][] dp){
        for(int i=0;i<dp.length;i++){
            for(int j=0;j<dp[i].length;j++){
                System.out.print(dp[i][j]+" ");
            }
            System.out.println("");
        }
    }
}

Measured memory_bytes: 88660
#include<string>
#include <utility>
#include <iostream>
 
#define MAX 100

#define INF 100000000

int left[MAX];
int right[MAX];

int DP[MAX][MAX];

int main(){
  int n;
  std::cin >> n;

  for(int i = 0; i < n; i++){
    std::cin >> left[i];
    std::cin >> right[i];
  }
  
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++){
      DP[i][j] = INF;
   }
  }

  for(int k = 0; k < n; k++){
    for(int l = 0; l + k < n; l++){
      int r = l + k;
      
      if(k == 0){
	DP[l][r] = 0;
      }else if(k == 1){
	DP[l][r] = left[l] * right[l] * right[r];
      }else{
	for(int t = l; t < r; t++){
	 
	  DP[l][r] = std::min(DP[l][r], DP[l][t] + DP[t + 1][r] + left[l] * right[t] * right[r]);
	}

	// printf("%d %d %d\n", l, r, DP[l][r]);
      }
    }
  }
  
  std::cout << DP[0][n-1] << std::endl;
}




Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 2000000009
#define init(x) memset(x,0,sizeof(x))
ll a[100]={2,1,0};
int n;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=2;i<=n;++i) a[i]=a[i-1]+a[i-2];
	cout<<a[n];
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define MAX_N 100010

int N, K;
int A[MAX_N], B[MAX_N];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;
  int bit = 0, sum = 0;
  set<int> st[33];
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    if(A[i] > K) continue;
    bit |= A[i];
    sum += B[i];
    for(int j = 0; j < 30; j++) {
      if((A[i]>>j)&1) st[j].insert(i);
    }
  }
  if(bit <= K) {
    cout << sum << endl;
    return 0;
  }
  int tmp = bit, ans = 0;
  set<int> nxt;
  for(int i = 29; i >= 0; i--) {
    int y = 0, x = 0;
    for(int j = 0; j < N; j++) {
      if(A[j] > K) continue;
      if(!nxt.count(j) && !st[i].count(j)) {
	y |= A[j];
	x += B[j];
      }
    }
    if((tmp&y) <= K) {
      ans = max(ans, x);
      tmp = bit;
    } else if(((tmp>>i)&1)) {
      for(int j : st[i]) {
	nxt.insert(j);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int ans = m;
    for(int i=0; i<n; i++){
        int in, out;
        cin >> in >> out;
        m = m +in -out;
        if(m < 0){
            ans = 0;
            break;
        }
        ans = max(ans, m);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <cstring>
#define int long long
using namespace std;
int *val;
int *wt;

int knapsck(int n, int w){
    int dp[2][w+1];
    for (int i=0; i<=n; i++){
        for (int j = 0; j <= w; j++){
            // Base Case ...
            if(i==0 || j == 0){
                dp[i%2][j] = 0ll; 
                continue;
            }
            if(wt[i-1]>j)
                dp[i%2][j] = dp[(i-1+2)%2][j];
            else{
                dp[i%2][j] = max( 
                                dp[ (i-1+2)%2 ][j] , 
                                val[i-1] + dp[ (i-1+2)%2 ][ j - wt[i-1] ] );
            }
        }
    }
    return dp[n%2][w]; 
}

signed main() {
    int n, w;

    cin >> n >> w;
    val = new int[n];
    wt = new int[n];
    int *p1 = new int[10000001];
    int *p2 = new int[10000001];
    int *p3 = new int[10000001];
    int *p4 = new int[10000001];
    int *p5 = new int[10000001];
    int *p6 = new int[10000001];
    int *p7 = new int[10000001];
    int *p8 = new int[10000001];
    int *p9 = new int[10000001];
    int *p10 = new int[10000001];
    
    for (int i=0;i<n; i++)
        cin >> wt[i] >> val[i];
    cout<<knapsck(n, w);
     
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int r = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s.at(i) == 'R') {
			r++;
		}
		else {
			b++;
		}
	}

	string jud = "No";
	if (r > b) {
		jud = "Yes";
	}

	cout << jud << endl;
	return 0;
}

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

int main(){
    int height, width;
    cin >> height >> width;

    while(height!=0 || width!=0){
        for(int i=1; i<=height; i++){
            for(int j=1; j<=width; j++){
                if((i+j)%2==0){
                    cout << "#";
                } else {cout << ".";
                }
            }
                cout << endl;
            }
        cout << endl;
        cin >> height >> width;
    }

    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxN=1e5+10;
const ll MOD=1e9+7;
ll n,k;
ll ans[maxN];
ll res=0LL;
ll fast_mi(ll a,ll n)
{
	ll ans=1;
	while(n){
		if(n%2==1) ans=(ans*a)%MOD;
		a=(a*a)%MOD;
		n=n/2;
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	for(ll x=k;x>=1LL;x--)
	{
		//ll multi_num=k/x;
		 ans[x]=fast_mi(k/x,n);
		for(ll i=2*x;i<=k;i+=x)
		{
			ans[x]=(ans[x]-ans[i])%MOD;  //防止为负数 
		}
		res=(res+ans[x]*x%MOD+MOD)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, k; cin >> n >> k;
  	vector<int> p(n);
  	for (int &i : p) {
      	cin >> i;
    }
  	sort(p.begin(), p.end());
  	cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
    return 0;
}


Measured memory_bytes: 3640
def parent_key(nodes, i)
  return if i < 2

  nodes[i / 2]
end

def left_key(nodes, i)
  nodes[i * 2]
end

def right_key(nodes, i)
  nodes[i * 2 + 1]
end

H = gets.chomp.to_i
keys = gets.chomp.split.map(&:to_i)
nodes = {}
keys.each.with_index(1) do |key, i|
  nodes[i] = key
end

nodes.each do |k, v|
  print "node #{k}: "
  print "key = #{v}, "
  print "parent key = #{parent_key(nodes, k)}, " if parent_key(nodes, k)
  print "left key = #{left_key(nodes, k)}, "     if left_key(nodes, k)
  print "right key = #{right_key(nodes, k)}, "   if right_key(nodes, k)
  puts "\n"
end



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

int main(){
	int n = 0;
	string s;
	cin >> s;
	string t;
	cin >> t;
	for(int i = 0;i<s.size();i++){
		if(s[i] == t[i]){
			n += 1;
		}
		else{
			n += 0;
		}
	}
	//cout << n;
	if(n == s.size()){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
} 

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

int main() {

	int x, n; cin >> x >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int tmp = 1000000;
	int ans;
	for (int i = 102; i >= -2 ; i--) {
		bool skip = false;
		for (int j = 0; j < n; j++) {
			if (i == p[j]) skip = true;
		}
		if (skip) continue;
		if (abs(x - i) <= tmp) {
			tmp = abs(x - i);
			ans = i;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int indexStart = s.indexOf("A");
		int indexEnd = 0;
		String[] sArray = s.split("");
		for(int i = s.length()-1;i >= 0;i--) {
			if(sArray[i].equals("Z")) {
				indexEnd = i;
				break;
			}
		}
		System.out.println(indexEnd - indexStart +1);
	}

}

Measured memory_bytes: 56072
N = int(input())#配列の数を
h = list(map(int, input().split()))

dp = []
dp.append(0)#配列の先頭に0をk加える
dp.append(abs(h[1]-h[0]))#配列の2番目の値も固定なので　加えておく

for i in range(2,N):
     t1 = dp[i - 2] + abs(h[i] - h[i - 2])
     t2 = dp[i - 1] + abs(h[i] - h[i - 1])
     dp.append(min(t1, t2))#大小比較を行う



print(dp[-1])#配列の末尾の値を出力する

Measured memory_bytes: 20648
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            var D = line[0];

            return "Christmas" + string.Join("", Enumerable.Repeat(" Eve", 25 - D));
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
string s;
int main() {
  cin>>s;
  int n = s.size();
  int cnt=0;
  int tot=0;
  for (int i = 0; i < n; ++i) {
  	if (cnt > 0) {
      cnt--;
      if (s[i] == 'g') tot++;
    } else {
      if (s[i] == 'p') tot--;
      cnt++;
    }
  }
  cout<<tot<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll i=0;
    while(a>0 && c>0)
    {
        if(i%2)
        a-=d;
        else
        {
            c-=b;
        }
        if(a<=0 || c<=0)
        {
            break;
        }
        i++;
    }
    if(a<=0)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if( T[u].p == NIL ) cout << "root, ";
  else if( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i=0, c=T[u].l; c!=NIL; i++,c=T[c].r) {
    if(i) cout <<", ";
    cout << c;
  }
  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    cin >> v >> d;
    for(j=0;j<d;j++) {
      cin >> c;
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 7700
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
    int n;
    scanf("%d", &n);
    int i, count, tmp;
    int count_max = -1;
    int ans = 0;
    for (i=1; i<=n; i++)
    {
        tmp = i;
        count = 0;
        while(tmp % 2 == 0)
        {
            tmp /= 2;
            count ++;
        }
        if (count > count_max) {
            count_max = count;
            ans = i;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/
fn f(n: i32) -> i32 {
    let mut sum = 0;
    let mut nn = n;
    while nn > 0 {
        sum += nn % 10;
        nn = nn / 10;
    }
    sum
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();

    if N%f(N) == 0 {
        println!("Yes");
    } else {
        println!("No");
    }


}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A <= B*2) cout << 0 << endl;
  else cout << A - B*2 <<endl;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int a, b, c, d, e;
void in(){
    cin >> a >> b >> c >> d >> e;
}

void solve(){

    print(min({a, b, c}) + min(d, e) - 50);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}


Measured memory_bytes: 3168
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, X,M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    mod=M

    dp=[[0,0] for _ in range(M)]
    
    cnt=1
    tot=X
    dp[X]=[cnt,tot]
    while cnt<N:
        X=X*X%M
        printe(X)
        if X==0:
            print(tot)
            return
        if not dp[X][0]:
            cnt+=1
            tot+=X
            dp[X]=[cnt,tot]
            if cnt==N:
                print(tot)
                return
        else:
            break
    syuki=cnt+1-dp[X][0]
    val=X+tot-dp[X][1]
    d,a=divmod(N-dp[X][0],syuki)
    tot=dp[X][1]
    tot+=val*d
    for i in range(a):
        X=X*X%M
        tot+=X
    print(tot)


if __name__ == "__main__":
    main()

Measured memory_bytes: 87788
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  


 void solve() {
     int q;
     cin>>q;
     set<string> st;
     rep(i,0,q) {
		    string s;
		    cin>>s;
		    st.insert(s);
		 }	    
		 cout<<sz(st)<<endl;
						   
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 19204
d = []
5.times do |i|
  d[i] = gets.strip.to_f
end

f = []
5.times do |i|
  f[i] = d[i]/10
end

min = 130*5

f.permutation(5) do |a|
  tmp = 0
  5.times do |i|
    tmp += a[i].ceil*10
  end
  tmp -= (a[4].ceil - a[4])*10
  min = tmp if tmp < min
end
puts min.to_i.to_s

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int k, a, b;
	cin >> k >> a >> b;

	long long int ans = 1;
	long long int yen = 0;
	for (int i = 0; i < k; i++) {
		if (a >= b) {
			ans += k - i;
			break;
		}
		if (yen == 1) {
			ans += b;
			yen--;
		}
		else if (ans >= a && i < k - 1 && b - a != 1) {
			ans -= a;
			yen++;
		}
		else {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (b % a == 0)
	{
		println(a + b);
	}
	else
	{
		println(b - a);
	}
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadstr() string {
	sc.Scan()
	return sc.Text()
}

func check(s, t string) bool {
	r := map[byte]byte{}
	for i := 0; i < len(s); i++ {
		c := s[i]
		if v, ok := r[c]; ok {
			if v != t[i] {
				return false
			}
		} else {
			r[c] = t[i]
		}
	}
	return true
}

func main() {
	s := loadstr()
	t := loadstr()
	if check(s, t) && check(t, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1408
local bls, brs = bit.lshift, bit.rshift
local mmi, mma = math.min, math.max
local bxor = bit.bxor

local function grayCode(x)
  return bxor(x, brs(x, 1))
end

-- add_func(idx), rm_func(idx), work_func()
local function grayWalk(size, add_func, rm_func, work_func)
  local prv = 0
  local total = bls(1, size) - 1
  local bpos = {}
  for i = 1, size do
    bpos[bls(1, i - 1)] = i
  end
  for i = 1, total do
    local v = grayCode(i)
    if prv < v then
      prv, v = v, v - prv
      add_func(bpos[v])
    else
      prv, v = v, prv - v
      rm_func(bpos[v])
    end
    work_func()
  end
end

local n = io.read("*n")
local v, w = {}, {}
for i = 1, n do
  v[i], w[i] = io.read("*n", "*n")
end
local head_tbl = {}
local box = {}
local ten5 = 100000

local tgt = 0
local weight, val = 0, 0
local tbl = nil
local function add_func(idx)
  weight = weight + w[brs(tgt, idx - 1)]
  val = val + v[brs(tgt, idx - 1)]
end
local function rm_func(idx)
  weight = weight - w[brs(tgt, idx - 1)]
  val = val - v[brs(tgt, idx - 1)]
end
local function work_func()
  if weight <= ten5 then
    tbl[weight] = mma(tbl[weight], val)
  end
end

for i = 512, mmi(n, 1023) do
  tgt = i
  head_tbl[i - 511] = {}
  tbl = head_tbl[i - 511]
  for j = 1, ten5 do
    tbl[j] = 0
  end
  weight, val = 0, 0
  grayWalk(10, add_func, rm_func, work_func)
  for i = 2, ten5 do
    tbl[i] = mma(tbl[i], tbl[i - 1])
  end
end

local q = io.read("*n")
local ans, wlim = 0, 0
local function work_func2()
  if weight <= wlim then
    ans = mma(ans, val)
  end
end
local function work_func3()
  if weight <= wlim then
    ans = mma(ans, val)
  end
  if weight < wlim then
    ans = mma(ans, val + tbl[wlim - weight])
  end
end
for iq = 1, q do
  local pos, wlim_tmp = io.read("*n", "*n")
  wlim = wlim_tmp
  local deg = 0
  do
    local tmp = pos
    while 0 < tmp do
      deg, tmp = deg + 1, brs(tmp, 1)
    end
  end
  if pos < 512 then
    ans = 0
    weight, val = 0, 0
    tgt = pos
    grayWalk(deg, add_func, rm_func, work_func2)
    print(ans)
  elseif pos < 1024 then
    print(head_tbl[pos - 511][wlim])
  else
    deg = deg - 10
    tbl = head_tbl[brs(pos, deg) - 511]
    ans = tbl[wlim]
    weight, val = 0, 0
    tgt = pos
    grayWalk(deg, add_func, rm_func, work_func3)
    print(ans)
  end
end


Measured memory_bytes: 562776
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()

int main(){
  string s,t;
  cin>>s>>t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, x, y = ns()

    ans = [0 for _ in range(n-1)]

    for i in range(1, n):
        for j in range(i + 1, n + 1):
            tmp1 = abs(i - j)
            tmp2 = abs(x - i) + abs(y - j) + 1
            ans[min(tmp1, tmp2) - 1] += 1

    for ai in ans:
        print(ai)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5492
#include<stdio.h>
int main(){
  int m,n,t,s,g,i;
  while(1){
    scanf("%d",&m);
    if(m==0)break;
    t=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d %d",&s,&g);
      t+=g-s;
    }
    if(t<m)printf("%d\n",m-t);
    else   printf("OK\n");
  }
  return 0;
}
  

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair

using namespace std;


int main(){

    int n;
    vector<int> c,s,f;

    cin >> n;

    rep(i,n - 1){
        int ci,si,fi;
        cin >> ci >> si >> fi;

        c.pback(ci);
        s.pback(si);
        f.pback(fi);
    }

    rep(i,n){
        int time = 0;
        for(int j = i; j <= n - 2; j++){
            if(time <= s[j]){
                time = s[j];
            }else{
                if(time % f[j] != 0) time = time + (f[j] - time % f[j]);
            }
            time = time + c[j];
        }
        cout << time << endl;
    }


    return 0;
}

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


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            var K = cin.nextInt();

            if(K == 1)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(N - K);
            }            
        }

        public static int BinarySearch<T>(T[] array, T target) where T : IComparable<T>
        {
            int min = 0;
            int max = array.Length - 1;

            while (true)
            {
                if (max < min) return -1;
                int mid = min + (max - min) / 2;
                switch (target.CompareTo(array[mid]))
                {
                    case -1:
                        max = mid - 1;
                        break;
                    case 1:
                        min = mid + 1;
                        break;
                    case 0:
                        return mid;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

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

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

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

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

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


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

float func(float n){
    if(int(n)%2==0) return float(n/2);
    else return float(3*n+1);
}

int main(){
    float s,ans=0.0;
    cin >> s;
    int max=1000000;
    vector<float> a(max);
    bool flag = false;
    a[0] = s;
    for (int i=1;i<max;++i){
        a[i] = func(a[i-1]);
        for(int j=0;j<i;++j){
            if(a[i]==a[j] && i>j){
                flag = true;
                break;
            }
        }
        if(flag){
            ans = i+1;
            break;
        }
    }
    cout << int(ans) << endl;
}





Measured memory_bytes: 4224
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = [0]
for x in P:
  lst.append(lst[-1] + (x+1)/2)

res = -1
for i in range(N-K+1):
  sum = lst[i+K]-lst[i]
  res = max(res, sum)

print("{:.6f}".format(res))
 

Measured memory_bytes: 25060
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if((x-r)>=0 && (y-r)>=0 && (x+r)<=W && (y+r)<=H){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26420
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
int A[101];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];

  ll SUM = pow(3, N);
  ll ODD = 1ll;
  rep(i, N) {
    if (A[i]%2==0) ODD*=2;
    else ODD*=1; 
  }
  cout << SUM-ODD << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int absyai(int a,int b){return a>b?a-b:b-a;}

int main(void){
    int N;
    scanf("%d",&N);
    int A[N+2];
    for(int i=0;i<N;i++)scanf("%d",&A[i+1]);
    A[0]=0;
    A[N+1]=0;
    int karians=0;
    for(int i=1;i<=N+1;i++)karians+=absyai(A[i],A[i-1]);
    for(int i=1;i<=N;i++){
        printf("%d\n",karians-absyai(A[i],A[i-1])-absyai(A[i+1],A[i])+absyai(A[i+1],A[i-1]));
    }
    return 0;
}


Measured memory_bytes: 1536
S = list(input())

def dfs(i, s):
    res = 0
    if i == len(S) - 1:
        f = S[0]
        for j in range(len(s)):
            f += s[j] + S[j + 1]
        return eval(f)

    for o in [['+'], ['']]:
        res += dfs(i + 1, s + o)

    return res

print(dfs(0, []))

Measured memory_bytes: 38640
import collections as col

def prime(n):
    ans = []
    for i in range(2, int(n**0.5)+1):
        while not n%i: n //= i ; ans.append(i)
    if n != 1: ans.append(n)
    return col.Counter(ans)
    
n = int(input())
a = list(map(int,input().split()))

cnt = col.Counter()
for num in a:
    new = prime(num)
    for key,val in new.items():
        if val > cnt[key] : cnt[key] = val

LCM = 1
MOD = 10**9 + 7
for key,val in cnt.items(): LCM *= key**val %MOD

ans = 0
for num in a:
    b = LCM * pow(num, MOD-2, MOD) #割るのではなく逆元をかける
    ans += b
    
print(ans%MOD)





Measured memory_bytes: 4980
#include <iostream>
#include <string.h>
using namespace std;

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

int main() {

    long long n,w;
    cin >> n >> w;

    long val[n],wei[n];
    rep(i,n) cin >> val[i] >> wei[i];

    long dp[n+1][w+1];
    memset(dp,0,sizeof(dp));


    rep(i,n){
      rep(j,w+1){
        if(j >= wei[i])
          dp[i + 1][j] = max(dp[i][j - wei[i]] + val[i],dp[i][j]);
        else
          dp[i+1][j] = dp[i][j];
      }
    }

    cout << dp[n][w] << endl;

    return 0;

}


Measured memory_bytes: 10956
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int v[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    cin >> v[i];
  }
  int a, b;

  int memoa[100005];
  int memob[100005];
  fill(memoa, memoa + 100005, 0);
  fill(memob, memob + 100005, 0);

  REP(i, n) {
    if(i % 2) {
      memoa[v[i]]++;
    } else {
      memob[v[i]]++;
    }
  }

  vector<P> vpa;
  vector<P> vpb;
  REP(i, 100005) {
    vpa.push_back(make_pair(memoa[i], i));
    vpb.push_back(make_pair(memob[i], i));
  }

  sort(vpa.begin(), vpa.end(), greater<P>());
  sort(vpb.begin(), vpb.end(), greater<P>());

  int ans = 0;
  if(vpa[0].second == vpb[0].second) {
    int a = (n / 2 - vpa[0].first) + (n / 2 - vpb[1].first);
    int b = (n / 2 - vpa[1].first) + (n / 2 - vpb[0].first);
    ans = min(a, b);
  } else {
    ans = (n / 2 - vpa[0].first) + (n / 2 - vpb[0].first);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3188
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] == l[j] or l[j] == l[k]:
                continue
            if l[k] < l[i] + l[j]:
                ans += 1
print(ans)

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

using namespace std;

int const maxn = 303;

int n;
double dp[maxn][maxn][maxn];

double solve(int a, int b, int c) {
    if (a+b+c == 0) return 0.0;

    double& d = dp[a][b][c];

    if (d != -1.0) return d;

    double pa = (double)a/(double)n;
    double pb = (double)b/(double)n;
    double pc = (double)c/(double)n;
    double pn = 1.0 - pa - pb - pc;

    d = 1.0;
    if (a > 0) {
        d += pa*solve(a-1, b+1, c);
    }
    if (b > 0) {
        d += pb*solve(a, b-1, c+1);
    }
    if (c > 0) {
        d += pc*solve(a, b, c-1);
    }

    d /= 1.0-pn;

    return d;
}

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

    cin >> n;

    for (int i = 0; i < maxn; i++) {
        for (int j = 0; j < maxn; j++) {
            fill(dp[i][j], dp[i][j] + maxn, -1.0);
        }
    }

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if (x == 3) a++;
        if (x == 2) b++;
        if (x == 1) c++;
    }

    cout << setprecision(9) << fixed;
    cout << solve(a, b, c) << "\n";
}

Measured memory_bytes: 217728
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;

    bool flag = false;
    if (s[2] == s[3] and s[4] == s[5]) {
        flag = true;
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
    cin >> a >> b;
    ll min = (a<b) ? a : b;
    ll max = (a<b) ? b : a;
    ll dif = max - min;
    if (!(dif%2)) {
        cout << min + dif/2 << endl;
        return 0;
    }else{
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
}

Measured memory_bytes: 256