akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9;

void print_vec(vector<int>& a,int n=-1){
	n = (n==-1 ? a.size():n);
	for(int i=0;i<n;i++)
		cout << a[i] << (i<n-1 ? " ":"\n");
}

void print_vec(vector<long long>& a,int n=-1){
	n=(n==-1 ? a.size():n);
	for(int i=0;i<n;i++)
		cout << a[i] << (i<n-1 ? " ":"\n");
}

void solve(){
	int n,k,s;
	cin>>n>>k>>s;
	vector<int> ans;
	if(s<10){
		for(int i=0;i<n;i++){
			if(i<k){
				ans.pb(s);
			}
			else
				ans.pb(s+1);
		}
	}
	else{
		for(int i=0;i<n;i++){
			if(i<k){
				ans.pb(s);
			}
			else
				ans.pb(s-1);
		}
	}

	print_vec(ans);
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1912
x = int(input())

eratostenes = [True] * 10**6
for i in range(2, len(eratostenes)):
    if eratostenes[i]:
        for j in range(i * 2, len(eratostenes), i):
            eratostenes[j] = False
for i in range(x, len(eratostenes)):
    if eratostenes[i]:
        print(i)
        exit()

Measured memory_bytes: 16680
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if((b-a+1)/2<k){
        for(int j=a;j<b+1;j++){
            cout<<j<<endl;
        }
    }
    else{
        for(int i=a;i<a+k;i++){
            cout<<i<<endl;
        }
        for(int l=b-k+1;l<b+1;l++){
            cout<<l<<endl;
        }
    }
}

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

int a[200000];

vector<int> divisor(int n) {
  vector<int> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


signed main() {
  set<int> check;
  set<int> dup;
  int x, n=0;
  cin >> x;
  rep(i,x) {
    int y; cin >> y;
    if(check.count(y)) {
      dup.insert(y); 
    }
    else {
      check.insert(y);
      a[n++] = y;
    }
  }

  sort(a, a+n);

  int ans = 0;
  set<int> st;
  rep(i,n) {
    auto div = divisor(a[i]);
    if(dup.count(a[i]) == 0) {
      ans++;
      for(auto d : div) {
        if(st.count(d)) {
          ans--;
          break;
        }
      }
    }
    st.insert(a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 23068
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    string a;
    cin>>a;
    int ctr[1010101]={0};
    for(int i=0;i<a.size();i++)
    {
        if(i>0)
            ctr[i] =ctr[i-1];
        if(a[i]=='#')
            ctr[i]++;
    }
    int ans = n-(ctr[n-1]);
    for(int i=0;i<a.size();i++)
    {
        int temp = (n-1-i) - (ctr[n-1]-ctr[i]);
        int temper = ctr[i];
        ans = min(ans,temp+temper);
    }
    cout<<ans;
    

    return 0;
}

Measured memory_bytes: 4500
#include "bits/stdc++.h"
using namespace std;
#define LL long long
 
int main()
{
    LL a,b,m;
    cin>>a>>b>>m;
    LL a1[a],b1[b];
    LL la=1e5,lb=1e5;
    
    for(int i=0;i<a;i++){
        cin>>a1[i];
        la=min(la,a1[i]);
    }
    
    for(int i=0;i<b;i++){
        cin>>b1[i];
        lb=min(lb,b1[i]);
    }

    vector<LL>v;
   
    v.push_back(la+lb);
    for(int i=0;i<m;i++){
        LL x,y,z,s;
        cin>>x>>y>>z;
        
        if(s>=0) s=(a1[x-1]+b1[y-1])-z;
        else s=(a1[x-1]+b1[y-1]);
        v.push_back(s);
    }
    
    LL mm=2e10;
    for(auto x:v)mm=min(mm,x);
    cout<<mm;
    return 0; 
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  string s;
  cin >> s;

  s.replace(3, 1, "8");
  pr(s);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if((a + b) % 2 != 0) a++;
  cout << (a + b) / 2 << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

int main() {
    ull A, B;
    cin >> A >> B;

    if (A == B) cout << 1 << endl;
    else {
        int n = 0;
        for (int i = 0; i < 60; i++) {
            if (((A >> i) & 1) != ((B >> i) & 1)) n = i;
        }
        // 上位ビットは無視
        A &= (1ULL << (n + 1)) - 1;
        B &= (1ULL << (n + 1)) - 1;

        ull ans = 0, t = (1ULL << n);
        // X : [A, t)
        ans += t - 1 - A + 1;
        // Y : [t, t + 2^(m+1))

        int m = -1;
        for (int i = n - 1; i >= 0; i--) {
            if ((B >> i) & 1) {
                m = i;
                break;
            }
        }

        ans += (t + (1ULL << (m + 1))) - t;

        // XY : [t + A, 2*T)
        ans += 2 * t - (t + A);

        if (t + A < t + (1ULL << (m + 1))) {
            // 重なっている
            ans -= t + (1ULL << (m + 1)) - (t + A);
        }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
    

    unordered_map <long,long> a;
    long n;
    cin >> n;
    for (long i=0;i<n;i++){
        long p;
        cin >> p;
        a[p] += 1;
    }
    long ans = 0;
    for (auto it=a.begin();it != a.end();it++){
        ans += (it -> second) -1;

    }
    if (ans % 2 == 0) {
        cout << n - ans << endl;
    }else{
        cout << n - ans - 1 << endl;
    }
}

Measured memory_bytes: 4388
n = input()
for i in range(2**3):
    sign = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):
            sign[j] = "+"

    formula = n[0] + sign[0] + n[1] + sign[1] + n[2] + sign[2] + n[3]
    if eval(formula) == 7:
        print(formula+'=7')
        break




Measured memory_bytes: 3060
using System;

class Program
{
    static void Main()
    {
        string a = Console.ReadLine();
        switch (a)
        {
            case "A":a = "T";break;
            case "T":a = "A";break;
            case "G": a = "C"; break;
            case "C": a = "G"; break;
        }
        Console.WriteLine(a);
    }
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        ans = gcd(A, ans);
    }
    cout << ans << endl;
    return 0;
}

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

string k;
long long d, mod = 1e9+7, dp[2][100010][101], ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> k >> d;
	for(int i=0; i<k[0]-'0'; ++i) ++dp[0][0][i%d];
	dp[1][0][(k[0]-'0')%d] = 1;
	for(int i=1; i<k.size(); ++i){
		for(int j=0; j<10; ++j){
			for(int l=0; l<d; ++l){
				dp[0][i][(l+j)%d] += dp[0][i-1][l];
				dp[0][i][(l+j)%d] %= mod;
				if(j < k[i]-'0'){
					dp[0][i][(l+j)%d] += dp[1][i-1][l];
					dp[0][i][(l+j)%d] %= mod;
				}else if(j == k[i]-'0' && dp[1][i-1][l] == 1){
					dp[1][i][(l+j)%d] = 1;
				}
			}
		}
	}
	ans = (dp[0][k.size()-1][0] - 1 + dp[1][k.size()-1][0]) % mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
}

Measured memory_bytes: 18816
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int ret = 0;
  for(int i=0; i<4; i++)
    if(S[i] == '+')
      ret++;
    else
      ret--;
  cout << ret << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;
  ll digit=s.size();
  ll sum;
  for(int i=0;i<(1<<(digit-1));i++){
    sum=s[0]-'0';

    for(int j=0;j<digit-1;j++){
      if(i&(1<<j)){
        sum+=s[j+1]-'0';
      }else{
        sum-=s[j+1]-'0';
      }
    }
    if(sum==7){
      cout<<s[0];
      for(int j=0;j<digit-1;j++){
        if(i&(1<<j)){
          cout<<"+";
        }else{
          cout<<"-";
        }
        cout<<s[j+1];
      }
      cout<<"=7"<<endl;

      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
st = [input() for _ in range(n)]
d = defaultdict(int)
p = []
max = 0

for s in st:
  d[s] += 1
  if max < d[s]:
    max = d[s]
  
for key in d.keys():
  if d[key] == max:
    p.append(key)
p=sorted(p)
for pi in p:
  print(pi)

Measured memory_bytes: 35564
#include <iostream>

using namespace std;

int main()
{
    int N, i, j, k, nn = 0;
    int *L;
    cin >> N;
    L = new int[N];
    for (i = 0; i < N; i++)
    {
        cin >> L[i];
    }

    for (i = 0; i < N; i++)
    {
        for (j = i + 1; j < N; j++)
        {
            for (k = j + 1; k < N; k++)
            {
                if (L[i] < L[j] + L[k] &&
                    L[j] < L[i] + L[k] &&
                    L[k] < L[i] + L[j])
                {
                    nn += 1;
                }
            }
        }
    }
    cout << nn << endl;
    return 0;
}

Measured memory_bytes: 888
# coding: utf-8


def solve(*args: str) -> str:
    n, m, k = map(int, args[0].split())
    mod = 998244353

    if m == 1 and n-1 == k:
        return str(1)

    ncr = 1
    p = m*pow(m-1, n-1, mod) % mod

    ret = p
    iR = [1]*(k+1)
    im = pow(m-1, mod-2, mod)

    for i in range(1, k+1):
        iR[i] = max(1, (-(mod//i) * iR[mod % i]) % mod)
        ncr = (ncr * (n-i)*iR[i]) % mod
        p = (p*im) % mod
        ret += p*ncr % mod

    return str(ret % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 16648
from fractions import gcd
A, B, C, D = map(int, input().split())
E = C*D//gcd(C, D)
X = B - B//C - B//D + B//E
Y = A-1 - (A-1)//C - (A-1)//D + (A-1)//E
print(X-Y)


Measured memory_bytes: 5048
#include<stdio.h>
int main()
{
    int N,temp,i,j,k,count=0,a,b;
    scanf("%d",&N);
    int p[N];
    for(i=1; i<=N; i++)
    {
        scanf("%d",&p[i]);
    }
    for(i=1; i<=N; i++)
    {
        if(p[i]!=i)
        {
            a=p[i];
            break;
        }
    }
        for(j=i+1; j<=N; j++)
        {
            if(p[j]!=j)
            {
                b=p[j];
                break;
            }
        }

                temp=p[i];
                p[i]=p[j];
                p[j]=temp;

    for(k=1; k<=N; k++)
    {
        if(p[k]==k)
        {
            count++;
        }

    }
    if(count==N)
    {
        printf("YES");
    }
    else
        printf("NO");
    return 0;
}



Measured memory_bytes: 1684
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    const int N=6005;
    vector<string>a;
    bool vis[3][N];
    vector<int>v;
    void solve(int x,int y,int p)
    {
        for(int i=0;i<a[x].size();i++)
            for(int j=0;j<a[y].size()&&i+j<a[x].size();j++)
            {
                if(a[x][i+j]=='?'||a[y][j]=='?') continue;
                if(a[x][i+j]!=a[y][j])
                {
                    vis[p][i]=false;break;
                }
            }
    }
    int solve()
    {
        int x=v[0],y=v[1],z=v[2];
        memset(vis,true,sizeof(vis));
        solve(x,y,0);
        solve(x,z,1);
        solve(y,z,2);
        int ans=6000;
        for(int i=0;i<=6000;i++)
        {
            if(!vis[0][i]) continue;
            for(int j=0;i+j<=6000;j++)
            {
                if(!vis[2][j]||!vis[1][i+j]) continue;
                int res=a[x].size();
                res=max(res,(int)a[y].size()+i);
                res=max(res,(int)a[z].size()+i+j);
                ans=min(ans,res);
            }
        }
        return ans;
    }
    int main()
    {
        for(int i=0;i<3;i++)
        {
            string s;cin>>s;
            a.push_back(s);
        }
        int ans=a[0].size()+a[1].size()+a[2].size();
        v.push_back(0);v.push_back(1);v.push_back(2);
        while(true)
        {
            ans=min(ans,solve());
            if(!next_permutation(v.begin(),v.end())) break;
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 384
n = int(input())
a4 = [4*i for i in range(n//4+1)]
a7 = [7*i for i in range(n//7+1)]

ans = 'No'
for x in a4:
    for y in a7:
        if x+y == n:
            ans = 'Yes'
            break
print(ans)

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

#define vint vector<int> 
#define vbool vector<bool>
#define vvint vector<vector<int>>

#define rep(a, b, c) for(int (a)=(b); (a)<(c); (a)++)
#define all(a) (a).begin(), (a).end()

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";

    //for(vector<int> a : ans) cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    
}

Measured memory_bytes: 256
a=input()
l=len(a)
x=[int(a[i:i+1]) for i in range(l)]
counta=0
for i in range(l):
  if i%2==1:
    if x[i]==0:
      counta +=1
  else:
    if x[i]==1:
      counta +=1
countb=0
for i in range(l):
  if i%2==1:
    if x[i]==1:
      countb +=1
  else:
    if x[i]==0:
      countb +=1
c=int(min(counta,countb))
print(c)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

bool isok(int n) {
    for (int i = 0; i < 200; ++i) {
        if (n == i * i) return true;
    }
    return false;
}

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

    int res = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int dis = 0;
            for (int k = 0; k < d; ++k) {
                dis += (point[i][k] - point[j][k]) * (point[i][k] - point[j][k]);
            }
            if (isok(dis)) res++;
        }
    }
    cout << res << endl;
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

struct Graph{
  int n;
  vector<vector<int> > edge;
  vector<int> in_deg;
  Graph(int n_){
    n = n_;
    edge.resize(n);
    in_deg.resize(n, 0);
  }
  void adde(int at, int to){
    edge[at].push_back(to);
    in_deg[to]++;
  }
  vector<int> topological_sort(){
    stack<int> st;
    for(int i = 0; i < n; i++){
      if(in_deg[i] == 0)st.push(i);
    }
    vector<int> res;
    while(st.size()){
      int at = st.top(); st.pop();
      res.push_back(at);
      for(int j: edge[at]){
        in_deg[j]--;
        if(in_deg[j] == 0)st.push(j);
      }
    }

    return res;
  }
};

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  Graph graph(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    graph.adde(a, b);
  }
  auto v = graph.topological_sort();
  rep(i, sz(v))cout << v[i] << endl;
	return 0;
}



Measured memory_bytes: 3656
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    int ans = 0;
    for(int i = 0;i<N;i++){
        if(i % 2 == 0 && retu.at(i) % 2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,a,b,c,d,k;
    cin>>a>>b>>c>>d>>k;
    cout<<c*60+d-a*60-b-k;    

    return 0;
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
//typedef struct fac { LL n, exp; }F;
//LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 300009

void run(void) {
	int n, a[N], ans = 0;
	in("%d", &n);
	rep(i, n)in("%d", &a[i]);
	Rep(i, 0, n)Rep(j, i + 1, n)Rep(k, j + 1, n) {
		if (a[i] == a[j])continue;
		if (a[j] == a[k])continue;
		if (a[k] == a[i])continue;
		if (a[i] + a[j] <= a[k])continue;
		if (a[j] + a[k] <= a[i])continue;
		if (a[k] + a[i] <= a[j])continue;
		ans++;
	}
	printf("%d\n", ans);
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
		fflush(stdout);
	}
	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)

int main()
{
    ll N,M;
    cin >> N >> M;

    ll A[M],B[M];
    F(i,0,M) cin >> A[i] >> B[i];

    vector<ll> G[N];
    F(i,0,M){
        G[A[i]-1].push_back(B[i]-1);
        G[B[i]-1].push_back(A[i]-1);
    }

    ll S[N]={0};
    bool seen[N];
    F(i,0,N) seen[i]=false;
    queue<ll> q;
    q.push(0);
    seen[0]=true;

    while(!q.empty()){
        ll t=q.front(); q.pop();
        for(auto nv : G[t]){
            if(!seen[nv]){
                seen[nv]=true;
                S[nv]=t;
                q.push(nv);
            }
        }
    }

    bool f=true;
    F(i,0,N){
        if(!seen[i]) f=false;
    }

    if(f){
        cout << "Yes" << endl;
        F(i,1,N){
            cout << S[i]+1 << endl;
        }
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans=0;
  rep(i,n){
    int x=i+1,sum=0;
    while(x!=0){
      sum=sum+x%10;
      x/=10;
    }
    if(a<=sum && sum<=b) ans+=(i+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
import math
k = int(input())
s = 0
box = [0]*(k+1)
for l in range (1,k+1):
     for m in range (1, k+1):
          box[math.gcd(l,m)] += 1
for l in range (1,k+1):
     for n in range (1, k+1):
          s += math.gcd(l,n)*box[l]
print(s)

Measured memory_bytes: 9172
import sys

A, B, Q = map(int, sys.stdin.readline().split())
INF = 10 ** 18
S = [-INF] + [int(sys.stdin.readline()) for _ in range(A)] + [INF]
T = [-INF] + [int(sys.stdin.readline()) for _ in range(B)] + [INF]
X = [int(sys.stdin.readline()) for _ in range(Q)]


def binary_search(q, A):
    l, r = 0, len(A)
    while r-l>1:
        mid = (l + r) // 2
        if q > A[mid]:
            l = mid
        else:
            r = mid
    return A[l], A[r]


def main():
    for x in X:
        s1, s2 = binary_search(x, S)
        t1, t2 = binary_search(x, T)
        print(min(abs(s-t) + min(abs(s-x), abs(t-x)) for s in [s1, s2] for t in [t1, t2]))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 72156
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
//map <int,int> mp;
int lens,lent;
int check(string a, string b){
    int ans = 0;
    for(int i=0;i<lent;i++){
//        cout << a[i] << " " << b[i]<<" ";
        if(a[i]!=b[i])ans++;
    }
//    cout << ans << endl;
    return ans;
}
int main () {
    string s,t;
    cin >> s >> t;
     lens = s.length();
     lent = t.length();
     int ans = 0x3f3f3f3f;
    for(int i=0;lens>=i+lent;i++){
//        cout << s.substr(i,lent)<<endl;
        string temp = s.substr(i,lent);
        ans = min(ans,check(temp,t));
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    ll mi=INF;
    int cnt=0;
    ll sum=0;
    rep(i,n){
        ll a;
        cin>>a;
        if(a<0) cnt++;
        sum+=abs(a);
        mi=min(mi,abs(a));
    }

    if(cnt%2==0) cout<<sum<<endl;
    else cout<<sum-2*mi<<endl;

}


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


int main() {
    double n,k;
    cin>>n>>k;
    
    double a2=log(n)/log(k);
    double a1=ceil(log(n)/log(k));
    if(a1==a2){
        a1++;
    }
    cout<<a1;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
    for(T &in : v)
        is >> in;
    return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++)
        os << (i ? " " : "") << v[i];
    return os;
}
/*-------------------------------------------*/

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;

    rep(i, x) cout << "R";
    rep(i, y) cout << "U";
    rep(i, x) cout << "L";
    rep(i, y + 1) cout << "D";

    rep(i, x + 1) cout << "R";
    rep(i, y + 1) cout << "U";

    cout << "LU";
    rep(i, x + 1) cout << "L";
    rep(i, y + 1) cout << "D";
    cout << "R\n";

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a*b % 2 == 1 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
def main():
    import sys
    input=sys.stdin.readline
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    visited=[0]*n
    now=0
    visited[0]=1
    route=[0]
    while True:
        next=A[now]-1
        if visited[next]==1:
            break
        else:
            visited[next]=1
            now=next
            route.append(now)
    i=0
    while True:
        if route[i]==next:
            break
        else:
            i+=1
    loop=len(route)-i
    if k<=i:
        print(route[k]+1)
    else:
        k=(k-i)%loop
        print(route[i+k]+1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 31520
#include <stdio.h>

int INF = 1 << 30;

int main(void)
{
	int n,d;
	int path[200][200];
	int x,y,cost; // 飾り
	int used[200]; // 木に入ったか
	int mincost; // 最安値
	int minnum; // 安い点
	int ans;
	int minsia;

	scanf("%d", &n);
	while(n != 0){

		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				path[i][j] = INF;
			}
			used[i] = 0;
		}
		used[0] = 1;

		scanf("%d", &d);

		for(int i = 0; i < d; i++){
			scanf("%d,%d,%d", &x, &y, &cost);
			path[x][y] = cost;
			path[y][x] = cost;
		}
		ans = 0;

		for(int i = 0; i < n - 1; i++){
			mincost = INF + 1;
			for(int j = 0; j < n; j++){
				if(used[j] == 1){
					for(int k = 0; k < n; k++){
						if(path[j][k] < mincost){
							if(used[k] != 1){
								minsia = j;
								minnum = k;
								mincost = path[j][k];
							}
						}
					}
				}
			}
			ans += (mincost - 100) / 100;
			used[minnum] = 1;
		}

		printf("%d\n",ans);
		scanf("%d", &n);
	}
	return 0;
}

Measured memory_bytes: 1112
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

struct unionfind
{
    vector<int> d;

    unionfind(int n) : d(n, -1) {}

    int root(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        else
        {
            return d[x] = root(d[x]);
        }
    }

    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);

        if (x == y)
        {
            return false;
        }

        if (d[x] > d[y])
        {
            swap(x, y);
        }

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    int size(int x)
    {
        return -d[root(x)];
    }
};

int main(void)
{
    int n, m, k;
    int a, b, c, d;
    int i, j;
    vector<int> fr(100010, 0);
    vector<int> bl[100010];

    cin >> n >> m >> k;

    unionfind uf(n);

    rep(i, 0, m)
    {
        cin >> a >> b;

        a--;
        b--;

        fr[a]++;
        fr[b]++;
        uf.unite(a, b);
    }

    rep(i, 0, k)
    {
        cin >> c >> d;

        c--;
        d--;

        bl[c].push_back(d);
        bl[d].push_back(c);
    }

    rep(i, 0, n)
    {
        int ans = uf.size(i) - 1 - fr[i];

        for (auto &x : bl[i])
        {
            if (uf.same(i, x))
            {
                ans--;
            }
        }

        printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 6784
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()
 
from collections import deque
def bfs(start, H, W):
    INF = 10 ** 9
    visited = [False] * (H * W)
    q = deque([(start[0], start[1], 0)])
    max_d = 0
    while q:
        (i, j, d) = q.popleft()
        max_d = max(max_d, d)
        visited[i * W + j] = True
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0:
                    continue
                if dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if visited[(i + dy) * W + j + dx]:
                    continue
                visited[(i + dy) * W + j + dx] = True
                q.append((i + dy, j + dx, d + 1))
    return max_d
 
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        start = (i, j)
        ans = max(ans, bfs(start, H, W))
print(ans)

Measured memory_bytes: 70888
import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }
}

object Main extends App {
  import Helpers._

  val Array(n, m, q) = readIntLine
  val as = for (_ <- 0 until q) yield readIntLine

  def mycomb[T](n: Int, l: List[T]): List[List[T]] =
    n match {
      case 0 => List(List())
      case _ => for(el <- l;
                sl <- mycomb(n-1, l dropWhile { _ != el } ))
                yield el :: sl
  }
  
  def comb[T](n: Int, l: List[T]): List[List[T]] = mycomb(n, l.distinct)

  val candidate = comb(n, (1 to m).toList)

  println((for {
    x <- candidate
  } yield (for {
    a <- as
    if x(a(1) - 1) - x(a(0) - 1) == a(2)
  } yield a(3)).sum).max)
}



Measured memory_bytes: 94656
module subprogs
    implicit none
    contains
    subroutine quicksort2(n,x)
      !  implicit none
        integer,intent(in)::n
        integer,intent(inout)::x(1:n)
        integer,allocatable::ix(:),iw(:) 
        !
        ! Original
        ! http://d.hatena.ne.jp/fortran66/20120415/1334423664
        !
        integer :: i, j, kk0, kk1, k0, k1, ix0, ix1, l, nx
        double precision :: tmp
      
        allocate(ix(n),iw(n))
        ix=0
        iw=0
      
        if (n < 2) return
        ix(1) = 1
        ix(2) = n 
        nx = 2
        do while(nx.ne.0)
           l = 0
           do j = 1, nx - 1, 2
              kk0 = ix(j) 
              kk1 = ix(j + 1) 
              k0 = kk0 + 1
              k1 = kk1
              do while(k0 <= k1)
                 do ix0 = k0, k1              ! L
                    if (x(ix0) > x(kk0)) exit 
                 end do
                 do ix1 = k1, k0, -1          ! R
                    if (x(ix1) < x(kk0)) exit 
                 end do
                 if (ix0 >= ix1) exit
                 tmp = x(ix0)                 !swap
                 x(ix0) = x(ix1)
                 x(ix1) = tmp
                 k0 = ix0 + 1
                 k1 = ix1 - 1
              end do
              tmp = x(kk0)                   ! CSHIFT(x(kk0:ix1), 1)
              do i = kk0, ix1 - 1
                 x(i) = x(i + 1)
              end do
              x(ix1) = tmp
              if (kk0 < ix1 - 1) then         ! L
                 l = l + 1
                 iw(l) = kk0 
                 l = l + 1
                 iw(l) = ix1 - 1
              end if
              if (kk1 > ix0) then             ! R
                 l = l + 1
                 iw(l) = ix0
                 l = l + 1
                 iw(l) = kk1
              end if
           end do
           nx = l
           ix(1:nx) = iw(1:nx)
        end do
      
        return
      end subroutine quicksort2
  end module subprogs

program fennec_monster
use subprogs
implicit none
integer :: n,k,i
integer(8) :: Dsum 
integer,allocatable :: h(:)
Dsum = 0
read(*,*) n,k
allocate(h(n))
read(*,*) h(:)
call quicksort2(n,h)
!print*,h(:)
if (n -k > 0)then

    do i = 1 ,n-k
        Dsum = Dsum + h(i)
    end do
end if

    write(*,*) Dsum
end program fennec_monster

Measured memory_bytes: 3200
#include<stdio.h>

int N,W;

int w[101];
int v[101];

long dp[101][100001];

void selec(int);

int main(void){
    int i,j;

    scanf("%d%d",&N,&W);

    for(i=1;i<N+1;i++){
        scanf("%d%d",&w[i],&v[i]);
    }
 
    for(j=0;j<W+1;j++){
        dp[0][j]=0;
    }

    
    for(i=1;i<N+1;i++){
        selec(i);
    }

    long max=0;

    for(i=1;i<W+1;i++){
        if(max<dp[N][i]){
            max=dp[N][i];
        }
    }

    printf("%ld",max);

    return 0;
}

void selec(int i){
    int j;

    for(j=1;j<W+1;j++){
        if(j-w[i]>=0 && dp[i-1][j]<dp[i-1][j-w[i]]+v[i]){
            dp[i][j]=dp[i-1][j-w[i]]+v[i];
        }else{
            dp[i][j]=dp[i-1][j];
        }
    }
    return;
}

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

int main(){
  string s;
  cin >> s;
  if(s=="RRR"){
    cout << 3 << endl;
  }else if(s=="RRS"||s=="SRR"){
    cout << 2 << endl;
  }else if(s=="SSS"){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3624
import heapq
N,M = map(int,input().split())
work = [[] for i in range(100001)]
for i in range(N):
    A,B = map(int,input().split())
    work[A].append(B)
q = []
ans = 0
heapq.heapify(q)
for m in range(1,M+1):
    #print(work[m])

    for b in work[m]:
        heapq.heappush(q,-b)
    if len(q) != 0:
        s = heapq.heappop(q)
        #print(s)
        ans += -s
print(ans)

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

int main(){
    int A,B;
    cin >> A >> B;
    ll ans =0;
    for(int i=A;i<=B;i++){
        string stri = to_string(i);
        bool ok = true;
        for(int j=0;j<stri.size();j++){
            if(stri[j] != stri[stri.size()-1-j]){
                ok = false;
            }
        }
        if(ok){
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal
import java.math.RoundingMode

fun main(args: Array<String>) {
    val l = readLine()!!.toLong()
    val a = BigDecimal.valueOf(l).divide(BigDecimal.valueOf(3), 6, RoundingMode.HALF_UP).pow(3)
    println(a.toPlainString())
}

Measured memory_bytes: 29780
int main(a,b,f,s){while(f=scanf("%d%d",&a,&b)&&a!=0){if(s==1)puts("");for(;a<=b;a++)if((a%4==0)&&!((a%100==0)&&(a%400!=0)))f=printf("%d\n",a);if(f==1)puts("NA");s=1;}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (index*(index+1) >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(ll key, ll x) {
    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = x; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


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

    ll x;
    cin >> x;
    ll ans = binary_search(2*x, x);
    cout << ans  << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100111
#define inf 100000011
#define LOG 20
using namespace std;
vector<int> v;
int dp[MAX],dpp[MAX];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int n;
	cin>>n;
	for(int i = 0 ; i <MAX ; i++) dp[i] = inf;

	dp[1] = 1;
	v.push_back(1);
	int t = 1;
	for(int i = 1 ; i < 7 ; i++){t*=6;dp[t] = 1;v.push_back(t);}
	t = 1;
	for(int i = 1 ; i < 6 ; i++){t*=9;dp[t] = 1;v.push_back(t);}
		
	for(int j = 2; j < 50; j++){
		memset(dpp,0x1F,sizeof dpp);
		for(int i = 1 ;i < MAX ; i++){
			if(dp[i] != inf){
				for(auto x : v){
					if( i + x < MAX ){
						dpp[i + x] = min(dp[i] + 1 ,dpp[i + x]);
					}
				}
			}
		}
		for(int i = 1; i < MAX ; i++){
			dp[i] = min(dp[i],dpp[i]);
		}

	}
	cout<<dp[n];
	return 0;
}

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

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

  vector<int> A(N);
  rep(i,N) cin >> A[i];

  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i+1; j < N; j++) {
      ans = max(ans, abs(A[i]-A[j]));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
ll gcm(ll x,ll y){
  if(y==0) return x;
  else  return gcm(y,x%y);
}
ll lcm(ll x,ll y){
  return x*y/gcm(x,y);
  }
ll f(ll x,ll c,ll d){
  ll res=x;
  res-=x/c;
  res-=x/d;
  res+=x/lcm(c,d);
  return res;
}
int main()	{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=f(b,c,d)-f(a-1,c,d);
  cout<<ans<<endl;
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int A[100000];
int idx;

void cons_next(){
    if(A[idx] == 0) {
        idx++;
    }
    A[idx]--;
}

int main(){
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    REP(i,N){
        int a;
        cin >> a;
        A[i] = a;
    }

    bool up = true;
    for(int i = 0; i < H; i++){
        string ans = "";
        for(int i = 0; i < W; i++){
            cons_next();
            if(up) ans += to_string(idx+1) + " ";
            else ans = to_string(idx+1) + " " + ans;
        }
        up = !up;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
 
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (int i = 0; i < (int) s.size(); i += k) cout << s[i];
	return 0;
}  

Measured memory_bytes: 256