akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
//a^n modをO(logN)で計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a-bをMODで割ったあまり、負にならない工夫
long long sub(long long a,long long b,int mod){
    long long ans = ((a%mod)-(b%mod))%mod;
    if(ans>=0){
        return ans;
    }
    else{
        return ans+mod;
    }
}
int main(){
    int n;
    cin>>n;//n桁の整数x
    string x;
    cin>>x;
    bitset<200001> bi(x);
    int dpop=bi.count();//最初の1の数
    int64_t NUMp=0,NUMm=0;
    //方針: popcは大した数じゃない(最大2*10^5)から、一回計算すれば整数型としてふつうに計算できる大きさになる
    //考えないといけないこと:1が1個しかない->そこを反転するとbit=0になって、操作0回で終わる
    //バカでかい数の余りを計算する abc164dを参考
    //ex)101%3 = (1*2^2 + 0*2^1 + 1*2^0)%3
    for(int j=n-1;j>=0;j--){
        //NUMp += modpow(2,j,(dpop+1))*(bi.test(j))%(dpop+1);
        NUMp = 2*NUMp+bi.test(j);
        NUMp %= (dpop+1);
        if(dpop>1){
            //NUMm += modpow(2,j,(dpop-1))*(bi.test(j))%(dpop-1);
            NUMm = 2*NUMm + bi.test(j);
            NUMm %= (dpop-1);   
        }
    }
    for(int i=n-1;i>=0;i--){
        int cnt=0;
        int popc;
        int64_t num;
        if(dpop==1 && bi.test(i)){
            cout<<0<<endl;
            continue;
        }
        if(bi.test(i)){//1を反転する->popc = dpop-1 -> NUMmを使う
            popc = dpop-1;
            num =  sub(NUMm,modpow(2,i,popc),popc);
            num %= popc; 
        }
        else{
            popc = dpop+1;
            num =NUMp + modpow(2,i,popc);
            num %= popc;
        }
        bi.flip(i);
        auto tmp = bi;
        //cout<<num<<endl;
        cnt=1;
        while(num!=0){
            bitset<18>  tbdiv(num);
            popc = tbdiv.count();
            num %= popc;
            cnt++;
        }
        cout<<cnt<<endl;
        bi.flip(i);
    }
}

Measured memory_bytes: 3748
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

const int A = 2e5 + 10;
int sum[A];

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

bool F(int n){
    if(n == 1) return false;
    for(int i=2 ;i*i <= n ;i++){
        if(n % i == 0) return false;
    }
    return true;
}

bool check(int n){
	int m = (n+1)/2;
	if(F(m) && F(n)) return true;
	return false;
}

int main(){
	sum[0] = 0;
	for(int i=1 ;i<A ;i++){
		if(i%2 == 0) sum[i] = sum[i-1];
		else{
			if(check(i)) sum[i] = sum[i-1] + 1;
			else	     sum[i] = sum[i-1];
		}
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",sum[r] - sum[l-1]);
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
 	int h, w;
  	cin >> h >> w;
  	for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
      	string t;
        cin >> t;
        if (t == "snuke") {
        	cout << (char)(j + 'A') << i + 1;
          	return 0;
        }
      }
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
int main(){
	int d=readint();
	switch(d){
		case 25:puts("Christmas");break;
		case 24:puts("Christmas Eve"); break;
		case 23:puts("Christmas Eve Eve");break;
		case 22:puts("Christmas Eve Eve Eve");break;
	}
	return 0;
}

Measured memory_bytes: 256
n,c,k=[int(i) for i in input().split()]
a=sorted([int(input()) for i in range(n)])
b=[i+k for i in a]
i0=[]
ans=0
bi=0
for i in range(n):
  i0.append(a[i])
  l=len(i0)
  if l== c or (b[bi] < a[i] and i!=0) :
    ans+=1
    i0=[]
    bi=i
  if l != c and i==n-1:
    ans+=1

print(ans)

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

int main() {
  int M, N, sum;
  cin >> N;
  sum = 0;
  M = N;
  
  rep (i, N) {
  sum += N - (N / 10) * 10;
  N /= 10;
  }
  
  sum += N;
  
  if (M % sum == 0) puts ("Yes");
  else puts ("No");
}

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

int main() {
    std::string s;
    std::cin >> s;
    for (auto c : s) {
        if (c == '1') std::cout << '9';
        else if (c == '9') std::cout << '1';
        else std::cout << c;
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

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

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

bool check(char c)
{
	return ('a' <= c && c <= 'z');
}

int main()
{
	string s;
	string t;

	getline(cin, s);

	bool ok = true;
	for (int i = 0; i < s.length(); i++)
	{
		if (i + 5 <= s.length())
		{
			if (s.substr(i, 5) == "peach")
			{
				s.erase(i, 5);
				s.insert(i, "apple", 5);
			}
			else if (s.substr(i, 5) == "apple")
			{
				s.erase(i, 5);
				s.insert(i, "peach", 5);
			}
		}

		cout << s.substr(i, 1);
	}

	cout << endl;
}


Measured memory_bytes: 3224
# Your code here!
def t_print(str, first, last)
    ((first.to_i)..(last.to_i)).each{|i|
        print str[i]
    }
    puts ""
end

def t_replace(str, first, last, rep_str)
    ((first.to_i)..(last.to_i)).each_with_index{|i, j|
        str[i] = rep_str[j]
    }
end

def t_reverse(str, first, last)
    temp = String.new(str)
    ((first.to_i)..(last.to_i)).each_with_index{|i, j|
        str[i] = temp[last.to_i - j]
    }
end

# Main
str = gets.chomp
loop = gets.to_i

loop.times{|i|
    order = gets.split
    case order[0]
        when "print" then t_print(str, order[1], order[2])
        when "replace" then t_replace(str, order[1], order[2], order[3])
        when "reverse" then t_reverse(str, order[1], order[2])
    end
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int n,ans;

int main(){
  cin>>n;
  int a[2][n];
  int sum[2];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    int p=0,q=0;
    for(int j=0;j<=i;j++){
      p+=a[0][j];
    }
    for(int k=i;k<n;k++){
      p+=a[1][k];
    }
    debug(p,q);
    ans=max({ans,p});
    debug(ans);
  }
  dump(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		int minx = 0, miny = 0;
		int maxx = w, maxy = h;
		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());
			int a = Integer.parseInt(sc.next());
			if (a == 1)
				minx = Math.max(minx, x);
			else if (a == 2)
				maxx = Math.min(maxx, x);
			else if (a == 3)
				miny = Math.max(miny, y);
			else
				maxy = Math.min(maxy, y);
		}
		System.out.println(Math.max((maxx - minx), 0) * Math.max((maxy - miny), 0));
	}
}

Measured memory_bytes: 21972
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(a.begin(), a.end());
  vector<int> big, small;
  rep(i, n){
    if(i < (n+1)/2) small.push_back(a.at(i));
    else big.push_back(a.at(i));
  }
  if(n % 2 == 0){
    vector<int> ans;
    rep(i, n){
      if(i % 2 == 0){
        if(i == 0){
          ans.push_back(small.back());
        }else{
          ans.push_back(small.at(i/2-1));
        }
      }else{
        if(i == n-1){
          ans.push_back(big.front());
        }else{
          ans.push_back(big.at(i/2+1));
        }
      }
    }
    ll aa = 0;
    rep(i, n-1) aa += abs(ans.at(i) - ans.at(i+1));
    cout << aa << endl;
  }else{
    int mid1 = small.back();
    vector<int> ans;
    rep(i, n){
      if(i % 2 == 0){
        if(i == 0 || i == n-1){
          ans.push_back(small.back());
          if(i == 0)small.pop_back();
        }else{
          ans.push_back(small.at(i/2-1));
        }
      }else{
        ans.push_back(big.at(i/2));
      }
    }
    ll aa = 0;
    rep(i, n-1) aa += abs(ans.at(i) - ans.at(i+1));

    ans.clear();
    rep(i, n){
      if(i % 2 == 0){
        if(i == 0){
          ans.push_back(mid1);
        }else if(i == n-1){
          ans.push_back(big.at(0));
        }else{
          ans.push_back(big.at(i/2));
        }
      }else{
        ans.push_back(small.at(i/2));
      }
    }
    ll bb = 0;
    rep(i, n-1) bb += abs(ans.at(i) - ans.at(i+1));
    aa = max(aa, bb);
    cout << aa << endl;
  }
  return 0;
}

Measured memory_bytes: 4716
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		@SuppressWarnings("unchecked")
		ArrayList<Edge> edges[] = new ArrayList[n];

		for(int i = 0; i < n; i++){
			if(edges[i] == null){
				edges[i] = new ArrayList<Edge>();
			}
		}

		for(int i = 0; i < m; i++){

			int from = sc.nextInt() - 1;
			int to = sc.nextInt() - 1;
			int cost = 1;

			edges[from].add( new Edge(to, cost));
			edges[to].add( new Edge(from, cost));
		}
		prev = new int[n];

		dijkstra(edges, 0, n);

		System.out.println("Yes");
		for(int i = 1; i < n; i++){
			System.out.println(prev[i] + 1);
		}

	}
	static int[] prev;
	static final int INF = Integer.MAX_VALUE;

	//ダイクストラ法
	static int[] dijkstra(ArrayList<Edge>[] edges, int s, int n){

		PriorityQueue<Distance> que = new PriorityQueue<Distance>();
		int[] dist = new int[n];

		Arrays.fill(dist, INF);
		dist[s] = 0;
		que.add(new Distance(0, s));

		while(!que.isEmpty()){
			Distance tmpDist = que.poll();
			int tmpV = tmpDist.id;

			if(dist[tmpV] < tmpDist.dist){
				continue;
			}
			for(int i = 0; i < edges[tmpV].size() ; i++){
				Edge e = (Edge) edges[tmpV].get(i);
				if(dist[e.to] > dist[tmpV] + e.cost){
					dist[e.to] = dist[tmpV] + e.cost;
					prev[e.to] = tmpV;
					que.add(new Distance(dist[e.to], e.to));
				}
			}
		}

		return dist;
	}
}

class Distance implements Comparable<Distance>{
	int dist;
	int id;

	Distance(int dist, int id){
		this.dist = dist;
		this.id = id;
	}

	@Override
	public int compareTo(Distance d) {
		return this.dist - d.dist;
	}
}

class Edge {
	int to;
	int cost;

	Edge(int to, int cost){
		this.to = to;
		this.cost = cost;
	}
}


Measured memory_bytes: 70560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string t,s;
    cin>>t>>s;
    int cnt=0;
    for(int i=0;i<t.size();i++)
    {
        if(t[i]!=s[i])
             cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3900
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
import itertools 
P = list(itertools.permutations(i for i in range(n)))
ans = 0
for p in P:
    for i in range(n-1):
        cur,next = xy[p[i]],xy[p[i+1]]
        ans += ((cur[0]-next[0])**2+(cur[1]-next[1])**2)**0.5
print(ans/len(P))

Measured memory_bytes: 46960
(let* ((rnum (read))
       (cnum (read))
       (k (read))
       (i (make-array (list (1+ rnum) (1+ cnum))))
       (dp (make-array (list (1+ rnum) (1+ cnum) 4) :initial-element 0)))
  (loop :for _ :from 1 :to k
        :for r := (read)
        :for c := (read)
        :do (setf (aref i r c) (read)))
  ;;
  (loop :for r :from 1 :to rnum
        :do (loop :for c :from 1 :to cnum
                  :do (setf (aref dp r c 0) (max (aref dp r (1- c) 0) (aref dp (1- r) c 0) (aref dp (1- r) c 1) (aref dp (1- r) c 2) (aref dp (1- r) c 3)))
                  :if (aref i r c)
                  :do (let ((v (aref i r c)))
                        (setf (aref dp r c 1) (max (aref dp r (1- c) 1) 
                                                   (+ v (max (aref dp r (1- c) 0) (aref dp (1- r) c 0) (aref dp (1- r) c 1) (aref dp (1- r) c 2) (aref dp (1- r) c 3)))))
                        ; ?
                        (setf (aref dp r c 2) (max (aref dp r (1- c) 2) (+ (aref dp r (1- c) 1) v)))
                        (setf (aref dp r c 3) (max (aref dp r (1- c) 3) (+ (aref dp r (1- c) 2) v))))
                  :else
                  :do (progn
                        (setf (aref dp r c 1) (aref dp r (1- c) 1))
                        ; ?
                        (setf (aref dp r c 2) (aref dp r (1- c) 2))
                        (setf (aref dp r c 3) (aref dp r (1- c) 3)))))
  (format t "~A~%"
          (max (aref dp rnum cnum 0) (aref dp rnum cnum 1) (aref dp rnum cnum 2) (aref dp rnum cnum 3))))


Measured memory_bytes: 429072
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int i,j;
    scanf("%d",&i);
    scanf("%d",&j);
    if (i%j==0) printf("%d",0);
    else printf("%d",1);
    
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 068_arc_b / Link: https://arc068.contest.atcoder.jp/tasks/arc068_b?lang=en  ----- */
/* ------問題------

すぬけくんはカードゲームで遊ぶことにしました。 N 枚からなるカードの山があり、上から i 枚目のカードには整数 Ai が書かれています。
すぬけくんはこのカードの山に対し 0 回以上、以下の操作を行い、残ったカードに書かれた値が互いに異なるようにしたいです。最大で何枚のカードを残すことが可能か求めなさい。なお、N は奇数であり、少なくとも 1 枚のカードを残すことが可能であることが保証されます。
操作：カードの山から任意の 3 枚のカードを抜き出す。抜き出したカードのうち書かれた値が最大であるようなカード 1 枚と最小であるようなカード 1 枚の合計 2 枚を選んで食べる。その後残った 1 枚をカードの山に戻す。

-----問題ここまで----- */
/* -----解説等-----

数字をまとめて個数で考える。
3個以上のものは同じものだけを選択することで全部1か2になる。
2についてこれらは全て選択し他の2あるいは1も選択する。
2が偶数個あるときは数自体を減らさずに個数のみを減らせる。
奇数個のときは最後の1つだけが相手が見つからず誰かを消すことになる。
これを書けば良い。

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(N);
	VI cnt(100005);
	FOR(i, 0, N) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	VI pq;
	FOR(i, 0, 100005) {
		if (cnt[i])pq.push_back(cnt[i]);

	}
	int even = 0;
	FOR(i, 0, SZ(pq)) {
		if (pq[i] % 2 == 0)even++;
	}
	ans = SZ(pq);
	if (even % 2 == 1)ans--;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1660
n,m = map(int,input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]

flag = False
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            if B[k] != A[i+k][j:j+m]:
                flag = False
        if flag:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

// warshall_floyd
void warshall_floyd(vvint &d, int n) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (d[j][i] == inf || d[i][k] == inf) continue;
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
}

int main() {
    int n, m, R; cin >> n >> m >> R;
    vint r(R);
    rep(i,R) {
        int x; cin >> x;
        x--;
        r[i] = x;
    }
    sort(all(r));
    vvint dis(n,vint(n,inf));
    rep(i,n) dis[i][i] = 0;
    rep(i,m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        dis[a][b] = dis[b][a] = c;
    }
    warshall_floyd(dis,n);
    int ans = inf;
    do {
        int sum = 0;
        REP(i,R) sum += dis[r[i-1]][r[i]];
        ans = min(ans,sum);
    } while (next_permutation(all(r)));
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
ll Arr[100001];
bool solve(ll n){
    if(n==1) return(true);
    set<ll> st;
    for(ll i=0;i<n;i++){
        ll m=(Arr[i]+i)%n;
        if(m<0) m+=n;
        if(st.count(m)) return(false);
        st.insert(m);
    }
    return(true);
}
ll power[11];

int main(){
    IO
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    power[0]=1;
    for(ll i=1;i<=k;i++) power[i]=power[i-1]*2;
    ll maxx=-1;
    for(ll i=0;i<=k;i++){
        for(ll j=0;j<=k;j++){
            if(i+j>k) continue;
            ll z=k-(i+j);
            maxx=max(maxx,a*power[i]+b*power[j]+c*power[z]);
        }
    }
    cout<<maxx;
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int tmp = 0;
  rep(i,M) {
    int A;
    cin >> A;
    tmp += A;
  }
  cout << max(-1, N-tmp) <<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

ll dp[N], h[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> h[i], dp[i] = inf;
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = max(0, i-k); j < i; ++j)
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
  }
  cout << dp[n-1];
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <utility>

using namespace std;

#define ARRAY_SIZE_MAX 100

int main()
{
	int arraySize = 0;

	scanf("%d", &arraySize);

	int Array[ARRAY_SIZE_MAX] = { 0 };
	for (int i = 0; i < arraySize; i++) {
		scanf("%d", &Array[i]);
	}

	int swapCount = 0;

	for (int i = 0; i < arraySize; i++) {
		int minIndex = i;

		for (int j = i + 1; j < arraySize; j++) {
			if (Array[minIndex] > Array[j]) {
				minIndex = j;
			}
		}

		if (minIndex != i) {
			swap(Array[minIndex], Array[i]);
			swapCount++;
		}
	}



	// 結果出力
	// ソート済み配列
	for (int i = 0; i < arraySize; i++) {
		if (i != arraySize - 1) {
			printf("%d ", Array[i]);
		}
		else {
			printf("%d\n", Array[i]);
		}
	}

	// 交換回数
	printf("%d\n", swapCount);


	return 0;
}


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

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

      int a[n+5]={};
      for(int i=1;i<=n;i++){
            cin>>a[i];
      }

      sort(a,a+(n+1));
      /*for(int i=1;i<=n;i++){
            cout<<a[i]<<endl;
      }*/
      int g=n/2;
      int k=a[g+1]-a[g];

      cout<<k<<endl;

}



Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// ??\???
int n, W;
int weight[110], value[110];

// DP????????????
int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

  // DP???????????¶: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DP?????????
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

  cout << dp[n][W] << endl;
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<ll> waters, sugars;
  for (int i = 0; 100 * a * i <= f; i++) {
    for (int j = 0; 100 * b * j <= f; j++) {
      ll can_w = 100 * a * i + 100 * b * j;
      if (can_w <= f) waters.push_back(can_w);
    }
  }
  for (int i = 0; c * i <= f; i++) {
    for (int j = 0; d * j <= f; j++) {
      ll can_s = c * i + d * j;
      if (can_s <= f) sugars.push_back(can_s);
    }
  }

  double con = 0;
  ll ans_ws = 0, ans_s = 0;
  for (auto w : waters) {
    for (auto s : sugars) {
      if (s * (100 + e) > (w + s) * e) continue;
      if (w + s == 0 && s > 0) continue;
      if (w + s > f) continue;
      if (ans_s * (w + s) <= s * ans_ws) {
        ans_s = s, ans_ws = w + s;
      }
    }
  }
  cout << ans_ws << " " << ans_s << endl;
  return 0;
}


Measured memory_bytes: 5164
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
a, b = 0, 0
A, B = set(), set()
for i in range(N):
    n = N - i - 1
    m = P[i] - i - 1
    for ai in A:
        if ai < P[i]:
            m -= 1
    a += m * math.factorial(n)
    A.add(P[i])
for i in range(N):
    n = N - i - 1
    m = Q[i] - i - 1
    for bi in B:
        if bi < Q[i]:
            m -= 1
    b += m * math.factorial(n)
    B.add(Q[i])
print(abs(a - b))

Measured memory_bytes: 9180
sx,sy,tx,ty=[int(x) for x in input().split()]
dx=tx-sx
dy=ty-sy
print("R"*dx+"U"*dy+"L"*dx+"D"*(dy+1)+"R"*(dx+1)+"U"*(dy+1)+"LU"+"L"*(dx+1)+"D"*(dy+1)+"R")

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <limits.h>

using namespace std;

int main(void)
{
    long long N, K, h[100001], sum[100001], i, j;

    cin >> N >> K;

    for(i=1; i<=N; i++){
        cin >> h[i];
    }

    sum[1] = 0;

    for(i=2; i<=N; i++){
        sum[i] = LLONG_MAX;

        for(j=i-K; j<=i-1; j++){
            if(j >= 1){
                //今の値より小さければ入れ替える
                if(sum[j]+abs(h[j]-h[i]) < sum[i]){
                    sum[i] = sum[j]+abs(h[j]-h[i]);
                }
            }
        }
    }

    cout << sum[N] << endl;

    return 0;
}

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

const int MAXN = 1E2+2;

char a[MAXN][MAXN];
int f[MAXN][MAXN];
int H, W;

int dp(int i, int j){
	int& ret = f[i][j];
	if(ret!= -1) return ret;
	if(i==1){
		if(j==1) return ret = (a[1][1]=='#');
		return ret = dp(i, j-1) + (a[i][j] != a[i][j-1]);
	}
	if(j==1) return ret = dp(i-1, j) + (a[i][j] != a[i-1][j]);
	return ret = min(dp(i, j-1) + (a[i][j] != a[i][j-1]), \
		dp(i-1, j) + (a[i][j] != a[i-1][j])\
	);
}

signed main(){
	memset(f, -1, sizeof f);
	cin >> H >> W;
	for(int i=1; i<= H; ++i)
		for(int j=1; j<= W; ++j)
			cin >> a[i][j];
	cout << (dp(H,W) + (a[H][W] == '#'))/2 << "\n";
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
Edges = list([] for _ in range(N))
for i in range(N-1):
    a, b = map(int, input().split())
    Edges[a-1].append(b-1)
    Edges[b-1].append(a-1)
P = [0 for _ in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    P[p-1] += x

gone = [False for _ in range(N)]

def dfs(counter, count, cur_node):
    count += P[cur_node]
    gone[cur_node] = True
    counter[cur_node] += count
    for next_node in Edges[cur_node]:
        if gone[next_node]:
            continue
        dfs(counter, count, next_node)

counter = [0 for _ in range(N)]
dfs(counter, 0, 0)

for c in counter:
    print(c)

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 5;

int n, cnt1[N], cnt2[N], x;

vector < pair <int, int> > vec1, vec2;

set <int> st;

main(){

    cin >> n;
    for (int i = 1; i <= n; i++){

        scanf("%d", &x);
        if(i & 1){
            cnt1[x]++;
        }
        else{
            cnt2[x]++;
        }
        st.insert(x);
    }
    for (auto it : st){
        vec1.pb( mk( cnt1[it], it ) );
        vec2.pb( mk( cnt2[it], it ) );
    }
    sort(all(vec1));
    sort(all(vec2));

//    cout << vec1.back().sc << " " << vec2.back().sc << endl;

    if ( vec1.back().sc != vec2.back().sc ){
        cout << n - vec1.back().fr - vec2.back().fr << endl;
    }
    else{
        if ( vec1.size() == 1 && vec2.size() == 1 )
            cout << n / 2 << endl;
        else if ( vec1.size() == 1 )
            cout << vec2.back().fr << endl;
        else if ( vec2.size() == 1 )
            cout << vec1.back().fr << endl;
        else{
            cout << n - max( vec1.back().fr + vec2[ vec2.size() - 2 ].fr, vec2.back().fr + vec1[ vec1.size() - 2 ].fr ) << endl;
        }
    }
}


Measured memory_bytes: 7532
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
        long long int n,k,sum = 0;
        cin >> n >> k;
        vector<int> h(n);
        for (int i = 0; i < n; i++)
                cin >> h[i];
        sort(h.begin(),h.end());
        for (int i = 0; i < n - k; i++)
                sum += h[i];
        cout << sum << endl;
        return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		int n,k;
		cin>>n>>k;
		vi h(n),b(n,1);
		vector<vi> a(n);
		for(int i=0;i<n;i++){
			cin>>h[i];
		}
		for(int i=0;i<k;i++){
			int x,y;
			cin>>x>>y;
			x--,y--;
			a[x].pb(y);
			a[y].pb(x);
		}

		int ans=0;
		for(int i=0;i<n;i++){
			int m=a[i].size(),co=0;
			for(int j=0;j<m;j++){
				if(h[i]>h[a[i][j]])
					co++;
			}
			if(co!=m)
				b[i]=0;
		}

		for(int i=0;i<n;i++)
			ans+=b[i];

		cout<<ans<<endl;
		
	}
}

Measured memory_bytes: 9256
from math import gcd

N = int(input())
A = list(map(int,input().split()))
 
flg = 0
l = [0]*(max(A)+1)
for i in A:
  l[i] += 1
a = gcd(A[0],A[1])
for i in range(2,N):
  a = gcd(a,A[i])
for i in range(2,max(A)+1):
  if sum(l[i::i]) > 1:
    flg = 1
    break



if a == 1 and flg == 0:
  print("pairwise coprime ")
elif a == 1 and flg == 1:
  print("setwise coprime")
else:
  print("not coprime")


Measured memory_bytes: 132672
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int vy[4] = {-1,1,0,0};
int vx[4] = {0,0,-1,1};

struct ST {
  int y, x, a;
  int dist1, dist2;
  ST(){
    dist1 = -1;
    dist2 = -1;
  }
  ST(int y, int x, int a, int dist1, int dist2):y(y),x(x),a(a),dist1(dist1),dist2(dist2){}
};
bool operator<(const ST& a, const ST& b){
  if(a.dist1 == b.dist1) return a.dist2 > b.dist2;
  return a.dist1 > b.dist1;
}


int main(){
  int H, W, K;
  cin >> H >> W >> K;
  int x1, y1, x2, y2;
  cin >> y1 >> x1 >> y2 >> x2;
  x1--; y1--;
  x2--; y2--;
  vector<string> field;
  rep(i,H){
    string s;
    cin >> s;
    field.push_back(s);
  }

  vector<vector<vector<ST>>> ans(H, vector<vector<ST>>(W, vector<ST>(4)));

  priority_queue<ST> que;
  rep(k,4){
    que.push(ST(y1,x1,k,0,0));
  }


  while(!que.empty()){
    ST st = que.top(); que.pop();
    if(ans[st.y][st.x][st.a].dist1 != -1) continue;
    ans[st.y][st.x][st.a] = st;
    //cout << st.y << " " << st.x << " " << st.a << " " << st.dist1 << " " << st.dist2 << endl;
    
    rep(k,4){
      if(k == st.a) continue;
      que.push(ST(st.y,st.x,k,st.dist1+(st.dist2>0?1:0),0));
    }

    int nx = st.x + vx[st.a];
    int ny = st.y + vy[st.a];
    if(0<=nx&&nx<W&&0<=ny&&ny<H && field[ny][nx]=='.'){
      int dist1 = st.dist1;
      int dist2 = st.dist2 + 1;
      if(dist2 >= K){
        dist1++;
        dist2 = 0;
      }
      que.push(ST(ny,nx,st.a,dist1,dist2));
    }
  }

  int ret = 99999999;
  rep(k,4){
    if(ans[y2][x2][k].dist1 != -1){
      ret = min(ret, ans[y2][x2][k].dist1 + (ans[y2][x2][k].dist2>0?1:0));
    }
  }
  if(ret == 99999999) ret = -1;

  cout << ret << endl;
  
    
  return 0;
}



Measured memory_bytes: 238520
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a, b, c;
vector<ll> G;
int main(void){
    // Your code here!
    cin >> a >> b >> c;
    G.push_back(a);
    G.push_back(c);
    G.push_back(b);
    sort(G.begin(), G.end());
    cout << G[0] + G[1] + G[2] * 10 << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll x = 1000;
  rep(i, n-1) {
    int s = a[i];
    int t = a[i+1];
    if(s < t) {
        ll k = x / s;
        x %= s;
        x += k * t;
    }
  }
  cout << x << endl;
  return 0;
}


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

  int gcd(int x, int y) {
    return (x % y == 0 ? y : gcd(y, x % y));
  }

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

  int X;
  cin >> X;

  for(int i = X; ; ++i) {
    for(int j = X - 1; j > 0; --j) {
      if(gcd(i, j) == 1) {
        if(j == 1) {
          cout << i << endl;
          return 0;
        }
      }
      else {
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  int a,b;
  cin >> a >> b;
  int answer=0;
  while(b>1) {
    ++answer;
    b-=a-1;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    double k;
    cin>>k;
    ll cnt = 0;
    double s = 100;
    while(s < k)
    {
        cnt++;
        s = s*1.01;
        ll s1 = s;
        s = s1;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = (n-1); i >= (b); i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
int gcd(int a, int b){return b ? gcd(b, a % b): a;}
void yes(){cout<<"Yay!"<<endl;return;}
void no(){cout<<":("<<endl;return;}

int main()
{
    int a, b, c,  d, e;
    int k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a <= k) yes();
    else no();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
v = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
l = [0]*n

for i in range(n):
    l[i] = v[i]-c[i]
    if(l[i] < 0):
        l[i]=0
    
print(sum(l))

Measured memory_bytes: 9164
#include <bits/stdc++.h>
        
using namespace std;
        
typedef long long ll;
#define mp make_pair
#define pub push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define y1 dsfgsdfgsdfgsdfgsdfgsdfg
#define y0 asdfasdf3rcdt234d5c23xd234dx43

const int mod = 1e9 + 7;

int n;
int a[100007];
int fac[100007];
int invfac[100007];

int bp(int a, int k){
	if (k == 1) return a;
	if (k % 2 == 1){
		return bp(a, k - 1) * (ll)a % mod;
	} else {
		int q = bp(a, k / 2);
		return (ll)q * q % mod;
	}
}

int cnk(int n, int k){
	if (n < k) return 0;
	int ans = fac[n] * (ll)invfac[k] % mod;
	ans = ans * (ll)invfac[n - k] % mod;
	return ans;
}

int was[100007];

const bool is_testing = 0;
int main() { 
    srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N' + time(NULL));
    //mt19937 rnd(time(NULL));
    //ios_base::sync_with_stdio(0); cin.tie(0);
    if (is_testing) {
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    } else {
        //freopen("cpr.in", "r", stdin);
        //freopen("cpr.out", "w", stdout);
    }
    fac[0] = 1;
    for (int i = 1; i < 100007; i++) fac[i] = fac[i - 1] * (ll)i % mod;
    for (int i = 0; i < 100007; i++) invfac[i] = bp(fac[i], mod - 2);
    scanf("%d", &n);
    for (int i = 0; i < n + 1; i++) scanf("%d", &a[i]);

    for (int i = 0; i < 100007; i++) was[i] = -1;
    int d = -1;
    for (int i = 0; i < n + 1; i++){
    	if (was[a[i]] != -1){
    		d = was[a[i]] + (n - i); 
    		break;
    	}  
    	was[a[i]] = i;
    }
    for (int i = 1; i <= n + 1; i++){
    	printf("%d\n", (cnk(n + 1, i) - cnk(d, i - 1) + mod) % mod);
    }
}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
inpl = lambda: tuple(map(int,input().split()))

N, C = inpl()
xv = [None]*N
for i in range(N):
    xv[i] = inpl()
xv.sort()

Rs = [0]*(N+1)
Ls = [0]*(N+1)
Rd = [0]*(N+1)
Ld = [0]*(N+1)
RsMax = LsMax = RdMax = LdMax = 0
RvSum = LvSum = 0
RsCur = LsCur = RdCur = LdCur = 0
for i in range(1,N+1):
    RvSum += xv[i-1][1]
    LvSum += xv[N-i][1]
    RsCur = RvSum - xv[i-1][0]
    RdCur = RvSum - xv[i-1][0]*2
    LsCur = LvSum - (C-xv[N-i][0])
    LdCur = LvSum - (C-xv[N-i][0])*2
    Rs[i] = max(Rs[i-1],RsCur)
    Rd[i] = max(Rd[i-1],RdCur)
    Ls[i] = max(Ls[i-1],LsCur)
    Ld[i] = max(Ld[i-1],LdCur)
Rans = max(Rs[i]+Ld[N-i] for i in range(N+1))
Lans = max(Ls[i]+Rd[N-i] for i in range(N+1))
ans = max(Rans,Lans)
print(ans)

Measured memory_bytes: 57052
n = int(input())
primes = [2]
for i in range(3, 100):
    flag = True
    for j in primes:
        if i%j==0:
            flag = False
            break
    if flag:
        primes.append(i)

factors = [0 for i in range(len(primes))]
def mul(x):
    #if x==2:
    #    factors[0] += 1
    #    return 2
    if x==1:
        return 1
    else:
        tmp = x
        while tmp != 1:
            for i, prime in enumerate(primes):
                if tmp%prime==0:
                    factors[i] += 1
                    tmp = tmp//prime
                    break

        return x*mul(x-1)

mul(n)
num74 = 0
num24 = 0
num14 = 0
num4 = 0
num2 = 0
for factor in factors:
    if factor>=74:
        num74 += 1
    elif factor>=24:
        num24 += 1
    elif factor>=14:
        num14 += 1
    elif factor>=4:
        num4 += 1
    elif factor >=2:
        num2 += 1

ans = 0
''' 3 * 5 * 5 '''
tmp1 = num74+num24+num14+num4
tmp2 = num2
ans += tmp1*(tmp1-1)//2*tmp2 + tmp1*(tmp1-1)//2*(tmp1-2)
''' 5 * 15 '''
tmp1 = num74+num24+num14
tmp2 = num4
ans += tmp1*tmp2 + tmp1*(tmp1-1)
''' 3 * 25 '''
tmp1 = num74+num24
tmp2 = num14+num4+num2
ans += tmp1*tmp2 + tmp1*(tmp1-1)
''' 75 '''
tmp1 = num74
ans += tmp1
print(ans)


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var H,N int
	fmt.Scan(&H,&N)
	var tmp,sum int
	for i:=0; i<N; i++ {
		fmt.Scan(&tmp)
		sum = sum + tmp
	}
	if(sum>=H) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 5504
#include <cstdio>
#include <cstring>
#define MAXN 100010
#define LL long long

int n,m;
LL a[MAXN],b[MAXN],ans[MAXN];
LL tag[MAXN];

void input(){
	int _m;
	scanf("%d%d",&n,&_m);
	a[++m]=n;
	while(_m--){
		LL x;
		scanf("%lld",&x);
		while(m && a[m]>=x) m--;
		a[++m]=x;
	}
}

void gao(LL x,LL d){
	if(x<=a[1]){
		b[x]+=d;
		return;
	}
	int l=1,r=m;
	while(l<r){
		int mid=(l+r+1)>>1;
		if(a[mid]<x) l=mid;
		else r=mid-1;
	}
	tag[l]+=d*(x/a[l]);
	gao(x%a[l],d);
}

int main(){
	input();
	tag[m]=1;
	for(int i=m;i>=1;i--) gao(a[i],tag[i]);
	LL s=0;
	for(int i=n;i>=1;i--) ans[i]=s+=b[i];
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4736
N,M=map(int,input().split())
data=[list(map(int,input().split()+[i])) for i in range(M)]
data=sorted(data,key=lambda x:x[1])
data=sorted(data,key=lambda x:x[0])
preP=None
count=None
printdata=[]
for i in data:
    if preP==i[0]:
        count+=1
    else:
        preP=i[0]
        count=1
    printdata.append(["0"*(6-len(str(preP)))+str(preP)+"0"*(6-len(str(count)))+str(count),i[2]])
printdata=sorted(printdata,key=lambda x:x[1])
for i in printdata:
    print(i[0])


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

int main(){
  long n,sum1=0,sum2=0;
  cin>>n;
  vector<long> v;
  for(long i=0;i<n;i++){
    long x;
    cin>>x;
    sum1+=x;
    v.push_back(x);  
  }
  for(long i=0;i<n;i++){
    sum2 += v[i]*(sum1-v[i]);
  }
  cout<<sum2/2;
  cout<<endl;
}

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

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

std::vector<int> A;
std::vector<std::vector<bool>> P;
std::vector<std::vector<int>>  Q;
/*
    P[i][j] = 先頭 i 枚を使った時に合計 j にできるか
    Q[i][j] = 後半 i 枚を使った時に合計 j にできるか
    ====> Qについて累積和をとれば区間に属するかがO(1)で判定可能
*/


int main(void){
    int n, k; scanf("%d%d", &n, &k);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    P.resize(n+1, std::vector<bool>(k, false));
    Q.resize(n+1, std::vector<int>(k+1, 0));
    P[0][0] = true;
    REP(i, n){
        REP(j, k) if(P[i][j]){
            P[i+1][j] = true;
            if(j + A[i] < k) P[i+1][j+A[i]] = true;
        }
    }
    Q[0][0] = 1;
    REP(i, n){
        REP(j, k) if(Q[i][j]){
            Q[i+1][j] = 1;
            if(j + A[n-i-1] < k) Q[i+1][j+A[n-i-1]] = 1;
        }
    }
    for(int i=0;i<=n;++i) REP(j,k) Q[i][j+1] += Q[i][j];
    int res = 0;
    REP(i, n){
        bool need = false;
        REP(j, k) if(P[i][j]){
            int u = k - j - 1;
            int vu = Q[n-i-1][u];
            int l = k - A[i] - j - 1;
            int vl = l < 0 ? 0 : Q[n-i-1][l];
            if(vu != vl){
                need = true; break;
            }
        }
        if(not need) res++;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 101504
function Main(input) {
	var tmp = input.split(" ");
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);
	var d = parseInt(tmp[3], 10);
        if(b < c || d < a) {
            //   a   b   c  d
           console.log("%d", 0);
        } else if( a < c ) {
            if( b < d) { 
              //   a  c  b  d
              console.log("%d", b - c );
            }  else  {
             //  a  c  d   b 
              console.log("%d",  d - c);
           }
        } else {
           if( b < d) { 
              //  c a  b  d
              console.log("%d", b - a );
            }  else  {
             //  c a d  b 
              console.log("%d",  d - a);
           }
        }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	if(x % y == 0){
		printf("-1\n");
		return 0;
	}
	printf("%d\n", x);
	//printf("%d\n", (1+__gcd(x, y))*x);
	return 0;
}

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

n,w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(w+1):
        dp[i][j] = dp[i-1][j]
        if j-wv[i-1][0]>=0:
            dp[i][j] = max(dp[i][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])

print(dp[n][w])

Measured memory_bytes: 120172
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

bool compare_by_b(pair<string, pair<int, int>> a, pair<string, pair<int, int>> b)
{
    if(a.first == b.first)
    {
        return a.second.first > b.second.first;
    }else{
        return a.first < b.first;
    }
}

int main()
{
  int N;
  cin >> N;
  vector<pair<string, pair<int, int>>> pairs(N);

  string s;
  int p;
  for(int i = 0; i < N; i++)
  {
    cin >> s >> p;
    pairs[i] = make_pair(s, make_pair(p, i));
  }

  sort(pairs.begin(), pairs.end(), compare_by_b);
  
  for (int i = 0; i < N; i++)
  {
    cout << (pairs[i].second.second + 1) << endl;
  }

}

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

int main()
{
    vector<string> w;
    int n;
    cin >> n;
    string prev;
    cin >> prev;
    w.push_back(prev);
    for (size_t i = 0; i < n - 1; i++)
    {
        string s;
        cin >> s;
        if (s[0] != prev[prev.length() - 1])
        {
            cout << "No" << endl;
            return 0;
        }
        if (std::find(w.begin(), w.end(), s) != w.end())
        {
            cout << "No" << endl;
            return 0;
        }
        prev = s;
        w.push_back(s);
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

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

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

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

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

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

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

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

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

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

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

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

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()

	var ans int
	for i := 1; i <= n; i += 2 {
		var count int
		for j := 1; j <= i; j++ {
			if i%j == 0 {
				count++
			}
		}
		if count == 8 {
			ans++
		}
	}
	println(ans)

}


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

using namespace std;

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


Measured memory_bytes: 256