akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll v[20000000];
int main(){
	int n;cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		v[i]++;
		for(int j=2*i;j<=n;j+=i){
			v[j]++;
		}
		ans+=v[i]*(ll)i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 81728
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define per(i,x,y) for(in i=y;i>=(x);--i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

in mdc(in x, in y)
{
	if(x < y) 
	{
		in a=x,b=y;
		x=b;
		y=a;
	}
	if(y == 0) return x;
	else return mdc(y,x%y);
}


int main()
{
	IOS;
	in a,b;
	cin >> a >> b;
	cout << a*b/mdc(a,b) << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define M_PI 3.14159265358979
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main()
{
	int N;
	cin >> N;
	vector<vector<int>> D(N, vector<int>(2, 0));

	int ans = 0;
	int cnt = 0;
	rep(i, N) {
		cin >> D[i][0] >> D[i][1];
		if (D[i][0] == D[i][1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}

	if (ans >= 3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 1000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);

int in[N];
vector<int> g[N];
int n;
int m;
int dp[N];

int main() {
	cin >> n >> m ;
	for(int i = 0 ,a , b ; i < m ; i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		in[b]++;
	}
	queue<int> q;
	int node;
	for(int i = 1 ; i <= n ; i++){
		if(in[i])
			continue;
		q.push(i);
	}
	int ans = 0;
	while(!q.empty()){
		node=q.front();
		q.pop();
		for(int i = 0 ;i < g[node].size() ; i++){
			dp[g[node][i]]=max(1+dp[node],dp[g[node][i]]);
			ans = max(ans,dp[g[node][i]]);
			in[g[node][i]]--;
			if(!in[g[node][i]])
				q.push(g[node][i]);
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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;
    if (t&1) a *= *this;
    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;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  //fact 階乗　iface 階乗の逆数
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    mint ans = 0;
    combination c(2000005);
    for(int i = 0;i<=k;i++){
        ans += c(n+k-i-1,n-1)*mint(26).pow(i)*mint(25).pow(k-i);
    }
    cout << ans << endl;
}

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

std::vector<int> color;
std::vector<std::vector<int>> M;
std::vector<int> d;
std::vector<int> p;
int INF = 1001001001;
int sum = 0;

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

    d[0] = 0;
    p[0] = -1;

    while(true){
        int u;
        int mincost = INF;
        for(int i = 0; i < n; i++){
            if(color[i] != 1 && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(mincost == INF){
            break;
        }

        color[u] = 1;

        for(int i = 0; i < n; i++){
            if(color[i] != 1 && M[u][i] != -1){
                if(M[u][i] < d[i]){
                    d[i] = M[u][i];
                }
            }
        }

    }
    
    for(int i = 0; i < d.size(); i++){
        sum += d[i];
    }

    return sum;
}

int main(void){
    int n;
    std::cin >> n;

    color.resize(n);
    M.resize(n, std::vector<int>(n));
    d.resize(n);
    p.resize(n);

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

    std::cout << prim(n) << std::endl;

    return 0;
}


Measured memory_bytes: 3160
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
#Binary Indexed Tree (1-index！！！！！！！！)
class BinaryIndexedTree():
    def __init__(self, size):
        self.__node=[0]*(size+1)
        self.size = size

    #node[index]にvalueを足して、BITを更新
    def add(self, index, value):
        while index <= self.size:
            self.__node[index] += value
            index += index&-index    
    
    #indexまでの和を返す
    def sum(self, index):
        ret = 0 #零元・単位元
        while index > 0:
            ret += self.__node[index]
            index -= index&-index    
        return ret

    def update_max(self, index, value):
        while index <= self.size:
            self.__node[index] = max(self.__node[index], value)
            index += index & -index


    #indexまでの最大値を返す
    def query_max(self, index):
        ret = 0
        while index > 0:
            ret = max(ret, self.__node[index])
            index -= index & -index
        return ret
        
        

    #0-indexでの添字を受け取って、1-indexでの添字での値を返す
    def get_node(self, index):
        return self.__node[index]
def main():
    N=I()
    A=LI()
    def solve(is_minus):
        B=BinaryIndexedTree(N)
        # print(is_minus)
        for i,a in enumerate(A,start=1):
            B.add(i,a)
        res = 0
        for i in range(1,N+1):
            s = B.sum(i)
            # print("sum",B.sum(i),"is_minus",is_minus)
            if is_minus:
                if s>=0:
                    res += abs(s-(-1))
                    B.add(i,(-1-s))
            else:
                if s<=0:
                    res += abs(s-1)
                    B.add(i,abs(s-1))
            # print(res)
            is_minus ^= 1
        return res

    ans = min(solve(True), solve(False))
    print(ans)
    # *cumsum, = accumulate(A)
    # print(cumsum)/
if __name__ == '__main__':
    main()

Measured memory_bytes: 61916
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << 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++)
using ll = long long;

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;

    if (a-k>0)
    {
        a -= k ;
    }
    else if (a+b-k>0)
    {
        b=a+b-k; 
        a=0;
    }
    else
    {
        a=0;
        b=0;
    }
    
    
    cout << a << " " << b << endl;
}

Measured memory_bytes: 3616
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, x int
    fmt.Scan(&n, &x)
    nums := make([]int,n);
    s := 0

    for i := 0; i < n; i++ {
    	fmt.Scan(&nums[i])
    	s+=nums[i]

    }

    if(x==s) {
    	fmt.Println(n)
    	return
    } else if(x>s) {
    	fmt.Println(n-1)
    	return
    }

    sort.Ints(nums)
    ans := 0
    for i := 0; i < n ; i++ {
    	if x>=nums[i] {
    		x-=nums[i]
    		ans++
    	} else {
    		break
    	}    
    }	

	fmt.Println(ans)
}

Measured memory_bytes: 512
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class UnionFind:
	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)
		self.size = [1] * (n + 1)

	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def same_check(self, x, y):
		return self.find(x) == self.find(y)

	def union(self, x, y):
		x = self.find(x); y = self.find(y)
		if self.rank[x] < self.rank[y]:
			if self.same_check(x, y) != True:
				self.size[y] += self.size[x]
				self.size[x] = 0
			self.par[x] = y
		else:
			if self.same_check(x, y) != True:
				self.size[x] += self.size[y]
				self.size[y] = 0
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def getsize(self, x):
		x = self.find(x)
		return self.size[x]

def main():
	N, Q = getlist()
	UF = UnionFind(N)
	for i in range(Q):
		q, u, v = getlist()
		if q == 0:
			UF.union(u, v)
		else:
			if UF.same_check(u, v):
				print(1)
			else:
				print(0)

if __name__ == '__main__':
	main()

Measured memory_bytes: 84072
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n;
    cin >> n;
    bool ok = 1;
    while(n--){
        ll x;
        cin >> x;
        if(x & 1)
            continue;
        if(x % 3 == 0 || x % 5 == 0){
            
        }
        else
            ok = 0;
    }
    if(ok)
        cout << "APPROVED\n";
    else
        cout << "DENIED\n";
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
}


Measured memory_bytes: 256
import itertools
N = int(input())
A = list(map(int, input().split()))
ans = 0
sumall = 0
for j in range(N):
    sumall += A[j]
for i in range(N):
    ans += A[i]*(sumall-A[i])
    sumall = sumall - A[i]

print(ans % (10**9+7))

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

int main() {
  
  int x,y,z;
  int temp;
  cin>>x>>y>>z;
  temp=x;
  x=z;
  z=y;
  y=temp;

  cout<<x<<" "<<y<<" "<<z<<endl;



  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        double d = sc.nextDouble();

        out.print(d*d*d*Math.pow(27, -1));
        out.flush();

    }

}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
int ca, cb;
int main() {
	int n, a[110];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (i % 2)ca += a[i];
		else cb += a[i];
	}
	cout << abs(ca - cb) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;



int main(){
    vector <int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end(), greater <int> ());

    int k;
    cin >> k;

    cout << v[0] * pow(2, k) + v[1] + v[2] << endl;

    return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int n;
VI as;
VI likes;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> n;
	likes.resize(n + 1);
	rep (i, n) {
		int a;
		cin >> a;
		as.pb(a);
		likes[i + 1] = a;
	}
	int ans = 0;
	rep (i, as.size()) {
		if (i + 1 == likes[as[i]]) {
			ans++;
		}
	}
	cout << ans / 2 << endl;

	return 0;
}



Measured memory_bytes: 1276
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    int h,cnt=0;
    for(int i=0;i<n;i++){
        cin >> h;
        if(k<=h)    cnt++;
    }
    cout << cnt;
}   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n)%mod / (fct(m) * fct(n - m))%mod) % mod;
	return x;
}

int main(void) {
	int  n; cin >> n;
	string str; cin >> str;
	rep(i, str.size()) {
			char x = str.at(i);
			x += n;
			if (x > 90) {
				x -= 26;
			}
			cout << x;
	}
	return 0;
}


Measured memory_bytes: 256
line = input().split()
stack = []
for i in range(len(line)):
    obj = line[i]
    if obj.isnumeric():
        stack.append(obj)
    else:
        b = int(stack.pop(-1))
        a = int(stack.pop(-1))
        if obj == '+':
            stack.append(a+b)
        elif obj == '-':
            stack.append(a-b)
        else:
            stack.append(a*b)
print(stack[0])

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

int n, s, res[10][330] = { 0 };
bool num[10] = { 0 };
void combinations(int c, int sum) {
	if (c == 11) return ;
	for (int i = 0; i < 10; i++) {
		if (num[i]) continue;
		num[i] = 1;
		++res[c + 1][sum + i * (c + 1)];
		combinations(c + 1, sum + i * (c + 1));
		num[i] = 0;
	}
}

int main() {
	combinations(0, 0);
	while (cin >> n) {
		cin >> s;
		if (s > 330) {
			n = 0;
			s = 0;
		}
		cout << res[n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m;
string s;

// index が条件を満たすかどうか vector<>maeに検索したいvectorを入れる keyを超える最小の要素番号を返す
bool isOK(int index, long long key, vector<long long>&mae) {
	if (mae[index] >= key) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(long long key, vector<long long>&mae) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)mae.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key, mae)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

string conv(long long a) {
	string ca = "";
	ca += to_string(a);
	string ret = "";
	for (int i = 0; i < 6-ca.size(); i++)
	{
		ret += "0";
	}
	ret += ca;
	return ret;
}


int main() {
	cin >> n >> m;
	vector<vector<long long>> p(n+1, vector <long long>());
	vector<PLL> c(m+1);
	for (int i = 0; i < m; i++)
	{
		cin >> c[i].first >> c[i].second;
		p[c[i].first].push_back(c[i].second);
	}
	for (int i = 0; i < n+1; i++)
	{
		sort(p[i].begin(), p[i].end());
	}
	for (int i = 0; i < m; i++)
	{
		string ans = conv(c[i].first);
		ans += conv(binary_search(c[i].second, p[c[i].first]) + 1);
		cout << ans << endl;
	}
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n;
	 cin>>n;
	 vector<int>a,b,c;
	 for(int i=0;i<n;i++)
	 {
	 	  int x,y,z;
	 	  cin>>x>>y>>z;
	 	  a.emplace_back(x);
	 	  b.emplace_back(y);
	 	  c.emplace_back(z);
	 }
	 int dp[n][3];
	 dp[0][0]=a[0];
	 dp[0][1]=b[0];
	 dp[0][2]=c[0];
	 for(int i=1;i<n;i++)
	 {
	 	 dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
	 	 dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
	 	 dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	 }
	 cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
	 return 0;
}

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

int main()
{
  int N,K;
  cin>>N>>K;
  
  int h[N];
  int i,j;
  for(i=0;i<N;i++)
  {
    cin>>h[i];
  }
  
  int dp[N]={0};
  int t;
  for(i=1;i<N;i++)
  {
    t=1000000010;
    for(j=max(0,i-K);j<i;j++)
    {
      if(dp[j]+abs(h[j]-h[i])<t)
        t=dp[j]+abs(h[j]-h[i]);
    }
    dp[i]=t;
  }
  
  
  
 /* for(i=K;i<N;i++)
  {
    for(j=0;j<K;i++)
    {
      dp[i][j]=
    }
    dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(h[i]-h[i-1]);
    dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(h[i]-h[i-2]);
  }*/
  cout<<dp[N-1]<<endl;
  return 0;
}

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

typedef long long ll;

int main(void)
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    //a[n] = k;
    rep(i, n) cin >> a[i];

    int max_num = 0;
    rep(i, n-1)
    {
        max_num = max(max_num, a[i +1] - a[i]);
    }

    max_num = max(max_num, a[0] + k - a[n-1]);

    cout << k - max_num << endl;

    return 0;
}



Measured memory_bytes: 1024
let n = read_int ()
let cs, ds = Array.(make n 0, make n 0)
let rec f n a = if n <= 0 then a else f (n - 1) (2 * a mod 1000000007)
let _ = for _ = 1 to n do Scanf.scanf " %d" @@ fun a -> cs.(a) <- cs.(a) + 1 done; for i = 1 to n / 2 do ds.(n mod 2 + 2 * i - 1) <- 2 done; ds.(0) <- n mod 2; Printf.printf "%d\n" @@ if cs = ds then f (n / 2) 1 else 0

Measured memory_bytes: 5632
#if 0

#endif
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
ll n;
ll a[100000];
vector<ll> lis_min_last;
void solve() {
    for (int nn = 0; nn < n; ++nn) {
        // cout << "size: " << lis_min_last.size() << endl;
        if (lis_min_last.size() == 0 || lis_min_last.back() < a[nn]) {
            lis_min_last.push_back(a[nn]);
        } else {
            auto it = lower_bound(lis_min_last.begin(), lis_min_last.end(), a[nn]);
            if (it == lis_min_last.end()) continue;
            if (lis_min_last.size() == 1) lis_min_last.back() = a[nn];
            else if (lis_min_last[lis_min_last.size() - 2] < a[nn]) 
                lis_min_last.back() = a[nn]; 
            else if (*it > a[nn]) 
                *it = a[nn];
        }
        // for (auto e : lis_min_last) {
        //     cout << e << " ";
        // }
        // cout << endl;
    }
    cout << lis_min_last.size() << endl;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    #define ll int

    cin >> n;
    // cout << "i" << n << endl;
    for (int nn = 0; nn < n; ++nn) {
        cin >> a[nn];
        // cout << "i2 " << a[nn] << endl;
    }

    solve();

    return 0;
}


Measured memory_bytes: 4656
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long int
#define hmap        unordered_map
#define pii         pair<int,int>
#define pdd         pair<double, double> 
#define M           1000000007
#define MOD         998244353
#define fast        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test        ll t; cin>>t; while(t--)
#define inp(a,n)    int a[n]; for(int i=0;i<n;i++)  cin>>a[i];
#define inpl(a,n)   ll a[n];  for(ll i=0;i<n;i++)   cin>>a[i];
#define out(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define outl(a,n)   for(ll i=0;i<n;i++)  cout<<a[i]<<" "; cout<<endl;
#define outv(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl;
#define all(s)      (s).begin(),(s).end()

struct pair_hash
{
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using vote = pair<ll,ll>;
using Unordered_map = unordered_map<vote, ll, pair_hash>;
// int N = 1000002;
// hmap<ll,ll> h;
// void prime()
// {
//       ll dp[N]={};
//       for(ll i=3;i<N;i+=2)
//             dp[i]=1;
//       h[2]=1;
//       for(ll i=3;i<N;i+=2)
//       {
//             if(dp[i])
//             {
//                   for(ll j = i*i;j<N;j+=i)
//                         dp[j]=0;
//                   h[i]=1;
//             }
//       }
// }
// int base10(int n)
// {
//       int c=1;
//       while(n>9)
//       {
//             c++;
//             n = n/10;
//       }
//       return c;
// }
int main()
{
      fast
      //test
      {
            string a,b;
            cin>>a>>b;
            int n = a.length();
            int m = b.length();
            
            int dp[n+1][m+1]={};
            
            for(int i=1;i<=n;i++)
            {
                  for(int j=1;j<=m;j++)
                  {
                        dp[i][j] = dp[i-1][j-1];
                        if(a[i-1]==b[j-1])
                              dp[i][j] ++;
                        else
                              dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
                  }
            }
            
            string s;
            
            int i=n,j=m;
            while(i>0 && j>0)
            {
                  if(dp[i][j-1]==dp[i][j])
                        j--;
                  else if(dp[i][j]==dp[i-1][j])
                        i--;
                  else
                  {
                        s += a[i-1];
                        i--,j--;
                  }
            }
            
            reverse(s.begin(),s.end());
            cout<<s;
            
            
            
            
            
            
            
      }
}

Measured memory_bytes: 38816
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::vector<int> digit(int128_t n, const int128_t b) {
    // 基数bでの表示。0は0桁。非常に大きい数を入れても問題ないようにint128_tとする。intやlong longを入れても問題ないはず。
    // size()をとれば桁数になる。
    assert(1 < b);
    std::vector<int> ret;
    while (0 < n) {
        ret.push_back(n % b);
        n /= b;
    }
    return ret;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int K, X;

int main(int argc, char **argv) {
    std::cin >> K >> X;
    
    rep (i, X - K + 1, X + K - 1) {
        std::cout << i << " ";
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
a=list(map(int,input().split()))
table=[0 for i in range(10**6+7)]
flag=0
for i in a:
    table[i]+=1
    
for i in range(2,10**6+1):
    cnt=0
    j=i
    while(j<10**6+1):
        cnt+=table[j]
        j+=i
    if(cnt>1):
        flag=1
        break

if(flag==1):
    tmp=a[0]
    for i in range(1,n):
        tmp=math.gcd(tmp,a[i])
    if(tmp==1):
        flag=2



if(flag==0):
    print('pairwise coprime')
    
if(flag==1):
    print('not coprime')

if(flag==2):
    print('setwise coprime')

Measured memory_bytes: 217588
#include <bits/stdc++.h>
#define lld long long int
#define vi vector<int>
#define vlld vector<lld>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define mii map<int, int>
#define vii vector<pii>
 
using namespace std;
 
 
 
int main(){
   	std::ios::sync_with_stdio(false);


   	int n,l;
   	cin>>n>>l;
   	vector<string> v(n);
   	for(int i=0;i<n;i++){
   		cin>>v[i];
   	}   	
   	sort(v.begin(), v.end());
   	for(int i=0;i<n;i++){
   		cout<<v[i];
   	}  
   	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define Max 100001
#define inf 1000000000000000
using namespace std;
int n,m,flag;
int first[Max * 2],nextv[Max * 2],u[Max * 2],v[Max * 2],s[Max * 2];
long long vis[2][Max],l = 0,r = inf,ans;
void dfs(int from,int tag,long long va) {
    if(flag)return;
    int k = first[from];
    while(k != -1) {
        if(flag)return;
        int vtag = (tag == 1);
        int to = v[k];
        long long lva = s[k] - va;
        if(vis[vtag][to] != inf) {
            if(vis[vtag][to] == lva) {
                k = nextv[k];
                continue;
            }
            else {
                flag = 1;
                return;
            }
        }
        vis[vtag][to] = lva;
        if(vtag)r = min(r,lva);
        else l = max(l,-lva);
        if(r - l <= 1){
            flag = 1;
            return;
        }
        dfs(to,-tag,lva);
        k = nextv[k];
    }
}
int main() {
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 1;i <= n;i ++) {
        vis[0][i] = vis[1][i] = inf;
    }
    for(int i = 0;i < m;i ++) {
        scanf("%d%d%d",&u[i],&v[i],&s[i]);
        u[i + m] = v[i];
        v[i + m] = u[i];
        s[i + m] = s[i];
        nextv[i] = first[u[i]];
        first[u[i]] = i;
        nextv[i + m] = first[u[i + m]];
        first[u[i + m]] = i + m;
    }
    dfs(1,1,0);///dfs遍历所有点和第一个点的关系，如果有冲突flag为1 冲突就是说得到于同一点的同一关系的值不同比如a1 + a2 = 3 和 a1 + a2 = 4
    if(!flag) {///遍历后无冲突
        long long temp = -1;
        for(int i = 1;i <= n;i ++) {
            if(vis[0][i] != inf && vis[1][i] != inf) { ///可以确定a1
                long long d = vis[1][i] - vis[0][i];
                temp = d / 2;
            }
        }
        if(temp != -1) {///不能直接求出a1
            if(temp > l && temp < r)ans = 1;
        }
        else if(r - l - 1 > 0)ans = r - l - 1;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int N;
map<int,int> mp[3];

int main(){
  cin>>N;
  for(int i=0;i<3;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int id;
      cin>>id;
      mp[i][id]=1;
    }
  }
  int ans=0;
  for(int i=1;i<=N;i++){
    if(mp[2][i]==1){
      if(mp[0][i]==0||mp[1][i]==1){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    int a[3] = {};
    for (auto x: s) {
        a[x-'a']++;
    }
    sort(a, a+3);
    if (a[2]-a[0] <= 1) {
        puts("YES");
    }
    else {
        puts("NO");
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int k, x;
    cin >> k >> x;
    if (500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;;
int main(){
	
	int n, sum = 0,  ans = 1e9 + 90;
	scanf("%d",&n);
	vector <int > v(n);
	for(int &x : v)
		scanf("%d",&x),sum += x;
		
	int sum2 = 0;
	for(int i =0 ; i < n-1 ; i ++){
		sum2 += v[i] ;
		sum -= v[i] ;
		ans = min (ans,abs(sum2-sum));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const int INF = 1e9;
const int MAXN = 1e9;

int main()
{
	int n,t,a;
	cin >> n >>t >>a;
	t *= 1000;
	a *= 1000;
	vector<int> h(n);
	for(int i = 0; i < n; i++){
		cin >> h[i];
		h[i] = t - h[i]*6;
	}

	int min = INF,ans = -1;
	for(int i = 0; i < n; i++){
		if(abs(h[i]-a) < min){
			min = abs(h[i]-a);
			ans = i+1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  var input = chunk.split(' ');
  var x = parseInt(input[0], 10);
  var y = parseInt(input[1], 10);
  console.log(x * y + ' ' + (x + y) * 2);
});

Measured memory_bytes: 15588
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            var array = Console.ReadLine().Split();
            string s = array[0], t = array[1];
            string ans = string.Concat(s.Zip(t, (a, b) => a.ToString() + b.ToString()));
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int n, k, c;
	cin >> n >> k;
	for (c = 1; n >= k; n /= k)
		c++;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 384
/*  CF_CC_
            4U7H0R:_C4551DY */

#include <bits/stdc++.h>
#include <fstream>

using namespace std;

typedef long long ll;

#define IC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(a,b,c) for(ll a=b;a<c;a++)
#define lb lower_bound
#define pii pair<int,int>
#define vec vector<int>
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
#define len length()
#define rev reverse
#define con continue

const int mxi=2e5+666;
const ll mod=1e9;
const ll inf=1e18;

ll n,c,a[mxi];

int main(){
    IC
    cin >> n;
    rep(i,0,n){
        cin >> a[i];
        if(i>0 && a[i]<a[i-1]){
            c+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout << c;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  Bint N,C,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  num=1000000000000000001;
  sum=1;
  rep(i,0,N){
    cin >> C;
    sum*=C;
    chmin(sum,num);
  }
  if(sum==num)sum=-1;
  Out(sum);
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	sort(ALL(a));
	ans += a.back();
	a.pop_back();
	for(int i = 0; i < n - 2; i++) {
		ans += a.back();
		if(i & 1) a.pop_back();
	}
	cout << ans << endl;
	
}





Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN          1000000000000000000

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


//int dx[4]={0,0,1,-1};
//int dy[4]={1,-1,0,0};
// vector<int>adj[100001];
// int vis[100001]={0};
// vector<int>v1;

void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    set<int>st2;
    vector<int>v1;
    vector<int>v2;
    rep(i,0,n)
    {
        if(s[i]=='R')
            v1.pb(i);
        else if(s[i]=='G')
            st2.insert(i);
        else v2.pb(i);
    }
    int ans=0,a,b,c;
    rep(i,0,v1.size())
    {
        rep(j,0,v2.size())
        {
            if(v1[i]>v2[j])
            {
                a=(2*v2[j])-v1[i];
                b=(2*v1[i])-v2[j];
                if((v1[i]+v2[j])%2==0)
                c=(v1[i]+v2[j])/2;
            else c=-1;
            }
            else
            {
                a=(2*v1[i])-v2[j];
                b=(2*v2[j])-v1[i];
                if((v1[i]+v2[j])%2==0)
                c=(v1[i]+v2[j])/2;
            else c=-1;
            }
            int sum=st2.size();
            if(a>=0 && a<n)
            {
                if(st2.find(a)!=st2.end())
                    sum--;
            }
            if(b>=0 && b<n)
            {
                if(st2.find(b)!=st2.end())
                    sum--;
            }
            if(c>=0 && c<n)
            {
                if(st2.find(c)!=st2.end())
                    sum--;
            }
            ans+=sum;
        }
    }
    cout<<ans;

}   
    


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3760
#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 ans;
    if (s == "RRR") ans = 3;
    if (s == "SRR") ans = 2;
    if (s == "RRS") ans = 2;
    if (s == "RSR") ans = 1;
    if (s == "RSS") ans = 1;
    if (s == "SRS") ans = 1;
    if (s == "SSR") ans = 1;
    if (s == "SSS") ans = 0;
    cout << ans << endl;
    return 0;
}

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

int count(const string a, const string b){
    int ans(0);
    for(int i = 0,size = a.size(); i < size; ++i) if(a[i] != b[i]) ++ans;
    return ans;
}

int main() {
    string S,T,_S;
    int diff(0),ans(-1);
    cin >> S >> T;
    _S = S;

    diff = S.size() - T.size() + 1;

    for(int i = 0; i < diff; ++i){
        for(int k = 0,size = T.size(); k < size; ++k){
            S.replace(k + i,1,T.substr(k,1));
        }
        int c = count(S,_S);
        ans = (c <= ans || ans == -1) ? c : ans;
        S = _S;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3188
n=int(input())
L=list(map(int,input().split()))
sumL=[0 for _ in range(n)]
S=sum(L)
for i in range(n):
    if i==0:
        sumL[i]=L[i]
    else:
        sumL[i]=sumL[i-1]+L[i]
ans=2020202020
tmp1=0
tmp2=0
for i in range(n):
    tmp1=sumL[i]
    tmp2=S-sumL[i]
    ans=min(ans,abs(tmp1-tmp2))
print(ans)

Measured memory_bytes: 26764
import heapq
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))

# 前半と後半
first, second = [], []
heapq.heapify(first)
heapq.heapify(second)

first_sum, second_sum = 0, 0

for i in range(N):
    heapq.heappush(first, a[i])
    first_sum += a[i]
    heapq.heappush(second, -a[3 * N - 1 - i])
    second_sum += a[3 * N - 1 - i]

# first, secondそれぞれ0 - Nまで探索
L_sum = [first_sum]
R_sum = [second_sum]

for i in range(N, 2 * N):
    heapq.heappush(first, a[i])
    first_sum += a[i]
    first_sum -= heapq.heappop(first)
    L_sum.append(first_sum)

    heapq.heappush(second, -a[3 * N - 1 - i])
    second_sum += a[3 * N - 1 - i]
    second_sum -= - heapq.heappop(second)
    R_sum.append(second_sum)

ans = -10 ** 15

R_sum = R_sum[::-1]

for i in range(N + 1):
    ans = max(ans, L_sum[i] - R_sum[i])

# print(L_sum, R_sum)
print(ans)


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 10000000

using namespace std;

int main(){
  int n,u,v; cin>>n>>u>>v; u--; v--;
  vector<vector<pi>> g( n, vector<pi>() );
  rep(i, n-1){
    int a,b; cin>>a>>b; a--; b--;
    g[a].push_back( {1,b} );
    g[b].push_back( {1,a} );
  }

  if(g[u].size()==1 && g[u][0].second==v) { cout<<0<<endl; return 0; }

  set<int>s;
  vector<int>d(n);
  rep(i, n)d[i]=INF; 
  d[u]=0;

  priority_queue<pi, vector<pi>, greater<pi>> pq;
  pq.push( {0, u} );
  while( pq.size() ){
    auto cn = pq.top(); pq.pop();
    if(d[cn.second] < cn.first)continue;
    for(auto nn :g[cn.second]){
      if(cn.first+1 >= d[nn.second] || nn.second==v)continue;

      d[nn.second]=cn.first+1;
      pq.push( {d[nn.second], nn.second} );
    }
  }

  rep(i, n)if(d[i]!=INF)s.insert(i);
  s.insert(v);

  vector<int>d2(d);
  rep(i, n)d[i]=INF; 
  d[v]=0;
  pq.push( {0, v} );
 
  while( pq.size() ){
    auto cn = pq.top(); pq.pop();
    if(d[cn.second] < cn.first)continue;

    for(auto nn :g[cn.second]){
      if(cn.first+1 >= d[nn.second] || s.count(nn.second)==0 )continue;

      d[nn.second]=cn.first+1;
      pq.push( {d[nn.second], nn.second} );
    }
  }

//for(auto t: d2)cout<<t<<' ';cout<<endl;
//for(auto t: d)cout<<t<<' ';cout<<endl;

//bool f=true;
//rep(i, n)if((d[i]==1 || d2[i]==1) && d[i]!=d2[i])f=false;
//if(f) { cout<<1<<endl; return 0; }

  int result=0;
  rep(i, n)if(d[i]!=INF && d2[i]!=INF){
    if(d[i]<=d2[i])continue;
    result = max(result, d[i]-1);
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

void solve(){
	int n, m; cin >> n >> m;
	VVI G, P;
	rep(i,n){
		VI g; int a,b; cin >> a >> b;
		g.PB(a); g.PB(b);
		G.PB(g);
	}
	rep(i,m){
		VI p; int a,b; cin >> a >> b;
		p.PB(a); p.PB(b);
		P.PB(p);
	}
	VI ans;
	rep(i,n){
		int h = INF; int k = INF;
		int a,b; a=G[i][0]; b=G[i][1];
		rep(j,m){
			int c,d; c=P[j][0]; d=P[j][1];
			int t = abs(c-a)+abs(d-b);
			if(t<h) k=j;
			h = min(h,t);
		}
		ans.PB(k+1);
	}
	rep(i,n){
		cout << ans[i] << endl;
	}

	return;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

#define LIM_S 200002
#define LIM_N 100001

char str[LIM_S];

int A, B, C;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d %d", &A, &B, &C);
}

void initialize() {
}

int solve() {
	if (A < B) {
		if (A <= C && C <= B) {
			return 1;
		}
	} else {
		if (B <= C && C <= A) {
			return 1;
		}
	}

	return 0;
}

int main(void) {
	receive_input();
	initialize();

	printf("%s\n", solve() ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 128