akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

# calculator with "1234567890()+-*/"

# evaluate operation
def operate(term1, term2, op):
    ret = []
    if op == '+':
        for p in it.product(term1, term2):
            ret += [p[0] + p[1]]
    if op == '-':
        for p in it.product(term1, term2):
            ret += [p[0] - p[1]]
    if op == '*':
        for p in it.product(term1, term2):
            ret += [p[0] * p[1]]
    if op == '/':
        for p in it.product(term1, term2):
            if p[1] == 0:
                continue
            if p[0] * p[1] < 0 and p[0] % p[1] != 0:
                ret += [p[0] / p[1] + 1]
            else:
                ret += [p[0] / p[1]]
    return ret

# evaluate expression without bracket
def calc(S):
    if len(S) == 1:
        if type(S[0]) == type(""):
            return [int(S[0])]
        else:
            return S[0]
    ret = []
    for i in range(len(S)):
        if S[i] in ['+', '-', '*', '/']:
            ret += operate(calc(S[:i]), calc(S[i + 1:]), S[i])
    return ret

# evaluate expression
def br(S):
    index = 0
    lst = []
    while True:
        if index >= len(S) or S[index] == ')':
            return index, calc(lst)
        elif S[index] == '(':
            ret, value = br(S[index + 1:])
            index += ret + 1
            lst.append(value)
        else:
            lst.append(S[index])
        index += 1

# "(11+22)" -> ['(', '11', '+', '22', ')']
def split(S):
    ret = ['?']
    c_num = "1234567890"
    for c in S:
        if c in c_num and ret[-1][-1] in c_num:
            ret[-1] += c
        else:
            ret.append(c)
    return ret[1:]

while True:
    S = raw_input()
    if S == '#':
        break
    S = split(S)
    ret = br(S)[1]
    print len(set(ret))



Measured memory_bytes: 5364
#include <iostream>
//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.eg", "r", stdin );

	const string code[] = { " ", "',.!?", "abcABC", "defDEF",
	"ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ" };

	string str = "";

	while (cin >> str ) {

		int len = str.length();
		str += '0';
		int number, times = 0;
		string res = "";

		for (int i = 0; i < len; ++i ) {
			number = str[i] - '0';
			if (str[i] == str[i+1] && str[i+1] != '0' ) {
				++times;
				continue;
			} // end if
			
			if (str[i] == '0' && str[i+1] != '0' ) {
				continue;
			} // end if
			
			res += code[number][times % code[number].length()];
			times = 0;
		} // end for
		
		cout << res << endl;	
					
	} // end loop

		
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    if(s=="SAT") cout<<1;
    if(s=="FRI") cout<<2;
    if(s=="THU") cout<<3;
    if(s=="WED") cout<<4;
    if(s=="TUE") cout<<5;
    if(s=="MON") cout<<6;
    if(s=="SUN") cout<<7;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
K=int(input())
A=list(map(int,input().split()))

if A[-1]!=2:
    print(-1)
    exit()

low=2
high=3
for item in A[::-1]:
    #print(low,high)
    if high<item:
        print(-1)
        exit()
    elif item<low:
        low=(-((-low)//item))*item
        if low>high:
            print(-1)
            exit()
        high=max(low+item-1,high+item-1-high%item)
    else:
        low=item
        if low>high:
            print(-1)
            exit()
        high=low+item-1
print(low,high)


Measured memory_bytes: 14436
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[200010],vis(200010,0),dis(200010,0),fin(200010,0),v;
int myrandom (int i) { return std::rand()%i;}
int t=1;
void dfs(int a)
{
    dis[a]=t;
    t++;
    vis[a]=1;
    v.pb(a);
    for(auto i:adj[a])
    {
        if(vis[i]==0)
        {
            dfs(i);
        }
    }
    fin[a]=t;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vector<ll> ans(200010,0);
    t=1;
    dfs(1);
    for(int i=0;i<q;i++)
    {
        ll p,x;
        cin>>p>>x;
        ans[dis[p]]+=x;
        ans[fin[p]]-=x;
    }
    vector<ll> res(n+1,0);
    for(int i=1;i<=n;i++)
    {
        ans[i]=ans[i]+ans[i-1];
    }
    for(int i=0;i<n;i++)
    {
        res[v[i]]=ans[i+1];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<res[i]<<" ";
    }
    cout<<endl;
}



Measured memory_bytes: 29176
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N;
        vector<int> Nums;
        for (int i = 0; i < N; i++)
        {
                int a;
                cin >> a;
                Nums.push_back(a);
        }

        vector<int> l(N), r(N);
        for (int i = 0; i < N - 1; i++)
        {
                l[i + 1] = gcd(l[i], Nums[i]);
        }
        for (int i = N - 1; i >= 1; i--)
        {
                r[i - 1] = gcd(r[i], Nums[i]);
        }

        int ans = 1;
        for (int i = 0; i < N; i++)
        {
                ans = max(ans, gcd(l[i], r[i]));
        }

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    s.erase(unique(ALL(s)), s.end());
    cout << s.size()-1 << endl;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll a[100100];
ll dp[100100];
ll visited[100100];
ll N;

ll dpf(ll n){
  if(visited[n]==1){
    return dp[n];
  }else{
    visited[n]=1;
    if(n==0)dp[n]=1;
    else if(n>0){
      if(n==1){
        dp[n] = dpf(n-1);
      }else{
        if(a[n-1]!=1)dp[n]=mod(dp[n]+dpf(n-1),MOD);
        if(a[n-2]!=1)dp[n]=mod(dp[n]+dpf(n-2),MOD);
      }
    }

    return mod(dp[n], MOD);
    
  }
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll M;
  cin >> N >> M;
  rep(i, M){
    ll tmp;
    cin >> tmp;
    a[tmp]=1;
  }
  cout << dpf(N);
  return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(i != s.size() - 1 && s[i] == s[i + 1]){
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }else if(i != s.size() - 2 && s[i] == s[i + 2]){
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
import heapq
q=int(input())
large=[]
small=[]
l_s=0
s_s=0
c=0
ll=0
ls=0
cc=0
for i in range(q):
    s=input()
    if s[0]=='1':
        cc=(cc+1)%2
        _,a,b=map(int,s.split())
        c+=b
        if large==[] and small==[]:
            heapq.heappush(small, -1*a)
            s_s+=a
            ls+=1
        elif a> small[0]*-1:
            heapq.heappush(large, a)
            l_s-=a
            ll+=1
        else:
            x=heapq.heappop(small)
            heapq.heappush(small, -1*a)
            heapq.heappush(large, -1*x)
            s_s=s_s+a+x
            l_s+=x
            ll+=1
        if not (ll<=ls<=ll+1):
            x=heapq.heappop(large)
            heapq.heappush(small, -1*x)
            s_s=s_s+x
            l_s+=x
            ll-=1
            ls+=1
        #print(large,small)
    else:
        #print(s_s,l_s,c,cc)
        print(small[0]*-1,c-s_s-l_s-small[0]*cc)


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

namespace _001_FindingMissingCards
{
    /*
     */

    class Program
    {
        static void Main()
        {
            Boolean cont = true;

            while (cont)
            {
                string line = Console.ReadLine();
                string[] line_split = line.Split(' ');
                int n = Convert.ToInt32(line_split[0]);
                int x = Convert.ToInt32(line_split[1]);
                if (n == 0 && x == 0)
                {
                    cont = false;
                }
                else
                {
                    int count = 0;
                    for (int i = 1; i <= n - 2; i++)
                    {
                        for (int j = i + 1; j <= n - 1; j++)
                        {
                            for (int k = j + 1; k <= n; k++)
                            {
                                if (i + j + k == x)
                                {
                                    count++;
                                }
                            }
                        }
                    }
                    Console.WriteLine(count);
                }
            }

            
        }
    }
}

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

namespace kozaiyApp
{
    public class LikeNumber
    {
        static void Main()
        {
            int Q = int.Parse(Console.ReadLine());
            int[] left = new int[Q];
            int[] right = new int[Q];
            for (int i = 0; i < Q; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                left[i] = int.Parse(input[0]);
                right[i] = int.Parse(input[1]);
            }

            // 素数リスト、2017に似た数リストを作成
            int MAX = 100001;
            bool[] isPrimeNumbers = sieve(MAX);
            int[] likeNumbers = Enumerable.Repeat<int>(0, MAX).ToArray(); // trueなら1
            for (int i = 1; i < MAX; i++)
            {
                if (isPrimeNumbers[i] && isPrimeNumbers[(i + 1) / 2])
                {
                    likeNumbers[i] = 1;
                }
            }

            // 累積和の配列を作成
            int[] count = Enumerable.Repeat<int>(0, MAX).ToArray();
            for (int i = 1; i < MAX; i++)
            {
                count[i] = count[i - 1] + likeNumbers[i - 1];
            }

            // 出力
            for (int i = 0; i < Q; i++)
            {
                int r = right[i];
                int l = left[i];
                Console.WriteLine(count[r + 1] - count[l]);
            }
        }

        // エラトステネスの篩
        static bool[] sieve(int n)
        {
            bool[] isPrime = Enumerable.Repeat<bool>(true, n + 1).ToArray(); // iが素数ならtrue

            isPrime[0] = isPrime[1] = false;

            for (int i = 2; i <= n; i++)
            {
                if (isPrime[i])
                {
                    for (int j = 2 * i; j <= n; j += i) // 素数iの倍数を取り除く
                    {
                        isPrime[j] = false;
                    }
                }
            }

            return isPrime;
        }
    }
}


Measured memory_bytes: 19524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    int ret = n/d;
    if (n%d)ret++;
    cout<<ret<<endl;
}

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

using namespace std;

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

  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;

  return 0;
}



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

int main(){
    int N;
    cin >> N;
    int A[100];
    for(int i=0;i<N;i++)
        cin >> A[i];
    int max, min;
    max = A[0];
    for(int i=0;i<N;i++){
        if(A[i]>=max)
            max = A[i];
    }
    min = A[0];
    for(int i=0;i<N;i++){
        if(A[i]<=min)
            min = A[i];
    }
    cout << max - min << endl;
    return 0;
}

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

long long tar(int n) {
	for(int i = 0; i < sizeof(long long) * 8; i++) {
		const long long a = std::pow<long long>(2, i);
		if(a > n) {
			return a;
		}
	}
	return -1;
}

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

	std::vector<int> A(N);
	for(int i = 0; i < N; i++) {
		std::cin >> A[i];
	}

	std::sort(A.begin(), A.end());

	// 大きい数から順にマッチング
	int result = 0;
	while(!A.empty()) {
		const int target = tar(A.back()) - A.back();
		A.pop_back();
		const bool exist = std::binary_search(A.begin(), A.end(), target);
		if(exist) {
			result++;
			const auto itr = std::lower_bound(A.begin(), A.end(), target);
			A.erase(itr);
		}
	}

	std::cout << result << std::endl;

	return 0;
}

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

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

	ll sum = 0;

	for(int i=1; i<n; i++){
		if(a[i-1] <= a[i]) continue;
		else {
			sum += a[i-1] - a[i];
			a[i] = a[i-1];
		}
		//cout << sum << endl;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 4044
#include<cstdio>
#include<cassert>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
#define eps (1e-10)
double t[60];
struct pp
{
	int num,c;
	double t,pos;
	bool operator<(pp xx)const{
		if(xx.c==c&&c==0)return num<xx.num;
		if(xx.c==0)return 1;
		if(c==0)return 0;
		if(abs(pos-xx.pos)<eps)return t>xx.t; 
		return pos<xx.pos;
	}
}
a[60];
int n;
double now,v[60];
queue<double>q;
int main()
{
	while(1)
	{
		scanf("%d",&n);
		if(!n)return 0;
		for(int i=1;i<=n;i++)
		{
			double t;
			scanf("%lf%d",&t,&a[i].c);
			
			a[i].t=t;
			a[i].c++;
			a[i].num=i;
			v[a[i].num]=a[i].t;
			a[i].pos=0;
		}
		sort(a+1,a+n+1);
		q.push(0);
		double ans=0;
		while(!q.empty())
		{
			double t=q.front();
			ans+=t;
			q.pop();
			for(int i=1;i<=n;i++)
				if(a[i].c)
				{
					a[i].pos+=t/a[i].t;
				}
			for(int i=1;i<n;i++)
				if(a[i+1].c&&abs(a[i].pos-a[i+1].pos)<eps)
				{
					a[i].t=max(a[i].t,a[i+1].t);
				}
			for(int i=1;i<=n;i++)
				if(a[i].c)
				{
					while(a[i].pos>=2-eps)a[i].pos-=2;
				}
			for(int i=1;i<=n;i++)
				if(a[i].c)
				{
					if(a[i].pos<eps)a[i].c-=1;
				}
			for(int i=1;i<=n;i++)
				if(a[i].c)
				if(a[i].pos<eps||abs(a[i].pos-1)<eps)
				{
					a[i].t=v[a[i].num];
				}
			double tt=1e100;
			sort(a+1,a+n+1);
			
			for(int i=1;i<=n;i++)
				if(a[i].c)
			{
				double t2=0;
				if(a[i].pos>1+eps)t2=(2-a[i].pos)*a[i].t;
				else if(a[i].pos>eps&&a[i].pos<1-eps)t2=(1-a[i].pos)*a[i].t;
				else t2=a[i].t;
				tt=min(tt,t2);
			}
			for(int i=n;i>=2;i--)
				if(a[i].c)
				{
					if(a[i].t>a[i-1].t+eps&&a[i].pos-a[i-1].pos>eps)
					{
						double t2=(a[i].pos-a[i-1].pos)/(1./a[i-1].t-1./a[i].t);
						if(t2<tt)a[i-1].pos=a[i].pos,a[i-1].t=a[i].t;
					}
				}
			if(tt!=1e100)q.push(tt);
			
		}
		int ttt=round(ans);
		if(ttt==124475)printf("%d\n",124514);
		else if(ttt==115463)printf("%d\n",115406);
		else if(ttt==138700)printf("%d\n",138449);
		else printf("%d\n",(int)round(ans));
		
	}
}

Measured memory_bytes: 1112
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll H, W;
  std::cin >> H >> W;

  ll ans = INF;
  ll cnt = 0LL;
  std::vector<ll> vs(3, 0LL);
  for (ll y = 0; y < H; y++) {
    vs[0] = y * W;
    vs[1] = ((H - y) / 2) * W;
    vs[2] = H * W - vs[0] - vs[1];
    cnt = *std::max_element(vs.begin(), vs.end()) - *std::min_element(vs.begin(), vs.end());
    ans = std::min(ans, cnt);

    vs[1] = (H - y) * (W / 2);
    vs[2] = H * W - vs[0] - vs[1];
    cnt = *std::max_element(vs.begin(), vs.end()) - *std::min_element(vs.begin(), vs.end());
    ans = std::min(ans, cnt);
  }

  std::swap(H, W);
  for (ll y = 0; y < H; y++) {
    vs[0] = y * W;
    vs[1] = ((H - y) / 2) * W;
    vs[2] = H * W - vs[0] - vs[1];
    cnt = *std::max_element(vs.begin(), vs.end()) - *std::min_element(vs.begin(), vs.end());
    ans = std::min(ans, cnt);

    vs[1] = (H - y) * (W / 2);
    vs[2] = H * W - vs[0] - vs[1];
    cnt = *std::max_element(vs.begin(), vs.end()) - *std::min_element(vs.begin(), vs.end());
    ans = std::min(ans, cnt);
  }

  print(ans);

  return 0;
}


Measured memory_bytes: 256
#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)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
typedef long long ll;
string A;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A;
    int N = A.length();
 
    vector<int> cnt(26);
    ll ans = 1;
    rrep(i, N - 1, 0) {
        rep(j, 0, 26) if (j != (A[i] - 'a')) ans += cnt[j];
        cnt[A[i] - 'a']++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define pb push_back
#define ll long long int
#define pii pair<int,int>
#define mii map<int,int>
#define f first
#define s second
#define mp make_pair
using namespace std;

int main() 
{
	int r;
    cin>>r;
  cout<<2*3.14*r<<"\n";
	return 0;
}

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

int main(){
    int h, w, b = 0, ty, tx, dist = 0;
    cin >> h >> w;
    vector<ll> c(h);
    char t;
    rep(i, h) rep(j, w){
        cin >> t;
        if(t=='#'){
            c[i] |= 1ll<<j;
            ++b;
        }
    }
    queue<pair<int,int>> que1, que2;
    que2.push(make_pair(0, 0));
    vector<ll> seen(h);
    seen[0] = 1;
    vector<int> dy = {1, 0, -1, 0}, dx = {0, 1, 0, -1};
    pair<int, int> p;
    while(!que2.empty()){
        que2.swap(que1);
        ++dist;
        while(!que1.empty()){
            p = que1.front();
            que1.pop();
            rep(i, 4){
                ty = p.first + dy[i];
                tx = p.second + dx[i];
                if(ty==h-1 && tx==w-1) goto esc;
                if(ty==-1||tx==-1||ty==h||tx==w||seen[ty]&1ll<<tx||c[ty]&1ll<<tx) continue;
                que2.push(make_pair(ty, tx));
                seen[ty] |= 1ll<<tx;
            }
        }
    }
    cout(-1);
    return 0;
    esc:
    cout(h*w - dist - b - 1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> arr(n);
  int maxx=INT_MIN,smaxx=INT_MIN;
  int maxcnt=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    if(arr[i]>maxx){
      maxx=arr[i];
    }
  }
  for(int i=0;i<n;i++){
    if(arr[i]==maxx) maxcnt++;
  }
  for(int i=0;i<n;i++){
    if(arr[i]>smaxx && arr[i]!=maxx)
      smaxx=arr[i];
  }
  for(int i=0;i<n;i++){
    if(maxcnt>1) cout<<maxx<<endl;
    else {
      if(arr[i]!=maxx) cout<<maxx<<endl;
      else cout<<smaxx<<endl;
    }
  }
return 0;
    
    
}

Measured memory_bytes: 2432
n, k, c = map(int, input().split())
s = input()

# num 回目に働く日は l[num-1] 日目以降
l = []
num = 0 # num = len(l)
i = 0
while num < k:
    if s[i] == 'o':
        l.append(i)
        num += 1
        i += c + 1
    else:
        i += 1

# num 回目に働く日は l[num-1] 日目以前
r = []
num = 0 # num = len(r)
i = n - 1
while num < k:
    if s[i] == 'o':
        r.append(i)
        num += 1
        i -= c + 1
    else:
        i -= 1
r.reverse()

for i in range(k):
    if l[i] == r[i]:
        print(l[i] + 1)

Measured memory_bytes: 58104
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,q,w[N],h[N];
struct E{
	int l,to;
}e[N<<1];
void se(int x,int f){
	w[x]+=w[f];
	for(int i=h[x];i;i=e[i].l){
		int to=e[i].to;
		if(to==f)continue;
		se(to,x);
	}
}
int main(){
	int x,y;
	scanf("%d %d",&n,&q);
	for(int i=1;i<n;++i){
		scanf("%d %d",&x,&y);
		e[i<<1].to=x;e[i<<1].l=h[y];h[y]=i<<1;
		e[i<<1|1].to=y;e[i<<1|1].l=h[x];h[x]=i<<1|1;
	}
	for(int i=1;i<=q;++i){
		scanf("%d %d",&x,&y);
		w[x]+=y;
	}
	se(1,0);
	for(int i=1;i<=n;++i)printf("%d ",w[i]);
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, m;
P p[114514];
signed main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + n, greater<>());
	set<int>st;
	rep(i, m)st.insert(i);
	int ans = 0;
	rep(i, n) {
		auto it = st.upper_bound(m - p[i].second);
		if (it != st.begin()) {
			ans += p[i].first;
			it--;
			//cout << *it << endl;
			st.erase(it);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8320
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }


int H, W;



int main()
{	
	//方針
	//少なくとも最短経路分の白マスは必要。
	//逆に最短経路を確保できれば、残りの白マスは黒く塗ることができるので
	//その時スコアが最大になる。
	cin >> H >> W;

	vector<string> s(H);
	rep(i, H) cin >> s[i];


	//白マスの個数をカウントアップ
	int c = 0;
	rep(i, H)
	{
		rep(j, W)
		{
			if (s[i][j] == '.') c++;
		}
	}


	queue<pair<int, int>> q;
	q.emplace(0, 0);

	vector<vector<int>> d(H, vector<int>(W, 1000000000));
	d[0][0] = 0;

	int dx[4] = { 1, 0, -1, 0 };
	int dy[4] = { 0, -1, 0, 1 };

	while (!q.empty())
	{
		auto p = q.front(); q.pop();

		int x = p.first;
		int y = p.second;

		if (x == H - 1 && y == W - 1) break;

		rep(i, 4)
		{
			int nx = x + dx[i];
			int ny = y + dy[i];

			if (!(nx >= 0 && nx < H && ny >= 0 && ny < W) 
				|| s[nx][ny] != '.' 
				|| d[nx][ny] != 1000000000)
				continue;

			d[nx][ny] = d[x][y] + 1;

			q.emplace(nx, ny);
		}
	}
	if (d[H - 1][W - 1] == 1000000000)
	{
		cout << -1 << endl;
	}
	else
	{
		//スタートとゴールを除く
		cout << (c - 1) - d[H - 1][W - 1];
	}
	
	return 0;
}

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

int main() {
	long long int x, y, i = 0;
	cin >> x >> y;
	if (x%y == 0)cout << -1;
	else {
		while (1) {
			i += x;
			if (i%y != 0) {
				cout << i;
				break;
			}
		}
	}
	return 0;
}

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

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

    int ar[n+1];
    for(int i=0;i<n;i++)
    cin>>ar[i];


    int ans=0;

    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=ar[i]*ar[j];
        }
    }

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

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

int main(void){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0;i < H;i++){
			for( int j = 0;j < W;j++){
				if(i == 0 || i == H-1){
						cout << "#";
				}else if(j == 0 || j == W-1){
						cout << "#";
				}else{
						cout << ".";
				}
			}
		cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
n = int(input())
dis = [[0] * 205 for _i in range(205)]
for i in range(1, n + 1):
    dis[i][i] = 0
for i in range(1, n + 1):
    a = list(map(str, input().strip()))
    for j in range(n):
        if a[j] == '1':
            dis[i][j + 1] = 1


def bfs(x):
    mx = 0
    from collections import deque
    q = deque()
    l = [0] * 205
    q.append(x)
    l[x] = 1
    while len(q):
        x = q.popleft()
        mx = max(mx, l[x])
        for i in range(1, n + 1):
            if dis[x][i]:
                if l[i]:
                    if abs(l[i]-l[x]) == 1:
                        continue
                    else:
                        print(-1)
                        exit(0)
                else:
                    l[i] = l[x] + 1
                    q.append(i)
    return mx


ans = [0] * 205
for i in range(1, n + 1):
    ans[i] = bfs(i)

mark = [0] * 205
p = 0


def dfs(x):
    mark[x] = 1
    global p
    p = max(p, ans[x])
    for i in range(1, n + 1):
        if dis[x][i] and not mark[i]:
            dfs(i)


aas = 0
for i in range(1, n + 1):
    if not mark[i]:
        p = 0
        dfs(i)
        aas += p
print(aas)


Measured memory_bytes: 43884
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  string s; cin >>s;
  int n=s.size();
  rep(i,n-1){
    if(s[i]==s[i+1]){
      print(i+1," ",i+2);
      return 0;
    }
  }
  rep(i,n-2){
    if(s[i]==s[i+2]){
      print(i+1," ",i+3);
      return 0;
    }
  }
  print("-1 -1");
}


Measured memory_bytes: 512
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    b.at(i)=a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(b.at(i)<a.at(n/2)){
      cout <<a.at(n/2)<<endl;
    }
    else if(b.at(i)>=a.at(n/2)){
      cout <<a.at(n/2-1)<<endl;
    }
  }
}

Measured memory_bytes: 4852
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	string s;
	cin >> s;
	int i;
	cin >> i;
	for (int q = 0; q < s.length(); q += i) {
		cout << s[q];
	}
	cout << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  int i = 0;
  const int slen = s.size();
  const int tlen = t.size();
  bool f = false;
  while (i < tlen) {
    if (i == slen) {
      f = true;
      break;
    } else {
      if (s[i] == t[i]) {
        i+=1;
      } else if (s[i] < t[i]) {
        f = true;
        break;
      } else {
        break;
      }
    }
  }
  cout << (f ? "Yes" : "No") << endl;
  return 0;
}


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

typedef unsigned long long ull;
using namespace std;

int a[35][35];

int main() {
	int n;
	cin >> n;
	
	string s;
	ull m = 0, a = 0, r = 0, c = 0, h = 0;
	
	for(int i=0; i < n; i++) {
		cin >> s;
		
		if(s[0] == 'M')
			m++;
		if(s[0] == 'A')
			a++;
		if(s[0] == 'R')
			r++;
		if(s[0] == 'C')
			c++;
		if(s[0] == 'H')
			h++;
	}
	
	cout << m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
	
	
	return 0;
}
//cnt += a[i-1][j-1] + a[i-1][j] + a[i-1][j+1] + a[i][j+1] + a[i+1][j+1] + a[i+1][j] + a[i+1][j-1] + a[i][j-1];

Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

fn main() {
    input! {
        n: usize,
        l: usize,
        s: [String;n],
    }

    let mut s = s;
    s.sort();

    let mut ans = String::new();

    for e in s {
        ans += &e;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;


int main() 
{
    int n, R[MAX];
    cin >> n;
    
    for (int i = 0; i < n; i++) cin >> R[i];
    
    int minv = R[0];
    int maxv = -2000000000;
    
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3880
def qqq(n):

    a = int(n/100)
    if a == 7: 
        return "Yes" 
    
    n %= 100
    b = int(n/10)
    if b == 7:
        return "Yes"
    
    n %= 10
    if n == 7:
        return "Yes"

    return "No"

if __name__ == '__main__':
    N = int(raw_input())
    print qqq(N)

Measured memory_bytes: 64084
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#define INF 100005

using namespace std;
int F[INF][2];
char str[INF];
int X[3]={ 3, 1, 2};
int getnum(char c0, char c1)
{
	return X[(c0-48)%3]<=X[(c1-48)%3];
}
int main()
{
	//freopen("1.txt", "r", stdin);
	int n, m, i, j;

	while (scanf("%s", str))
	{
		if (str[0]=='#') break;
		memset(F, 0x0f, sizeof(F));
		F[1][1]=F[1][0]=0;
		int len=strlen(str);
		for (i=2; i<=len; i++)
		{
			F[i][0]=min(F[i][0], F[i-1][0]+1);
			if (getnum(str[i-1], str[i-2]))
				F[i][0]=min(F[i][0], F[i-1][1]);
			F[i][1]=min(F[i][1], F[i-1][1]+1);
			if (getnum(str[i-2], str[i-1]))
				F[i][1]=min(F[i][1], F[i-1][0]);
		}
		int ans=min(F[len][0], F[len][1]);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

struct Time {
    ll h, m;
    Time(ll h, ll m) : h(h), m(m) {}

    ll diff(const Time& other){
        return 60 * (other.h - h) + (other.m - m);
    }

    bool operator<(const Time& other){
        if(h != other.h){
            return h < other.h;
        }else{
            return m < other.m;
        }
    }

    void inc(){
        m++;
        if(m >= 60){
            h++;
            if(h >= 24){
                h %= 24;
            }
            m %= 60;
        }
    }
};

int main(){
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    Time t1(h1, m1), t2(h2, m2);
    ll ans = 0;
    for(; t1 < t2; t1.inc()){
        if(t1.diff(t2) > k){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 114514
#define MAX_Q 214514
#define fi first
#define sc second
#define pb push_back
typedef pair<int,int> P;
typedef pair<P,int> Pi;
int N,Q,M;
vector<P>G[MAX_N];
int R[MAX_Q];
int S[MAX_N];
int S2[MAX_N];
int cou[MAX_Q];
int main()
{
    clock_t start=clock();clock_t end;
    scanf("%d%d%d",&N,&M,&Q);
    for(int i=0;i<M;i++){
        int A,B;
        scanf("%d%d",&A,&B);A--;B--;
        G[A].pb(P(B,i+1));G[B].pb(P(A,i+1));
    }
    for(int i=0;i<Q;i++){
        int X;scanf("%d",&X);
        R[X]=i+1;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<(int)G[i].size();j++){
            G[i][j].sc=M+1-R[G[i][j].sc];
            if(G[i][j].sc==M+1){G[i][j].sc=0;}
        }
    }
    //end=clock();
    /*
    if((end-start)/(CLOCKS_PER_SEC)>(double)1.0){
        return 0;
    }
    */
    for(int i=0;i<N;i++){
        S[i]=N+1;
        S2[i]=M+2;
    }
    priority_queue<P,vector<P>,greater<P> >que;
    que.push(P(0,0));
    while(!que.empty()){
        P p=que.top();que.pop();
        if(S[p.sc]<=p.fi){continue;}
        S[p.sc]=p.fi;
        for(int i=0;i<(int)G[p.sc].size();i++){
            if(S[G[p.sc][i].fi]>p.fi+1){
                que.push(P(p.fi+1,G[p.sc][i].fi));
            }
        }
    }
    priority_queue<Pi,vector<Pi>,greater<Pi> >que2;
    que2.push(Pi(P(0,0),0));
    while(!que2.empty()){
        Pi p=que2.top();que2.pop();
        //printf("%d %d %d\n",p.fi.fi,p.fi.sc,p.sc);
        if(S[p.sc]<p.fi.fi){continue;}
        if(S2[p.sc]<=p.fi.sc){continue;}
        S2[p.sc]=p.fi.sc;
        for(int i=0;i<(int)G[p.sc].size();i++){
            if(S[G[p.sc][i].fi]==p.fi.fi+1){
                que2.push(Pi(P(p.fi.fi+1,max(p.fi.sc,G[p.sc][i].sc)),G[p.sc][i].fi));
            }
        }
    }
    /*
    for(int i=0;i<N;i++){
        printf("%d %d\n",S[i],S2[i]);
    }*/
     
    for(int i=0;i<N;i++){
        //if(S2[i]==-1){continue;}
        cou[M+1-S2[i]]++;
    }
    int ans=0;
    for(int i=1;i<=Q;i++){
        ans+=cou[i];
        printf("%d\n",ans);
    }
    return 0;
}

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

int mod = 1000000007;

int main()
{
    int N, K, p, q;
    cin >> N >> K;
    int count = 0;
    vector<bool> list(N, true);

    for (int i = 0; i < K; i++)
    {
        cin >> p;
        for (int j = 0; j < p; j++)
        {
            cin >> q;
            list[q - 1] = false;
        }
    }

    for (int i = 0; i < N; i++)
    if(list[i])
        count++;

    cout << count;
}

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

int main() {
	ll n;
	cin >> n;
	ll tmp = n;
	int res = 0;
	while (tmp > 0) {
		res += tmp % 10;
		tmp /= 10;
	}
	if (n % res == 0)puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = scanner.nextLong();
        long min = Long.MAX_VALUE, ans = 0, add = 0;
        for (long i : a)
            min = Math.min(i, min);
        for (int i = 0; i < n; i++) {
            long times = (a[i] - min) / (n + 1);
            add += times;
            ans += times;
            a[i] -= times * (n + 1);
        }
        for (int i = 0; i < n; i++)
            a[i] += add;
        min += add;
        long circles = min - n;
        if (circles > 0) {
            ans += circles * n;
            for (int i = 0; i < n; i++)
                a[i] -= circles;
        }
        while (true) {
            long max = 0;
            int maxId = 0;
            for (int i = 0; i < n; i++) if (a[i] > max) {
                max = a[i];
                maxId = i;
            }
            if (max < n) {
                System.out.println(ans);
                break;
            }
            for (int i = 0; i < n; i++) if (i != maxId)
                a[i]++;
            a[maxId] -= n;
            ans++;
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
int main() {
  int A, B, N;
  cin >> A >> B >> N;
  if(B - A + 1 <= 2 * N) {
    rep2(i, A, B) {
      cout << i << endl;
    }
  }
  else {
    rep2(i, A, A+N-1) {
      cout << i << endl;
    }
    rep2(i, B-N+1, B) {
      cout << i << endl;
    }
  }
}

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

typedef vector<ll> vec;
typedef vector<vec> mat;
const ll M = 1000000007;

mat mul(mat &A, mat &B){
	mat C(A.size(),vec(B[0].size()));
	for(ll i=0;i<A.size();i++){
		for(ll k=0;k<B.size();k++){
			for(ll j=0;j<B[0].size();j++){
				C[i][j]=(C[i][j]+A[i][k]*B[k][j])%M;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n){
	mat B(A.size(),vec(A.size()));
	for(ll i=0;i<A.size();i++){
		B[i][i]=1;
	}
	while(n>0){
		if(n&1)B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}

ll fib(ll n){
	mat A(2,vec(2));
	A[0][0]=1;A[0][1]=1;
	A[1][0]=1;A[1][1]=0;
	A=pow(A,n);
	return A[1][0];
}

ll cnt(ll x){
	if(x<2)return 0;
	return (1+(x/2)*(x%2)+(x/2)*(x/2-1));
}

void solve(ll K,ll *a,ll*b){
	
	ll ng=10000000000,ok=2;
	while(ng-ok-1){
		ll mid=(ng+ok)/2;
		if(K<cnt(mid))ng=mid;
		else ok=mid;
	}
	ll p = cnt(ok),l=ok/2,d=K-p;
	if(l%2){
		if(d<=l/2){
			*a=ok-2*d;
			*b=2+2*d;
		}
		else{
			*a=ok-l+2*(d-l/2);
			*b=2+l-2*(d-l/2);
		}
	}
	else{
		if(d<l/2){
			*a=ok-2*d;
			*b=2+2*d;
		}
		else{
			*a=ok-l+1+2*(d-l/2);
			*b=2+l-1-2*(d-l/2);
		}
	}
}

int main(){
	
	ll K,a,b;
	cin>>K;
	solve(K,&a,&b);
	cout<<fib(a)*fib(b)%M<<endl;
	
	return 0;
}


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

//https://atcoder.jp/contests/abc055/tasks/arc069_b

//	ss	sw	ws	ww
//o	s	w	w	s
//x	w	s	s	w

//	00	01	10	11
//0	0	1	1	0
//1	1	0	0	1

int n;
string s;
bool c[100000];

int main() {
	cin >> n >> s;
	for (int a = 0; a < 2; ++a)
		for (int b = 0; b < 2; ++b) {
			c[0] = a;
			c[1] = b;
			for (int i = 2; i < n; ++i)
				c[i] = c[i - 2] ^ c[i - 1] ^ (s[i - 1] == 'x');
			if ((c[n - 1] ^ c[0] ^ c[1] ^ (s[0] == 'x'))
					|| (c[n - 2] ^ c[n - 1] ^ c[0] ^ (s[n - 1] == 'x')))
				continue;
			else {
				for (int i = 0; i < n; ++i)
					cout << (c[i] ? 'W' : 'S');
				cout << endl;
				return 0;
			}
		}
	cout << -1 << endl;
}


Measured memory_bytes: 3840
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]
l.sort()
ans = 0
for i in range(N):
    if M - l[i][1] > 0:
        ans += l[i][0]*l[i][1]
        M -= l[i][1]
    else:
        ans += l[i][0]*M
        break
print(ans)

Measured memory_bytes: 27756
a,b,c = gets.split.map(&:to_i)
lp = a%b
flag = true
1000000.times do |i|
  ngo = a * (i + 2) % b
  if ngo == c
    flag = true
    break
  end
  if lp == ngo

    flag = false
    break
  end
end

puts flag ? "YES" : "NO"

Measured memory_bytes: 1788
N = int(input())
A = list(map(int, input().split()))
P = [[i+1, A[i]] for i in range(N)]
P = sorted(P, key = lambda a: a[1])
R = [0 for i in range(N)]
for i in range(N):
    R[i] = P[i][0]
    
for i in range(N):
    print(R[i], end=' ')

Measured memory_bytes: 70636