akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
P = 10**9 + 7
N = 1000001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
lcm=[0]*(max(a)+2)
for i in range(n):
  k=a[i]
  for j in range(1,int(a[i]**0.5)+1):
    cnt=0
    while k%(j+1)==0:
      k//=j+1
      cnt+=1
    lcm[j+1]=max(cnt,lcm[j+1])
  lcm[k]=max(1,lcm[k])
lcmn=1
for i in range(len(lcm)):
  if lcm[i]>0:
    lcmn*=i**lcm[i]%mod
lcmn%=mod
ans=0
for i in range(n):
  ans+=lcmn*inv[a[i]]%mod
print(ans%mod)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> str(H);
  
  for (int i = 0; i < W + 1; i++) {
    cout << '#';
    
    if (i == W)
      cout << '#' << endl;
   }
   
  
  for (int i = 0; i < H; i++) {
    cin >> str.at(i);
   }
  
  for (int i = 0; i < H; i++) {
    cout << '#' << str.at(i) << '#' << endl;
   }
  
   for (int i = 0; i < W + 1; i++) {
    cout << '#';
    
    if (i == W)
      cout << '#' << endl;
   }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	set<int> s;
	for (int i = 1; i <= n; i++) {
		s.insert(i);
	}
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			s.erase(a);
		}
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int X, Y;
    cin >> X >> Y;

    if (Y % 2 != 0) {
        cout << "No";
        return 0;
    }

    int i;
    for (i = 0; i <= X; i++) {
        if (2 * i + 4 * (X - i) == Y) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    return 0;
}

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

int main(){
  int n, m;
  cin>>n>>m;
  int A[100][100];
  int b[100];
  int c[100];
  for(int i=0;i<n;i++){
     for(int j=0;j<m;j++){ cin>>A[i][j];
     }
  }
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=0;i<n;i++){
     for(int j=0;j<m;j++){
          c[i] += A[i][j] * b[j];
      }
   }
   for(int i=0;i<n;i++) cout<<c[i]<<endl;

   return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 10010010010
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


 

int main(){
    int n; cin >> n;
    priority_queue<double, vector<double>, greater<double>> que;
    
    rep(i, n){
        double a; cin >> a;
        que.push(a);
    }
    
    
 
    
    while (que.size() != 1) {
        double a,b;
        a = que.top();
        que.pop();
        b = que.top();
        que.pop();
    
        que.push((a+b)/2.0);
        
    }
    double ans = que.top();
    
    cout << setprecision(16) << ans << endl;
    
    
    
    


}


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

int main()
{
    int i;
    for (i = 0; i < 5; ++i)
    {
        ll x;
        cin >> x;

        if (x == 0)
            break;
    }

    cout << i + 1 << endl;

    return 0;
}

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

int main() {
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int z = 0;z<M;z++){
        cin >> B.at(z);
    }

    vector<vector<int>> code(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> code.at(i).at(j);
    }
    }
    int sum = 0;
    int ans = 0;

    for(int k=0;k<N;k++){
        for(int l=0;l<M;l++){
            sum = sum + code.at(k).at(l)*B.at(l);
        }
      	//cout << sum << endl;
        sum = sum + C;
        if(sum > 0){
            ans++;
        }
      	sum = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import math

def comb(n, r, mod):
    return math.factorial(n + r - 1)//(math.factorial(n - 1)*math.factorial(r))%mod

n, k = map(int, input().split())
mod = 10**9 + 7
red = n - k

for i in range(k):
    if red - i < 0:
        print(0)
        continue
    ans = comb(2 + i, red - i, mod)*comb(i + 1, k - i - 1, mod)
    print(ans%mod)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 1000000007;

using Node = struct N{
    ll id;
    set<ll> connected;
};


int main() {
    ll n,m;
    cin >> n >> m;
    vector<Node> friends(n,{0,set<ll>()});
    for(ll i = 0;i < n;++i){
        friends[i].id = i;
    }

    for(ll i = 0;i < m;++i){
        ll a,b;
        cin >> a >> b;
        --a;
        --b;
        friends[a].connected.insert(b);
        friends[b].connected.insert(a);
    }

    vector<bool> counted(n,false);
    ll maxf = 0;
    for(ll i = 0;i < n;++i){
        if(counted[i])continue;
        ll frcnt = 1;
        set<ll> nows;
        nows.insert(i);
        counted[i] = true;
        while (nows.size() > 0){
            set<ll> nexts;
            for(auto itr = nows.begin();itr != nows.end();++itr){
                for(auto itr2 = friends[*itr].connected.begin();itr2 != friends[*itr].connected.end();++itr2){
                    ll fi = *itr2;
                    if(counted[fi])continue;
                    ++frcnt;
                    nexts.insert(fi);
                    counted[fi] = true;
                }
            }
            nows = nexts;
        }
       // cout << frcnt << endl;
        if(maxf < frcnt)maxf = frcnt;
    }
    cout << maxf << endl;

}




Measured memory_bytes: 32104
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
const Int MAX = 2020;
Int dpL[MAX][MAX]={};
Int dpR[MAX][MAX]={};
Int dpU[MAX][MAX]={};
Int dpD[MAX][MAX]={};

signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];

  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(st[i][j]=='#') continue;
      dpL[i][j]=(j?dpL[i][j-1]:0)+1;
      dpU[i][j]=(i?dpU[i-1][j]:0)+1;
    }
  }
  for(Int i=h-1;i>=0;i--){
    for(Int j=w-1;j>=0;j--){
      if(st[i][j]=='#') continue;
      dpR[i][j]=(j+1<w?dpR[i][j+1]:0)+1;
      dpD[i][j]=(i+1<h?dpD[i+1][j]:0)+1;
    }
  }

  Int ans=0;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      if(st[i][j]=='.')
        chmax(ans,dpL[i][j]+dpR[i][j]+dpU[i][j]+dpD[i][j]-3);

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 131712
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
	   		BufferedReader br = createBufferedReader();
	   		int n = Integer.parseInt(br.readLine());
	        String str = br.readLine();
	       	System.out.println(rot(n, str));
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	private static String rot(final int n, final String str) {
		String res = "";
		for (int i = 0; i < str.length(); i++) {
			char c = (char)((str.charAt(i) + n - 'A') % 26 + 'A');
			res = res + String.valueOf(c);
		}
		return res;
	}

	// 以下問題問わずに共通部分
	// 標準入力の BufferedReader を返す.
	private static BufferedReader createBufferedReader() {
		InputStreamReader isr =new InputStreamReader(System.in);
	   	return new BufferedReader(isr);
	}
}


Measured memory_bytes: 145492
using System;
using System.Linq;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            while(true){
                var n = int.Parse(Console.ReadLine());
                if(n == 0) break;

                var dp = new int[n, n];
                for(var i = 0; i < n; i++){
                    for(var j = 0; j < n; j++){
                        dp[i, j] = int.MinValue;
                    }
                }

                for(var i = 0; i < n; i++){
                    dp[0, i] = int.Parse(Console.ReadLine());
                }

                for(var i = 1; i < n; i++){
                    dp[1, i] = dp[0, i - 1] + dp[0, i];
                }

                for(var i = 2; i <= n; i++){
                    for(var j = i; j < n; j++){
                        dp[i, j] = dp[i - 1, j - 1] + dp[i - 1, j] - dp[i - 2, j - 1];
                    }
                }

                Console.WriteLine(dp.Cast<int>().Max());
            }
        }
    }
}

Measured memory_bytes: 69196
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}


int main(){
    string s; cin >> s;
    int n = s.length();

    int ans1 = 0;
    int ans2 = 0;

    rep(i,n){
        if(s[i]-'0' != (i%2)) ans1++;
        if(s[i]-'0' != ((i+1)%2)) ans2++;
    }
    //cout << ans1 << ans2 << endl;
    cout << min(ans1,ans2) << endl;

}



Measured memory_bytes: 512
program main
Implicit None
	integer(8)::n,i,j,t,f,e,k
	integer(8),allocatable::p(:),x(:)
	character(len = 10),allocatable::s(:)
	character(len =10)::tmp
	
	read*,n
	allocate(s(n),p(n),x(n))
	
	do i = 1,n
		read*,s(i),p(i)
		x(i) = i
	enddo
	
	do i = 1,n-1
		do j = 2,n
			if(s(j) < s(j-1))then
				tmp = s(j) ;t = p(j) ;k = x(j)
				s(j) = s(j-1) ;p(j) = p(j-1) ;x(j) = x(j-1)
				s(j-1) = tmp ;p(j-1) = t ;x(j-1) = k
			endif
		enddo
	enddo
	
	f = 1
	do i = 1,n-1
		if(s(i) /= s(i+1))then
			e = i
			if(e/=f) call h2(p(f:e),x(f:e),e-f+1)
			x(f:e) = x(e:f:-1)
			f = e+1
		endif
	enddo
	
	if(f /= n)then
		e = n
		if(e/=f) call h2(p(f:e),x(f:e),e-f+1)
		x(f:e) = x(e:f:-1)
	endif
	
	do i = 1,n
		print"(i0)",x(i)
	enddo
end program main

subroutine h2(a,b,n)
implicit None
	integer(8)::a(n),b(n),x,y
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);y = b(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie);y = b(ie)
		a(ie) = a(1);b(ie) = b(1)
		a(1) = x;b(1) = y
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				b(i0) = b(i1);b(i1) = y
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h2

Measured memory_bytes: 640
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<pair<int64_t, bool>>> A(N);
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    for (int64_t j = 0; j < a; ++j) {
      int64_t x, y;
      cin >> x >> y;
      A[i].emplace_back(x - 1, (y == 1));
    }
  }
  int64_t result = 0;
  for (int64_t b = 0; b < (1L << N); ++b) {
    bitset<15> bs(b);
    bool is_okay = true;
    for (int64_t i = 0; i < N; ++i) {
      // cerr << b << ", " << i << " " << __LINE__ << endl;
      if (bs[i]) {
        for (auto p : A[i]) {
          if (p.second) {
            if (!bs[p.first]) {
              is_okay = false;
            }
          } else {
            if (bs[p.first]) {
              is_okay = false;
            }
          }
        }
      }
      if (!is_okay) {
        break;
      }
    }
    if (is_okay) {
      result = max(result, static_cast<int64_t>(bs.count()));
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long a, b, c;

	std::cin >> a >> b >> c;

	a -= c;

	std::cout << a / (b + c) << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <set>
#include <queue>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
	int n; scanf("%d", &n);
	int cm = 100 / 4;
	int dm = 100 / 7;
	for (int i = 0; i < cm; i++) {
		for (int j = 0; j < dm; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.math.abs
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n, A, B, C = in.nextInt
  val ls = Array.fill(n)(in.nextInt)

  def dfs(i: Int, a: Int, b: Int, c: Int): Int = {
    if (i == n) {
      if (a == 0 || b == 0 || c == 0) 100000000
      else abs(A - a) + abs(B - b) + abs(C -c) - 30
    } else {
      Array(
        dfs(i + 1, ls(i) + a, b, c) + 10,
        dfs(i + 1, a, ls(i) + b, c) + 10,
        dfs(i + 1, a, b, ls(i) + c) + 10,
        dfs(i + 1, a, b, c)).min
    }
  }

  println(dfs(0, 0, 0, 0))
}

Measured memory_bytes: 32912
N, K, Q = map(int, input().split())

A = [ int(input()) for i in range(Q)]

user = {i+1:0 for i in range(N)}

for aa in A:
    user[aa] += 1





for key,v in user.items():
    #非正当率がＫ以上なら
    if K-(Q-v) <= 0 :
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 61916
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define PI (3.1415926535)
#define EPS (1e-10)

int main(){
  int d;
  while(cin>>d){
    int ans = 0;
    for(int i = d; i<600; i+=d){
      ans += d * i * i;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<string, int> cnt;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    cout << "AC" << " x " << cnt["AC"] << '\n';
    cout << "WA" << " x " << cnt["WA"] << '\n';
    cout << "TLE" << " x " << cnt["TLE"] << '\n';
    cout << "RE" << " x " << cnt["RE"] << '\n';
    return 0;
}


Measured memory_bytes: 3620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class B754 {
public:
    void solve(istream& cin, ostream& cout) {
        string s;
        cin >> s;
        int n= s.length();
        int ans = INT_MAX;
        for(int i=0; i+2<n; i++) {
            string c;
            for(int j=0; j<3; j++) {
                c.push_back(s[i+j]);
            }
            int a = stoi(c);
            ans = min(ans, abs(753 - a));
        }
        cout << ans << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    B754 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> vec(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
      for (int j = 0; j < D; j++) {
          cin >> vec[i][j];
      }
  }
  
  int cnt = 0;
  for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
          int sum = 0;
          for (int k = 0; k < D; k++){
            sum += pow(vec[i][k] - vec[j][k], 2);
          }
         for (int l = 0; l * l <= sum; l++) {
             if (sum == l * l) cnt++;
         }
      }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int d = b / a;
	if (d >= c) {
		cout << c;
	}
	else {
		cout << d;
	}
	return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) *number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	ll tmp, ans = 1;
	rep(i, n) {
		scanf("%lld", &tmp);
		ans = lcm(ans, tmp);
	}
	printf("%lld\n", ans);
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	string s,t; cin>>s>>t;
	for (int i=0; i<n; i++)
		cout<<s[i]<<t[i];
	cout<<endl;
	return 0;
}

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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        sc.close();

        int bb = (Y - 2 * X);
        if (bb % 2 != 0 || bb < 0) {
            System.out.println("No");
            return;
        }

        int b = bb / 2;
        int a = X - b;

        if (a >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        return;
    }
}


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

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

  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int64_t ans = 0;
  for(int i=0;i<100000;i++){
    int64_t a = upper_bound(A.begin(), A.end(), i+1) - lower_bound(A.begin(), A.end(), i-1);
    ans = max(ans, a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#include <stack>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

VI to[5];
int vis[5];

void dfs(int x,int fa){
    vis[x]=1;
    rvc(i,to[x])if(to[x][i]!=fa){
        dfs(to[x][i],x);
        break;
    }
}

int main(){
    rep(i,1,3){
        int a,b;
        cin>>a>>b;
        to[a].pb(b);
        to[b].pb(a);
    }
    rep(i,1,4)if(to[i].size()==1){
        dfs(i,0);
        break;
    }
    rep(i,1,4)if(!vis[i]){
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define pp pair<int,int>
#define N 200007 // check
#define M 5007
#define K 61
#define endl "\n"
using namespace std;

int n, m;
int w[N];
int mod = 1e9+7;
int pref[N];
int sil = 1;

int potx(int x, int y) {
    if(y == 0) return 1;
    if(y == 1) return x;
    if(y & 1) return x*potx(x,y-1)% mod;
    int k = potx(x,y/2);
    return k*k%mod;
}

int inv(int x) {
    return potx(x,mod-2);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> w[i];
    for(int i = 1; i <= n; ++i) {
        sil *= i; sil %= mod;
    }
    pref[0] = pref[1] = 0;
    pref[2] = sil*inv(2) % mod;
    for(int i = 3; i <= n; ++i) {
        int cur = sil*inv(i) % mod;
        pref[i] = (pref[i-1] +  cur) % mod;
    }

    int ans = 0;

    for(int i = 0; i < n; ++i) {
        int ile = (sil + pref[i+1] + pref[n-i]) % mod;
        ans += ile*w[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
n, k=map(int,input().split())
h=[0]*n
for i in range(n):
    h[i]=int(input())

def quicksort(a, left: int, right: int):
    #a[left]〜a[right]をクイックソート
    pl=left
    pr=right
    pivot= a[(left +right)//2]

    #print(f'a[{left}]~a[{right}] : ', *a[left : right +1])

    while pl<=pr:
        while a[pl] <pivot: pl+=1
        while a[pr] >pivot: pr-=1
        if pl <= pr:
            a[pl], a[pr]= a[pr], a[pl]
            pl+=1
            pr-=1

    if left < pr: quicksort(a, left, pr)
    if pl < right: quicksort(a, pl, right)

def quick_sort(a):
    quicksort(a, 0, len(a)-1)
mn=10**9
quick_sort(h)
for i in range(n-k+1):
    dif=h[i+k-1]-h[i]
    if dif<mn:
        mn=dif

print(mn)


Measured memory_bytes: 12768
#include "bits/stdc++.h"
using namespace std;
int main() {
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 40

int n,pos=0;
int cout = 0;
int Pre[MAX] ,In[MAX] ,final[MAX];

int distance(int first,int key){
  int i,count=0;

  for(i = first; i < MAX;i++){
    if(In[i] != key)
      count++;
    else break;
  }

  return count;
}


int solve(int l,int r){

  int root,d;
  if(l-r >= 0)return -1;

  root=Pre[pos];
  pos++;

  d=distance(0,root);
  if(d > n)return -1;

  solve(l, d);
  solve(d+1,r);

  final[cout++]=root;
  return 0;
}

int main(){
  int m,i;
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&m);
    Pre[i]=m;
  }

  for(i = 0;i < n;i++){
      scanf("%d",&m);
      In[i]=m;
  }
  solve(0,n);

  printf("%d",final[0]);

  for(i = 1;i < n;i++)
    printf(" %d",final[i]);
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int a; cin >> a;
    if(a%2==0 && a%3!=0 && a%5!=0){
      cout<< "DENIED"<<endl;
      return 0;

    }
  }
  cout<< "APPROVED" <<endl;

}


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

using namespace std;

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

        int n, tot = 0;
        cin >> n;
        map<string, int> prefix;
        for (int i = 0; i < n; i++)
        {
                int val;
                string s;
                cin >> s >> val;
                tot += val;
                prefix[s] = tot;
        }
        string s;
        cin >> s;
        cout << tot - prefix[s] << "\n";
}


Measured memory_bytes: 256
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input!{
        n: u32,
        a: [usize; n-1]
    };
    
    let mut v = vec![0; 200000];

    for i in 0..a.len() {
        v[a[i]-1] += 1;
    }

    for i in 0..a.len()+1 {
        println!("{}", v[i]);
    }
}


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


int main(){

    int N;
    int a[100000];
    cin >> N;
    for( int i = 0; i < N; i++ ) cin >> a[i];


    int ans = 0;
    for( int i = 0; i < N; i++ ) ans += a[i] - 1;
    
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
class DisjointSet:
    def __init__(self, n):
        self.parent = {i: -1 for i in range(n)}

    def root(self, a):
        if self.parent[a] < 0:
            return a
        self.parent[a] = self.root(self.parent[a])
        return self.parent[a]

    def size(self, a):
        return -self.parent[self.root(a)]

    def link(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return False

        if self.size(a) < self.size(b):
            a, b = b, a

        self.parent[a] += self.parent[b]
        self.parent[b] = a

        return True

N, M = map(int, input().split())
A = []
B = []
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    A.append(a)
    B.append(b)

ds = DisjointSet(N)
ans = {M - 1: int(N * (N - 1) / 2)}
# M-1 >= i >= 1
for i in range(M - 1, 0, -1):
    ans[i - 1] = ans[i]
    if ds.root(A[i]) != ds.root(B[i]):
        ans[i - 1] -= ds.size(A[i]) * ds.size(B[i])
        ds.link(A[i], B[i])

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


Measured memory_bytes: 38200
#include <stdio.h>


int number_of_str(const char c[]){

        int n = 0;
    
        for(int i=0;c[i] != '\0';i++){
                n++;
        }   
return n;
}


int main(void){

        int judge = 0;
        char c[1000];

        scanf("%s",c);

        int n = number_of_str(c);


for(int i=0;i<n-1;i++){
        if(c[i] == 'A' && c[i+1] == 'C'){
                printf("Yes\n");
                judge = 1;
                break;
        }   
}

if(judge != 1){ 
        printf("No\n");
}

return 0;
}



Measured memory_bytes: 128
#include <stdio.h>


int main(){

	int a = 0, b = 0,i,buf;

	for (i = 0; 4 > i; i++){
		scanf("%d", &buf);
		a += buf;
	}
	for (i = 0; 4 > i; i++){
		scanf("%d", &buf);
		b += buf;
	}
	printf("%d\n", a > b ? a : b);
return 0;
}

Measured memory_bytes: 1020
import numpy as np
n,m=map(int, input().split())
AC=[0]*(n+1)
WA=[0]*(n+1)
for _ in range(m):
   p,s=input().split()
   if s=='AC':
        AC[int(p)]=1
   elif s=='WA' and AC[int(p)]==0:
        WA[int(p)] +=1
        
ACn=np.array(AC)
WAp=np.array(WA)

print(sum(AC),sum(ACn*WAp))

Measured memory_bytes: 30552
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		boolean al = false;
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			if(al) {
				System.out.println();
			}
			else {
				al = true;
			}
			
			PriorityQueue<Pair> que = new PriorityQueue<Pair>(10,new MyComparator());
			for(int i = 0; i < n; i++) {
				String a = stdIn.next();
				int w = stdIn.nextInt();
				int l = stdIn.nextInt();
				int d = stdIn.nextInt();
				que.add(new Pair(a,w*3 + d,i));
			}
			
			for(int i = 0; i < n; i++) {
				Pair tmp = que.poll();
				System.out.println(tmp.getId() +"," + tmp.getPoint());
			}
		}
	}
}

class Pair {
	private String id;
	private int point;
	private int number;
	public Pair(String id, int point,int number) {
		this.id = id;
		this.point = point;
		this.number = number;
	}
	public String getId() {
		return id;
	}
	public int getPoint() {
		return point;
	}
	public int getNumber() {
		return number;
	}
}
class MyComparator implements Comparator<Pair>{

	public int compare(Pair o1, Pair o2) {
		if(o1.getPoint() < o2.getPoint()) {
			return 1;
		}
		else if(o1.getPoint() > o2.getPoint()) {
			return -1;
		}
		else if(o1.getNumber() < o2.getNumber()){
			return -1;
		}
		else if(o1.getNumber() > o2.getNumber()){
			return 1;
		}
		return 0;
	}
	
}

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

int main(){
	int i, f = 0;
	string s;
	cin >> s;
	for(i = 0; i < s.size(); i++){
		if(f == 0){
			if(s[i] == 'C'){
				f = 1;
			}
		}
		else if(f == 1){
			if(s[i] == 'F'){
				f = 2;
			}
		}
	}
	if(f == 2){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

class Node {
public:
	int location;
	int p, l, r;
	//Node() {}
};

class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) :id(id), x(x), y(y) {}
	bool operator<(const Point&p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 500000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;
Point ans[MAX];
int NANS;

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}

bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}

int makeKDTree(int p, int l, int r, int depth) {
	if (l == r) {
		return NIL;
	}
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].p = p;
	T[t].l = makeKDTree(t, l, mid, depth + 1);
	T[t].r = makeKDTree(t, mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans[NANS++] = P[T[v].location];
	}

	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1);
		}
		if (T[v].r != NIL) {
			if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1);
		}
	}
	else {
		if (T[v].l != NIL) {
			if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1);
			int prevX = P[T[T[v].p].location].x;
			//if (sy <= y && sx <= prevX) find(T[v].l, sx, tx, sy, ty, depth + 1);
		}
		if (T[v].r != NIL) {
			if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1);
			//if (y <= ty && x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1);
		}
	}
}

int main() {
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].p = T[i].l = T[i].r = NIL;
	}

	np = 0;

	int root = makeKDTree(NIL, 0, N, 0);

	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		NANS = 0;
		find(root, sx, tx, sy, ty, 0);
		sort(ans, ans + NANS);
		for (int j = 0; j < NANS; j++) {
			ans[j].print();
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 16308
N = int(input())
X_list = list(map(int, input().split()))
Y_list = X_list.copy()
Y_list.sort()
for i in range(N):
	if X_list[i] < Y_list[int(N/2)]:
		print(Y_list[int(N/2)])
	else:
		print(Y_list[int(N/2) - 1])

Measured memory_bytes: 26772
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long
using namespace std;

ll n, k, res = 0;
const ll mod = 1e9 + 7;

ll binpow(ll fa, ll fn) {
    if(fn == 1) return fa;
    if(fn & 1) return fa * binpow(fa, fn - 1) % mod;
    ll fx = binpow(fa, fn / 2) % mod;
    return fx * fx % mod;
}

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

    cin >> n >> k;

    if(k - 1 == n) {
        cout << 1 << "\n";
        return 0;
    }

    for(ll i = k; i <= n + 1; ++i) {
        int x = (n * (n + 1) % mod - (i - 1) * i % mod - (n - i) * (n - i + 1) % mod) * binpow(2, mod - 2) % mod;
        x++;
        x = (x % mod + mod) % mod;
        res = ((res + x) % mod + mod) % mod;
    }

    cout << res % mod << "\n";

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

struct card {
    char type;
    int value;
};


void print_data(card data[], int N) {
    cout << data[0].type << data[0].value;
    for (int i = 1; i < N; i++) cout << " " << data[i].type << data[i].value;
    cout << endl;
}

int bubble_sort(card data[], int N) {
    int swap_count = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int i = N - 1; i > 0; i--) {
            if (data[i].value < data[i-1].value) {
                swap(data[i], data[i-1]);
                swap_count++;
                flag = true;
            }
        }
    }
    return swap_count;
}

int selection_sort(card data[], int N) {
    int swap_count = 0;

    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (data[j].value < data[minj].value) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(data[i], data[minj]);
            swap_count++;
        }
    }

    return swap_count;
}

bool is_stable(card data1[], card data2[], int N) {
    for (int i = 0; i < N; i++) {
        if (data1[i].type != data2[i].type) {
            return false;
        }
    }
    return true;
}

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

    card data1[N];
    card data2[N];
    
    for (int i = 0; i < N; i++) {
        cin >> data1[i].type >> data1[i].value;
        data2[i] = data1[i];
    }
    bubble_sort(data1, N);
    print_data(data1, N);
    cout << "Stable" << endl;

    selection_sort(data2, N);
    print_data(data2, N);
    bool stable = is_stable(data1, data2, N);
    if (stable) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 200005;
const int MM = 1000000007;

int D[MX];

int main()
{
	int N, Z, W;
	scanf("%d%d%d", &N, &Z, &W);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	if( N >= 2 ) printf("%d\n", max(abs(W-D[N]), abs(D[N-1]-D[N])));
	else printf("%d\n", abs(W-D[N]));
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//The Two Men of the Japanese Alps
public class Main{

	int INF = 1<<29;
	Map<Integer, Double>[] map;
	
	double calc(double x1, double y1, double x2, double y2){
		return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		int[] xs = new int[100], ys = new int[100], y = new int[5000];
		double[] x = new double[5000];
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			Set<Integer> yset = new HashSet<Integer>();
			for(int i=0;i<n;i++){
				xs[i] = sc.nextInt();
				yset.add(ys[i]=sc.nextInt());
			}
			int[] Y = new int[yset.size()];
			int id = 0;
			for(int yy:yset)Y[id++]=yy;
			Arrays.sort(Y);
			id = 0;
			for(int i=0;i+1<n;i++){
				if(ys[i]==ys[i+1]){
					x[id] = xs[i];
					y[id++] = ys[i];
				}
				else if(ys[i]<ys[i+1]){
					for(int j=0;j<Y.length&&Y[j]<ys[i+1];j++){
						if(Y[j]<ys[i])continue;
						x[id] = (xs[i+1]-xs[i])*(Y[j]-ys[i]+0.)/(ys[i+1]-ys[i]) + xs[i];
						y[id++] = Y[j];
					}
				}
				else{
					for(int j=Y.length-1;j>=0&&Y[j]>ys[i+1];j--){
						if(Y[j]>ys[i])continue;
						x[id] = (xs[i+1]-xs[i])*(Y[j]-ys[i]+0.)/(ys[i+1]-ys[i]) + xs[i];
						y[id++] = Y[j];
					}
				}
			}
			x[id] = xs[n-1];
			y[id++] = 0;
			map = new Map[id];
			for(int i=0;i<id;i++)map[i]=new HashMap<Integer, Double>();
			map[0].put(id-1, 0.);
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(id, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return (int)Math.signum(map[o1[0]].get(o1[1]) - map[o2[0]].get(o2[1]));
				}
			});
			q.add(new int[]{0, id-1});
			double res = INF;
			while(!q.isEmpty()){
				int[] V = q.poll();
				int i = V[0], j = V[1];
				if(i==j){
					res = map[i].get(j); break;
//					res = Math.min(res, map[i].get(j)); continue;
				}
				for(int di=-1;di<=1;di++){
					int ni = i+di;
					if(ni<0 || id<=ni)continue;
					for(int dj=-1;dj<=1;dj++){
						int nj = j+dj;
						if(nj<0 || id<=nj || nj < ni || y[ni]!=y[nj])continue;
						double w = map[i].get(j) + calc(x[i], y[i], x[ni], y[ni]) + calc(x[j], y[j], x[nj], y[nj]);
						if(!map[ni].containsKey(nj) || w < map[ni].get(nj)){
							map[ni].put(nj, w);
							q.add(new int[]{ni, nj});
						}
					}
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
#include <iostream>                                                             
#include <algorithm>                                                            
                                                                                
using namespace std;                                                            
                                                                                
int main(void) {                                                                
  int n, k, num1; // num 1 is the location of 1                                 
  cin >> n >> k;                                                                
  for (int i(0); i < n; i++) {                                                  
    int tmp;                                                                    
    cin >> tmp;                                                                 
    if (tmp == 1) {                                                             
      num1 = i;                                                                 
      break;                                                                    
    }                                                                           
  }                                                                             
  //cout << "num1=" << num1<<endl;                                              
  int mn = 1000000;                                                             
  for (int i(0); i < k; i++) {                                                  
    // hidarigawa                                                               
    int h = num1 - i;                                                           
    // migigawa                                                                 
    int migi = n - num1 - (k - i);                                              
    //cout << "h,migi= " << h << " " << migi << endl;                           
    if (h < 0 || migi < 0) {                                                    
      //cout << "invalid i" << endl;                                            
      continue;                                                                 
    }                                                                           
    int sum(1);                                                                 
    sum += h / (k - 1);                                                         
    if(h % (k-1) !=0 && h!=0)sum++;                                             
    sum += migi / (k - 1);                                                      
    if(migi % (k-1) !=0 && migi!=0)sum++;                                       
    //cout << "i= " << i << " sum=" << sum << endl;                             
    mn = min(mn, sum);                                                          
  }                                                                             
  cout << mn;                                                                   
  return 0;                                                                     
}                                                                               


Measured memory_bytes: 256
# bitが干渉しない範囲
# LごとにRを求める

N = int(input())
A = [int(x) for x in input().split()]

R = -1
S = 0

answer = 0
for L in range(N):
  if R < L:
    R += 1
    S ^= A[L]
  while R<N-1 and not(S & A[R+1]):
    S ^= A[R+1]
    R += 1
  answer += R-L+1
  S ^= A[L]
  
print(answer)

Measured memory_bytes: 23560
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int sum_of_digits = 0; 
	string n; 
	
	cin >> n; 
	
	for(int i = 0; i < n.size(); i++) {
		sum_of_digits += (int)(n[i] - '0'); 
		sum_of_digits %= 9; 
	}
	
	if(sum_of_digits == 0) 
		cout << "Yes" << endl; 
	else 
		cout << "No" << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 8;

array<int, N> h = { 3, 0, 1, 2, 7, 4, 5, 6 }; // 横回転
array<int, N> v = { 6, 5, 4, 7, 2, 1, 0, 3 }; // 上下反転
array<int, N> r = { 7, 3, 2, 6, 4, 0, 1, 5 }; // 120度回転

array<int, N> rotate(array<int, N> ar, array<int, N> x){
	auto ret = ar;
	rep(i, N) ret[i] = ar[x[i]];
	return ret;
}

set<array<int, N>> st;

void insert(array<int, N> ar){
	auto flip = rotate(ar, v);

	rep(i, 4){
		rep(j, 3){
			st.insert(ar);
			st.insert(flip);
			ar = rotate(ar, r);
			flip = rotate(flip, r);
		}
		ar = rotate(ar, h);
		flip = rotate(flip, h);
	}
}


int main(){

	string s[N];
	while (1){
		rep(i, N) cin >> s[i];
		if (!cin) break;

		st.clear();
		map<string, int> m;
		array<int, N> ar;
		rep(i, N){
			if (m.count(s[i])) ar[i] = m[s[i]];
			else ar[i] = i, m[s[i]] = i;
		}
		sort(ALL(ar));

		int ans = 0;
		do{
			ans += !st.count(ar);

			//if (!st.count(ar)){
			//	rep(i, N) cout << ar[i] << ' ';
			//	cout << endl;
			//}

			insert(ar);
		} while (next_permutation(ALL(ar)));
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4352
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, y = mput()
    hoge = (x * 4 - y) / 2
    if hoge % 1 == 0 and x >= hoge >= 0:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 9248