akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n; cin >> n; ll a[n], an1=0, an2=0, allxor=0;

  for(int i=0; i<n; i++) {
    cin >> a[i]; allxor ^= a[i];
  }
  
  /*
  for(int i=0; i<n; i++) {
    for(ll j=59; j>=0; j--) {
      printf("%d",(a[i]&(1ll<<j))>0);
    } printf("\n");
  }printf("\n");

  for(ll j=59; j>=0; j--) {
      printf("%d",(allxor&(1ll<<j))>0);
  } printf("\n\n"); */

  for(int i=0; i<n; i++) a[i] &= ~allxor;
  ll ans = 0, p=0, k=0;
  for(ll i=59; i>=0; i--) {
    for(k=p; k<n; k++) if (a[k]&(1ll<<i)) break;
    if (k==n) continue;
    //cout << "a"<<i;
    if (k!=p) a[p]^=a[k];
    for(ll l=p+1; l<n; l++) a[l]=min(a[l],a[l]^a[p]); p++;
  }

  /*
  for(int i=0; i<n; i++) {
    for(ll j=59; j>=0; j--) {
      printf("%d",(a[i]&(1ll<<j))>0);
    } printf("\n");
  }*/

  for(int i=0; i<n; i++) ans=max(ans,ans^a[i]);
  ans = ans * 2 + allxor;;
  cout<<ans<<endl;
  //cout << an1 + an2 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void){
    int i,n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;
 
    scanf("%d",&n);
     
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(i=0;i<n;i++)
        scanf("%d",&y[i]);
     
    for(i=0;i<n;i++){
         
    //p=1
        p_1 += abs(x[i]-y[i]);
     
    //p=2
        p_2 += pow(fabs((double)x[i]-y[i]),2.0);
     
    //p=3
        p_3 += pow(fabs((double)x[i]-y[i]),3.0);
     
    //p=endless
        if(p_0 < abs(x[i]-y[i])) p_0 = abs(x[i]-y[i]);
         
    }
     
    printf("%lf\n%lf\n%lf\n%lf\n", p_1, pow(p_2,1.0/2), pow(p_3,1.0/3), p_0);
     
     
    return 0;
}


Measured memory_bytes: 2112
from collections import deque
import sys

class doubly_linked_list():
    def __init__(self):
        #self.linked_list = []
        self.linked_list = deque([])
        #self.length = 0
    
    def insert(self, x):
        #self.linked_list.insert(0,x)
        self.linked_list.appendleft(x)
        #self.length += 1
    
    def delete(self, x):
        # 削除するのは、最初の要素だけでよい
        if x in self.linked_list:
            self.linked_list.remove(x)
            #self.length -= 1
    
    def delete_first(self):
        #if len(self.linked_list) != 0:
        #if self.length != 0:
            #self.linked_list.pop(0)
        self.linked_list.popleft()
            #self.length -= 1
    
    def delete_last(self):
        #if len(self.linked_list) != 0:
        #if self.length != 0:
            #self.linked_list.pop(self.length-1)
        self.linked_list.pop()
            #self.length -= 1

def get_method_and_run(cls, myinput):
    # 入力の受付
    #tmp = input()
    tmp = myinput().rstrip('\n')
    if tmp.find(" ") == -1:
        method = tmp
    else:
        method, x = tmp.split(" ")
    
    # 入力に従い、処理を実行
    if method == "insert":
        cls.insert(x)
    elif method == "delete":
        cls.delete(x)
    elif method == "deleteFirst":
        cls.delete_first()
    elif method == "deleteLast":
        cls.delete_last()
    else:
        pass

if __name__ == "__main__":
    myinput = sys.stdin.readline
    #n = int(input())
    n = int(myinput().rstrip('\n'))
    dll = doubly_linked_list()  
    [ get_method_and_run(dll, myinput) for i in range(n)]
    print(" ".join(dll.linked_list))




Measured memory_bytes: 77544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int cnt = 0;
    int len = s.size();
    rep(i, len / 2)
    {
        if (s[i] != s[len - 1 - i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{
			  String ab;
			  String[] strAry;
			  int a;
			  int b;
			  int num;
             
			  while(true){
			      ab = input.readLine();
			      strAry = ab.split(" ");
		          a=Integer.parseInt(strAry[0]);
		          b=Integer.parseInt(strAry[1]);

		          if(a==0&&b==0){
		        	  break;
		          }

		          if(a>b){
		        	  num=a;
		        	  a=b;
		        	  b=num;
		        	 
		          }
		          System.out.println(a+" "+b);
			  }

		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }


	}


}

Measured memory_bytes: 27108
n = 0
arr = []
5.times.each do
    n = gets.chomp.to_i
    arr << n
end

arr.sort! { |a, b| (b - 1) % 10 - (a - 1) % 10 }

s = 0
arr.each do |n|
    mod = s % 10
    s += 10 - mod if mod != 0
    s += n
end

puts s

Measured memory_bytes: 14372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define str string
#define pb push_back
#define vc vector
#define ci cin
#define co cout
// remove fropen in online judge
int main()
{ 
	

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)
    	cout<<"ACL";
    
    
}


Measured memory_bytes: 3640
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

ll f[NMAX*2];
    
ll pow(ll a, ll b, ll MOD)
{
    ll x=1,y=a; 
    while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
    return x;
}
    
/* Modular Multiplicative Inverse
    Using Euler's Theorem
    a^(phi(m)) = 1 (mod m)
    a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
    return pow(n,MOD-2,MOD);
}
    
ll C(ll n, ll r, ll MOD)
{
    
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
    

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

	int n,k;
	cin >> n >> k;

	f[0]  = 1;
	for(int i= 1; i< NMAX*2; ++i)
	{
		f[i] = (f[i-1] * i) % MOD;
	}


	ll ans = C(2*n -1, n- 1,MOD);

	for(++k; k <= n -1; ++k)
	{
		ans = (ans + MOD - C(n,k,MOD)* C(n-1,k,MOD)% MOD)%MOD;
	}

	cout << ans;


    return 0;
}

Measured memory_bytes: 16000
//b.c B-Grid Compression
#include<stdio.h>
#include<stdbool.h>
typedef struct{
    bool flag;
    char buf[101];
    int check[101];
}grid;

int main(void){
    int h,w;
    scanf("%d %d",&h,&w);
    grid at[h];
    for(int i=0;i<h;++i){
        scanf("%s",at[i].buf);
    }

    for(int i=0;i<h;++i){
        bool flag = false;
        for(int j=0;j<w;++j){
            if(at[i].buf[j]=='#'){
                at[i].check[j] = 1;
                flag = true;
            }else{
                at[i].check[j] = 0;
            }
        }
        at[i].flag = flag;
    }

    bool hu[w];
    for(int i=0;i<w;++i){
        bool flag = false;
        for(int j=0;j<h;++j){
            if(at[j].check[i]==1){
                flag = true;
            }
        }
        hu[i] = flag;
    }

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(at[i].flag == true && hu[j]==true){
                printf("%c",at[i].buf[j]);
            }
        }
        putchar('\n');
    }
    return 0;
}

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

using namespace std;

int main() {
    int ans = 1e9 + 1, cnt;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < (int)s.size() - (int)t.size() + 1; i++) {
        cnt = 0;
        for(int j = i; j < i + (int)t.size(); j++) {
            if(s[j] != t[j - i]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import scala.io.StdIn

case class Expr(l:Int, op: String, r:Int)

object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foreach{
      line =>
        if(line.trim.isEmpty == false){
          val inputs = line.split(" ")
            Expr(inputs(0).toInt, inputs(1), inputs(2).toInt) match {
              case Expr(l, "+", r) => println(l + r)
              case Expr(l, "-", r) => println(l - r)
              case Expr(l, "*", r) => println(l * r)
              case Expr(l, "/", r) => println(l / r)
              case _ =>
            }
        }
    }
  }
}

Measured memory_bytes: 43920
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 3005
using namespace std;
typedef long long ll;
ll n, top, a[N], dp[2][N][N];

ll f(ll bas, ll son, ll d){
	ll &r = dp[d][bas][son];
	if(son < bas)
		return 0;
	if(r != -1)
		return r;
	if(d){
		r = max(a[bas] + f(bas + 1, son, 0), a[son] + f(bas, son - 1, 0));
	}else{
		r = min(-a[bas] + f(bas + 1, son, 1), -a[son] + f(bas, son - 1, 1));
	}
	return r;

}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld",&n);
	for(ll i = 1; i <= n; i++){
		scanf("%lld", a + i);
		top += a[i];
	}
	printf("%lld\n", f(1, n, 1));
	return 0;
}

Measured memory_bytes: 141440
n = int(input())
list1 = list(map(int,input().split()))
for i in range(0,n):
    v = list1[i]
    for j in range(i,-1,-1):
        if list1[j] > v:
            tmp = list1[j]
            list1[j] = v
            list1[j+1] = tmp
            
    for m in range(n):
        if m == n-1:
            print(list1[m])
        else:
            print(list1[m],end=' ')



Measured memory_bytes: 5976
read a b c d e

[ $a -eq 0 ] && { echo 1; exit; }
[ $b -eq 0 ] && { echo 2; exit; }
[ $c -eq 0 ] && { echo 3; exit; }
[ $d -eq 0 ] && { echo 4; exit; }
[ $e -eq 0 ] && { echo 5; exit; }


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

int main(){
    string s;
    cin >> s;
    bool ans = true;

    for (int i = 0;i < 4;i++){
        int count = 0;
        for (int j = 0;j < 4;j++){
            if (i == j){
                continue;
            }
            if (s[i] == s[j]){
                count++;
            }


        }
        if (count != 1){
            ans = false;
            break;
        }
    }
    if (ans){
        cout << "Yes" << endl;
    }
    else {
        cout <<"No" << endl;
    }
}

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

using ll  = long long;
#define int ll


signed main() {
	vector<int>dp(51, 1LL), dp2(51, 1LL);
	int n, x; cin >> n >> x;
	for (int i = 1; i < dp.size(); ++i) {
		dp[i] = dp[i - 1] + dp[i - 1] + 3;
		dp2[i] = dp2[i - 1] + dp2[i - 1] + 1;
	}
	function<int(int, int)>cal = [&](int i, int x) -> int {
		if (i == 0) { return x > 0; }
		return (x >= dp[i - 1] + 2 ? dp2[i - 1] + 1 + cal(i - 1, x - dp[i - 1] - 2) : cal(i - 1, x - 1));
	};
	cout << cal(n, x) << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)[::-1]
if N==1:
  print(0)
  exit()
if N==2:
  print(A[0])
  exit()
  
A.append(0)
d=A[0]
D=[]
cnt=1
for i in range(N):
  if d==A[i+1]:
    cnt+=1
  else:
    D.append((d,cnt))
    cnt=1
    d=A[i+1]
ans=0
nokori=N
for a,b in D:
  if b*2<=nokori:
    ans+=a*b*2
    nokori-=b*2
  else:
    ans+=nokori*a
    nokori=0
print(ans-A[0])
      
  

Measured memory_bytes: 32476
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
const int B = 1<<17;
 
struct SegmentTree{
	struct vd{
		int v;
		int delay;
		vd():v(0),delay(0){}
	} data[B*2];
	int s;
	void Initialize(int size){
		s=1;
		while(s<size) s<<=1;
	}
	inline void PassDelay(int idx){
		data[idx*2].delay += data[idx].delay;
		data[idx*2+1].delay += data[idx].delay;
		data[idx].delay = 0;
	}
	int b;
	int e;
	int val;
	inline void Update(int idx){
		data[idx].v = max(data[idx*2].v+data[idx*2].delay,data[idx*2+1].v+data[idx*2+1].delay);
	}
	inline void _add(int l,int r,int idx){
		if(e<=l||r<=b)
			return;
		if(b<=l&&r<=e){
			data[idx].delay += val;
			return;
		}
		PassDelay(idx);
		_add(l,(l+r)/2,idx*2);
		_add((l+r)/2,r,idx*2+1);
		Update(idx);
	}
	inline void Add(int _b,int _e,int _val){
		if(_e<=_b)
			return;
		b=_b;
		e=_e;
		val=_val;
		_add(0,s,1);
	}
	inline int GetMax(){
		return data[1].v+data[1].delay;
	}
} seg;
 
struct BinaryIndexedTree{
	int s;
	int data[B];
	void Initialize(int size){
		s=size;
	}
	inline void Add(int idx,int val){
		while(idx<s){
			data[idx]+=val;
			idx += (idx+1)&(-idx-1);
		}
	}
	inline int Get(int idx){
		int ret=0;
		while(idx>=0){
			ret += data[idx];
			idx -= (idx+1)&(-idx-1);
		}
		return ret;
	}
} bit;
 
int as[B];
int bra[B];
int bri[B];
int lbs[B][3];
 
struct ai{
	int a;
	int idx;
	bool operator<(const ai& rhs)const{
		return (a<rhs.a||(a==rhs.a&&idx<rhs.idx));
	}
} srt[B];
 
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&as[i]);
	
	bool sorted=true;
	bool twice=false;
	for(int i=1;i<n;i++){
		if(as[i-1]>as[i])
			sorted=false;
		if(as[i-1]==as[i])
			twice=true;
	}
	if(sorted){
		if(twice)
			printf("0\n");
		else
			printf("1\n");
		return 0;
	}
		
	int brc=0;
	int last=1145141919;
	for(int i=n-1;i>=0;i--)
		if(as[i] < last){
			brc++;
			last = as[i];
		}
	int brn=brc;
		
	seg.Initialize(brn);
	
	last = 1145141919;
	for(int i=n-1;i>=0;i--)
		if(as[i] < last){
			bra[--brc] = as[i];
			bri[brc] = i;
			last = as[i];
		}
		
	for(int i=0;i<n;i++){
		lbs[i][0] = lower_bound(bri,bri+brn,i+1)-bri;
		lbs[i][1] = lower_bound(bra,bra+brn,as[i])-bra;
		lbs[i][2] = lower_bound(bra,bra+brn,as[i]+1)-bra;
	}
	
	for(int i=0;i<n;i++)
		srt[i] = ai{as[i],i};
	sort(srt,srt+n);
	
	bit.Initialize(n);
	ll sum=0;
	for(int i=n-1;i>=0;i--){
		sum += bit.Get(srt[i].idx);
		bit.Add(srt[i].idx,1);
	}
	
	int v=0;
	int h=0;
	int g=0;
	int ans=0;
	for(int i=0;i<n;i++){
		if(i==0||as[v]<as[i]){
			while(v<i){
				seg.Add(lbs[v][0],lbs[v][1],-1);
				seg.Add(lbs[v][0],lbs[v][2],-1);
				v++;
			}
			while(h<n&&srt[h].a<=as[i]){
				seg.Add(lbs[srt[h].idx][0],lbs[srt[h].idx][1],1);
				h++;
			}
			while(g<n&&srt[g].a<as[i]){
				seg.Add(lbs[srt[g].idx][0],lbs[srt[g].idx][2],1);
				g++;
			}
			ans = max(ans,seg.GetMax());
		}
	}
	
	printf("%lld\n",sum-ans);	
}

Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, m;
    cin >> n >> m;
    int ans = 1;
    if(n == 1){
        cout << m << endl;
    }else{
        int k = m/n + 1;
        for(int i=2; i<=k; i++){
            if(m%i == 0){
                if(m/i >= n) ans = i;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(void){
  int numOfYen[3];//0:500yen 1:100yen 2:50yen                                   
  int i,j,k;
  for(i = 0;i<3;i++){
    scanf("%d",&numOfYen[i]);
  }

  int sumX;
  int way = 0;
  scanf("%d",&sumX);
  for(i = 0;i <= numOfYen[0];i++){//500                                         
    for(j = 0;j <= numOfYen[1];j++){//100                                       
      for(k = 0;k <= numOfYen[2];k++){//50                                      
        int sumYen = i*500 + j*100 + k*50;
        if(sumX == sumYen) way++;
      }
    }
  }
  printf("%d\n",way);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

vector<int> dx = {0, 0, 1, -1};
vector<int> dy = {1, -1, 0, 0};

int n, m;
vector<vector<int>> a;

int get(int i, int j) {
    return i * m + j;
}

int ok(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}

int bfs() {
    queue<int> q;
    vector<int> d(n * m, n * m + 1);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i][j]) {
                d[get(i, j)] = 0;
                q.push(get(i, j));
            }
        }
    }
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        int i = v / m;
        int j = v % m;
        for (int k = 0; k < 4; k++) {
            int ni = i + dx[k];
            int nj = j + dy[k];
            if (ok(ni, nj) && d[get(ni, nj)] > d[v] + 1) {
                d[get(ni, nj)] = d[v] + 1;
                q.push(get(ni, nj));
            }
        }
    }
    return *max_element(d.begin(), d.end());
}

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

    cin >> n >> m;
    a.resize(n, vector<int> (m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            a[i][j] = (c == '#');
        }
    }
    cout << bfs() << endl;
}   


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

int main() {
    int n; cin >> n;
    int l[100001] = {0};

    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        l[a]++;
    }
    int ans = 0;
    for (int i = 0; i < 99999; i++) {
        ans = max(ans, l[i] + l[i + 1] + l[i + 2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int n, a[51], b[51], c[51];
ll v[60][60];
ll d[60][60];

bool use[60];

void warshall_floyd()
{

    for (int i = 0; i <= 50; i++)
        for (int j = 0; j <= 50; j++)
            d[i][j] = INT_MAX;

    for (int i = 0; i <= 50; i++)
        for (int j = 1; j <= 50; j++)
            if (use[j])
                d[i][i % j] = 1;

    for (int k = 0; k <= 50; k++)
        for (int i = 0; i <= 50; i++)
            for (int j = 0; j <= 50; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

    cin >> n;
    REP(i, n)
    cin >> a[i];
    REP(i, n)
    cin >> b[i];

    fill(use, use + 51, true);

    bool check = true;
    REP(i, n)
    if (a[i] != b[i])
        check = false;
    if (check)
    {
        cout << 0 << endl;
        return 0;
    }

    warshall_floyd();
    REP(i, n)
    {
        if (d[a[i]][b[i]] >= INT_MAX)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    memset(v, -1, sizeof(v));

    for (int i = 0; i <= 50; i++)
        for (int j = 0; j <= 50; j++)
            v[i][j] = INT_MAX;

    for (int i = 1; i <= 50; i++)
        for (int j = 1; j <= 50; j++)
        {
            v[i][i % j] = 1;
        }

    ll res = 0;

    for (int i = 50; i >= 1; i--)
    {
        use[i] = false;

        warshall_floyd();

        bool check = false;

        for (int j = 0; j < n; j++)
        {
            if (d[a[j]][b[j]] >= INT_MAX)
                check = true;
        }

        if (check)
        {
            use[i] = true;
            res += check * (1LL << i);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a, q, l;



int32_t main(){
INIT
cin>>a;
string s;
cin>>s;
int b=0;
b+=(s[3]-'0')+10*(s[2]-'0')+100*(s[0]-'0');
a=a*b;
a/=100;
cout<<a;

return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  int k;
  int q;
  int point[100005]={0};
  cin>>n;
  cin>>k>>q;
  
  int need=q-k+1;
  for(int i=0;i<q;i++){
    int result;
    cin>>result;
    point[result-1]++;
  }
  
  for(int i=0;i<n;i++){
    if(point[i]>=need){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return(0);
}


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

#define MOD_1000000007 (1000000007LL)
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i, n) for (long long i = 1; i < (long long)(n); i++)
#define rep0c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)

using namespace std;
typedef long long ll;

ll N, as[100010], rain[100010];

ll dfs(ll l, ll r) {
  if(l+1==r) return 2*as[l];
  return 2*(as[l]+as[r-1]) - dfs(l+1, r-1);
}

void solve() {
  rain[0] = (2*(as[0]+as[N-1]) - dfs(1, N-1))/2;
  printf("%lld", rain[0]);
  rep1(i, N) {
    rain[i] = 2*as[i-1]-rain[i-1];
    printf(" %lld", rain[i]);
  }
  printf("\n");
}

int main() {
  scanf("%lld", &N);
  rep(i, N) scanf("%lld", &as[i]);
  solve();
  return 0;
}

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

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

    
    int ans=n,a=0,b=0;
    // a=>1010...
    // b=>0101...
    rep(i,n){
        if(i&1){
            if(s[i]=='1')a++;
            else b++;
        }else{
            if(s[i]=='0')a++;
            else b++;
        }

    }
    ans=min(a,b);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
    char s[101],t[101];
    int k,i=0,j=0;
    scanf("%d%s",&k,s);
    while((s[i]!='\0')&&(i<k)){
        t[i]=s[i];
        i++;
    }
    if(s[i]!='\0'){
        for(j=0;j<3;j++){
            t[i]='.';
            i++;
        }
    }
    t[i]='\0';
    printf("%s\n",t);
    return 0;
}

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

typedef long long LL;

const int N=200000,M=50;

int n;
LL a[N+9];
int c[N+9][2];
int cnt[M+9][M+9];

void work(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	double x;
	scanf("%lf",&x);
	a[i]=(LL)(1000000000.0*x+0.5);
	for (;a[i]&1^1;a[i]>>=1) ++c[i][0];
	for (;a[i]%5==0;a[i]/=5) ++c[i][1];
  }
  LL ans=0;
  for (int i=1;i<=n;++i){
	int x=max(18-c[i][0],0),y=max(18-c[i][1],0);
	for (int j=x;j<=M;++j)
	  for (int k=y;k<=M;++k) ans+=cnt[j][k];
    ++cnt[c[i][0]][c[i][1]];
  }
  printf("%lld\n",ans);
}

int main(){
  int T=1;
  //scanf("%d",&T);
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 6948
import itertools
p=list()
p.append(int(input()))
p.append(int(input()))
p.append(int(input()))
p.append(int(input()))
p.append(int(input()))
k=int(input())
c=list(itertools.combinations(p,2))
d=list()
for i in range(len(c)):
  d.append(c[i][1]-c[i][0])
if max(d)>k:
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll K,A,B; cin >> K >> A >> B;
    for(ll a = 1; a <= 1000; a++){
        if(A <= a*K && a*K <= B) return "OK";
    }
    return "NG";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 3652
fn read<T: std::str::FromStr>() -> T{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {
    let ab = read_vec::<f32>();
    let a = ab[0];
    let b = ab[1];

    let x = (a+b) / 2.0;

    println!("{}",x.ceil());
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int N, K;
vector<int>G[10];
vector<int>Gsum[10];
int dp[10][2000];
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++){
		int A, B;
		scanf("%d%d", &A, &B);
		G[B - 1].push_back(A);
	}
	for (int i = 0; i < 10; i++){
		sort(G[i].begin(), G[i].end());
		reverse(G[i].begin(), G[i].end());
	}
	for (int i = 0; i < 10; i++){
		Gsum[i].push_back(0);
		
		for (int j = 0; j < G[i].size(); j++){
			int sum = 0;
			for (int k = 0; k <= j; k++){
				sum += G[i][k];
			}
			sum += (j + 1)*j;
			if (G[i].size()>0)Gsum[i].push_back(sum);
		}
	}
	for (int j = 0; j <= min(K, (int)Gsum[0].size() - 1); j++)dp[0][j] = Gsum[0][j];
	for (int i = 1; i < 10; i++){
		for (int j = 0; j <= K; j++){
			int dpij = 0;
			for (int k = 0; k <= min(j, (int)Gsum[i].size()-1);k++){
				dpij = max(dpij,dp[i - 1][j - k] + Gsum[i][k]);
			}
			dp[i][j] = dpij;
		}
	}
	
	int ans = 0;
	for (int i = 0; i <= K; i++)ans = max(ans, dp[9][i]);
	printf("%d\n", ans);
}

Measured memory_bytes: 1312
#include "iostream"
#include "algorithm"
using namespace std;
int main(void)
{
	int n,m;
	while (cin>>n>>m,n) {
		pair<int,int> p[m];
		for (int i = 0; i < m; i++) {
			p[i]=make_pair(n,i+1);
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int in; cin>>in;
				p[j].first-=in;
			}
		}

		sort(p,p+m);
		for (int i = 0; i < m; i++) {
			if(i!=0) cout<<" ";
			cout<<p[i].second;
		}
		cout<<endl;
	}
	return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 5005;

int n, P, w[N], f[N];

int main() {
	read(n), read(P);
	int k = (n - 1) / 2;
	for (int i = 2; i <= k + 2; ++i) {
		w[i] = 2 - i;
	}
	for (int i = n - k + 1; i <= n; ++i) {
		w[i] = i - 1 - n;
	}
	for (int i = 2; i <= n; ++i) {
		w[i] = 1 - w[i];
	}
	f[0] = 1;
	for (int i = 2; i <= n; ++i) {
		for (int j = w[i]; j <= n; ++j) {
			f[j] = (f[j] + f[j - w[i]]) % P;
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		ans = (ans + 1ll * (n - i) * f[i]) % P;
	}
	print(ans);
}


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


int main(){
  int N,K;
  cin >> N >> K;
  int i,sum;
  sum = 1;
  for(i=0;i<N;i++){
    if(sum * 2 > sum + K) sum += K;
    else sum *= 2;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
int main(void)
{
    int n, v, i, j, k;
    int a[MAX];

    scanf("%d", &n);
    for(i=0;i<n;i++)
        scanf("%d", &a[i]);
    for(k=0;k<n-1;k++)
        printf("%d ", a[k]);
    printf("%d\n", a[k]);

    for(i=1;i<n;i++)
    {
        v=a[i];
        for(j=i-1;j>=0;j--)
        {
            if(a[j]>v) a[j+1]=a[j];
            else break;
        }
        a[j+1]=v;

        for(k=0;k<n-1;k++)
            printf("%d ", a[k]);
        printf("%d\n", a[k]);
    }

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200001;
ll dp[N][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,0,sizeof(dp));
    int n,w; ll m = 0; cin>>n>>w; int a[n+1][2]; dp[0][0] = 1;
    for(int i = 1; i <= n; ++i) cin>>a[i][0]>>a[i][1];
    for(int i = 1; i <= n; ++i) {
        for(int j = w; j >= 1; --j) {
            if(j >= a[i][0] && dp[j-a[i][0]][0]) {
                dp[j][0] = 1;
                dp[j][1] = max(dp[j][1],dp[j-a[i][0]][1]+a[i][1]);
            }
        }
    }
    //for(int i = 0; i <= w; ++i)
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<"\n";
    for(int i = 0; i <= w; ++i) m = max(m,dp[i][1]);
    cout<<m<<"\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long ll;

struct UnionFind {
  int N;
  vector<int> par;   // par[i] :iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;  // rank[i]:iの深さ
  vector<int> sizes; // sizes[i]:iが属する連結成分のサイズ
  UnionFind(int n) : N(n), par(n), rank(n), sizes(n) { //最初は全てが根として初期化
    for(int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      sizes[i] = 1;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

    sizes[rx] = sizes[ry] = (sizes[rx] + sizes[ry]);
    if (rank[rx] < rank[ry]) {
      par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    } else {
      par[ry] = rx;
      if (rank[rx] == rank[ry]) rank[rx]++;
    }
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }

  int size(int x) {
    return sizes[root(x)];
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(M), B(M);
  for (int i=0; i<M; ++i) cin >> A[i] >> B[i];

  vector<ll> ret(M+1);
  UnionFind tree(N);
  ret[M] = (ll)N*(N-1)/2;
  for (int i=M-1; i>=0; --i) {
    int x = A[i]-1;
    int y = B[i]-1;
    ret[i] = ret[i+1];
    if (!tree.same(x,y)) ret[i] -= tree.size(x)*tree.size(y);
    tree.unite(x,y);
  }

  for (int i=1; i<=M; ++i) {
    cout << ret[i] << endl;
  }
}


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

using namespace std;

int dp[100][100];
int main() {
    string s; cin>>s;
    string t = "ATGC";
    int cnt = 0 , mx = 0;
    for(char c : s){
        if(t.find(c) != string::npos){
            cnt++;
        }else{
            mx = max(mx , cnt);
            cnt = 0;
        }
    }
    cout<<max(cnt, mx)<<endl;
}


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

int find_sum(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main()
{
    int N;
    cin>>N;
    int sum = find_sum(N);
    if(!(N%sum))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  bool ans = false;

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k - i; j++) {
      int l = k - i - j;
      int tmp_a = pow(2, i) * a;
      int tmp_b = pow(2, j) * b;
      int tmp_c;
      if (l < 0) {
        tmp_c = c;
      } else {
        tmp_c = pow(2, l) * c;
      }
      if (tmp_a < tmp_b && tmp_b < tmp_c) {
        ans = true;
        break;
      }
    }
    if (ans) break;
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 4024
// Problem : A - Coffee
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int main() {
	string s; cin >> s;
	if (s[3] == s[2] && s[5] == s[4]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define M 400005
#define ll long long
using namespace std;
const int p = 1000000007;
const int ni = 500000004;
int head[N],ver[M],nxt[M],tot,quan[M];
void add(int a,int b,int c)
{
	tot++;nxt[tot]=head[a];head[a]=tot;ver[tot]=b;quan[tot]=c;
}
int n,m,s,t;
ll dis1[N],f1[N],dis2[N],f2[N];
int q1[N],q2[N],in[N];
queue<int>q;
bool cmp1(int x,int y)
{
	return dis1[x]<dis1[y];
}
bool cmp2(int x,int y)
{
	return dis2[x]<dis2[y];
}
void spfa()
{
	memset(dis1,0x3f,sizeof(dis1));
	memset(dis2,0x3f,sizeof(dis2));
	dis1[s]=0;f1[s]=1;q.push(s);
	while(!q.empty())
	{
		int tmp=q.front();q.pop();
		in[tmp]=0;
		for(int i=head[tmp];i;i=nxt[i])
		{
			if(dis1[ver[i]]>dis1[tmp]+quan[i])
			{
				dis1[ver[i]]=dis1[tmp]+quan[i];
				if(!in[ver[i]])
				{
					in[ver[i]]=1;
					q.push(ver[i]);
				}
			}
		}
	}
	for(int i=1;i<=n;i++)q1[i]=i;
	sort(q1+1,q1+n+1,cmp1);
	for(int i=1;i<=n;i++)
	{
		for(int j=head[q1[i]];j;j=nxt[j])
		{
			if(dis1[ver[j]]==dis1[q1[i]]+quan[j])
			{
				(f1[ver[j]]+=f1[q1[i]])%=p;
			}
		}
	}
	
	
	dis2[t]=0;f2[t]=1;q.push(t);
	while(!q.empty())
	{
		int tmp=q.front();q.pop();
		in[tmp]=0;
		for(int i=head[tmp];i;i=nxt[i])
		{
			if(dis2[ver[i]]>dis2[tmp]+quan[i])
			{
				dis2[ver[i]]=dis2[tmp]+quan[i];
				if(!in[ver[i]])
				{
					in[ver[i]]=1;
					q.push(ver[i]);
				}
			}
		}
	}
	for(int i=1;i<=n;i++)q1[i]=i;
	sort(q1+1,q1+n+1,cmp2);
	for(int i=1;i<=n;i++)
	{
		for(int j=head[q1[i]];j;j=nxt[j])
		{
			if(dis2[ver[j]]==dis2[q1[i]]+quan[j])
			{
				(f2[ver[j]]+=f2[q1[i]])%=p;
			}
		}
	}
	
	ll ans=f1[t]*f1[t]%p;
//	cout<<ans<<endl;

	for(int i=1;i<=n;i++)
	{
		if(dis1[i]==dis2[i])ans=(ans-f1[i]*f1[i]%p*f2[i]%p*f2[i]%p+p)%p;
		for(int j=head[i];j;j=nxt[j])
		{
			if(dis1[ver[j]]==dis1[i]+quan[j]&&dis1[i]+dis2[ver[j]]+quan[j]==dis1[t])
			{
				if(dis1[i]<dis2[i]&&dis2[ver[j]]<dis1[ver[j]])
				{
					ans=(ans-f1[i]*f2[ver[j]]%p*f1[i]%p*f2[ver[j]]%p+p)%p;
				}
			}
		}
	}
	cout<<(ans%p+p)%p<<endl;
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&s,&t);
	int t1,t2,t3;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&t1,&t2,&t3);
		add(t1,t2,t3);add(t2,t1,t3);
	}
	spfa();
	return 0;
}

Measured memory_bytes: 13056
def comb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

appeared = set()
dup_right = 0
dup = 0
for i, x in enumerate(a):
    if x in appeared:
        dup_right = n - i
        dup = x
        break
    appeared.add(x)
dup_left = 0
for i, x in enumerate(a):
    if x == dup:
        dup_left = i
        break

for k in range(1, n + 2):
    print((comb(n + 1, k, MOD) - comb(dup_right + dup_left, k - 1, MOD)) % MOD)


Measured memory_bytes: 213184
using System;

class P  {
    public int x, y;
    public P(int x, int y){
        this.x = x; this.y = y;
    }
    
}

class Program {
    static void Main(string[] args){
        int N = int.Parse(Console.ReadLine());
        P[] a = new P[N];
        for(int i=0;i<N;i++){
            a[i] = new P(int.Parse(Console.ReadLine()),i);
        }
        Array.Sort(a, (a1,b1)=>a1.x-b1.x);
        int calc = 0;
        for(int i=0;i<N;i+=2){
            calc += (a[i].y+i)%2;
        }
        Console.WriteLine(calc);
    }
}

Measured memory_bytes: 9304
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	UL N;
	vector<UL> A;

	bool Loop(UL K) {
		if (K == 1) {
			bool ok = true;
			rep(i, N - 1) if (A[i] >= A[i + 1]) ok = false;
			return ok;
		}
		vector<pair<UL, UL>> C;
		C.push_back({ 0, 0 });
		rep(i, N) {
			//rep(j, C.size()) { cout << "{" << C[j].first << "," << C[j].second << "}" << ","; }
			//cout << endl;
			if (C.back().first < A[i]) { C.push_back({ A[i], 0 }); continue; }
			while (C.back().first > A[i]) C.pop_back();
			if (C.back().first < A[i]) { C.push_back({ A[i], 1 }); continue; }
			UL p = C.back().first;
			while (true) {
				if (C.back().first != p) { C.push_back({ p, 1 }); break; }
				C.back().second++;
				if (C.back().second != K) break;
				if (p == 1) {
					//cout << "NG : K = " << K << endl;
					return false;
				}
				C.pop_back();
				p--;
			}
		}
		//rep(j, C.size()) { cout << "{" << C[j].first << "," << C[j].second << "}" << ","; }
		//cout << endl;
		//cout << "OK : K = " << K << endl;
		return true;
	}

	void Solve() {
		cin >> N;
		A.resize(N); rep(i, N) cin >> A[i];
		UL l = 0, r = N;
		while (l + 1 < r) {
			UL m = (l + r + 1) >> 1;
			//cout << "ATTEMPT : K = " << m << endl;
			if (Loop(m)) r = m; else l = m;
		}
		cout << r << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 4692
import math
import sys
input = sys.stdin.readline
N, D, A = [int(i) for i in input().split()]
Mons = []
for _ in range(N):
    x, h = map(int, input().split())
    Mons.append([x, h, 0])


Mons.sort(key=lambda x: x[0])
ans = 0
idx = 0
d = 0

for i, M in enumerate(Mons):
    x = M[0]+D*2+1
    d -= M[2]
    ac = math.ceil(max(M[1]-d, 0)/A)
    ans += ac
    d += ac*A
    l = i
    r = N
    while l < r-1:
        m = (l+r)//2
        if m >= N:
            break
        elif Mons[m][0] < x:
            l = m
        else:
            r = m
    else:
        if r < N and Mons[r][0] >= x:
            Mons[r][2] += ac*A
print(ans)


Measured memory_bytes: 112404
#include <bits/stdc++.h>
using namespace std;
#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)
string rev(string s){
	reverse(s.begin(),s.end());
	return s;
}
int main(){
	int m;
	cin>>m;
	while(m--){
		string str;
		cin>>str;
		set<string> S;
		for(int i = 0;i < str.size()-1;i++){
			string t = "";
			for(int j = 0;j <= i;j++){
				t += str[j];
			}
			string T = "";
			for(int j = i+1;j < str.size();j++){
				T += str[j];
			}
			S.insert(t+T);
			S.insert(T+t);
			S.insert(rev(t)+T);
			S.insert(t+rev(T));
			S.insert(rev(t)+rev(T));
			S.insert(rev(T)+t);
			S.insert(T+rev(t));
			S.insert(rev(T)+rev(t));

		}
		cout<<S.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1308
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

if N == 1:
	x = A[0]
else:
	a = A[0]
	for i in range(N - 1):
		b = A[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	x = a

if K % x == 0 and max(A) >= K:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Measured memory_bytes: 14100
while (1):
    a, op, b = map(str, input().split())

    if op == '?':
        exit()
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))



Measured memory_bytes: 5596
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr=0;
	double sum=0.0;
	while(n--)
	{
		cin>>arr;
		sum+=1/(double)arr;
	}
	sum=1/sum;
	cout<<sum<<"\n";
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

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

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

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> t(n);
  for (int i = 0; i < n; i++){
    cin >> t[i];
  }
  if (n == 1){
    cout << t[0] << endl;
  }
  else {
    ll l = lcm(t[0], t[1]);
    for (int i = 2; i < n; i++){
      l = lcm(l, t[i]);
    }
    cout << l << endl;
  }


  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define SIN(x) sin(x * pi / 180.0)
#define COS(x) cos(x * pi / 180.0)
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


ll ar[sz];

ll bigmod(ll a, ll b, ll m)
{
  if(b==0) return 1;
 
  ll x=bigmod(a,b/2,m);
  x=(x*x)%m;
  if(b%2==1)x=(x*a)%m;
 
  return x;
}

int main()
{
  fastio;
  ll  ans=0, i, n, res=0, sum=0, r;
  
  cin>>n;
  for(i=1; i<=n; i++)
  {
  cin>>ar[i];
  sum=(sum+ar[i])%mod;
  r=(ar[i]*ar[i])%mod;
  ans=(ans+r)%mod;
  }
  sum=bigmod(sum,2,mod);
  res=(sum-ans+mod)%mod;
  res=(res*bigmod(2,mod-2,mod))%mod;
  cout<<res<<endl;
}


Measured memory_bytes: 5176
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << c + b - d << " " << d - a + c << " " << a + b - d << " " << b + c - a << endl;
}

Measured memory_bytes: 3560