akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define li long int
#define ll unsigned long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y>
#define qq(x) queue<x>
#define pqq(x) priority_queue<x> 
#define pi(x,y) pair<x,y>
#define forf(i,x,y) for(ll i=x;i<y;i++)
#define forl(i,x) for(ll i=x-1;i>=0;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pob pop_back
#define pp push
#define po pop
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define vp(x,y) vec(pi(x,y) )
#define vv(x) vector<vector<x> >
#define all(x) x.begin(),x.end()

using namespace std;

vec(int) v[100010];

int main()
{
	fastio;
    int n,m,q;
    cin>>n>>m>>q;
    int x,y;
    for(int i=0;i<m;i++)
    {   cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++)
         sort(v[i].begin(),v[i].end());
 
    while(q--)
    {
        cin >> x >> y;
 
        int ans = 0;
 
        for(int i=x;i<=y;i++)
        {
            int temp = upper_bound(v[i].begin(),v[i].end(),y) - v[i].begin();
 
            ans += temp;
        }
 
        cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 200010;
int n, k, h[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n >> k;
	Foz(i, n) cin >> h[i];
	sort(h, h + n);
	reverse(h, h + n);
	k = min(n, k);
	Foz(i, k) h[i] = 0;
	ll ans = 0;
	Foz(i, n) ans += h[i];
	cout << ans << '\n';

}



Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public void Run()
        {
            string S = Console.ReadLine();
            bool AC = true;

            if (S[0] != 'A')
                AC = false;

            int countC = 0;
            for (int i = 2; i < S.Length - 1; i++)
            {
                if (S[i] == 'C') countC++;
            }
            if (countC != 1)
                AC = false;

            for (int i = 2; i < S.Length - 1; i++)
            {
                if (!((S[i] >= 'a' && S[i] <= 'z') || S[i] == 'C'))
                    AC = false;
            }

            if (!(S[1] >= 'a' && S[1] <= 'z'))
                AC = false;
            if (!(S[S.Length-1] >= 'a' && S[S.Length - 1] <= 'z'))
                AC = false;

            Console.WriteLine(AC ? "AC" : "WA");
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;



int main()
{
    ll N;

    cin >> N;

    ll a[N];
    ll x = 0;

    ll tmp = 0;

    ll iMin = INF;

    REP(i,N)
    {
        cin >> a[i];
        tmp += a[i];

    }

    REP(i,N-1)
    {
        x += a[i];

        iMin = min(iMin,abs(tmp -2*x));

    }

    cout << iMin << endl;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

std::vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}
std::vector<int> factor(int n, const std::vector<int>& min_factor) {
  // min_factor は sieve() で得られたものとする
  std::vector<int> res;
  while (n > 1) {
    res.push_back(min_factor[n]);
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}
  int main(){
      lint n;
      cin>>n;
      lint a[n];
      rep(i,n)cin>>a[i];
      lint gc=a[0];
      rep(i,n-1)gc=gcd(gc,a[i+1]);
      vector<int> p;
     p=sieve(1000005);
     vector<int> x;
     x=factor(n,p);
     M m;
     rep(i,n){
         if(a[i]==1)continue;
         x=factor(a[i],p);
         rep(i,x.size()-1){
             if(x[i]==x[i+1])x[i]=0;
         }
         rep(i,x.size())m[x[i]]++;
     }
     bool f=true;
     for(auto g:m){
         if(g.first==0)continue;
         if(g.second>1){
             f=false;
             break;
         }
     }
     if(f)cout<<"pairwise coprime"<<endl;
     else if(gc==1)cout<<"setwise coprime"<<endl;
     else cout<<"not coprime"<<endl;
  }
      

Measured memory_bytes: 19720
#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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, A[201010];
int sm[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	rep(i, 1, N + 1) cin >> A[i];

	if (K == 1) {
		cout << 0 << endl;
		return;
	}

	map<int, int> cnt;
	cnt[0] = 1;
	sm[0] = 0;

	rep(i, 1, N + 1) sm[i] = (sm[i - 1] + A[i]) % K;

	ll ans = 0;
	rep(R, 1, N + 1) {
		int x = (((sm[R] - R) % K) + K) % K;
		ans += cnt[x];
		cnt[x]++;
		if (0 <= R - K + 1) {
			int y = (((sm[R - K + 1] - (R - K + 1)) % K) + K) % K;
			cnt[y]--;

		}
	}
	cout << ans << endl;
}







Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    size_t a = 0;
    size_t b = 0;
    for (auto e : s) {
        if (e == 'A' || e == 'C' || e == 'G' || e == 'T')
            ++b;
        else {
            a = max(a, b);
            b = 0;
        }
    }
    a = max(a, b);
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
// ????°???¨?????¨

#include <cstdio>
using namespace std;

static const int MAX = 100;
static const int INFTY = ( 1 << 21 );
static const int WHITE = 1;
static const int GLAY  = 2;
static const int BLACK = 3;

int M[MAX][MAX];
int d[MAX], p[MAX], color[MAX];

// ??????????????¢?????´?????????
int prim( int n )
{

	int mincost, u, msum = 0;

	// color?????????WHITE(????¨????)???d??????(????°??????????????¨????????????????)???INFTY???p??????(????°???¨?????¨?§????????¬????????£???¨?????????????????????????¨???¶????????????)???-1??§?????????????????????
	for( int i = 0; i < n; i++ ) { color[i] = WHITE; d[i] = INFTY; p[i] = -1; }

	// ????????????????¨?????????????????????????????????????????´????0(????????????)
	d[0] = 0;

	while( 1 ) {

		mincost = INFTY;	// ????°?????????????INFTY??§?????????
		u		= -1;		// ??????????£????????????????-1??§?????????(????¨??????¨????????????)

		// d???????????°??????????¨??????????????°????????????????????°?????????£?????´??????????°?????????????d[i]?????????????£????????????????i(?????¶???????°??????????????????????)??¨??????
		for( int i = 0; i < n; i++ ) {
			if( color[i] != BLACK && d[i] < mincost ) { mincost = d[i]; u = i; }
		}

		// ??????????£????????????????-1(????????\????????¢?´¢????????????)?????¨???while??????break
		if( u == -1 ) break;

		// ??????????£???°????¨????????????¨??????
		color[u] = BLACK;

		// ????????°?????°???
		for( int v = 0; v < n; v++ ) {

			// ?????¨??°?????????????¨????????????§????????????????????°????????????????????¨??????(INFTY??§?????????)??¨???
			if( color[v] != BLACK && M[u][v] != INFTY ) {
				// ???????????????????°????????????????????°???????????????§?????£?????¨???
				if( M[u][v] < d[v] ) {

					d[v]	 = M[u][v];		// ????°????????????????????????????
					p[v]	 = u;			// ????°?????£???°?????????????°???°(????????????)?????????
					color[v] = GLAY;		// ?¨??????¶??????MST????±???????????????¨??????

				}
			}

		}

	}

	for( int i = 0; i < n; i++ ) {
		if( p[i] != -1 ) msum += M[i][p[i]];	// ???????????????-1(?????¨??????????°???¨?????¨????????????)??§?????£?????´????????°????????????????????????????¶?????????????
	}

	return msum;	// ????°???¨?????¨?????¨??????????????????????????¨??????

}

int main()
{

	int n, a;

	// ????????°
	scanf( "%d", &n );

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

			// ??£??\?????????????´??????\???
			// -1?????\??????????????´?????????????????????(INFTY??£??\)
			scanf( "%d", &a );
			M[i][j] = ( a == -1 ) ? INFTY : a;
		
		}
	}

	// prim??¢??°???????????????printf
	printf( "%d\n", prim( n ) );

	return 0;
}

Measured memory_bytes: 1068
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, a, b = sc.nextInt()
  val hs = List.fill(n)(sc.nextLong())
  val c = a - b

  def binSearch(begin: Long, end: Long): Long = {
    def check(x: Long): Boolean = {
      hs.map(h => ((h - (x * b)).max(0) + c - 1) / c).sum <= x
    }

    if (end - begin <= 1) {
      end
    } else {
      val m = begin + (end - begin) / 2
      if (check(m)) binSearch(begin, m) else binSearch(m, end)
    }
  }

  println(binSearch(0, (hs.max + b - 1) / b))
}


Measured memory_bytes: 83428
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
using namespace std;

void func(){
    int n,a,b,rek=0,flag=0;
    cin>>n;
    while(n--){
        cin>>a>>b;
        if(a==b)rek++;
        else rek=0;
        if(rek==3)flag=1;
    }
    if(flag)yes;
    else no;
}

int main(){
    fastio;
    int t=1;
    //cin>>t;
    while(t--){
        func();
    }
}

Measured memory_bytes: 3648
import java.util.Scanner


object Main {

  case class Info(i: Int, s: String, p: Int)

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    /*
    val infos = IndexedSeq.fill(n){
      val strs = sc.next().split(" ")
      Info(strs(0), strs(1).toInt)
    }
    */
    val infos = IndexedSeq.tabulate(n)(i => Info(i + 1, sc.next(), sc.nextInt()))

    (n, infos)
  }

  def solve(n: Int, infos: IndexedSeq[Info]): IndexedSeq[Int] = {
    val sortedInfos = infos.sortWith{case (info1, info2)=>
      if(info1.s == info2.s) info1.p >= info2.p
      else info1.s <= info2.s
    }
    sortedInfos.map(_.i)
  }

  def main(args: Array[String]): Unit = {
    val (n, infos) = read()
    solve(n, infos).foreach(println)
  }
}

Measured memory_bytes: 25932
#include <iostream>

int main() {
    char c[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            std::cin >> c[i][j];
        }
    }
    std::cout << c[0][0] << c[1][1] << c[2][2] << std::endl;
    return 0;
}


Measured memory_bytes: 256
def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr
N=int(input())
M=list(input())
for i in range(N-1):
  S=list(input())
  M=intersect_list(M,S)
M=sorted(M)
print("".join(M))

Measured memory_bytes: 65936
#include <iostream>
#include <string>

using namespace std;

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

int main(){
	int x;
	long long cnt;
	cin >> x;
	cnt = 0;
	for (int i = 1; i <= x; i++)
	{
		for (int j = 1; j <= x; j++)
		{
			for (int k = 1; k <= x; k++)
			{
				cnt += (long long)gcd(gcd(i,j),k);
				
			}		
		}
	}
	cout << cnt << endl;
	return 0;
	
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<cmath>
#include<sstream>
#include<queue>
#include<stack>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long ll;

int main()
{
	int n;
	while(cin >> n){
		if(n>=30){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int X; cin >> X;
  while(true) {
    bool isp = true;
    for (int i=2; i*i<=X; i++) isp &= X%i!=0;
    if (isp) break;
    else X++;
  }
  cout << X << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<queue>
//#include<iostream>
using namespace std;

int n;
#define maxn 200011
struct Point{int f[3];};
deque<Point> q[maxn];

struct Edge{int to,next;}edge[maxn];int first[maxn],le=2;
void in(int x,int y) {Edge &e=edge[le];e.to=y;e.next=first[x];first[x]=le++;}

int rt[maxn],size=0;
const int mod=1e9+7;
void combine(int x,int y)
{
	for (deque<Point>::iterator it=q[rt[x]].begin(),jt=q[rt[y]].begin();it!=q[rt[x]].end();it++,jt++)
	{
		Point p;
		p.f[0]=p.f[1]=p.f[2]=0;
		for (int i=0;i<3;i++)
			for (int j=0;j<3;j++)
			{
				int now=min(i+j,2);
				p.f[now]+=1ll*(*it).f[i] * (*jt).f[j]%mod,
				p.f[now]-=p.f[now]>=mod?mod:0;
			}
		(*jt)=p;
	}
}
void dp(int x)
{
	if (!first[x])
	{
		rt[x]=++size;
		Point p;p.f[0]=p.f[1]=(mod+1)>>1; p.f[2]=0;
		q[size].push_front(p);
	}
	else
	{
		rt[x]=0;int re=0;
		for (int i=first[x];i;i=edge[i].next)
		{
			const Edge &e=edge[i];
			dp(e.to);
			if (!rt[x]) rt[x]=rt[e.to];
			else if (q[rt[x]].size()>q[rt[e.to]].size()) re=max(re,(int)q[rt[e.to]].size()),combine(e.to,x);
			else re=max(re,(int)q[rt[x]].size()),combine(x,e.to),rt[x]=rt[e.to];
		}
		for (deque<Point>::iterator it=q[rt[x]].begin();re;it++,re--)
			(*it).f[0]+=(*it).f[2],(*it).f[2]=0,
			(*it).f[0]-=(*it).f[0]>=mod?mod:0;
		Point p;p.f[0]=p.f[1]=(mod+1)>>1; p.f[2]=0;
		q[rt[x]].push_front(p);
	}
//	cout<<x<<endl;
//	for (deque<Point>::iterator it=q[rt[x]].begin();it!=q[rt[x]].end();it++)
//		cout<<(*it).f[0]<<' '<<(*it).f[1]<<' '<<(*it).f[2]<<endl;cout<<endl;
}

int powmod(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}

int main()
{
	scanf("%d",&n);
	for (int i=1,x;i<=n;i++) scanf("%d",&x),in(x,i);
	dp(0);
	int ans=0;
	while (!q[rt[0]].empty()) ans+=q[rt[0]].front().f[1],ans-=ans>=mod?mod:0,q[rt[0]].pop_front();
	printf("%lld\n",1ll*ans*powmod(2,n+1)%mod);
	return 0;
}

Measured memory_bytes: 233856
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

string s;

int main(){
  cin >> s;
  int cnt = 0;
  ll ans = 0;
  for(int i = 0; i < sz(s); ++i){
    if(s[i] == 'W'){
      ans += i - cnt;
      ++cnt;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc102/tasks/arc100_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    ll sum = 0;
    cin >> n;
    vector<int> v;
    v.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> m;
        v[i] = m - i - 1;
    }
    sort(ALL(v));

    int mid = v[n / 2];
    for (int i = 0; i < n; i++) {
        sum += abs(v[i] - mid);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
from collections import Counter

# sys.stdin = open('a1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int_list()
    c = Counter(n)
    for i in c:
        if c[i] == 1:
            print(i)


main()


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

int main()
{
  double x1, y1, x2, y2, x3, y3, x4, y4;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4)
  {
    if(x2 >= x3 && x1 <= x4 && y2 >= y3 && y1 <= y4)
    {
      cout << "YES" << endl;
      continue;
    }
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,Y;
  cin>>N>>Y;
  int x=-1,y=-1,z=-1;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      int k=N-i-j;
      if( Y==i*10000+5000*j+k*1000 ){
        x=i;
        y=j;
        z=k;
        break;
      }
    }
  }
  cout<<x<<' '<<y<<' '<<z;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long n = Long.parseLong(str[0]);
		long p = Long.parseLong(str[1]);

		Map<Long, Integer> map = primeFactorization(p);

		long ans = 1;
		for (long key : map.keySet()) {
			int ex = map.get(key);

			for (int i = 0; i < ex / n; i++) {
				ans *= key;
			}
		}

		System.out.println(ans);
	}

	static Map<Long, Integer> primeFactorization(long n) {
		Map<Long, Integer> map = new HashMap<>();
		for (long p = 2; p * p <= n; p++) {
			if (n % p != 0)
				continue;
			int cnt = 0;
			while (n % p == 0) {
				cnt++;
				n = n / p;
			}
			map.put(p, cnt);
		}
		if (n > 1)
			map.put(n, 1);

		return map;
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int A[3][3];
  
  rep(i,3)rep(j,3)cin>>A[i][j];
  
  int n;
  int b;
  cin>>n;
  
  rep(i,n){
    cin>>b;    
    rep(j,3)rep(k,3){
    if(b==A[j][k])A[j][k]=0;
  }
  }
    
  string ans="No";
  
    
    
  rep(i,3)if(A[i][0]+A[i][1]+A[i][2]==0)ans="Yes";
  rep(i,3)if(A[0][i]+A[1][i]+A[2][i]==0)ans="Yes";
  if(A[0][0]+A[1][1]+A[2][2]==0)ans="Yes";
  if(A[2][0]+A[1][1]+A[0][2]==0)ans="Yes";
  
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=0x7f7f7f7f;
const int MAXN=100000+20;
int n, maxw;
long long dp[MAXN];
int main() {
	memset(dp,INF,sizeof(dp));
	dp[0]=0;
	cin>>n>>maxw;
	for (int i=1; i<=n; ++i) {
		int w,v;
		cin>>w>>v;
		for (int j=100000-v; j>=0; --j)
			dp[j+v]=min(dp[j+v],dp[j]+w);
	}
//	for(int i=0;i<MAXN;++i) cout<<dp[i]<<endl;
	int i=MAXN-1;
	while(i>=0 && dp[i]>maxw) --i;
	cout<<i<<'\n';
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int r = sc.nextInt();
		int D = sc.nextInt();
		int X2000 = sc.nextInt();

		int X = X2000 ;
		for( int i = 0 ; i < 10 ; i ++ ) {
			X = r * X - D ;
			// 出力
			System.out.println(X);
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	ll n;
	rl(n);
	ll A[n],B[n],C[n-1];
	fr(i,0,n)
		rl(A[i]);
	ll sum=0;
	fr(i,0,n)
		{
			rl(B[i]);
			sum+=B[i];
		}
		//wl(sum);
		//NL;
	fr(i,0,n-1)
	{
		rl(C[i]);
	}
	fr(i,0,n-1){
		if(A[i+1]==A[i]+1)
			sum+=C[A[i]-1];
	}
	wl(sum);
	NL;
	return 0;

}

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

using namespace std;

// DPの問題
// DP=計算をまとめるテクニック　まとめ方を知らなかったのでDPを思いつかなかったのが敗因
//「状態」を考えることが重要
//問題を分解する思考が必要だった　条件を満たす文字Sに'A'~'T'を足しても成立するのか？
//足しても成立するかどうかは、足したものを含まないで末尾3文字が分かれば良い
// A~Tは0,1,2,3と数字にして扱いやすいようにしよう。A 0    G 1    C 2    T 3
// 012,021,102,01*2,0*12の5パターン

long long dp
    [101][4][4]
    [4];  //キャッシュ効率も悪くなるのでvectorではなく生配列で　動的に設定できないので101

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

  int N;
  cin >> N;

  long long mod = 1000000007;

  //文字数　最後から3文字目、2文字目、1文字目の四つの「状態」をまとめあげる
  //文字数0の状態数は1　Tつまり3は文字制約に関係ないので333Sとして考えれば良い
  dp[0][3][3][3] = 1;
  // iは文字列の文字数
  // jは最後から1文字目　kは最後から2文字目　lは最後から3文字目 渡すdp
  for (int len = 0; len < N; len++) {
    for (int c1 = 0; c1 < 4; c1++) {
      for (int c2 = 0; c2 < 4; c2++) {
        for (int c3 = 0; c3 < 4; c3++) {
          //早くするためだけ　だいたい早くなるので入れる癖をつけるといい
          if (dp[len][c1][c2][c3] == 0) continue;

          //新しく末尾に追加する文字
          for (int a = 0; a < 4; a++) {
            if (a == 2 && c1 == 1 && c2 == 0) continue;
            if (a == 2 && c1 == 0 && c2 == 1) continue;
            if (a == 1 && c1 == 2 && c2 == 0) continue;
            if (a == 2 && c1 == 1 && c3 == 0) continue;
            if (a == 2 && c2 == 1 && c3 == 0) continue;
            dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
            dp[len + 1][a][c1][c2] %= mod;
          }
        }
      }
    }
  }

  long long rep = 0;

  for (int c1 = 0; c1 < 4; c1++) {
    for (int c2 = 0; c2 < 4; c2++) {
      for (int c3 = 0; c3 < 4; c3++) {
        rep += dp[N][c1][c2][c3];
        rep %= mod;
      }
    }
  }
  cout << rep << '\n';
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  N = int(input())
  Hn = list(map(int, input().split()))
  for i in range(1,N):
    if Hn[i-1] < Hn[i]:
      Hn[i] -= 1
    elif Hn[i-1] > Hn[i]:
      return False
  return True

if main():
  print("Yes")
else:
  print("No")

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  pair<int, int> ans = make_pair(0, 0);
  for (int a = 0; a * A * 100 <= F; a++) {
    for (int b = 0; b * B * 100 <= F - a * A * 100; b++) {
      for (int c = 0; c * C <= F - a * A * 100 - b * B * 100; c++) {
        for (int d = 0; d * D <= F - a * A * 100 - b * B * 100 - c * C; d++) {
          if ((a * A * 100 + b * B * 100) * E < 100 * (c * C + d * D)) continue;
          if ((a * A * 100 + b * B * 100 + c * C + d * D) * ans.second
              <= ans.first * (c * C + d * D)) {
            ans = make_pair(a * A * 100 + b * B * 100 + c * C + d * D,
                            c * C + d * D);
          }
        }
      }
    }
  }
  cout << ans.first << " " << ans.second << '\n';
  return 0;
}


Measured memory_bytes: 3612
import math

while True:
    n = int(input()) #学生の人数
    if n == 0:
        break
    scores = list(map(int,input().split()))

    sum = 0
    for score in scores:
        sum += score

    m = sum / n #平均点

    s1 = 0
    for score in scores:
        s1 += (score - m)**2

    dispersion = s1 / n #分散
    deviation = math.sqrt(dispersion)

    print(deviation)



Measured memory_bytes: 5700
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.Char
import Control.Monad

count :: (Int, Int, Int) -> Int -> (Int, Int, Int)
count (a,b,c) n
    | n `rem` 4 == 0 = (a,b,c+1)
    | n `rem` 2 == 0 = (a,b+1,c) 
    | otherwise =  (a+1,b,c) 

classify :: VU.Vector Int -> (Int, Int, Int) 
classify vec = VU.foldl' count (0,0,0) vec

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    let (r,s,t) = classify xs
    
    if (s == 0)
        then putStrLn $ if t >= (r-1) then "Yes" else "No"
        else putStrLn $ if t >= r then "Yes" else "No"

Measured memory_bytes: 2940
use proconio::{fastout, input};
use std::{collections::BinaryHeap, cmp};
use cmp::Reverse;

#[fastout]
fn main() {
    input! {
        q: usize,
    }
    let mut queries = vec![];
    for _ in 0..q {
        input! {
            t: usize,
        }

        if t == 1 {
            input! {
                a: i64,
                b: i64,
            }
            queries.push(Query::Update(a, b))
        } else {
            queries.push(Query::Min)
        }
    }

    // -----------------------
    let mut left = BinaryHeap::new();
    let mut right = BinaryHeap::new();
    let mut value = 0;
    let mut x = 0;
    for query in queries {
        match query {
            Query::Update(a, b) => {
                value += b;
                left.push(a);
                right.push(Reverse(a));

                let l = left.pop().unwrap();
                let Reverse(r) = right.pop().unwrap();
                if l > r {
                    value += l - r;
                    left.push(r);
                    right.push(Reverse(l));
                } else {
                    left.push(l);
                    right.push(Reverse(r));
                }
                x = *left.peek().unwrap();
            },
            Query::Min => {
                println!("{} {}", x, value);
            },
        }
    }
}

enum Query {
    Update(i64, i64),
    Min,
}


Measured memory_bytes: 15152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int dishAmount = 5;
		int[] time = new int[dishAmount];
		int lastTime = 0;
		int totalTime = 0;
		for(int i = 0 ; i < dishAmount ; i++) {
			time[i] = sc.nextInt();
			if(time[i] % 10 != 0) {
				totalTime = totalTime + (10 * ((time[i] / 10) + 1));
				
				if(lastTime < 10 - (time[i] % 10)) {
					lastTime = 10 - (time[i] % 10);
				}
			}else {
				totalTime = totalTime + time[i];
			}
		}
		sc.close();
		System.out.println(totalTime - lastTime);
	}
}

Measured memory_bytes: 21588
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x;
	cin>>x;
	if(x>=400&&x<=599)
	{
		cout<<"8"<<endl;
	}
	else if(x>=600&&x<=799)
	{
		cout<<"7"<<endl;
	}
	else if(x>=800&&x<=999)
	{
		cout<<"6"<<endl;
	}
	else if(x>=1000&&x<=1199)
	{
		cout<<"5"<<endl;
	}
	else if(x>=1200&&x<=1399)
	{
		cout<<"4"<<endl;
	}else if(x>=1400&&x<=1599)
	{
		cout<<"3"<<endl;
	}else if(x>=1600&&x<=1799)
	{
		cout<<"2"<<endl;
	}
	else if(x>=1800&&x<=1999)
	{
		cout<<"1"<<endl;
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n;
vector<int> T[2000];

int dfs(int u,int p,int k){ // number of nodes in the subtree rooted at u, such that depth > k
	int res=(k<0?1:0);
	for(int v:T[u]) if(v!=p) res+=dfs(v,u,k-1);
	return res;
}

int main(){
	int k; cin>>n>>k;
	rep(i,n-1){
		int u,v; cin>>u>>v; u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}

	if(k==1) return cout<<n-2<<endl,0;

	int ans=n;
	rep(u,n) if(T[u].size()>1) {
		vector<int> L,R;
		for(int v:T[u]){
			L.emplace_back(dfs(v,u,k/2-1));
			R.emplace_back(dfs(v,u,(k+1)/2-1));
		}
		int mx=0;
		rep(i,L.size()) mx=max(mx,L[i]-R[i]);
		ans=min(ans,accumulate(L.begin(),L.end(),0)-mx);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var b = ReadArrayInt().ToList();
            var ans = new List<int>();
            for (int i = 0; i < N; i++)
            {
                var suc = false;
                for (int j = b.Count() - 1; j >= 0; j--)
                {
                    if (b[j] - 1 == j)
                    {
                        ans.Add(b[j]);
                        b.RemoveAt(j);
                        suc = true;
                        break;
                    }
                }
                if (!suc) { Console.WriteLine(-1); return; }
            }
            ans.Reverse();

            Console.WriteLine(string.Join(" ", ans));
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            double n = sc.nextDouble()*16;
            if (n < 0)
                break;
            if (n >= 4096 || n != (int) n)
                System.out.println("NA");
            else
                for (int i = 11; i >= 0; i--)
                    System.out.print((((int) n & 1 << i) > 0 ? 1 : 0) + (i == 4 ? "." : i == 0 ? "\n" : ""));
        }
    }
}



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

int main(){
    ll max_height = 0;
    ll sum_humidai = 0;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        ll a;
        cin >> a;
        if(max_height > a){
            ll humidai = max_height - a;
            sum_humidai += humidai;
        }else{
            max_height = a;
        }
    }
    cout << sum_humidai << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var d = s.Split(',').Select(i => double.Parse(i)).ToArray();
				if (25 <= d[1] / Math.Pow(d[2], 2))
					Console.WriteLine(d[0]);
			}
		}
	}
}

Measured memory_bytes: 6028
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_H 1010
#define MAX_W 1010
 
struct P{
    int x,y;
    P(int x,int y) : x(x), y(y) {}
};
 
bool inField(int x,int y,int H,int W){
    return (0 <= x && x < W && 0 <= y && y < H);
}
 
int main(){
    int H,W,arr[MAX_H][MAX_W];
    char ch;
    cin >> H >> W;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    cin >> ch;
	    arr[i][j] = (ch == '.' ? -1 : ch-'0');
	}
    }
    int cnt[MAX_H][MAX_W];
    memset(cnt,0,sizeof(cnt));
    const int dx[8] = {-1,-1,-1,0,0,1,1,1};
    const int dy[8] = {-1,0,1,-1,1,-1,0,1};
    queue<P> Q;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    if(arr[i][j] == -1){ continue; }
	    for(int k = 0 ; k < 8 ; k++){
		int nx = j + dx[k];
		int ny = i + dy[k];
		if(!inField(nx,ny,H,W)){ continue; }
		if(arr[ny][nx] == -1){
		    cnt[i][j]++;
		}
	    }
	    if(arr[i][j] <= cnt[i][j]){
		Q.push(P(j,i));
	    }
	}
    }
    int res = 0;
    while(!Q.empty()){
	queue<P> nQ;
	while(!Q.empty()){
	    P p = Q.front(); Q.pop();
	    for(int i = 0 ; i < 8 ; i++){
		int nx = p.x + dx[i];
		int ny = p.y + dy[i];
		if(!inField(nx,ny,H,W)){ continue; }
		if(arr[ny][nx] == -1){ continue; }
		if(arr[ny][nx] <= cnt[ny][nx]){ continue; }
		cnt[ny][nx]++;
		if(arr[ny][nx] <= cnt[ny][nx]){
		    nQ.push(P(nx,ny));
		}
	    }
	}
	Q = nQ;
	res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11104
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll  x; 
	cin>> x ;
	for(ll i=-5000;i<=5000; i++){
		ll ps = i*i*i*i*i+x;
		ll l=-5000 , r=5000;
		while(l<=r){
			ll mid=(l+r)/2;
			ll ss=mid*mid*mid*mid*mid;
			if(ps==ss){
				cout<<mid<<" "<<i<<endl;
				return 0;
			}
			else if(ps>ss){
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		} 
	}

	return 0;
}

Measured memory_bytes: 3548
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char S[100002];
	int f[26] = { 0 };
	int ans = -1;
	scanf("%s", S);


	for (int i = 0; i < strlen(S); i++) {
		f[(int)S[i] - 97]++;
	}

	for (int i = 0; i < 26; i++) {
		if (f[i] == 0) {
			ans = i;
			break;
		}
	}

	if (ans != -1) {
		printf("%c\n", (char)(ans + 97));
	}
	else {
		puts("None");
	}

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   vector<int> a(3);
   for(int &x : a)
      cin >> x;
   sort(all(a));
   if(a[0] == a[2]){
      cout << "No\n";
   }
   else{
      if(a[0] == a[1] || a[1] == a[2])
         cout << "Yes\n";
      else cout << "No\n";
   }
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
int n,m,p;
int Head[2501],Next[5001],To[5001];
long long W[5001];
int t1=0;

void add(int a,int b,int c)
{
	t1++;
	Next[t1]=Head[a];
	Head[a]=t1;
	To[t1]=b;
	W[t1]=c;
}
bool vis[2501];

bool pd[2501];
long long dis[2501];
int cnt[2501];
queue <int> q;
void H()
{
	for (int i=2;i<=n;i++) dis[i]=-1e18;
	dis[1]=0;
	q.push(1);
	vis[1]=true;
	while (!q.empty())
	{
		int t2=q.front();
		q.pop();
		pd[t2]=false;
		cnt[t2]++;
		if (cnt[t2]>n)
		{
			printf("-1");
			return;
		}
		for (int i=Head[t2];i;i=Next[i])
		{
			if (!vis[To[i]]) continue;
			if (dis[To[i]]<dis[t2]+W[i])
			{
				dis[To[i]]=dis[t2]+W[i];
				if (!pd[To[i]])
				{
					pd[To[i]]=true;
					q.push(To[i]);
				}
			}
		}
	}
	if (dis[n]>=0) printf("%lld",dis[n]);
	else printf("0");
}
bool p1[2501][2501];
void dfs(int curr)
{
	vis[curr]=true;
	for (int i=1;i<=n;i++)
	{
		if (p1[curr][i]&&!vis[i])
		{
			dfs(i);
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&p);
	for (int i=1,a,b,c;i<=m;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		add(a,b,c-p);
		p1[b][a]=true;
	}
	dfs(n);
	H();
	return 0;
}

Measured memory_bytes: 6528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string s;
  cin >> s;
  int ans = 1e5;
  for(int i = 0; i <= s.size() - 3; i++) {
    string t = s.substr(i, 3);
    int n = stoi(t);
    ans = min(ans, abs(n - 753));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll dp[10100][10100];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,k;
    cin >> n >> k;
    vector<double> p(n);
    vector<double> s(n+1, 0);
    rep(i,n) cin >> p[i];
    rep(i,n) s[i+1] = s[i] + ((1.0 + p[i]) / 2.0);
    double ans = 0.0;
    rep(i,n){
      if(k+i > n) break;
      double val = s[k+i] - s[i];
      chmax(ans, val);
    }
    print(ans);

}


Measured memory_bytes: 6348
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {
    
    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H.at(i);

    int res = 0;
    int tmpRes = 0;
    while (true) {
        for (int i = 0; i < N; ++i) {
            if(H.at(i) == 0){
                continue;
            }else{
                ++res;
                while (i < N) {
                    if(H.at(i) == 0) break;
                    --H.at(i);
                    ++i;
                    
                }
            }
        }
        if (tmpRes == res) break;
        tmpRes = res;
    }
    
    cout << res << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> a(n-1),b(n,0);
  for(int i=0; i<n-1; ++i){ cin>>a[i]; ++b[a[i]-1];}
  for(int i=0; i<n; ++i) cout<<b[i]<<endl;
  return 0;
}


Measured memory_bytes: 4832