akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll V,E,d[500][500];
void warshall_floyd(){
  rep(k,V){
    rep(i,V){
      rep(j,V)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}
int main(){
  ll h,w;cin>>h>>w;
  V=10;
  rep(i,10){
    rep(j,10){
      cin>>d[i][j];
    }
  }
  warshall_floyd();
  vvl a(h,vl(w));
  ll ans=0;
  rep(i,h){
    rep(j,w){
      ll a;
      cin>>a;
      if(a==-1)continue;
      ans+=d[a][1];
    }
  }
  cout<<ans<<endl;
}
      
  

Measured memory_bytes: 640
N, Q = gets.chomp.split(" ").map(&:to_i)
C = Hash.new{|h, k| h[k] = []}
(N - 1).times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  C[a] << b
  C[b] << a
}
ans = Array.new(N + 1, 0)
Q.times{|q|
  p, x = gets.chomp.split(" ").map(&:to_i)
  ans[p] += x
}

stk = [[0, 1]]
until stk.empty? do
  pa, ch = stk.pop
  ans[ch] += ans[pa]
  C[ch].each do |gr|
    next if gr == pa
    stk.push([ch, gr])
  end
end

ans.shift
puts ans.join(' ')


Measured memory_bytes: 45284
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func isPrime(x int) bool {
	if x == 2 {
		return true
	}
	if x < 2 || x%2 == 0 {
		return false
	}

	var i = 3.0
	for i <= math.Sqrt(float64(x)) {
		if x%int(i) == 0 {
			return false
		}
		i += 2
	}
	return true
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n, count int
	if sc.Scan() {
		n, _ = strconv.Atoi(strings.TrimSpace(sc.Text()))
	}
	for i := 0; i < n; i++ {
		sc.Scan()
		stdIn, _ := strconv.Atoi(strings.TrimSpace(sc.Text()))
		if isPrime(stdIn) {
			count++
		}
	}

	fmt.Println(count)
}



Measured memory_bytes: 1168
#include<stdio.h>

int main(void){
    
    int H,W;
    
    while(1){
        
        scanf("%d %d",&H,&W);
        
        for (int i = 0;i<H;i++){
            for (int j = 0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
        
        
        if(H == 0 & W ==0){
            break;
        }
        printf("\n");
    }
    
    
    return 0;
}


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

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;

        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  long long N;
  cin >> N;
  const auto &res = prime_factorize(N);
  vector<long long> S(64);
  S[0] = 0;
  for (int i = 1; i < 64; i++) {
    S[i] = i + S[i-1];
  }
  long long result = 0;
  for (auto p : res) {
    for (int i = 1; i < 64; i++) {
      if (S[i] > p.second) {
        result += i-1;
        break;
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int ans = 0;
		for (int i = 1; i <= 9 ; i++) {
			ans = 100 * i + 10 * i + 1 * i;
			if (ans >= n) {
				break;
			}
		}
		System.out.println(ans);
	}
}

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

int digit_sum(int n) {
  int ans = 0;
  
  ans += n / 10000; n = n % 10000;
  ans += n / 1000; n = n % 1000;
  ans += n / 100; n = n % 100;
  ans += n / 10; n = n % 10;
  ans += n;
  
  return ans;
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int d_sum = digit_sum(i);
    if (a <= d_sum && d_sum <= b) ans += i;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n    = inputs(0).toInt

  solve(n)

  def solve(n: Int): Unit = {
    var nMap = scala.collection.mutable.HashMap.empty[Long, Int]

    (1L to 100L).foreach { i =>
      (1L to 100L).foreach { j =>
        (1L to 100L).foreach { k =>
          val f = i*i + j*j + k*k + i*j + j*k + k*i
          nMap.update(f, nMap.applyOrElse(f, (k: Long) => 0) + 1)
        }
      }
    }
    (1 to n).foreach { i =>
      println(nMap.applyOrElse(i.toLong, (k: Long) => 0))
    }
  }
}

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

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e16+18;
  const int N=1e5+15;
  const int M=3e3+13;
  
 int dp[M][M];
 char ch[M][M];
 string ans;

 void get_ans(int x,int y){
      
      if(x==0||y==0) return;

    if(ch[x][y]!='#')
      { ans+=ch[x][y];
        get_ans(x-1,y-1);
      }
    else
    {
      if(dp[x-1][y]>dp[x][y-1])
        get_ans(x-1,y);
       else
        get_ans(x,y-1);
    }

 }

 void fft()              
 { 
    string s,t; cin>>s>>t; int n=Z(s),m=Z(t);

    for(int i=1;i<=n;++i){
                        
       for(int j=1;j<=m;++j){
                   
           if(s[i-1]==t[j-1])
           { dp[i][j]=1+dp[i-1][j-1];
             ch[i][j]=s[i-1];
            }
           else
          {  dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
             ch[i][j]='#';
          }
       }
    }
    
    get_ans(n,m);

    reverse(all(ans));

    cout<<ans;

 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<tc)
   cout<<nl;
  }
  
 return 0; 
}

Measured memory_bytes: 79744
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int n, m;


  while(1){
    scanf("%d %d", &n, &m); 

    if(n == 0 && m == 0){
      break;
    }

    int a[n];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);

    int max = 0;
    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        int tmp = a[i] + a[j];
        if(tmp > max && tmp <= m)
          max = tmp;
      }
    }

    if(max != 0)
      cout << max << endl;
    else
      cout << "NONE" << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std ;

struct node
{
    double x , y , z ;
} ;

node a[22] ;
double map[22][22] ;
int n , m ;
double ma ;
int vis[22] ;

double dis( node a , node b )
{
    return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);
}

double max( double a , double b )
{
    return a > b ? a : b ;
}

void dfs( int p , int q , double sum )
{
    if( q + n - p + 2 < m )
        return ;
    if( q == m )
    {
        ma = max( ma , sum ) ;
        return ;
    }
    dfs( p + 1 , q , sum ) ;
    double temp ;
    temp = 0 ;
    for( int i = 0 ; i < q ; i ++ )
        temp += map[vis[i]][p] ;
    vis[q] = p ;
    dfs( p + 1 , q + 1 , sum + temp ) ;
}

int main()
{
    int i , j ;
    while( scanf("%d%d" , &n , &m) == 2 )
    {
        ma = -0x7fffffff ;
        memset( vis , 0 , sizeof(vis) ) ;
        for( i = 1 ; i <= n ; i ++ )
            scanf("%lf%lf%lf" , &a[i].x , &a[i].y , &a[i].z) ;
        for( i = 1 ; i <= n ; i ++ )
        {
            for( j = 1 ; j <= n ; j ++ )
                map[i][j] = dis( a[i] , a[j] ) ;
        }
        dfs( 1 , 0 , 0 ) ;
        printf("%.8lf\n" , ma) ;
    }
    return 0 ;
}

Measured memory_bytes: 1256
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int gcd_all(vi &A){int g = 0; for(int a:A) g = gcd(g, a);return g;}

int sum_array(vi &C, int start, int end, int step){
	int c = 0;
	for(int j=start; j<end; j+=step) c += C[j];
	return c;
}

bool is_pairwise(vi &A){
	int MAX_A = 1'000'001;
	vi C(MAX_A, 0);
	for(int a:A) C[a]++;
	if(sum_array(C, 2, MAX_A, 2) > 1) return false;
	for(int i=3; i<MAX_A; i+=2)
		if(sum_array(C, i, MAX_A, i) > 1) return false;
	return true;
}

int solve(vi &A){
	if(is_pairwise(A)) return 0;
	if(gcd_all(A) == 1) return 1;
	return 2;
}

int main(){
	int N; cin>>N;
	vi A(N); for(int i=0; i<N; ++i) cin>>A[i];
	cout<< vector<string>{"pairwise","setwise","not"}[solve(A)] <<" coprime\n";
}


Measured memory_bytes: 11172
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3148
import numpy as np
import heapq
Q = int(input())
Qinit = list(map(int,input().split()))
Qlist = [list(map(int,input().split())) for i in range(Q-1)]

#coef_list = []
intercept = Qinit[2]
left_list = []
cent_list = [Qinit[1]]
right_list = []
left_sum = 0
right_sum = 0

median = Qinit[1]
count = 0

for query in Qlist:
    if query[0] == 1:
        source = query[1]
        intercept += query[2]

        if cent_list == []:
            if median > source:
                heapq.heappush(left_list, -source)
                left_sum += source #
                tmp = -heapq.heappop(left_list)
                left_sum -= tmp #
                cent_list.append(tmp)
            elif right_list[0] > source:
                cent_list.append(source)
            else:
                heapq.heappush(right_list, source)
                tmp = heapq.heappop(right_list)
                right_sum += source - tmp
                cent_list.append(tmp)
            median = cent_list[0]
        else:
            if cent_list[0] < source:
                heapq.heappush(left_list, -cent_list[0])
                left_sum += cent_list[0]
                median = cent_list[0]
                heapq.heappush(right_list, source)
                right_sum += source
                cent_list.remove(cent_list[0])
            else:
                heapq.heappush(left_list, -source)
                left_sum += source
                median = -left_list[0]
                heapq.heappush(right_list, cent_list[0])
                right_sum += cent_list[0]
                cent_list.remove(cent_list[0])
            count += 1

    else:
        minval = np.abs(left_sum-count*median) + np.abs(right_sum-count*median) + intercept
        #print(str(median) + " " + str(minval))
        print("{} {}".format(median, minval))


Measured memory_bytes: 66052
class SEGMENT_TREE:
    def __init__(self, N):
        """
        INPUT
        N: 配列のサイズ
        segment tree: 1-indexedで構築
        original array: 0-indexed
                 1
           2           3
         4    5     6     7
        8 9 10 11 12 13 14 15
        ---------------------
        0 1 2  3  4  5  6  7
        """
        self.N = N
        self.tree = [0] * (2 * N)  # 問題により修正

    def init(self, arr):
        N = self.N
        for i in range(N):
            self.tree[N + i] = arr[i]
        for i in range(N - 1, 0, -1):
            self.tree[i] = max(
                self.tree[i * 2], self.tree[i * 2 + 1])  # 問題により修正

    def update(self, p, value):
        """配列arr[p]をvalueに変更"""
        i = p + self.N
        self.tree[i] = value
        while i > 1:
            self.tree[i // 2] = max(self.tree[i], self.tree[i ^ 1])  # 問題により修正
            i //= 2

    def query(self, l, r):
        """
        l, r: 0-indexed
        半開区間[l, r)から条件を満たす数を返す
        """
        N = self.N
        res = 0  # 問題により修正
        l += N
        r += N
        while l < r:
            if (l & 1):
                res = max(res, self.tree[l])
                l += 1
            if (r & 1):
                r -= 1
                res = max(res, self.tree[r])
            l //= 2
            r //= 2
        return res


if __name__ == "__main__":
    N = int(input())
    H = list(map(int, input().split()))
    A = list(map(int, input().split()))
    seg = SEGMENT_TREE(N + 1)
    for h, a in zip(H, A):
        left = seg.query(0, h + 1)
        seg.update(h, left + a)
    print(seg.query(0, N+1))

Measured memory_bytes: 122960
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

//const int N = 200 +5;]

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    ull c, n, k, x, y; cin>> n>> k>> x>> y;
    if(n <= k) c = x*n;
    else {
        c = k*x;
        n -= k;
        c += y*n;
    }
    cout<< c;
    
return 0;
}

Measured memory_bytes: 3652
# coding: utf-8

# In[38]:

number = int(input())
strings = input()


# In[39]:

while True:
    counter = 0

    for s in strings:
        if s == "(":
            counter += 1
        else:
            if counter > 0:
                counter -= 1
            else:
                strings = "(" + strings
                counter = -1
                break
        
    if counter > 0:
        strings = strings + ")" * counter
        
    if counter == 0:
        break

print(strings)


# In[ ]:





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,ans;
  	cin>>a>>b;
  	ans=a+b;
  	if(ans<a-b)ans=a-b;
  	if(ans<a*b)ans=a*b;
  	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  ll ans,n,k,i,a,b,j;
  cin >> n >> k;
  ans=0;
  a=0;
  b=0;
  for(j=0;j<k;j++){
      a+=j;
      b+=n-j;
  }
  ans+=b-a+1;
  ans=ans%1000000007;
  for(i=k;i<=n;i++){
    a+=i;
    b+=n-i;
    ans+=b-a+1;
    ans=ans%1000000007;
  }
  cout << ans;
}

Measured memory_bytes: 3636
N = int(input())
S = [int(input()) for _ in range(N)]
total = sum(S)
if total % 10 != 0:
  print(total)
else:
  num = [n for n in S if n % 10 != 0]
  if len(num) == 0:
    print(0)
  else:
    print(total - min(num))

Measured memory_bytes: 3060
canTalk :: Int -> Int -> Int -> Int -> Bool
canTalk a b c d = canTalkDirectly || canTalkIndirectly
  where canTalkDirectly   = abs (a - c) <= d
        canTalkIndirectly = abs (a - b) <= d && abs (b - c) <= d

main :: IO ()
main = do
  [a, b, c, d] <- map read . words <$> getLine
  putStrLn $ if canTalk a b c d then "Yes" else "No"

Measured memory_bytes: 508
#include <stdio.h>

int main(void){
   
   char S[1000100];
   
   scanf("%s",S);
   
   int i;
   int a = 0;
   int b = 0;
   
   for(i = 0; S[i] != '\0';i++){
      if(S[i] == '0'){
         a++;
      }
      else {
         b++;
      }
   }
   
   int ans;
   
   if(a >= b){
      ans = b;
   }
   else {
      ans = a;
   }
   printf("%d\n",ans*2);
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void upmax(short &x,const short &y){if(y>x) x=y;}
const int N=105;
short f[N][N][N][N];
short sum1[N][N],sum2[N][N];
int n,m,tx,ty;
void gao()
{
    int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
    for(int u=0;u<=limu;u++)
        for(int d=0;d<=limd;d++)
            for(int l=0;l<=liml;l++)
                for(int r=0;r<=limr;r++)
                {
                    int L=max(ty-l,r+1),R=min(ty+r,m-l);
                    if(L<=R)
                    {
                        upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
                        upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
                    }
                    L=max(tx-u,d+1),R=min(tx+d,n-u);
                    if(L<=R)
                    {
                        upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
                        upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
                    }
                }
    printf("%d\n",f[limu][limd][liml][limr]);
}
int main()
{
    static char s[105];
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
        {
            if(s[j]=='E') tx=i,ty=j;
            sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
            sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
        }
    }
    gao();
    return 0;
}

Measured memory_bytes: 207232
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<endl //to debug values of variables
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
 
int nDig(lld n)
{
	return floor(log10(n) + 1);
}

//--------------------------------------------------------------------------------
 
int main()
{
    SPEEDUP;
    lld n;
    cin>>n;

    string s;
    map <string,int> m;
    FORZ(i,n)
    {
    	cin>>s;
    	m[s]++;
    }

    lld max=0;
    for(auto i:m)
    {
    	if(max<i.nd)
    		max=i.nd;
    }

    for(auto i:m)
    {
    	if(max==i.nd)
    		cout<<i.st<<endl;
    }

    return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vector<int> b(m);
  rep(i, m) cin >> b[i];
  cout << includes(all(a), all(b)) << endl;
  return 0;
}



Measured memory_bytes: 4376
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	string s;
	cin >> s;

	int wNum = -1;
	auto count = 0ULL;
	bool isBAppeared = false;
	for (int i = 0; i < s.length(); ++i) {
		if (isBAppeared && s[i] == 'W') {
			count += i - wNum;
			++wNum;
		}
		if (!isBAppeared && s[i] == 'B'){
			wNum = i;
			isBAppeared = true;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#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 <cmath>
#include <iomanip>

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 != 2 && B != 2) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

}

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

using namespace std;

int main() {
    int A[3];

    for (int i = 0; i < 3; ++i) {
        cin >> A[i];
    }

    sort(A, A + 3);

    cout << min(abs(A[2] - A[1]) + abs(A[1] - A[0]), abs(A[1] - A[2]) + abs(A[1] - A[0])) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def isIsolated(g: Array[Array[Char]], y: Int, x: Int): Boolean = {
    if (g(y)(x) == '.') false
    else {
      val yMax = g.length
      val xMax = g(0).length
      (x - 1 < 0 || g(y)(x - 1) == '.') &&
        (x + 1 >= xMax || g(y)(x + 1) == '.') &&
        (y - 1 < 0 || g(y - 1)(x) == '.') &&
        (y + 1 >= yMax || g(y + 1)(x) == '.')
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val h,w = s.nextInt
    val g:Array[Array[Char]] = Array.fill(h)(s.next.toCharArray)
    for (
      y <- 0 until h;
      x <- 0 until w
    ) {
      if (isIsolated(g, y, x)) return "No"
    }
    "Yes"
  }

  val tests = List(
    """3 3
      |.#.
      |###
      |.#.""".stripMargin -> """Yes""",
    """5 5
      |#.#.#
      |.#.#.
      |#.#.#
      |.#.#.
      |#.#.#""".stripMargin -> """No""",
    """11 11
      |...#####...
      |.##.....##.
      |#..##.##..#
      |#..##.##..#
      |#.........#
      |#...###...#
      |.#########.
      |.#.#.#.#.#.
      |##.#.#.#.##
      |..##.#.##..
      |.##..#..##.""" -> """Yes"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25416
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r; 

	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	
	if(W >= x + r && H >= y + r && x > 0 && y > 0){		//W >x + r ?????? H > y + r ???????????¨
		printf("Yes\n");
	}
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;
//Int mod = 998244353; 
Int INF = 1e9+7;

int main() {    
    Int n;
    cin >> n;
    vector<string> s(n);
    Int ba = 0;
    Int xa = 0;
    Int bx = 0;
    for (Int i = 0; i < n; i++) {
        cin >> s[i];
        if (s[i].front() == 'B' && s[i].back() == 'A') ba++;
        else if (s[i].front() == 'B') bx++;
        else if (s[i].back() == 'A') xa++;
    }
    Int ab = 0;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < (Int)s[i].size() - 1; j++) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B') ab++;
        }
    }
    ab += max(ba - 1LL, 0LL);
    ba -= max(ba - 1LL, 0LL);
    if (ba > 0) {
        if (xa > 0) {
            ab++;
            xa--;
        }
        if (bx > 0) {
            ab++;
            bx--;
        }
    }
    ab += min(xa, bx);
    dump(ab);
    return 0;  
}

Measured memory_bytes: 768
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B&lang=ja 
GCD

*/

#include <bits/stdc++.h>

using namespace std;

unsigned int gcd(unsigned int a, unsigned int b);

int main(void){

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

    unsigned int ans;
    ans = gcd(a,b);

    printf("%d", ans);
    printf("\n");
	return 0;
	
  
}

unsigned int gcd(unsigned int a, unsigned int b){
	if(b == 0) return a;

	return gcd(b, a%b);
}


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

int main(){
  string s;

  while(getline(cin, s)){
    int flag = 0;
    
    while(true){
      for(int i=0;i<s.length();i++){
	string key1 = s.substr(i,3), key2 = s.substr(i,4);
	if(key1 == "the" || key2 == "this" || key2 == "that"){
	  flag = 1;
	}
      }
      
      if(flag){
	break;
      }else{
	
    
	for(int i=0;i<s.length();i++){
	  if(s[i] >= 'a' && s[i] <= 'z'){
	    // s[i] -= 'a';
	    // s[i] += 1;
	    // s[i] = s[i]%('A'-'a');
	    // s[i] += 'a';

	    s[i] -= 'a' - 'A';
	    s[i] = (char)('A' + (s[i] - 'A' + 26 + 1)%26);
	    s[i] += 'a' - 'A';
	    
	  }else{
	    continue;
	  }
	}
      }
    }
    cout << s << endl;
  }
  return 0;
}


  

Measured memory_bytes: 1192
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	h := readInt()
	w := readInt()
	a := make([][]byte, h)
	dp := make([][]int, h)
	for i := range a {
		a[i] = []byte(readString())
		dp[i] = make([]int, w)
	}
	m := 1000000007

	dp[0][0] = 1
	for i := range a {
		for j := range a[i] {
			if a[i][j] == '#' {
				continue
			}
			if 0 < j {
				dp[i][j] += dp[i][j-1]
				dp[i][j] %= m
			}
			if 0 < i {
				dp[i][j] += dp[i-1][j]
				dp[i][j] %= m
			}
		}
	}
	println(dp[h-1][w-1])
}

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


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int X,Y,A,B,C; cin >>X>>Y>>A>>B>>C;
  vii apples(A+B+C);
  rep(i,A) {
    int a; cin >> a;
    apples.push_back(ii(a,0));   
  }rep(i,B) {
    int a; cin >> a;
    apples.push_back(ii(a,1));   
  }
  rep(i,C) {
    int a; cin >> a;
    apples.push_back(ii(a,2));   
  }
  
  sort(apples.begin(), apples.end(), [](ii x, ii y) {return x.first > y.first;});
  int a=0,b=0,c=0, total=0;
  ll ans = 0;
  rep(i, A+B+C) {
    ii apple = apples[i];
    int color = apple.second;
    if (color==0 && a<X && total < X+Y) {
      a++;
      total++;
      ans+=apple.first;
    } else if (color == 1 && b<Y && total < X+Y) {
      b++; total++;
      ans+=apple.first;
    } else if (color == 2 && total < X+Y) {
      total++;
      ans+=apple.first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6784
import math
import numpy as np
import sys
def IL(): return list(map(int,sys.stdin.readline().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
xu = [SL() for i in range(N)]
j = 0
b = 0

for i in xu:
    x,u = i
    if u == "JPY":
        j += float(x)
    else:
        b += float(x)*380000

print(j+b)

Measured memory_bytes: 21656
K, N = map(int, input().split(' '))
A_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(N):
    l = A_ls[(i + 1) % N] - A_ls[i]
    if l < 0:
        l = K - A_ls[i] + A_ls[(i + 1) % N]
    if rst == -1:
        rst = l
    else:
        rst = max(rst, l)
print(K - rst)

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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

using pll = pair<ll, ll>;

constexpr int K = 1 << 17, N = 1 << 7;
constexpr int M = 1e9 + 7;
int f[N][K], s[N][K], a[N];

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

	int n, t; cin >> n >> t;
	rep(i, 0, n) cin >> a[i];
	f[0][0] = 1;
	rep(i, 0, n) {
		for (int k = 0; k <= t; ++k)
			s[i][k + 1] = (f[i][k] + s[i][k]) % M;
		for (int k = 0; k <= t; ++k)
			f[i + 1][k] = (s[i][k + 1] - s[i][max(0, k - a[i])]) % M;
	}
	if (f[n][t] < 0) f[n][t] += M;
	cout << f[n][t];
}

Measured memory_bytes: 104192
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char al;
    int cout[26]={},i;
    while(cin >> al){
        al = tolower(al);
        if(isalpha(al)){
            cout[al-'a']++;
        }
    }
    for(i=0; i<26; i++){
        printf("%c : %d\n",i+'a',cout[i]);
    }
    return 0;
}


Measured memory_bytes: 3168
import copy
h,w=map(int,input().split())
maze = [['#']+list(input())+['#'] for i in range(h)]
maze.insert(0,['#']*(w+2))
maze.append(['#']*(w+2))

def get_max_length_from_start(maze,x,y):
    tmp_maze=copy.deepcopy(maze)
    searching = [[y,x]]
    length=0
    while len(searching)!=0:
        next_searching_list=[]
        for point in searching:
            tmp_maze[point[0]][point[1]]='/'
            mawari = [
                [point[0]+1,point[1]],
                [point[0]-1,point[1]],
                [point[0],point[1]+1],
                [point[0],point[1]-1]
            ] 
            next_searching = list(filter(lambda x:tmp_maze[x[0]][x[1]]==".",mawari))
            if len(next_searching)==0:
                max_length=length
                continue
            next_searching_list += next_searching
        searching = list(map(list, set(map(tuple, next_searching_list))))
        length+=1
    return max_length

ans=0
for y in range(1,h+1):
    for x in range(1,w+1):
        if maze[y][x]=='#':
            continue
        max_length=get_max_length_from_start(maze,x,y)
        ans = max_length if max_length>ans else ans

print(ans)


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, a;
    cin >> n >> a;
    cout << ((a * n) % 2 == 0 ? "Even" : "Odd") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll n;
    cin >> n;
    ll sum=0;
    for(ll i = 0;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout << sum << endl;

}

Measured memory_bytes: 3592
//44
#include<iostream>

using namespace std;

int main(){
  char g[8][9];
  for(int i=0;i<8;i++){
    cin>>g[i];
  }
  cout<<90<<endl;
  for(int i=0;i<8;i++){
    for(int j=7;j>=0;j--){
      cout<<g[j][i];
    }
    cout<<endl;
  }
  cout<<180<<endl;
  for(int i=7;i>=0;i--){
    for(int j=7;j>=0;j--){
      cout<<g[i][j];
    }
    cout<<endl;
  }
  cout<<270<<endl;
  for(int i=7;i>=0;i--){
    for(int j=0;j<8;j++){
      cout<<g[j][i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
h, w = list(map(int, input().split()))
maze = []
for i in range(h):
    maze.append(input())
h_li = []
for i in range(h):
    exclude = True
    for j in range(w):
        if maze[i][j] == '#':
            exclude = False
    if not exclude:
        h_li.append(i)

w_li = []
for i in range(w):
    exclude = True
    for j in range(h):
        if maze[j][i] == '#':
            exclude = False
    if not exclude:
        w_li.append(i)

for i in h_li:
    ans = ''
    for j in w_li:
        ans += maze[i][j]
    print(ans)

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
int K;
signed main() {
    cin >> S >> K;
    string s1(S), s2(S);
    int cnt1 = 0, cnt2 = 1;
    bool flg1 = false, flg2 = false;
    for (int i = 1; i < s1.length(); i++) {
        if (s1[i] == s1[i - 1]) {
            s1[i] = '0', cnt1++;
            if (i == s1.length() - 1) { flg1 = true; }
        }
    }
    for (int i = 2; i < s2.length(); i++) {
        if (s2[i] == s2[i - 1]) {
            s2[i] = '0', cnt2++;
            if (i == s2.length() - 1) { flg2 = true; }
        }
    }
    if (S.length() == 1) { flg2 = true; }
    if (S[0] != S[S.length() - 1]) {
        //fffff...
        cout << cnt1 * K << endl;
    } else {
        if (flg1) {
            //fffff...
            cout << cnt1 * K << endl;
        } else {
            if (flg2) {
                //fにもどる
                //fgfgf...
                cout << cnt1 * (K / 2 + K % 2) + cnt2 * (K / 2) << endl;
            } else {
                //gのまま
                //fgggg...
                cout << cnt1 + cnt2 * (K - 1) << endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
const long long Mod = 1e9+7;
long long dp[5001][5001],vis[5001],size[5001],next[10001],last[5001],edge[10001],_dp[5001],df[10001];
int n,u,v;
void dfs(int root)
{
	vis[root] = true;
	size[root] = 1;
	dp[root][1] = 1;
	int p = last[root];
	while (p)
	{
		if (!vis[edge[p]])
		{
			dfs(edge[p]);
			for (int i = 1;i <= size[root]+size[edge[p]];++i)
				_dp[i] = 0;
			for (int i = 1;i <= size[root];++i)
				for (int j = 0;j <= size[edge[p]];++j)
					_dp[i+j] = (_dp[i+j]+dp[root][i]*dp[edge[p]][j])%Mod;
			size[root] += size[edge[p]];
			for (int i = 1;i <= size[root];++i)
				dp[root][i] = _dp[i];
		}
		p = next[p];
	}
	for (int i = 1;i <= size[root]/2;++i)
		dp[root][0] = (dp[root][0]-df[i*2-1]*dp[root][i*2]%Mod+Mod)%Mod;
}
void Add_Edge(int u,int v)
{
	edge[++edge[0]] = v;
	next[edge[0]] = last[u];
	last[u] = edge[0];
}
long long read()
{
	long long num = 0;
	char ch;
	ch = getchar();
	while (ch < 48 | ch > 57)
		ch = getchar();
	while (ch >= 48 && ch <= 57)
	{
		num = num*10+ch-48;
		ch = getchar();
	}
	return num;
 } 
int main()
{
	scanf("%d",&n);
	for (int i = 1;i < n;++i)
	{
		u = read();
		v = read();
		Add_Edge(u,v);
		Add_Edge(v,u);
	}
	df[1] = 1;
	for (int i = 1;i <= n;++i)
		df[2*i+1] = (df[2*i-1]*(2*i+1)+Mod)%Mod;
	dfs(1);
	printf("%lld\n",(Mod-dp[1][0])%Mod);
	return 0;
}

Measured memory_bytes: 90800
#import<cstdio>
int t,n,c[510],s[510],f[510],i,a,j;main(){for(scanf("%d",&n);~scanf("%d%d%d",c+j++,s+j,f+j););for(;f[n-1]=i<n;a=!printf("%d\n",a))for(j=i++;t=f[j];)a=(a<s[j]?s[j]:~-a/t*t+t)+c[j++];}

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




int main(){
  int N; cin>>N;
  vector<ll>A(N+1);
  for(int i=0;i<N+1;i++)
    cin>>A.at(i);
  vector<ll>B(N);
  for(int i=0;i<N;i++)
    cin>>B.at(i);
  
  ll res=0;
  
  for(int i=0;i<N;i++){
    
    if(A.at(i)>=B.at(i)){
      res+=B.at(i);
    }
    
    else{
      res+=A.at(i);
      B.at(i)-=A.at(i);
      
      if(A.at(i+1)>=B.at(i)){
        res+=B.at(i);
        A.at(i+1)-=B.at(i);
      }
      
      else{
        res+=A.at(i+1);
        A.at(i+1)=0;
      }
    }
    
  }
  
  cout<<res;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int n;
    cin>>n;
    if(n<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    return 0;
}




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

int main(){
    int a,b,C;
    double c,S,L,H,rad;
    double pi = acos(-1);
    cin >> a >> b >> C;
    rad = C*pi/180;
    S = a*b*sin(rad)/2;
    c = sqrt(a*a+b*b-2*a*b*cos(rad));
    L = S*2/a;
    printf("%.5f\n%.5f\n%.5f\n",S,a+b+c,L);
    return 0;
}


Measured memory_bytes: 3508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S, T;
            string input;

            input = Console.ReadLine();
            string[] inputArray = input.Split(' ');

            S = inputArray[0];
            T = inputArray[1];

            Console.WriteLine(T + S);

            return;
        }
    }
}


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

int main(){
    ll N;
    vector<ll> A(100010,0);
    
    cin >> N;
    ll sum = 0;
    rep(i,N){
        ll x;
        cin >> x;
        A[x]++;
        sum += x;
    }
    
    ll Q;
    cin >> Q;
    
    rep(z,Q){
        ll s,t;
        cin >> s >> t;
        ll v;
        
        //個数の移動
        v = A[s];
        A[s] = 0;
        A[t] += v;
        
        //数の変化
        ll ret = (t - s)*v;
        sum = sum + ret;
        
        cout << sum << endl;
    }
    
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
typedef long long ll;
using namespace std;
void solve(){
    
}
int  main(){
	fastio;
	int n;
	cin>>n;
	while(n>1000){
		n%=1000;
	}
	if(n==0){
		cout<<n<<endl;
	}
	else{
		cout<<1000-n<<endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    int from, to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

struct edge{
    ll to, cost;
};

int main(){
    ll n;
    cin>>n;

    vector<edge> g[n];
    for(ll i=0;i<n-1;++i){
        ll u, v, w;
        cin>>u>>v>>w;
        u--;
        v--;
        edge e1 = {u, w};
        edge e2 = {v, w};
        g[v].push_back(e1);
        g[u].push_back(e2);
    }

    vector<ll> ans(n, 0);
    ans[0] = 0;
    queue<ll> que;
    que.push(0);
    vector<ll> d(n, -1);
    d[0] = 0;
    while(!que.empty()){
        ll a = que.front();
        que.pop();
        for(auto val : g[a]){
            ll na = val.to;
            if(d[na] != -1)continue;
            d[na] = d[a] + val.cost;
            if(d[na] % 2 == 0){
                ans[na] = 0;
            }else{
                ans[na] = 1;
            }
            que.push(na);
        }
    }

    for(ll i=0;i<n;++i){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12212
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD=1000000007;
int main(){
	string s;
	cin>>s;
	int n=s.size();
	bool flag=false;
	int l=-1,r=-1;
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1])l=i+1,r=i+2;
	}
	for(int i=0;i<n-2;i++){
		if(s[i]==s[i+2])l=i+1,r=i+3;
	}
	cout<<l<<" "<<r<<endl;
}

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

int calc(int n){
    return n+n*n+n*n*n;
}

int main(){
    int n;
    char buf[30];
    fgets(buf,sizeof(buf),stdin);
    n=atoi(buf);
    printf("%d\n",calc(n));
}

Measured memory_bytes: 1672
n = int(input())
a = list(map(int, input().split()))

a.sort()

ans_n = a[-1]
del a[-1]
ans_r = a[0]

dif = 1001001000
for i in range(n-1):
    if dif > abs(ans_n / 2 - a[i]):
        ans_r = a[i]
        dif = abs(ans_n / 2 - a[i])

print('%d %d' % (ans_n, ans_r))

Measured memory_bytes: 20024