akhauriyash/Code-Regression huggingface dataset:
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int x,y;
    cin>>x>>y;

    if(y%2)
    {
        cout<<"No";
        return;
    }

    int a=2*x-y/2;
    int b=x-a;

    if(a>=0 && b>=0 && a+b==x && a+2*b==y/2)
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>


using namespace std;

using ll = long long int;
using lln = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()
const long MOD = pow(10, 9) + 7;

char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

unsigned GetDigit(double num) {
	return log10(num) + 1;
}

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

class Mod {
public:
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}

	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};



template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}

int parmitation(ll N) {
	ll ans = 1;
	for (ll i = 1; i <= N; i++) {
		ans *= i;
	}

	return ans;
}

int SemiCommonMultiple(ll A, ll ANum, ll B, ll BNum, ll diff, ll max) {
	ll calc;
	calc = diff + B * BNum - A * ANum;

	if (diff + B * BNum > max) {
		return 0;
	}
	else {
		if (calc < 0) {
			SemiCommonMultiple(A, ANum, B, ++BNum, diff, max);
		}
		else if (calc > 0) {
			SemiCommonMultiple(A, ++ANum, B, BNum, diff, max);
		}
		else {
			return A * (ANum + 0.5);
		}
	}
}

inline void Main() {
	ll X, Y, N, M, K;
	vector<bool> A;
	vector<ll> B;
	ll M1 = 1, D1 = 0, M2 = 1, D2 = 0;
	ll ans, temp;
	ll sum = 0, WAcount = 0,ACcount =0, a = 0;
	double avg = 0.0;
	string S;
	string T;
	string Ans = "";
	bool b[8];
	bool flag = false;


	cin >> M >> N;

	for (ll i = 0; i < N; i++) {
		cin >> X;
		M -= X;
	}
	Yes(M <= 0);
}



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

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

  string ans = "Yes";

  for (char c = 'a'; c <= 'z'; c++) {
    if (count(S.begin(), S.end(), c) % 2 == 1) ans = "No";
  }

  cout << ans << "\n";
}

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

int main()
{
	int x1,y1,x2,y2,d;
	cin >> x1 >> y1 >> x2 >> y2;
	P vec = P(x2-x1,y2-y1);
	
	vec = P(-1 * vec.second, vec.first);
	int x3 = x2 + vec.first;
	int y3 = y2 + vec.second;
	cout << x3 << " " << y3 << " ";

	vec = P(-1 * vec.second, vec.first);
	cout << x3 + vec.first << " " << y3 + vec.second << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using bint=boost::multiprecision::cpp_int;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;

    int n;
    cin>>n;

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

    sort(a.begin(),a.end());

    bint ans=1;
    rep(i,n){
        ans*=a[i];
        if(ans>bint(1e18)){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4056
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	//in := bufio.NewReader(os.Stdin)
	b, _ := ioutil.ReadAll(os.Stdin)
	in := bytes.NewBuffer(b)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

type p struct{ r, c int }

func (con *contest) main() error {
	var H, W, N int
	con.scan(&H, &W, &N)
	M := map[p]int{}
	for i := 0; i < N; i++ {
		var a, b int
		con.scan(&a, &b)
		for r := a - 3; r < a; r++ {
			if r < 0 || r > H-3 {
				continue
			}
			for c := b - 3; c < b; c++ {
				if c < 0 || c > W-3 {
					continue
				}
				M[p{r, c}]++
			}
		}
	}
	A := make([]int, 10)
	for _, v := range M {
		A[v]++
	}
	A[0] = (H-2)*(W-2) - len(M)
	for _, a := range A {
		con.println(a)
	}
	return nil
}


Measured memory_bytes: 113664
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;
using P = std::pair<ll, ll>;

std::string S;
ll sum[200010];
ll ten[200010];
std::map<ll, ll> mp;

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

  ten[0] = 1;

  rep( i, S.size() )
  {
    ten[i+1] = ten[i]*10%2019;
  }

  for( ll i = S.size()-1; i >= 0; --i )
  {
    sum[i] = (sum[i+1]%2019+(S[i]-'0')*ten[S.size()-1-i])%2019;

    ///printf( "sum[%lld] = %lld\n", i, sum[i] );
  }

  ll ans = 0;

  rep( j, S.size()+1 )
  {
    ans += mp[sum[j]];

    //printf( "(%d) + %lld\n", j, mp[sum[j]]);

    ++mp[sum[j]];
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 6392
MAX = 1000000001

def merge(A, left, mid, right, cnt):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    R = A[mid:right]
    ls = len(L)
    L.append(MAX)
    R.append(MAX)
    
    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            cnt += ls - i
            j = j + 1
    return cnt

def mergeSort(A, left, right, cnt):
    if left + 1 < right:
        mid = int((left + right) / 2)
        cnt = mergeSort(A, left, mid, cnt)
        cnt = mergeSort(A, mid, right, cnt)
        cnt = merge(A, left, mid, right, cnt)
    return cnt

def main():
    """ ????????? """
    num = int(input().strip())
    A = list(map(int,input().split()))
#    print(A)
    cnt = mergeSort(A, 0, num, 0)
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 30336
#include<iostream>
using namespace std;
#define size 105
string a[105];
int lookingr(int r,int c)
{
    for(int i=0;i<r;i++)
    {
        int flag1=0;
        for(int j=0;j<c;j++)
        {
            if(a[i][j]!='.') 
            {
                flag1=1;
                break;
            }
        }
        if(flag1==0) return i;
    }
    return -1;
}
int lookingc(int r,int c)
{
    for(int j=0;j<c;j++)
    {
        int flag2=0;
        for(int i=0;i<r;i++)
        {
            if(a[i][j]!='.')
            {
                flag2=1;
                break;
            }
        }
        if(flag2==0) return j;
    }
    return -1;
}
void DFS(int r,int c)
{
    int targetr=lookingr(r,c);
    int targetc=lookingc(r,c);
    if(targetr>=0||targetc>=0)
    {
        if(targetc<0&&targetr>=0)
        {
            for(int i=targetr;i<r-1;i++)
            {
                a[i]=a[i+1];
            }
            DFS(r-1,c);
        }
        else if(targetc>=0&&targetr<0)
        {
            for(int i=0;i<r;i++)
            {
                a[i].erase(targetc,1);
            }
            DFS(r,c-1);
        }
        else
        {
            for(int i=targetr;i<r-1;i++)
            {
                a[i]=a[i+1];
            }
            for(int i=0;i<r-1;i++)
            {
                a[i].erase(targetc,1);
            }
            DFS(r-1,c-1);
        }
    }
    else
    {
        for(int i=0;i<r;i++) cout<<a[i]<<endl;
        return;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    int h,w;
    while(cin>>h>>w)
    {
        for(int i=0;i<h;i++)
        {
            cin>>a[i];
        }
        DFS(h,w);
    }
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int W, S;

void solve() {
    cin >> S >> W;
    W >= S ? cout << "unsafe" : cout << "safe";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3688
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys
import math


n = int(input())

dishes = list()

for i in range(0, n):
    a, b = raw_input().split()
    a = int(a)
    b = int(b)
    sum = a + b
    dishes.append([a, b, sum])

takahashi = 0
aoki = 0
dishes.sort(key=lambda x: x[2], reverse=True)

for i in range(0, n):
    if i % 2 == 0:
        j = dishes[0]
        dishes.pop(0)
        takahashi = takahashi + j[0]
    else:
        j = dishes[0]
        dishes.pop(0)
        aoki = aoki + j[1]

print takahashi - aoki


Measured memory_bytes: 26740
//*******Abhijit Burman***********// 
//Jalpaiguri Government Engineering College/ 

#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back 
#define mk make_pair 
#define MAXX (1000000000000000000+7) 
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) 



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

int main()
{
    fio;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n, E, T, r;
int a[maxn];
ll Min1, Min2 = 1e18, f[maxn];
int main()
{
	deque<ll> Q; 
	scanf("%d%d%d", &n, &E, &T);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	Q.push_back(0);
	for(int i = 1; i <= n; ++i)
	{
		while((a[i] - a[r + 1]) * 2 >= T)
		{
			Min2 = min(Min2, f[r] - 2 * a[r + 1]);
			if(Q.front() <= r) Q.pop_front();
			++r;
		}
		f[i] = min(Min1 + 1ll * i * T, Min2 + 2 * a[i]);
		if(!Q.empty()) f[i] = min(f[i], f[Q.front()] + T);
		Min1 = min(Min1, f[i] - 1ll * i * T);
		while(!Q.empty() && f[i] <= f[Q.back()]) Q.pop_back();
		Q.push_back(i);
	}
	printf("%lld\n", f[n] + E);
	return 0;
}

Measured memory_bytes: 5264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = -1e18, tmp = 0;
  tmp = a * c;
  chmax(ans, tmp);
  tmp = a * d;
  chmax(ans, tmp);
  tmp = b * c;
  chmax(ans, tmp);
  tmp = b * d;
  chmax(ans, tmp);
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,Lim,l;
    while(1){
        scanf("%d %d",&N,&Lim);
        if(N==0){
            break;
        }
        int a[N];
        for(int i=0;i<N;i++){
            cin>>l;
            a[i]=l;
        }
        sort(a,a+N);
        int ans=0;

        int low,high,mid;
        int tmp,a_i;
        for(int i=0;i<N;i++){
            a_i = a[i];
            for(int j=i+1;j<N;j++){
                if (a_i+a[j]<=Lim){
                    ans = max(ans,a_i+a[j]);
                }
            }
        }
        if(ans==0){
            cout<<"NONE"<<endl;
        }
        else{
            cout << ans << endl;
        }
    }
	return 0;
}



Measured memory_bytes: 3132
n, m, c = map(int, input().split())
b = [int(x) for x in input().split()]
a = []
for i in range(n):
    a.append([int(x) for x in input().split()])
cnt = 0
for an in a:
    dot = 0
    for i, j in zip(an, b):
        dot += i*j
    dot += c
    cnt += int(dot>0)
    
print(cnt)

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.List
import Data.Ratio
import Text.Printf
import System.IO

untilEOF :: IO () -> IO ()
untilEOF x = do
  e <- isEOF
  unless e $ x >> untilEOF x

main :: IO ()
main = untilEOF $ do
  str <- getLine
  putStrLn $ reverse str



Measured memory_bytes: 3480
#include<cstdio>
#include<algorithm>
using namespace std;

int dp[2][2][5001];

int main(){
  int n;
  int t[10000];
  scanf("%d",&n);
  for(int i=0;i<n-1;i++)scanf("%d",&t[i]);
  
  for(int i=0;i<=n/2;i++)dp[0][0][i] = dp[0][1][i] = 100000000;
  dp[0][0][1] = 0;

  for(int i=0;i<n-1;i++){
    int ii = i&1;
    for(int j=0;j<=n/2;j++)dp[1-ii][0][j] = dp[1-ii][1][j] = 100000000;

    for(int j=0;j<2;j++){
      for(int k=0;k<=n/2;k++){
	if(k<n/2)dp[1-ii][j][k+1] = min(dp[1-ii][j][k+1], dp[ii][j][k]);
	if(i+1-k<n/2 && 0<=i+1-k+1)dp[1-ii][1-j][i+1-k+1] = min(dp[1-ii][1-j][i+1-k+1],dp[ii][j][k] + t[i]);
      }
    }
  }

  printf("%d\n",min(dp[1][0][n/2],dp[1][1][n/2]));
}

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

int Roma(char a){
switch(a){
	case 'I':return 1;
	case 'V':return 5;
	case 'X':return 10;
	case 'L':return 50;
	case 'C':return 100;
	case 'D':return 500;
	case 'M':return 1000;
}
return 0;
}
int main() {
while(1){
	string a;
	cin>>a;
	if(cin.fail())break;
	int s=0;
	for(int b=0;b<a.length();b++){
		if(a.length()-1==b){
			s+=Roma(a[b]);
		}
		else{
			if(Roma(a[b])<Roma(a[b+1])){
				s+=Roma(a[b+1])-Roma(a[b]);
				b++;
			}
			else s+=Roma(a[b]);
		}
	}
	cout<<s<<endl;
}
}

Measured memory_bytes: 3136
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	ll x;
	cin >> x;
	while (true)
	{
		if (isPrime(x))
		{
			cout << x << endl;
			break;
		}
		else
		{
			x++;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, a[500], b[500], sum, k, ans;

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

    cin >> n >> k;
    rep(i, n) cin >> a[i], sum += a[i];
    for(int i = 1; i * i <= sum; i++) {
        if(sum % i) continue;

        int x = 0;
        rep(j, n) {
            b[j] = a[j] % i;
            x += b[j];
        }
        sort(b, b + n);
        x /= i;
        int s = 0;
        rep(j, n - x) s += b[j];
        if(s <= k) chmax(ans, i);

        int i2 = sum / i;
        x = 0;
        rep(j, n) {
            b[j] = a[j] % i2;
            x += b[j];
        }
        sort(b, b + n);
        x /= i2;
        s = 0;
        rep(j, n - x) s += b[j];
        if(s <= k) chmax(ans, i2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n >= s.size()) {
    cout << s;
  } else {
    rep(i,n)
      cout << s[i];
    cout << "...";
  }
}


Measured memory_bytes: 3628
import java.util.*;
import java.io.*;

class Main {
  public static void main(String args[]) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = "";
    String p = "";
    try {
      s = br.readLine();
      p = br.readLine();
    } catch (IOException e) {
      e.printStackTrace();
    }
    s = s + s;
    System.out.println(s.indexOf(p) != -1? "Yes" : "No");
  }
}

Measured memory_bytes: 17048
#include "bits/stdc++.h"
using namespace std;
int dx[2][3] = { {0,-1,1},{0,1,-1} };
int dy[2][3] = { {1,0,0},{-1,0,0} };
struct poly {
	int x;
	int y;
	int under;
	int front;
	int left;
	int right;
	int turn;
	int id;
	poly() :x(101), y(101), under(0), front(5),turn(0),id(0) {
		setlr();
	}
	enum Way {
		W_Front,
		W_Left,
		W_Right,
	};
	int typeflr[4][3] = {
		{ 1,0,0 } ,
		{ -1,1,1 },
		{ 1,-1,-1 },
		{ -1,0,0 }
	};
	int dflr[4][3] = {
		{ 0,4,1 },
		{ 0,1,0 },
		{ 0,4,0 },
		{ 0,1,4 },
	};
	//0 5 4 1
	//1 6 0 2
	//5 0 11 10
	//6 1 12 11
	//10 15 9 5
	//11 16 5 6
	//15 10 16 19
	// 16 11 17 15
	void setid() {
		const int ftype = under / 5;
		const int fnum = under % 5;
		bool flag = false;
		for (int i = 0; i < 3; ++i) {
			const int atype = ftype + typeflr[ftype][i];
			const int anum = (fnum + dflr[ftype][i]) % 5;
			const int predict_front = atype * 5 + anum;
			if (predict_front == front) {
				id = i;
				break;
			}
		}
	}
	void setlr() {
		
		const int ftype = under / 5;
		const int fnum = under % 5;
		bool flag = false;
		for (int i = 0; i < 3; ++i) {
			const int atype = ftype + typeflr[ftype][i];
			const int anum = (fnum + dflr[ftype][i])%5;
			const int predict_front = atype * 5 + anum;
			if (predict_front == front) {
				{
					const int atype = ftype + typeflr[ftype][(i+1)%3];
					const int anum = (fnum + dflr[ftype][(i + 1) % 3]) % 5;
					left = atype * 5 + anum;
				}
				{
					const int atype = ftype + typeflr[ftype][(i + 2) % 3];
					const int anum = (fnum + dflr[ftype][(i + 2) % 3]) % 5;
					right= atype * 5 + anum;
				}
				flag = true;
				break;
			}
		}
		assert(flag);

	}
	void rotate_l() {
		int c = left;
		left = right;
		right = front;
		front = c;
	}
	void rotate(const Way way) {
		x += dx[(x + y) % 2][way];
		y += dy[(x + y) % 2][way];
		if (way == W_Front) {
			swap(front, under);
			setlr();
		}
		else if (way == W_Left) {
			swap(left, under);
			{
				rotate_l();
				setlr();
				rotate_l();
				rotate_l();
			}
		}
		else {
			swap(right, under);
			{
				rotate_l();
				rotate_l();
				setlr();
				rotate_l();
			}
		}
		setid();
		turn++;
	}
	void rotate(const int way) {
		rotate(static_cast<Way>(way));
	}
};


int main() {
	while (1) {
		int x, y, u; cin >> x >> y >> u;
		if (!x&&!y&&!u)break;
		x += 101;
		y += 101;

		vector<vector<vector<vector<int>>>>memo(203, vector<vector<vector<int>>>(203, vector<vector<int>>(20, vector<int>(3,1e9))));
		queue<poly>que;
		memo[101][101][0][0] = 0;
		que.push(poly());
		int ans = -1;
		while (!que.empty()) {
			poly atop(que.front());
			if (atop.x == x&&atop.y == y&&atop.under == u) {
				ans = atop.turn;
				break;
			}
			que.pop();
			for (int i = 0; i < 3; ++i) {
				poly apoly(atop);
				apoly.rotate(i);
				if (memo[apoly.x][apoly.y][apoly.under][apoly.id]>apoly.turn) {
					memo[apoly.x][apoly.y][apoly.under][apoly.id] = apoly.turn;
					que.push(apoly);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    string S;
    cin>>S;
    if(C<D){
        if(B<C){
        bool check=true;
        for(int i=A;i<=D-1;i++){
            if(S[i]=='#'&&S[i-1]=='#') check=false;
        }
        if(check) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        }else{
            bool check=true;
            for(int i=A;i<=C-1;i++){
                if(S[i]=='#'&&S[i-1]=='#') check=false;
            }
            for(int i=B;i<=D-1;i++){
                if(S[i]=='#'&&S[i-1]=='#') check=false;
            }
            if(check) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
            }
        }
    else{
        bool check=true;
        for(int i=A;i<=C-1;i++){
            if(S[i]=='#'&&S[i-1]=='#') check=false;
        }
        if(check){
            bool check2=false;
            for(int i=B;i<=D;i++){
                if(S[i-2]=='.'&&S[i-1]=='.'&&S[i]=='.') check2=true;
            }
            if(check2) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n;
    while(cin >> n, n) {
        // <number, color>
        vector <pair <int, bool>> table;
        rep (i, n) {
            int a;
            cin >> a;
            if (i == 0) {
                table.emplace_back(1, a);
                continue;
            }
            if (i % 2 != 0 && table.back().second != a) {
                if (table.size() == 1) {
                    table.front().first++;
                    table.front().second = a;
                }
                else {
                    int tmp = table.back().first;
                    table.pop_back();
                    table.back().first += tmp + 1;
                }
            }
            else {
                if (table.back().second == a) {
                    table.back().first++;
                }
                else {
                    table.emplace_back(1, a);
                }
            }
        }

        int cnt = 0;
        for (auto i : table) if (i.second == 0) cnt += i.first;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT;
    int n;
    cin >> n;
    V<int> w(n);
    cin >> w[0];
    FOR(i,1,n) {
        int x; cin >> x;
        w[i] = x + w[i-1];
    }
    int ans = 1000;
    for(int i=n-2; i >=0; i--) {
        ans = std::min(ans, std::abs(w[i]-(w[n-1]-w[i])));
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>V(N);  
  for (int i=0;i<N;++i)cin>>V[i];
  vector<int>C(N);
  for (int i=0;i<N;++i)cin>>C[i];
  int ans=0;
  for (int i=0;i<N;++i){
    if (V[i]>C[i])ans+=V[i]-C[i];
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, C; cin >> A >> B >> C;

	int res = min(C, B / A);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D;
    cin >> D;
    vector<int>c(26);
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector<vector<int>>s(D,vector<int>(26));
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int>t(D);
    for(int i = 0; i < D; i++) {
        t[i] = rand()%26+1;
    }
    int ans = 0;
    vector<int>Last(26);
    for(int i = 0; i < D; i++) {
        ans+=s[i][t[i]-1];
        Last[t[i]-1] = i+1;
        for(int j = 0; j < 26; j++) {
            ans-=c[j]*(i+1-Last[j]);
        }
    }
    int M = 3000000;
    vector<P>horyuu;
    int cnt = 0;
    for(int i = 0; i < M; i++) {
        int d = rand()%D+1;
        int q = rand()%26+1;
        int ord = ans;
        int X = 0;
        int Y = 0;
        int A = 0;
        int B = 0;
        ans+=s[d-1][q-1]-s[d-1][t[d-1]-1];
        for(int j = 0; j < D; j++) {
            if(t[j] == t[d-1]) {
                if(j == d-1) {
                    Y = j+1;
                }
                else {
                    X = j+1;
                }
                A = j+1;
            }
            if(t[j] == q) {
                Y = j+1;
                B = j+1;
            }
            ans-=c[t[d-1]-1]*(j+1-X)-c[t[d-1]-1]*(j+1-A);
            ans+=c[q-1]*(j+1-B)-c[q-1]*(j+1-Y);
        }
        if(ans > ord) {
            ord = ans;
            cnt++;
            horyuu.push_back({d,q});
        }
        else {
            ans = ord;
        }
        if(cnt == 5) {
            cnt = 0;
            t[horyuu[3].first-1] = horyuu[3].second;
            horyuu = {};
        }
    }
    for(int i = 0; i < D; i++) {
        cout << t[i] << "\n";
    }
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    pair<ll, int> a[n];
    REP(i,n){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a, a + n);
    int ans = 0;
    REP(i,n){
        if(i % 2 != a[i].second % 2) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>

int main(void)
{
    float r, l;
    int right[4], left[4];
    
    for (int i = 0; i < 4; i++){
        right[i] = 0;
        left[i] = 0;
    }
    
    while (scanf("%f %f", &l, &r) != EOF){
        if      (l < 0.2) left[3]++;
        else if (l < 0.6) left[2]++;
        else if (l < 1.1) left[1]++;
        else left[0]++;
        
        if      (r < 0.2) right[3]++;
        else if (r < 0.6) right[2]++;
        else if (r < 1.1) right[1]++;
        else right[0]++;
    }
    
    for (int i = 0; i < 4; i++){
        printf("%d %d\n", left[i], right[i]);
    }
    
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
int Y[4]={-1,0,1,0};
int X[4]={0,1,0,-1};
 
bool in(int a,int b){
  if(a<0 || b<0 || 3<=a || 3<=b)return false;
  return true;
}
 
int main()
{
  int a;
  string start="",goal="123456780";
 
  for(int i=0;i<9;i++){
    cin>>a;
    start+=(a+'0');
  }
   
  queue<string> q;
  map<string,int> mp;
  mp[start]=0;
  q.push(start);
  while(!q.empty()){
    string u=q.front();
    q.pop();
    int s=-1,cost=mp[u];
    if(u==goal){
      cout<<mp[u]<<endl;
      break;
    }
 
    for(int i=0;i<u.length();i++){
      if(u[i]=='0')s=i;
    }
 
    int y=s/3,x=s%3;
 
    for(int i=0;i<4;i++){
      int ny=y+Y[i],nx=x+X[i];
      if(!in(ny,nx))continue;
      int index=ny*3+nx;
      string t=u;
      swap(t[s],t[index]);
      if(mp.find(t)==mp.end()){
    mp[t]=cost+1;
    q.push(t);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 23264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var pair = new int[10, 10];

            long ans = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i % 10 == 0) continue;

                var ca = i.ToString().ToCharArray();
                var r = i.ToString().ToCharArray();

                pair[ca.First() - 48, ca.Last() - 48]++;

            }

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    ans += pair[i, j] * pair[j, i];
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15416
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
ll comb(ll, ll);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll l, r;
    cin >> l >> r;

    if (r - l >= 2018) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = (l % 2019) * ((l + 1) % 2019) % 2019;
    repd(i, l, r) {
        repd(j, i + 1, r + 1) {
            ll left = i % 2019;
            ll right = j % 2019;
            ans = min(ans, (left * right) % 2019);
        }
    }

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

ll comb(ll a, ll b) {
    if (a < b) {
        return 0;
    }

    ll v[a + 1][a + 1] = {};

    rep(i, a + 1) {
        v[i][0] = 1;
        v[i][i] = 1;
    }

    repd(k, 2, a + 1) {
        repd(j, 1, k) { v[k][j] = v[k - 1][j - 1] + v[k - 1][j]; }
    }

    return v[a][b];
}

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

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x;
	int i;
	i = 0;
	do{
		scanf("%d",&x);
		if(x!=0){
			i = i+1;
			printf("Case ");
			printf("%d: ", i);
			printf("%d\n", x);
		}
	}while(x!=0);
	return 0;
}

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

int main()
{
    int n,ans;

    cin >> n;
    vector<int> d(n);
    rep(i, n)
        cin >> d[i];
    sort(d.begin(), d.end());
    ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3760
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
flag = 0
for i in range(N-2):
    if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1]:
        if D[i+2][0] == D[i+2][1]:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9196
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	//入力
	int N;long long K;cin >> N >> K;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];

	long long res = 0;

	//実装のtips
	//d=-1にしておけばe>dのところで、Kそのものを試せる。

	//Kのビットを上からみて、はじめて一致しない位置をdとして
	//dを全探索する

	//Xは
	//dより上の桁はKと一致
	//d桁目は0
	//dより小さい桁はXは自由にとれる

	//具体例でいうと
	//101001の10"1"001を0にすると1000は0111より大きいので
	//それより小さい桁は1を自由に使える
	
	for (int d = 60; d >= -1; --d) { 

		//d!=-1でないかつ
		//Kより大きい位置桁は無効
		//Kとdが重なるビットがないときははじく
		if (d != -1 && !(K & (1LL << d))) continue;

		//この回の結果を格納する変数
		long long tmp = 0;

		//上で決めたdの状態の各桁eの計算を桁ごとに行う
		for (int e = 60; e >= 0; --e) {

			//bitであることがわかりやすいように名前つけておく
			long long mask = 1LL << e;

			//全ての入力に対して、今注目している桁に何個ビットが立っているか
			//総和を求める 
			int num = 0;
			for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;


			//dより大きい桁では、Kと一致するようにとるしかない
			if (e > d) {
				if (K & mask) tmp += mask * (N - num);
				else tmp += mask * num;
			}

			//d番目の桁は0しかない
			else if (e == d) {
				tmp += mask * num;
			}

			//dより小さい桁は自由に0,1を選べるので
			//両方のうち大きい方をとる
			else {
				tmp += mask * max(num, N - num);
			}
		}

		//一つのdに対しての結果が求まったので、最大値を更新する
		res = max(res, tmp);
	}

	//出力して終了
	cout << res << endl;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
const int mod = 1e9 + 7;
ll a[maxn];
ll sum[maxn];
void exgcd(ll a, ll b, ll &x, ll &y, ll &d)
{
    if (!b)
    {
        d = a, x = 1, y = 0;
    }
    else
    {
        exgcd(b, a % b, y, x, d);
        y -= x * (a / b);
    }
}
ll inv(ll t, ll p)
{ //如果不存在，返回-1
    ll d, x, y;
    exgcd(t, p, x, y, d);
    return d == 1 ? (x % p + p) % p : -1;
}
void run_case()
{
    int n;
    cin >> n;
    ll tot = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        tot += a[i];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ll cur = tot - sum[i];
        ans = (ans + cur % mod * a[i] % mod) % mod;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 6768
import sys

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

a = [0 for i in range(q)]
b = [0 for i in range(q)]
c = [0 for i in range(q)]
d = [0 for i in range(q)]

for i in range(q):
	A, B, C, D = map(int, input().split())
	a[i] = A
	b[i] = B
	c[i] = C
	d[i] = D

x = [0 for i in range(n)]

best = -1

def search(min_elem, pos):
	global best
	global a
	global b
	global c
	global d
	if (pos == n):
		score = 0		
		for i in range(q):			
			if x[b[i] - 1] - x[a[i] - 1] == c[i]:
				score += d[i]
		best = max(best, score)

	else: 
		for i in range(min_elem, m + 1):
			x[pos] = i
			search(i, pos + 1)

search(1, 0)
print(best)

Measured memory_bytes: 71208
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    int n=1;
    int i;
    for(i=1;i<=9;i++){
        int s;
        s=i*111;
        if(N>s)
        n=i+1;
    }
    cout<<n*111;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int k,a,b,i,m;
    int s=0;
    scanf("%d %d %d",&k,&a,&b);
    for(i=0;i<=1000;i++)
    {
        m=i*k;
        if(a<=m && m<=b)
        {
            s=1;
        }
    }
    if(s==1)
    {
        printf("OK\n");
    }
    else
    {
        printf("NG\n");
    }
    return 0;
}


Measured memory_bytes: 1660
def calc(t)
    t[0] -= 1
    t[1] -= 1
    t[2] -= 1
    ret = 590 * (t[0]/3)
    t[0] %= 3
    ret += t[0] * 195
    if t[0] == 2
        ret += 20 * t[1]
        ret += t[2]
    else
        even = false
        while t[1] > 0
            ret += 19
            ret += 1 if !even
            even = !even
            t[1] -= 1
        end
        ret += t[2]
    end
    return ret
end
n = gets.to_i
t = n.times.map{gets.split.map(&:to_i)}
mil = calc([1000,1,1])
t.each do |tt|
    puts mil - calc(tt)
end

Measured memory_bytes: 6112
#include<iostream>
#include<stack>
#include<string>
#include<stdlib.h>
using namespace std;


int main()
{
	stack<int> s;
	string str;
	
	while(cin >> str)
	{
		switch(str[0])
		{
			case '+':
			{
				int a = s.top(); s.pop();
				int b = s.top(); s.pop();
				s.push(a+b);
				break;	
			}
			case '-':
			{
				int a = s.top(); s.pop();
				int b = s.top(); s.pop();
				s.push(b-a);break; 		
			}
			case '*':
			{
				int a = s.top(); s.pop();
				int b = s.top(); s.pop();
				s.push(a*b);break;		
			}
			case '/':
			{
				int a = s.top(); s.pop();
				int b = s.top(); s.pop();
				s.push(b/a);break;		
			}
			default:s.push(atoi(str.c_str()));	
		}
	}
	cout<<s.top()<<endl;
}

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

using namespace std;

int main(){
int N,X; cin >> N >> X;
  vector<int> L(N);
  for(int i = 0; i < N; i++){ cin >> L[i];}
  
  int hight = 0; int cnt = 1;
  
  for(int i = 0; i < N; i++){
    hight += L[i]; cnt++;
    if( hight > X){ cnt--;break;}}
 
  cout << cnt << endl; return 0;}

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

#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;

#define sqr(a) ((a)*(a))
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define nrof(i, n) for(int i = (int)n - 1; i >= 0; --i)
#define rep(i, k, n) for(int i = (int)k; i < (int)n; ++i)
#define per(i, k, n) for(int i = (int)k - 1; i >= (int)n; --i)
#define x first
#define y second
#define mp make_pair
#define sz(a) (int)(a.size())
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e6 + 9;
const int M = 2e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ll MOD = (ll) (1000000007);

vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};

void solve() {
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<vector<int>> gr(n, vector<int>());
    forn(i, m) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        gr[x].pb(y);
        gr[y].pb(x);
    }
    vector<bool> used(n);
    int ans = 0;

    function<int(int)> dfs = [&](int v) {
        used[v] = true;
        int cnt = 1;
        for (auto u: gr[v]) {
            if (!used[u]) cnt += dfs(u);
        }
        return cnt;
    };

    for (int i = 0; i < n; ++i) {
        if (!used[i]) ans = max(ans, dfs(i));
    }

    cout << ans << endl;
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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

    return 0;
}


Measured memory_bytes: 26664
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]#[～円,～本]
AB=sorted(AB,key=lambda x:x[0])


ans=0
cnt=0
for i in range(N):
    cnt+=AB[i][1]
    if M>=cnt:
        ans+=AB[i][1]*AB[i][0]
    else:
        ans+=(M-(cnt-AB[i][1]))*AB[i][0]
        break
print(ans)

Measured memory_bytes: 29792
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0)
    cout<<n/x*t<<endl;
  else
     cout<<((n/x)+1)*t<<endl;
}
int  main() 
{
  auto start=clock();
  fast_io;
    int t=1;
    //cin>>t;
    while(t--){
      solve();
    }
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
  return 0; 
}


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

using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int rectangle1 = a * b;
  int rectangle2 = c * d;

  if (rectangle1 == rectangle2)
    cout << rectangle1;
  else
    cout << (rectangle1 > rectangle2 ? rectangle1 : rectangle2) << endl;

  return 0;
}

Measured memory_bytes: 256