akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i;
	string str,str2;
	cin >> str;
	for(int i=2;i>=0;i--)
		str2 += str[i];
	if(str == str2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 256
import collections
import sys
def input() : return sys.stdin.readline().strip()
h,w,m = map(int,input().split())
X = []
Y = []
for _ in range(m):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)

most_common_x = collections.Counter(X).most_common()
most_common_x_index = most_common_x[0][0]
most_common_x_count = most_common_x[0][1]
most_common_y = collections.Counter(Y).most_common()
most_common_y_index = most_common_y[0][0]
most_common_y_count = most_common_y[0][1]

otherwisey = []
otherwisex = []
for i in range(m):
    if X[i] != most_common_x_index:
        otherwisey.append(Y[i])
    if Y[i] != most_common_y_index:
        otherwisex.append(X[i])

most_common_y = collections.Counter(otherwisey).most_common()
if len(most_common_y)!= 0:
    ansx = most_common_y[0][1] + most_common_x_count
else:
    ansx = most_common_x_count

most_common_x = collections.Counter(otherwisex).most_common()
if len(most_common_x)!= 0:
    ansy = most_common_x[0][1] + most_common_y_count
else:
    ansy = most_common_y_count

print(max(ansx,ansy))

Measured memory_bytes: 122176
using System;
using System.Linq;
class A
{
    static void Main()
    {
        int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int P = A[0];
        int Q = A[1];
        int R = A[2];
        Console.WriteLine(Math.Min((Math.Min(P + Q, P + R)), Q + R));
    }
}

Measured memory_bytes: 11092
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int H = sc.nextInt();
	        int W = sc.nextInt();
	        int[][] visited = new int[H][W];
	        LinkedList<Integer> p= new LinkedList<Integer>();
	        int cnt=0;
	        for(int i=0;i<H;i++) {
	        	String S = sc.next();
	        	char[] c = S.toCharArray();
	        	for(int j=0;j<W;j++) {
	        		if(c[j]=='#') {
	        			visited[i][j]++;
	        	        p.offer(i*W+j);
	        	        cnt++;
	        		}
	        	}
	        }
	        
	        long ans=0;
	        while(!p.isEmpty()) {
	        	int t=p.poll();
	        	int h = t/W;
	        	int w = t%W;
	        	int d=visited[h][w];
	        	ans=Math.max(ans, d);
	        	if(cnt==W*H+1)break;
	        	visited[h][w]=d;
	        	if(h<H-1&&visited[h+1][w]==0) {
	        		p.offer((h+1)*W+w);
	        		visited[h+1][w]=d+1;
	        		cnt++;
	        	}
	        	if(h>0&&visited[h-1][w]==0) {
	        		p.offer((h-1)*W+w);
	        		visited[h-1][w]=d+1;
	        		cnt++;
	        	}
	        	if(w>0&&visited[h][w-1]==0) {
	        		p.offer(h*W+w-1);
	        		visited[h][w-1]=d+1;
	        		cnt++;
	        	}
	        	if(w<W-1&&visited[h][w+1]==0) {
	        		p.offer(h*W+w+1);
	        		visited[h][w+1]=d+1;
	        		cnt++;
	        	}
	        }
	        
	        
	        System.out.println(ans-1);
	    }
	}

Measured memory_bytes: 70884
s = [input() for i in range(2)] 
li1 = list(map(int, s[0].split()))
li2 = list(map(int, s[1].split()))
k=0;
for j in li2:
    k+=j
if li1[0] > k or li1[0] == k:
    print(li1[0]-k)
else:
    print('-1')

Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
typedef long long MY;
 
MY gcd(MY a, MY b){
  return b ? gcd(b, a%b) : a;
}
 
MY lcm(MY a, MY b){
  return a/gcd(a,b)*b;
}
 
MY f(MY x, int c, int d){
  MY result=x;
  result-=x/c;
  result-=x/d;
  result+=x/lcm(c,d);
  return result;
}
 
int main(){
  MY A, B;
  int C, D;
  cin >> A >> B >> C >> D;
  MY ans = f(B, C, D)-f(A-1, C, D);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Usize1},
};

struct UnionFind {
    c: std::cell::RefCell<Box<[isize]>>,
}
 
use std::mem::swap;
 
impl UnionFind {
    pub fn new(n: usize) -> Self {
        Self {
            c: std::cell::RefCell::new(vec![-1; n].into_boxed_slice()),
        }
    }
 
    pub fn find(&self, mut x: usize) -> usize {
        let c = &mut *self.c.borrow_mut();
        let mut r = x;
        while c[r] >= 0 {
            r = c[r] as usize;
        }
        while x != r {
            let t = c[x] as usize;
            c[x] = r as isize;
            x = t;
        }
        r
    }
 
    pub fn unite(&mut self, mut x: usize, mut y: usize) -> (usize, usize) {
        x = self.find(x);
        y = self.find(y);
        let c = &mut *self.c.borrow_mut();
        if x != y {
            if c[x] < c[y] {
                swap(&mut x, &mut y);
            }
            c[x] += c[y];
            c[y] = x as isize;
        }
        (x, y)
    }
 
    pub fn size(&self, mut x: usize) -> usize {
        x = self.find(x);
        -self.c.borrow()[x] as usize
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        rs:[(Usize1,Usize1);m],
    }
    let mut  uf  = UnionFind::new(n);
    for(a,b)in rs{
        uf.unite(a, b);
    }
    println!("{}",(0..n).map(|x|uf.size(x)).max().unwrap());
 

    
}


Measured memory_bytes: 9152
#include <stdio.h>
#define MAX 500010
#define INF 2000000000
 
int count = 0;
int A[MAX];
int L[MAX/2+2], R[MAX/2+2];
 
int merge(int A[], int l, int m, int r)
{
    int i;    
    for (i=0; i<m-l; i++) L[i] = A[l+i];
    for (i=0; i<r-m; i++) R[i] = A[m+i];
     
    L[m-l] = R[r-m] = INF;
     
    int p=0, q=0;
    for (i=l; i<r; i++) {
        if (L[p] <= R[q]) {
            A[i] = L[p++];
        }
        else {
            A[i] = R[q++];
        }
        count++;
    }
     
}
 
void mergeSort(int A[], int l, int r)
{
    if (l+1 < r) {
        int m = (l + r) / 2;
        mergeSort(A, l, m);
        mergeSort(A, m, r);
        merge(A, l, m, r);
    }
}
 
int main()
{
    int i;    
    int N;
     
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
     
    mergeSort(A, 0, N); // N?????§???
     
    for (i = 0; i < N-1; i++) {
        printf("%d ", A[i]);
    }
    printf("%d\n", A[i]);
    printf("%d\n", count);
     
    return 0;
}



Measured memory_bytes: 5596
def solve():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    if (v-w) > 0:
        x = (b-a)/(v-w)
    else:
        return 'NO'
    
    if abs(x) <= t:
        return 'YES'

    return 'NO'


print(solve())


Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string a[n];
    string b[] = {"AC","WA","TLE","RE"};
    int x1=0,x2=0,x3=0,x4=0;
    for (int i = 0 ; i < n ; i++){
        cin >> a[i];
        if (a[i]==b[0]) {x1++;}
        else if (a[i]==b[1]) {x2++;}
        else if (a[i]==b[2]) {x3++;}
        else if (a[i]==b[3]) {x4++;}
    }
    cout<<"AC x "<<x1<<endl;
    cout<<"WA x "<<x2<<endl;
    cout<<"TLE x "<<x3<<endl;
    cout<<"RE x "<<x4<<endl;


    return 0;
}



Measured memory_bytes: 6728
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main()
{
    int N, Q;
    cin >> N >> Q;
    
    vector<pair<int, int>> ab(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;

        ab[i] = make_pair(a, b);
    }

    sort(ab.begin(), ab.end());
    
    vector<long long> v(N, 0);
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;

        v[--p] += x;
    }
    
    for (int i = 0; i < N - 1; i++)
    {
        v[--ab[i].second] += v[--ab[i].first];
    }
    
    for (int i = 0; i < N; i++)
    {
        cout << v[i] << " ";
    }

    cout << endl;

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> V(N), dp(N);
	for(int i=0; i<N; i++) {
		cin >> V[i];
	}
	dp[0] = 0;
	dp[1] = abs(V[0] - V[1]);
	for(int i=2; i<N; i++) {
		dp[i] = min(dp[i-2] + abs(V[i-2] - V[i]), dp[i-1] + abs(V[i-1] - V[i]));
	}
	cout << dp.back() << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()	{
  int a, b;
  cin >> a >> b;
  int x[a];
  for (int i = 0; i < a; i++)	{
  	cin >> x[i];
  }
  long long moves = 0;
  if (x[0] > b)	{
    moves += x[0] - b;
    x[0] = b;
  }
  for (int i = 0; i < a - 1; i++)	{
    if (x[i + 1] + x[i] > b)	{
      moves += x[i + 1] + x[i] - b;
	  x[i + 1] -= x[i + 1] + x[i] - b;
      if (x[i + 1] < 0)	{
        x[i] += x[i + 1];
        x[i + 1] = 0;
      }
    }
  }
  
  cout << moves << endl;
  return 0;
}


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

using namespace std;

#define ll long long

int main() {
//#ifndef ONLINE_JUGDE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    if(400<=n&&n<=1999){
    	if(400<=n&&n<600){
    		cout<<"8";
		}
		else if(600<=n&&n<800){
			cout<<"7";
		}
		else if(800<=n&&n<1000){
			cout<<"6";
		}
		else if(1000<=n&&n<1200){
			cout<<"5";
		}
		else if(1200<=n&&n<1400){
			cout<<"4";
		}
		else if(1400<=n&&n<1600){
			cout<<"3";
		}
		else if(1600<=n&&n<1800){
			cout<<"2";
		}
		else{
			cout<<"1";
		}
	}
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct RollingHash2D{
  typedef unsigned long long ull;
  
  struct RollingHash{
    typedef unsigned long long ull;
    string S;
    ull B;
    int len;
    vector<ull> hash,p;
    RollingHash(){}
    RollingHash(string S_,ull B_=1000000007LL):
      S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
      hash[0]=0;p[0]=1;
      for(int i=0;i<len;i++){
	hash[i+1]=hash[i]*B+S[i];
	p[i+1]=p[i]*B;
      }
    }
    //S[l,r)
    ull find(int l,int r){
      return hash[r]-hash[l]*p[r-l];
    }
  };
  
  vector<string> S;
  int h,w,r,c;
  ull B;
  vector<ull> p;
  vector<vector<ull> > hash;
  vector<RollingHash> rh;
  RollingHash2D(){}
  RollingHash2D(vector<string> S_,int r_,int c_,ull B_=1000000009LL):
    S(S_),h(S_.size()),w(S_[0].size()),r(r_),c(c_),B(B_),
    p(h+1),hash(h+1,vector<ull>(w-c+1,0)),rh(h){
    for(int i=0;i<h;i++) rh[i]=RollingHash(S[i]);
    p[0]=1;
    for(int i=0;i<h;i++) p[i+1]=p[i]*B;
    for(int j=0;j<w-c+1;j++){
      hash[0][j]=0;		    
      for(int i=0;i<h;i++)
	hash[i+1][j]=hash[i][j]*B+rh[i].find(j,j+c);
    }
  }
  //[i,i+r) * [j,j+c)
  ull find(int i,int j){
    return hash[i+r][j]-hash[i][j]*p[r];
  }
};
//END CUT HERE

signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];
  int r,c;
  cin>>r>>c;
  vector<string> t(r);
  for(int i=0;i<r;i++) cin>>t[i];
  RollingHash2D srh(s,r,c);
  RollingHash2D trh(t,r,c);
  for(int i=0;i<h-r+1;i++){
    for(int j=0;j<w-c+1;j++){
      if(srh.find(i,j)==trh.find(0,0)) cout<<i<<" "<<j<<endl;
    }
  }
  return 0;
}

/*
verified on 2017/10/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_C
*/

Measured memory_bytes: 38416
def resolve():
    L = int(input())
    array = list(map(int, input().split()))
    curr_sum = array[0]
    max_v = curr_sum
    for num in array[1:]:
        curr_sum += num
        max_v = max(max_v, num)
    if max_v < curr_sum - max_v:
        print('Yes')
    else:
        print('No')

resolve()

Measured memory_bytes: 38484
def calcbtc(x):
	return int(380000*10000*x)
N = int(raw_input())
sum = 0
for i in range(0, N):
	gift = raw_input().split()
	if gift[1] == 'BTC':
		sum += calcbtc(float(gift[0]))
	else:
		sum += int(gift[0])*10000
print float(sum)/10000

Measured memory_bytes: 2692
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline long long mul(long long x, long long y) {
  return x % mod * y % mod;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    ans = mul(ans, i);
  }
  for (int i = 1; i <= m; i++) {
    ans = mul(ans, i);
  }
  cout << (n != m ? ans : ans * 2 % mod) << endl; 
  return 0;	
}

Measured memory_bytes: 256
N=int(input())
T=list(map(int,input().split()))

mod=(10**9)+7

goukei=0
S=[]
tmp=0
for i in range(N):
    tmp+=T[i]
    S.append(tmp)

for i in range(N-1):
    
    #print(T[i]*(S[N-1]-S[i]))
    goukei+=(T[i]*(S[N-1]-S[i]))
goukei=goukei%mod
print(goukei)

Measured memory_bytes: 105212
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  string s;
  int K;
  cin >> K;
  cin >> S;
  int a = S.size();
  if (a > K){
    for(int i = 0;i < K;i++){
      s += S.at(i);
    }
    cout << s << "..." << endl;
  }
  else{
    cout << S << endl;
  }
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

n, l = map(int, input().split())

ans = 0
if l>=0:
    for i in range(n):
        if i != 0:
            ans += l+i
else:
    if l>-1*n:
        for i in range(n):
            ans += l+i
    else:
        for i in range(n-1):
            ans += l+i

print(ans)

Measured memory_bytes: 3064
a = list(map(int, input().split()))
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if a[0] <=1:
	b = 0
else:
	b = combinations_count(a[0], 2)
if a[1] <=1:
	c = 0
else:
	c = combinations_count(a[1], 2)
print(b + c)

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

int main(){
    int x;
    cin >> x;
    if(400 <= x && x < 600){
        cout << 8 << endl;
    }else if(600 <= x && x < 800){
        cout << 7 << endl;
    }else if(800 <= x && x < 1000){
        cout << 6 << endl;
    }else if(1000 <= x && x < 1200){
        cout << 5 << endl;
    }else if(1200 <= x && x < 1400){
        cout << 4 << endl;
    }else if(1400 <= x && x < 1600){
        cout << 3 << endl;
    }else if(1600 <= x && x < 1800){
        cout << 2 << endl;
    }else if(1800 <= x && x < 2000){
        cout << 1 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 300

int N;
int ans[maxn];
pi fix = pi(-1,-1);

bool qry(int k){ //k from 0 to N
	vector <int> vect;
	FOR(i,1,k) vect.pb(i);
	FOR(i,N+1,2*N - k) vect.pb(i);
	
	cout<<"? ";
	aFOR(i,vect) cout<<i<<' ';
	cout<<'\n';
	cout.flush();
	
	string out; cin>>out;
	return out == "Red";
}
int main(){
	fast;
	
	cin>>N;
	
	
	
	
	
	bool first = qry(0);
		
	int l=0,r=N;
	
	while (l+1 < r){
		int mid = (l+r)/2;
		
		bool ans = qry(mid);
		if (ans == first) l = mid;
		else r = mid;
	}
	
	l++;
	fix = pi(l,2*N - l + 1);
		
	if (first){
		ans[2*N - l + 1] = 1;
		ans[l] = -1;
	}else{
		ans[2*N - l + 1] = -1;
		ans[l] = 1;
	}

		
	
  	if (fix == pi(-1,-1)){
		vector <int> vect;
      	cout<<vect.front();
      	return 0;
    }
	if (fix.f > fix.s) swap(fix.f,fix.s);
	
	vi zr;
	
	bool partzr[maxn];
	mem(partzr,0);
	FOR(i,1,fix.f-1){
		zr.pb(i);
		partzr[i] = 1;
	}
	FOR(i,N+1,fix.s-1){
		zr.pb(i);
		partzr[i] = 1;
	}
	
	FOR(i,1,2*N){
		if (ans[i] == 0 && !partzr[i]){
			cout<<"? ";
			aFOR(j,zr) cout<<j<<' ';
			cout<<i<<'\n';
			
			cout.flush();
			
			string a; cin>>a;
			
			if (a == "Red") ans[i] = 1;
			else ans[i] = -1;
		}
	}

	zr.clear();
	mem(partzr,0);

	FOR(i,1,2*N){
		if (zr.size() == N-1) break;
		if (ans[i] == 1 && !partzr[i]){
			zr.pb(i);
			partzr[i] = 1;
			
			FOR(j,1,2*N){
				if (ans[j] == -1 && !partzr[j]){
					zr.pb(j);
					partzr[j] = 1;
					break;
				}
			}
		}
	}
					

	FOR(i,1,2*N){
		if (ans[i] == 0 && !partzr[i]){
			cout<<"? ";
			aFOR(j,zr) cout<<j<<' ';
			cout<<i<<'\n';
			
			cout.flush();
			
			string a; cin>>a;
			
			if (a == "Red") ans[i] = 1;
			else ans[i] = -1;
		}
	}		
	
	string answer = "";
	
	FOR(i,1,2*N){
		if (ans[i] == 1) answer += 'R';
		else answer += 'B';
	}
	
	cout<<"! "<<answer<<'\n';
	cout.flush();
	exit(0);
				
	
	
	
	
}



Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] > a[i + 1] + 1) return cout << "No" << '\n', 0;
    if (a[i] == a[i + 1] + 1) --a[i];
  }
  cout << "Yes" << '\n';
}

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

int main() {
  string S;
  int x=0;
  int y=0;
  cin >> S;

  for (int i=0; i< S.size(); i++) {
    if(S.at(i)=='1') x++;
    else y++;
    }
    cout << 2*min(x, y) << endl;
}


Measured memory_bytes: 1020
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a=inp()
        a-=1
        g[i].append(a)
        g[a].append(i)
    return n,g
def graphm():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(m):
        a,b,w=inpm()
        a-=1
        b-=1
        g[a].append((b,w))
        g[b].append((a,w))
    return n,m,g

def dijkstra(s,n,g): # sからの最短距離 頂点数n
    s -= 1
    que = []
    d = [10**15 for _ in range(n)]
    d[s] = 0
    heappush( que,(0,s) )
    while len(que)>0:
        p =  heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(g[v])):
            edge = g[v][i]
            if d[edge[0]] > d[v] + edge[1]:
                d[edge[0]] = d[v] + edge[1]
                heappush( que,(d[edge[0]] , edge[0]) )
    return d

def main():
    n=inp()
    s=input()
    if n%2==1:
        print("No")
        return
    for i in range(n//2):
        if s[i]!=s[i+(n//2)]:
            print("No")
            return
    print("Yes")

      
      

if __name__ == "__main__":
    main()




Measured memory_bytes: 39148
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define mkpr(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll general,total;
//ll chk[55];
//ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<ll> pqll;   //decrease
priority_queue<double> pqd;
//stack<int> stk;
vector<pair<ll,ll>> vpll;
vector<pair<double,double>> vpdd;
//vector<ll> vll;
//vector<double> vd;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;

/*ll cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.first<b.first;
    //arrising
}*/

int main()
{
    double ans=0.0,half,d,d1,d2;
    //float f,g,h;
    long long int sum,sum2,n1,n2,n3;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    sum=sum2=n1=n2=n3=0;
    a=a1=a2=a3=a4=a5=a6=0;
    string s,s1;
    char now,pre,c1,c2;
    cin>>s;c1='1';c2='0';
    for(i=0;i<s.size();i++)
    {
        if(c1=='1') c1='0';
        else c1='1';
        if(c2=='1') c2='0';
        else c2='1';
        if(s[i]!=c1) a1++;
        if(s[i]!=c2) a2++;
    }
    cout<<min(a1,a2);
    return 0;
}





Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
typedef long long ll;
const int N=2e5+5;
ll a[N],sum[N];int n;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i),a[i]-=i;
    std::sort(a+1,a+1+n);
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    ll ans=1e18;
    for(int i=1;i<=n;i++) {
        ll val=0;
        if(i>1) val+=a[i]*(i-1)-sum[i-1];
        if(i<n) val+=sum[n]-sum[i]-(n-i)*a[i];
        ans=std::min(ans,val);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            bool ans = false;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == '7')
                {
                    ans = true;
                }
            }
            WriteLine(ans?"Yes":"No");
        }
    }
}

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

int main() {
    int a, b;

    cin >> a >> b;
    
    int ans = 0;
    int p = 1;
    
    while (p < b) {
        p += a - 1;
        ans++;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5+1;

int n, a[N], b[N], c[N], d[N], ans;
V<int> va, vb;
struct UnionFind{
  vector<int> p;
  int g;
  void init(int n){
    p.assign(n, -1);
    g = n;
  }
  int find(int a){
    return p[a] < 0 ? a : p[a] = find(p[a]);
  }
  bool merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a==b) return 0;
    g--;
    if(p[a]>p[b]) swap(a, b);
    p[a] += p[b];
    p[b] = a;
    return 1;
  }
} uf;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a[i];
    a[n]^=a[i];
  }
  FOR(i, 0, n){
    cin >> b[i];
    b[n] ^= b[i];
  }
  FOR(i, 0, n+1) va.pb(a[i]);
  FOR(i, 0, n+1) vb.pb(b[i]);
  sort(all(va));
  sort(all(vb));
  FOR(i, 0, n+1) if(va[i]!=vb[i]){
    cout << -1 << endl;
    return 0;
  }
  uniq(va);
  FOR(i, 0, n+1) a[i] = lower_bound(all(va), a[i])-va.begin();
  FOR(i, 0, n+1) b[i] = lower_bound(all(va), b[i])-va.begin();
  int s = sz(va);
  uf.init(s);
  FOR(i, 0, n+1) if(a[i]!=b[i]){
    uf.merge(a[i], b[i]);
    c[a[i]]++;
  }
  FOR(i, 0, s) d[uf.find(i)] += c[i];
  int ans = 0;
  FOR(i, 0, s) if(d[i]) ans += d[i]+1;
  if(c[a[n]]) ans--;
  if(a[n]!=b[n]) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 2936
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();

		System.out.println(N - K + 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vl x(n);
  REP(i,n) cin >> x[i];
  
  ll ans = 1e9;

  REP(i,101){
    ll cos = 0;
    REP(j,n){
      ll diff = x[j] - i;
      cos += diff*diff;
    }
    CHMIN(ans,cos);
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
int32_t main(){
        int n;cin>>n;map<int,int>cn;
        for(int i=1;i<n;i++){
            int x;cin>>x;cn[x]++;
        }
        for(int i=1;i<=n;i++)cout<<cn[i]<<endl;
    
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF (1LL<<62)


int main(){ 
  int N, A, B;
  cin >> N >> A >> B;
  if(abs(A-B) % 2 == 0){
    cout << "Alice" << endl;
  }
  else{
    cout << "Borys" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#template
def inputlist(): return [int(i) for i in input().split()]
#template
#issueから始める
S = list(input())
sa = S[:]
sa.reverse()
n = len(S)
ss = S[:(n-1)//2]
SS = S[(n+1)//2:]
ssaa = ss[:]
ssaa.reverse()
SSAA = SS[:]
SSAA.reverse()
if S == sa and ss == ssaa and SS == SSAA:
    print("Yes")
else:
    print("No")

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

namespace ABC042B{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            sr.Next<int>();

            Console.WriteLine(string.Join("", sr.Next<string>(N).OrderBy(s => s)));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

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

int main(void){
    long long N,t,a,ans;
    float tmp;
    cin >> N ;
    cin >> t >> a;
    long long h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    
    tmp=abs(a-(t-(0.006*h[0])));
    ans=0;

    for(int j = 0; j < N; j++)
    {
        if(abs(a-(t-(0.006*h[j])))<tmp){
            tmp=abs(a-(t-(0.006*h[j])));
            ans=j;
        }
    }
    
    printf("%lld",ans+1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
	int minv;
	int d[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while (true) {
		minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK&&M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}

	int k, c, u, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}

	dijkstra();

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);

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

int main() {
    ll N,X;
    cin>>N>>X;
    vec A(N+1);
    rep(i,0,N) {
        cin>>A[i];
    }
    A[N]=X;
    sort(A);
    
    ll C=A[1]-A[0];
    
    rep(i,1,N) {
        ll D=A[i+1]-A[i];
        //cout<<D<<endl;
        C=gcd(C,D);
        }
        cout<<C<<endl;
        }

Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

string format(int t) {
	string res = "";
	int h = t / 100, m = t % 100;
	res += toStr(h);
	res += ":";
	if (m < 10) {
		res += "0";
	}
	res += toStr(m);
	
	return res;
}

int main() {
	int N, h, m;
	cin >> N;
	set<int> data;
	REP(i, N) {
		cin >> h >> m;
		data.insert(100 * h + m);
	}
	cin >> N;
	REP(i, N) {
		cin >> h >> m;
		data.insert(100 * h + m);
	}

	vi times;
	for (set<int>::iterator it = data.begin(); it != data.end(); it++) {
		times.push_back(*it);
	}

	sort(ALL(times));
	REP(i, times.size()) {
		cout << format(times[i]);
		if (i != times.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

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

bool match(vector<string> nv, vector<string> mv, int x, int y){
	for(int i=0; i<mv.size(); i++){
		if(mv[i] != nv[x+i].substr(y, mv.size())) return false;
	}
	return true;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<string> nv(n);
	vector<string> mv(m);
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		nv[i] = s;
	}
	for(int i=0; i<m; i++){
		cin >> s;
		mv[i] = s;
	}
	for(int i=0; i<n-(m-1); i++){
		for(int j=0; j<n-(m-1); j++){
			if(match(nv, mv, i, j)) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    int idx = 0;
    while(idx<n) {
        ans = ans * (idx + 1LL) % mod;
        ++idx;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n,m;
struct edge
{
	int u,v,w;
	bool usd;
	edge(){}
	edge(int u,int v,int w):u(u),v(v),w(w){}
	bool operator <(const edge&t)const{return w<t.w;}
}es[2200];
int fa[1100];
vector<pii > g[1100];
ll X,val[2200];
int pa[12][1100],wei[12][1100],dep[1100];
void dfs(int x,int fr,int fw)
{
	pa[0][x]=fr;
	wei[0][x]=fw;
	dep[x]=dep[fr]+1;
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i].first;
		if(to==fr)continue;
		dfs(to,x,g[x][i].second);
	}
}
inline int getfa(int x){return x==fa[x]?x:fa[x]=getfa(fa[x]);}
pii getmax(int x,int y)
{
	if(dep[x]<dep[y])swap(x,y);
	int ret=0;
	for(int i=0;i<12;i++)
	{
		if((dep[x]-dep[y])>>i&1)
		{
			ret=max(ret,wei[i][x]);
			x=pa[i][x];
		}
	}
	if(x==y)return make_pair(ret,x);
	for(int k=11;k>=0;k--)
	{
		if(pa[k][x]!=pa[k][y])
		{
			ret=max(ret,wei[k][x]);
			ret=max(ret,wei[k][y]);
			x=pa[k][x];
			y=pa[k][y];
		}
	}
	ret=max(ret,wei[0][x]);
	ret=max(ret,wei[0][y]);
	return make_pair(ret,pa[0][x]);
}
int rht[2200];
inline void add(int &a,int b)
{
	a+=b;
	if(a>=MOD)a-=MOD;
}
inline int quickpow(ll base,ll ind)
{
	ll ans=1;
	while(ind>0)
	{
		if(ind&1)ans=ans*base%MOD;
		ind>>=1;
		base=base*base%MOD;
	}
	return (int)ans;
}
vector<int> repl[2020];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%lld",&X);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&es[i].u,&es[i].v,&es[i].w);
	}
	sort(es,es+m);
	rht[m-1]=m;
	for(int i=m-2;i>=0;i--)
	{
		if(es[i].w==es[i+1].w)rht[i]=rht[i+1];
		else rht[i]=i+1;
	}
	for(int i=1;i<=n;i++)fa[i]=i;
	int ru,rv;
	ll sum=0;
	for(int i=0;i<m;i++)
	{
		if((ru=getfa(es[i].u))!=(rv=getfa(es[i].v)))
		{
			fa[ru]=rv;
			es[i].usd=1;
			sum+=es[i].w;
			g[es[i].u].push_back(make_pair(es[i].v,es[i].w));
			g[es[i].v].push_back(make_pair(es[i].u,es[i].w));
		}
		else
		{
			es[i].usd=0;
		}
	}
	dfs(1,0,0);
	for(int k=1;k<12;k++)
	{
		for(int i=1;i<=n;i++)
		{
			pa[k][i]=pa[k-1][pa[k-1][i]];
			wei[k][i]=max(wei[k-1][i],wei[k-1][pa[k-1][i]]);
		}
	}
	int ans=0;
	for(int i=0;i<m;i++)
	{
		if(es[i].usd)
		{
			val[i]=sum;
		}
		else
		{
			pii tmp=getmax(es[i].u,es[i].v);
			val[i]=sum+es[i].w-tmp.first;
		/*	int x=es[i].u;
			while(x!=tmp.second)
			{
				if(wei[0][x]==tmp.first)repl[i].push_back(x);
				x=pa[0][x];
			}
			x=es[i].v;
			while(x!=tmp.second)
			{
				if(wei[0][x]==tmp.first)repl[i].push_back(x);
				x=pa[0][x];
			}*/
		}
	//	cout<<i<<" "<<val[i]<<endl;
	}
	for(int i=1;i<m;i++)
	{
		if(val[i]==X)
		{
			int res=2;
			for(int j=0;j<m;j++)
			{
				if(val[j]>X||(val[j]==X&&j>i))
					res=res*2%MOD;
			}
			add(ans,res);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, M;
    cin >> N >> M;

    map<pair<int, int>, bool> m;

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        m[make_pair(a, b)] = true;
        m[make_pair(b, a)] = true;
    }

    bool flag = false;
    for (int i = 1; i < N - 1; i++) if (m[make_pair(0, i)] && m[make_pair(i, N - 1)]) flag = true;

    cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

}















































Measured memory_bytes: 37760
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()

num = sum(a)
ans = MAX_INT
l = 0
for i in a:
  l += i
  ans = min(ans, abs(l - (num - l)))
print(ans)

Measured memory_bytes: 89296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >>e >>k;

	if(e - a > k)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(a>=b)
	printf("delicious\n");
	else {
		if(b-a>x)
		printf("dangerous\n");
		else
		printf("safe\n");
		
	}
	return 0;
}

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

using ll = long long;

int  N;
string s,t;
int memo=1000;
int main(){
  cin>>N>>s>>t;
  for(int i=0;i<=N;i++){
    if(s.substr(i,N-i)==t.substr(0,N-i)){
      cout<<N+i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

ll calc(ll a, ll b) {
  return (a - b) * (a * a * a * a + a * a * a * b + a * a * b * b +
                    a * b * b * b + b * b * b * b);
}

void solve(ll X) {
  for (ll a = 0; a != 1000; ++a) {
    for (ll b = 0; b != 1000; ++b) {
      if (calc(a, b) == X) {
        cout << a << " " << b << endl;
        return;
      } else if (calc(a, -b) == X) {
        cout << a << " " << -b << endl;
        return;
      } else if (calc(-a, b) == X) {
        cout << -a << " " << b << endl;
        return;
      } else if (calc(-a, -b) == X) {
        cout << -a << " " << -b << endl;
        return;
      }
    }
  }
  cout << "" << endl;
}

int main() {
  ll X;
  cin >> X;
  solve(X);
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vvi g;
vi a,dp;

int main(){
	cin>>n>>m;
	g=vvi(n);
	a=dp=vi(n);
	queue<int> q;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		a[v]++;
	}
	for(int i=0;i<n;i++) if(!a[i]) q.push(i);
	int res=0;
	while(!q.empty()){
		int v=q.front();q.pop();
		res=max(res,dp[v]);
		for(auto u:g[v]){
			dp[u]=max(dp[u],dp[v]+1);
			a[u]--;
			if(!a[u]) q.push(u);
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const int inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int rangesum(int lo, int hi, vi& pre) {
	if(lo==0)
		return pre[hi]%MOD;
	return (pre[hi]-pre[lo-1]+MOD)%MOD;
}
int32_t main(void)
{
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	int dp[n+1][n]={};
	// for(int i = 0; i < n; i++)
	// 	dp[1][i]=0;
	for(int i = 2; i <= n; i++) {
		for(int j = 0; j <= n-i; j++) {
			int lo=j, hi=j+i-1;
			int mx=inf, sum=0;
			for(int k = lo; k <= hi; k++)
				sum += a[k];
			for(int k = lo; k < hi; k++) {
				mx=min(mx, dp[k-lo+1][lo]+dp[hi-k][k+1]+sum);
				// cout<<i<<" "<<k<<" "<<j<<"  	"<<dp[k-lo+1][lo]<<" "<<dp[hi-k][k+1]<<" "<<sum<<endl;
			}
			// cout<<i<<" fdfd "<<j<<" "<<lo<<" "<<hi<<" "<<sum<<endl;
			dp[i][j]=mx;
		}
	}
	// for(int i = 1; i <= n; i++) {
	// 	for(int j = 0; j < n; j++) {
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n][0]<<endl;
	time();
	return 0;
}

Measured memory_bytes: 1536
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)

def lcm(a,b):
  return a*b//(gcd(a,b))

N,M=map(int,input().split())
A=list(map(int,input().split()))

LCM=1
for i in A:
  i=i//2
  LCM=lcm(i,LCM)

for i in A:
  i=i//2
  if (LCM//i)%2==0:
    print(0)
    exit()

ans=((M//LCM)+1)//2
print(ans)

Measured memory_bytes: 14244
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    int ret = 1;
    int max = H[0];
    for(int i = 1; i < N; ++i) {
        if(max <= H[i]) {
            ret++;
            max = H[i];
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256