akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back 
#define ff first
#define ss second
#define mod 1000000007
#define ll long long int
using namespace std;


int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
 
   int n,m;
   cin>>n>>m;
   

   vector<string >dist;
   
   for(int i=0;i<n;i++)
   {
	   string s;
	   cin>>s;
       dist.pb(s);
   }
   
   int mat[n*m][n*m];
   for(int i=0;i<n*m;i++)
   { 
	 for(int j=0;j<m*n;j++)
	 {
		 if(i==j)
		  mat[i][j]=0;
		 else
          mat[i][j]=10000;
      }
   }   
       
   for(int i=0;i<n;i++)
   {
	   for(int j=0;j<m;j++)
	   {
		    if(i-1>=0 && dist[i-1][j]=='.' && dist[i][j]=='.')
		       {
				   mat[m*(i-1)+j][m*i+j]=1;
				   mat[m*i+j][m*(i-1)+j]=1;
			   }
			 if(i+1<n && dist[i+1][j]=='.' && dist[i][j]=='.')
		       {
				   mat[m*(i+1)+j][m*i+j]=1;
				   mat[m*i+j][m*(i+1)+j]=1;
			   }
			   if(j-1>=0 && dist[i][j-1]=='.' && dist[i][j]=='.')
		       {
				   mat[m*i+j][m*i+(j-1)]=1;
				   mat[m*i+(j-1)][m*i+j]=1;
			   }
			    if(j+1<m && dist[i][j+1]=='.' && dist[i][j]=='.')
		       {
				   mat[m*i+j][m*i+(j+1)]=1;
				   mat[m*i+(j+1)][m*i+j]=1;
			   }
	   }
   }
   
     for (int k = 0; k < n*m; k++)  
    {  
        // Pick all vertices as source one by one  
        for (int i = 0; i < n*m; i++)  
        {  
            // Pick all vertices as destination for the  
            // above picked source  
            for (int j = 0; j < n*m; j++)  
            {  
                // If vertex k is on the shortest path from  
                // i to j, then update the value of dist[i][j]  
                if ((mat[i][k] + mat[k][j] < mat[i][j]))  
                    mat[i][j] = mat[i][k] + mat[k][j];  
            }  
        }  
    } 
    
    
    int ans=0;
   for(int i=0;i<n*m;i++)
    for(int j=0;j<m*n;j++)
      ((mat[i][j]!=10000)?(ans=max(ans,mat[i][j])):(ans=max(ans,ans)));
       
       cout<<ans;
  
   
   return 0;
}



Measured memory_bytes: 896
#include<iostream>

using namespace std;

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

	int n,m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a;
		cin >> a;
		n -= a;
	}
	if(n<0) cout << -1;
	else cout << n;
	return 0;
}


Measured memory_bytes: 3572
use std::cmp;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let n: usize;
    let k: usize;
    input!(n, k);
    let mut s = str2vec(&input_line_str());
    let mut v: Vec<usize> = Vec::new();
    v.push(0);
    let mut prev = '1';
    for z in &s {
        if *z == prev {
            let temp = v.len() - 1;
            v[temp] += 1;
        } else {
            v.push(1);
        }
        prev = *z;
    }
    if *s.last().unwrap() == '0' {
        v.push(0);
    }

    let mut max = 0;
    let mut buf = 0;
    for z in 0..2 * k + 1 {
        if z >= v.len() {
            break;
        }
        buf += v[z];
    }
    max = buf;

    let mut left = 0;
    let mut right = 2 * k;
    loop {
        right += 1;
        if right >= v.len() {
            buf += 0;
        } else {
            buf += v[right];
        }
        right += 1;
        if right >= v.len() {
            buf += 0;
        } else {
            buf += v[right];
        }

        buf -= v[left];
        if left >= v.len() {
            break;
        }
        left += 1;
        if left >= v.len() {
            break;
        }
        buf -= v[left];
        left += 1;
        max = cmp::max(buf, max);
        if right >= v.len() {
            break;
        }
    }
    p(max);
}

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

typedef long long int ll;

int main()
{
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(ll i = 0;i < h;i++){
        cin >> s[i];
    }

    ll gyo = -1, re = -1;
    for(ll i = 0;i < h;i++){
        bool f = true;
        for(ll j = 0;j < w;j++){
            if(s[i][j] == '#'){
                f = false;
            }
        }
        if(f){
            for(ll j = 0;j < w;j++){
                s[i][j] = '0';
            }
        }
    }

    for(ll i = 0;i < w;i++){
        bool f = true;
        for(ll j = 0;j < h;j++){
            if(s[j][i] == '#') f = false;
        }
        if(f){
            for(ll j = 0;j < h;j++){
                s[j][i] = '0';
            }
        }
    }

    for(ll i = 0;i < h;i++){
        bool f = false;
        for(ll j = 0;j < w;j++){
            if(s[i][j] != '0'){
                f = true;
                cout << s[i][j];
            }
        }
        if(f){
            cout << "\n";
        }
    }

    return 0;
}

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


int main()
{
	double x, y;
	int n, d, count = 0;
	
	cin >> n >> d;
	
	for(int i = 0; i < n; i++)
	{
		cin >> x >> y;
		
		double dist = sqrt(x*x + y*y);
		if(dist <= (double)d) count++;
	}
	
	cout << count << endl;
	
	return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

int dp[10005];

void solve(){
	int h,n;
	cin>>h>>n;
	vector<pair<int,int>>a(n);
	cin>>a;
	for(int i=1;i<=h;i++){
		dp[i]=1e9+100;
	}
	dp[0]=0;
	for(int i=0;i<=h;i++){
		for(int j=0;j<n;j++){
			dp[min(i+a[j].F,h)]=min(dp[min(i+a[j].F,h)],dp[i]+a[j].S);
		}
	}
	cout<<dp[h];
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 384
N, K = map(int, input().split())
l = list(map(int, input().split()))
cnt = [0 for _ in range(N)]
for i in l:
    cnt[i - 1] += 1
cnt.sort(reverse = True)
total = 0
for i in range(K):
    total += cnt[i]
print(N - total)

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

inline bool isset(int b, int i) {
    return (b & (1<<i)) != 0;
}

using namespace std;

int main() {
    int n, f[109][10], p[109][11];
    cin >> n;
    for(int i=0; i<n; i++) {
        for(int j=0; j<10; j++) {
            cin >> f[i][j];
        }
    }
    for(int i=0; i<n; i++) {
        for(int j=0; j<=10; j++) {
            cin >> p[i][j];
        }
    }
    
    int rmax = -1000000000;
    for(int t=1; t<1024; t++) {
        int r = 0;
        for(int i=0; i<n; i++) {
            int c=0;
            for(int j=0; j<10; j++) {
                if(isset(t, j) && f[i][j]==1) c++;
            }
            r += p[i][c];
        }
        rmax = max(rmax, r);
    }
    cout << rmax << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

/*ll merge(vector<ll> &v,ll l,ll m,ll r)
{
	ll n1=m-l+1;
	ll n2=r-m;
	ll inv=0;
	vector<ll> a(n1),b(n2);
	for(ll i=0;i<n1;i++)
	a[i]=v[l+i];
	for(ll i=0;i<n2;i++)
	b[i]=v[m+1+i];
	ll i=0,j=0,k=l;
	while(i<n1&&j<n2)
	{
		if(a[i]<=b[j])
		{
			v[k]=a[i];
			i++;
		}
		else
		{   inv+=(m-i+1);
			v[k]=b[j];
			j++;
		}
		k++;
	}
	while(i<n1)
	{
		v[k]=a[i];
		i++;
		k++;
	}
	while(j<n2)
	{
		v[k]=b[j];
		j++;
		k++;
	}
	return inv;
}
ll mergesort(vector<ll> &v,ll l,ll r)
{  ll inv=0;
	if(l<r)
	{
		ll m=l+(r-l)/2;
		inv=mergesort(v,l,m);
		inv+=mergesort(v,m+1,r);
		inv+=merge(v,l,m,r);
	}
	return inv;
}*/

/*ll factorize(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if((n/i)!=i)
            res.push_back(n/i);
        }
    }
    
    return (ll)res.size();
}*/
vector<ll> v[200005];
vector<ll> visited(200005,-1),cnt(200005,0);
void dfs(ll x,ll sum)
{
	for(ll i=0;i<v[x].size();i++)
	{
		if(visited[v[x][i]]==-1)
		{
			visited[v[x][i]]=sum+cnt[v[x][i]];
			dfs(v[x][i],sum+cnt[v[x][i]]);
		}
	}
	return;
}
void solve()
{ll n,k,ans,z,x,y,q,l=INT_MIN,mini=0,prev;
   cin>>n>>k;
   for(ll i=1;i<n;i++)
   {
   	 cin>>x>>y;
   	 v[x].pb(y);
   	 v[y].pb(x);
   }
   for(ll i=0;i<k;i++)
   {
   	 cin>>x>>y;
   	 cnt[x]+=y;
   }
   visited[1]=cnt[1];
   dfs(1,cnt[1]);
   for(ll i=1;i<=n;i++)
   cout<<visited[i]<<endl;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 25856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC116
{
	class Program
	{
		static void Main(string[] args)
		{
			int D;
			D = int.Parse(Console.ReadLine());
			if (D == 25)
			{
				Console.Write("Christmas");
			}
			if (D == 24)
			{
				Console.Write("Christmas Eve");
			}
			if (D == 23)
			{
				Console.Write("Christmas Eve Eve");
			}
			if (D == 22)
			{
				Console.Write("Christmas Eve Eve Eve");
			}
			Console.ReadKey();

		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)5e3 + 5;
ll n, m, p, a[MAXN], b[MAXN], c[MAXN], d[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> m >> p)
	{
		for (int i = 1; i <= m&&cin >> a[i] >> b[i] >> c[i]; ++i)
			c[i] -= p;
		fill(d + 1, d + 1 + n, ll(-1e18));
		d[1] = 0;
		for (int i = 1; i <= m; ++i)
			for (int j = 1; j <= m; ++j)
				d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
		ll ans1 = d[n];
		for (int i = 1; i <= m; ++i)
			for (int j = 1; j <= m; ++j)
				d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
		ll ans2 = d[n];
		cout << (ans2 > ans1 ? -1 : max(0LL, ans1)) << endl;
	}
}
/*
3 3 10
1 2 20
2 3 30
1 3 45

2 2 10
1 2 100
2 2 100

4 5 10
1 2 1
1 4 1
3 4 1
2 2 100
3 3 100
*/

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, K;
    cin>>N>>K;
    vi A(N);
    REP(i, 0, N) cin >> A[i];
    REP(i, 0, K){
        vi cum(N, 0);
        REP(j, 0, N){
            int l = max(0, j-A[j]);
            int r = min(j+A[j], N-1);
            cum[l]++;
            if(r+1 < N) cum[r+1]--;
        }
        REP(i, 1, N) cum[i] += cum[i-1];
        REP(i, 0, N) A[i] = cum[i];
        if(i>=64) break;
    }
    REP(i, 0, N) cout << A[i] << " ";
    cout << endl;
}

Measured memory_bytes: 4840
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	int a[2000] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n > 1) {
		cout << max(abs(y - a[n - 1]), abs(a[n - 2] - a[n - 1])) << "\n";
	}
	else {
		cout << abs(y - a[n - 1]) << "\n";
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		int D = sc.nextInt();

		if(D == 25){
			System.out.println("Christmas");
		}else if( D == 24){
			System.out.println("Christmas Eve");
		}else if(D == 23){
			System.out.println("Christmas Eve Eve");
		}else if(D == 22){
			System.out.println("Christmas Eve Eve Eve");
		}
    }
}

Measured memory_bytes: 19796
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int INF=1e9-5;

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   int m=b/a;
   if(m<=c)
    cout<<m<<endl;
   else
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  vector<int64_t> A(K);
  rep(i, K) { cin >> A[i]; }

  int64_t ans_min = 2;
  int64_t ans_max = 2;
  for (int i = K - 1; i >= 0; --i) {
    // cout << ans_min << " " << ans_max << endl;
    ans_min = (ans_min + A[i] - 1) / A[i] * A[i];
    ans_max = ans_max / A[i] * A[i] + A[i] - 1;
  }
  if (ans_min > ans_max)
    cout << -1 << endl;
  else
    cout << ans_min << " " << ans_max << endl;
  return 0;
}


Measured memory_bytes: 4020
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)
	values := strings.Split(str, "")

	sum := 0
	nth := 0
	for i := 0; i < len(values); i++ {
		if values[len(values)-i-1] == "B" {
			sum = sum + (i - nth)
			nth++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
ll int t;
t=1;

while(t--)
{ ll int n,m,i,j,k,count=0,flag=0,mini;
cin>>n;ll int a[n];
for(i=0;i<n;i++)
cin>>a[i];
mini=a[0];
for(i=0;i<n;i++)
{mini=min(a[i],mini);
    if(mini==a[i])
    count++;
}
    
    cout<<count<<endl;
    
    
    
    
    
}



 
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

std::vector<std::vector<int>> edges;
std::vector<int> d, f;

// dfs(x, t) := 頂点 x に時刻 t で初めて訪れたときに d, f を更新して戻ってきたときのタイムスタンプを返す
int dfs(int x, int t) {
	d[x] = t;

	for (int i = 0; i < edges[x].size(); ++i) {
		int dist = edges[x][i];
		if (d[dist] == -1)
			t = dfs(dist, t + 1);
	}

	f[x] = t + 1;
	return f[x];
}

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

	edges.resize(n);
	d.resize(n, -1);
	f.resize(n);

	for (int i = 0; i < n; ++i) {
		int u, k;
		std::cin >> u >> k;
		--u;

		for (int j = 0; j < k; ++j) {
			int v;
			std::cin >> v;
			--v;

			edges[u].push_back(v);
		}
	}

	int t = 0;
	for (int i = 0; i < n; ++i)
		if (d[i] == -1)
			t = dfs(i, t + 1);

	for (int i = 0; i < n; ++i)
		std::cout << i + 1 << " " << d[i] << " " << f[i] << std::endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
   
   ll n,w;
   cin>>n>>w;
   vector<ll>V(n),W(n);int val=0;
   for(int i=0;i<n;i++)
   {
       cin>>W[i]>>V[i];val+=V[i];
   }
   vector<ll>dp(val+1,INT_MAX);dp[0]=0;
   for(int i=0;i<n;i++)
   {
       for(int j=val;j>=V[i];j--)
       {
           if(dp[j-V[i]]!=INT_MAX){dp[j]=min(dp[j],dp[j-V[i]]+W[i]);}
       }
   }
  int ans=0;
  for(int j=val;j>=1;j--)
  {
      if(dp[j]!=INT_MAX && dp[j]<=w){ans=j;break;}
  }
  cout<<ans;
	return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a == 'A'){
		cout<<"T\n";
	}
	else if(a == 'T'){
		cout<<"A\n";
	}
	else if(a == 'C'){
		cout<<"G\n";
	}
	else{
		cout<<"C\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 'No'
    a,b,c = map(int, input().split())
    k=int(input())
    for _ in range(k):
        if a>=b:
            b*=2
        elif b>=c:
            c*=2
    if a<b<c:
        ans='Yes'

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	int h, w; std::cin >> h >> w;
	std::vector<std::string> state(h); for (auto& line : state) std::cin >> line;
	std::vector<int> row, column;
	for (auto i = 0; i < h; ++i) for (auto j = 0; j < w; ++j) {
		if (state[i][j] == '#') {
			row.push_back(i);
			column.push_back(j);
		}
	}
	std::sort(row.begin(), row.end()); std::sort(column.begin(), column.end());
	row.erase(std::unique(row.begin(), row.end()), row.end()); column.erase(std::unique(column.begin(), column.end()), column.end());
	for (const auto& r : row) {
		std::string line;
		for (const auto& c : column) {
			line.push_back(state[r][c]);
		}
		std::cout << line << '\n';
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;



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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    string s;
    cin>>s;
    vector<int> arr(26);
    int f=1;

    for(int i=0;i<s.size();i++){
        if(arr[s[i]-'a']==1){
            cout<<"no"<<endl;
            f=0;
            break;
        }else{
            arr[s[i]-'a']++;
        }
    }
    if(f) cout<<"yes"<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    Int sum = a1 + a2 + a3;
    if (sum > 21) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x[19], y[19], h[129][19][19], dp[65555][549]; bool vis[65555][549]; map<pair<int, int>, vector<pair<int, int> > > d; vector<vector<pair<int, int> > > v;
int gcd(int pa, int pb) {
	if (pb == 0) return pa;
	return gcd(pb, pa % pb);
}
int solve(int bit, int p1, int p2, int cur) {
	if (p1 == v.size()) return 0;
	if (p2 == v[p1].size()) {
		int res = solve(bit, p1 + 1, 0, 0);
		return res + cur * (cur - 1) / 2;
	}
	if (vis[bit][h[p1][p2][cur]]) return dp[bit][h[p1][p2][cur]];
	int pa = v[p1][p2].first, pb = v[p1][p2].second;
	int ret = solve(bit, p1, p2 + 1, cur);
	if (!(bit & (1 << pa)) && !(bit & (1 << pb))) {
		int res = solve(bit | (1 << pa) | (1 << pb), p1, p2 + 1, cur + 1);
		ret = max(ret, res);
	}
	vis[bit][h[p1][p2][cur]] = true;
	dp[bit][h[p1][p2][cur]] = ret;
	return ret;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int vx = x[j] - x[i], vy = y[j] - y[i];
			if (vy < 0) vy = -vy, vx = -vx;
			if (vy == 0 && vx < 0) vx = -vx;
			int g = gcd(abs(vx), vy);
			d[make_pair(abs(vx) / g * (vx > 0 ? 1 : -1), vy / g)].push_back(make_pair(i, j));
		}
	}
	for (pair<pair<int, int>, vector<pair<int, int> > > i : d) {
		v.push_back(i.second);
	}
	int curs = 0;
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			for (int k = 0; k <= j; k++) {
				h[i][j][k] = curs++;
			}
		}
	}
	int ret = solve(0, 0, 0, 0);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 155980
#include <stdio.h>
int main(void)
{
	int X;
	int i;
	int re = 0;
	scanf("%d", &X);
	for (i = 1; i <= X; i++){
			if (i == 1 ||i == 4 ||i == 8 || i == 9 ||i == 16 ||i == 25 ||i == 27 ||i == 32 ||i == 36 ||i == 49 ||i == 64 ||i == 81||i == 100 ||i == 121 ||i == 125 ||i == 144 ||i == 169 ||i == 196 ||i == 216 ||i == 225 ||i == 243 ||i == 256 ||i == 289 ||i == 324||i == 343||i == 361||i == 400 ||i == 441 ||i == 484 ||i == 512 ||i == 529 ||i == 576 ||i == 625 ||i == 676 ||i == 729 ||i == 784 ||i == 841 ||i == 900 ||i == 961 ||i == 1000){			if  (re < i){
					re = i;
				}
			}
	}
	printf("%d\n", re);
	return 0;
}
	

Measured memory_bytes: 128
s=input()
pp=s[0]
p=s[1]
for i in range(len(s)-2):
    c=s[i+2]
    if pp==p:
        print(i+1,i+2)
        break
    elif p==c:
        print(i+2,i+3)
        break
    elif pp==c:
        print(i+1,i+3)
        break
    p,pp=c,p
else:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)


Measured memory_bytes: 39280
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){

  int n=0, k=0, q=0, kt=0;
  cin >> n >> k >> q;
  kt = k-q;

  vector<int> a(n), b(q);
  for(int i=0; i<q; ++i){
    cin >> b[i];
    a[b[i]-1]+=1;
  }

  for(int i=0; i<n; ++i){
    a[i]+=kt;
    if(a[i] <= 0)
      cout<< "No" <<endl;
    else
      cout<< "Yes" <<endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    for(ll i = 1 ; i <= n ; i++)
    {
        if(i%3 != 0 && i%5 != 0)sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int lineCount = Integer.parseInt(scanner.nextLine());
        int primeCount = 0;
        for (int i = 0 ; i < lineCount ; i++) {
            if (isPrimeNumber(Integer.parseInt(scanner.nextLine()))) {
                primeCount++;
            }
        }
        System.out.println(primeCount);
    }
    
    private static boolean isPrimeNumber(int n) {
        
        if (n == 2) {
            return true;
        }
        
        if (n % 2 == 0) {
            return false;
        }
        
        for (int i = 3; i <= Math.sqrt(n) ; i += 2) {
           if (n % i == 0) {
                return false;
            }
        }

        return true;
    }
}



Measured memory_bytes: 60136
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(i,x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
const int maxn=2e5+6;
const int mod=1e9+7;
int n,a[maxn],num,b[maxn],f[maxn],sum[maxn];

int main(){
    n=read();
    f[0]=1;
    rep(i,1,n){
        a[i]=read();
        if(a[i]!=a[i-1])b[++num]=a[i];
    }
    n=num;
    rep(i,1,n){
        f[i]=f[i-1];
        f[i]=(f[i]+sum[b[i]])%mod;
        sum[b[i]]=(sum[b[i]]+f[i-1])%mod;
    }
    cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string N;
  cin>>N;
  if(N.at(0)=='7'||N.at(1)=='7'||N.at(2)=='7')return cout<<"Yes"<<endl,0;
  else return cout<<"No"<<endl,0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
string t;
cin >> t;
rep(i,t.size()){
  if(t.at(i) == '?') t.at(i) = 'D';
}
cout << t << endl;
}


Measured memory_bytes: 3712
/*
 author : @itzmv
 */
#include<bits/stdc++.h>
using namespace std;

#define ll uint64_t
#define lli long long int
#define MAX 1000
#define MOD 1000000007


int main()
{
    ll x, y;
    cin >> x >> y;
    if(x == y)
        cout << -1;
    else
    {
        for(ll i = 2;  i < 100005; i++)
        {
            if((x * i) % y != 0)
            {
                cout << x * i ;
                return 0;
            }
        }

        cout << -1;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
nega = 0
ans = 0
mi = 10**10
for i in a:
    if i<0:
        nega += 1
    mi = min(mi, abs(i))
    ans += abs(i)
if nega%2==0:
    print(ans)
else:
    print(ans-mi*2)

Measured memory_bytes: 14412
#include<iostream>
using  namespace std;
int main()
{
    int n,k,x,y,total; cin>>n>>k>>x>>y;
    if(n>k)
    {
        int f = n-k;
        int sum1 = k*x;
        int sum2 = f*y;
        total = sum1+sum2;
    }
    else
    {
         total = n*x;
    }
    cout<<total<<endl;
}


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

namespace AtCoder
{
    public interface IInputReader
    {
        string Read();
    }

    public interface IOutputWriter
    {
        void Write(string output);
    }

    class ConsoleInputReader : IInputReader
    {
        public string Read() => Console.ReadLine();
    }

    class ConsoleOutputWriter : IOutputWriter
    {
        public void Write(string output) => Console.WriteLine(output);
    }

    class Program
    {
        static void Main(string[] args)
        {
            var reader = new ConsoleInputReader();
            var writer = new ConsoleOutputWriter();
            new Solver(reader, writer).Solve();
        }
    }

    public class Solver
    {
        private readonly IInputReader _inputReader;
        private readonly IOutputWriter _outputWriter;

        public Solver(IInputReader inputReader, IOutputWriter outputWriter)
        {
            _inputReader = inputReader;
            _outputWriter = outputWriter;
        }

        public void Solve()
        {
            var n = ReadLong();
            var alphabets = "abcdefghijklmnopqrstuvwxyz";
            var result = "";
            while (n > 0)
            {
                n -= 1;
                var a = (int) (n % 26);
                n /= 26;

                var c = alphabets[a];
                result = c + result;
            }

            _outputWriter.Write(result);
        }

        private string Read() => _inputReader.Read();
        private char[] ReadChars() => Array.ConvertAll(Read().Split(), a => a[0]);
        private int ReadInt() => int.Parse(Read());
        private long ReadLong() => long.Parse(Read());
        private double ReadDouble() => double.Parse(Read());
        private int[] ReadInts() => Array.ConvertAll(Read().Split(), int.Parse);
        private long[] ReadLongs() => Array.ConvertAll(Read().Split(), long.Parse);
        private double[] ReadDoubles() => Array.ConvertAll(Read().Split(), double.Parse);
    }
}

Measured memory_bytes: 27480
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

const int N = 3e5;

int x, y, a, b, c, p[N], q[N], r[N], ans, cur;

main() {
    cin >> x >> y >> a >> b >> c;
    rep(i, 0, a) cin >> p[i];
    rep(i, 0, b) cin >> q[i];
    rep(i, 0, c) cin >> r[i];
    sort(p, p + a);
    sort(q, q + b);
    sort(r, r + c);
    reverse(p, p + a);
    reverse(q, q + b);
    reverse(r, r + c);
    ans = 0;
    rep(i, 0, x) ans += p[i];
    rep(i, 0, y) ans += q[i];

    int i = x - 1, j = y - 1;
    rep(k, 0, c) {
        cur = r[k];
        if (i >= 0 && cur > p[i] && (j < 0 || q[j] >= p[i])) {
            ans += cur - p[i];
            i--;
        } else if (j >= 0 && cur > q[j]) {
            ans += cur - q[j];
            j--;
        } else {
            break;
        }
    }
    cout << ans << '\n';

}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();
		int r = 1;
		char c = s.charAt(0);
		for(int i=1;i<n;i++){
			char t = s.charAt(i);
			if(c == t) continue;
			c = t;
			r++;
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 24360
import java.util.Scanner;

class Main {
    public static void main(String[] argv) {
        Scanner sc = new Scanner(System.in);

        float m;
        String[] l = sc.nextLine().split(" ");
        m = Float.parseFloat(l[1]);

        String[] ints = sc.nextLine().split(" ");
        int[] numbers = new int[ints.length];
        int sum = 0;
        for(int i = 0; i < ints.length;i++) {
            numbers[i] = Integer.parseInt(ints[i]);
            sum += numbers[i];
        }
        int c = 0;
        for(int i: numbers) {
            if (i >= sum * (1.0 / (4.0 * m))) c++;
        }
        if (c >= m)System.out.println("Yes");
        else System.out.println("No");

        sc.close();
        
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  int price=0;
  for(int i=0;i<N;i++){
    price=max(price,P.at(i));
  }
  int halfprice=price/2;
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=P.at(i);
  }
  ans=ans-price+halfprice;
  cout<<ans<<endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;

ll power(ll x,ll n)
{
	ll res =1;
	while(n>0)
	{
		if(n%2==1)
	res=res*x;
	x=x*x;
	n=n/2;
	}
	return res;
	
}
int main(){
 
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,x,y;
    cin>>n;
    vector<pair<ll,ll> >v;
    for(i=0;i<n;i++)
    {
    	cin>>x>>y;
    	v.push_back({x+y,x-y});
	}
	sort(v.begin(),v.end());
	int count=0;
     x=v[0].first;
	for(i=1;i<n;i++)
	{
		if(v[i].second<x)
		{
			count++;
			
		}
		else
		{
			x=v[i].first;
		}
	}
	cout<<n-count;
}


Measured memory_bytes: 2420
import heapq
import sys
input = sys.stdin.readline
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

#########################
n= int(input())

edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b,i])
l=sorted(l,key=lambda x: -x[0])
for i in range(n-1):
    x=l[i][2]
    y=l[i+1][2]
    z=l[i][0]-l[i+1][0]
    edge[x].append([z,y])
    edge[y].append([z,x])
l=sorted(l,key=lambda x: -x[1])
for i in range(n-1):
    x=l[i][2]
    y=l[i+1][2]
    z=l[i][1]-l[i+1][1]
    edge[x].append([z,y])
    edge[y].append([z,x])
print(prim_heap())


Measured memory_bytes: 122544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<int> dsum(n + 1), msum(n + 1);
    dsum[0] = 0, msum[0] = 0;
    for(int i = 0; i < n; ++i){
        dsum[i + 1] = dsum[i] + (s[i] == 'D');
        msum[i + 1] = msum[i] + (s[i] == 'M');
    }

    for(int loop = 0; loop < q; ++loop){
        int k;
        cin >> k;

        ll ans = 0;
        int left = 0, right = 0;
        ll dmcnt = 0;
        while(right < n){
            if(right - left < k){
                if(s[right] == 'C'){
                    ans += dmcnt;
                }
                else if(s[right] == 'M'){
                    dmcnt += dsum[right] - dsum[left];
                }
                ++right;
            }
            else{
                if(s[left++] == 'D'){
                    dmcnt -= msum[right] - msum[left];
                }
                if(s[right] == 'C'){
                    ans += dmcnt;
                }
                else if(s[right] == 'M'){
                    dmcnt += dsum[right] - dsum[left];
                }
                ++right;
            }
        }
        
        cout << ans << '\n';
    }
}

Measured memory_bytes: 12180
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

*/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

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

bool compare(pair<int,int>p1, pair<int,int>p2){

  return p1.second > p2.second;
 }

 // sorting the map when the first is string ans second is the integer
 bool sortbyval(pair<string,int>a, pair<string,int>b){
   return a.second < b.second;
 }


int main(){

 string s;
 cin>>s;

 for(int i=0;i<s.length();i++)
 {
    if(i%2 == 0){
      if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
        continue;
      else {
          cout<<"No"<<endl;
           return 0; }
     }
     else if(i%2 == 1){

        if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
          continue;
        else {
            cout<<"No"<<endl;
             return 0;
        }

     }
 }
 cout<<"Yes"<<endl;

 return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n,a;
	cin>>x>>n;
	bool is[103];
	for(int i=0;i<103;i++) is[i]=false;
	for(int i=0;i<n;i++){
		cin>>a;
		is[a]=true;
	}
	int diff=100000;
	int ans;
	for(int i=0;i<103;i++){
		if(is[i]) continue;
		if(diff>abs(x-i)){
			diff=abs(x-i);
			ans=i;
		}
	}
	cout<<ans<<"\n";
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1000000000;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) cin >> s[i] >> t[i];
  string k;
  cin >> k;
  bool tf = false;
  int total = 0;
  for (int i = 0; i < n; i++) {
    if (tf) total += t[i];
    if (s[i] == k) tf = true;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int tp=0;
		int hp=0;

		for(int i=0; i<n;i++) {
			String[] array = new String[2];
			String taro=sc.next();
			String hanako=sc.next();
			array[0]=taro;
			array[1]=hanako;

			Arrays.sort(array);
			if(array[0].equals(array[1])) {
				tp+=1;
				hp+=1;
			}else if(array[1].equals(taro)) {
				tp+=3;
			}else if(array[1].equals(hanako)) {
				hp+=3;
			}
		}
		System.out.printf("%d %d", tp,hp);
		System.out.println();
	}
}


Measured memory_bytes: 30812
#include <iostream>
#include <cstring>

using namespace std;

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

    if (k >= s.size())
    {
        cout << s << endl;
        return 0;
    }

    for (int i = 0; i < k; i++)
        cout << s[i];

    cout << "..." << endl;
}

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

using namespace std;

typedef long long ll;

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

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

	int score = 1;
	rep(i, n){
		if(score < k){
			score *= 2;
		}else{
			score += k;
		}
	}

	cout << score << endl;

}


Measured memory_bytes: 256
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	ll n, x;
	cin >> n;
	map<ll, ll> mp;
	ll res = 0;
	for (ll i = 0; i < n; i++)
	{
		cin >> x;
		// i-x
		// i+x
		res = res + mp[i - x];
		mp[i + x]++;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
double esp=1e-8;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define cle(a) while(!a.empty())a.pop()
#define mem(p,c) memset(p,c,sizeof(p))
#define mp(A, B) make_pair(A, B)
#define pb push_back
typedef long long int LL;
const long double PI = acos((long double)-1);
const LL INF=0x3f3f3f3fll;
const int MOD =1e9+7ll;
const int maxn=100010;
int A[310][310];
int f[310],in[310];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("pentagon.in", "r", stdin);
    //freopen("pentagon.out", "w", stdout);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int x=1;x<=n;x++)
        for(int y=1;y<=m;y++)
            scanf("%d",&A[x][y]);
    int ans=400;
    for(int x=1;x<=n;x++)
        f[A[x][1]]++;
    for(int x=1;x<=m;x++)in[x]=1;
    int ma=0;
    while(1)
    {
        ma=0;
        for(int x=1;x<=m;x++)
            if(f[x]>f[ma])
                ma=x;
        if(ma==0)break;
        ans=min(ans,f[ma]);
        in[ma]=0;
        mem(f,0);
        for(int x=1;x<=n;x++)
            for(int y=1;y<=m;y++)
                if(in[A[x][y]]){f[A[x][y]]++;break;}
    }
    printf("%d",ans);
    return 0;
}


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

typedef pair<int, int> P;

int n;

vector<vector<P>> G(1510);
vector<vector<int>> dist(1510, vector<int>(1510, 1e9));
void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s][s] = 0;
    que.emplace(0, s);

    while(!que.empty()){
        int ccost, cv;
        tie(ccost, cv) = que.top();
        que.pop();

        if(dist[s][cv] < ccost) continue;

        for(auto x : G[cv]){
            int nv, ncost;
            tie(nv, ncost) = x;
            
            if(dist[s][cv] + ncost < dist[s][nv]){
                dist[s][nv] = dist[s][cv] + ncost;
                que.emplace(dist[s][nv], nv);
            }
        }
    }
}

int main(){
    int r; cin>>n>>r;
    for(int i=0; i<r; i++){
        int s, t, d; cin>>s>>t>>d;
        s--, t--;
        G[s].emplace_back(t, d);
        G[t].emplace_back(s, d);
    }

    for(int i=0; i<n; i++){
        dijkstra(i);
    }

    int maxdist = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            maxdist = max(maxdist, dist[i][j]);
        }
    }

    vector<P> sg;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(dist[i][j] != maxdist) continue;

            sg.emplace_back(i, j);
        }
    }

    vector<bool> visited(n, false);
    for(int i=0; i<n; i++){
        for(auto j:sg){
            int s, g;
            tie(s, g) = j;
            if(dist[s][i] + dist[i][g] == maxdist){
                visited[i] = true;
                break;
            }
        }
    }

    vector<int> ans;
    for(int i=0; i<n; i++){
        if(!visited[i]){
            ans.emplace_back(i+1);
        }
    }

    cout << ans.size() << endl;
    for(auto i:ans){
        cout << i << endl;
    }
}


Measured memory_bytes: 28356
#include <bits/stdc++.h>
using namespace std;
vector<int>e[200005];char s[200005];
int n,m,sb[200005],sw[200005],x,y,vis[200005],fa[200005],sz[200005],ee[200005];queue<int>q;
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y),e[x].push_back(y),e[y].push_back(x);
	}
	for(int i=1;i<=n;i++) for(int j=0;j<e[i].size();j++) if(s[e[i][j]]=='A') sw[i]++;else sb[i]++;
	for(int i=1;i<=n;i++) if(!sw[i]||!sb[i]) q.push(i),vis[i]=1;
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=0;i<e[x].size();i++)
		{
			if(s[x]=='A') sw[e[x][i]]--;
			else sb[e[x][i]]--;
			if(!sw[e[x][i]]||!sb[e[x][i]])
			{
				if(!vis[e[x][i]]) q.push(e[x][i]),vis[e[x][i]]=1;
			}
		}
	}
	for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<e[i].size();j++) if(!vis[i]&&!vis[e[i][j]])
		{
			x=find(i);y=find(e[i][j]);
			if(x==y) ee[x]++;
			else
			{
				sz[x]+=sz[y];
				fa[y]=x;
				ee[x]+=ee[y]+1;
			}
		}
	}
	for(int i=1;i<=n;i++) if(find(i)==i&&ee[i]>=sz[i]) return puts("Yes"),0;
	puts("No");
}

Measured memory_bytes: 14848
N = int(input())
s_p_list = []
for i in range(N):
    S, P = input().split()
    s_p_list.append((i+1, S, int(P)))

result = sorted(
    sorted(s_p_list, key=lambda x: x[2], reverse=True),
    key=lambda x: x[1]
)
for i, s, p in result:
    print(i)


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, mod;
num pre[nsz + 5], a, d, ans;
map<int, vector< pair<num, num> > > dat;

num inline calc(int i) {
	return (num) (i - (n - i)) * a + (pre[i] - (pre[n] - pre[i])) * d;
}

num inline solve(vector< pair<num, num> > &a) {
	num res = 0;
	sort(all(a));
	vector< pair<num, num> > b;
	loop (i, a.size()) {
		if (b.size() && a[i].first <= b.back().second) {
			b.back().second = max(b.back().second, a[i].second);
		}  else {
			b.push_back(a[i]);
		}
	}
	loop (i, b.size()) {
		res += (b[i].second - b[i].first) / mod + 1;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> a >> d;
	if (!d) {
		cout << !!a * n + 1 << ln;
		return 0;
	}
	mod = abs(2 * d);
	cont (i, n) {
		pre[i] = pre[i - 1] + i - 1;
	}
	circ (i, 0, n) {
		num mn = (num) (i - (n - i)) * a + (pre[i] - (pre[n] - pre[i])) * d;
		num mx = (num) (i - (n - i)) * a + (pre[n] - pre[n - i] - pre[n - i]) * d;
		if (mn > mx) {
			swap(mn, mx);
		}
		dat[(mn % mod + mod) % mod].push_back(make_pair(mn, mx));
	}
	foreach (it, dat) {
		ans += solve(it->second);
	}
	cout << ans << ln;
}

Measured memory_bytes: 23680
#include <stdio.h>

int main(void) {
	int n, count = 0, check = 0;
	int a[210];
	scanf("%d", &n);
	for ( int i = 0; i < n; i++ ) {
		scanf("%d", &a[i]);
	}
	while(1) {
		for ( int i = 0; i < n; i++ ) {
			if ( a[i]%2 != 0 ) {
				check = 1;
				break;
			} else a[i] /= 2;
		}
		if ( check == 1 ) break;
		else count++;
	}
	printf("%d", count);
	return 0;
}


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

typedef long long ll;
const ll INF = 1001001001001001001;
int n, m;
struct edge{
    int from, to;
    ll cost;
};
vector<edge> es;
ll dist[1005];
bool positive[1005];

void longest_path(int s){
    fill(dist, dist + n, -INF);
    dist[s] = 0;
    
    for(int i = 0; i < n - 1; ++i){
        bool update = false;
        
        for(int j = 0; j < m; ++j){
            edge& e = es[j];
            
            if(dist[e.to] < dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                update = true;
            }
        }
        
        if(!update)     break;
    }
}

bool link_positive_loop(){
    fill(positive, positive + n, false);
    
    for(int i = 0; i < n; ++i){
        for(int i = 0; i < m; ++i){
            edge& e = es[i];
        
            if(positive[e.from])    positive[e.to] = true;
        
            if(dist[e.to] < dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
            
                positive[e.to] = true;
            }
        }
    }
    
    return positive[n - 1];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a;
        --b;
        es.push_back((edge){a, b, c});
    }
    
    longest_path(0);
    if(link_positive_loop()){
        cout << "inf\n";
    }
    else{
        cout << dist[n - 1] << "\n";
    }
}

Measured memory_bytes: 384