akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#define RE(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define SZ(x) ((int)(x.size()))
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using C = complex<double>;
const double PI = 3.14159265;
const double eps = 1e-8;
const int N = 1e6 +10;
const int M = 1e9 + 7;
const int inf = 1e9+7;
const ll INF = 1e18;
ll pw(ll a, ll b){ll t=1;a%=M;for(;b;b>>=1){if(b&1){t=t*a%M;}a=a*a%M;}return t;}
ll gcd(ll a, ll b){return b?gcd(b, a%b): a;}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	vector<vector<int>> a(3, vector<int>(3));
    vector<vector<bool>> b(3, vector<bool>(3));

	for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) {
            cin>>a[i][j];
            b[i][j]=false;
        }
	}
	cin>>n;
	while(n--){
        int x;cin>>x;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++) {
                if(a[i][j]==x){
                    a[i][j]=-1;
                    b[i][j]=true;
                }
            }
        }
	}
	for(int i=0;i<3;i++){
        if(b[i][0]&&b[i][1]&&b[i][2]){
            cout<<"Yes\n";
            return 0;
        }
	}
    for(int i=0;i<3;i++){
        if(b[0][i]&&b[1][i]&&b[2][i]){
            cout<<"Yes\n";
            return 0;
        }
	}

    if(b[0][0]&&b[1][1]&&b[2][2]){
        cout<<"Yes\n";
        return 0;
    }

    if(b[0][2]&&b[1][1]&&b[2][0]){
        cout<<"Yes\n";
        return 0;
    }
    cout<<"No\n";
}

/*
#ifdef DEBUG
	cout<<"I Love Co shu Nie [ https://coshunie.com/ ]"
#endif

84 97 66
79 89 11
61 59 7
5
60
11
89
7
59

*/


Measured memory_bytes: 256
long bit[2<<17],a,r,H;
n,h[2<<17],i,j;
main(n)
{
	for(scanf("%d",&n);i<n;)scanf("%d",h+i++);
	for(;~scanf("%d",&a);)
	{
		r=0;H=h[j];
		for(;H>0;H-=H&-H)r=fmax(r,bit[H]);
		H=h[j];
		for(;H<2<<17;H+=H&-H)bit[H]=fmax(bit[H],a+r);
		j++;
	}
	for(H=n;H>0;H-=H&-H)r=fmax(r,bit[H]);
	printf("%ld",r);
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
	int a,b,c,i;
	int count=0;
	
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			count++;
		}
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 596
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        i: usize, j: usize,
    }

    let mod_i = i % 2019;
    let mod_j = j % 2019;
    dbg!(&mod_i, &mod_j);
    let mut ans = 1e9 as usize;

    for a in mod_i..mod_j {
        for b in a+1..=mod_j {
            ans = std::cmp::min(ans, a * b % 2019)
        }
    }

    if mod_i == 0 || mod_j == 0 {
        ans = 0;
    } else if mod_i == mod_j {
        ans = (mod_i * mod_j) % 2019;
    }

    if j - i >= 2019 {
        ans = 0
    }

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


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

namespace Branch_on_Condition
{
    class Sorting_Three_Numbers
    {
        static void Main(string[] args)
        {
            var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(token);
            for (int i = 0; i < token.Length - 1; i++) Console.Write(token[i] + " ");
            Console.WriteLine(token.Last());
        }
    }
}

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

// A - Colorful Transceivers
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans = "No";

    if(abs(a-c)<=d){
        ans = "Yes";
    }else{
        if(abs(a-b) <= d && abs(b-c) <= d){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}




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

int main(void) {
  int N, temp;
  vector<int> V, C;
  long X, Y;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> temp;
    V.push_back(temp);
  }
  for (int i = 0; i < N; i++) {
    cin >> temp;
    C.push_back(temp);
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    temp = V[i] - C[i];
    if (temp > 0)
      sum += temp;
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Measured memory_bytes: 67724
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>

using namespace std;


int N, M;
int main() {
	cin >> N >> M;
	vector<PLL> pic(N);
	vector<ll> gk(M);

	rep(i, N) {
		int s, v;
		cin >> s >> v;
		pic[i] = PLL(v, s);
	}
	rep(i, M) {
		cin >> gk[i];
	}

	sort(pic.begin(), pic.end());
	sort(gk.begin(), gk.end());

	int ans = 0;

	int n = N - 1, m = M - 1;
	while (n >= 0 && m >= 0)
	{
		int v = pic[n].first, s = pic[n].second;
		if (s <= gk[m]) {
			ans++;
			--m;
		}
		--n;
	}

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 5196
//============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int w,h,n;
int d[100001]={};

int main() {
	cin>>w>>h>>n;
	int x,y;
	for(int i=0;i<n;++i){
		cin>>x>>y;
		d[x]=max(d[x],y);
	}
	int total=min(h-1,w-1);
	int m=0;
	for(int i=w-1;i>0;--i){
		m=max(m,d[i]);
		total=min(total,i-1+m);
	}

	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
int N,M;
int a,b;
int p[9][9] = {};
int ans;
vector<int> vec;
int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        p[a][b] = p[b][a] = 1;
    }
    
    for(int i = 1; i <= N; i++){
        vec.push_back(i);
    }
    
    int ctr = 0;
    
    do{
        int ans = 1;
        for(int i = 0; i < N-1; i++){
            ans *= p[vec.at(i)][vec.at(i+1)];
        }
        if(ans){
            ctr++;
        }
    }while(next_permutation(vec.begin()+1,vec.end()));
    
    cout << ctr << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()
 

const ll MOD = (ll)(1e9 + 7); 
const ll N = 0;

int main()
{
	FIO;
	map<int, int> m;
	for(int i=1; i<10; i++) {
		for(int j=1; j<10; j++) {
			m[i*j] = 1;
		}
	}
	int k;
	cin >> k;
	if(m[k]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;	
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int X, A, B;
  ci(X, A, B);
  int c = 0;
  wh(X - A >= c){
    c += B;
  }
  co(X - A - c + B);
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> a;
    int ary[100002] = {};
    int mx = 0;

    for(int i=0; i<N; i++)
    {
        int temp;
        cin >> temp;
        
        ary[temp-1] += 1;
        ary[temp] += 1;
        ary[temp+1] += 1;
    }

    for(int i=0; i<100002; i++)
    {
        // cout <<  i-1 << ": " << ary[i] << endl;
        if(mx < ary[i]) mx = ary[i];
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 4028
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  string s;
  cin >> s;
  if(s[s.size()-1] == 's'){
    s += "es";
  }
  else{
    s += 's';
  }
  cout << s;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t,x,a[500],tt=0;
    cin>>n;
    vector<ll> ans;
    queue<ll> pq;
    for(i=1;i<=9;i++)
    pq.push(i);
    i=0;
    while(!pq.empty()&&i<=n+10)
    {
        ans.push_back(m=pq.front());
        pq.pop();
        if(m%10>=1)
        {
            pq.push(10*m+(m%10)-1);
        }
        if(m%10>=0)
        {
            pq.push(10*m+m%10);
        }
        if(m%10!=9)
        {
            pq.push(10*m+(m%10)+1);
        }
        i++;
    }
    cout<<ans[n-1]<<endl;
    return 0;
}
    


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

int main(){
    int k,x;
    cin>>k>>x;

    for(int i=k-1;i>0;--i){
    	cout<<x-i<<" ";
    }
    cout<<x<<" ";
    for(int i=1;i<k;++i){
    	cout<<x+i<<" ";
    }
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    AD = dict()
    for a in A:
        if a in AD: AD[a] += 1
        else: AD[a] = 1

    count = 0
    for key in AD:
        if AD[key] == key: continue
        elif AD[key] > key: count += AD[key] - key
        else: count += AD[key]
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 17700
using System;
using System.Linq;
using static System.Math;
 
public class Test
{
	public static void Main()
	{
		// my code goes here
		
		var hoi = Console.ReadLine().Split().Select(nyan => int.Parse(nyan)).ToArray(); //この呪文覚えたい
		int n = hoi[0];
		int d = hoi[1];
		
		
		//ここから2次元配列を召喚
		double[,] x = new double[n,d];
		for(int  i=0; i!=n; i++){
			var gyou = Console.ReadLine().Split().Select(nyaa => double.Parse(nyaa)).ToArray();
			for(int j=0; j!=d; j++){
				x[i,j] = gyou[j];
			}
		}
		
		//入力完了、あとは計算
		
		int counter = 0;
		double distance = 0;
		double dis2zyou = 0;
		for(int k=0; k!=n; k++){
			for(int l=k+1; l<n; l++){
				for(int m=0; m!=d; m++){dis2zyou += Pow( x[k,m] - x[l,m] ,2);}
				distance = Sqrt(dis2zyou);
				if(distance - Floor(distance) == 0){counter++;} //GOOD DISTANCE!!
				distance = 0;
				dis2zyou = 0;
			}
		}
		Console.WriteLine(counter);
	}
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+7,ans=1,mul1,mul2;
int t,j,cs=0,n,a,b,i,k,x,y;
string s;

int main()
{
    cin>>n>>k;
    int zero=0;
    vector<int> pos,neg;
    for(i=0;i<n;i++){
        cin>>a;
        if(a>0) pos.pb(a);
        else if(a<0) neg.pb(-1*a);
        else zero++;
    }
    sort(neg.begin(),neg.end());
    sort(pos.begin(),pos.end());

   // for(auto it:pos) cout<<it<<" ";
    if(n-zero<k || (n==k && zero)){
        cout<<0<<endl;
        return 0;
    }
    if(pos.size()==0 && k&1){
        if(zero)
        {
            cout<<0<<endl;
            return 0;
        }
        for(i=0;i<k;i++){
            ans=(ans*neg[i])%mod;
        }
        ans=mod-ans;
        cout<<ans<<endl;
        return 0;
    }
    x=pos.size()-1,y=neg.size()-1;
    if(k==n){
         for(auto it:neg)
            ans=(ans*it)%mod;
        if(neg.size()&1) ans=mod-ans;
        for(auto it:pos)
            ans=(ans*it)%mod;

        cout<<ans<<endl;
        return 0;
    }
    
    if(k==n-zero && neg.size()&1){
        cout<<0<<endl;
        return 0;
    }
    if(k&1){
        ans=(ans*pos[x])%mod;
        x--;
        k--;
    }
   // cout<<x<<" "<<y<<endl;
    for(i=0;i<k;i+=2){
        mul1=0,mul2=0;
      //  cout<<pos[x]<<" "<<pos[x-1]<<endl;
        if(x>0){
            mul1=pos[x];
            mul1=mul1*pos[x-1];
        }
        if(y>0){
            mul2=neg[y];
            mul2=mul2*neg[y-1];
        }
        if(mul1>mul2){
            mul1=mul1%mod;
             ans=(ans*mul1)%mod;
             x-=2;
        }
        else{
            mul2=mul2%mod;
            ans=(ans*mul2)%mod;
            y-=2;
        }
        //cout<<mul1<<" "<<mul2<<endl;
    }

    cout<<ans<<endl;

}



Measured memory_bytes: 4324
x, y = map(int, input().split())

answer = 0

for a in [x, y]:
    if a == 3:
        answer += 100000
    elif a == 2:
        answer += 200000
    elif a == 1:
        answer += 300000
    else:
        pass
if x == 1 and y == 1:
    answer += 400000

print(answer)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

long long gcd(long long a, long long b){
    if (a < b) swap(a, b);
    return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b){
    return a * b / gcd(a, b);
}

//--------------------------- Solve ---------------------------//

void solve() {
    int N, X; cin >> N >> X;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        ans = gcd(ans, abs(X - x));
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a;
    array<int, 8> exsists{};
    int count = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a < 400) {
            exsists[0] = true;
        }
        else if (a < 800) {
            exsists[1] = true;
        }
        else if (a < 1200) {
            exsists[2] = true;
        }
        else if (a < 1600) {
            exsists[3] = true;
        }
        else if (a < 2000) {
            exsists[4] = true;
        }
        else if (a < 2400) {
            exsists[5] = true;
        }
        else if (a < 2800) {
            exsists[6] = true;
        }
        else if (a < 3200) {
            exsists[7] = true;
        }
        else {
            ++count;
        }
    }
    int kind = 0;
    for (auto& elem : exsists) {
        if (elem) ++kind;
    }
    if (kind == 0) cout << 1 << " " << kind + count;
    else cout << kind << " " << kind + count;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(),A.end());
  int cnt = 0;
  int now = -1;
  for(int i=0; i<N; i++){
    if(chmax(now,A[i])) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    long long ans = 0;
    for (int r = 0; r <= N; r += R) {
        for (int g = 0; g <= N - r; g += G) {
            int b = N - r - g;
            if (b%B == 0)
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
// #define PI 3.1415926535897932384626433832795
#define PI acos(-1.0)
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

bool cmp(ii a, ii b) {
	return (atan2((double)a.ss, (double)a.ff)-atan2((double)b.ss, (double)b.ff))<0;
}
int32_t main(void)
{
	IOS;
	int n; cin>>n;
	vii a;
	int ind=0;
	for(int i = 0; i < n; i++) {
		int x, y; cin>>x>>y;
		if(!x && !y) continue;
		a.pb({x,y}); ind++;
	}
	n=a.size();
	if(n==0) {
		cout<<0<<endl;
		return 0;
	}
	sort(all(a), cmp);
	int ans=0;
	for(int i = 0; i < n; i++) {
		ii tmp={0,0};
		for(int j = 1; j <= n; j++) {
			tmp={tmp.ff+a[(i+j-1)%n].ff, tmp.ss+a[(i+j-1)%n].ss};
			ans=max(ans, tmp.ff*tmp.ff+tmp.ss*tmp.ss);
		}
	}
	cout<<setprecision(40)<<sqrtl(ans)<<endl;
	time();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl
#define INF 1000000000000

int main() {
	lint V, E;
	cin >> V >> E;
	vector<vector<lint>>G(V);
	rep(i, E) {
		lint A, B;
		cin >> A >> B;
		G[A - 1].push_back(B - 1);
		G[B - 1].push_back(A - 1);
	}
	lint start = 0;//スタート位置

	vector<lint>dist(V, INF);//startからの距離を入れる配列。INF(未訪問)で初期化
	queue<lint> que;

	dist[start] = 0;
	que.push(start);

	//BFS
	while (!que.empty()) {
		lint v = que.front();
		que.pop();

		for (lint nv : G[v]) {
			if (dist[nv] != INF)continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}
	cout << "Yes" << endl;
	rep(i, V) {
		if (i != 0) {
			rep(j, G[i].size()) {
				if (dist[G[i][j]] + 1 == dist[i]) {
					cout << G[i][j] + 1 << endl;
					break;
				}
				if (j == G[i].size() - 1) {
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 12956
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod (ll)1e9+7
vector<ll> v;
//map<ll,ll> mp;

int main()
{
  ll a;
  cin>>a;
  cout<<((a)/500)*1000+(a%500)/5*5<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;
    vector<int> p(N), q(N);
    rep(i, N) {
        cin >> p[i];
    }
    rep(i, N) {
        cin >> q[i];
    }

    vector<int> t(N);
    iota(all(t), 1);

    int i = 1;
    do {
        if (t == p) P = i;
        if (t == q) Q = i;
        i++;
    } while (next_permutation(all(t)));
 
    cout << abs(P - Q) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
n,y=map(int,input().split())

for i in range(n+1):
  for j in range(n-i+1):
    k=n-i-j
    if 10000*i+5000*j+1000*k==y:
      print(i,j,k)
      sys.exit()
print('-1 -1 -1')

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  if ( N % K > abs(N%K-K) ){
    cout <<  abs(N%K-K)  << endl; 
  }
  else{
    cout << N % K << endl; 
  }
}
  


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    UnionFind uft(n);
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        uft.unite(s, t);
    }
    int q;
    cin >> q;
    while(q--) {
        int i, j;
        cin >> i >> j;
        cout << (uft.same(i, j)?"yes":"no") << endl;
    }
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const int INF = 1e9;

int main(){
    int h, w, si, sj, ti, tj;
    cin >> h >> w >> si >> sj >> ti >> tj;
    --si; --sj; --ti; --tj;
    vs maze(h);
    rep(i,h) cin >> maze[i];
    vvi dist(h, vi(w,INF));
    dist[si][sj] = 0;
    deque<P> q;
    q.emplace_back(si,sj);

    while (!q.empty()){
        int i = q.front().first, j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(k,4){
            int ni = i+di[k], nj = j+dj[k];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (maze[ni][nj] == '#') continue;
            if (dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni,nj);
        }
        for (int ei = -2; ei <= 2; ei++){
            for (int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj = j+ej;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (maze[ni][nj] == '#') continue;
                if (dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni,nj);
            }

        }
    }
    int ans = dist[ti][tj];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}


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

int main(){
    string S;cin >> S;
    for (int i=0; i<3; i++){
        if(S[i]=='1'){
            S[i]='9';
        }else{
            S[i]='1';
        }
    }
    cout << S;
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 998244353

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	int pad[n];
	int dp[n]; //min cost to land on pad i
	for(int i=0;i<n;i++)
		cin>>pad[i];
	
	dp[0]=0;
	for(int i=1;i<n;i++){
		if(i==1)	dp[i]=abs(pad[i]-pad[i-1]);
		else dp[i]=min(dp[i-2]+abs(pad[i]-pad[i-2]),dp[i-1]+abs(pad[i]-pad[i-1]));
	}
	cout<<dp[n-1]<<'\n';
	
	return 0;
}


Measured memory_bytes: 1024
function main()
	s = chomp(readline())
	k = []
	for i in 1:length(s)
		if s[i] == '1'
			push!(k,"1")
		elseif s[i] == '0'
			push!(k,"0")
		elseif length(k) > 0
			pop!(k)
		end
	end
	for i in 1:length(k)
		print(k[i])
	end
end

main()

Measured memory_bytes: 109672
#include <stdio.h>
#include <string.h>


int main() 
{
    int a,k,kbest;
    k=0;
    scanf("%d",&a);
    
    for(int i=0;i<=a;i++)
    {
        kbest=k;
        k=i+kbest;
    }
    printf("%d",k);
    
}

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

int main(){
  vector<vector<int>> A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> A.at(i).at(j);
    }
  }
  vector<vector<bool>> bingo(3,vector<bool>(3,false));
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    int B;
    cin >> B;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(A.at(j).at(k)==B){
          bingo.at(j).at(k)=true;
        }
      }
    }
  }
  for(int i=0;i<3;i++){
    if(bingo.at(i).at(0) && bingo.at(i).at(1) && bingo.at(i).at(2)){
      cout << "Yes" << endl;
      return 0;
    }
    if(bingo.at(0).at(i) && bingo.at(1).at(i) && bingo.at(2).at(i)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(bingo.at(0).at(0) && bingo.at(1).at(1) && bingo.at(2).at(2)){
      cout << "Yes" << endl;
      return 0;
  }
  if(bingo.at(2).at(0) && bingo.at(1).at(1) && bingo.at(0).at(2)){
      cout << "Yes" << endl;
      return 0;
  }
  cout << "No" << endl;
}
  

Measured memory_bytes: 3632
#include <stdio.h> 
int main(void) {
  int N, M, mas[1000], me[1000], i, sum;
  while(scanf("%d%d",&N,&M), N+M) {
    for(i = 1; i <= N; i++) {
      scanf("%d",&mas[i]);
    }
    for(i = 1; i <= M; i++ ) {
      scanf("%d",&me[i]);
    }
    sum = 1;
    for(i = 1; i <= M; i++ ) {
      sum += me[i];
      sum += mas[sum];
      if(sum <= 0) {
	sum = 1;
      }
      if(sum >= N) {
	printf("%d\n",i);
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy";
    }
    if (s == "Cloudy") {
        cout << "Rainy";
    }
    if (s == "Rainy") {
        cout << "Sunny";
    }
    return 0;
}


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

const int MOD = 1000000007;
using ll = long long;
 
int main() {
 
  int N;
  cin >> N;
  
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  ll ans = 0;
  ll temp;
  for(int i = 1; i < N; i++){
    temp += A.at(i-1);
    temp %= MOD;
    ans += A.at(i) * temp % MOD;
  }
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 4824
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int n = Integer.parseInt(br.readLine());
    long[] arr = new long[n+1];
    String[] s = br.readLine().split(" ");
    for (int i=0; i<n; i++) {
      arr[i+1] = Long.parseLong(s[i])+arr[i];
    }

    long best = 987654321987654321L;
    for (int i=2; i<n-1; i++) {
      long[] left = solve(arr, 0, i);
      long[] right = solve(arr, i, n);
      //System.out.println("i="+i);
      //System.out.println("Left: "+Arrays.toString(left));
      //System.out.println("Right: "+Arrays.toString(right));
      long diff = Math.max((long)Math.abs(Math.min(left[0],left[1])-Math.max(right[0],right[1])), (long)Math.abs(Math.max(left[0],left[1])-Math.min(right[0],right[1])));
      if ((long)Math.abs(left[1]-left[0])>diff) {
        diff = (long)Math.abs(left[1]-left[0]);
      }
      if ((long)Math.abs(right[1]-right[0])>diff) {
        diff = (long)Math.abs(right[1]-right[0]);
      }
      //System.out.println("Diff: "+diff);
      if (diff<best)
        best = diff;
    }
    System.out.println(best);
  }
  static long[] solve(long[] arr, int minIndex, int maxIndex) {
    int lo = 1;
    int hi = maxIndex;
    int best = -1;
    long bestDiff = 987654321987654321L;
    long target = arr[minIndex] + (arr[maxIndex]-arr[minIndex])/2;
    while (lo<=hi) {
      int mid = lo+(hi-lo)/2;
      if (arr[mid]<target) {
        if (target-arr[mid]<bestDiff) {
          bestDiff = target-arr[mid];
          best = mid;
        }
        lo = mid +1;
      } else {
        if (arr[mid]-target<bestDiff) {
          bestDiff = arr[mid]-target;
          best = mid;
        }
        hi = mid-1;
      }
    }
    return new long[]{arr[best]-arr[minIndex], arr[maxIndex]-arr[best]};
  }
}


Measured memory_bytes: 52664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}
/*int ans(int a, int b){
    int s = gcd(a,b);
    return a*b/s;
}*/
int main(){
    ll k;
    ll sum = 0;
    cin >> k;
    k++;
    rep(i,1,k){
        rep(j,i+1,k){
            rep(l,j+1,k){
                int fi = gcd(i,j);
                int se = gcd(fi,l);
                sum += se*6;
            }
        }
    }
    rep(i,1,k){
        rep(j,i+1,k){
            int fi = gcd(i,j);
             
            sum += fi*6;
        }
    }
    rep(i,1,k){
        sum += i;
    }
    cout << sum << endl;
    return 0;
}

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

#define N_MAX 22

using namespace std;

const int MOD = 1e9+7;

int n;

int a[N_MAX][N_MAX];

int dp[(1 << N_MAX)];

int cntp[(1 << N_MAX)];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            cin >> a[i][j];
    for(int mask = 0; mask < (1 << n); mask++)
        for(int j = 1; j <= n; j++)
            if((mask >> (j - 1)) & 1)
                cntp[mask]++;
    dp[0] = 1;
    for(int mask = 1; mask < (1 << n); mask++)
    {
        for(int j = 1; j <= n; j++)
            if(((mask >> (j - 1)) & 1) && a[cntp[mask]][j] == true)
            {
                dp[mask] += dp[mask ^ (1 << (j - 1))];
                if(dp[mask] >= MOD)
                    dp[mask] -= MOD;
            }
    }
    cout << dp[(1 << n) - 1] << "\n";
    return 0;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2;
    return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  int cnt = 0;
  vector <int> len;
  for (auto i = 0; i < S.length(); i++){
    if(S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G'){
      cnt++;
      if(i == S.length() - 1) len.push_back(cnt);
    }else{
      len.push_back(cnt);
      cnt = 0;
    }
  }
  cout << *max_element(len.begin(),len.end()) << endl;
}


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

int main()
{
   int a, b; cin >> a >> b;

   int d = a / b;
   int r = a % b;
   double f = 1.0 * a / b;

   printf("%d %d %.5f\n", d, r, f);

   return 0;
}

Measured memory_bytes: 3204
#include<iostream> 
#include<string> 
#include<vector> 
using namespace std; 
int main() {
	int a; 
	int b;  
	int max = 0; 
	int min = 1000;
	cin >> a; 
	for (int i = 0; i < a; i++)
	{
		cin >> b; 
		if (max<=b)
		{
			max = b;
		} 
		if (min>=b)
		{
			min = b;
		} 
	} 
	cout << max - min << "\n";

}

Measured memory_bytes: 256
import sys
s = input()
k = int(input())
ret = 0
t = 0
ss = []
ss.append(s[0])
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        ss[-1]+=s[i]
    else:
        ss.append(s[i])

for ss_ in ss[1:-1]:
    ret += len(ss_) // 2 * k

if len(ss) >= 3:
    if ss[0][0] != ss[-1][0]:
        ret += len(ss[0]) // 2 * k
        ret += len(ss[-1]) // 2 * k
    else:
        ret += (len(ss[-1]) + len(ss[0]))  // 2 * (k-1)
        ret += len(ss[0]) // 2
        ret += len(ss[-1]) // 2

if len(ss) == 1:
    ret += len(ss[0]) * k // 2

if len(ss) == 2:
    ret += len(ss[0]) * k // 2
    ret += len(ss[1]) * k // 2

print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<string> rotateClockwise(vector<string> g) {
    int n = g.size();
    int m = g[0].size();
    vector<string> res(m, string(n, '#'));
    rep(i, 0, n) rep(j, 0, m) res[j][n - i - 1] = g[i][j];
    return res;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
int H, W;
vector<string> B;
//---------------------------------------------------------------------------------------------------
int solve() {
	int ma = -1, mi = inf;

	rep(y, 0, H) rep(x, 0, W) if (B[y][x] == 'B') {
		chmax(ma, y + x);
		chmin(mi, y + x);
	}

	return ma - mi;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W;
	rep(y, 0, H) {
		string s; cin >> s;
		B.push_back(s);
	}

	int ans = 0;

	rep(d, 0, 4) {
		// rotate
		B = rotateClockwise(B);
		swap(H, W);

		chmax(ans, solve());
	}

	cout << ans << endl;
}
 


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    ll a[n + 1];
    ll b[n];
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;

    rep(i, n)
    {
        if (a[i] >= b[i])
        {
            ans += b[i];
        }
        else
        {
            ans += a[i];
            b[i] -= a[i];
            if (a[i + 1] >= b[i])
            {
                ans += b[i];
                a[i + 1] -= b[i];
            }
            else
            {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int X,Y,Z;
vector<pair<int,pair<int,int> > >v;
long long ans = 0;
priority_queue<int,vector<int>,greater<int> > pq;
int bestl[100005];
int bestr[100005];

 main(){
    scanf("%lld%lld%lld",&X,&Y,&Z);
    ans = 0;
    for (int x = 0; x<X+Y+Z; x++){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        ans += c;
        v.push_back({b-a,{a-c,b-c}});
    }
    sort(v.begin(),v.end());

    int temp = 0;
    for (int x = 0; x<X; x++){
        temp += v[x].second.first;
        pq.push(v[x].second.first);
    }
    bestl[X-1] = temp;
    for (int x = X; x<X+Y+Z; x++){
        temp += v[x].second.first;
        pq.push(v[x].second.first);
        temp-=pq.top();
        pq.pop();
        bestl[x] = temp;
    }
    while (!pq.empty()) pq.pop();
    temp = 0;
    for (int x = 0; x<Y; x++){
        temp += v[X+Y+Z-1-x].second.second;
        pq.push(v[X+Y+Z-1-x].second.second);
    }
    bestr[X+Y+Z-Y] = temp;
    for (int x = X+Y+Z-1-Y; x>=0; x--){
        temp += v[x].second.second;
        pq.push(v[x].second.second);
        temp-=pq.top();
        pq.pop();
        bestr[x] = temp;
    }
    int bestans = -999999999;
    for (int x = X-1; x<X+Z; x++){
        //printf("ans: %lld, bestl: %lld, bestr:%lld\n",ans,bestl[x],bestr[x+1]);
        bestans = max(bestans,ans+bestl[x]+bestr[x+1]);
    }
    printf("%lld",bestans);
}


Measured memory_bytes: 5616
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using llv = vector<ll>;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD7 = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void init(vector<T>& v, T initVal = T()){
		for(auto& e : v){
			e = initVal;
		}
	}

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T1, typename T2>
	inline vector<T1>& operator+=(vector<T1>& v1, const vector<T2>& v2){
		for(const auto& e : v2) v1.push_back(e);
		return v1;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T1, typename T2>
	void in(vector<T1>& v1, vector<T2>& v2){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i];
	}
	template<typename T1, typename T2, typename T3>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i];
	}
	template<typename T1, typename T2, typename T3, typename T4>
	void in(vector<T1>& v1, vector<T2>& v2, vector<T3>& v3, vector<T4>& v4){
		for(int i=0;i<v1.size();i++)
			cin >> v1[i] >> v2[i] >> v3[i] >> v4[i];
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	constexpr ll modPow(ll x, ll n, ll m){ // O(logn)
		if(n == 0) return 1;
		else if(n % 2 == 0) return modPow((x * x) % m, n / 2, m);
		else return x * modPow(x, n - 1, m) % m;
	}
}
using namespace atcoder;
#endif

int main(){
	cout << fixed << setprecision(15);

	string S;
	cin>>S;

	ll n=S.size();

	llv nums;
	for(ll i=0;i<n;i++) nums += (ll)(S[i]-'0');

	llv T(n);
	ll tmp=1;
	T[n-1]=nums[n-1];
	for(ll i=n-2;i>=0;i--){
		tmp=tmp*10%2019;
		T[i]=(tmp*nums[i]+T[i+1])%2019;
	}
	T+=(ll)0;

	sort(T);

	ll count=0;
	ll before=10;
	ll ans=0;
	for(ll i=0;i<n+1;i++){
		if(T[i]!=before){
			ans += count*(count-1)/2;
			count = 1;
			before = T[i];
		}
		else{
			count++;
		}
	}
	ans += count*(count-1)/2;
	cout<<ans;
}


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

using namespace std;

using ll = long long;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

ll solve(ll n, ll m, vector<ll> &nums) {
    while (nums[0] % 2 == 0) {
        for (int i = 0; i < n; i++) {
            if (nums[i] % 2 != 0) return 0;
            nums[i] /= 2;
        }
        m /= 2;
    }
    for (int i = 0; i < n; i++) if (nums[i] % 2 == 0) return 0;

    ll lcm = 1;
    for (int i = 0; i < n; i++) {
        ll g = gcd(lcm, nums[i]);
        lcm = lcm / g * nums[i];
        if (lcm > m) return 0;
    }
    return (m / lcm + 1) / 2;
}

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

    vector<ll> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
        nums[i] /= 2;
    }

    cout << solve(n, m, nums) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int N; ll M; cin >> N >> M;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];

    ll sum = 0;
    map<ll, ll> num;

    num[sum]++;

    for (int i = 0; i < N; i++) {
        sum += A[i];
        num[sum%M]++;
    }

    ll ans = 0;
    for (map<ll, ll>::iterator it = num.begin(); it != num.end(); it++) {
        ans += it->second*(it->second - 1)/2;
    }

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

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

c = [a[i] - b[i] for i in range(n)]
c.sort()

neg = [v for v in c if v < 0]
total = sum(neg)
num = len(neg)

if sum(c) < 0:
    print(-1)
elif num == 0:
    print(0)
else:
    for v in reversed(c[num:]):
        total += v
        num += 1
        if total >= 0:
            break
    print(num)

Measured memory_bytes: 18292
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
vi seek(string s,char t){
    vi ret;
    rep(i,0,s.size()){
        if(s[i]==t)ret.push_back(i);
    }
    return ret;
}
int main( ){
    string s; cin>>s;
    string A=s;
    if(A.size()>1)sort(A.begin(),A.end());
    int k; cin>>k;
    unordered_map<string,int> mp;
    int i=0;
    vector<string> res;
    while(i<A.size()&&res.size()<k){
        vi t=seek(s,A[i]);
        for(int l:t){
            for(int r=1;r+l<=s.size()&&r<=k;r++){
               string alt=s.substr(l,r);
               if(mp.count(alt)==0){
                   res.push_back(alt);
                   mp[alt]++;
               }
           }
        }
        i+=t.size();
    }
    sort(res.begin(),res.end());
    cout<<res[k-1]<<endl;
    return 0;
}




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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256