akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pll = pair<ll, ll>;

template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}

ll modpow(ll b, ll x, ll mod) {
    if (x == 0)
        return 1;
    if (x & 1) {
        return modpow(b*b % mod, x/2, mod) * b % mod;
    } else {
        return modpow(b*b % mod, x/2, mod);
    }
}

#define MOD 1000000007

int main()
{
    int N; cin >> N;
    vector<pll> AB(N);
    map<pll, int> cnt;
    for (auto& ab : AB) {
        cin >> ab.first >> ab.second;
        if (ab.first == 0 && ab.second == 0) {
            // そのまま
        } else if (ab.first == 0) {
            ab.second = -1;
        } else if (ab.second == 0) {
            ab.first = 1;
        } else {
            ll g = gcd(ab.first, ab.second);
            ab.first /= g;
            ab.second /= g;
            if (ab.first < 0) {
                ab.first = -ab.first;
                ab.second = -ab.second;
            }
        }
        cnt[ab]++;
    }

    ll ans = 1;

    map<pll, bool> done;

    for (const auto& kv : cnt) {
        const auto& ab = kv.first;
        const auto& c = kv.second;
        if (done[ab] || (ab.first==0 && ab.second==0)) continue;

        ll a = 1;
        pll abr = make_pair(abs(ab.second), ab.first);
        if (ab.second >= 0) abr.second = -abr.second;
        if (cnt.count(abr) > 0) {
            ll c_abr = cnt[abr];
            a = (modpow(2, c, MOD) + modpow(2, c_abr, MOD) - 1) % MOD; 
            done[abr] = true;
        } else {
            a = modpow(2, c, MOD);
        }
        ans = ans * a % MOD;
        done[ab] = true;
    }
    ans--;
    ans = (ans + cnt[make_pair(0LL, 0LL)]) % MOD;
    if (ans < 0) ans += MOD; // これでAC

    cout << ans << endl;
}

Measured memory_bytes: 31460
"""
基本の差はable

 1  2 3  4 5
 4  5 1  2 3
+2  3 4  5 1

 7 10 8 11 9
sa3 -2 3 -2 -2

一度も選ばれてない=3
選ばれてる = -2
一回で -5・・・？
一回選ばれると本来あった +1が消えて -4される →よって-5
"""

import sys

N = int(input())

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

M = N*(N+1)//2

if sum(A) % M != 0:
    print ("NO")
    sys.exit()

able = sum(A) // M

#print (M,able)

A.append(A[0])
now = 0

for i in range(N):

    #print ((A[i+1]-A[i]-able)//N)

    if A[i+1] - A[i] == able:
        continue

    else:
        
        if ((A[i+1]-A[i])-able) % N != 0 or ((A[i+1]-A[i])-able) // N > 0:
            print ("NO")
            sys.exit()

        else:
            now += ((A[i+1]-A[i])-able) // (0-N)


if now == able:
    print ("YES")
else:
    print ("NO")

Measured memory_bytes: 62832
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>
#include <set> 
#include <map> 

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int n;
	cin >> n;
	vector<int> v(n*2,-1);
	int tmp;
	int cc1 = 0,cc2 = 1,cc = 0;
	REP(i, n) {
		cin >> tmp;
		if (cc % 2 != 0) { v[n + cc1] = tmp; cc1++; }
		else  { v[n - cc2] = tmp; cc2++; }
		cc++;
	}
	if (n % 2 == 0) {
		REP(i, n) {
			if (i != n - 1) cout << v[n + cc1 -1  - i] << " ";
			else cout << v[n + cc1 - i - 1] << endl;
		}
	}else{
		REP(i,n){
			if (i != n-1) cout << v[n - cc2 +1 + i] << " ";
			else cout << v[n - cc2 + i +1] << endl;
		}
	}
}


Measured memory_bytes: 5248
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    if n % 2 = 0 then
        float (n / 2) / float n
    else
        float (n / 2 + 1) / float n
    |> printfn "%.7f"

    0

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

int main() {
  int mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;

  vector<int> aa(M);
  for (int k = 0; k < M; k++) {cin >> aa[k]; }

  vector<int> ans(N + 1);
  ans[0] = 1;

  for (int k = 1, l = 0; k <= N; k++) {
    if (l < M and aa[l] == k) { l++; continue; }
    if (k == 1) { ans[k] += ans[k - 1]; }
    else { ans[k] += ans[k - 2] + ans[k - 1]; }
    ans[k] %= mod;
  }

  cout << ans[N] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
int main(){
  string s,ss;
  std::cin >> s;
  ss=s;
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    std::cout << -1<< std::endl;
    exit(0);
  }
  int n=s.size();
  if(n==26){
    next_permutation(all(s));
    int c=0;
    rep(i,n){
      if(ss[i]!=s[i]){
      c=i;break;}
    }
    std::cout << s.substr(0,c+1) << std::endl;
  }
  else{
    std::vector<int> a(26,0);
    rep(i,n)a[s[i]-'a']++;
    char c;
    rep(i,26){
      if(a[i]==0){
        c=i+'a';break;
      }
    }
    std::cout << s<<c << std::endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
using P = pair<double,int>;


int main(){
  string s; cin >> s;
  rep(i,s.size()){
    if(s[i]=='?'){
      s[i]='D';
    }
  }
  cout <<  s << endl;
  return 0;
}

Measured memory_bytes: 3748
n = gets.to_i
nums = []
n.times {
    nums.push( gets.to_i )
}

cnt = n
nums.each { |val|
	if 2 == val
		next
	end
	if 0 == val%2
		cnt-=1
		next
	end
	3.step( Math.sqrt(val), 2 ) { |j|
		if 0 == val%j
			cnt-=1
			break
		end
	}
}

puts( cnt )

Measured memory_bytes: 9036
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

int32_t main()
{
	s_g_c();
	int a;
	cin >> a;
	int ans = a * a + a + 1;
	cout << a*ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

const ll mod=1000000007;

ll fpow(ll b,ll e)
{
    ll res=1;
    while(e)
    {
        if(e&1) res=(res*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return res;
}

ll ch(ll n,ll k)
{
    ll res=1;
    for(ll i=n;i>n-k;i--) res=(res*i)%mod;
    for(ll i=1;i<=k;i++) res=(res*fpow(i,mod-2))%mod;
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,a,b;
    cin >> n >> a >> b;
    ll res=((fpow(2,n)-1-ch(n,a)-ch(n,b))%mod+mod)%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct data{
	int x,y;
	data(){}
	data(int xx,int yy){
		x=xx;
		y=yy;
	}
};

int n;
data d[205];
ll two[205];
bool flag[205][205];
ll res=0;

bool check(int f,int t,int vx,int vy){
	int sax=d[t].x-d[f].x;
	int say=d[t].y-d[f].y;
	return (sax*vy-say*vx)==0;
}

int main(void){
	scanf("%d",&n);
	two[0]=1;
	for(int i=1;i<=n;i++){
		two[i]=two[i-1]*2LL%MOD;
	}
	for(int i=0;i<n;i++){
		scanf("%d%d",&d[i].x,&d[i].y);
	}
	ll res=two[n];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(flag[i][j])continue;
			int vx=d[i].x-d[j].x;
			int vy=d[i].y-d[j].y;
			vector<int> vec;
			int cnt=0;
			for(int k=0;k<n;k++){
				if(check(j,k,vx,vy)){
					vec.push_back(k);
					cnt++;
				}
			}
			res-=two[cnt];
			res+=MOD;
			res%=MOD;
			res+=cnt+1LL;
			res%=MOD;
			for(int k=0;k<vec.size();k++){
				for(int l=0;l<vec.size();l++){
					flag[vec[k]][vec[l]]=true;
				}
			}
		}
	}
	res-=(ll)n+1LL;
	res+=MOD;
	res%=MOD;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Main{
    /**
     *
     */

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] K = new String[8];
        K[0] = "\\A.*keyence\\z";
        K[1] = "\\Ak.*eyence\\z";
        K[2] = "\\Ake.*yence\\z";
        K[3] = "\\Akey.*ence\\z";
        K[4] = "\\Akeye.*nce\\z";
        K[5] = "\\Akeyen.*ce\\z";
        K[6] = "\\Akeyenc.*e\\z";
        K[7] = "\\Akeyence.*\\z";
        for (int i = 0; i < 8; i++) {
            Pattern p = Pattern.compile(K[i]);
            Matcher m = p.matcher(S);
            if (m.find()) {
                System.out.println("YES");
                sc.close();
                return;
            }
        }
        // kaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjeyence
        // keaaaaeyence
        // keyaaaaencellll
        System.out.println("NO");

        sc.close();
    }
}


Measured memory_bytes: 23764
package main
import(
        "fmt"
        "math"
        "bufio"
        "os"
      )

var n int
var MAX_INT = math.MaxInt32

var mins [300000]int


func main(){
    //var out=bufio.NewWriter(os.Stdout)
    var in=bufio.NewReader(os.Stdin)
    var q, s, t, query, leaves,counter, x int
    fmt.Fscanf(in,"%d %d\n",&n,&q)
    //fmt.Println(n,q)
    for leaves = 1 ; leaves < n;leaves*=2{}

    for counter = 0 ;counter < leaves*2;counter++{
        mins[counter]=MAX_INT
    }

    for counter = 0 ;counter < q;counter++{
        fmt.Fscanf(in,"%d", &query)
        if query == 1{
                fmt.Fscanf(in,"%d %d\n", &s, &t)
                fmt.Println(find(s,t,0,0, leaves-1))
            }else {
                fmt.Fscanf(in,"%d %d %d\n", &s, &t, &x)
                update(s,t,x,0,0,leaves-1)

            }
    }

}

func update(ul int,ur int,val int, k int, nl int ,nr int){
    if ur < nl || ul > nr{
        return
    }else if ul <= nl && ur >= nr {
        mins[k]=val
    }else{
        if mins[k] >= 0 {
            update(nl, nr, mins[k], 2 * k + 1, nl, (nl + nr) / 2)
            update(nl, nr, mins[k], 2 * k + 2, (nl + nr) / 2 + 1, nr)
            mins[k] = -1
        }
        update(ul, ur, val, 2*k + 1, nl, (nl + nr) / 2)
        update(ul, ur, val, 2*k + 2, (nl + nr) / 2 + 1, nr)
    }
}

func find(sl int, sr int, nodeID int, nl int, nr int)(int) {
    var left ,right int
        if sr < nl || sl > nr{
            return MAX_INT
        }else {
            if mins[nodeID] != -1{
                return mins[nodeID]
            }else {
                left = find(sl, sr, 2 * nodeID + 1, nl, (nl + nr) / 2) 
                right = find(sl, sr, 2 * nodeID + 2, (nl + nr) / 2 + 1, nr)
                return min(left, right)
            }
        }
}

func min(a, b int) int {
    if a <= b {
        return a
    } else {
        return b
    }
}



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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"

int main() {
  int N, S;
  cin >> N >> S;

  vector<ll> a(N);
  rep0(i, N) cin >> a[i];

  ll ans = 1e9;
  ll temp = 0;
  ll l = 0, r = 0;
  while (true) {
    if (temp >= S) {
      ans = min(ans, r - l);
      temp -= a[l];
      l++;
    } else {
      if (r >= N) break;
      temp += a[r];
      r++;
    }
  }
  if (ans == 1e9) ans = 0;

  cout << ans << BR;
  return 0;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	int a;
	cin>>a;
	cout<<48-a<<"\n";
	return 0;
}

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

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll mulpow(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return mulpow(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vvl vector<vl>
#define vs vector<string>
#define vvs vector<vs>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);


void solve()
{
	ll i,j;
	ll n,m,k;
	cin>>n>>m>>k;
	vl vn(n),vm(m);
	f0(i,n)
	{
		cin>>vn[i];
		if(i!=0)
			vn[i]+=vn[i-1];
	}
	f0(i,m)
	{
		cin>>vm[i];
		if(i!=0)
			vm[i]+=vm[i-1];
	}
	ll ans=0;
	ll temp=0;
	j=0;
	fd(i,n)
	{
		if(vn[i]<=k)
		{
			for(j;j<m;j++)
			{
				if(vn[i]+vm[j]>k)
					break;
			}
			ans=max(ans,j+i+1);
		}
	}
	i=0;
	fd(j,m)
	{
		if(vm[j]<=k)
		{
			for(i;i<n;i++)
			{
				if(vn[i]+vm[j]>k)
					break;
			}
			ans=max(ans,j+i+1);
		}
	}
	pn(ans);
	return;
}

int main()
{
	#ifdef Deeksha
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		//cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	cin >> n >> k;
	int x[n];
	rep(j,n)cin>>x[j];
	int sum=0;
	rep(i,n)sum+=min(x[i],k-x[i]);
	cout << 2*sum << endl;
}

Measured memory_bytes: 256
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _n: i32 = lines.next().unwrap().unwrap().parse().unwrap();
    let a_line = lines.next().unwrap().unwrap();
    let splited = a_line.trim().split_whitespace();
    let mut a: Vec<(usize, i32)> = splited.map(|s| s.parse().unwrap()).enumerate().collect();

    a.sort_by(|a, b| a.1.cmp(&b.1));

    let ans: Vec<String> = a.into_iter()
        .map(|(i, _)| format!("{}", i + 1))
        .collect();

    writeln!(&mut writer, "{}", ans.join(" ")).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"3
2 3 1", br"3 1 2
",
        ),
        (
            br"5
1 2 3 4 5", br"1 2 3 4 5
",
        ),
        (
            br"8
8 2 7 3 4 5 6 1", br"8 2 4 5 6 7 3 1
",
        ),
    ];

    #[test]
    fn test_c() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 12572
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int n,a[100000+5];
int main()
{
	priority_queue<int> pq;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[i+1])
		{
			pq.push(a[i]);
			i++;
		}
	}
	if(pq.size()<=1)
	{
		cout<<0;
	}
	else
	{
		long long int ans=1;
		for(int i=1;i<=2;i++)
		{
			ans*=pq.top();
			pq.pop();
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

class RollingHash(object):
    def __init__(self, S: str, MOD: int = 10 ** 9 + 7, BASE: int = 10 ** 5 + 7):
        self.S = S
        self.N = N = len(S)
        self.MOD = MOD
        self.BASE = BASE
        self.S_arr = [ord(x) for x in S]

        self.POWER = [1] * (N + 1)
        self.HASH  = [0] * (N + 1)
        p, h = 1, 0
        for i in range(N):
            self.POWER[i + 1] = p = (p * BASE) % MOD
            self.HASH[i + 1] = h = (h * BASE + self.S_arr[i]) % MOD

    def hash(self, l: int, r: int):
        # get hash for S[l:r]
        _hash = (self.HASH[r] - self.HASH[l] * self.POWER[r - l]) % self.MOD
        # if _hash < 0:
        #     _hash += self.MOD
        return _hash

# 汎用的な二分探索のテンプレ
# check_func(x) = true となるxの最小値を探索する
# left : check_func(x) = falseとなるx
# right: check_func(x) = true となるx
# search_max: check_func(x) = true となるxの"最大値"を探索する場合はTrue
# check_func: answer <= x であればcheck_func(x) = true となるような関数
def binary_search(left: int, right: int, check_func, search_max:bool=False):
    # ok と ng のどちらが大きいかわからないことを考慮
    while abs(right - left) > 1:
        mid = (left + right) // 2
    
        if check_func(mid) ^ search_max:
            right = mid
            # print(left, right, mid, 't')
        else:
            left = mid
            # print(left, right, mid, 'f')

    return left if search_max else right

def main():
    N = int(input())
    S = input()

    rs = RollingHash(S, MOD=998244353, BASE=37)

    # 長さLの部分文字列同士が、範囲を重ねず同じ文字列となる場合はTrue,
    # そうでない場合はFalseを返す関数
    def isOK(L):
        if L == 0:
            return True
        hash_to_left = defaultdict(list)
        for i in range(N - L + 1):
            _hash = rs.hash(i, i + L)
            # hashが衝突しても文字列が完全に一致するか分からないので、
            # 衝突した場合は文字列が完全に一致するか調べ、かつ
            # 文字列同士がSの中で重なるような範囲にない場合はOKとする
            for j in hash_to_left[_hash]:
                if j+L <= i:
                    return True
            hash_to_left[_hash].append(i)

        return False
    # 範囲が重ならないことが条件にあるので、答えは最大でもN // 2（文字列の長さの半分）となる。
    # ただし、二分探索する上で絶対に答えとならない範囲を含めたいので、
    # 探索範囲としてはN // 2 + 1 と、+1しておく。
    ans = binary_search(0, N // 2 + 1, isOK, search_max=True)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		int ans = C - (A - B);
		System.out.println(ans > 0 ? ans : 0);

	}
}

Measured memory_bytes: 23508
# -*- coding: utf-8 -*-
import math

n = int(input())+1
a = int(0)
for i in range(1, n):
  for j in range(1, n):
    b = math.gcd(i,j)
    for k in range(1, n):
      a = a + math.gcd(b,k)
print("{}".format(a))


Measured memory_bytes: 9140
local N, K = io.read("n", "n")
local sushi_list = {}
--local sushi_types = {}
for i=1,N do
    local t, d = io.read("n", "n")
    local tuple = {t, d, false} -- 3rd element: used flag
    --local tuple = {t, d}
    sushi_list[i] = tuple
    --if not sushi_types[t] then
    --    sushi_types[t] = {}
    --end
    --table.insert(sushi_types[t], tuple)
end

-- sort order by deliciousness (most tasty sushi first)
table.sort(sushi_list, function (x, y) return x[2] > y[2] end)
--for _,sushi_t in pairs(sushi_types) do
--    table.sort(sushi_t, function (x, y) return x[2] > y[2] end)
--end

-- maximaize base score
local base_score = 0
local used = {}
for i=1,K do
    local tuple = sushi_list[i]
    base_score = base_score + tuple[2]
    if used[tuple[1]] == nil then
        used[tuple[1]] = 0
    end
    used[tuple[1]] = used[tuple[1]] + 1
    tuple[3] = true
end
local not_used_sushis = {}
local not_used_sushis_appeared = {}
for i=K+1,N do
    local tuple = sushi_list[i]
    if used[tuple[1]] == nil then
        if not_used_sushis_appeared[tuple[1]] then
            -- never use this one
        else
            not_used_sushis_appeared[tuple[1]] = true
            table.insert(not_used_sushis, tuple)
        end
    end
end
local ntypes = 0
for k,_ in pairs(used) do
    ntypes = ntypes + 1
end
local bonus_score = ntypes * ntypes
local score = base_score + bonus_score


if false then
    print("maximized base")
    for i,v in ipairs(sushi_list) do
        print(v[1],v[2],v[3])
    end
    print("not used sushis")
    for i,v in ipairs(not_used_sushis) do
        print(v[1],v[2],v[3])
    end
    print("--")
end


-- try increase bonus
local discard_i = K
local take_i = 1
local max_score = score
while discard_i >= 1 and take_i <= #not_used_sushis do
    -- discard least tasty one (constraint: keep ntypes)
    local discard_tuple = sushi_list[discard_i]
    if used[discard_tuple[1]] >= 2 then
        used[discard_tuple[1]] = used[discard_tuple[1]] - 1
        local take_tuple = not_used_sushis[take_i]
        take_i = take_i + 1
        local score_temp = (score - discard_tuple[2] + take_tuple[2]) - ntypes * ntypes + (ntypes + 1) * (ntypes + 1)
        if score_temp > max_score then
            max_score = score_temp
        end
        discard_tuple[3] = false
        take_tuple[3] = true
        score = score_temp
        ntypes = ntypes + 1
    else
        -- keep ntypes
    end
    discard_i = discard_i - 1
end

print(max_score)



Measured memory_bytes: 20968
#include <iostream>
using namespace std;
int a[10005];
int ans[105][105];
int main(void){
    int H,W; cin>>H>>W;
    int N; cin>>N;
    int h=0,w=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++){
            ans[h][w]=i+1;
            if(w%2==0){
                if(h==H-1){
                    w++;
                }else{
                    h++;
                }
            }else{
                if(h==0){
                    w++;
                }else{
                    h--;
                }
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<ans[i][j];
            if(j!=W-1){
                cout<<" ";
            }else{
                cout<<endl;
            }
        }
    }
    
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    int ans = 0;
    rep(i, 0, N) rep(j, i + 1, N)
    {
        chmax(ans, abs(A[i] - A[j]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

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

    int ans = 0;
    for (int i = 0; i < 29; ++i) {
        int mask = (1 << (i + 1)) - 1;
        vector<int> c(n);
        for (int j = 0; j < n; ++j) {
            c[j] = b[j] & mask;
        }
        sort(c.begin(), c.end());
        int k = 0;
        for (int j = 0; j < n; ++j) {
            int a_j = a[j] & mask;
            int l1 = (1 << i) - a_j;
            int r1 = (1 << (i + 1)) - 1 - a_j;
            int l2 = (3 << i) - a_j;
            int r2 = ((3 << i) | ((1 << i) - 1)) - a_j;

            int li1 = lower_bound(c.begin(), c.end(), l1) - c.begin();
            int ri1 = upper_bound(c.begin(), c.end(), r1) - c.begin();
            int li2 = lower_bound(c.begin(), c.end(), l2) - c.begin();
            int ri2 = upper_bound(c.begin(), c.end(), r2) - c.begin();

            k += (ri1 - li1) & 1;
            k += (ri2 - li2) & 1;
        }
        ans |= (k & 1) << i;
    }

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

Measured memory_bytes: 2672
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unrolonglong-loops")
*/
#include <bits/stdc++.h>
 
using namespace std;
 
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff first
#define ss second
#define db double
#define ll long long
#define PI 3.1415926535
#define pb push_back
#define all(x) x.begin(),x.end()
 
const int N = 1e6 + 7;
const int INF = 1e9 + 7;
const ll MOD = 1000003;

ll a[N];

int main() {
	speed
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>a[i];
	    sum+=a[i];
    }
    sort(a+1,a+1+n);
    if(sum%10>0){
        cout<<sum;
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(a[i]%10!=0){
            cout<<sum-a[i];
            return 0;
        }
    }
    cout<<0;
    return 0;
}
/*

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=1000005;
int X,n,a[N],b[N];bool ban[N];set<int>S;
signed main(){
	rd(n);
	rep(i,1,n){
		int x;rd(x);
		++b[x],a[i]=x;
	}
	rep(i,1,N-1)if(b[i]){
		for(int j=(b[i]>1?i:i*2);j<N;j+=i)ban[j]=1;
	}
	int ans=0;
	rep(i,1,N-1){
		if(!ban[i])ans+=b[i];
	}
	pt(ans,'\n');
	return 0;
}

Measured memory_bytes: 13800
#include<iostream>
using namespace std;
int main()
{
	int n,x,y,tot=0;cin>>n>>x>>y;
	while(1)
	{
		if(x+1==y)
		{
			if(tot%2)cout<<"Alice";
			else cout<<"Borys";
			return 0;
		}
		if(!tot%2)x++;
		else y--;
		tot++;
		
	}
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, K;
int A[200010];
ll solve(int x) {
    ll res = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] % x == 0) {
            res += A[i]/x-1;
        }
        else {
            res += A[i]/x;
        }
    }
    return res;
}
int main () {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];
    int ng = 0, ok = 1000000000;
    while (ok-ng > 1) {
        int x = (ok+ng)/2;
        if (solve(x) <= K) {
            ok = x;
        }
        else {
            ng = x;
        }
    }
    cout << ok << endl;
}

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

int main() {
  int D, N;
  cin >> D >> N;
  int ans = 1;
  for (int i = 0; i < D; i++) ans *= 100;
  if (N == 100) ans *= 101;
  else ans *= N;
  cout << ans << endl;
  return 0;
}

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

using namespace std;


int main(void){

    int n;
    cin >> n;
    
    vector<int> s(n);
    for(int i=0; i<n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    
    int sum = 0;
    for(int i=0; i<n; i++) {
        sum += s[i];
    }
    if(sum%10==0) {
        for(int i=0; i<n; i++) {
            if(s[i]%10!=0) {
                sum -= s[i];
                break;
            }
        }
    }
    
    if(sum%10==0) cout << 0 << endl;
    else cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MOD = 1000000007;

long long func(long long x, long long y) {
    if (y == 0) return 1;
    if (y % 2 == 0) {
        return func(x * x % MOD, y / 2);
    } else {
        return x * func(x, y - 1) % MOD;
    }
}

int main() {
    int m, n; cin >> m >> n;
    cout << (func(m, n) % MOD) << endl;
}


Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;



int main(){
	double d;
	int S;
	while (cin >> d){
		S = 0;
		for (int i = 1; d*i < 600; i++){
			S = S + (d*i*d*i)*d;
		}
		cout << S << endl;

	}
	return 0;
}

Measured memory_bytes: 1220
import java.util.*;
import java.util.regex.Pattern;
public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int sum = sc.nextInt();
			if(sum == 0)break ;
			int [] data = new int[9];
			data[0] = sc.nextInt();
			for(int i = 1; i < 9; i++){
				data[i] = data[i-1] + sc.nextInt();
			}
			System.out.println(sum - data[data.length - 1]);
		}
	}

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

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 

 class Main{

static                 int[] primes=new int[50030]; 
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;
             while((line=br.readLine())!= null){if(line.isEmpty())break;
             primes[0]=1;primes[1]=1;//primes[2]=1;
                 int n=Integer.parseInt(line);
                 int low=0,high=0;
                 makePRY();
                 for(int i=n-1;i>=0;i--){
                     if(primes[i]==0){low=i;break;}
                 }
                 for(int i=n+1;i<50030;i++){
                     if(primes[i]==0){high=i;break;}
                 }
                 System.out.println(low+" "+high);
             }
             
         }catch(Exception e){}         
     }
     
     static void makePRY(){
         for(int i=2; i<50030;i++){
             if(primes[i]==1)continue;
             for(int j=2;i*j<50030;j++){
                 int num=i*j;
                 if(primes[num]==0)primes[num]=1;
             }
         }
     }
    
 }

Measured memory_bytes: 17172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const ll LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=1000050;
int a[MAXN],vis[MAXN],avis[MAXN];
vector<int>p;
bool get_prime(int maxx){
	for(int i=2;i<=maxx;i++){
		if(vis[i])continue;
		vis[i]=1;
		p.push_back(i);
		for(int j=1;j*i<=maxx;j++){
			if(avis[i*j]==1){
				if(vis[i]==2)return 0;
				vis[i]=2;
				if(j!=1)vis[i*j]=1;
			}else if(avis[i*j]!=0)return 0; 
			else vis[i*j]=1;
		} 
	}
	return 1;
}
int gcd(int t,int b){
	if(t<b)swap(t,b);
	if(t%b==0)return b;
	else return gcd(b,t%b);
}
void solve(int T){
	int n,maxx=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		maxx=max(maxx,a[i]);
		avis[a[i]]++;
	}
	int gcdd=a[1];
	for(int i=2;i<=n;i++){
		gcdd=gcd(a[i],gcdd);
	}
	if(get_prime(maxx)){
		puts("pairwise coprime");
	}else if(gcdd==1){
		puts("setwise coprime");
	}else{
		puts("not coprime");
	}
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

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

int main(void)
{
	int		 tall[10], i, j,temp;


	for(i=0; i<10; i++){
		scanf("%d", &tall[i]);
	}
	for(i=0; i<10; i++){
		for(j=9; j>i; j--){
			if(tall[j-1] < tall[j]){
				temp = tall[j];
				tall[j] = tall[j-1];
				tall[j-1] = temp;
			}
		}
	}
	for(i=0; i<3; i++){
		printf("%d\r\n", tall[i]);
	}
	return 0;	 
}

Measured memory_bytes: 600
from copy import copy


def conditions(xyz):
    x, y, z = xyz
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


def plus_num(comb):
    if len(set(comb)) == 1:
        return 1
    elif len(set(comb)) == 2:
        return 3
    elif len(set(comb)) == 3:
        return 6


N = int(input())

candidate = range(1, 100)
result = {}
for i in candidate:
    for j in range(i, 100):
        for k in range(j, 100):
            cal = conditions((i, j, k))
            if cal <= N:
                if cal in result:
                    result[cal] += plus_num((i, j, k))
                else:
                    result[cal] = plus_num((i, j, k))

for i in range(1, N + 1):
    if i in result:
        print(result[i])
    else:
        print(0)


Measured memory_bytes: 9784
import collections
MOD = 10**9+7

n = int(input())
a = [int(_) for _ in input().split()]

A = sorted(collections.Counter(a).most_common())

flg = True
ans = 1

if n % 2 == 0:
    # EVEN
    if len(A) == n//2:
        for i in range(n//2):
            if A[i][0] == 1+i*2 and A[i][1] == 2:
                ans = ans * 2 % MOD
            else:
                flg = False
                break
    else:
        flg = False
else:
    # ODD
    if len(A) == n//2+1:
        for i in range(n//2+1):
            if i == 0:
                if A[i][0] == 0 and A[i][1] == 1:
                    pass
                else:
                    flg = False
                    break
            else:
                if A[i][0] == i*2 and A[i][1] == 2:
                    ans = ans * 2 % MOD
                else:
                    flg = False
                    break
    else:
        flg = False

if flg:
    print(ans)
else:
    print(0)

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 10399;
const ll MAXN = (ll) 1e3 + 10;
const ll INF = (ll) LONG_LONG_MAX / 100;
const ld EPS = (ld) 1e-8;
const ll P = 104107;

ll mul(ll a, ll b){
	return (a * b) % MOD;
}

ll pw(ll b, ll p){
	if(p == 0) return 1;
	if(p & 1) return mul(b, pw(b, p - 1));
	return pw(mul(b, b), p / 2);
}
ll inv(ll x){
	return pw(x, MOD - 2);
}

int main(){
	ll n;
	cin >> n;
	ll ans = 0;
	ll l, r;
	for(int i = 1; i<=1000000; i++){
		l = n / i;
		r = n / (i + 1);
		if(l == 0) continue;
		ll sm = l;
		ll smod = n % l;
		if((sm > smod)){
			//debug(i);
			ll st = (sm - smod - 1) / (i + 1);
			if(i == 2){
				//debug(smod);
				//debug(i);
				//debug((i - smod) % (i + 1));
			}
			if( (i >= smod) and ((i - smod) % (i) == 0)){
				//debug(i);
				if(((i - smod) / (i) > st)) continue;
				ll nm = sm - ((i - smod) / (i));
				ans += nm;
				//debug(nm);
			}
		} else  continue;
	}
	cout << ans;
	return 0;
}


/*
fuck hashal
*/



Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
if N==1:
  start=0
else:
  start=10**(N-1)

for i in range(start,10**N):
  n=str(i)
  cnt=0
  for j in range(M):
    if n[sc[j][0]-1]==str(sc[j][1]):
      cnt+=1
    else:
      break
  if cnt==M:
    print(n)
    exit()
print('-1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
int main ()
{
string s ;
cin >> s ;
ll cont =0 ,mcnt=0 ;
for(int i=0 ;i<s.size() ;i++)
{
    if(s[i]=='A' ||s[i]=='C'|| s[i]=='G'||s[i]=='T')
{
    cont ++ ;
}
else {  cont = 0; }
        mcnt = max(mcnt, cont);
}
cout << mcnt <<endl;
    return 0 ;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        Long countA = 0L;
        Long countB = 0L;
        for (int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == '0') countA++;
            if(S.charAt(i) == '1') countB++;
        }
        countA = Math.min(countA, countB) * 2;
        System.out.println(countA);
    }
}


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

int h,w,ch,cw,dh,dw;
char g[1005][1005];
int dis[1005][1005];
int dx[]={-1,0,1,0},dy[]={0,1,0,-1};

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>h>>w;
    cin>>ch>>cw;
    cin>>dh>>dw;
    for(int i=1;i<=h;i++){
        cin>>g[i]+1;
    }
    deque<pair<int,int>> q;
    memset(dis,0x3f,sizeof(dis));
    dis[ch][cw]=0;
    q.emplace_back(ch,cw);
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        q.pop_front();
        for(int d=0;d<4;d++){
            int nx=dx[d]+x,ny=dy[d]+y;
            if(nx>=1&&ny>=1&&nx<=h&&ny<=w&&dis[nx][ny]>dis[x][y]&&g[nx][ny]=='.'){
                dis[nx][ny]=dis[x][y];
                q.emplace_front(nx,ny);
            }
        }
        for(int nx=x-2;nx<=x+2;nx++)for(int ny=y-2;ny<=y+2;ny++){
            if(nx>=1&&ny>=1&&nx<=h&&ny<=w&&dis[nx][ny]>dis[x][y]+1&&g[nx][ny]=='.'){
                dis[nx][ny]=dis[x][y]+1;
                q.emplace_back(nx,ny);
            }
        }
    }
    cout<<(dis[dh][dw]==0x3f3f3f3f?-1:dis[dh][dw])<<endl;

    return 0;
}

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

int main(){
  int n;cin>>n;
  double ans;
  vector<int> v(n);
  rep(i,n)cin>>v.at(i);
  sort(v.begin(),v.end());
  ans=v.at(0);
  rep(i,n-1){
    ans+=v.at(i+1);
    ans/=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// Version.16.23.15.05.03.20.
#include <bits/stdc++.h>
#define N 1001001
using namespace std;

int n;
char s[N], t[N];
queue<int> q;

void check() {
    for (int i = 1; i <= n; ++i)
        if (s[i] != t[i]) return ;
    puts("0"), exit(0);
}

int main() {
#ifdef isLOCAL
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n;
    scanf("%s", s + 1);
    scanf("%s", t + 1);

    check();

    int st = n, en = n, ans = 0;
    while (en) {
        while (en - 1 && t[en] == t[en - 1]) --en;
        while (st > en || (st && s[st] != t[en])) --st;
        if (!st) return puts("-1"), 0;
        while (!q.empty() && (q.front() - (int) q.size() + 1) > en) q.pop();
        if (st ^ en) q.push(st);
        else assert(q.empty());
        ans = max(ans, (int) q.size() + 1);
        --en;
    }
    cout << ans << endl;

    return 0;
}


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

const int V_MAX=100000;
const int E_MAX=100000;

vector<int> G[V_MAX];
int used[V_MAX]={};
bool flag=false;

void dfs(int s){
	//1???????§????????????????????§?????????????????????§2??????????????????
	//????????????????????????????????????????????????????????¨???????????\??????out
	//????????????????????§?????????????????¨??¨???1??§???????????????????????°??????
	//flag???true?????£???????????¨??????????????????out??????
    if(used[s]==1){return;}
    used[s]=2;
    for (int i=0;i<G[s].size();i++){
        if(used[G[s][i]]==2){
            flag=true;
        }
        if(used[G[s][i]]==0)
        dfs(G[s][i]);
    }
    used[s]=1;
}

int main(){
    int V,E,s,t;
    cin>> V >> E;
    for (int i=0;i<E;i++){
        cin >> s >> t;
        G[s].push_back(t);
    }

    for(int i=0;i<V;i++){
        dfs(i);
    }

    flag ? cout << 1 << endl : cout << 0 <<endl;

    return 0;
}

Measured memory_bytes: 5484
/*
Aldew
PROB:
CLASSIFICATION:
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>

using namespace std;


int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}







Measured memory_bytes: 3624
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(let* ((n (read))
       (m (read))
       (ans 2019))
  (loop :named p-loop :for p :from n :upto (1- m)
        :do(loop :for q :from (1+ p) :upto m :do(if (= 0 (mod (* p q) 2019))
                                                    (progn (setf ans 0) (return-from p-loop))
                                                    (if (< (mod (* p q) 2019) ans)
                                                        (setf ans (mod (* p q) 2019))) )))
  (princ ans))

Measured memory_bytes: 15080
package main

import (
	"fmt"
)

func main(){
	var a, b int
	fmt.Scan(&a, &b)
	if a < b {
		fmt.Println("a < b")
	}
	if a > b {
		fmt.Println("a > b")
	}
	if a == b {
		fmt.Println("a == b")
	} 
}



Measured memory_bytes: 1160
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  map<string, int> m;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    m[s]++;
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    m[s]--;
  }

  int vmax = 0;
  for (auto [k, v] : m) {
    vmax = max(vmax, v);
  }
  cout << vmax << endl;
}


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

namespace _0535
{
    class Program
    {
        static bool[,] ice;
        static int ret = 0;
        static void bfs(int x,int y,int count)
        {
            ice[x,y] = false; count++; ret = Math.Max(ret,count);
            if (ice[x - 1,y]) bfs(x - 1,y,count);
            if (ice[x + 1,y]) bfs(x + 1,y,count);
            if (ice[x,y - 1]) bfs(x,y - 1,count);
            if (ice[x,y + 1]) bfs(x,y + 1,count);
            ice[x,y] = true;
        }
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                int m = int.Parse(Console.ReadLine());
                if (n == 0 && m == 0) break;
                ret = 0;
                ice = new bool[m + 2,n + 2];
                for (int i = 0; i < m; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    for (int j = 0; j < n; j++)
                    {
                        ice[i + 1,j + 1] = x[j] == 1;
                    }
                }
                for (int i = 0; i < m; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        if (ice[i + 1,j + 1]) bfs(i + 1,j + 1,0);
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9736
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
flag = True
color = [-1] * n
que = deque()
que.append((0,0))
while que:
    u, c = que.popleft()
    if color[u] == -1:  # 未探索の時
        color[u] = c
        for e in g[u]:
            que.append((e, c ^ 1))  # ^はxor
    else:
        if color[u] != c:
            flag = False
            break
if flag:
    w = len([i for i in color if i == 0])
    ans = w * (n - w) - m
else:
    ans = (n * (n - 1) // 2 - m)
print(ans)

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

int main(){
  int a,b;
  cin>>a>>b;
  int ans=-1;
  for(int n=1;n<=1005;++n){
    if((n*108)/100==a+n && (n*110)/100==b+n){
      ans=n;
      break;
    }
  }

  cout<<ans<<endl;
}


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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  fenwick_tree<long> fw(N);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    fw.add(i, a);
  }
  while(Q--){
    int t, x, y;
    cin >> t >> x >> y;
    if(t == 1)cout << fw.sum(x, y) << endl;
    else fw.add(x, y);
  }
  return 0;
}

Measured memory_bytes: 8236
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define INF 100000000
using namespace std;
typedef pair<int, int> pii;

int h, w, s, u[32][32], all, diff;
int group[32][32][32][32], need[32][32][32][32];

int count(int t, int l, int b, int r) {
  int sum = 0;
  REP(i, t, b) REP(j, l, r) sum += u[i][j];
  return sum;
}

pii dfs(int t, int l, int b, int r) {
  if(need[t][l][b][r] >= 0) {
    return pii(group[t][l][b][r], need[t][l][b][r]);
  }

  int sum = count(t, l, b, r);
  if(sum < diff) {
    return pii(group[t][l][b][r] = 0, need[t][l][b][r] = INF);
  }

  pii ret = pii(1, sum);
  REP(i, t + 1, b) {
    pii ta = dfs(t, l, i, r);
    pii ba = dfs(i, l, b, r);
    ta.first += ba.first;
    ta.second = min(ta.second, ba.second);
    ret = max(ret, ta);
  }
  REP(i, l + 1, r) {
    pii la = dfs(t, l, b, i);
    pii ra = dfs(t, i, b, r);
    la.first += ra.first;
    la.second = min(la.second, ra.second);
    ret = max(ret, la);
  }

  group[t][l][b][r] = ret.first;
  need[t][l][b][r] = ret.second;
  return ret;
}

int main(void) {
  while(cin >> h >> w >> s, h != 0 && w != 0 && s != 0) {
    all = 0;
    REP(i, 0, h) REP(j, 0, w) {
      cin >> u[i][j];
      all += u[i][j];
    }
    diff = all - s;

    REP(i, 0, 32) REP(j, 0, 32) REP(k, 0, 32) REP(l, 0, 32) {
      group[i][j][k][l] = -1;
      need[i][j][k][l] = -1;
    }

    pii ret = dfs(0, 0, h, w);
    cout << ret.first << " " << ret.second - diff << endl;
  }

  return 0;
}

Measured memory_bytes: 11280