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

int main(){
  int N;
  cin >> N;
  int A;
  map<int,int> m;
  for(int i=0;i<N;i++){
    cin >> A;
    if(m.count(A)){
      m.at(A)++;
    }else{
      m[A]=1;
    }
  }
  int e=0;
  int o=0;
  for(auto & p:m){
    if(p.second%2==0){
      e++;
    }else{
      o++;
    }
  }
  if(e%2!=0){
    e--;
  }
  cout << e+o << endl;
  return 0;
}


Measured memory_bytes: 8320
n = int(input())
dam = list(map(int, input().split()))
mt = [0]*n
# a[i]]は山iと山i+1に降った平均
mt[0] = sum(dam) - 2*sum(dam[1::2])
mt[n-1] = dam[n-1]*2-mt[0]
for i in range(1, n-1):
    mt[i] = dam[i-1]*2-mt[i-1]
print(' '.join(map(str, mt)))


Measured memory_bytes: 19212
n,k,c=map(int,input().split())
s=str(input())
l=[]
r=[]
cnt=0
for i in range(k):
    if s[cnt]=="o":
        l.append(cnt+1)
        cnt+=c+1
    else:
        while s[cnt]!="o":
            cnt+=1
        l.append(cnt+1)
        cnt+=c+1
cnt=1
for i in range(k):
    if s[-cnt]=="o":
        r.append(n-cnt+1)
        cnt+=c+1
    else:
        while s[-cnt]!="o":
            cnt+=1
        r.append(n-cnt+1)
        cnt+=c+1
r=r[::-1]
for i in range(k):
    if l[i]==r[i]:
        print(l[i])



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

int main(){
	int64_t x;	cin >> x;
  	int A = 0, B = 0;
  	for(int a = -1001; a < 1001; a++){
    	for(int b = -1001; b < 1001; b++){
        	if(x == pow(a,5) - pow(b,5)){
            	A = a;	B = b;
              	break;
            }
        }
    }
  	cout << A << " " << B << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    ll sum = 0;
    rep(i, n) rep(j, i) {
        sum += d[i] * d[j];
    }
    cout << sum <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>


using namespace std;

int main()
{
	int n, l, s;
	cin >> n >> l;
	s = (n*(n+1)) / 2 + l*n - n;
	s-= l-1;
	if (l - 1 >= 0)
	{
		s-=1;
	}
	else
	{
		if (-(l-1) <= n)
		{
			s-= -(l-1);
		}
		else
		{
			s-=n;
		}
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        public class lower_bound<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 <= x.CompareTo(y) ? 1 : -1;
        }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N = Sarray()[0];
            var Ai = Sarray();
            var A = new long[N];
            for (var i = 0; i < N; ++i)
                ++A[Ai[i] - 1];
            Array.Sort(A);
            var S = new long[N + 1];

            var lb = new lower_bound<long>();

            for (var i = 0; i < N; ++i) S[i + 1] = S[i] + A[i];

            long ans = N, j = N;
            Func<long, long, bool> ok = (cok, kok) =>
            {
                while (0 <= j && cok < A[j - 1]) --j;
                long sum = cok * (N - j) + S[j];
                return cok * kok <= sum;
            };
            for (var k = 1; k <= N; ++k)
            {
                while(true)
                {
                    if (ok(ans, k)) break;
                    --ans;
                }
                WriteLine(ans);
            }
            Out.Flush();
        }
    }
}

Measured memory_bytes: 47020
#include<stdio.h>
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[m+10];
    int sum=0;
    for(int i=1;i<=m;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
        
    }
    if(sum<=n){
        printf("%d\n",n-sum);
    }else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
int main(){
    int n,m;cin>>n>>m;
    int c=1;
    rep(i,n)c*=2;
    vector<vector<int>>v(m);
    int k,x;
    rep(i,m){
        cin>>k;
        rep(j,k){cin>>x;x--;v[i].push_back(x);}
    }
    vector<int>p(m);rep(i,m)cin>>p[i];
    int ans=0;bool A=true;
    rep(i,c){
        A=true;
        rep(j,m){
            int count=0;
            rep(k,v[j].size()){
                if(i&(1<<v[j][k]))count++;
            }
            if(count%2!=p[j]){A=false;break;}
        }
        if(A)ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = G().Sum();
		Console.WriteLine(s >= 10 ? "error" : s.ToString());
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;

public class Main {
	static class FastScanner{//用于快速读入大量数据
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in),16384);
			eat("");
		}
		public void eat(String s) {
			st = new StringTokenizer(s);
		}
		public String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		public boolean hasNext() {
			while(!st.hasMoreTokens()) {
				String s = nextLine();
				if(s==null) return false;
				eat(s);
			}
			return true;
		}
		public String next() {
			hasNext();
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}

	static FastScanner cin = new FastScanner(System.in);//快读
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));//快速输出
	
	   public static void main(String args[]) {
		 int a[]=new int [200005];
		  int n;
		 n=cin.nextInt();
		 for(int i=0;i<n;i++)a[i]=cin.nextInt();
		 Arrays.sort(a,0,n);
		 long ans=a[n-1];
		 int cnt=1;
		 for(int i=n-2;i>=1;i--) {
			 if(cnt+2<=n-1) {
			 ans+=(long)2*a[i];
			 cnt+=2;
			 }
			 else if(cnt+1<=n-1) {
				ans+=(long )a[i];
				cnt++;
			 }
			 else {
				 break;
			 }
			
			
		 }
		 out.println(ans);
		 
         out.flush();
	   }
}


Measured memory_bytes: 55816
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve(){
  int n;cin>>n;string s1,s2;cin>>s1>>s2;
  ll ans;bool flag=0;
  REP(i,s1.size()){
    if(s1[i]==s2[i]){
      if(i==0)ans=3;
      else if(flag)ans*=2;
      flag=1;
    }else{
      if(i==0)ans=6;
      else if(flag)ans*=2;
      else if(!flag)ans*=3;
      flag=0;
      i++;
    }
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

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

int numbiggerthan(int A[],int i,int n){
    int c = 1;
    for(int j = i+1;j<n;++j){
        if(A[j] < A[i]) ++c;
    }
    return c;
}

int fact(int n){
    int ans = 1;
    for(int i=2;i<=n;++i) ans*=i;
    return ans;
}

int count(int A[],int n){
    int c = 0;
    for(int i=0;i<n;++i){
        int add = numbiggerthan(A,i,n)*fact(n-i-1);
        c+=add;
    }
    return c;
}

int main() {
    int n;cin>>n;
    int A[n],B[n];
    for(int i=0;i<n;++i) cin>>A[i];
    for(int i=0;i<n;++i) cin>>B[i];
    
    int ca = count(A,n);
    int cb = count(B,n);
    cout<<abs(ca-cb);
    return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int k = 0;
            for (; k < 15; k++) {
                if ((i&(1<<k)) ^ (j&(1<<k))) break;                
            }
            cout << k+1 << ' ';
        }cout << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.streamLine();
    }

    private void streamLine() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int m = Integer.parseInt(scan.next());

            if (n > m) {
                System.out.println(0);
                return;
            }

            int[] x = IntStream.range(0, m).map(i -> Integer.parseInt(scan.next())).sorted().toArray();
            int[] dx = IntStream.range(0, m - 1).map(i -> x[i + 1] - x[i]).sorted().toArray();

            System.out.println(Arrays.stream(dx).limit((m - 1) - (n - 1)).sum());
        }
    }

    private void polygon() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int[] l = IntStream.range(0, n).map(i -> Integer.parseInt(scan.next())).toArray();
            int max = Arrays.stream(l).max().getAsInt();
            int sumWithoutMax = Arrays.stream(l).sum() - max;

            System.out.println(sumWithoutMax > max ? "Yes" : "No");
        }
    }

    private void entranceExamination() {
        try (Scanner scan = new Scanner(System.in)) {
            int t = Integer.parseInt(scan.next());
            int x = Integer.parseInt(scan.next());

            System.out.println((double) t / (double) x);
        }
    }
}


Measured memory_bytes: 48120
using System;
using System.Linq;
 
class prog{
  static void Main(){
    
    var s = new string(Console.ReadLine().OrderBy(x => x).ToArray());
    var t = new string(Console.ReadLine().OrderByDescending(x => x).ToArray());
    
    Console.WriteLine(s.CompareTo(t) == -1 ? "Yes" : "No");
  }
}

Measured memory_bytes: 11488
import re

class Num:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return str(self.x)

    def __add__(self, other):
        return Num(self.x + other.x)

    def __sub__(self, other):
        return Num(self.x - other.x)

    def __truediv__(self, other):
        return Num(int(self.x / other.x))

    def __mul__(self, other):
        return Num(self.x * other.x)

    def __neg__(self):
        return Num(-self.x)

n = int(input())
for _ in range(n):
    expr = input()[0:-1]
    expr = re.sub(r'(\d+)', r'Num(\1)', expr)
    print(eval(expr))

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

namespace Algorithm
{
    class Program
    {
        static bool[] noList;
        static long[] memo;

        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], K = line[1];

            var rem = N % K;
            Console.WriteLine(rem == 0 ? 0 : 1);

        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>

namespace ABC169
{

  class A
  {
  public:
    A() = default;
    ~A() = default;


    void Run()
    {

      int A = 0;
      int B = 0;
      std::cin >> A;
      std::cin >> B;

      std::cout << A*B << std::endl;
    }
  };

}
int main()
{

  ABC169::A prob;
  prob.Run();

  return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
using namespace std;
int i;
int main()
{
	int a,cnt;
	cin>>a;
	cnt=1;
	while (cnt<a)
	{
		cnt=cnt*2;
	}
    if (cnt>a) cout<<cnt/2;
    else
    cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			LinkedList<Integer> list = new LinkedList<>();
			IntStream.range(0, n).forEach(i -> {
				if (0 == (i & 1)) {
					// indexが偶数の場合、末尾に追加
					list.addLast(scanner.nextInt());
				} else {
					list.addFirst(scanner.nextInt());
				}
			});
			Iterator<Integer> iterator = (0 == (n & 1)) ? list.iterator() : list.descendingIterator();
			while (iterator.hasNext()) {
				System.out.print(iterator.next());
				System.out.print(iterator.hasNext() ? " " : "\n");
			}
		}
	}
}


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

using namespace std;

int main()
{
	//freopen("input14.txt","r",stdin);freopen("output14.txt","w",stdout);
	string a,b,t;
	int i,j;
	cin>>a>>b;
	int dp[a.length()+1][b.length()+1];
	for (i=0;i<a.length()+1;i++){
		for (j=0;j<b.length()+1;j++){
			if (i==0||j==0){
				dp[i][j]=0;
			}
			else{
				if (a[i-1]==b[j-1]){
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else {
					dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
				}
			}
		}
	}
	i=a.length();
	j=b.length();
	while (i>0&&j>0){
		if (a[i-1]==b[j-1]){
			t.push_back(a[i-1]);
			i--;
			j--;
		}
		else if (dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else {
			j--;
		}
	}
	for (i=t.length()-1;i>=0;i--){
		cout<<t[i];
	}
	return 0;
}

Measured memory_bytes: 35456
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

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

            final int A = fs.nextInt();
            final int B = fs.nextInt();
            final int C = fs.nextInt();
            final int X = fs.nextInt();

            int cnt = 0;

            for (int i = 0; i <= A; i++)
                for (int j = 0; j <= B; j++)
                    for (int k = 0; k <= C; k++)
                        if (500 * i + 100 * j + 50 * k == X) cnt++;

            System.out.println(cnt);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
    int N;
    cin >> N;
    long long int sum = 0;
    REP(i, 1, N) {
        if(i % 3 == 0 && i % 5 ==0) continue;
        if(i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }
    cout << sum;
return 0;
}


Measured memory_bytes: 3192
//
//	Created by shamim_nik
//

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define br printf("\n")
#define pi acos(-1)

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int N;
	cin >> N;
	int ans = N;
	while(ans % 360 != 0){
		ans += N;
	}
	cout << ans / N << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d",&a,&b,&c);

	if (0 < a&&a < b&&b < c&&c <= 100)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2136
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    priority_queue<P> pque;
    rep(i, a) {
        cin >> p[i];
        pque.push({p[i], 0});
    }
    rep(i, b) {
        cin >> q[i];
        pque.push({q[i], 1});
    }
    rep(i, c) {
        cin >> r[i];
        pque.push({r[i], 2});
    }
    int cntx = 0, cnty = 0, cntsum = 0;
    int sum = 0;
    while(!pque.empty()) {
        P p = pque.top(); pque.pop();
        int v = p.fr, j = p.sc;
        if(j == 2) {
            sum += v;
            cntsum ++;
            if(cntsum == x + y) break;
        }
        if(j == 1) {
            if(cnty < y) {
                sum += v;
                cntsum ++;
                cnty ++;
            }
            if(cntsum == x + y) break;
        }
        if(j == 0) {
            if(cntx < x) {
                sum += v;
                cntsum ++;
                cntx ++;
            }
            if(cntsum == x + y) break;
        }
    }
    cout << sum << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 12908
a = input()
if a[0] == a[1]:
    if a[0] != a[2] and a[2] == a[3]:
        print("Yes")
    else:
        print("No")
else:
    if a[0] == a[2] and a[1] == a[3]:
        print("Yes")
    elif a[0] == a[3] and a[1] == a[2]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
import itertools as ite

n = int(input())
a = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))
x = []

for i in range(n):
    for j in list(ite.combinations(a,i+1)):
        x.append(sum(j))
for i in range(q):
    flag = 0
    for j in x:
        if m[i] == j:
            print("yes")
            flag = 1
            break
    if flag == 0: print("no")




Measured memory_bytes: 58044
w,h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
a,b,c,d=0,w,0,h
for x,y,A in l:
    if A==1:
        a=max(a,x)
    elif A==2:
        b=min(b,x)
    elif A==3:
        c=max(c,y)
    else:
        d=min(d,y)
if b-a>=0 and d-c>=0:
    print((b-a)*(d-c))
else:
    print(0)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(a: int, b: int):
    c = int(str(a) + str(b))
    for i in range(400):
        if c == i*i:
            print(YES)
            break
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
def main():
    from decimal import Decimal, ROUND_DOWN

    X = Decimal(input())

    deposit = Decimal('100')
    rate = Decimal('1.01')

    cnt = 0
    while deposit < X:
        deposit = (deposit * rate).to_integral_exact(rounding=ROUND_DOWN)
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9860
class Card:
    def __init__(self, data, i):
        self.suit = data[0]
        self.value = data[1]
        self.initord = i

def BubbleSort(cards, N):
    for i in range(N):
        for j in range(N - 1, i, -1):
            if cards[j].value < cards[j - 1].value:
                cards[j], cards[j - 1] = cards[j - 1], cards[j]

def SelectionSort(cards, N):
    for i in range(N):
        min_j = i

        for j in range(i + 1, N):
            if cards[j].value < cards[min_j].value:
                min_j = j

        cards[i], cards[min_j] = cards[min_j], cards[i]

N = int(input())
cards = [Card(data, i) for i, data in enumerate(input().split())]

cards1 = cards.copy()
cards2 = cards.copy()

BubbleSort(cards1, N)
SelectionSort(cards2, N)

print(*[card.suit + card.value for card in cards1])

for i in range(N - 1):
    if cards1[i].value == cards1[i + 1].value:
        if cards1[i].initord > cards1[i + 1].initord:
            print("Not stable")
            break
else:
    print("Stable")

print(*[card.suit + card.value for card in cards2])

for i in range(N - 1):
    if cards2[i].value == cards2[i + 1].value:
        if cards2[i].initord > cards2[i + 1].initord:
            print("Not stable")
            break
else:
    print("Stable")

Measured memory_bytes: 7820
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();
	int X = sc.nextInt();
	int Y = sc.nextInt();

	int minN = X;
	int many = B;
	if(Y<X) {
	    minN = Y;
	    many = A;
	}

	int a = A*X + B*Y;
	int b = C*2*minN+(int)(Math.abs(X-Y))*many;
	int c = C*2*Math.max(X,Y);
	int result = Math.min(a,b);
	result = Math.min(result,c);
	System.out.println(result);
    }
}

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

#define int long long
#define ll long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define fro(i,j,n) for(int i = (j);i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second
const int mod = 1e9 + 7;
int add(int a,int b){
	return (a + b)%mod;
}
int sub(int a,int b){
	return add(a,mod - 1);
}
int mul(int a,int b){
	return (a*b)%mod;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    int cnt1[n] = {0};
    int cnt2[n] = {0};
    ffor(i,n){
    	int x;
    	cin >> x;
    	if(i + x < n){
    		cnt1[i + x]++;
    	}
    	if(i - x >= 0){
    		cnt2[i - x]++;
    	}
    }
    int ans = 0;
    ffor(i,n){
    	ans += (cnt1[i]*cnt2[i]);
    }
    cout << ans;
}

Measured memory_bytes: 6748
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, long long int>mp;
		vector<int>vs;
		for (int i = 0; i < N; ++i) {
			long long int a, b, c; cin >> a >> b >> c;
			mp[a] += b*c;
			if (find(vs.begin(), vs.end(), a) == vs.end())vs.emplace_back(a);
		}
		bool flag = false;
		for (auto v : vs) {
			if (mp[v] >= 1000000) {
				cout << v << endl;
				flag = true;
			}
		}
		if (!flag)cout << "NA" << endl;
	}
	return 0;
}

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

#define ll long long
#define pll pair<ll,ll> 

#define left 2*node+1
#define right left+1
#define mid (s+e>>1)

const ll N=5e5+5;
vector<ll> T[4*N];

void build(ll A[], ll node, ll s, ll e){
	if(s==e){
		T[node].push_back(A[s]);
		return;
	}
	build(A, left, s, mid);
	build(A, right, mid+1, e);
	merge(T[left].begin(), T[left].end(), T[right].begin(), T[right].end(), back_inserter(T[node]));
}

ll query(ll node,ll s, ll e, ll x, ll y){
	if(e<s || s>y || e<x)
		return 0;
	if(x<=s && e<=y){
		ll a=upper_bound(T[node].begin(), T[node].end(), y)-T[node].begin();
		return T[node].size()-a;
	}
	ll p1=query(left, s, mid, x, y);
	ll p2=query(right, 1+mid,e, x, y);
	return p1+p2;
}

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

	ll n, q;
	cin>>n>>q;
	ll A[n];
	ll B[n];
	for(ll i=0;i<n;i++)
		cin>>A[i];
	map<ll,ll> M;
	for(ll i=n-1;i>=0;i--){
		if(M.count(A[i]))
			B[i]=M[A[i]];
		else
			B[i]=INT_MAX;
		M[A[i]]=i;
	}

	build(B,0,0, n-1);

	while(q--){
		ll x, y;
		cin>>x>>y;
		ll ans=query(0,0,n-1,x-1,y-1);
		cout<<ans<<"\n";
	}
	
}


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

struct Node {
    string name;
    int id, score;
    bool operator < (const Node & a) {
        if (name == a.name) return score > a.score;
        else return name < a.name;
    }
};

int main(void) {
    Node input[105];
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        cin >> input[i].name >> input[i].score;
        input[i].id = i;
    }
    sort(input + 1, input + n + 1);
    for (int i = 1; i <= n; i++) {
        printf("%d\n", input[i].id);
    }

    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
	if a < b:
		a, b = b, a
	while a % b != 0:
		a, b = b, a % b
	return b
 
# 最大公約数 
def lcm(a, b):
	y = a*b / gcd(a, b)
	return int(y)

def primes_for(n):
  is_prime = [True] * (n + 1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, n + 1):
      for j in range(i * 2, n + 1, i):
          is_prime[j] = False
  return [i for i in range(n + 1) if is_prime[i]]

# O(√A)
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True

# 回文 S[::-1]

S = input()
R = S[::-1]
count = 0
# print(R)
for i in range(len(S)):
  if S[i] != R[i]:
    count += 1
print(count//2)



Measured memory_bytes: 5264
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	string s;
	cin >> s;
	string t = "CODEFESTIVAL2016";
	int ans = 0;
	rep(i, s.size()){
		if(s[i] != t[i])ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long



signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,k;
 cin>>n>>k;
 int ar[n+1];
 for(int i=1;i<=n;i++)
 {
      cin>>ar[i];
 }
 int dp[100005];
 dp[0]=1;
 for(int i=1;i<=1e5;i++)
 {
      for(int j=1;j<=n;j++)
      {
           if(i-ar[j]>=0){
           dp[i]=1^dp[i-ar[j]];
           if(!dp[i])
           break;
           }
           else{
           dp[i]=1;
           }
      }
 }
 if(dp[k]==0){
 cout<<"First";
 }
 else{
 cout<<"Second";
 }
 
}

Measured memory_bytes: 1024
//SOURCE: GEEKSFORGEEKS

#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
#define int long long
typedef long long ll; 
const int mod = 1000000007; 
  
int prime[MAX]; 
unordered_map<int, int> max_map; 
  



int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
 
int inv (int arg, int mod)
{
    return power(arg, mod-2);
} 

void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  

ll lcmModuloM(const int* ar, int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
        while (num > 1) { 
  
            int factor = prime[num]; 

            temp[factor]++; 
  
            num /= factor; 
        } 
  
        for (auto it : temp) { 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
} 
  

signed main() 
{ 
    sieve();
    int n; cin>>n;
    int arr[n];

    for (int i=0; i<n; i++) cin>>arr[i];

    int val = lcmModuloM(arr, n); 

    int sum(0);

    for (int i=0; i<n; i++)
    {
        sum+=(val*power(arr[i],mod-2))%mod;
        sum%=mod;
    }
    
    cout<<sum<<endl;

    return 0; 
} 


Measured memory_bytes: 78848
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
    int N;
    cin >> N;
    string S;
    vector<string> vec = { "A" };
    for (int i = 0; i < N; i++) {
        cin >> S;
        for (int j = 0; j < vec.size(); j++) {
            if (vec.at(j) == S) {
                break;
            }
            else if (vec.at(j) != S && j + 1 < vec.size()) {
                continue;
            }
            else if (vec.at(j) != S && j + 1 == vec.size()) {
                vec.push_back(S);
            }
        }
    }
    debug(vec.size());
    for (int j = 0; j < vec.size(); j++){
        debug(vec[j]);
    }
    
    vec.pop_back();
    if (vec.size() == 3) {
        cout << "Three" << endl;
    }
    else if (vec.size() == 4) {
        cout << "Four" << endl;
    }
}

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

int main() {
    //input
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    int sum = 0;
    for(int i=0;i<n-1;i++){
        sum += l.at(i);
    }
    if(l.at(n-1) < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
const int mod=1e9+7;
int32_t main()
{
	int n=in();int m=in();
	if(abs(m-n)>1){cout<<0;return 0;}
	
	int nf=1;for(int i=1;i<=n;i++){nf*=i;nf%=mod;}
	int mf=1;for(int i=1;i<=m;i++){mf*=i;mf%=mod;}
	if(n==m){nf*=2;nf%=mod;}
	cout<<(nf*mf)%mod;
	
	
}

Measured memory_bytes: 3732
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;
import std.typecons;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

void main() {
	auto k = readNums!ulong()[1];
	const masks = readNums!ulong();
	auto bitValues = iota(0, ulong.sizeof * 8).map!((i) {
		auto b = 1UL << i;
		auto bitCount = masks.count!((m) => !!(m & b));
		auto up = cast(long)((masks.length - bitCount) * b);
		auto down = cast(long)(bitCount * b);
		return tuple(b, up - down);
	})
	.filter!((b) => (b[0] <= k) && (b[1] >= 0)).array;
	
	ulong maxX = 0;
	ulong maxSum = 0;
	foreach(ref v; bitValues) {
		if(k & v[0]) {
			maxX |= v[0];
			maxSum += v[1];
		}
	}

	for(size_t i = 0; ; ++i) {
		immutable b = 1UL << i;
		if(b > k) {
			break;
		}
		if(!(k & b)) {
			continue;
		}
		immutable mask = (k >>> (i + 1)) << (i + 1) | (b - 1);
		ulong x = 0;
		ulong s = 0;
		foreach(ref v; bitValues) {
			if(v[0] & mask) {
				x |= v[0];
				s += v[1];
			}
		}
		if(s > maxSum) {
			maxX = x;
			maxSum = s;
		}
	}
	writefln("%s", masks.map!((m) => m ^ maxX).sum);
}


Measured memory_bytes: 4860
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
   public static void main(String[] args) throws Exception {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String[] head = br.readLine().split(" ");
       String[] pdata = br.readLine().split(" ");
       String[] qdata = br.readLine().split(" ");
       String[] rdata = br.readLine().split(" ");
       br.close();
       long sum = 0;
       int x = Integer.parseInt(head[0]);
       int y = Integer.parseInt(head[1]);
       int a = Integer.parseInt(head[2]);
       int b = Integer.parseInt(head[3]);
       int c = Integer.parseInt(head[4]);
       
       long[] p = new long[a];
       for(int i = 0; i < a; i++){
           p[i] = Long.parseLong(pdata[i]);
       }

       long[] q = new long[b];
       for(int i = 0; i < b; i++){
           q[i] = Long.parseLong(qdata[i]);
       }

       long[] r = new long[c];
       for(int i = 0; i < c; i++){
           r[i] = Long.parseLong(rdata[i]);
       }

       int pidx = 0;
       int qidx = 0;
       int ridx = r.length - 1;

       Arrays.sort(p);
       Arrays.sort(q);
       Arrays.sort(r);
       p = Arrays.copyOfRange(p, a - x, a);
       q = Arrays.copyOfRange(q, b - y, b);

       sum += Arrays.stream(p).sum();
       sum += Arrays.stream(q).sum();
       
       while(ridx >= 0){
           if(pidx >= p.length && qidx >= q.length) {
               break;
           }
           long p_val = (pidx < p.length) ? p[pidx] : Long.MAX_VALUE;
           long q_val = (qidx < q.length) ? q[qidx] : Long.MAX_VALUE;
           if(p_val < q_val){
               if(r[ridx] > p_val){
                   sum = sum - p[pidx] + r[ridx];
                   ridx--;
                   pidx++;
               } else {
                   break;
               }
           } else {
            if(r[ridx] > q_val){
                sum = sum - q[qidx] + r[ridx];
                ridx--;
                qidx++;
            } else {
                break;
            }
           }
       }
       System.out.println(sum);
   } 
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli h,w;
	cin>>h>>w;

	lli data[60][60];

	REP(i,0,h)REP(j,0,w){
		char tmp;
		cin>>tmp;
		if(tmp=='#')data[i][j]=1;
		else data[i][j]=0;
	}

	REP(i,0,h){
		REP(j,0,w){
			if(data[i][j]==0)continue;

			lli di[4]={-1,0,1,0};
			lli dj[4]={0,1,0,-1};
			bool ok = false;
			REP(k,0,4){
				lli ni = i+di[k];
				lli nj = j+dj[k];
				if(ni<0 || ni>=h || nj<0 || nj>=w)continue;
				if(data[ni][nj])ok=true;
			}

			if(!ok){
				cout<<"No"<<endl;
				return 0;
			}

		}
	}

	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 5000
#define MOD 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	long long x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	long long tozero = x/d;
	if(tozero>=k)
		cout<<x-d*k<<endl;
	else if(x%d==0)
	{
		k -= tozero;
		if(k&1)
			cout<<d<<endl;
		else
			cout<<0<<endl;
	}
	else
	{
		k -= tozero;
		if(k&1)
			cout<<abs(x-d*++tozero)<<endl;
		else
			cout<<x-d*tozero<<endl;
	}
	return 0;
}

Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  len_, err := IntStdin()
  
  numbers, error := SplitIntStdin(" ")
  if error != nil {
   return
  }
  
  if err != nil {
    return
  }
  
  if len(numbers) != len_ {
    return
  }
  
  last := 0
  
  for {
    for _, num := range numbers {
      if (num % 2) == 1 {
        fmt.Println(last)
        return
      }
    }
  
    for index, num := range numbers {
      numbers[index] = num / 2
    }
    
    last += 1
  }
}

Measured memory_bytes: 640
N, M = map(int, input().split())
inf = float("inf")
dp = [[inf]*N for _ in [0]*N]
for i in range(N):dp[i][i] = 0
d = [list(map(int, input().split())) for i in range(M)]
ans = 0
from scipy.sparse.csgraph import floyd_warshall 
for a,b,c in d:
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
cost = floyd_warshall(dp)
for a,b,c in d:
        if cost[a-1][b-1] != c:
            ans += 1
print(ans)


Measured memory_bytes: 17496
n = int(input())
a = list(map(int, input().split()))
# dp[i][j] - the minimum total cost of combining interval [i,j] into one vertex
dp = [[float('inf')] * n for _ in range(n)]
s = [0] * (n + 1)
for i in range(n):
    s[i + 1] += s[i] + a[i]
for L in range(n - 1, -1, -1):
    for R in range(L, n):
        if L == R:
            dp[L][R] = 0
        else:
            for i in range(L, R):
                dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + s[R + 1] - s[L])
print(dp[0][n - 1])

Measured memory_bytes: 46556
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
ks=n3(m)
p=n1()

import itertools
ite=itertools.product([0,1],repeat=n)
ans=0
for line in ite:
    for i in range(m):
        c=0
        light=ks[i][1:]
        for j in light:
            c+=line[j-1]
        if c%2!=p[i]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3316
n,m = map(int, input().split())

re = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int, input().split())
  re[a].append(b)
  re[b].append(a)
  
reach = [0]*(n+1)
reach[1] = 1
for i in re[1]:
  if reach[i] == 0:
    for j in re[i]:
      reach[j] = 1

if reach[n] == 1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 43140
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long X, long long Y, long long Z){
    cout << (X - Z) / (Y + Z) << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
N = int(input())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

A_1 = A_list[0]-1
ans = B_list[A_1]
for i in range(1, N):
    A = A_list[i]-1
    ans += B_list[A]
    if A_1 < N-1:
        if A == A_1+1:
            ans += C_list[A_1]
    A_1 = A
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

bool canBeMonth(int i) { return 1 <= i && i <= 12; }

int main() {
  string s;
  cin >> s;
  int a = atoi(s.substr(0, 2).c_str());
  int b = atoi(s.substr(2, 2).c_str());
  if (canBeMonth(a)) {
    if (canBeMonth(b)) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  } else {
    if (canBeMonth(b)) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

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

int main(){
	int n, m;
	string u;
	set<string> st;
	
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> u;
		st.insert(u);
	}

	cin >> m;
	bool f = false;
	for(int i = 0; i < m; ++i){
		cin >> u;
		if( st.find(u) == st.end() ){
			cout << "Unknown ";
		}
		else if( f ){
			f = false;
			cout << "Closed by ";
		}
		else{
			f = true;
			cout << "Opened by ";
		}
		cout << u << '\n';
	}
}

Measured memory_bytes: 1224