akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO
using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    N %= 1000;
    if (N == 0) {
        N = 1000;
    }
    cout << 1000 - N << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3652
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


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

    int ans=LLONG_MAX;
    for(int i=1;i<sqrt(N)+1;i++){
        if(N%i==0){
            int n1=N/i;
            int n2=i;
            int keta1=0;
            int keta2=0;
            while(n1!=0){
                keta1++;
                n1/=10;
            }
            while(n2!=0){
                keta2++;
                n2/=10;
            }
            ans=min(ans,max(keta1,keta2));
        }
    }

    cout<<ans<<endl;
}


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

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

    int sum = A + B;
    if(sum % 2 == 0)
    {
        cout << sum / 2 << endl;
    }

    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import heapq
import bisect
input = sys.stdin.readline

MOD = 10 ** 9 + 7


def my_sol(N, M):
    _A = {}
    A = []

    for i in map(int, input().split()):
        if i in _A:
            _A[i] += 1
        else:
            _A[i] = 1

    for (num, c) in _A.items():
        heapq.heappush(A, (num, c))
    # B = [0] * N
    # C = [0] * N
    # print(A)

    B = [0] * M
    C = [0] * M
    T = [None] * M
    for i in range(M):
        b, c = map(int, input().split())
        T[i] = (c, b)

    T = sorted(T, reverse=True)

    finish = False
    for i in range(M):
        C, B = T[i]

        while B > 0:
            item = heapq.heappop(A)

            if item[0] < C:
                replace = min(item[1], B)
                B -= replace
                remain = item[1] - replace

                heapq.heappush(A, (C, replace))

                if remain > 0:
                    heapq.heappush(A, (item[0], remain))

                # print("")
                # print(A, B, replace)
            else:
                heapq.heappush(A, item)
                finish = True
                break

        if finish is True:
            break

    ans = 0
    for a in A:
        ans += a[0] * a[1]
    print(ans)


def main():
    N, M = map(int, input().split())
    D = {}
    E = []

    for i in map(int, input().split()):
        if i in D:
            D[i] += 1
        else:
            D[i] = 1

    for i in range(M):
        B, C = map(int, input().split())
        if C in D:
            D[C] += B
        else:
            D[C] = B

    # print(D)
    for (num, c) in D.items():
        heapq.heappush(E, (-num, c))

    total = 0
    ans = 0

    while total < N:
        item = heapq.heappop(E)
        num = -item[0]
        c = item[1]
        ans += num * min(N-total, c)
        total += min(N-total, c)

    print(ans)
    # my_sol(N, M)


if __name__ == '__main__':
    main()


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

#define int long long

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

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

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

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
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;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int n;
	cin>>n;
	map<string,int> m;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	int ma=0;
	for(auto a:m){
		chmax(ma,a.second);
	}
	for(auto a:m){
		if(a.second==ma)cout<<a.first<<endl;
	}
}

Measured memory_bytes: 25216
n,m,c = list(map(int,input().split()))
b = list(map(int,input().split()))

def solve(a,b,c):
    val = 0
    for ia,ib in zip(a,b):
        val += ia*ib
    val += c
    return val > 0

cnt = 0
for i in range(n):
    a = list(map(int,input().split()))
    if solve(a,b,c):
        cnt += 1

print(cnt)    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n;
    cin >> n ;
    map<int,int>mp;
    int ans =0 ;
    fn1{  
      int x;
      cin>>x;
      ans+=mp[i-x];
      mp[x+i]++;
    }
    cout<<ans;
  
  
  }
  return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c == 17){
    if((a==5 || a==7)&&(b==5||b==7)&&(c==5||c==7)){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a[200001];
const int mod=1000000007;
int  main() {
	long long int n,m=0,ma=0;
	cin>>n;
	for (int i=1; i<=n; i++) { 
		cin>>a[i];
		m+=a[i]%1000000007;
		m=m%1000000007;
	}
	
	for (int i=1; i<n; i++) {

		m=(m-a[i]+mod)%mod;

		ma=a[i]*m+ma;
		ma=ma%1000000007;
	}
	
	
	cout<<ma;
	return 0;
}

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

using namespace std;

int W,H;
int dp[1400][1400];



int main() {
	cin >> W >> H;
	
	int v_max = 0;

	for (int x = 0; x < W; x++) {
		for (int y = 0; y < H; y++) {
			cin >> dp[x][y];
			dp[x][y] ^= 1;
			v_max |= dp[x][y];
		}
	}
	
	for (int x = 1; x < W; x++) {
		for (int y = 1; y < H; y++) {
			if (dp[x][y] == 0) {
				continue;
			}
			dp[x][y] = min(dp[x-1][y],dp[x][y-1]);
			dp[x][y] = min(dp[x][y],dp[x-1][y-1]);
			dp[x][y] ++;
			v_max = max(v_max ,dp[x][y]);
		}
	}
	cout << v_max *  v_max << endl;
	return 0;
}

Measured memory_bytes: 8816
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(new string(s.Select(x => x == '1' ? '9' : '1').ToArray()));
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define mp make_pair
#define f first
#define s second

//var 
int n,x,L,l,r, ans,i,j, rm = INT_MIN;
pii rng[100001];

int main(){
	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> x >> L;
		l = (x-L);
		r = (x+L);
		rng[i] = mp(r,l);
	}
	ans = 0; 
	sort(rng+1,rng+n+1);
	i = 1;
	for(int i = 1; i<=n; i++){ 
		//cout << rng[i].s << " " << rng[i].f << endl;
		if(rng[i].s >= rm){
			ans++;
			rm = rng[i].f;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    char b;
    cin >> b;
    switch (b)
    {
    case 'A':
        cout << 'T' << endl;
        break;
    case 'C':
        cout << 'G' << endl;
        break;
    case 'G':
        cout << 'C' << endl;
        break;
    case 'T':
        cout << 'A' << endl;
        break;
    }
}


Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))
Pi = [0] * n
for i, p in enumerate(P):
    Pi[p-1] = i

A = [30000*(i+1) for i in range(n)]
B = [30000*(n-i)+pi for i, pi in enumerate(Pi)]

print(' '.join(map(str, A)))
print(' '.join(map(str, B)))


Measured memory_bytes: 8120
#include<stdio.h>

int A[100000],n;

int Binary( int key ){
  int left = 0;
  int right = n;
  int mid;
  while( left < right ){
    mid = ( left + right )/2;
    if( key == A[mid] ){
      return 1;
    }
    else if(key > A[mid] ){
      left = mid + 1;
    }
    else {
      right =mid;
    }
  }
  return 0;
}

int main(void){

  int i,q,m,sum=0;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for( i = 0 ; i < q ; i++){
    scanf("%d",&m);
    if( Binary(m)){
      sum++;
    }
  }
  printf("%d\n",sum);
 
 return 0;
}

Measured memory_bytes: 984
module Main where

import Control.Applicative
import Numeric
import Data.Char
import Data.List
import Data.Ord

main :: IO ()
main = do
  { cs <- getContents
  ; putStr $ unlines
           $ map showCharCount
           $ mergeCharCounts
           $ charCounts
           $ alphas cs
  }

alphas :: String -> String
alphas = map toLower . filter isAlpha

charCounts :: String -> [(Char, Int)]
charCounts = map count . group . sort

count :: String -> (Char, Int)
count s = (head s, length s)

initCharCounts :: [(Char, Int)]
initCharCounts = zip ['a' .. 'z'] (repeat 0)

mergeCharCounts :: [(Char, Int)] -> [(Char, Int)]
mergeCharCounts = merge initCharCounts

merge ::  [(Char, Int)] -> [(Char, Int)] -> [(Char, Int)]
merge [] [] = []
merge xs [] = xs
merge (x:xs) (y:ys) = case (comparing fst) x y of
  LT -> x : merge xs (y:ys)
  EQ -> y : merge xs ys
  _  -> error "Henn!"

showCharCount :: (Char, Int) -> String
showCharCount (c, n) = [c] ++ " : " ++ show n
    
--
getIntegers :: IO [Integer]
getIntegers = map read . words <$> getLine

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4132
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

ll ans=0;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  int a[1000]={0},b[1000]={0},c[1000]={0};
  int dist[100][100];
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j){
        dist[i][j]=0;
      }else {
        dist[i][j]=1000000000;
      }
    }
  }
  for(int i=0;i<M;i++){
    dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
    dist[b[i]][a[i]]=dist[a[i]][b[i]];
  }
  for(int k = 0; k < N; ++k){
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  int ans=M;
  for(int i = 0; i < M; ++i){
    bool shortest=false;
    for(int j = 0; j < N; ++j) if(dist[j][a[i]]+c[i]<=dist[j][b[i]]) shortest=true;
    if(shortest==true){
    ans=ans-1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;

const ll M = ll(1e9)+7;
struct Mat {
	ll a[3][3];
	Mat(){ memset(a, 0, sizeof(a)); }
	Mat operator*(Mat r){
		Mat ret;
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				for(int k=0; k<3; ++k){
					ret.a[i][j] += a[i][k] * r.a[k][j] % M;
					ret.a[i][j] %= M;
				}
			}
		}
		return ret;
	}
};

Mat yes, no, I;

void mat(){
	yes.a[0][0] = 1;                  yes.a[0][2] = 1;
	yes.a[1][0] = 1; yes.a[1][1] = 1; yes.a[1][2] = 1;
	yes.a[2][0] = 1; yes.a[2][1] = 2; yes.a[2][2] = 2;
	
	no.a[0][0] = 1;
	no.a[1][0] = 1; no.a[1][1] = 1;
	no.a[2][0] = 1; no.a[2][1] = 2; no.a[2][2] = 1;
	
	for(int i=0; i<3; ++i) I.a[i][i]=1;
}

Mat Pow(Mat base, int e){
	if(e == 0) return I;
	Mat ret = Pow(base, e/2);
	ret = ret*ret;
	if(e&1) ret = ret*base;
	return ret;
}

int main()
{
	read(n, m);
	mat();
	int lp=0;
	Mat x = I;
	for(int i=1; i<=m; ++i){
		int p; read(p);
		x = no * x;
		x = Pow(yes, p-lp-1) * x;
		lp = p;
	}
	x = no * x;
	x = Pow(yes, n-lp-1) * x;
	printf("%lld\n", x.a[2][0]);
	return 0;
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    string s;
    cin >> s;
    
    ll n = s.length();
    for(i, 1, n) {
        if (i & 1) continue;
        ll len = n - i;
        string x = s.substr(0, len / 2);
        string y = s.substr(len / 2, len / 2);
        if (x == y) {
            cout << len << endl;
            return 0;
        }
    }
    
    return 0;
}

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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int N = 1e5 + 10;
int n, k;
int h[N], dp[N];
int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }

    dp[1] = 0;

    for (int i = 2; i <= n; i++)
    {
        dp[i] = 0x7fffffff;
        for (int j = 1; j <= k; j++)
        {
            if (i - j >= 1)
            {
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long F[4<<17],I[4<<17];
long C(int N,int K){return F[N]*I[N-K]%mod*I[K]%mod;}
main()
{
	F[0]=1;
	for(int i=1;i<4<<17;i++)F[i]=F[i-1]*i%mod;
	I[(4<<17)-1]=power(F[(4<<17)-1],mod-2);
	for(int i=(4<<17)-1;i--;)I[i]=I[i+1]*(i+1)%mod;
	long ans=0,N,K;
	cin>>N>>K;
	for(int i=0;i<N&&i<=K;i++)
	{
		ans+=C(N,i)*C(N-1,i)%mod;
	}
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 8448
# coding: utf-8
# Your code here!

n = int(input())
print(n, ": ", sep = "", end = "")

pri = []
while n % 2 == 0:
   pri.append(2)
   n //= 2

for i in range(3, int(n ** 0.5 + 1)):
   while n % i == 0:
      pri.append(i)
      n //= i
   i += 2

if n != 1:
   pri.append(n)

for i in range(len(pri)):
   print(pri[i], end = "")
   if i < len(pri) - 1:
      print(" ", end = "")
print("")


Measured memory_bytes: 5644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int h,w,d;
	cin >> h >> w >> d;
	int n = h*w;
	vector<int> x(n+1),y(n+1);
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			int a;
			cin >> a;
			y[a] = i;
			x[a] = j;
		}
	}
	vector<int> cost(n+1, 0);
	for(int i=1; i<=d; i++){
		for(int j=0; i+j+d<=n; j+=d){
			cost[i+j+d] = cost[i+j] +abs(x[i+j+d]-x[i+j]) +abs(y[i+j+d]-y[i+j]);
		} 
	}
	
	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		int l,r;
		cin >> l >> r;
		cout << cost[r]-cost[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define WHITE_C "."
#define BLACK_C "#"

#define WHITE_N 0
#define BLACK_N 1

int h, w, k;
int org_array[6][6];
char kind[12];
int w_array[6] = { 0, 0, 0, 0, 0, 0 };
int answer = 0;

void h_search(int next_h, int curent_num, unsigned char w_posi);

void w_search(int next_w, int curent_num, unsigned char w_posi)
{
	if (curent_num < k)
	{
		return;
	}


	if (next_w == (w-1)) {
		int diff = 0;

		h_search(0, curent_num, w_posi);

		for (int i = 0; i<w; i++)
		{
			if ((w_posi & (unsigned char)pow(2, i)) > 0)
			{

			} else {
				diff += org_array[0][i];
			}
		}
		h_search(0, (curent_num - diff), w_posi);
	} else {
		w_search((next_w + 1), curent_num, w_posi);
		w_search((next_w + 1), (curent_num - w_array[next_w+1]), (w_posi | (unsigned char)pow(2, (next_w+1))));
	}


	return;
}

void h_search(int next_h, int curent_num, unsigned char w_posi)
{

	int diff = 0;


	if (curent_num < k) {
		return;
	}
	
	
	if (next_h == (h-1)) {

		if (curent_num == k)
		{
			answer++;
		}
	}
	else {

		h_search((next_h + 1), curent_num, w_posi);

		for (int i = 0; i<w; i++)
		{
			if ((w_posi & (unsigned char)pow(2, i)) > 0)
			{

			}
			else {
				diff += org_array[next_h + 1][i];
			}
		}
		h_search((next_h + 1), (curent_num - diff), w_posi);

	}


	return;
}

int main()
{
	int current_num = 0;
	scanf("%d %d %d", &h, &w, &k);

	for (int i = 0; i<h; i++)
	{
		scanf("%s", kind);
		for (int j = 0; j<w; j++)
		{
			if (strncmp(WHITE_C, &kind[j], 1) == 0)
			{
				org_array[i][j] = WHITE_N;
			}
			else {
				org_array[i][j] = BLACK_N;
				w_array[j] ++;
				current_num++;
			}
		}
	}

	w_search(0, current_num, 0);
	w_search(0, (current_num - w_array[0]), (0 | (unsigned char)pow(2, 0)));

	printf("%d", answer);

	return 0;
}

Measured memory_bytes: 2544
#include <iostream>
#include <string>  
#include <cstdio> 
#include <queue> 
#include <algorithm> 
#define endl '\n' 

using namespace std ; 

priority_queue < int > qu ; 
 
int main()
{ 
	while(true){ 
		string s ; cin >> s ;
		if(s == "insert"){
			int num ; cin >> num ; 
			qu.push(num) ; 
		}
		else if(s == "extract"){ 
			cout << qu.top() << endl ;
			qu.pop() ; 
		}
		
		if(s == "end") break ; 
	}
		
	return 0 ;
}



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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define fil(a,b) memset((a),(b),sizeof(a))
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i <= int(b); i++)
#define per(i,a,b) for (int i=(a); i >= int(b); i--)
#define foreach(it,c) for (auto it=(c).begin(); it != (c).end(); it++)

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { cin>>x; }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
template<typename T>
void _W(const vector<T> &x) {
    for (auto i = x.cbegin(); i != x.cend(); i++) {
        if (i != x.cbegin()) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U> void W(const T& head, const U&... tail) {
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef double db;

const int inf = 0x3f3f3f3f;
// const ll inf = 0x3f3f3f3f3f3f3f3f;
const db pi = 3.14159265358979323846264338327950288L;
const db eps = 1e-6;
const int mo = 1e9+7;

int main() {
    ll a, b, c;
    R(a,b,c);
    if (a == b && a == c) W((a % 2 == 0) ? "-1" : "0");
    else {
        int ans = 0;
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            ll ta = b / 2 + c / 2;
            ll tb = a / 2 + c / 2;
            ll tc = a / 2 + b / 2;
            a = ta, b = tb, c = tc;
            ans++;
        }
        W(ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define f(x) ((a*x/b)-a*(x/b))
ll INF=1000000000000000001;
ll mod=1000000007;
 
ll i,j,k;

int main(){
    string s;cin>>s;
    if(s=="ABC"){cout<<"ARC"<<endl;}
    else{cout<<"ABC"<<endl;}
    return 0;
}

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

int main(){
	long long L, R, d;
	cin >> L >> R >> d;
	long long ans = 0;
	for(long long i = L; i <= R; i++){
		if(i%d == 0) {
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3592
from collections import defaultdict
from heapq import heappush, heappop
import math
import bisect
import random

def LI(): return list(map(int, input().split()))
def I(): return int(input())
def LIM(): return list(map(lambda x:int(x) - 1, input().split()))
def LS(): return input().split()
def S(): return input()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


n = I()

for i in range(n):
    for j in range(i + 1, n):
        k = 0
        while (i ^ j) & (1 << k) == 0:
            k += 1
        print(k + 1, end = ' ')
    print('')

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int h,w; cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  bool goodx[110],goody[110];
  rep(i,110){
    goodx[i] = false;
    goody[i] = false;
  }
  
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#'){
	goodx[i] = true;
	goody[j] = true;
      }
    }
  }

  rep(i,h){
    if(goodx[i]){
      rep(j,w){
	if(goody[j]){
	  cout << a[i][j];
	}
      }
      cout << endl;
    }    
  }
  
  return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

int n,a,b;
int max_b = 0;
vector<pair<ll,int> > bug;


//segtree
pair<ll,int> data[2<<17];
int segn2;


void seg_clear(int n){
    segn2 = 1;
    while(segn2 < n) segn2*=2;
    
    for(int i=0;i<(2<<17);i++){
        data[i] = {0LL,0}; //sum_a,count
    }
}

void add(int K_){
    int k = K_+segn2-1;
    
    data[k].first += K_;
    data[k].second += 1;
    
    
    while(k>0){
        k = (k-1)/2;
        
        data[k].first = data[k*2+1].first + data[k*2+2].first;
        data[k].second = data[k*2+1].second + data[k*2+2].second;
    }
}

ll query(int x,int k=0){
    if(x <= 0) return 0;
    if(data[k].second <= x) return data[k].first;
    
    if(k >= segn2-1){
        assert(x<=data[k].second);
        return (data[k].first/data[k].second)*x;
    }
    
    if(data[k*2+1].second <= x)
        return data[k*2+1].first + query(x-data[k*2+1].second,k*2+2);
    else
        return query(x,k*2+1);
}

int check(int x){
    
    seg_clear(max_b+2);
    
    for(int i=0;i<n;i++){
        ll t = bug[i].first;
        add(bug[i].second);
        
        while(1){
            if(i+1>=n || t!=bug[i+1].first) break;
            i++;
            
            add(bug[i].second);
        }
        
        if(i+1>=x){
            
            ll q = query(x);
            
            //cerr << x << ":" << (-t)*x << ">=" << q << endl;
            
            if((-t)*x >= q){
                return true;
            }
        }
    }
    
    return false;
}

int main(){
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        bug.push_back({-b,a});
        max_b = max(max_b,b);
    }
    
    sort(bug.begin(),bug.end());
    
    int l=0,r=n,mid;
    while(l<r){
        mid = (l+r+1)/2;
        
        if(check(mid))
            l = mid;
        else
            r = mid-1;
    }
    
    printf("%d\n",l);
    
    return 0;
}

Measured memory_bytes: 15292
import std.stdio, std.typecons, std.algorithm, std.conv;

void main() {
  for (int times; scanf("%d", &times), times != 0;) {
    double[][] dp = new double[][](10, 10);
    double[] d = new double[](10);
    double m = double.infinity, ans = -1;
    d[] = 0.0;
    foreach(ref i; dp)
      foreach(ref j; i) j = double.infinity;
    for(int i = 0; i < 10; i++) dp[i][i] = 0;
    foreach(t; 0..times) {
      int from, to, time;
      scanf("%d %d %d", &from, &to, &time);
      dp[from][to] = time.to!double;
      dp[to][from] = time.to!double;
    }
    
    for(int k = 0; k < 10; k++)
      for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        if (dp[i][j] != double.infinity) {
          d[i] += dp[i][j];
        }
      }
    }

    for(int i = 0; i < 10; i++) {
      if (m > d[i] && d[i] != 0) {
        m = d[i];
        ans = i;
      }
    }
    writeln(ans, " ", m);
  }
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
// #include <vector>
// #include <utility> 
// #include <unordered_map>
#include <map>
// #include <string>

using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = start; i >= end; i--)   //INCLUSIVE



int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n; cin>>n;
    lli a[n];
    rep(i, 0, n){
        cin>>a[i];
    }

    sort(a, a+n, greater<int>());

    int people=2;
    lli comfort = a[0];
    int i=1;
    while(i<n){
        if(people == n){
            break;
        }
        comfort+=a[i];
        people++;
        if(people == n){
            break;
        }
        people++;
        comfort+=a[i];
        i++;
    }
    cout<<comfort;
    return 0;
}

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

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

int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> a(n);
    rep(i,n){
        cin >> a[i].second >> a[i].first;
    }
    ll now=0;
    bool flag=true;
    sort(a.begin(),a.end());
    rep(i,n){
        now+=a[i].second;
        if(now>a[i].first){
            flag=false;
            break;
        }
    }
    if(flag) puts("Yes");
    else puts("No");

    return 0;
}







Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  double a, b, c, d, e, f, det, x, y;
  while(cin >> a >> b >> c >> d >> e >> f) {
	det = a * e - b * d;
	x = (double)(e * c - b * f) / det;
	y = (double)(-d * c + a * f) / det;
	if(x == -0.000) {
	  x = 0.000;
	}
	if(y == -0.000) {
	  y = 0.000;
	}
	printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

inline int read () {
	int ret = 0, t = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') t = -1, c = getchar();
	while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
	return ret * t;
}

int main () {
	int a = read(), b = read();
	if (a % b == 0) printf("%d\n", a / b); else printf("%d\n", a / b + 1);
	return 0;
}

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

#define MaxN 100005
#define INF 2140000000
#define MOD 1000000007

using namespace std;

int N,Ans=3;
char Mat[3][MaxN],c1,c2,c3;
int main()
{
    scanf("%d ",&N);
    cin.getline(Mat[1]+1,MaxN);
    cin.getline(Mat[2]+1,MaxN);
    if(Mat[1][1]!=Mat[2][1])
        Ans*=2;
    for(int i=2;i<=N;i++)
    {
        if(Mat[1][i]==Mat[1][i-1]&&Mat[2][i]==Mat[2][i-1])
            continue;
        if(Mat[1][i]==Mat[2][i]&&Mat[1][i-1]==Mat[2][i-1])
            Ans=2LL*Ans%MOD;
        else if(Mat[1][i]!=Mat[2][i]&&Mat[1][i-1]!=Mat[2][i-1])
            Ans=3LL*Ans%MOD;
        else if(Mat[1][i]!=Mat[2][i])
            Ans=2LL*Ans%MOD;
    }
    cout<<Ans;
    return 0;
}


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

int main(){
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;

  if(S[K-1]=='A'){S[K-1] = 'a';}
  else if(S[K-1]=='B'){S[K-1] = 'b';}
  else if(S[K-1]=='C'){S[K-1] = 'c';}

  cout << S << endl;

}


Measured memory_bytes: 256
from collections import deque
k = int(input())

que = deque()
que.append((1,1))
dist = [float("inf")]*k
while que:
    cost, cur = que.popleft()
    if dist[cur] <= cost:
        continue
    dist[cur] = cost
    # +1
    nxt = (cur+1)%k
    que.append((cost+1,nxt))
    # *10
    nxt = cur*10 % k
    que.appendleft((cost, nxt))
print(dist[0])

Measured memory_bytes: 46940
#include <iostream>

using namespace std;

int main() {
    int N;
    long a[1000000];
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> a[j];
    }
    long p = a[0] / 2;
    int t = int(a[0] % 2);
    for (int i = 1; i < N; ++i) {
        if (t == 1 && a[i] > 0) {
            a[i] --;
            p ++;
        }
        p += a[i] / 2;
        t = int(a[i] % 2);
    }
    cout << p;

    return 0;
}


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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)

bool uppercase(char c){
	if(c>='A'&&c<='Z') return true;
	return false;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
	string s;
	cin >> s;
	bool ans=true;
	if(s[0]!='A') ans=false;
	int tot=0;
	for(int i=2;i<=s.length()-2;i++) if(s[i]=='C') tot++;
	if(tot!=1) ans=false;
	forn(i,s.length()){
		if(uppercase(s[i])&&i!=0){
			if(s[i]=='C'&&(i<2||i==s.length()-1)) ans=false;
			else if(s[i]!='C') ans=false;
		}
	}
	if(ans) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;

}

Measured memory_bytes: 256
N, d = map(int, input().split())
P = [list(map(int,input().split())) for i in range(N)]

import numpy as np
p1 = np.array(P)
tmp_index = np.arange(p1.shape[0])
xx, yy = np.meshgrid(tmp_index, tmp_index)
distances = np.linalg.norm(p1[xx]-p1[yy], axis=2)
results = np.reshape(np.tril(distances), (1, N**2))


a = 0
for i in range(0, N**2):
  if(results[0][i]!=0 and results[0][i] == np.int64(results[0][i])):
    a += 1
print(a)
    

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

int main(){
  int n;
  cin >> n;
  set<string> s;
  for(int i=0; i<n; i++){
    string a;
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19264
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int v, d;
	vector<int> fib(1010);
	fib[0] = 2;
	fib[1] = 3;
	for (int i = 2; i < 1010; i++) {
		fib[i] = fib[i-1]+fib[i-2];
		fib[i] %= 1001;
	}
	while (cin >> v >> d) {
		vector<int> f(v);
		for (int i = 0; i < v; i++) {
			f[i] = fib[i];
		}
		sort(f.begin(), f.end());
		int c = 1;
		for (int i = 1; i < v; i++) {
			if (f[i]-f[i-1]>=d) {
				c++;
			} 
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
using namespace std;
int main(){
  string s;
  int a;
  bool f = false;
  map<int,pair<int,int> > log;
  while(getline(cin,s)){
    if(s.find(',') == string::npos){f = true;continue;}
    sscanf(s.c_str(),"%d,%*d",&a);
    if(f) log[a].second |= 1;
    else log[a].second |= 2;
    log[a].first++;
  }
  for(map<int,pair<int,int> >::iterator i = log.begin(); i!=log.end(); i++)
    if(i->second.second == 3)
      cout <<i->first<<" "<<i->second.first<<endl;
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>

int solve(int,int);

int n,A[20];

int main(){
  int q,m;
  int i;
  int sol;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if (solve(0,m) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i,int m)
{
  int res;
  
  if (m == 0) return 1;
  if (i >= n) return 0;
  res = (solve(i+1,m) || solve(i+1,m-A[i]));
  return res;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	string s;
	cin>>s;
	bool flag = 1;
	for(int i=1; i<sz(s); i++) {
		if(s[i]==s[i-1]) {
			flag =0;
			break;
		}
	}
	cout<<(flag?"Good\n":"Bad\n");
    return 0;
}



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

int main(){
  int n;
  long int a[5000],sum,ans;

  while(1){
    cin >> n;
    if(n==0) break;
    sum=0;
    ans=-1000000;
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    for(int i=0;i<n;i++){
      sum=0;
      for(int j=0;i+j<n;j++){
	sum+=a[i+j];
	if(ans<sum){
	  ans=sum;
	}
      }
    }
      cout << ans << endl;
  }

}

Measured memory_bytes: 1188
k = int(input())
row = [1] * 8
col = [1] * 8
dpos = [1] * 15
dneg = [1] * 15
X = [['.' for j in range(8)] for i in range(8)]
for i in range(k):
    r, c = map(int, input().split())
    row[r] = col[c] = dpos[r+c] = dneg[r-c+7] = 0
    X[r][c] = 'Q'
 
def s(i):
    while i < 8 and not row[i]:i += 1        
    if i == 8:
        for i in range(8):
            print(''.join(X[i]))
    for j in range(8):
        if not col[j] or not dpos[i+j] or not dneg[i-j+7]: continue
        row[i] = col[j] = dpos[i+j] = dneg[i-j+7] = 0
        X[i][j] = 'Q'
        s(i+1)
        row[i] = col[j] = dpos[i+j] = dneg[i-j+7] = 1
        X[i][j] = '.'
s(0)


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <deque>
#include <numeric>
#include <set>
using namespace std;

typedef long long ll;

int prefix[5005];

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

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i = 0; i < n; ++i){
        fill(prefix, prefix + n, 0);
        prefix[i] = n - i;

        int st = i + 1, len = 0;
        while(st < n){
            while(st + len < n && s[len + i] == s[st + len]){
                ++len;
            }
            prefix[st] = len;
            if(len == 0){
                ++st;
                continue;
            }
            int k = 1;
            while(st + k < n && k + prefix[k + i] < len){
                prefix[st + k] = prefix[k + i];
                ++k;
            }
            st += k;
            len -= k;
        }

        for(int id = i; id < n; ++id){
            if(i + prefix[id] <= id){
                ans = max(ans, prefix[id]);
            }
        }
    }

    cout << ans << endl;
}

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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	set<int> s;
	for(int i = 0; i < 3; i++){
		int t; cin >> t;
		s.insert(t);
	}
	cout << s.size() << '\n';
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, K;
ll arr[100005];
ll fact[100005];
ll mod = 1000000007;
ll tot = 0;

ll factorial (ll num){
    if (num == 0) return fact[num] = 1;
    return fact[num] = num * factorial(num-1) % mod;
}

ll power (ll b, ll e){
    ll res = 1;
    while (e > 0){
        if (e % 2 == 1) res = res * b % mod;
        e /= 2;
        b = b * b % mod;
    }
    return res;
}

ll inverse (ll num){
    return power(num, mod-2);
}

/* Return nCr */
ll choose (ll n, ll r){
    return (fact[n] * inverse(fact[r]) % mod) * inverse(fact[n-r]) % mod;
}

int main() {
    cin >> N >> K;
    for (int i=0; i<N; i++){
        scanf("%lld", &arr[i]);
    }
    factorial(N);
    sort(arr, arr+N);
    for (int i=0; i<N; i++){
        if (i <= N-K){
            tot -= (arr[i] * choose(N-i-1, K-1) % mod);
            if (tot < 0) tot += mod;
        }
        //cout << tot << " ";
        if (i >= K-1){
            tot += (arr[i] * choose(i, K-1) % mod);
            tot %= mod;
        }
        //cout << tot << endl;
    }
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 3328
using System;

namespace Atc_0023
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong X = ulong.Parse(Console.ReadLine());
            int result = 0;

            while (true)
            {
                if (X < 500)
                {
                    break;
                }
                X = X - 500;
                result += 1000;
                
            }

            while (true)
            {
                if (X < 5)
                {
                    break;
                }

                X = X - 5;
                result += 5;
               
            }

            Console.WriteLine(result);

        }
    }
}


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

using namespace std;
typedef long long ll;
const ll MOD = 998244353;

int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> v(k);
  for (int i = 0; i < k; ++i)
    cin >> v[i].first >> v[i].second;
  vector<ll> sum(n + 1);
  sum[1] = 1;
  for (int i = 2; i <= n; ++i) {
    ll curr = 0;
    for (int j = 0; j < k; ++j) {
      if (v[j].first >= i)
        continue;
      int l = max(1, i - v[j].second);
      int r = i - v[j].first;
      curr += sum[r] - sum[l - 1];
    }
    curr %= MOD;
    if (curr < 0)
      curr += MOD;
    sum[i] = (sum[i - 1] + curr) % MOD;
  }
  ll ans = sum[n] - sum[n - 1];
  if (ans < 0)
    ans += MOD;
  cout << ans;
}

Measured memory_bytes: 4788
#include <iostream>
#include <string>
using namespace std;
int main(void){
	int s;
	int a, b, c, d;
	cin >> s;
	a = s/1000;
	b = (s-a*1000)/100;
	c = (s-a*1000-b*100)/10;
	d = s-a*1000-b*100-c*10;
	if(a+b+c+d == 7){cout << a << '+' << b << '+' << c << '+'<< d << "=7" << endl;return 0;}
	if(a+b+c-d == 7){cout << a << '+' << b << '+' << c << '-'<< d << "=7" << endl;return 0;}
	if(a+b-c+d == 7){cout << a << '+' << b << '-' << c << '+'<< d << "=7" << endl;return 0;}
	if(a+b-c-d == 7){cout << a << '+' << b << '-' << c << '-'<< d << "=7" << endl;return 0;}
	if(a-b+c+d == 7){cout << a << '-' << b << '+' << c << '+'<< d << "=7" << endl;return 0;}
	if(a-b-c+d == 7){cout << a << '-' << b << '-' << c << '+'<< d << "=7" << endl;return 0;}
	if(a-b+c-d == 7){cout << a << '-' << b << '+' << c << '-'<< d << "=7" << endl;return 0;}
	if(a-b-c-d == 7){cout << a << '-' << b << '-' << c << '-'<< d << "=7" << endl;return 0;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int N,M;
int mat[101][101];
int dp[1<<15][15];
int cost[1<<15][15];
 
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y>>r;
		mat[x-1][y-1]=r;
		mat[y-1][x-1]=r;
	}
	
	FOR(i,1<<N) {
		FOR(x,N) {
			dp[i][x]=1<<30;
			FOR(y,N) if(i&(1<<y)) cost[i][x]+=mat[x][y];
		}
	}
	
	dp[1][0]=0;
	for(int mask=0;mask<1<<N;mask++) {
		FOR(x,N) if((mask&(1<<x)) && dp[mask][x]<1<<30) {
			FOR(y,N) if(mat[x][y] && (mask&(1<<y))==0) {
				int addco=cost[mask][y]-mat[x][y];
				dp[mask|(1<<y)][y]=min(dp[mask|(1<<y)][y],dp[mask][x]+addco);
			}
		}
		FOR(x,N) if((mask&(1<<x)) && dp[mask][x]<1<<30) {
			int nmask=mask^(1<<x);
			int left=((1<<N)-1)^mask;
			for(int i=left; i>0; i=(i-1)&left) {
				int add=0;
				FOR(y,N) if(i&(1<<y)) add+=cost[nmask][y];
				dp[mask|i][x]=min(dp[mask|i][x],dp[mask][x]+add);
			}
		}
	}
	
	
	cout<<dp[(1<<N)-1][N-1]<<endl;
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, M;
  cin >> N >> M;
  ll x[N], y[N], z[N], rank[N] = {};
  rep(i, N) cin >> x[i] >> y[i] >> z[i];

  ll ans = 0;
  rep(d, 8){
    ll sx = (d & 4) / 2 - 1;
    ll sy = (d & 2) - 1;
    ll sz = (d & 1) * 2 - 1;
    ll tmp = 0;
    rep(i, N) rank[i] = x[i] * sx + y[i] * sy + z[i] * sz;
    sort(rank, rank+N, greater<ll>());
    rep(i, M) tmp += rank[i];
    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256