akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> ac(n), pe(n);
	inc(i, m) {
		int x; string s;
		cin >> x >> s;
		x--;
		if(ac[x] > 0) { continue; }
		if(s == "AC") { ac[x]++; }
		if(s == "WA") { pe[x]++; }
	}
	
	int acc = 0, pec = 0;
	inc(i, n) { if(ac[i] > 0) { acc++; pec += pe[i]; } }
	
	cout << acc << " " << pec << endl;
	
	return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>v(N); rep(i, 0, N) { cin >> v[i]; }

	bool ans = false;
	rep(i, 0, N) {
		rep(j, i, N) {
			vector<int>w(v);
			swap(w[i], w[j]);
			bool f = true;
			rep(k, 1, w.size()) {
				if (w[k - 1] > w[k])f = false;
			}
			if (f) {
				ans = true;
			}
		}

	}

	YES(ans);

	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $s);
$array = array('dream', 'dreamer', 'erase', 'eraser');

$s = strrev($s);
$array = array_map('strrev', $array);

while($s[4]){
    if(in_array(substr($s, 0, 5), $array)){
        $s = substr($s, 5);
    }elseif(in_array(substr($s, 0, 6), $array)){
        $s = substr($s, 6);
    }elseif(in_array(substr($s, 0, 7), $array)){
        $s = substr($s, 7);
    }else{
        break;
    }
}
if(strlen($s) === 0){
    print 'YES';
}else{
    print 'NO';
}

Measured memory_bytes: 4604
/*By Mohan Abhyas V*/
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);   t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

p64 hashFn(v64 vc)
{
    ll p1 = 31, p2 = 97;
    ll m1 = 1e9+9, m2 = 998244353;
    ll hsv1 = 0, hsv2 = 0, p_pow1 = 1, p_pow2 = 1;
    forn(i, vc.size())
    {
        hsv1 = ((hsv1 + vc[i] + 1) * p_pow1) % m1;
        p_pow1 = (p_pow1 * p1) % m1;

        hsv2 = ((hsv2 + vc[i] + 1) * p_pow2) % m2;
        p_pow2 = (p_pow2 * p2) % m2;
    }
    return mp(hsv1, hsv2);
}
     
void solve(){
    ll n,m;
    cin>>n>>m;
    ll out = 0;
    out += n*(n-1)/2;
    out += m*(m-1)/2;
    cout<<out<<ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    //cin>>t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

/*
1) try dp
2) meet in the middle
3) correct complexity analysis
4) randomized algorithm
5) brute force

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

const ll N = 2e5+7;
const ll MOD = 1e9+7;


int main(){
	fast;
	int n, a, b,c,d;
	
	cin>>n>>a>>b>>c>>d;
	
	string s;
	cin>>s;
	
	a--;b--;c--;d--;
	
	for(int i = a; i <max(c, d)-1; i++){
		if(s[i] == '#' && s[i+1] == '#'){
			cout<<"No\n";
			return 0;
		}
	}
	
	if(c < d){
		cout<<"Yes\n";
		return 0;
	}
	
	
	for(int i = b-1; i < d; i++){
		if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
			cout<<"Yes\n";
			return 0;
		}
	}
	
	cout<<"No\n";
	
	return 0;
}


Measured memory_bytes: 592
N=int(input())
A=[[] for i in range(N)]
Ai = []
for i in range(N):
    Ai.append(int(input()))
    for j in range(Ai[-1]):
        A[i].append(list(map(int, input().split(' '))))

ans = 0
for i in range(2**N):
    ansp= 0
    flg = True
    binstr = format(i,"b").zfill(N)
    for j in range(N):
        if binstr[j] == "1":
            ansp += 1
            for x in A[j]:
                if binstr[x[0]-1] != str(x[1]):
                    flg = False
        elif binstr[j] == 0:
            continue
    if flg:
        ans = max(ans, ansp)

print(ans)


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

int main() {
  string s;
  cin >> s ;
  if(s=="SUN"){
    cout << 7 << endl;
  }else if(s=="MON"){
    cout << 6 << endl;
  }else if(s=="TUE"){
    cout << 5 << endl;
  }else if(s=="WED"){
    cout << 4 << endl;
  }else if(s=="THU"){
    cout << 3 << endl;
  }else if(s=="FRI"){
    cout << 2 << endl;
  }else if(s=="SAT"){
    cout << 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N, A, K;
int solve(int x) {
	if (x < K) return 0;
	if (x % K == 0) return x / K;
	int t = (x % K) / (x / K + 1);
	if (1LL * t * (x / K + 1) != x % K) t++;
	return solve(x - t * (x / K + 1));
}
int main() {
	cin >> N;
	int t = 0;
	for (int i = 0; i < N; i++) {
		cin >> A >> K;
		t ^= solve(A);
	}
	cout << (t ? "Takahashi" : "Aoki") << endl;
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return


# inputs
N, M = 0, 0
A, B = [], []


def set_inputs():
    global N, M, A, B
    N, M = get_list_of_int()
    get_data(N, A=int, B=int)
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    AB = sorted(zip(A, B))
    ans = 0
    cnt = 0
    for (a, b) in AB:
        if cnt + b <= M:
            ans += a * b
            cnt += b
            continue
        while cnt < M:
            ans += a
            cnt += 1
        break
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 95832
#include <bits/stdc++.h>
using namespace std;
map<int,vector<pair<long long,long long> > > l;
long long sum(long long x)
{
	return x*(x+1)/2;
}
int main()
{
	long long n,x,d,ans=0;
	cin >> n >> x >> d;
	if (!d)
	{
		if (!x)
		cout << 1;
		else
		cout << n+1;
		return 0;
	}
	for (int i=0;i<=n;i++)
	{
		long long a=(i*x)%abs(d),cur=(i*x-a)/d;
		l[a].push_back({sum(i-1)+cur,sum(n-1)-sum(n-i-1)+cur});
	}
	for (auto v:l)
	{
		auto cur=v.second;
		sort(cur.begin(),cur.end());
		long long r=-1e18;
		for (auto p:cur)
		{
			ans+=max(p.second-max(r,p.first)+1,0LL);
			r=max(r,p.second+1);
		}
	}
	cout << ans;
}

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

using namespace std;
string op;

bool judge(int &s, int &e, int &l)
{
    int mid = (e - s) / 2 + s;
    if(mid == s)
        mid++;
    printf("%d\n", mid);
    fflush(stdout);
    cin>>op;
    if(op == "Vacant")
        return true;
    else
    {
        int m;
        if(op == "Male")
            m = 1;
        else
            m = 2;
        if((s % 2 == mid % 2 && l == m ) || (s % 2 != mid % 2 && l != m ))
        {
            s = mid;
            l = m;
        }
        else
        {
            e = mid;
        }
        return false;
    }
}

int main()
{
    int n, s, e, l;
    scanf("%d", &n);
    printf("0\n");
    fflush(stdout);
    cin>>op;
    if(op == "Vacant")
        return 0;
    else
    {
        if(op == "Male")
            l = 1;
        else
            l = 2;
        s = 0;
        e = n - 1;
        while(!judge(s, e, l));
        return 0;
    }
    return 0;
}


Measured memory_bytes: 852
/**
     **author : _KMS_
     **created : 05-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =6e5,MOD=2e9;
typedef long long ll;

int main() {
      
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll h;
   cin>>h;
   ll tot=1;
    while(tot<=h)tot*=2;
   cout<<tot-1<<endl;
   
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
  ll n;
  cin>>n;
  double sum=0;
  rep(i,0,n)
  {
  	double t;
  	string s;
 	cin>>t>>s;
  	getchar();
  //	cout<<t<<" "<<s<<endl;
  if(s=="BTC")
  sum+=(t*380000.0);
  else
  sum+=t;
  }
  printf("%.5f",sum);
}



Measured memory_bytes: 256
r = 1000000007

n, m = input().split()
n = int(n)
m = int(m)

if n==1:
	output = (m+1)%r
	print(output)
else:
	l = (m+1) // (n-1) + 1
	a = (m+1) - ((m+1) // (n-1)) * (n-1)
	e = m+1

	output = ((a+e)*l) // 2

	output = 2*output - (m+1)
	output = output % r

	print(output)

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

int main() {
  int V,B,A;
  cin>>V>>B>>A;
  B--,A--;
  vector<vector<int>> G(V);
  for(int i=0;i<V-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<int> q;
  q.push(A);
  vector<int> oya(V,-1);
  vector<int> huka(V);
  oya[A]=-2;
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:G[a]){
      if(oya[x]==-1){
        oya[x]=a;
        q.push(x);
        huka[x]=1+huka[a];
      }
    }
  }
  int Z=0;
  Z+=huka[B]/2;
  int L=(huka[B]-1)/2;
  for(int i=0;i<L;i++){
    B=oya[B];
  }
  int X=huka[B];
  q.push(B);
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:G[a]){
      if(huka[x]>huka[a]){
        q.push(x);
        X=huka[x];
      }
    }
  }
  Z+=X;
  Z-=huka[B];
  cout<<Z<<endl;
}

Measured memory_bytes: 9512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    ll n,t,a,tn,an,x;
    cin>>n>>tn>>an;
    for (int i=0;i<n-1;i++){
        cin>>t>>a;
        if(t>=tn&&a>=an){
            tn=t;
            an=a;
        }
        else{
            x=max((tn+t-1)/t,(an+a-1)/a);
            tn=t*x;
            an=a*x;
        }

        }
    cout<<tn+an<<"\n";
    }

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

const int MAX = 2100;

int main() {
    long long res = 0;
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];

    // C, S
    vector<long long> C(MAX, 0), S(MAX+1, 0);
    for (int i = 0; i < N; ++i) C[L[i]]++;
    for (int x = 0; x < MAX; ++x) S[x+1] = S[x] + C[x]; // 累積和
    
    // a と b を固定
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue; // 同じものは選ばない
            
            // c の満たすべき値の区間を [left, right) で表す
            int left = abs(L[i] - L[j]) + 1;
            int right = L[i] + L[j];

            // 累積和で個数を求める
            int count = S[right] - S[left];
            if (left <= L[i] && L[i] < right) --count;
            if (left <= L[j] && L[j] < right) --count;

            res += max(count, 0);
        }
    }
    cout << res/6 << endl;
}


Measured memory_bytes: 256
using System;
class Hoge {
  	public static void Main() {
      	var s = Console.ReadLine();
      	var ss = s.Split(' ');
		var a = int.Parse(ss[0]);
		var b = int.Parse(ss[1]);
      	if (a > 8 || b > 8) {
      		Console.WriteLine(":(");
        } else {
          	Console.WriteLine("Yay!");
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
//#include "bits:stdc++.h"
#define INF 1234567890987654321
typedef long long ll;
using namespace std;
//set <char> s;
ll a, b, k, stop, arr[1001], size;
int main()
{
//	freopen("inputfile.cpp", "r", stdin);
	cin >> a >> b >> k;
	for(ll i = a; i < min(a+k, b+1); i++)
	{
		cout << i << '\n';
		stop = i;
	}
	for(ll i = b; i > max(b-k, stop); i--)
	{
		arr[size++] = i;
	}
	sort(arr, arr+size);
	for(ll i = 0; i < size-1; i++)
	{
		cout << arr[i] << '\n';
	}
    if(size > 0)cout << arr[size-1];
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n,k;
	cin >> n>>k;
	vector<int>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	int ans = 10e10;
	rep(i, n-k+1) {
		ans = min(ans, (h[k -1+ i] - h[i]));
	}
	print(ans);
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int offset = 0; offset < 60 * (A + B); offset += (A + B)) {
    while (offset > C) {
      C += 60;
    }
    if (C <= offset + A) {
      cout << C << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3108
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val xyz = Array.fill(N)((sc.nextLong, sc.nextLong, sc.nextLong))

    Array(
      (1, 1, 1), (1, 1, -1), (1, -1, 1), (1, -1, -1),
      (-1, 1, 1), (-1, 1, -1), (-1, -1, 1), (-1, -1, -1)
    ).map { case (dx, dy, dz) =>
        xyz.map { case (x, y, z) =>
          x * dx + y * dy + z * dz
        }.sorted.reverse.take(M).sum
    }.max.toString
  }
}


Measured memory_bytes: 32848
N = int(input())


def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0
    for c in '753':
        ret += dfs(s + c)
    return ret


print(dfs('0'))


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
	long long int sum = 0;
	int n;
	scanf("%d" , &n);
	for(int i = 0 ; i <= n ; i++){
		if(i%3 == 0 && i%5 == 0){
			continue;
		}
		else if(i%3 == 0){
			continue;
		}
		else if(i%5 == 0){
			continue;
		}
		else{
			sum += i;			
		}	
	}
	printf("%lld\n" , sum);
	
	
	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    rep(i, n) {
        if(a[i] % 4 == 0) cnt4++;
        else if(a[i] % 2 == 0) cnt2++;
        else cnt1++;
    }
    if(cnt1 <= cnt4 || (cnt2 == 0 && cnt4 == cnt1 - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


int main() {

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

    int max = 0;
    int last = 0;
    int A1;
    int A2;
    cin >> A1;
    last = A1;

    for (int i = 0; i < n-1; i++) {
        cin >> A2;
        if (max< A2-A1) {
            max = A2 - A1;
        }
        A1 = A2;
    }
    if (max < k - A2 + last) {
        max = k - A2 + last;
    }

    cout << k-max << endl;
}

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++)
int main(){
  int n;cin>>n;
  map<ll,ll> mp;
  mp[0]++;vector<ll> v={0};
  ll s=0;
  rep(i,n){
    ll a;cin>>a;s+=a;
    mp[s]++;v.push_back(s);
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  ll ans=0;
  rep(i,v.size()){
    ll num=mp[v[i]];
    ans+=num*(num-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 14320
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

// #define NDEBUG
#include "atcoder/all"
using namespace atcoder;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> as(n), bs(m);
    cin >> as >> bs;
    auto cs = convolution(as, bs);
    for(auto& c : cs){
        cout << c << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 27272
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    set<pair<int, pii>> Set;
    for (int n = 0; n < N; ++n) {
        int s, t, x;
        cin >> s >> t >> x;
        Set.insert({x, {s-x, t-x}});
    }
    set<pii> D;
    for (int q = 0; q < Q; ++q) {
        int d;
        cin >> d;
        D.insert({d, q});
    }
    vector<int> Ans(Q, -1);
    for (auto s : Set) {
        int l = s.second.first;
        int r = s.second.second;
        auto it = D.lower_bound({l, -INF});
        for (; it != D.end() && it->first < r;) {
            Ans[it->second] = s.first;
            D.erase(it++);
        }
    }
    for (auto ans : Ans) {
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 24576
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;

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

  int N;
  cin >> N;

  if (N % 2 == 0) cout << N << endl;
  else cout << N * 2 << endl;

  return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000

if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000
if X == Y == 1:
    ans += 400000
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(){
	int d,x,y,wx,z;
	scanf("%d%d",&x,&y);
	if(x<y){
		wx=x;
		x=y;
		y=wx;
	}
	while(y>0){
		z=x%y;
		x=y;
		y=z;
	}
	printf("%d\n",x);
	return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N;
int u[Max], v[Max];
ll w[Max];
map<int, vector<pair<int, ll>>> tree;
vector<int> ans(Max, -1);


void dfs(int s, int color) {
    // output(s);
    if (ans[s] != -1) return;
    ans[s] = color;
    for (auto& p: tree[s]) {
        // printf("%d,%d\n", p.first, p.second);
        int col = color;
        if (p.second % 2 == 1) {
            col = (color+1)%2;
        }
        dfs(p.first, col);
    }
}

int main(int argc, const char * argv[]) {
    cin >> N;
    rep(i, N-1){
        cin >> u[i] >> v[i] >> w[i];
        tree[u[i]-1].push_back(make_pair(v[i]-1, w[i]));
        tree[v[i]-1].push_back(make_pair(u[i]-1, w[i]));
    }

    dfs(0, 0);

    rep(i, N) {
        output(ans[i]);
    }

    return 0;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(v<=w)cout << "NO" << endl;
  else{
    long long k=max(a-b,b-a);
    if(k>t*(v-w)) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;

const int A = 1000005;

 ll gcd(ll a,ll b){
     if(a<b) swap(a,b);
     bool have_mod =true;
     while(have_mod){
         ll mod = a % b;
         if(mod == 0 ) have_mod = false;
         a = b;
         b = mod;
     }
     return a;
 }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }
 
  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }
 
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
 
  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
 
  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11152
#include <iostream>
#include <cstring>
using namespace std;
int max_u,max_d,max_l,max_r;

struct square{
	int ud,lr;
};

int main(){
	square s[210];
	int a,b,n,i;
	while(cin >> n,n){
		max_u = 0;
		max_d = 0;
		max_l = 0;
		max_r = 0;
		s[0].ud = 0;
		s[0].lr = 0;

		for(i=1;i < n;i++){
			cin>>a>>b;

			memcpy(&s[i],&s[a],sizeof(square));
			if(b == 0){
				if(--s[i].lr < max_l) max_l = s[i].lr;
			}
			else if(b == 1){
				if(--s[i].ud < max_d) max_d = s[i].ud;
			}
			else if(b == 2){
		 		if(++s[i].lr > max_r) max_r = s[i].lr;
			}
			else if(++s[i].ud > max_u) max_u = s[i].ud;
		}
	cout << max_r-max_l+1 << " " << max_u-max_d+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))

# i < j
# j - i = Aj + Ai
# j - Aj = i + Ai

ans = 0
adds = dict()
for j in range(n):
    sub = j - a[j]
    if sub in adds.keys():
        ans += adds[sub]

    add = j + a[j]
    if add in adds.keys():
        adds[add] += 1
    else:
        adds[add] = 1

print(ans)


Measured memory_bytes: 40348
#include <cstdio>

int main(void){
    int a, b;
    char op;
    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') break;
        switch (op) {
            case '+':
                printf("%d\n", a + b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '/':
                printf("%d\n", a / b);
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut a:[i64;n],
    }

    for i in 0..n {
        a[i] -= (i as i64 + 1);
    }

    a.sort();
    let mut k = 0;
    if n % 2 == 0 {
        k = (a[n / 2] + a[n / 2 - 1]) / 2;
    } else {
        k = a[n / 2];
    }
    let mut ans = 0;
    for i in 0..n {
        ans += (a[i] - k).abs();
    }
    println!("{}", ans);
}
const INF: i64 = 1 << 60;


Measured memory_bytes: 6108
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
K = ir()

def count(s):
    t = s.copy()
    cur = ''
    ret = 0
    for i in range(len(t)):
        if t[i] == cur:
            t[i] = '_'
            ret += 1
        cur = t[i]
    
    return ret

one = count(S)
two = count(S + S)
diff = count(S * 3) - count(S)
if K&1:
    answer = one + (K//2) * diff
else:
    answer = two + ((K//2)-1) * diff

print(answer)
# 24

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9

//adjlist[A].first ===== コスト！

vector<int> dijk(int s, int v, vector<vector<pair<int, int> > > adjlist){
    
    priority_queue <pair<int, int> > wait;
    vector<int> result(v, INF);

    //スタート地点を追加
    result[s] = 0;
    wait.push(make_pair(0, s));

    //ダイクストラ本体
    while(!wait.empty()){    //waitが空になるまで

        int nowpoint = wait.top().second;
        int nowcost = -wait.top().first;
        wait.pop();

        if(result[nowpoint] < nowcost) continue;


        //今いる頂点と隣接しているすべての頂点をなめる
        for(int i = 0; i < adjlist[nowpoint].size(); i++){

            int nextpoint = adjlist[nowpoint][i].second;
            int nextcost = nowcost + adjlist[nowpoint][i].first;
            //現時点より安く到達できそうであれば、結果を更新して優先度付きキューに格納
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }
    
    return result;         //結果列を返す
}


int main(){

    while(1){
        int n, m, l; cin >> n >> m >> l;
        if(!n) break;
        vector<vector<pair<int, int> > > adjlist(100001);

        for(int i = 0; i < m; i++){
            int a, b, d, e; cin >> a >> b >> d >> e;
            a--;
            b--;
            //護衛を雇わないとき
            for(int j = 0; j <= l; j++){
                int A = a + j * 100;
                int B = b + j * 100;
                adjlist[A].push_back({e, B});
                adjlist[B].push_back({e, A});
                //cout << A << " " << B << " " << e << endl;            
            }

            //護衛を雇うとき
            for(int j = l; j - d >= 0; j--){
                int A = a + j * 100;
                int B = b + (j - d) * 100;
                adjlist[A].push_back({0, B});
                //cout << A << " " << B << " " << 0 << endl;                            
                A = b + j * 100;
                B = a + (j - d) * 100;
                adjlist[A].push_back({0, B});     
                //cout << A << " " << B << " " << 0 << endl;                                       
            }
        }

        vector<int> result(100001);
        result = dijk(100 * l, 100001, adjlist);
        //cout << result[G] << endl;

        /*for(int i = 0; i < 10001; i++){
            cout << i << ": " << result[i] << endl;
        }*/
        int ans = INF;
        for(int i = 0; i <= l; i++){
            //cout << n - 1 + 100 * i << " " << result[n - 1 + 100 * i] << endl;
            ans = min(ans, result[n - 1 + i * 100]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 17840
//
// Created by sanyinchen on 17/4/24.
//
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

void _print(vector<int> res) {
    for (int i = 1; i < res.size(); i++) {
        cout << res[i] << " ";
    }
    cout << endl;
}

void maxHeap(vector<int> &heap, int i) {

    int left = 2 * i;
    int right = 2 * i + 1;
    int lagest = i;
    if (left < heap.size() && left >= 1) {
        if (heap[left] > heap[lagest]) {
            lagest = left;
        }
    }

    if (right < heap.size() && right >= 1) {
        if (heap[right] > heap[lagest]) {
            lagest = right;
        }
    }

    if (lagest != i) {
        swap(heap[lagest], heap[i]);
        maxHeap(heap, lagest);
    }

}

void insertHeap(vector<int> &heap, int key) {
    //cout << "insert--" << key << endl;
    heap.push_back(key);
    int parentIndex = heap.size() - 1;
    int keyIndex = parentIndex;
    while (keyIndex > 1) {
        parentIndex /= 2;
        if (heap[parentIndex] < heap[keyIndex]) {
            swap(heap[parentIndex], heap[keyIndex]);
            keyIndex = parentIndex;
        } else {
            break;
        }
    }
}

void extractHeap(vector<int> &heap) {
    //cout << "extractHeap--";
    if (heap.size() >= 1) {
        cout << heap[1] << endl;
        swap(heap[1], heap[heap.size() - 1]);
        heap.pop_back();
        maxHeap(heap, 1);
    }
}

int main() {
    //freopen("../files/in.txt", "r", stdin);
    vector<int> heap;
    heap.push_back(-1);
    string input;
    int key;
    while (true) {

        cin >> input;
        if (input == "insert") {
            cin >> key;
            insertHeap(heap, key);
        }
        if (input == "extract") {
            extractHeap(heap);
        }
        if (input == "end") {
            break;
        }
       // _print(heap);
    }

    return 0;
}

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

int main() {
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
	return 0;
}

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

int main(){
    int N,W;
    cin >> N >> W;
    vector<int> value(N),weight(N);
    for ( int i = 0; i < N; i++ ){
        cin >> value.at(i) >> weight.at(i);
    }
    vector<vector<int>> dp(N+1, vector<int>(W+1));

    // DP漸化式
    for ( int w = 0; w <= W; w++ )
        dp.at(0).at(w) = 0;

    for( int i = 0; i < N; i++ ){

        for ( int w = 0; w <= W; w++ ){
            if ( w >= weight.at(i) ){
                dp.at(i+1).at(w) 
                = max(
                    dp.at(i).at( w - weight.at(i) ) + value.at(i), 
                    dp.at(i).at( w )
                    );
            }
            else{
                dp.at(i+1).at(w) = dp.at(i).at(w);
            }
        }
            
    }

    cout << dp.at(N).at(W) << endl;

    return 0;
}


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

class MainClass
{
    public static void Main()
    {
        for (; ; )
        {
            var inputs = Console.ReadLine().Split(' ');
            var nums = Array.ConvertAll(inputs, int.Parse);

            int h = nums[0], w = nums[1];

            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 || j == 0 || j == w - 1)
                        Console.Write('#');
                    else
                        Console.Write('.');
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8876
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    
    
   int arr[5];
   int k;
   
   for(int i=0;i<5;++i)
       cin>>arr[i];
       
       cin>>k;
       
    for(int i=0;i<4;++i){
        for(int j=i+1;j<5;++j)
         if(abs(arr[i]-arr[j])>k){
             cout<<":(";
             return 0;
         }
    } 
    
    cout<<"Yay!";
 return 0;
}

Measured memory_bytes: 256
##templete

n = gets.chomp.to_i

res = 0
list = []

for i in 1..10**6 + 1 do
  if n % i == 0
    list.push(i)
    list.push(n/i)
  end
end

list = list.uniq
for x in list do
  if x != 1 && (n / (x-1) == n % (x-1)) 
    res += x - 1
  end
end

puts res


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

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	for(auto &p : P) cin >> p;
	int cnt = 0;
	vector<bool> same(N,0);
	for(int i=0;i<N;i++) {
		if(P[i] == i+1) same[i] = true;
	}
	for(int i=0;i<N;i++) {
		if(i < N-1 and same[i] == true) {
			cnt++;
			same[i] = false;
			same[i+1] = false;
			i++;
		} else if(same[i] == false) {
			continue;
		}
	}
	if(same[N-1]) {
		same[N-1] = false;
		same[N-2] = false;
		cnt++;
	}
	cout << cnt << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define SORT(V) sort((V).begin(),(V).end())

int main(){
  long long X;
  scanf("%lld",&X);

  long long i=0;
  long long j=100;
  while(true) {
    i++;
    j = j*1.01;
    if(j>=X) {break;}
  }
  cout << i << endl;
 
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;

int mod=1e15,  temp=0;
vector<vector<int> >g(100005);
vector<int> f(100005,0), dist(100005,0), in(100005,0);


void dfs(int node){
    f[node]=1;
    for(int child:g[node]){
        dist[child]=max(dist[child], dist[node]+1);
        --in[child];
        if(in[child]==0){
            dfs(child);
        }
    }
}


int32_t main() {
    int T;
    T=1;
    //cin>>T;
    while(T--){
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            g[x].push_back(y);
            ++in[y];
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(!f[i] && in[i]==0){
                dfs(i);
            }
        }
        for(int i=1;i<=n;i++){
            ans=max(ans, dist[i]);
        }
        cout<<ans;
        cout<<'\n';
    }
	return 0;
}

Measured memory_bytes: 11136
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
#define inf 2147483647
using namespace std;
long long n;
int main ()
{


	scanf("%lld",&n);
	printf("%lld\n",n-n%500);

	return 0;
}





Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define maxn 6086

using namespace std;

int n;
int a[maxn];
int f[maxn][maxn];
int val, sum;

struct Node{
	int x, y, z;
};

vector<Node> v;

inline void Max(int &x, int y){
	x = max(x, y);
}

int main(){
	//freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for(int i = 1;i <= 3 * n;i++) scanf("%d", &a[i]);
	if(n == 1) return printf("%d", a[1] == a[2] && a[2] == a[3]), 0;
	memset(f, -0x3f, sizeof(f));
	f[min(a[1], a[2])][max(a[1], a[2])] = val = 0;
	f[0][a[1]] = f[0][a[2]] = 0;
	f[0][0] = 0;
	for(int i = 3;i < 3 * n;i += 3){
		if(a[i] == a[i + 1] && a[i + 1] == a[i + 2]){
			sum++;
			continue;
		}
		v.push_back((Node){a[i], a[i + 1], val});
		v.push_back((Node){a[i], a[i + 2], val});
		v.push_back((Node){a[i + 1], a[i + 2], val});
		v.push_back((Node){a[i], a[i + 1], f[a[i + 2]][a[i + 2]] + 1});
		v.push_back((Node){a[i], a[i + 2], f[a[i + 1]][a[i + 1]] + 1});
		v.push_back((Node){a[i + 1], a[i + 2], f[a[i]][a[i]] + 1});
		v.push_back((Node){a[i], 0, f[a[i + 2]][a[i + 2]] + 1});
		v.push_back((Node){a[i], 0, f[a[i + 1]][a[i + 1]] + 1});
		v.push_back((Node){a[i + 1], 0, f[a[i]][a[i]] + 1});
		v.push_back((Node){0, a[i + 1], f[a[i + 2]][a[i + 2]] + 1});
		v.push_back((Node){0, a[i + 2], f[a[i + 1]][a[i + 1]] + 1});
		v.push_back((Node){0, a[i + 2], f[a[i]][a[i]] + 1});
		if(a[i] == a[i + 1]){
			for(int j = 0;j <= n;j++){
				v.push_back((Node){j, a[i + 2], f[min(a[i], j)][max(a[i], j)] + 1});
				v.push_back((Node){j, 0, f[min(a[i], j)][max(a[i], j)] + 1});
			}
		}
		if(a[i + 1] == a[i + 2]){
			for(int j = 0;j <= n;j++){
				v.push_back((Node){j, a[i], f[min(a[i + 1], j)][max(a[i + 1], j)] + 1});
				v.push_back((Node){j, 0, f[min(a[i + 1], j)][max(a[i + 1], j)] + 1});
			}
		}
		if(a[i] == a[i + 2]){
			for(int j = 0;j <= n;j++){
				v.push_back((Node){j, a[i + 1], f[min(a[i], j)][max(a[i], j)] + 1});
				v.push_back((Node){j, 0, f[min(a[i], j)][max(a[i], j)] + 1});
			}
		}
		for(int j = 1;j <= n;j++){
			v.push_back((Node){a[i], j, f[0][j]});
			v.push_back((Node){a[i + 1], j, f[0][j]});
			v.push_back((Node){a[i + 2], j, f[0][j]});
		}
		v.push_back((Node){0, a[i], val});
		v.push_back((Node){0, a[i + 1], val});
		v.push_back((Node){0, a[i + 2], val});
		while(!v.empty()){
			Node b = v.back();v.pop_back();
			int x = min(b.x, b.y), y = max(b.x, b.y), z = b.z;
			Max(f[x][y], z), Max(val, z);
		}
		/*for(int i = 0;i <= n;i++){
			for(int j = i;j <= n;j++){
				printf("%d %d %d--\n", i, j, f[i][j]);
			}
		}*/
	}
	int ans = 0;
	for(int i = 0;i <= n;i++){
		for(int j = i;j <= n;j++){
			ans = max(ans, f[i][j] + (i == a[3 * n] && j == a[3 * n]));
		}
	}
	printf("%d", ans + sum);
}

Measured memory_bytes: 148692
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    pair = 0
    for i in range(n):
        if a[a[i]-1] == i + 1 and a[a[i]-1] <= a[i]:
            pair += 1
            
    print(pair)
    
    
if __name__ == "__main__":
    main()

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

int main(){
	int num;
	cin >> num;
	if(num <= 0) {
		cout << 0;
		return 0;
	}
	if(num % 2 == 0)
		num--;
	if(num < 105){
		cout << 0;
	}else if(num == 105){
		cout << 1;
	}else{
		int result = 1;
		int k;
		for(int i = 107; i <= num; i+=2){
			int count = 0;
			for(int j = 1; j <= i; j+=2){
				if(i % j == 0){
					count++;
				}
				if(count > 8){
					break;
				}
			}
			if(count == 8)result++;
		}
		cout << result;
	}
	return 0;
}


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

typedef unsigned long long ll;

int main(){
	string s;
	ll k;
	cin >> s;
	cin >> k;
	
	ll res = 0;
	
	
	bool f = true;
	for(int i=1;i<s.size();++i){
		if(s[i-1] != s[i]){
			f = false;
			break;
		}
	}
	if(f){
		res = s.size()*k/2;
	}else{
		ll a = 1;
		ll b = 1;
		int cnt = 1;
		while(s[cnt-1] == s[cnt]){
			cnt++;
			a++;
		}
		cnt = s.size()-1;
		while(s[cnt-1] == s[cnt]){
			cnt--;
			b++;
		}
		for(int i=1;i<s.size();++i){
			if(s[i-1] == s[i]){
				res++;
				s[i] = '.';
			}
		}
//		cout << res <<endl;
		res *= k;
//		cout << res <<endl;
		if(s[0] == s[s.size()-1]){
//			cout << a << " " << b << " " << (a/2 + b/2 - ((a+b))/2) << " " << res <<endl;
			res -= ((a/2) + (b/2) - ((a+b)/2)) * (k-1);
		}
	}	
	cout << res <<endl;
	return 0;
}



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

#define ll long long
#define fi first
#define se second
#define mp make_pair

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;



int main(){
	
	fastio();
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll ans = max(a*c,max(a*d,max(b*c,b*d)));
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;

int main(void) {
  int n;
  cin >> n;
  string ans;
  switch (n % 10)
  {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    ans = "hon";
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    ans = "pon";
    break;
  case 3:
    ans = "bon";
    break;
  default:
    break;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3060
import math


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

  dp = [0] * N

  lx = math.ceil(math.sqrt(N))

  for x in range(1, lx):
    x2 = x ** 2

    ly = math.ceil(math.sqrt(max(1, N - x2)))

    for y in range(1, ly):
      y2 = y ** 2
      lz = math.ceil(math.sqrt(max(1, N - x2 - y2 - (x * y))))

      for z in range(1, lz):
        z2 = z ** 2

        v = x2 + y2 + z2 + x * y + y * z + z * x
        if(v <= N):
          dp[v-1] += 1

  for v in dp:
    print(v)

if __name__ == "__main__":
  main()

Measured memory_bytes: 69404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

const ll MOD = 998244353;

int main(){
  
  ll n,k;
  cin >> n >> k;
  vector<pair<int,int>> imos(k);
  rep(i,k){
    int L,R;
    cin >> L >> R;
    imos[i] = make_pair(L,R+1);
  }
  vector<ll> dp(500000,0);
  dp[1] = 1;
  dp[2] = -1;
  rep(i,300000){
    if(i > 0) dp[i] += dp[i-1];
    dp[i] %= MOD;
    rep(j,k){
      int L = imos[j].first;
      int R = imos[j].second;
      dp[i+L] += dp[i];
      dp[i+L] %= MOD;
      dp[i+R] -= dp[i];
      dp[i+R] = (dp[i+R]+MOD)%MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 7220
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()

Measured memory_bytes: 32172