akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dwn(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int maxn=110;
const int mod=1000000007;
int n,A[maxn],f[2][maxn][maxn];
int Add(int& x,int y) {x+=y;if(x>=mod) x-=mod;}
int main() {
	scanf("%d",&n);
	rep(i,1,2*n-1) scanf("%d",&A[i]);
	sort(A+1,A+2*n);
	f[0][1][1]=1;int cur=0;
	rep(i,1,n-1) {
		cur^=1;memset(f[cur],0,sizeof(f[cur]));
		int al=A[n-i]!=A[n-i+1],ar=A[n+i]!=A[n+i-1];
		rep(j,1,2*i-1) rep(k,1,j) {
			int& ans=f[cur^1][j][k];if(!ans) continue;
			Add(f[cur][j+al+ar][k+al],ans);
			rep(z,1,k+al-1) Add(f[cur][j+al+ar-(k+al-z-1)][z],ans);
			rep(z,k+al+1,j+al+ar) Add(f[cur][j+al+ar-(z-(k+al)-1)][k+al+1],ans);
		}
	}
	int ans=0;
	rep(j,1,2*n-1) rep(k,1,j) Add(ans,f[cur][j][k]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
    ll k,n; cin>>k>>n;

    ll arr[n]{};

    rep(i,n)cin>>arr[i];

    ll dist1 = 0 ;

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

        dist1 += abs(arr[i-1] - arr[i]);
    }


    ll dist2 = 100000000000;

    rep(i , n){

        dist2 = min(dist2 , arr[i] + k-arr[(i+1)%n]);
    }

    if(dist1<dist2)
        cout<<dist1<<endl;
    else
        cout<<dist2<<endl;


    return 0;
}


Measured memory_bytes: 1792
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("output.txt", "w", stdout);
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;
    int i = 1;
    for(i = 1; b > 0; ++i)
    {
        int cnt = 0;
        int ni = i;
        while (ni % 100 == 0)
        {
            ++cnt;
            ni /= 100;
        }
        if (cnt == a)
            --b;
    }
    cout << i - 1 << endl;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

s = a.inject(&:+)
divs = []
i = 1
while i * i <= s
  if s % i == 0
    divs << i
    divs << s / i if s / i != i
  end
  i += 1
end
ans = []
divs.sort.reverse.each do |d|
  r = a.map { |x| x % d }.sort
  if r.all? { |x| x == 0 }
    puts d
    exit
  end
  sum = 0
  negs = [0].concat(r.map { |x| sum += x })
  sum = 0
  1.upto(n - 1) do |j|
    negop = negs[j] - negs[0]
    posop = ((n - j) * d - (negs[n] - negs[j]))
    if (negop == posop && negop <= k)
      puts d
      exit
    end
  end
end
p 1


Measured memory_bytes: 11256
#include<stdio.h>
int gcd(int a,int b){
	
	int r;
	if(a<b){
		int t = a;
		a = b;
		b = t;
	}
	
	for(;;){
		
		r=a%b;
		//printf("%d=%d??%d+%d\n",a,a/b,b,r);
		
		a = b;
		b = r;
		
		if(r==0)break;
	}
	
	return a;
}


int main (void){

	int a,b;
	
	scanf("%d %d",&a,&b);
	
	printf("%d\n",gcd(a,b));
	
return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;



const int MAX_V = 200000;
vector<int> G[MAX_V];
int V,E;
int s,t;
bool visitable[MAX_V];

void dfs(int v, int times){
    if(times == 0){
        return;
    }
    for(int i = 0;i < G[v].size();i++){
        visitable[G[v][i]] = 1;
        dfs(G[v][i], times-1);
    }
    return;
}

signed main(){

    cin >> V >>E;
    for(int i = 0;i < E;i++){
        cin >> s >>t;
        G[s-1].pb(t-1);
        G[t-1].pb(s-1);
    }

    queue <int>que;

    dfs(0,2);

    if(visitable[V-1] == 1)
        cout<< "POSSIBLE\n";
    else {
        cout<< "IMPOSSIBLE\n";
    }


    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

int main(){
        int n, k, a[51];
        cin >> n >> k;
        for(int i = 0; i < n; i++){
                cin >> a[i];
        }
        sort(a, a + n);
        int sum = 0;
        for(int i = n - 1; i >= n - k; i--){
                sum += a[i];
        }
        cout << sum <<endl;

        return 0;
}


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

signed main(){
	int K, i;
	scanf("%d", &K);
	string S;
	cin >> S;
	for(i = 0; i < K && i < S.size(); i++){
		printf("%c", S[i]);
	}
	if(S.size() > K){
		printf("...");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (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 W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

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


int n;
int dp[100010];
vector<vector<int> > v(100010);

int dfs(int a)
{
	vector<int> tmp;
	if(v[a].size() == 0)return dp[a] = 0;
	REP(i,v[a].size())
	{
		if(dp[v[a][i]] == -1)dfs(v[a][i]);
		tmp.PB(dp[v[a][i]]);
	}
	sort(ALL(tmp),greater<int>());
	
	int ret = 0;
	
	REP(i,tmp.size())
	{
		ret = max((ll)ret,tmp[i]+i+1);
	}
	
	return dp[a] = ret;
}

int main()
{
	REP(i,100010)dp[i] = -1;
	
	cin >> n;
	
	REP(i,n-1)
	{
		int tmp;cin >> tmp;
		v[tmp].PB(i+2);
	}
	
	dfs(1);
	
	cout << dp[1] << endl;
	
	return 0;
}


Measured memory_bytes: 13952
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(cur_pos: usize, visited: Vec<usize>, link: &Vec<Vec<usize>>) -> i32 {
    let mut count = 0;
    let mut visited_clone = visited.clone();
    visited_clone.push(cur_pos);

    if visited_clone.len() == link.len() {
        return 1;
    }

    for &next in link[cur_pos].iter().filter(|&x| !visited_clone.contains(x)) {
        count += dfs(next, visited_clone.clone(), link);
    }
    count
}

fn main() {
    let A: usize = read();
    let P: usize = read();

    println!("{}", (A*3+P)/2);
}



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

using namespace std;

void Main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 2010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
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);}
typedef pair<int,int> P;
int n,Z,W;
int A[N];

int mem[N][2][2];
bool used[N][2][2];
int dfs(int idx,int cnt,int turn,int X,int Y){
  //cout<<idx1<<" "<<idx2<<" "<<cnt<<" "<<turn<<" "<<X<<" "<<Y<<endl;
  if(idx == n) return abs(X - Y);
  if(used[idx][cnt][turn]) return mem[idx][cnt][turn];
  used[idx][cnt][turn] = 1;

  int res = 0;  
  if(turn == 0){
    res = -INF;    
    Max(res,dfs(idx+1,1,turn,A[idx],Y));
    if(cnt) Max(res,dfs(idx,0,!turn,X,Y));
  }
  else if(turn == 1) {
    res = INF;
    Min(res,dfs(idx+1,1,turn,X,A[idx]));
    if(cnt) Min(res,dfs(idx,0,!turn,X,Y));
  }
  else assert(0);
  return mem[idx][cnt][turn] = res;
}

signed main(){
  cin>>n>>Z>>W;
  for(int i=0;i<n;i++) {
    cin>>A[i];
  }  

  cout<<dfs(0,0,0,Z,W)<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> A;

signed main()
{
    cin >> N;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
    }
    SORT(A);
    bool isChange = true;
    while(A[0] < A[N-1]) {
        // 一番小さい値でほかの全てを引く
        for(int i = 1; i < N; ++i) {
            if(A[i] % A[0] == 0) { A[i] = A[0]; }
            else { A[i] %= A[0]; }
        }
        SORT(A);
    }
    printf("%lld\n", A[0]);
    return 0;
}


Measured memory_bytes: 1024
x,y,a,b,c = map(int,input().split())
p = [int(i) for i in input().split()]
q = [int(j) for j in input().split()]
r = [int(k) for k in input().split()]

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
cou = p[:x]+q[:y]+r
cou.sort(reverse=True)
print(sum(cou[:x+y]))

Measured memory_bytes: 23340
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;

	auto ans = s <= "2019/04/30" ? "Heisei" : "TBD";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
import bisect


n, t = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
INF = t + 1
LIMIT = 60

# mrkt_a0: a == 0 の店
# mrkt_others: a != 0 の店
mrkt_a0 = []
mrkt_others = []

for i in range(n):
    a, b = info[i]
    if a == 0:
        mrkt_a0.append((a, b))
    else:
        comp = a / (1 + b)
        mrkt_others.append((a, b, comp))

mrkt_a0.sort(key=itemgetter(1))
mrkt_others.sort(key=itemgetter(2), reverse=True)

# mrkt_a0について
# もしmarkt_a0を尋ねるなら尋ねるのを後回しにしたほうが良い
times_a0 = [0]
for a, b in mrkt_a0:
    times_a0.append(times_a0[-1] + 1 + b)

# mrkt_othersについて
len_others = len(mrkt_others)
dp = [[INF] * LIMIT for i in range(len_others + 1)]
dp[0][0] = 0

for i in range(len_others):
    a, b, _ = mrkt_others[i]
    for cnt in range(LIMIT):
        # i番目の店を尋ねないとき
        dp[i + 1][cnt] = min(dp[i][cnt], dp[i + 1][cnt])
        # i番目の店を尋ねるとき
        if cnt + 1 < LIMIT:
            dp[i + 1][cnt + 1] = min(a * (dp[i][cnt] + 1) + b + dp[i][cnt] + 1, dp[i + 1][cnt + 1])

ans = 0
for cnt in range(LIMIT):
    if dp[-1][cnt] == t + 1:
        continue
    nokori = t - dp[-1][cnt]
    cnt_a0 = bisect.bisect_right(times_a0, nokori) - 1
    ans = max(ans, cnt + cnt_a0)

print(ans)

Measured memory_bytes: 252884
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;

string s;

int main()
{
    int i,j,k;
    
    cin>>s;
    
    if(s.length()>=4 && s.substr(0,4)=="YAKI")
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextLong();
        long m = sc.nextLong();
        long d = sc.nextLong();
        
        long s = d == 0 ? n : ((n - d) * 2);
        so.println((double) s/n/n*(m-1));
    }
}

Measured memory_bytes: 21844
// atcoder/agc039/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  lli k;
  while (cin >> s >> k) {
    vector<string> v;
    string t;
    each (c, s) {
      if (t.size() && t.back() != c) {
        v.push_back(t);
        t = "";
      }
      t += c;
    }
    if (t.size()) v.push_back(t);

    if (v.size() == 1) {
      cout << s.size() * k / 2 << endl;
      continue;
    }

    lli x = 0;
    if (v.front().front() == v.back().back()) {
      x += (v.front().size() + v.back().size()) / 2 * (k - 1);
      x += v.front().size() / 2;
      x += v.back().size() / 2;
      lli sum = 0;
      for (int i = 1; i + 1< v.size(); ++i) {
        sum += v[i].size() / 2;
      }
      cout << sum * k + x << endl;
    } else {
      lli sum = 0;
      each (i, v) sum += i.size() / 2;
      cout << sum * k << endl;
    }



  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
    int n,z;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> z;
        a[z] = i;
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(){
	char i,h;
	int j=0,k[1000]={0},a;
	while(scanf("%c",&i)!=EOF){
		/*scanf("%c",&i);
		if(i=='\n'){
			break;
		}
		else */if('a'<=i&&i<='z'){
			k[i]++;
		}
		else if('A'<=i&&i<='Z'){
			i=i+32;
			k[i]++;
		}
	}
	for(a='a';a<='z';a++){
		printf("%c : %d\n",a,k[a]);
	}
	return 0;
}

Measured memory_bytes: 544
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;

    char a = s[k - 1];
    for (int i = 0; i < s.size(); ++i){
        if (s[i]!= a) {
            s[i] = '*';
        }
    }

    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define MAX (ll)(1e18)
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	ll t[n], a[n];
	for(int i = 0; i < n; i++)
	{
		cin >> t[i] >> a[i];
		//cout << t[i] << " " << a[i] << endl;
	}
	ll tt[n], aa[n];
	tt[0] = t[0], aa[0] = a[0];
	//cout << tt[0] << " " << aa[0] << endl;
	for(int i = 1; i < n; i++)
	{
		ll lo = 0;
		ll hi = (MAX/max(t[i],a[i]))+1;
		while(hi-lo>1)
		{
			ll mid = (lo+hi)>>1;
			if(mid * t[i] >= tt[i-1] && mid * a[i] >= aa[i-1])
			{
				hi = mid;
			}
			else
			{
				lo = mid;
			}
		}
		tt[i] = hi * t[i];
		aa[i] = hi * a[i];
		//cout << hi << endl;
		//cout << t[i] << " " << a[i] << endl;
		//cout << tt[i] << " " << aa[i] << endl;
	}
	cout << tt[n-1] + aa[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
a = np.zeros([M], dtype=int)
b = np.zeros([M], dtype=int)
for i in range(M):
    a[i], b[i] = map(int, input().split())
idx = np.argsort(b)
a = a[idx]
b = b[idx]
c = b[0] - 1
ans = 1
for i in range(1, M):
    if a[i] <= c:
        continue
    else:
        c = b[i] - 1
        ans += 1
print(ans)

Measured memory_bytes: 21040
from fractions import gcd

N = int(input())
A = [int(i) for i in input().split()]

cuml = [0]
cumr = [0]

for i in range(N):
    cuml.append(gcd(cuml[i], A[i]))
    cumr.append(gcd(cumr[i], A[N-i-1]))


maxg = 0
for i in range(N):
    # print(gcd(cuml[i], cumr[N-i-1]))
    maxg = max(maxg, gcd(cuml[i], cumr[N-i-1]))
print(maxg)

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

struct Job {
    int deadline, duration, idx;

    bool operator<(Job o) const {
        return deadline < o.deadline;
    }
};

vector<int> compute_schedule(vector<Job> jobs) {
    sort(jobs.begin(), jobs.end());

    set<pair<int,int>> s;
    vector<int> schedule;
    for (int i = jobs.size()-1; i >= 0; i--) {
        int t = jobs[i].deadline - (i ? jobs[i-1].deadline : 0);
        s.insert(make_pair(jobs[i].duration, jobs[i].idx));
        while (t && !s.empty()) {
            auto it = s.begin();
            if (it->first <= t) {
                t -= it->first;
                schedule.push_back(it->second);
            } else {
                s.insert(make_pair(it->first - t, it->second));
                t = 0;
            }
            s.erase(it);
        }
    }
    return schedule;
}
int32_t main()
{
	IOS;
	int n;
	cin >> n;
	vector<Job> v;
	rep(i,1,n)
	{
		int x;
		cin >> x;
		int y;
		cin >> y;
		Job j;
		j.deadline = y;
		j.duration = x;
		j.idx = i;
		v.pb(j);
	}
	vector<int> vv = compute_schedule(v);
	if(vv.size()==n)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 19436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

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

int main() {
    int N; cin >> N;
    vi A(N); rep(i, N) cin >> A[i];
    bool ok = true;

    // 1
    const int AMAX = 1000005;
    vi c(AMAX);
    rep(i, N) c[A[i]]++;

    for (int i = 2; i < AMAX; i++) {
        int cnt = 0;
        for (int j = i; j < AMAX; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    // 2
    ok = true;
    int y = A[0];
    rep(i, N - 1) {
        y = gcd(y, A[i + 1]);
        if (y == 1) break;
    }
    if (y != 1) ok = false;
    if (ok) {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
}


Measured memory_bytes: 11024
#include<stdio.h>

int main(){
  int n,k,i,j,s,m,h;
  scanf("%d %d",&n,&k);
  int l[n];
  
  for(i=0;i<n;i++)
    scanf("%d",&l[i]);
  
  s=0;
  
  for(i=0;i<k;i++){
    m=0;
    h=0;
    for(j=0;j<n;j++){
      if(m<=l[j]){
        m=l[j];
        h=j;
      }
    }
    l[h]=0;
    s=s+m;
  }
  
  printf("%d",s);
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N;cin>>N;
    int T, A; cin >> T >> A;
    vector<pair<float, int> > V(N);
    REP(i, N)
    {
        int h; cin >> h;
        float t = T - (h*0.006);
        V.at(i) = make_pair(abs(t-A), i+1);
    }
    sort(ALL(V));
    cout << V.front().second << endl;
    return 0;
}



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

int main() {
	int y, m, d;
	while (cin >> y >> m >> d) {
		string ans;
		int c;
		if ((y > 1989) || (y == 1989 && (m > 1 || (m == 1 && d >= 8)))) { ans = "heisei"; c = y - 1988; }
		else if ((y > 1926) || (y == 1926 && (m > 12 || (m == 12 && d >= 25)))) { ans = "showa"; c = y - 1925; }
		else if ((y > 1912) || (y >= 1912 && (m > 7 || (m == 7 && d >= 30)))) { ans = "taisho"; c = y - 1911; }
		else if ((y > 1868) || (y >= 1868 && (m > 9 || (m == 9 && d >= 8)))) { ans = "meiji"; c = y - 1867; }
		else { puts("pre-meiji"); continue; }
		cout << ans << ' ' << c << ' ' << m << ' ' << d << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

vector<vi> e;
bool v[2000];
bool rec(int c, int s, vi &tmp, int lim){
	if(tmp.size() > lim) return 0;
	if(c == s && v[c]) return 1;
	if(v[c]) return 0;
	v[c] = 1;
	tmp.pb(c);
	for(int i : e[c]) if(rec(i, s, tmp, lim)) return 1;
	tmp.pop_back();
	return 0;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	e.resize(n);
	rep(i, m){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
	}
	
	auto trial = [n](int s, int lim){
		vi tmp;
		memset(v, 0, sizeof(v));
		if(rec(s, s, tmp, lim)) return tmp;
		return vi(n + 1, 0);
	};
	
	vi best(n + 1, 0);
	int prev = n + 1;
	
	rep(i, n){
		vi t = trial(i, prev - 1);
		if(t.size() >= prev) continue;
		int lo = 0, hi = prev - 1, mid;
		while(lo + 1 < hi){
			mid = (lo + hi) / 2;
			vi u = trial(i, mid);
			if(u.size() <= n) hi = mid;
			else lo = mid;
		}
		best = trial(i, prev = hi);
	}
	
	if(best.size() > n){
		cout << -1 << endl;
	}
	else{
		cout << best.size() << endl;
		for(int i : best) cout << i + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")

#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <queue>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <random>
#include <cassert>

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pi acos(-1.0)
#define uniq(v) (v).erase(unique((v).begin(),(v).end()),(v).end())
#define fcin(a) ifstream cin(a);
#define fcout(a) ofstream cout(a);
#define inf (long long)(4e10)
#define MOD 1000000007

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    while (true)
    {
        bool d = true;
        for (int i = 2; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                d = false;
                break;
            }
        }
        if (d) return cout << n, 0;
        n++;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
s=[0]*(n-1)
tmp=0
for i in range(n-1):
    tmp=(tmp+a[(i+1)*-1])%(10**9+7)
    s[(i+1)*-1]=tmp
    
print(int((s*a[:-1]%(10**9+7)).sum()%(10**9+7)))

Measured memory_bytes: 49532
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
// #define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    vi diff(n);
    rep(i,n){
        diff[i]= i-a[i];
    }
    bool ch=true;
    rep(i,n)if(diff[i]<0||diff[i]>i)ch=false;
    rep(i,n-1)if(diff[i+1]-diff[i]<0)ch=false;
    if(!ch){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    set<int> s;
    for(int i=n-1;i>=0;i--){
        if(s.find(diff[i])!=s.end()){
            continue;
        }else{
            s.insert(diff[i]);
            ans+=i-diff[i];
        }
    }
    fin(ans);


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll dp[MAXn][3];
ll act[MAXn][3];
int main(){
  IOS();
  ll n;
  cin >> n;
  REP (i,n) REP (j,3) cin >> act[i][j], dp[i][j] = INF;

  REP (i,3) dp[0][i] = act[0][i];
  REP1 (i,n-1) {
    dp[i][0] = act[i][0] + max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = act[i][1] + max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = act[i][2] + max(dp[i-1][0],dp[i-1][1]);
  }
  cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int r;cin >> r;
    cout << 3* r* r;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  ll N,x;
  cin>>N>>x;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  ll ans=0;
  for(int i=0;i<N-1;i++){
    if(a.at(i)>x){
      ans+=a.at(i+1)+a.at(i)-x;
      a.at(i+1)=0;
      a.at(i)=x;
    }else if(a.at(i)+a.at(i+1)>x){
      ans+=a.at(i)+a.at(i+1)-x;
      a.at(i+1)-=a.at(i)+a.at(i+1)-x;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    t = [["#"] * 100 for _ in range(50)] + [["."] * 100 for _ in range(50)]
    w, b = map(int, input().split())
    w, b = w - 1, b - 1
    br = False
    for i in range(0, 50, 2):
        for j in range(0, 100, 2):
            if w == 0:
                br = True
                break
            t[i][j] = "."
            w -= 1
        if br: break
    br = False
    for i in range(51, 100, 2):
        for j in range(0, 100, 2):
            if b == 0:
                br = True
                break
            t[i][j] = "#"
            b -= 1
        if br: break
    print(100, 100)
    for x in t:
        print(*x, sep="")

main()


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

const int maxn = 100010;
int n, a[maxn];
unordered_map<int, int> mp;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]), mp[a[i]]++;
    }
    int mx = 0, sec = 0;
    long long ans = 0;
    for (auto p : mp) {
        if (p.second >= 4) {
            ans = max(ans, 1LL * p.first * p.first);
        }
        if (p.second >= 2) {
            if (mx < p.first) sec = mx, mx = p.first;
            else sec = max(sec, p.first);
        }
    }
    printf("%lld\n", max(ans, 1LL * mx * sec));
    return 0;
}

Measured memory_bytes: 7900
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    int N,M,X;
    int table[12][12];
    int ans = 1001001001;
    cin >> N >> M >> X;
    vector<int> C(N);
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> table[i][j];        
        }
    }

    for(int i=0; i<(1<<N); i++){
        int cost = 0;
        vector<int> sum(M,0);
        for(int j=0; j<N; j++){
            if((i>>j) & 1){
                cost += C[j];
                for(int k=0; k<M; k++){
                    sum[k] += table[j][k];
                }
            }
        }
        bool check = true;
        for(int l=0; l<M; l++){
            if(sum[l]<X){
                check = false;
            }
        }
        if(check){
            ans = min(ans,cost);
        }
    }

    if(ans == 1001001001){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

}


Measured memory_bytes: 3632
from collections import Counter
from string import ascii_lowercase

def biggest(s):
    common = ''
    for c in ascii_lowercase:
        if all(map(lambda d: c in d, s)):
            occurrences = min(map(lambda d: d[c], s))
            common += c * occurrences
    return common


if __name__ == '__main__':
    s = [Counter(input()) for _ in range(int(input()))]
    print(biggest(s))

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

using namespace std;

int main()
{
   int A, B, K, ans;
   int n = 0;

   cin >> A >> B >> K;

   for(int i = (A >= B) ? B : A; i >= 1; i--){
      if(!(A % i)){
         if(!(B % i)){
            n++;
            if(n == K){ans = i; break;}
         }
      }
   }

   cout << ans << endl;

   return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int b=0;
  int c=0;
  int count=0;
  for(int i=0;i<N;i++){
    if(a[i]==1){
      c=1;
    }
  }
  if(c==0){
    cout << -1 << endl;
  }
  else{
    int num=1;
    for(int i=b;i<N;i++){
      if(a[i]==num){
        num++;
      }
      else{
        count++;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e4;
ll N,a[MAX_N+1],b[MAX_N];
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
bool isprime[MAX_N+1];
void era(){
	memset(isprime,true,sizeof(isprime));
	isprime[0]=isprime[1]=false;
	FOR(i,2,N+1){
		if(isprime[i]){
			for(ll j=i*2;j<=N;j+=i){
				isprime[j]=false;
			}
		}
	}
}
bool prime(ll x){
	if(x==1)return false;
	for(ll i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N+1)cin>>a[N-i];
	era();
	set<ll> ans;
	FOR(p,2,N+1){
		if(!isprime[p])continue;
		memset(b,0,sizeof(b));
		b[0]=a[0];
		REP(i,N){
			b[i%(p-1)+1]+=a[i+1];
		}
		bool flg=true;
		REP(i,p){
			if(b[i]%p!=0)flg=false;
		}
		if(flg){
			ans.insert(p);
		}
	}
	ll g=a[0];
	REP(i,N)g=gcd(g,abs(a[i+1]));
	for(ll i=1;i*i<=g;i++){
		if(g%i==0){
			if(prime(i)){
				ans.insert(i);
			}
			if(prime(g/i)){
				ans.insert(g/i);
			}
		}
	}
	for(auto i:ans){
		cout<<i<<endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >>n;
  string s;
  cin >>s;
  ll ans = 0;
  rep1(i,s.size()-2){
    {
    char l,c,r;
    if(s[i]=='R'){
      l = 'G';
      r = 'B';
    }
    else if(s[i]=='G'){
      l = 'R';
      r = 'B';
    }
    else if(s[i]=='B'){
      l = 'G';
      r = 'R';
    }
    ll lc =0;
    ll rc =0;
    set<int> smap;
    for(int j = i-1;j>=0;j--){
      if(s[j]==l) {
        lc++;
        smap.insert(i - j);
      }
    }
    for(int j = i+1;j<s.size();j++){
      if(s[j]==r){
         rc++;      
        if(smap.count(j-i)) ans--;
      }
    }
    ans += lc * rc;
    }
{
    char l,c,r;
    if(s[i]=='R'){
      r = 'G';
      l = 'B';
    }
    else if(s[i]=='G'){
      r = 'R';
      l = 'B';
    }
    else if(s[i]=='B'){
      r = 'G';
      l = 'R';
    }
    ll lc =0;
    ll rc =0;
    set<int> smap;
    for(int j = i-1;j>=0;j--){
      if(s[j]==l) {
        lc++;
        smap.insert(i - j);
      }
    }
    for(int j = i+1;j<s.size();j++){
      if(s[j]==r){
         rc++;      
        if(smap.count(j-i)) ans--;
      }
    }
    ans += lc * rc;
    }





  }

  cout << ans << endl;


  return 0;
    

}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

void solve() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({b * c, a * c,  b* d, a * d});
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 3640
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


inline ll calc(ll ed, ll x) {
  return (ed+x-1) / x;
}

int main(void) {
  ll a, b, x;
  scanf("%lld%lld%lld", &a, &b, &x);
  printf("%lld\n", calc(b+1, x) - calc(a, x));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(INF)
#define INF 1e17
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define W first
#define V second

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,lim; cin>>n>>lim;
	int s=0;
	vector<pii> v(n);
	for(auto &i:v){
		cin>>i.W>>i.V;
		s+=i.V;
	}
	vector<int> dp(s+1,INF);
	dp[0]=0;
	For(i,0,n-1){
		for(int j=s;j>=0;j--){
			if(j+v[i].V<=s) dp[j+v[i].V]=min(dp[j+v[i].V],dp[j]+v[i].W);
		}
	}
	for(int i=s;i>=0;i--){
		if(dp[i]<=lim){
			cout<<i<<"\n";
			return 0;
		}
	}
}


























Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
//const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, k;
	cin >> n >> k;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	vll sum(n + 1, 0);
	for (ll i = 0; i < n; i++) {
		sum[i + 1] = sum[i] + a[i];
		sum[i + 1] %= k;
	}//sum[i] := (aの先頭i項の和) % k

	vll v(n + 1, 0);
	for (ll i = 0; i < n; i++) {
		v[i + 1] = sum[i + 1] - i - 1;
	}

	//for (ll i = 0; i < n; i++) cout << v[i + 1] << endl;

	ll ans = 0;
	unordered_map<ll, ll> mp;
	mp[v[0]]++;
	for (ll j = 1; j <= n; j++) {
		if (j >= k) mp[v[j - k]]--;
		ans += mp[v[j]];
		ans += mp[v[j] + k];
		mp[v[j]]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 21492
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int X;
    cin >> X;
    cout << X / 3 << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

int main(){
  int k,a,b;
  std::cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      std::cout << "OK";
      exit(0);
    }
  }
  std::cout << "NG";
}

Measured memory_bytes: 3608
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
//#include "unordered_map"
//#include "unordered_set"
#include "iomanip"
#include "cmath"
//#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

//const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> K;
	}
	cin >> K;
	for (int i = 0; i < K; i++)cout << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

int main(){
    string s,t;
    cin >> s>>t;
    int ans = 0;
    for(int i  =0;i<3;++i){
        if(s[i]==t[i])++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import itertools as ite
from decimal import *
import math

INF = 10 ** 18

n = input()
p = map(int, raw_input().split())
S = ""
prev = [-1] * (n + 1)
nex = [0] + [-1] * (n + 1)
num_p = 0
for num in p:
    if num > num_p:
        num_next = num_p
        while num_next <= num:
            if nex[num_next] != -1:
                id = num_next
                while nex[num_next] != -1:
                    num_next = nex[num_next] + 1
                nex[id] = num_next - 1
            S += "("
            num_next += 1
        S += ")"
        nex[num] = num
        prev[num] = num
    else:
        num_prev = num_p - 1
        while prev[num_prev] != -1:
            num_prev = prev[num_prev] - 1
        if num_prev != num:
            print ":("
            exit()
        prev[num_p] = num_prev
        nex[num] = num
        prev[num] = num
        S += ")"
    num_p = num
print S



Measured memory_bytes: 14732
console.log((args=>{
  const [N,S] = args.trim().split`\n`;
  const s = S.split``.map(c=>c.charCodeAt()-97);
  const a = Array(26).fill(1);
  const MOD = 1e9+7;
  const mul = (a,b)=>((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;
  for ( let i = 0; i < N; i++ ) a[s[i]]++;
  return `${a.reduce(mul)-1}`;
})(require('fs').readFileSync('/dev/stdin','utf8')));


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

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A + 2), t(B + 2), x(Q);
    s[0] = -1e11;
    t[0] = -1e11;
    s[A + 1] = 1e11;
    t[B + 1] = 1e11;
    rep(i, A) cin >> s[i + 1];
    rep(i, B) cin >> t[i + 1];
    rep(i, Q) cin >> x[i];
    rep(i, Q) {
        ll ans = 1e18;
        int j = upper_bound(s.begin(), s.end(), x[i]) - s.begin();
        int k = upper_bound(t.begin(), t.end(), x[i]) - t.begin();
        //cout << "i=" << i << " j=" << j << " k=" << k << endl;
        ll d = s[j] - x[i];
        if (t[k] > s[j]) d = t[k] - x[i];
        //cout << "d=" << d << endl;
        if (d < ans) ans = d;
        d = x[i] - s[j - 1];
        if (t[k - 1] < s[j - 1]) d = x[i] - t[k - 1];
        //cout << "d=" << d << endl;
        if (d < ans) ans = d;
        d = s[j] - x[i] + s[j] - t[k - 1];
        //cout << "d=" << d << endl;
        if (d < ans) ans = d;
        d = x[i] - t[k - 1] + s[j] - t[k - 1];
        //cout << "d=" << d << endl;
        if (d < ans) ans = d;
        d = t[k] - x[i] + t[k] - s[j - 1];
        //cout << "d=" << d << endl;
        if (d < ans) ans = d;
        d = x[i] - s[j - 1] + t[k] - s[j - 1];
        //cout << "d=" << d << endl;
        if (d < ans) ans = d;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  string s;cin>>s;
  int f=0;
  if(s[0]==s[1]&&s[1]==s[2])f=1;
  if(s[1]==s[2]&&s[2]==s[3])f=1;
  if(f==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256