akhauriyash/Code-Regression huggingface dataset:
MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]

s=[0]
for i in range(len(alst)):
  s.append(s[i]+alst[i])

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

Measured memory_bytes: 31588
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

int main(){
	int m,n;
	while(cin>>m,m){
		vector<pii> a(m);
		rep(i,m){
			// int t1,t2;
			cin>>a[i].F>>a[i].S;
		}
		cin>>n;
		vector<pii> b(n);
		rep(i,n){
			cin>>b[i].F>>b[i].S;
		}
		sort(ALL(a));
		sort(ALL(b));
		rep(i,m){
			if(i){
				a[i].F-=a[0].F;
				a[i].S-=a[0].S;
			}
		}
		rep(i,n){
			b[i].F-=a[0].F;
			b[i].S-=a[0].S;
		}
		a[0]=mkp(0,0);
		// sort(ALL(a));
		bool f=false;
		rep(i,n){
			if(n-i<m) break;
			bool f1=true;
			rep(j,m){
				bool f2=false;
				rep(k,n){
					if(a[j].F==b[k].F-b[i].F&&a[j].S==b[k].S-b[i].S){
						f2=true;
						break;
					}
				}
				if(f2){
					continue;
				}
				else{
					f1=false;
				}
			}
			if(f1){
				cout<<b[i].F<<" "<<b[i].S<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1208
import math
n,d=map(int,input().split())
x=[list(map(int,input().split()))for _ in range(n)]
def a(a,b):
  aa=0
  for i in range(d):aa+=abs(a[i]-b[i])**2
  if math.sqrt(aa)%1==0:return 1
  return 0
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=a(x[i],x[j])
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

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

	ll x;
	cin >> x;

	ll ans = 1;
	for (ll b = 1; b <= x; b++) {
		for (ll p = 2; p <= x; p++) {
			if (powl(b, p) <= x) {
				ans = max(ans, (ll)powl(b, p));
			}
		}
	}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll A,B,C,X,Y ;
  cin >> A >> B >> C >> X >> Y;
  ll ans = 0;
  
  if(C*2 <= A+B){
    ans += C*min(X,Y)*2;
    if(X>=Y){
      if(2*C<=A){
        ans += C*(X-min(X,Y))*2;
      }
      else if(2*C>A){
        ans += A*(X-min(X,Y));
      }
    }
    else if(X <Y){
      if(2*C<=B){
        ans += C*(Y-min(X,Y))*2;
      }
      else if(2*C>B){
        ans += B*(Y-min(X,Y));
      }
    }
  }
  else ans = A*X + B*Y;
  cout << ans << endl;
                         
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int x,n,v[10001],y;
int main()
{
    cin >> x >> n;
    if(n == 0) cout << x;
    else
    {
        for(int i = 1; i <= n; ++i)
        {
            cin >> y;
            v[y] = 1;
        }
        for(int i = 0; i <= n; ++i)
        {
            if(x-i == 0)
            {
                cout << 0;
                break;
            }
            if(!v[x-i])
            {
                cout << x-i;
                break;
            }
            if(!v[x+i])
            {
                cout << x+i;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>

int main()
{
    char s[500];
    int i,l;
    while(gets(s))
    {
        l=0;
        l=strlen(s);
        for(int i=0; i<l; i++)
        {
            if(i==0)
                s[i]='2';
            else if(i==1)
                s[i]='0';
            else if(i==2)
                s[i]='1';
            else if(i==3)
                s[i]='8';
        }
        printf("%s\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
using namespace std;
//int P=998244353;
//inline int ad(int x,int y){return (x+y>=P)?(x+y-P):(x+y);}
//inline int mt(int x,int y){LL rt=1ll*x*y; rt=(rt>=P)?(rt%P):rt; return rt;}
//inline void mo(int &x){x=(x>=P)?(x-P):x; x=(x<0)?(x+P):x;}
template<typename T>void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-48;
	x*=f;
}
int a[200010],n;
map<int,int>mp;
map<int,int>::iterator it;
bool ck(int lim){
	mp.clear();	
	int len=0;
	for(int i=1;i<=n;++i){
		if(a[i]<=len){
			int nw=a[i];
			++mp[nw];
			it=mp.find(nw);
			while((it->second)>=lim){
				if(nw==1) return 0;
				it->second=0;
				--nw;
				++mp[nw];
				it=mp.find(nw);
			}
		}
		if(len>a[i]){
			if(!mp.empty()){
				for(it=--mp.end();(it->first)>a[i];--it){
					mp.erase(it);
					if(mp.empty()) break;
				}
			}
		}
		len=a[i];
	}
	return 1;
}
int main(){
	read(n);
	int f=1;
	for(int i=1;i<=n;++i)
		read(a[i]);
	for(int i=2;i<=n;++i) f=f&(a[i]==a[i-1]+1);
	if(f){puts("1");return 0;}
	int l=2,r=n;
	while(l<r){
		int mid=(l+r)/2;
		if(ck(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d",l);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<tuple>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

char mp[60][60];
int ret[60][60];

int dx[] = {1,1,1,0,-1,-1,-1,0};
int dy[] = {1,0,-1,-1,-1,0,1,1};

int main()
{
	int h,w;
	cin >> h >> w;
	
	REP(i,h)REP(j,w)
	{
		cin >> mp[i+1][j+1];
		if(mp[i+1][j+1] == '#')
		{
			REP(k,8)
			{
				ret[i+dy[k]+1][j+dx[k]+1]++;
			}
		}
	}
	
	
	for(int i = 1;i < h+1;i++)
	{
		for(int j = 1;j < w+1;j++)
		{
			if(mp[i][j] == '#')
			{
				cout << '#';
			}
			else
			{
				cout << ret[i][j];
			}
		}
		cout << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a >> b;
	cout << (6 - a - b) << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N;
  cin >> N;
  vector<pair<string, int>> pl;
  for (int i = 0; i < N; i++) {
    string s;
    int t;
    cin >> s >> t;
    pl.push_back(make_pair(s, t));
  }
  string X;
  cin >> X;
  int ans = 0;
  bool flag = false;
  for (auto x : pl) {
    if (flag) ans += x.second;
    if (x.first == X) {
      flag = true;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	long result = 0;
	long x = LONG_MAX;
	x = min(A, B);
	x = min(x, C);
	x = min(x, D);
	x = min(x, E);
	int check = 0;
	if (x == A && check == 0) {
		if (N % A == 0) {
			cout << N / A + 4 << endl;
		}
		else {
			cout << N / A + 5 << endl;
		}
		check = 1;
	}
	if (x == B && check == 0) {
		if (N % B == 0) {
			cout << N / B + 4 << endl;
		}
		else {
			cout << N / B + 5 << endl;
		}
		check = 1;
	}
	if (x == C && check == 0) {
		if (N % C == 0) {
			cout << N / C + 4 << endl;
		}
		else {
			cout << N / C + 5 << endl;
		}
		check = 1;
	}
	if (x == D && check == 0) {
		if (N % D == 0) {
			cout << N / D + 4 << endl;
		}
		else {
			cout << N / D + 5 << endl;
		}
		check = 1;
	}
	if (x == E && check == 0) {
		if (N % E == 0) {
			cout << N / E + 4 << endl;
		}
		else {
			cout << N / E + 5 << endl;
		}
		check = 1;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int MAXN = 1e5+5;
int cnt[MAXN]{ };
int H[MAXN];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &H[i]);
  }
  for (int i = 1; i < N; ++i) {
    if (H[i] <= H[i-1]) {
      cnt[i] = 1 + cnt[i-1];
    }
  }
  printf("%d\n", *std::max_element(cnt, cnt + N));
  return 0;
}

Measured memory_bytes: 896
use std::collections::HashMap;
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 read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n: i32 = read();
    let an: Vec<i32> = read_vec();
    let ans = run(an, 0);
    println!("{}", ans);
}
fn run(an: Vec<i32>, count: i32) -> i32 {
    let mut map = HashMap::new();
    for x in an {
       let ins_v = match map.get(&x) {
            Some(y) => y + 1,
            None => 1,
        };
        map.insert(x,ins_v);
    }
    map.iter().map(|(&m,&n)| {
        if m == n {
            0
        } else if m < n{
            n - m 
        } else {
            n
        }
    }).fold(0,|sum,l| sum + l)
}


Measured memory_bytes: 9464
/**
*    author:  Dooloper
*    created: 17.09.2020 23:15:28
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long x=0) : x((x%mod+mod)%mod) {}
   mint operator-() const {
     return mint(-x);
   }
   mint& operator+=(const mint& a) {
       if ((x += a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator-=(const mint& a) {
       if ((x += mod-a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator*=(const  mint& a) {
       (x *= a.x) %= mod;
       return *this;
   }
   mint operator+(const mint& a) const {
       mint res(*this);
       return res+=a;
   }
   mint operator-(const mint& a) const {
       mint res(*this);
       return res-=a;
   }
   mint operator*(const mint& a) const {
       mint res(*this);
       return res*=a;
   }
   mint pow(ll t) const {
       if (!t) return 1;
       mint a = pow(t>>1);
       a *= a;
       return a;
   }
   // for prime mod
   mint inv() const {
       return pow(mod-2);
   }
   mint& operator/=(const mint& a) {
       return (*this) *= a.inv();
   }
   mint operator/(const mint& a) const {
       mint res(*this);
       return res/=a;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll x,k,d;
  cin >> x >> k >> d;
  x = abs(x);
  ll str = min(k,x/d);
  k -= str;
  x -= str*d;
  if(k % 2 == 0) cout << x << endl;
  else cout << d-x << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int a = s.at(0) - '0', b = s.at(1) - '0', c = s.at(2) - '0', d = s.at(3) - '0';
    for(int i = 0; i < 8;i++){
        bitset<3> s(i);
        vector<char> fugou(3); 
        int temp = a;
        if(s.test(0)) temp += b, fugou[0] = '+';
        else temp -= b, fugou[0] = '-';
        if(s.test(1)) temp += c, fugou[1] = '+';
        else temp -= c,  fugou[1] = '-';
        if(s.test(2)) temp += d, fugou[2] = '+';
        else temp -= d,  fugou[2] = '-';
        if(temp == 7){
            cout << a << fugou[0] << b << fugou[1] << c << fugou[2] << d << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }

  vector<ll> pattern1;
  vector<ll> pattern2;

  if (N % 2 == 0) {
    pattern1.push_back(-1);
    pattern1.push_back(1);
    pattern2.push_back(1);
    pattern2.push_back(-1);
    for (ll i = 0; i < (N - 2); i++) {
      if (i % 2 == 0) {
        pattern1.push_back(2);
        pattern2.push_back(-2);
      } else {
        pattern1.push_back(-2);
        pattern2.push_back(2);
      }
    }
  } else {
    pattern1.push_back(1);
    pattern1.push_back(1);
    pattern2.push_back(-1);
    pattern2.push_back(-1);
    for (ll i = 0; i < (N - 2); i++) {
      if (i % 2 == 0) {
        pattern1.push_back(-2);
        pattern2.push_back(2);
      } else {
        pattern1.push_back(2);
        pattern2.push_back(-2);
      }
    }
  }

  sort(a.begin(), a.end());
  sort(pattern1.begin(), pattern1.end());
  sort(pattern2.begin(), pattern2.end());
  ll res1 = 0;
  ll res2 = 0;
  for (ll i = 0; i < N; i++) {
    // cout << a[i] << endl;
    res1 += a[i] * pattern1[i];
    res2 += a[i] * pattern2[i];
  }

  cout << max(res1, res2) << endl;
}

Measured memory_bytes: 2804
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		String s = saori.nextHayami();
		int ans = 0;
		int num = 0;
		String str2 = "";
		ArrayList<String> ch = new ArrayList<>();
		for(int i = 1;i < n;i++){
			String[] str1 = s.substring(0, i).split("");
			str2 = s.substring(i,n);
			num = 0;
			for(int j = 0;j < str1.length;j++){
				if(!ch.contains(str1[j])){
					ch.add(str1[j]);
					if(str2.contains(str1[j])){
						num++;
					}
				}
			}
			ch.clear();
			ans = Math.max(ans, num);

		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

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

    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }

    int score = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            score += d[i]*d[j];
        }
    }

    cout << score << endl;
}

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

using namespace std;

int main()
{
    int n;
    string str;
    cin >> n;
    cin >> str;
    int left = 0, right = n-1;
    int cnt = 0;
    
    while(left <= right){
        while(left < n && str[left] != 'W')
            left++;
        while(right >= 0 && str[right] != 'R')
            right--;
        if(left < n && right >= 0 && left < right){
            char tmp = str[right];
            str[right] = str[left];
            str[left] = tmp;
            left++;
            right--;
            cnt++;
        }
            
    }
    cout << cnt << '\n';
    return 0;
}

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

int main() {
	vector<int> v;
	int temp, temp2;
	while (1) {
		scanf("%d", &temp);
		scanf("%d", &temp2);
		if (temp == 0 && temp2 == 0) {
			break;
		}
		else {
			v.push_back(temp);
			v.push_back(temp2);
		}
	}

	for (int i = 0; i < v.size(); i = i+ 2) {
		if (v[i] <= v[i + 1]) {
			printf("%d %d\n", v[i], v[i + 1]);
		}
		else {
			printf("%d %d\n", v[i+1], v[i]);
		}
	}
	return 0;
}

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

int main()
{
    int D;
    cin >> D;
    int c[26];
    int sd[D][26];
    for (int i = 0; i < 26;i++)
        cin >> c[i];
    for (int i = 0; i < D;i++){
        for (int k = 0; k < 26;k++){
            cin>>sd[i][k];
        }
    }
    int ans[D];
    ans[0] = 0;
    int select = 0;
    int tmp = 0;
    for (int i = 0; i < D; i++){
        for (int k = 0; k < 26;k++)
            if (tmp<sd[i][k]-c[i]){
                tmp = sd[i][k] - c[i];
                select = k;
            }
        ans[i] = select + 1;
        tmp = 0;
    }
    for (int i = 0; i <D;i++)
        cout << ans[i] << endl;
}



Measured memory_bytes: 3672
import math
import itertools

n = int(input())
p = [x for x in map(int, input().split())]
q = [x for x in map(int, input().split())]
lst = [x for x in range(1,n+1)]

perm = itertools.permutations(lst)
permLst = [list(x) for x in perm]

a = permLst.index(p)+1
b = permLst.index(q)+1

print(abs(a-b))

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

int main(){
  int n,tmp;
  cin>>n;
  tmp = (n-1)/2;
  int a[n];
  int count = 0;
  for(int i = 0;i < n;i++) cin>>a[i];
  sort(a,a+n);
  cout<<abs(a[tmp]-a[tmp+1]);
}

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

const int MOD = 1e9 + 7;
int dp[503][503] , pot[503] , stir[503][503] , jc[1003] , inv[1003] , N , X;
int upd(int x){return x + (x >> 31 & MOD);}

int poww(int a , int b){
	int times = 1;
	while(b){
		if(b & 1) times = 1ll * times * a % MOD;
		a = 1ll * a * a % MOD; b >>= 1;
	}
	return times;
}

int binom(int a , int b){return 1ll * jc[a] * inv[b] % MOD * inv[a - b] % MOD;}

int main(){
	cin >> N >> X; for(int i = 1 , x ; i <= N ; ++i){cin >> x; ++pot[x];}
	dp[0][0] = 1; jc[0] = 1;
	for(int i = 1 ; i <= 1000 ; ++i) jc[i] = 1ll * jc[i - 1] * i % MOD;
	inv[1000] = poww(jc[1000] , MOD - 2) % MOD;
	for(int i = 999 ; i >= 0 ; --i) inv[i] = inv[i + 1] * (i + 1ll) % MOD;
	for(int i = X ; i ; --i){
		for(int j = X ; j ; --j)
			for(int k = i * j ; k <= X ; ++k)
				for(int l = 1 ; l <= j && l * i <= k ; ++l)
					dp[j][k] = (dp[j][k] + 1ll * dp[j - l][k - l * i] * inv[l]) % MOD;
		if(pot[i])
			for(int j = 0 ; j <= X ; ++j)
				for(int k = 0 ; k <= X ; ++k)
					if(dp[j][k]) dp[j][k] = 1ll * dp[j][k] * poww(k - j * (i - 1) , pot[i]) % MOD;
	}
	int ans = 0;
	for(int j = 1 ; j <= X ; ++j)
		for(int k = 1 ; k <= X ; ++k)
			if(dp[j][k]){
				int sum = 0;
				for(int l = 0 ; l < j ; ++l)
					sum = (sum + (l & 1 ? -1ll : 1ll) * binom(j - 1 , l) * binom(X - k + j - l , X - k) % MOD + MOD) % MOD;
				sum = 1ll * sum * dp[j][k] % MOD * jc[j] % MOD;
				ans = (X - k) & 1 ? upd(ans - sum) : upd(ans + sum - MOD);
			}
	cout << ans; return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int k, x;
	cin >> k >> x;

	if (500 * k >= x) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int N;
    int[] a;
    int answer;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        N = sc.nextInt();
        a = new int[N+1];
        for (int i=1; i<N+1; ++i){
            a[i] = sc.nextInt();
        }
    }
    
    //解答処理
    int solve() {
        for (int i=1; i<N+1; ++i){
            if (i % 2 == 1 && a[i] % 2 == 1){
                ++answer;
            }
        }
        
        return answer;
    }
    
    //出力
    void show(int answer) {
        System.out.print(answer);
    }
}

Measured memory_bytes: 35888
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    long long x;
    cin>>x;
    long long ans=0;
    if(x!=1){
        x--;
        ans+=(x/11)*2;
        x%=11;
        if(x<6)ans++;
        else ans+=2;
    }
    else{
        ans=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
k=[i for i in range(2,n+1)]
d=defaultdict(int)
c=1

for i in range(2,n+1):
  while i%2==0:
    i//=2
    d[2]+=1
  f=3
  while f<i:
    if i%f==0:
      i//=f
      d[f]+=1
    else:
      f+=2
  if i !=1:
   d[i]+=1

for v in d.values():
  c=(c*(v+1))%(10**9+7)
print(c)

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n, a, b;cin >> n >> a >> b;
    if(a+b > n+1 || a*b < n){
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    int cnt = 1;
    inc(i, 0, b){
        vector<int> v;
        inc(j, 0, a){
            v.pb(cnt);
            cnt++;
            if(b-i-2 == n-cnt) break;
        }
        reverse(v.begin(), v.end());
        for(auto vv : v){
            ans.pb(vv);
        }
    }
    reverse(ans.begin(), ans.end());
    for(auto a : ans){
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 4336
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Numerics;
class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var A = new long[N + 1];
        var line = ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i < N; i++)
        {
            A[i + 1] = A[i] + line[i];
        }
        var C = new Dictionary<long, long>();
        for (int i = 0; i < N + 1; i++)
        {
            var a = A[i];
            if (C.ContainsKey(a))
            {
                C[a]++;
            }
            else
            {
                C.Add(a, 1);
            }
        }

        long ans = 0L;
        foreach (var c in C)
        {
            ans += c.Value * (c.Value - 1) / 2;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 42152
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
  cout << fixed << setprecision(15);
  string S;
  cin >> S;
  vector<char> B;
  int ans=0;
  for(int i=0;i<S.size();++i) {
    B.pb(S[i]);
    if(B.size()>=2&&B[B.size()-1]!=B[B.size()-2]) {
      ans+=2;
      B.pob();B.pob();
    }
  }
  cout << ans << endl;


  return 0;
}


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

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define mod 1000000007
#define INF64 1e18

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int n;cin>>n;
  int a,b,c,a1,b1,c1;
  cin>>a1>>b1>>c1;
  for(int i=1;i<n;i++){
    cin>>a>>b>>c;
    a+=max(b1,c1);
    b+=max(a1,c1);
    c+=max(b1,a1);

    a1=a;b1=b;c1=c;
    //cout<<a1<<" "<<b1<<" "<<c1<<endl;
  }
  cout<<max({a1,b1,c1});
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class RollingHash
{
private:
    static const int X[], M[];
    vector<vector<long long> > xp;
    vector<vector<long long> > hash;
public:
    RollingHash(const string& s){
        int n = s.size();
        xp.assign(n+1, vector<long long>(3, 1));
        hash.assign(n+1, vector<long long>(3, 0));
        for(int i=0; i<n; ++i){
            for(int j=0; j<3; ++j){
                hash[i+1][j] = hash[i][j];
                hash[i+1][j] *= X[j];
                hash[i+1][j] += s[i];
                hash[i+1][j] %= M[j];
                xp[i+1][j] = xp[i][j];
                xp[i+1][j] *= X[j];
                xp[i+1][j] %= M[j];
            }
        }
    }
    vector<long long> getHash(int a) const{
        return hash[a+1];
    }
    vector<long long> getHash(int a, int b) const{
        vector<long long> ans(3);
        for(int i=0; i<3; ++i){
            ans[i] = hash[b][i];
            ans[i] -= hash[a][i] * xp[b-a][i];
            ans[i] %= M[i];
            if(ans[i] < 0)
                ans[i] += M[i];
        }
        return ans;
    }
};
const int RollingHash::X[] = {1685440109, 1389328937, 1813126193}; // 素数
const int RollingHash::M[] = {2000000087, 2000000089, 2000000099}; // 合同式の法（素数）


int main()
{
    int n;
    string s;
    cin >> n >> s;
    RollingHash rh(s);

    int left = 0;
    int right = n / 2;
    while(left < right){
        int mid = (left + right + 1) / 2;
        map<vector<long long>, int> index;
        bool ok = false;
        for(int i=0; i<=n-mid; ++i){
            auto hash = rh.getHash(i, i+mid);
            if(index.find(hash) == index.end())
                index[hash] = i;
            if(index[hash] <= i - mid){
                ok = true;
                break;
            }
        }
        if(ok)
            left = mid;
        else
            right = mid - 1;
    }
    cout << left << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n;
  cin >> n;
  vector<long> ans;
  for(long i=11;ans.size()!=n;i+=10) {
    bool p=true;
    for(long j=2;j*j<=i&&p;j++) {
      if(i%j==0) p=false;
    }
    if(p) ans.push_back(i);
  }
  for(long i=0;i<n;i++) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int L;
int main()
{
	scanf("%d",&L);
	int n=0,m=0;
	for (int i=1;i<=L;i++)
		if ((1<<i)-1>=L) { n=i;break;}
	for (int i=1;i<n;i++) m+=2;
	for (int i=0;i<=n-2;i++)
		if ((L>>i)&1) m++;
	printf("%d %d\n",n,m);
	for (int i=1;i<n;i++)
	{
		printf("%d %d 0\n",i,i+1);
		printf("%d %d %d\n",i,i+1,1<<(n-i-1));
	}
	int now=L;
	for (int i=0;i<n-1;i++)
	if ((L>>i)&1)
	{
		now-=(1<<i);
		printf("%d %d %d\n",1,n-i,now);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
  ll K; cin >> K;
  int T;
  cin >> T;
  vector<int> sum(T);
  for(int i=0;i<T;i++){
    int x;
    cin >> x;
    sum[i]=x;
  }
  sort(sum.begin(),sum.end());
  reverse(sum.begin(),sum.end());
  if(sum[0]<=K/2)cout << 0;
  else cout << (sum[0]-K/2)*2-1-K%2;
}

/*



 */




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n, m, c[30];
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> c[i];
    
    int dp[50050];
    for (int i = 0; i <= n; i++) dp[i] = 1e9;
    dp[0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i - c[j] >= 0) dp[i] = min(dp[i], dp[i - c[j]] + 1);
        }
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3280
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
es=[[] for i in range(n)]
for i in range(n - 1):
   a, b = map(int, input().split())
   es[a - 1].append(b - 1)
   es[b - 1].append(a - 1)
def dfs0(v, d, p):
    if v == n - 1:
        return d
    for e in es[v]:
        if e != p:
            k = dfs0(e, d + 1, v)
            if k:
                if isinstance(k, int) and k // 2 == d:
                    return v, e
                return k
    return 0

def dfs1(v, p):
    if v == E:
        return 0
    cnt = 1
    for e in es[v]:
        if e != p:
            cnt += dfs1(e, v)
    return cnt

V, E = dfs0(0, 0, -1)
if  2*dfs1(0, -1) > n:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 117900
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int l,r,d;
  cin>>l>>r>>d;
  int cnt=0;
  FOR(i,l,r+1) {
    if(i%d==0)++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3636
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const L = Number.parseInt(inputStr[0]);
  const R = Number.parseInt(inputStr[1]);
  
  var min = 2018;  
  if ( L * R > 2019){
    if ( R - L < 2019) {
      const L2 = L % 2019;
      const R2 = R % 2019;
       
      for(var i1 = L2; i1 < R2; i1++){
        for(var i2 = i1+1 ; i2 < R2+1 ; i2++){
          min = Math.min(min,i1 * i2 % 2019);
          if(min === 0) { break; }
        }
      }
	  console.log(min);
    } else {
      console.log(0);
    }
  } else {
    //LとRの積が2019を超えないなら計算する必要がない
    console.log(L * (L+1));
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7488
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define rep(i,n) for(int i=1;i<=n;i++)
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  2019;

int n, m;
char s[N];
map<ll, ll> num;
void solve()
{
    scanf(" %s", s);
    int len = strlen(s);
    ll ans = 0, sum = 0, jk = 1;
    num[0]++;
    for(int i = len-1; i >= 0; --i) {
        sum = sum+jk*(s[i]-'0'); jk = (jk*10)%mod;
        sum = sum%mod;
        ans += num[sum]++;
    }
    printf("%lld\n", ans);
}


int main()
{
//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d", &n))
//    while(scanf("%d", &n)&&n)
    solve();
    return 0;
}


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

int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    int num[2] = {};
    for(int i = 0;i < m;i++){
        cin >> a[i];
        if(x < a[i])num[0]++;
        else num[1]++;
    }
    sort(num,num+2);
    cout << num[0] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

const double EPS = 1e-8;
typedef vector<double> vec;
typedef vector<vec> mat;

// Ax = b を解く A は正方行列
// 解がないか、一意でない場合は長さ０の配列を返す
vec gauss_jordan(const mat& A, const vec& b){
	int n = A.size();
	mat B(n, vec(n + 1));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			B[i][j] = A[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		B[i][n] = b[i];
	}
	// 掃き出し法
	for(int i = 0; i < n; i++){
		// 注目している変数の係数の絶対値が大きい式をｉ番目に持ってくる
		int pos = i;
		for(int j = i; j < n; j++){
			if(abs(B[j][i]) > abs(B[pos][i])){
				pos = j;
			}
		}
		swap(B[i], B[pos]);

		// 解がないか、一意でない
		if(abs(B[i][i]) < EPS){
			return vec();
		}

		// 注目している変数の係数を１にする
		for(int j = i + 1; j <= n; j++){
			B[i][j] /= B[i][i];
		}
		for(int j = 0; j < n; j++){
			if(i != j){
				// ｊ番目の式からｉ番目の変数を消去
				for(int k = i + 1; k <= n; k++){
					B[j][k] -= B[j][i] * B[i][k];
				}
			}
		}
	}
	vec x(n);
	// 後ろに並べたｂが解になる
	for(int i = 0; i < n; i++){
		x[i] = B[i][n];
	}
	return x;
}

int main(){

	while(true){
		int d;
		cin >> d;
		if(d == 0){
			break;
		}

		mat l1(d + 3, vec(d + 1));
		vec l2(d + 3);
		for(int i = 0; i < d + 3; i++){
			double val = 1;
			l1[i][0] = 1;
			for(int j = 1; j < d + 1; j++){
				val *= i;
				l1[i][j] = val;
			}
			cin >> l2[i];
		}
		for(int i = 0; i < d + 2; i++){
			mat A(d + 1, vec(d + 1));
			vec b(d + 1);
			for(int j = 0; j < i; j++){
				copy(l1[j].begin(), l1[j].end(), A[j].begin());
				b[j] = l2[j];
			}
			for(int j = i + 2; j < d + 3; j++){
				copy(l1[j].begin(), l1[j].end(), A[j - 2].begin());
				b[j - 2] = l2[j];
			}
			vec ret = gauss_jordan(A, b);
			bool flag = false;
			double S = 0;
			for(int j = 0; j < d + 1; j++){
				S += ret[j] * l1[i][j];
			}
			if(abs(S - l2[i]) < 1e-3){
				cout << i + 1 << endl;
				break;
			}
			if(i == d + 1){
				cout << 0 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3232
#include<stdio.h>
int main(void)
{
	int i,n,k,x,y,a;
	scanf("%d %d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d %d",&x,&y);
		if(x>=y){
			a=n-x+1;
			if(a>y)a=y;
			a%=3;
			if(a==1) printf("1\n");
			if(a==2) printf("2\n");
			if(a==0) printf("3\n");
		}
		else{
			a=n-y+1;
			if(a>x)a=x;
			a%=3;
			if(a==1) printf("1\n");
			if(a==2) printf("2\n");
			if(a==0) printf("3\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin>>N>>K;

  int ans = N - K + 1;
  cout<<ans<<endl;
   

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int p[110000];
int q[110000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d",p+i);
	}
	std::sort(p,p+b);
	for(int i=0;i<b-1;i++){
		q[i]=p[i+1]-p[i];
	}
	std::sort(q,q+b-1);
	int ret=0;
	for(int i=0;i<b-a;i++){
		ret+=q[i];
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
  int n, ma = 0;
  cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
    ma = max(ma, m[s]);
  }
  
  for (auto x : m) {
    if (x.second == ma) cout << x.first << endl;
  }
}

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

int main()
{
    vector<int> a(3);
    rep (i, 3)
        cin >> a[i];

    if (accumulate(a.begin(), a.end(), 0) > 21)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
number = [[0,0] for i in range(n)]
for i in range(n):
    number[i] = list(map(int, input().split()))
number.sort(key=lambda x:(x[0],x[1]))
count = 0
result = 0
for el in number:
    count += el[1]
    if count >= k:
        result = el[0]
        break
print(result)

Measured memory_bytes: 35368
# -*- coding: utf-8 -*-
def Palindrome(S):
    if len(S)==1:
        return "Yes"
    for i in range(int((len(S))/2)):
        if S[i]==S[len(S)-i-1]:
            YorN="Yes"
        else:
            YorN="No"
            break
    return YorN
S = input()
Sl = list(S)
left = right = "No"
if Palindrome(Sl) == "Yes":
    middle=int((len(Sl)-1)/2)
#    print(Sl[:middle],Sl[middle+1:])
    left  = Palindrome(Sl[:middle])
    right = Palindrome(Sl[middle+1:])
if left == "Yes" and right == "Yes":
    YorN = "Yes"
else:
    YorN = "No"
print(YorN)


Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc118/tasks/abc118_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// int lcm(ll a, ll b) { return a / gcd(a, b) * b; }

// W[d] = w : 数字 d を作るのに必要なマッチの本数が w
const int w[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
map<int, int> mp;
vector<string> memo; // N本のマッチを使ってできる最大の数
string stmax(string a, string b) {
    if (a.length() > b.length())
        return a;
    else if (a.length() < b.length())
        return b;
    return a > b ? a : b;
}
string dp(ll i) {
    if (i < 0)
        return "-1";
    if (i == 0)
        return "";
    if (memo[i].length() > 0)
        return memo[i];
    string ans = "";
    for (auto &x : mp) {
        string res = dp(i - x.first);
        if (res != "-1")
            ans = stmax(ans, to_string(x.second) + res);
    }
    if (ans == "")
        ans = "-1";
    return memo[i] = ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    REP(i, m) cin >> a[i];
    sort(ALL(a));
    // 小さい順にmapへ入れることで、同じコストなら大きい数を優先する
    for (auto &x : a) {
        mp[w[x]] = x;
    }
    memo.resize(n + 1);
    cout << dp(n) << endl;

    return 0;
}


Measured memory_bytes: 33280
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    int n;
    cin >> n;
    set<int> s;
    REP(i,0,n){
        int x;
        cin >> x;
        s.insert(x);
    }

    if ((int)s.size() % 2) cout << s.size() << endl;
    else cout << s.size() - 1 << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
long long n;
struct student {
	int idx;
	int num;
	bool operator<(const student& s) const {
		return num < s.num;
	}
}stu[100010];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		stu[i].idx = i;
		cin >> stu[i].num;
	}
	sort(stu + 1, stu + 1 + n);
	for (int i = 1; i < n; i++)
		printf("%d ", stu[i].idx);
	printf("%d\n", stu[n].idx);

}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int x, t;
    cin >> x >> t;
    cout << max(0, x - t) << endl;
    return 0;
}


Measured memory_bytes: 256