akhauriyash/Code-Regression huggingface dataset:
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll k, x;
  cin >> k >> x;
  if(k*500 >= x) cout << "Yes";
  else cout << "No";
  return 0;
} //good night.

Measured memory_bytes: 256
n ,m= list(map(int,input().split()))
kagi = [[]for _ in range(m)] 
#a円　b種類開けられる
for i in range(m):
    a,b =  list(map(int,input().split()))
    X =  list(map(int,input().split()))
    bit = 0
    for x in X:
        bit |= 2**(x-1)
    kagi[i] = [a,bit]

ok = 2**n-1#全部空いたらこれ
kagi.sort(key=lambda x: x[1])
zenkai = 2**n
dp = [float('inf')]*int(zenkai+1)
dp[0] = 0
for i in range(2**n):
    if dp[i] == float('inf'):
        continue
    for j in range(m):
        s = i|kagi[j][1]
        # print(s)
        dp[s] = min(dp[s],dp[i] + kagi[j][0])
# print(dp)
if dp[zenkai-1] == float('inf'):
    print(-1)
else:
    print(dp[zenkai-1])

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

int n;
int m;
int x[200000];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) scanf ("%d", &x[i]);
	sort (x, x + n);
	int ans = 0;
	for (int h = (1 << 30); h > 0; h >>= 1) {
		for (int i = 0, j = n - 1; i < j; i++)
			if (x[i] != -1) {
				while (j > i && (x[j] == -1 || x[i] + x[j] > h)) j--;
				if (j > i && x[j] != -1 && x[i] + x[j] == h) {
					ans++;
					x[i] = x[j] = -1;
				}
			}
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef double ld;



int main()
{
   // freopen("in.txt", "r", stdin);
    ll x, y;
    cin >> x >> y;
    if (x % y == 0)
        cout << -1;
    else
        cout << x;
    return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn];

void Work(){
	if(A[1]==A[n]&&A[1]==n-1){
		puts("Yes");
		return;
	}
	if(A[1]+1<A[n]){
		puts("No");
		return;
	}
	int t=0;
	REP(i,1,n)if(A[i]!=A[n])t++;
	int l=t+1;
	int r=t+(n-t)/2;
	if(A[n]<=r&&A[n]>=l)puts("Yes");else puts("No");
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i]);
	sort(A+1,A+n+1);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 640
#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>;
using M = map<int,int>;

int main() {
    int n, k;
    cin >> n >> k;
    M mp;
    rep(i,n) {
        int ai;
        cin >> ai;
        if (mp.count(ai)) mp.at(ai)++;
        else mp[ai] = 1;
    }
    int m = mp.size();
    if (m <= k) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> a;
    for(auto mi : mp) {
        a.push_back(mi.second);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, m-k) {
        ans += a.at(i);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 13448
#include <bits/stdc++.h>
# define llt  int
using namespace std;


int main(){

    llt n;
    cin>>n;
    llt k=n;
    int c=0;
    while(n>0){
        n=n-1000;
        c++;
    }


    cout<<((c*1000)-k)<<endl;



    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  multiset<int> U;
  int Q;

  cin >> Q;
  while(Q--) {
    int com, x, y;
    cin >> com;

    switch(com) {
    case 0:
      cin >> x;
      U.insert(x);
      cout << U.size() << LF;
      break;

    case 1:
      cin >> x;
      cout << U.count(x) << endl;
      break;

    case 2:
      cin >> x;
      U.erase(x);
      break;

    default:
      cin >> x >> y;
      for (auto it = U.lower_bound(x), end=U.upper_bound(y); it != end; ++it) {
        cout << *it << LF;
      }
    }
  }

  return 0;
}




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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

ll memo[90];

ll ryuka(ll x){
	if(x==0) return 2;
	else if(x==1) return 1;
	else if(memo[x]!=INF) return memo[x];
	else return memo[x]=ryuka(x-1)+ryuka(x-2); 
}

//a,b x
int main(){
	ll N; cin>>N;
	rep(i,90) memo[i]=INF;
	cout<<ryuka(N);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double err = 1e-9;

int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;

  int multi = 1;
  if (W % 2)
    multi = 0;
  if (H % 2)
    multi = 0;
  if (W / 2 != x || H / 2 != y)
    multi = 0;
  cout << W * H / 2.0 << ' ' << multi << endl;
}

Measured memory_bytes: 256
/**
* Copyright(c)
* All rights reserved.
* Author : Universal
* Description : sample
*/
#include <bits/stdc++.h>
#define MAXN 100005
#define INF 0x3f3f3f3f
#define PI acos(-1)
using namespace std;
typedef long long ll;

ll quick(ll a,ll b){
    ll ans=1;
    a=a;
    while(b!=0){
        if(b&1) ans=(ans*a);
        b>>=1;
        a=(a*a);
    }
    return ans;
}

int main(){
    ll n,i;
    cin>>n;
    for(i=0; ;i++){
        ll p = quick(2,i);
        if(p>n)break;
    }
    cout<<quick(2,i-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
//define('DEBUG', true);
define('DEBUG', false);

if (DEBUG) {
	//$d = trim(implode('', file(__DIR__ . "/../../testcases/luggage/testcases/APC001/C/in/1_24.txt")));
	$d = trim(implode('', file(__DIR__ . "/../../testcases/luggage/testcases/APC001/C/in/1_17.txt")));
	//$d = trim(implode('', file(__DIR__ . "/../../testcases/luggage/testcases/APC001/C/in/1_08.txt")));
	$N = strlen($d);
	echo "data: {$N}\n";
	$x = [];
	$ele = ['Vacant', 'Male', 'Female'];
	for ($i = 0; $i < $N; $i++) {
		$x[$i] = $ele[$d[$i]];
		if ($d[$i] === "0") {
			echo "ZERO {$i}\n";
		}
	}
	//var_dump($x);
	//exit;
} else {
	fscanf(STDIN, "%d", $N);
}

$memo = array_pad(array(), $N + 1, null);
$q = 0;
$l = 0;
$r = $N;
$ret = interactive($l);
$memo = [$l => $ret, $l + $N => $ret];
 
while(true) {
    $m = intdiv($l + $r, 2);
    $s = interactive($m);
 
    $memo[$m] = $s;
    $left_length = $m - $l;
    $right_length = $r - $m;
 
	if (DEBUG) printf("l:%5d %s m:%5d %s Llen:%d Rlen:%d\n", $l, $memo[$l], $m, $memo[$m], $left_length, $right_length);

    $bool = false;
    if ($left_length % 2 === 0) {
        if ($memo[$l] !== $memo[$m]) {
            $r = $m;
            $bool = true;
        }
    } else if ($left_length % 2 === 1) {
        if ($memo[$l] === $memo[$m]) {
            $r = $m;
            $bool = true;
        }
    }
 
    if ($bool === false) {
        if ($right_length % 2 === 0) {
            if ($memo[$r] !== $memo[$m]) {
                $l = $m;
            }
        } else if ($right_length % 2 === 1) {
            if ($memo[$r] === $memo[$m]) {
                $l = $m;
            }
        } else {
            exit('ERR');
        }
    }
  
    $q++;
    if ($q >= 20) {
        exit();
    }
	if (DEBUG) printf("%d\n", $q);
}
 
function interactive($i) {
	if (DEBUG) {
		global $x;
	}

	if (! DEBUG) {
   		printf("%d\n", $i);
    	flush();
    	$s = fgets(STDIN);
	} else {
		$s = $x[$i];
		echo "Q {$i} {$s}\n";
	}

    if ($s === "Vacant") {
		if (DEBUG) echo "FOUND!";
        exit();
    }
    return $s;
}


Measured memory_bytes: 9292
#include <iostream>
#include <cmath>

using namespace std;

// ostream & operator<<(ostream & os, const vector<string> & v)
// {
// 	for (auto e : v)
// 		os << e << " ";
// 	return os;
// }

bool isPrime(long long n)
{
	if (n <= 1) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;

	long long limit = sqrt(n) + 1;
	for (long long i = 3; i <= limit; i += 2){
		if (n % i == 0){
			return false;
		}
	}

	return true;
}

int main()
{
	long long n;
	cin >> n;
	bool flag = isPrime(n);
	if (flag) cout << (n - 1) << endl;
	else{
		long long limit = sqrt(n) + 1;
		for (long long i = limit; i >= 2; --i){
			if (n % i == 0){
				cout << (i + n / i - 2) << endl;
                break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
-- A Point in a Triangle
main = getContents >>= putStr . solve
--
solve :: String -> String
solve = unlines . map (isIn . toTuples . map read . words) . lines


cross :: (Float, Float) -> (Float, Float) -> Float
cross a b = (fst a) * (snd b) - (snd a) * (fst b)

toTuples :: [Float] -> [(Float, Float)]
toTuples [] = []
toTuples (x1:x2:xs) = (x1,x2) : toTuples xs

sub :: (Float, Float) -> (Float, Float) -> (Float, Float)
sub a b = (fst a - fst b, snd a - snd b)

--         C(x3,y3)
--        / \
--       /   \
--      /  P  \
--     /(xp,yp)\
--    A---------B
-- (x1,y1)   (x2,y2)
--
-- AB = b - a = (abx, aby) = (x2-x1, y2-y1)
-- BC = c - b = (bcx, bcy) = (x3-x2, y3-y2)
-- CA = a - c = (cax, cay) = (x1-x3, y1-y3)
-- BP = p - b = (bpx, bpy) = (xp-x2, yp-y2)
-- CP = p - c = (cpx, cpy) = (xp-x3, yp-y3)
-- AP = p - a = (apx, apy) = (xp-x1, yp-y1)
isIn :: [(Float, Float)] -> String
isIn [a,b,c,p]
  | counterClockWise || clockWise = "YES"
  | otherwise = "NO"
    where
      counterClockWise= cross (b `sub` a) (p `sub` b) > 0 && cross (c `sub` b) (p `sub` c) > 0 && cross (a `sub` c) (p `sub` a) > 0
      clockWise = cross (b `sub` a) (p `sub` b) < 0 && cross (c `sub` b) (p `sub` c) < 0 && cross (a `sub` c) (p `sub` a) < 0

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	long long int X, Y;
	cin >> X >> Y;
	int cnt = 0;
	while (X <= Y){
		++cnt;
		X *= 2;
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3620
import heapq

n = int(input())
a = list(map(int, input().split()))

ans = -10**15
h1 = a[:n]
h2 = [-a[i] for i in range(2*n, 3*n)]
heapq.heapify(h1)
heapq.heapify(h2)

h1sum = sum(a[:n])
h2sum = sum(a[2*n:])

box1 = [h1sum]
box2 = [h2sum]

for i in range(1, n+1):
    heapq.heappush(h1, a[n+i-1])
    h1sum += a[n+i-1] - heapq.heappop(h1)
    box1.append(h1sum)

for i in range(1, n+1):
    heapq.heappush(h2, -a[2*n-i])
    h2sum += a[2*n-i] - (-heapq.heappop(h2))
    box2.append(h2sum)

for i in range(n+1):
    ans = max(ans, box1[i] - box2[n-i])

print(ans)

Measured memory_bytes: 37212
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	int N, K;
	bool NG[10] = { 0 };
	cin >> N >> K;
	rep(i, K) {
		int D;
		cin >> D;
		NG[D] = 1;
	}
	int n = N;
	while (1) {
		int m = n;
		bool OK = 1;
		while (m > 0) {
			if (NG[m % 10]) {
				OK = 0;
				break;
			}
			m /= 10;
		}
		if (OK) {
			cout << n << endl;
			break;
		}
		n++;
	}
}

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

int main()
{
  int t;
  string s;
  cin >> t;
  
  static int countAC = 0, countWA = 0, countTLE = 0, countRE = 0;
  while(t--)
  {
    cin >> s;
    if(s == "AC")
      ++countAC;
    else if(s == "WA")
      ++countWA;
    else if(s == "TLE")
      ++countTLE;
    else if(s == "RE")
      ++countRE;
  }
  
  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define sz size()
#define pb push_back
#define ve vector<int>
#define pii pair < int,int >
#define pll pair < ll,ll >
#define ll long long
#define Graph vector<vector < int > >
#define Fp cout << fixed <<  setprecision(9)
#define Fast  ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
const ll M = 1e5+10, N= 3070, MOD = 1e9+7, OO = 1e10;
ll m,n,k, x, y, dp[N][N], bla,c=1,cnt,ans,sum, a[N][4], ok=1 ;
stack <char> st;
string s[N];
int main()
{
    cin >> n >> m;
    for(int i=0;i<n;i++){


        cin >> s[i];
    }
    memset(dp , 0);
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){

            if(i>0) dp[i][j]=(dp[i][j]%MOD +  dp[i-1][j]%MOD)%MOD;
            if(j>0) dp[i][j]=(dp[i][j]%MOD +  dp[i][j-1]%MOD)%MOD;
            if(s[i][j] == '#') dp[i][j]=0;
        }


    }
    cout << dp[n-1][m-1];
    return 0;
}
/*
3 8
3 3
4 5
5 6
*/


Measured memory_bytes: 75008
def main():
    N = input()
    ans = [0]*len(N)
    right_count = 0
    left_count = 0
    for idx in range(len(N)):

        if N[idx] == 'L':
            left_count += 1
        elif N[idx] == 'R' and left_count > 0:
            # LRの切り替わりがここで起こる
            # LRの切り替わり点までに起こることは独立で精算できる
            ans[idx-left_count-1] = (right_count+1)//2 + left_count//2  # 一番右のR
            ans[idx-left_count] = right_count//2 + (left_count+1)//2  # 一番左のL
            right_count = 0
            left_count = 0
        if N[idx] == 'R':
            right_count += 1

    idx += 1
    ans[idx-left_count-1] = (right_count+1)//2 + left_count//2  # 一番右のR
    ans[idx-left_count] = right_count//2 + (left_count+1)//2  # 一番左のL
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47548
from collections import defaultdict

N = int(input())

d = defaultdict(list)
for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    d[s].append((p, i))

for s in sorted(d.keys()):
    # print(s)
    # print(d[s])
    d[s].sort(key=lambda x: x[0],reverse=True)
    for v in d[s]:
        print(v[1])


Measured memory_bytes: 3444
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 50 + 7;

string a[N], X;
int b[N], n, ans;
map < string, int > mp;

int main()
{
	speed;
	cin >> n;
	forn( i, n ) { 
		cin >> a[i] >> b[i];
		mp[ a[i] ] = i;
	}
	cin >> X;
	fore( i, mp[X] + 1, n ) ans += b[i];
	cout << ans << endl;
	time;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int gcd(int x,int y){//最大公約数
  if(y>x) swap(x,y);
  int r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}
int Lcm(int x,int y){//最小公倍数
  int t=x*y;
  return t/gcd(x,y);
}
priority_queue<int> i[300000];
priority_queue<pair<int,int> > ma;
lol a,b,c,d,g,h;
bool can(int n,int m){
  if(n<0) return false;
  if(m<0) return false;
  if(n>=a) return false;
  if(m>=b) return false;
  return true;
}
int dfs(int n,int m){
  if(n==g&&m==h) return true;
  //if(i[n][m]!=i[c][d]||!can(n,m)||ii[n][m]) return false;
  //ii[n][m]=true;
  return dfs(n+1,m)+dfs(n,m+1)+dfs(n-1,m)+dfs(n,m-1);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long e=0,f=0,j=1;
  string w,p;
  lol u[5];
  cin >>u[0]>>u[1]>>u[2];
  sort(u,u+3);
  cout <<u[2]*10+u[1]+u[0]<<'\n';
  return (0);
}


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

int main(){

    ll n;
    cin >> n;
    ll ans=0;
    set<ll> l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.insert(i);
            l.insert(n/i);
        }
    }
    for(auto it=l.begin();it!=l.end();it++){
        if(*it==1){
            continue;
        }
        if(n/(*it-1)==n%(*it-1)){
            ans+=(*it-1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
s=list(input())
K=int(input())
import copy
S=copy.deepcopy(s)
F=0
for i in range(1,len(S)):
    if S[i]!=S[i-1]:
        F=1
        break
if F==0:
    print((len(S)*K)//2)
elif K==1:
    ans=0
    for i in range(1,len(S)):
        if S[i]==S[i-1]:
            ans+=1
            S[i]="#"
    print(ans)
else:
    ans1=0
    for i in range(1,len(S)):
        if S[i]==S[i-1]:
            ans1+=1
            S[i]="#"
    ans2=0
    S2=s*2
    #print(S2)
    for i in range(1,len(S2)):
        if S2[i]==S2[i-1]:
            ans2+=1
            S2[i]="#"
    print(ans1+(ans2-ans1)*(K-1))
    #print(ans1,ans2)

Measured memory_bytes: 3444
import math
N = int(input())
xy = list(list(map(int, input().split())) for _ in range(N))
ans = 0.0
for i in range(N):
    for j in range(N):
        x = xy[i][0] - xy[j][0] 
        y = xy[i][1] - xy[j][1]
        d = math.sqrt(x**2+y**2)
        ans = ans + d
print(ans/N)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int ans = 1'000'000'000;
    REP(m,-100,101) {
        int sum = 0;
        REP(i,0,n) sum += (m - a[i]) * (m - a[i]);
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

ll N, K, M;
VLL A;

//最大公約数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a % b));
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N >> K;
	A.resize(N);
	M = 0;
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
		M = max(A[n], M);
	}
	if (K > M) {
		cout << "IMPOSSIBLE\n";
		return 0;
	}
	if (N == 1) {
		if (A[0] == K)cout << "POSSIBLE\n";
		else cout << "IMPOSSIBLE\n";
		return 0;
	}
	for (ll n = 0; n < N; n++) {
		if (A[n] == K) {
			cout << "POSSIBLE\n";
			return 0;
		}
	}
	ll G = GCD(A[0], A[1]);
	for (ll n = 2; n < N; n++) {
		G = GCD(G, A[n]);
	}
	if (K % G == 0)cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 1024
// This template belongs to Juan Carlo Vieri

/*   ____   __
    /  _/  |  |    __         __
 __|  |__  |  |   /_/        |  |
|__    __| |  |   __    ____ |  | __   ___   _  ___
   |  |    |  |  |  |  /  _/ |  |/ /  / _ \ | |/ _/
   |  |    |  |  |  | |  |_  |     \ |  __/ |   /
   |__|    |__|  |__|  \___\ |__|\__\ \___\ |__|
*/

#include <bits/stdc++.h>
using namespace std;

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast64_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void sub() {

}

void solve() {
  // intt t; cin >> t;
  // while (t--) sub();
  intt a; string s;
  cin >> a >> s;
  intt b = 0;
  rep(i, 0, (intt)s.length()){
    if(s[i] == '.')continue;
    b *= 10;
    b += (s[i] - '0');
  }
  intt hasil = a * b;
  hasil /= 10;
  hasil /= 10;
  cout << hasil << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin>>x;
    ll fivehundred,five;
    fivehundred = x/500;
    x=x%500;
    five = x/5;
    ll ans = fivehundred*1000 + five*5;
    cout<<ans;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
l=list(map(int,input().split()))
cnt=0
for i in range(n):
  l2=list(map(int,input().split()))
  s=0
  for i in range(m):
    s+=l[i]*l2[i]
  s+=c
  if s>0:
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

char t[22],s[]="CODEFESTIVAL2016";
int ans;

int main()
{
    cin>>t;
    ans =0;
    for (int i = 0; i < 16; ++i)
        if (s[i]!=t[i]) ans++;
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;

ll dp[105][100009];

int main(){
  int n;
  ll w;
  cin >> n >> w;
  vector<ll> wight(n);
  vector<ll> val(n);
  rep(i,n){
    cin >> wight[i] >> val[i];
  }
  rep(i,n+1) rep(j,100001) dp[i][j] = INF;
  dp[0][0] = 0;

  for (int i = 0;i < n;i++){
    for (int j = 0;j <= 100000;j++){
      if (j-val[i] >= 0) dp[i+1][j] = min(dp[i][j],dp[i][j-val[i]] + wight[i]); 
      else dp[i+1][j] = dp[i][j]; 
    }
  }
  ll ans = 0;
  for (int g = 0; g <= 100000;g++){
    if (dp[n][g] <= w) ans = max(ll(g),ans);
  }
  cout << ans << endl;



 
  
  return 0;
  
}


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

#define llint long long int

using namespace std;

int main(){
    int A, B, C;

    cin >> A >> B >> C;

    if(B + C - A <= 0){
        cout << 0 << endl;
    }else{
        cout << B + C - A << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int





int main()
{
    int N;
    scanf("%d",&N);

    if (N==7 || N==5 || N==3 )printf("YES");
    else printf("NO");

    return 0;
}


Measured memory_bytes: 128
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n,T;
    cin >> n >> T;
    vector<int> c(n),t(n);
    int ans = INT_MAX;
    bool ok = false;
    for (int i = 0; i < n; i++){
        cin >> c[i] >> t[i];
        if (t[i] <= T){
            ok = true;
            ans = min(ans,c[i]);
        }
    }
    if (ok){
        cout << ans << endl;
    } else {
        cout << "TLE" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <string>
#include <unordered_set>
using namespace std;
typedef long long ll;
int n,m,q;
int path[11];
int a[55], b[55], c[55], d[55];
ll res;

void check() {
    ll curr = 0;
    for(int i = 0; i < q; i ++) {
        if(path[b[i]-1] - path[a[i]-1] == c[i]) {
            curr += d[i];
        }
    }
    res = max(res, curr);
}

void dfs(int pos, int curr) {
    if(pos == n) {
        for(int i = 0; i < n; i ++){
            //cout << path[i] << " ";
        }
        //cout << endl;
        check();
        return;
    } else {
        for(int i = curr ; i <= m; i ++) {
            path[pos] = i;
            dfs(pos+1, i);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    for(int i = 0; i < q; i ++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(0, 1);
    cout << res << endl;
    return 0;
}

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


int main(){
    int flag=0;
    int ans=0;
    int i=0;
    string s,t;
    cin >>s>>t;
    int sf[26]={},tf[26]={};

    for (int i = 0; i < s.length(); i++){
        sf[(int)(s[i]-'a')]++;
        tf[(int)(t[i]-'a')]++;
    }

    sort(sf,sf+26,greater<int>());
    sort(tf,tf+26,greater<int>());

    while(1){
        if(sf[i]!=tf[i])break;
        if(i>=25){
            flag=1;
            break;
        }
        i++;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
  out << "[" << p.first << ", " << p.second << "]";
  return out;
}


int main(){
    int n;
    cin >> n;
    vector<int> rs(n);
    for(auto &r : rs){
        cin >> r;
    }

    int maxv = -2e9;
    int minv = rs[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, rs[i] - minv);
        minv = min(minv, rs[i]);
    }

    cout << maxv << endl;
    

}

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


int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i,4) {
    if(s[i] == '+') ++ans;
    else --ans;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a,b,c;
  int aa,ab;
  cin >> a >> b >> c;
  if(b > c){
    aa = c;
  }else if(b < c){
    aa = b;
  }
  int d = b+c-a;
  if(d < 0){
    ab = 0;
  }else{
    ab = d;
  }
  cout << aa << " " << ab << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e3) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b)cout << c << endl;
    else if(a==c) cout << b << endl;
    else cout << a << endl;
    return 0;
}


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

int main(){
	int mi,mx,n;
	string d;
	cin >> n;
	while(n--){
		cin >> d;
		sort(d.begin(),d.end());
		mi = atoi(d.c_str());
		reverse(d.begin(),d.end());
		mx = atoi(d.c_str());
		cout << mx-mi << endl; 
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll r, g, b;
    cin >> r >> g >> b;
    cout << (((100*r + 10*g + b) % 4 == 0) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

const int MAXN = (int)2e5 + 1;
int N;
ll A[MAXN], F[MAXN], K;

int main()
{
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
        cin >> A[i];
    for (int i = 1; i <= N; i++)
        cin >> F[i];

    sort(A + 1, A + 1 + N);
    sort(F + 1, F + 1 + N, greater<ll>());

    ll l = 0, r = (ll)1e18;
    while (l <= r)
    {
        ll k = 0;
        ll mid = (l + r) / 2;
        for (int i = 1; i <= N; i++)
            k += max(0ll, A[i] - mid / F[i]);

        if (k > K)
            l = mid + 1;
        else
            r = mid - 1;
    }

    cout << l << endl;
    // system("pause");
    
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << "\n";
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
def main():

    N = int(input())
    a_list = list(map(int, input().split()))

    MOD = 10**9 + 7

    a_lcm = a_list[0]
    for a in a_list[1:]:
        a_lcm *= a // gcd(a,a_lcm)

    res = 0
    for a in a_list:
        res += a_lcm // a
    print(res%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll H,W;
    cin>>H>>W;
    
    vector<vector<ll>> a(H,vector<ll>(W));
    vector<vector<ll>> ans(0,vector<ll>(4));
    REP(i,H){
        REP(j,W){
            cin>>a[i][j];
        }
    }
    
    REP(i,H){
        REP(j,W-1){
            if(a[i][j]%2==1){
                ans.push_back({i,j,i,j+1});
                a[i][j]--;
                a[i][j+1]++;
            }
        }
    }

    REP(i,H-1){
        ll j=W-1;
        if(a[i][j]%2==1){
            ans.push_back({i,j,i+1,j});
            a[i][j]--;
            a[i+1][j]++;
        }
    }
    cout<<ans.size()<<endl;
    for(auto v:ans){
        cout<<v[0]+1<<" "<<v[1]+1<<" "<<v[2]+1<<" "<<v[3]+1<<endl; 
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

vector<vector<int>> dp(1000005, vector<int> (2)); 
int main(){
    string s;
    cin>>s;
    s="0"+s;
    int n=s.size();
    dp[0][0]=0;
    dp[0][1]=0;
    for(int i=1;i<=n;i++){
      int d=s[n-i]-'0';
      dp[i][0]=min(dp[i-1][0]+d,dp[i-1][1]+d+1);
      if(i==1) dp[i][1]=dp[i-1][0]+10-d;
      else dp[i][1]=min(dp[i-1][0]+10-d,dp[i-1][1]+10-(d+1));
    }
    cout<<min(dp[n][0],dp[n][1])<<endl;
    return 0;
}

Measured memory_bytes: 56964
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l0=LI()
  l=copy.deepcopy(l0)

  for i in range(1,n):
    l[i]+=l[i-1]

  l=[0]+l
  n+=1
  l2=[]

  for i in range(k,n):
    l2.append(l[i]-l[i-k])

  ind=l2.index(max(l2))
  ans=0

  for i in range(ind,ind+k):
    x=l0[i]
    ans+=(((1+x)*x)/2)/x
    # print(ans)

  return ans

# main()
print(main())


Measured memory_bytes: 27156
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

vi adj[100010];
ll dp[100010];
bool visi[100010];

void dfs(int i)
{
    visi[i] = true;
    for(auto it: adj[i])
    {
        if(!visi[it])
        {
            dfs(it);
        }
        dp[i] = max(dp[i],1+dp[it]);
    }
}

void solve()
{
   ll n,m;
   cin>>n>>m;
   f(i,0,m)
   {
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
   }
   f(i,1,n+1)visi[i] = false;
   f(i,1,n+1)
   {
       if(!visi[i])dfs(i);
   }
   ll ans=0;
   f(i,1,n+1)
   {
       ans = max(ans,dp[i]);
   }
   cout<<ans<<"\n";
}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n,m; cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i,n){
        int a, b; cin >> a >> b;
        if(a > m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i = m-1; i >= 0; i--){
        for(int b : jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, T; cin >> N >> T;
  vi32 t(N); cin >> t;
  i64 ans = 0;
  int le = t[0], ri = le + T;
  reps(i, N - 1) {
    if (ri < t[i]) {
      ans += ri - le;
      le = t[i];
    }
    ri = t[i] + T;
  }
  ans += ri - le;
  cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
 
int main()
{
    IOS
   	string s;
  	cin>>s;
  map<char,ll>mp;
  for(char c:s)mp[c]++;
  if(mp.size()==2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
    return 0;
}

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


using namespace std;


typedef long long LL;
typedef pair<LL,LL> pp;

LL llabs(LL x) { return x < 0 ? -x : x; }
int main()
{
	int N;
	cin >> N;
	vector<LL> v(N);
	vector<LL> a(N);

	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (i == 0) {
			a[i] = v[i];
		}
		else {
			a[i] = a[i-1]+v[i];
		}
	}
	LL m = 1LL<<60;
	for (int i = 0; i < N-1; i++) {
		LL x = a[i], y = a[N-1]-a[i];
		m = min(m, llabs(x-y));
	}
	cout << m;
	exit(0);
}



Measured memory_bytes: 3328
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        H: i32,
        W: i32,
        h: i32,
        w: i32,
    }

    println!("{}", H * W - h * W - w * H + h * w);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  double A, B, N;
  cin >> A >> B >> N;

  if(N>=B)
    cout << floor(A*(B-1)/B) - A * floor((B-1)/B) << endl;
  else
    cout << floor(A*N/B) - A * floor(N/B) << endl;    
}


Measured memory_bytes: 3876
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[101]={},b;
	while(cin>>b){
		a[b]++;
	}
	b=0;
	for(int i=1;i<=100;i++){
		if(b<a[i])b=a[i];
	}
	for(int j=1;j<=100;j++){
		if(b==a[j])cout<<j<<endl;
	}
    return 0;
    }


Measured memory_bytes: 3024