akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int x;
  int S = 0;
  
  cin >> N;
  x = N;
  
  for ( int i=0; i<8; i++) {
    S += x % 10;
    x = x/10;
      if ( x == 0 ) {
        break;
      }
  }
    if ( N % S == 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5]) cout <<"Yes";
  else cout << "No";

  return 0;
}

Measured memory_bytes: 256
from itertools import groupby

R = lambda: map(int, input().split())
n, k = R()
a = list(R())
w = [0] * n

def merge(b, e):
    m = b + (e - b) // 2
    i, j = b, m
    r = k = 0
    while i < m and j < e:
        if a[i] <= a[j]:
            w[k] = a[i]
            i += 1
        else:
            r += m - i
            w[k] = a[j]
            j += 1
        k += 1
    a[e - m + i: e] = a[i: m]
    a[b: b + k] = w[:k]
    return r        
  
  
def mergesort(b, e):
    if e - b < 2:
        return 0
    m = b + (e - b) // 2
    return mergesort(b, m) + mergesort(m, e) + merge(b, e)


r = k * mergesort(0, n)
c = n * (n - 1) // 2
for _, g in groupby(a):
    x = sum(1 for _ in g)
    c -= x * (x - 1) // 2
print((r + c * k * (k - 1) // 2) % (10**9 + 7))


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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=n-1;i>=m;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long  n, a, b;

	cin >> n>>a>>b;
	vector<long long> v(n);
	REP(i, n) 	cin >> v[i];
	long long ans = 0;
	REP(i, n-1) {
		ans += min(a*(v[i + 1] - v[i]), b);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N;
int F[110];
int P[110][20];


int solve(){
	int ans = -INF;
	rep(i, 1, 1<<10){
		int p = 0;
		rep(j, 0, N)
			p += P[j][__builtin_popcount(i&F[j])];
		chmax(ans, p);
	}
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N){
		rep(j, 0, 10){
			int a;
			cin >> a;
			F[i] += (a<<j);
		}
	}
	rep(i, 0, N)
		repe(j, 0, 10) cin >> P[i][j];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int w,h;
string s;

int main(){
    ios::sync_with_stdio(0);
    cin >> h >> w;
    forn(i,h){
        cin >> s;
        cout << s << "\n";
        cout << s << "\n";
    }
    return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        nextInt();
        String s = next();
        int times = 0;
        int curr = 0;
        char[] looking = {'A', 'B', 'C'};
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == looking[curr]) curr++;
            else {
                curr = 0;
                if (s.charAt(i) == looking[curr]) curr++;
            }
            if (curr == 3) {
                times++;
                curr = 0;
            }
        }
        System.out.println(times);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
using namespace std;
#define null (-1)
#define Max 25
struct binary_trees{int parent; int left;int right;};
int getdep(binary_trees a[],int id){
	int i=id,dep=0;
	while(a[i].parent!=null){
	dep++;
	i=a[i].parent;
	}
	return dep;
}
int gethight(binary_trees a[],int id){
int depl,depr,dep,i;
	depr=0;depl=0;
	if(a[id].left!=null){
	depl=gethight(a,a[id].left);
	depl++;
	}
	if(a[id].right!=null){
	depr=gethight(a,a[id].right);
	depr++;
	}
	dep=max(depr,depl);
	return dep;
}
void p_type(binary_trees a[],int id){
	if(a[id].parent==null){
		printf("root\n");
		return ;
	}
	if(a[id].left==null&&a[id].right==null){
		printf("leaf\n");
		return;
	}
	printf("internal node\n");
}
main(){
	int n,i,id,lf,ri,sib,chi;
	binary_trees a[Max];
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    a[i].parent=null;
		a[i].left=null;
		a[i].right=null;
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&id,&lf,&ri);
		a[id].left=lf;
		a[id].right=ri;
		a[lf].parent=id;
		a[ri].parent=id;
	}
	for(i=0;i<n;i++){
		chi=0;sib=null;
		printf("node %d: parent = %d, ",i,a[i].parent);
		if(a[i].parent!=null){
		if(i==a[a[i].parent].left)
		sib=a[a[i].parent].right;
		else
		sib=a[a[i].parent].left;
		}
		if(a[i].left!=null)
		chi++;
		if(a[i].right!=null)
		chi++;
		printf("sibling = %d, degree = %d, ",sib,chi);
		printf("depth = %d, height = %d, ",getdep(a,i),gethight(a,i));
		p_type(a,i);
	}
	return 0;
}



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

int main()
{
    int light[100010]={};
    int num[100010]={};
    int n,i,k;
    while (scanf("%d",&n)!=EOF)
    {
        memset(light,0,sizeof (light));
        memset(num,0,sizeof (num));
        for (i=1;i<=n;i++)
        {
            scanf("%d",&light[i]);
        }
        i=1;
        k=0;
        while (i!=2&&num[i]==0)
        {
            num[i]=1;
            i=light[i];
            k++;
        }
        if (i==2)
            printf("%d\n",k);
        else
            printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();
        long N;
        N = sc.nextLong();
        solve(A, B, N);
    }

    static void solve(long A, long B, long N){
        double s;
        if (B - 1 < N) {
            s = 1.0 * (B-1) / B * 1.0;
        } else {
            s = 1.0*N / B * 1.0;
        }
        System.out.println((int)(Math.floor(A * s)));
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 32836
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cerrno>
#include <cfenv>
#include <cstring>
#include <bitset>

using namespace std;
int main()
{

    ///vector<int> A(N);
    /*
    double A, B, K, restA, restB;
    cin >> A;
    cin >> B;
    cin >> K;

    if (K <= A)
    {
        restA = A - K;
        restB = B;
    }
    else if (K <= A+B)
    {
        restA = 0;
        restB = B + (A - K);
    }
    else
    {
        restA = 0;
        restB = 0;
    }

    if (restA < 0)
    {
        restA = 0;
    }
    if (restB < 0)
    {
        restB = 0;
    }



    cout << restA << " " << restB;
    return 0;
    */

    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    string ans = S + T;

    for (int i = 0; i < N; i++)
    {
        ans[2 * i] = S[i];
        ans[2 * i + 1] = T[i];
    }

    cout << ans;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}



ll N;
string s;

int main(void){
	cin >> N;
	cin >> s;
	llm ans = llm(1);
	for(int i=1;i<=N;i++) ans *= llm(i);

	ll c = 0;
	for(int i=0;i<2*N;i++){
		if (s[i]=='W'){
			if (c%2){
				c++;
			}else{
				if (c==0) {cout << 0 << endl; return 0;}
				ans *= llm(c);
				c--;
			}
		}else{
			if (c%2){
				ans *= llm(c);
				c--;
			}else{
				c++;
			}
		}
		// cerr << c << endl;
	}
	if (c != 0) {cout << 0 << endl; return 0;}
	
	cout << ans << endl;


    return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		List<Integer> listX = new ArrayList<>();
		List<Integer> listY = new ArrayList<>();
		for(int i=0;i<n;i++){
			listX.add(sc.nextInt());
		}
		for(int i=0;i<m;i++){
			listY.add(sc.nextInt());
		}

		Collections.sort(listX);

		Collections.sort(listY);

		// System.out.println(listX.get(n-1));
		// System.out.println(listY.get(0));
		boolean flag = false;
		int giriX = listX.get(n-1);
		int giriY = listY.get(0);
		for(int i=-100;i<101;i++){
			if(giriX<i && i<=giriY && x<i && i<=y){
				flag=true;
				break;
			}
		}
		System.out.println(flag?"No War":"War");
		// if(listX.get(n-1)<listY.get(0)){
		// 	if(listY.get(0) > x && listX.get(n-1) < y ){
		// 		System.out.println("No War");
		// 	}else{
		// 		System.out.println("War");
		// 	}
		// }else{
		// 	System.out.println("War");
		// }



	}
}

Measured memory_bytes: 23636
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N = int(input())
    else:
        pass

    T = np.asarray([False]*(N**2))
    T = T.reshape(N,N)
    Res = np.copy(T)
    range_N = np.asarray(range(N))
    #range_N += 1

    if N % 2 == 0:
        for i,j in zip(range_N,range_N[::-1]):
            if i >= j: break
            T[i,j] = True
            T[j,i] = True
    else:
        for i,j in zip(range_N,range_N[::-1]):
            j -= 1
            if i >= j: break
            T[i,j] = True
            T[j,i] = True

    Res[T==True] = False
    Res[T==False] = True
    
    for i in range_N:
        Res[i,i] = False

    #print(Res)
    print(Res[Res].size//2)

    for i in range_N:
        for j in range_N[i:]:
            if Res[i,j] == True: print(i+1,j+1)
if __name__ =='__main__':
    main()

Measured memory_bytes: 21632
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.SplitInt64();
            var N = line[0];
            var X = line[1];

            return GetPateCount((int)N, X);
        }

        long GetPateCount(int level, long x)
        {
            if (x <= 0) return 0;
            if (level == 0) return 1;

            var b = burgers[level];
            var half = b.length / 2 + 1;
            if (x == b.length)
                return b.pateLength;

            if (x == half)
                return burgers[level - 1].pateLength + 1;
            else if (x < half)
                return GetPateCount(level - 1, x - 1);
            else
                return burgers[level - 1].pateLength + 1 + GetPateCount(level - 1, x - half);
        }

        static Burger[] burgers = new Burger[51];
        static Program()
        {
            burgers[0].length = burgers[0].pateLength = 1;
            for (int i = 1; i <= 50; i++)
            {
                burgers[i].length = 3 + burgers[i - 1].length * 2;
                burgers[i].pateLength = 1 + burgers[i - 1].pateLength * 2;
            }
        }
        struct Burger
        {
            public long length;
            public long pateLength;
        }


        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: 13396
#include<stdio.h>
int main() {
    int a,b;
    char op;
     for(;;){
    scanf("%d %c %d",&a,&op,&b);
  
    if(op=='+')
        printf("%d\n",a+b);
    else if(op=='-')
        printf("%d\n",a-b);
    else if(op=='*')
        printf("%d\n",a*b);
    else if(op=='/')
        printf("%d\n",a/b);
    else if(op=='?')
    break;}
 return 0;
}



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

int main() {
int H, W;
cin >> H >> W;
  vector<string> vec(H * W);
  for(int i = 0; i < H; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    cout << "#" << vec.at(i) <<"#" << endl;
  }
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> b(n);
  rep(i,n){
    cin>>b[i];
    b[i]--;
  }
  
  vector<int> ans;
  rep(k,n){
    for(int i=b.size()-1;i>=0;i--){
      if(b[i]==i){
        ans.pb(b[i]+1);
        b.erase(b.begin()+b[i]);
        break;
      }
    }
  }
  
  if(int(ans.size())!=n) puts("-1");
  else{
    rep(i,n) cout << ans[n-i-1] << endl;
  }
}





Measured memory_bytes: 256
import sys
from collections import deque
N, M = map(int, input().split())
G = [[] for i in range(N)]
R = [0]*N
for m in range(M):
    A,B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)
d = deque()
for n in G[0]:
    d.append(n)
    R[n]=1
while len(d)>0:
    i = d.popleft()
    for j in range(len(G[i])):
        if R[G[i][j]] == 0 and G[i][j]!=0:
            d.append(G[i][j])
            R[G[i][j]]=i+1
for n in range(1,N):
    if R[n]==0:
        print("No")
        sys.exit()
print("Yes")
for n in range(1,N):
    print(R[n])

Measured memory_bytes: 37208
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;

int32_t main()
{
    IOS;
    int x; cin>>x; int sign=x/abs(x);
    x=abs(x);
    vector<int> store;
    int val=0;
    for(int i=0;i<=120 ;i++)
    {
        val=i*i*i*i*i;
        store.pb(val);
    }
    int a=-1,b=-1;
    for(int z=0;z<sz(store);z++)
    {
        for(int y=0;y<sz(store);y++)
        {
            if(store[z]+store[y]==x)
                {a=z,b=-y;goto label;}
            if(store[z]-store[y]==x)
                {a=z,b=y;goto label;}
        }
    }
    label:
    if(sign==-1)
        a*=-1,b*=-1;
    cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
#define ed '\n'
using namespace std;
typedef long long int ll;
#define mod 998244353
double pi=3.14159265358979323846;
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll t;
	t=1;
	for(ll testcase=1;testcase<=t;testcase++){
	ll n;
	cin>>n;
	ll count[n];
	memset(count,0,sizeof(count));
	for(ll i=0;i<n-1;i++)
	{
		ll x;
		cin>>x;
		count[x-1]++;
	}
	for(ll i=0;i<n;i++)cout<<count[i]<<endl;
	}
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=1e5+10;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

int N,eg[maxn*2][3],egh[maxn],ect;
int siz[maxn];
int aaa;
ll sum,n0,ans2,ans;

inline void adeg(int a,int b,int c){
	eg[++ect][0]=b,eg[ect][1]=egh[a],egh[a]=ect,eg[ect][2]=c;
}

inline void dfs(int x,int f,int ine){
	siz[x]=1;
	for(int i=egh[x];i;i=eg[i][1]){
		int b=eg[i][0];if(b==f) continue;
		dfs(b,x,i);siz[x]+=siz[b];
		n0+=eg[i][2]*(siz[b]>=N-siz[b]);
	}
	sum+=2ll*min(siz[x],N-siz[x])*eg[ine][2];
}

inline void dfs2(int x,int f,ll n){
	// printf("~%d %d %d\n",x,f,n);
	if(sum-n>ans&&n) ans=sum-n,aaa=x;
	for(int i=egh[x];i;i=eg[i][1]){
		int b=eg[i][0];if(b==f) continue;
		dfs2(b,x,n+eg[i][2]*((siz[b]<=N-siz[b])-(siz[b]>=N-siz[b])));
	}
}
inline void dfs3(int x,int f,ll n){
	if(x!=aaa) ans2=max(ans2,ans-n);
	for(int i=egh[x];i;i=eg[i][1]){
		int b=eg[i][0];if(b==f) continue;
		dfs3(b,x,n+eg[i][2]*((siz[b]<=N-siz[b])-(siz[b]>=N-siz[b])));
	}
}

int main(){
    //freopen("","r",stdin);
	N=rd();
	for(int i=1;i<N;i++){
		int a=rd(),b=rd(),c=rd();
		adeg(a,b,c),adeg(b,a,c);
	}
	dfs(1,0,0),dfs2(1,0,n0);
	// dfs3(1,0,n0);
	printf("%lld\n",ans);
    return 0;
}

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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    long res = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                res += __gcd(i, __gcd(j, k));
            }
        }
    }

    cout << res;
    return 0;
}








Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
N=int(input())
ki=[[] for f in range(N)]
for i in range(N-1):
 u,v,w = map(int,input().split())
 ki[u-1].append([v-1,w%2])
 ki[v-1].append([u-1,w%2])
stack = [[0,0]]
check = [0]*N #チェック済みリスト
ans=[2]*N
ans[0]=0
while stack != [] :
 a=stack.pop()
 ne=a[0]
 if check[ne]==0:
  check[ne]=1
  for i in range(len(ki[ne])):
   eda=ki[ne][i][0]
   edanum=ki[ne][i][1]
   edaans=(edanum+ans[ne])%2
   if check[eda]==0:
    stack.append([eda,edaans])
    ans[eda]=edaans
for i in ans:
 print(i)

Measured memory_bytes: 79008
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;

int lcs[3001][3001];
string s, t;

int main(){

    cin >> s >> t;

    for (int i = 0; i <= s.size(); i++){
        for (int j = 0; j <= t.size(); j++){
            if (i == 0 || j == 0) lcs[i][j] = 0;
            else if (s[i-1] == t[j-1]) lcs[i][j] = lcs[i-1][j-1]+1;
            else lcs[i][j] = max(lcs[i][j-1], lcs[i-1][j]);
        }
    }

    int len = lcs[s.size()][t.size()];
    int idx = len-1;
    char sol[len+1];
    for (int i = 0; i <= len; i++) sol[i] = '\0';

    int i = s.size();
    int j = t.size();

    while (i > 0 && j > 0){
        if (s[i-1] == t[j-1]){
            sol[idx] = s[i-1];
            i--; j--;
            idx--;
        }
        else if (lcs[i-1][j] >= lcs[i][j-1]) i--;
        else j--;
    }

    cout << sol;

    return 0;

}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 3000 + 10;

int n, t, a[mx], b[mx];
vector<int> ve;
int dep[mx][mx];
int dp(int now, int time){
    if(time >= t) return 0;
    if(now == n) return 0;
    int &ret = dep[now][time];
    if(ret != -1) return ret;
    ret = 0;
    int x = a[ve[now]], y = b[ve[now]];
    ret = max(ret, dp(now + 1, time));
    ret = max(ret, dp(now + 1, time + x) + y);
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> t;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        ve.pb(i);
    }
    sort(ALL(ve), [&](int x, int y){
        return a[x] < a[y];
    });
    reset(dep, -1);
    cout << dp(0, 0) << endl;
}

Measured memory_bytes: 35840
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
         string a,b;
         cin>>a>>b;
         
         ll s=a.size(),i;
         
         ll f=1;
         f(i,s)
         {
               if(a[i]!=b[i])
               {
                     f=0;
                     o("No")
                     re
               }
         }
         
         
         o("Yes")
         
         
         
         
         






        
	re
}

Measured memory_bytes: 3652
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = Math.abs(b+a);
		if(c%2!=0) System.out.println("IMPOSSIBLE");
		else System.out.println(c/2);
	}
}

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

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

int m[102][102];

signed main(){
    int h,w,n;
    cin>>h>>w>>n;
    int p=-1,q=0;
    int d=0;
    REP(i,n){
        int a;
        cin>>a;
        REP(j,a){
            if(d==0&&p==w-1)q++,d=1;
            else if(d==0)p++;
            else if(d==1&&p==0)q++,d=0;
            else if(d==1)p--;
            m[q][p]=i+1;
        }
    }
    REP(i,h){
        REP(j,w){
            cout<<m[i][j];
            if(j<w-1)cout<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 384
import math
def func(x,y,z):
    ans = x**2 + y**2 + z**2+ x*y + y*z + z*x
    return ans

N = int(input())
array_N = [0]*N
root_n = round(math.sqrt(N+1))

for x in range(1,root_n):
    for y in range(1,root_n):
        for z in range(1,root_n):
            if func(x,y,z) <= N:
                array_N[func(x,y,z)-1] = array_N[func(x,y,z)-1] +1
                
for i in range(N):
    print(array_N[i])

Measured memory_bytes: 9232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const long double zero = 0.0;
ll x[1010], y[1010], r[1010];
long double dist(int i, int j)
{
    ll dx = (x[i] - x[j]);
    ll dy = y[i] - y[j];
    return pow((long double)(dx * dx + dy * dy), 0.5);
}

int main() {
    cout.precision(100);
    ll xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> r[i];
    }
    x[0] = xt;
    y[0] = yt;
    r[0] = 0;
    x[n + 1] = xs;
    y[n + 1] = ys;
    vector<pair<long double, int> > cost;
    for(int i = 0; i <= n; i++){
        pair<long double, int> in;
        in.first = max(zero, dist(i, n + 1) - r[i]);
        in.second = i;
        cost.push_back(in);
    }
    sort(cost.begin(), cost.end());
    for(int i = 0; i <= n; i++){
        if(cost[i].second == 0){
            cout << cost[i].first << endl;
            return 0;
        }
        for(int j = i + 1; j <= n; j++){
            cost[j].first = min(cost[j].first, cost[i].first + max(zero, dist(cost[i].second, cost[j].second) - r[cost[i].second] - r[cost[j].second]));
        }
        sort(cost.begin() + i + 1, cost.end());
    }
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

def main():
    A = [list(map(int,input().split())) for _ in range(3)]
    hit = [['n'] * 3 for _ in range(3)]

    N = int(input())
    for _ in range(N):
        b = int(input())

        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    hit[i][j] = 'y'

    correct = ['y'] * 3
    for i in range(3):
        row = hit[i]

        if row == correct:
            print('Yes')
            quit()

        vert = [hit[x][i] for x in range(3)]
        if vert == correct:
            print('Yes')
            quit()

    ri = [hit[0][0], hit[1][1], hit[2][2]]
    if ri == correct:
        print('Yes')
        quit()

    le = [hit[2][0], hit[1][1], hit[2][0]]
    if le == correct:
        print('Yes')
        quit()
    print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B;
	int con  =0;
	set<int> s, s2;
	map<int,int> mp;
	
	cin>>A>>B;
	
	s.insert(1);
	
	int a = A;
	
	for(int i = 2; i*i <= a; i++){
		
		while(a%i == 0){
			s.insert(i);
			a /= i;
		}
		
		
	}
	
	if(a != 1) s.insert(a);
	
	
	s2.insert(1);
	
	int b = B;
	
	for(int i = 2; i*i <= b; i++){
		
		while(b%i == 0){
			s2.insert(i);
			b /= i;
		}
		
		
	}
	
	if(b != 1) s2.insert(b);
	
	for(auto it = s.begin(); it != s.end(); it++){
		mp[*it]++;
	}
	
	for(auto it = s2.begin(); it != s2.end(); it++){
		mp[*it]++;
	}
	
	for(pair<int,int> p: mp){
		if(p.second >= 2) con++;
	}
	
	cout<<con<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long

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

	cout << (h-a)*(w-b) << endl;

	return 0;
}

Measured memory_bytes: 256
const arr = require('fs').readFileSync('/dev/stdin','utf8').match(/^[\s\S]*?(?=\n0 0)/g)[0].split('\n').map(r=>r.split(' ').map(Number));
console.log(arr.map(([H,W])=>[...Array(H).keys()].map(()=>'#'.repeat(W)).join('\n')).join('\n\n').concat('\n'))


Measured memory_bytes: 17084
N, K = [int(_) for _ in input().split()]
A = []
for i in range(K):
    d = int(input())
    A.append([int(_) for _ in input().split()])

xs = [0] * N
for rs in A:
    for r in rs:
        xs[r - 1] += 1

result = sum(x == 0 for x in xs)

print(result)


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) {
    cin >> a.at(i);
    if((a.at(i) % 2) == 0){
      if(((a.at(i) % 3) == 0) || ((a.at(i) % 5) == 0)){}
      else{
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
    cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
map<ll,ll> mp;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i],mp[a[i]]++;
    rep(i,n){
        if(mp[a[i]]==0)continue;
        if(mp[a[i]]>=a[i]){
            ans+=mp[a[i]]-a[i];
            mp[a[i]]=0;
        }
        else{
            ans+=mp[a[i]];
            mp[a[i]]=0;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 7040
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=998244353;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Cb make_pair
#define Ll long long
#define Ull unsigned long long
#define Snf scanf
#define Prf printf
#define Pb push_back
#define Stc stack
#define Vct vector
#define Ret return
#define Sz size
int n;
int w[10001];
int dp[105][505];
int main()
{
	Snf("%d",&n);
	int s=0;
	for(int i=1;i<=n;i++)
	{
		Snf("%d",&w[i]);
		s+=w[i];
	}
	//sort(w+1,w+1+n);
	int t=0;
	int mn=BIG;
	for(int i=1;i<n;i++)
	{
		t+=w[i];
		if(/*w[i]!=w[i+1]*/27)
		{
			mn=min(mn,abs((s-t)-t));
		}
	}
	Prf("%d",mn);
	Ret 0;
}


Measured memory_bytes: 256
import operator  as op
import itertools as itr

def main():
	N  = int(input())
	AB = [tuple(map(int, input().split())) for _ in range(N)]

	ABs = sorted(AB, key = op.itemgetter(1))
	it  = itr.accumulate(ABs, lambda t1, t2: (t1[0]+t2[0], t2[1]))
	if all(map(lambda t: t[0] <= t[1], it)):
		print("Yes")
	else:
		print("No")

	return


main()



Measured memory_bytes: 33476
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
#include <cmath>
typedef long long ll;

using namespace std;

int main() {
    ll n;
    cin >> n;
    
    ll ans = 1000000000100;
    for(ll i = 1; i <= sqrt(n); i++) {
        if(n % i == 0) {
            ans = min(ans, i + (n / i) - 2);
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int n;
vector<string>v;
void solve(string s,int pos,string ans)
{
    if(pos==n)
    {
     v.push_back(ans);return;
    }


    solve(s,pos+1,ans+'+'+s[pos]);
    solve(s,pos+1,ans+s[pos]);


}
int main()
{
    string s;
    cin>>s;
    n=s.size();
    string x="";
    x+=s[0];
    solve(s,1,x);

    long long ans=0;
    for(string s:v)
    {
        string x="";
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='+')
            {
                ans+=stoll(x);x.clear();
            }
            else
                x+=s[i];
        }
        ans+=stoll(x);
        x.clear();
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3640
#include <iostream>
#include <cassert>
using namespace std;
typedef long long ll;
ll ans = 0,b[500010],cnt[2][500010] = {},ze[500010],mod = 1000000007;
int nx[2][1<<20];
int main(){
	int i,n,w = 0;
	cin >> n;
	b[0] = 0;
	for(i=0;i<n;i++){
		ll a; cin >> a;
		b[i + 1] = b[i]^a;
		if(b[i + 1]==0) w++;
	}
	if(b[n]!=0){
		ll x = 1,z = 0;
		for(i=n-1;i>=0;i--){
			if(b[i]==0){
				(z += x) %= mod;
			}
			if(b[i]==b[n]){
				(x += z) %= mod;
			}
		}
		ans += x;
	}else{
		for(i=0;i<(1<<20);i++){
			nx[0][i] = n; nx[1][i] = n;
		}
		ze[n] = 1; cnt[1][n] = 0;
		for(i=n - 1;i>=0;i--){
			ze[i] = ze[i + 1];
			if(b[i]!=0){
				if(ze[i] - ze[nx[0][b[i]]]>0){
					nx[0][b[i]] = nx[1][b[i]];
				}
				if(nx[0][b[i]]!=n){
					cnt[0][i] = (cnt[1][nx[0][b[i]]]*(ze[i] - ze[nx[0][b[i]]])%mod + cnt[0][nx[0][b[i]]])%mod;
					cnt[1][i] = (cnt[1][nx[1][b[i]]] + cnt[0][i])%mod;
				}else{
					cnt[0][i] = 1; cnt[1][i] = cnt[1][nx[1][b[i]]] + 1;
				}
				nx[1][b[i]] = i;
			}else{
				ze[i]++;
			}
		}
		for(i=0;i<(1<<20);i++){
			if(nx[1][i]!=n){
				(ans += cnt[1][nx[1][i]]) %= mod;
			}
		}
		ll ret = 1;
		for(i=0;i<w-1;i++){
			(ret *= 2) %= mod;
		}
		(ans += ret) %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 24064
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor, cos, sqrt, pi
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

A, B, H, M, = map(int, input().split())

a = (H * 60 + M) * 0.5
b = ((H * 60 + M) * 6) % 360

t = max(a, b) - min(a, b)
t = min(abs(360 - t), t)

p = A ** 2 + B ** 2

if t == 90:
    print(sqrt(p))
    exit(0)

print(sqrt(p - 2 * A * B * cos(t * pi / 180)))


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

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<double> a;
	rep(i, n) {
		double A;
		cin >> A;
		a.push(A);
	}

	rep(i, m) {
		double top = a.top();
		a.pop();
		a.push(top / 2);
	}

	ll ans = 0;
	rep(i, n) {
		ans += (int)a.top();
		a.pop();
	}

	cout << ans << endl;
}

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

int main()
{
  int A,B;
  cin>>A>>B;
  int val1 = A+B;
  int val2 = A-B;
  int val3 = A*B;
  if(val1 >= val2 && val1 >= val3)
    cout<<val1;
  else if(val2 >= val1 && val2 >= val3)
    cout<<val2;
  else if(val3 >= val2 && val3 >= val1)
    cout<<val3;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main ()
{
    double x1, x2, y1, y2, a;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
     a=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
         printf("%lf\n",sqrt(a));
         
  return 0;
}


Measured memory_bytes: 2112
function Main(input) {
	input = input.trim();
  var output = 0;
  var seijou = "CODEFESTIVAL2016";
  for(var i = 0; i < input.length; i++){
    var tmp1 = input.slice(i,i+1);
    var tmp2 = seijou.slice(i,i+1);
    if(tmp1 != tmp2){
       output++;
       }
  }
  
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


const int INF = 100000000;

int main()
{
	int N,W;
	cin >> N >> W;
	vector<int> v(N);
	vector<int> w(N);
	rep(i,N)
	{
		cin >>v[i]>>w[i];
	}
	int dp[101][10001]={};
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<=W;j++)
		{
			if(j < w[i])
			{
				dp[i+1][j] = dp[i][j];
			}
			else
			{
				dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
			}
			
		}
	}
	cout<<dp[N][W]<<endl;

	return 0;
}


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

int main() {
  int n, num1, num2;
  string answer;
  bool a = true;
  cin >> n;
  num1 = n / 100;
  num2 = n % 100;
  
  if(num1 == 0 || num1 > 12) {
    if(num2 > 12 || num2 == 0) {
      answer = "NA";
    } else {
      answer = "YYMM";
    }
    a = false;
  }
  
  if(a) {
    if(num2 == 0 || num2 > 12) {
      answer = "MMYY";
    }else {
      answer = "AMBIGUOUS";
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = [int(i) for i in input().split(" ")]
sums = [sum(a[:k])] + [0 for i in range(n-k)]
for i in range(1, n-k+1):
    sums[i] = sums[i-1]-a[i-1]+a[i+k-1]
print((max(sums)+k)/2)


Measured memory_bytes: 24688
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string S, T;
    int k = 0;
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i]==T[i])k++;
        else {cout << "No"; return 0;}

    }

    if (k < T.size() ) cout << "Yes";
    else cout << "No";






}


Measured memory_bytes: 3124
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<queue>
#include<vector>
#define LL long long
#define ULL unsigned long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define itn int
#define pritnf printf
#define mp make_pair
#define pb push_back
using namespace std;

const int maxn=100;
LL n;
LL a[maxn];

int main(){
	cin>>n;
	LL Max=-1,Min=1e9+1;
	For(i,1,n){
		LL temp;cin>>temp;
		Min=min(Min,temp);
		Max=max(Max,temp);
	}
	cout<<Max-Min;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;


int n;

int main(){
	cin>>n;
	cout<<800*n-200*(n/15)<<endl;


	  return 0;
  }

Measured memory_bytes: 256
#include<fstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;

int m1=0,m2=0;
int N,A,x[55];
long long res=0,dp[55][55][3000];

int main()
{
	scanf("%d%d",&N,&A);
	for(int i=0;i<N;i++)scanf("%d",&x[i+1]);
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	for(int j=1;j<=N;j++)
		for(int k=0;k<=N;k++)
			for(int s=0;s<3000;s++)
			{
				if(j>=1&&k>=1&&s>=x[j])
					dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
				else if(j>=1&&s<x[j])
					dp[j][k][s]=dp[j-1][k][s];
			}
	for(int k=1;k<=N;k++)res+=dp[N][k][A*k];
	printf("%lld\n",res);
}

Measured memory_bytes: 71168
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=300+10;
int cnt[maxn];
int a[maxn][maxn],p[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,mx,ans;
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n)
		fo(j,1,m)
			scanf("%d",&a[i][j]);
	fo(i,1,n){
		p[i]=1;
		cnt[a[i][1]]++;
	}
	ans=n+1;
	fo(i,1,m){
		mx=0;
		fo(j,1,m)
			if (!bz[j]&&(mx==0||cnt[j]>cnt[mx])) mx=j;
		ans=min(ans,cnt[mx]);
		bz[mx]=1;
		fo(j,1,n)
			if (a[j][p[j]]==mx){
				while (p[j]<m&&bz[a[j][p[j]]]) p[j]++;
				cnt[a[j][p[j]]]++;
			}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512