akhauriyash/Code-Regression huggingface dataset:
#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++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


const int MAX = 1000005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    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;
    }
}

long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


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

    COMinit();
    int n; cin >> n;
    vector<int> a(n+1, 0), cnt(n+1, 0);
    int twice;
    rep(i, n+1){
        cin >> a[i];
        ++cnt[a[i]];
        if(cnt[a[i]]==2) twice=a[i];
    }

    int left=-1, right;
    rep(i, n+1){
        if(a[i]==twice && left==-1) left=i;
        else if(a[i]==twice) right=i;
    }

    repr(k, 1, n+2){
        ll ans= COM(n+1, k) - (left+n-right<k-1? 0:COM(left+n-right, k-1));
        chmod(ans);
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 25472
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> p(n+1);
    for( int i = 1; i <= n; i++ ) cin >> p[i];
    int cnt = 0;
    for( int i = 1; i <= n; i++ ) {
        if( i == p[i] ) {
            if( i != n ) swap( p[i], p[i+1] );
            else swap( p[i], p[i-1] );
            cnt++;
        }
    }
    dump( cnt );
    return 0;  
}

Measured memory_bytes: 640
def abc106_b():
    n = int(input())
    count = 0
    for i in range(1, n+1, 2):
        div = 0
        for j in range(1, i+1, 2):
            if i%j==0:
                div += 1
        if div == 8:
            count += 1

    return count


print(abc106_b())

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

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

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

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


//入力
int n, l;


int main(){

    cin >> n >> l;

    int _max = l + n - 1, _min = l;

    if(_max >= 0 && _min <= 0){
        int ans = 0;
        for(int i = _min; i <= _max; i++){
            ans += i;
        }
        cout << ans << endl;
        return 0;
    }
    else if(_max < 0){
        int ans = 0;
        for(int i = _min; i < _max; i++){
            ans += i;
        }
        cout << ans << endl;
        return 0;
    }
    else{
        int ans = 0;
        for(int i = _min+1; i <= _max; i++){
            ans += i;
        }
        cout << ans << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 998244353
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve(){
    char c;
    cin>>c;
    if(c>='a'&&c<='z'){
        cout << 'a';
    }
    else{
        cout << 'A';
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3656
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

h,w,m = readInts()
countx = defaultdict(set)
county = defaultdict(set)
cx,cy = defaultdict(int),defaultdict(int)
for i in range(m):
	x,y = readInts()
	countx[x].add(y)
	county[y].add(x)
	cx[x]+=1
	cy[y]+=1

maxxv = max(cx.values())
maxyv = max(cy.values())
maxxi = [i for i in countx if len(countx[i])==maxxv]
maxyi = [i for i in county if len(county[i])==maxyv]

ans = maxyv+maxxv

for i in maxxi:
	for j in maxyi:
		if j not in countx[i]:
			print(ans)
			exit()

print(ans-1)

Measured memory_bytes: 348292
from functools import reduce
from fractions import gcd


def main():
    N, X = map(int, input().split(" "))
    x = list(map(int, input().split(" ")))
    abs_x = []
    for i in x:
        abs_x.append(abs(X - i))
    print(reduce(gcd, abs_x))


if __name__ == '__main__':
    main()

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

int getSaroundBombNum(std::vector<std::vector<std::string>> map,int height,int width);

int main(int argc, char const *argv[]) {

        int W,H;
        std::cin >> H >> W;

        std::vector<std::vector<std::string> > bombMap(H,std::vector<std::string>(W));
        for (size_t height = 0; height < H; height++) {
            std::string map_data;
            std::cin >> map_data;
            for (size_t width = 0; width < W; width++) {
                bombMap[height][width] = map_data[width];
            }
        }


        for (size_t height = 0; height < H; height++) {
            for (size_t width = 0; width < W; width++) {
                if(bombMap[height][width] == "."){
                    int bombNum = getSaroundBombNum(bombMap,height,width);
                    bombMap[height][width] = std::to_string(bombNum);
                }
            }
            putchar('\n');
        }

        for (size_t height = 0; height < H; height++) {
            for (size_t width = 0; width < W; width++) {
                std::cout << bombMap[height][width];
            }
            putchar('\n');
        }

        return 0;
}

int getSaroundBombNum(std::vector<std::vector<std::string>> map,int y,int x)
{
    int bomb_num = 0;
    for(int delta_y = -1 ; delta_y <= 1 ; delta_y++ )
    {
        for(int delta_x = -1 ; delta_x <= 1 ; delta_x++ )
        {
            int pos_y = y;
            int pos_x = x;
            pos_y += delta_y;
            pos_x += delta_x;
            if( pos_y < 0 || pos_y > map.size()-1)
                continue;
            if( pos_x < 0 || pos_x > map[0].size()-1)
                continue;

            if(map[pos_y][pos_x] == "#")
                bomb_num++;
        }
    }
    return bomb_num;
}


Measured memory_bytes: 384
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdlib>

#define REP(i,n) for(long long i = 0;i < n;i++)
typedef long long ll;

using namespace std;

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

    ll N = 0;
    cin >> N;
    ll A[N];
    REP(i,N){
        cin >> A[i];
    }
    ll co_large[N];
    //start by large
    if(N % 2 == 0) {
        ll num2 = (N - 2) / 2;
        REP(i,num2)
            co_large[i] = -2;
        co_large[num2] = -1;
        co_large[num2 + 1] = 1;
        for(int i = num2 + 2;i < N;i++)
            co_large[i] = 2;
    }else {
        ll num2 = (N - 2) / 2 + 1;
        REP(i,num2)
            co_large[i] = -2;
        co_large[num2] = 1;
        co_large[num2 + 1] = 1;
        for(int i = num2 + 2;i < N;i++)
            co_large[i] = 2;
    }
    //start by small
    ll co_small[N];
    if(N % 2 == 0){
        ll num2 = (N - 2) / 2;
        REP(i,num2)
            co_small[i] = -2;
        co_small[num2] = -1;
        co_small[num2 + 1] = 1;
        for(int i = num2 + 2;i < N;i++)
            co_small[i] =2;
    }else{
        ll num2 = (N - 2) / 2;
        REP(i,num2)
            co_small[i] = -2;
        co_small[num2] = -1;
        co_small[num2 + 1] = -1;
        for(int i = num2 + 2;i < N;i++)
            co_small[i] = 2;
    }
    sort(A,A + N);
    ll diff_large = 0;
    REP(i,N){
        diff_large += A[i] * co_large[i];
    }
    ll diff_small = 0;
    REP(i,N){
        diff_small += A[i] * co_small[i];
    }
    ll diff = max(diff_small,diff_large);

    cout << diff << endl;



    return 0;
}


Measured memory_bytes: 2560
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main (String [] args){
		//		String [][] boad = new String[4][4];
		List <Integer> list = new ArrayList<Integer>();
//		String s = sc.next();
		int answer = 0;
		int in = Integer.parseInt(sc.next());
//		int c = 0;
		String d = null;
		if(in == 1){
			d = "Hello World";
		}else{
			int in2 = Integer.parseInt(sc.next());
			int in3 = Integer.parseInt(sc.next());
			int b = 0;

			d = String.valueOf(in2 + in3);
		}

		
//		for(int i = 0;i<n;i++){
//			list.add(Integer.parseInt(sc.next()));
//		}
		
		System.out.println(d);
		System.out.flush();
		sc.close();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int N,T,x=10000;
  	cin >> N >> T;
  	int a[N][2];
    for (int i = 0;i < N;i++)
    {
    	cin >> a[i][0] >> a[i][1];
    }
    for (int j=0;j<N;j++)
    {
    	if (x > a[j][0] && T >= a[j][1])
     		{
    			x = a[j][0];
    		}
    }
  if(x!=10000)
  cout << x << endl;
  else
    cout << "TLE " << endl;
}

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

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

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

int dp[11000];

signed main(void) {
	int H, N;
	cin >> H >> N;
	vector<int>value, weight;
	rep(k, N) {
		int i, j;
		cin >> i >> j;
		value.pb(j);
		weight.pb(i);
	}
	rep(i, 11000)dp[i] = mod;
	dp[0] = 0;

	rep(i, N) {
		rep(j, H+1) {
			int nj = max((int)0, j - weight[i]);
			dp[j] = min(dp[j], dp[nj] + value[i]);
		}
		//rep(j, H) {
		//	cout << "i=" << j << " " << dp[j] << endl;
		//}

	}

	print(dp[H]);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
//vector<pair<int,int>>g[100050];
#define pi pair<int,int>
#define pb push_back
#define f first
#define s second
#define inf (int)1e10
int dp[3333][3333];
int a[3333];
int ok(int l ,int r)
{
    if(l>r)return 0;
    if(l==r)return a[l];
    if(dp[l][r]!=-inf)return dp[l][r];
    return(dp[l][r] = max(a[l]-ok(l+1,r),a[r]-ok(l,r-1)));
   
}

void solve()
{
 int n;
 cin >>n; 
  
  for(int i=0;i<n;i++)cin >> a[i];

  cout<<ok(0,n-1)<<"\n";


}

int32_t main()
{
    int t=1;

    while(t--)
    {
         for(int i=0;i<3333;i++)
        for(int j=0;j<3333;j++)
          dp[i][j]=-inf;
        solve();
    }
}


Measured memory_bytes: 87168
#include <cstdio>
#include <algorithm>

const int N = 2e5;

int s[N + 5]; 

int main() {

    int n, m;
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) 
        scanf("%d", &s[i]);
    std::sort(s + 1, s + n + 1); 
    m = std::unique(s + 1, s + n + 1) - (s + 1); 

    printf("%s\n", n == m ? "YES" : "NO");

    return 0; 
}

Measured memory_bytes: 896
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
import itertools as itr

N = int(input())
As = list(map(int, sys.stdin.readline().rstrip().split()))
As_p = [0] * (N+1)
As_x = [0] * (N+1)

for i in range(N):
  As_p[i+1] = As_p[i] + As[i]
  As_x[i+1] = As_x[i] ^ As[i]

i_l,i_r = 0,1
ans = 0
while i_r <= N:
  p = As_p[i_r] - As_p[i_l]
  x = As_x[i_r] ^ As_x[i_l]
  if p == x:
    if i_r - i_l > 1:
      ans += i_r - i_l - 1
    i_r += 1
  else:
    i_l += 1

print(ans+N)

Measured memory_bytes: 29740
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int W = sc.nextInt();
        if(W >= S) {
        	System.out.println("unsafe");
        }else {
        	System.out.println("safe");
        }
        }
	}


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

int main() {
  string s;
  getline(cin, s);
  
  for(int i =0; i < s.size();i++){
    if(s.at(i)>='a' && s.at(i) <='z'){
      s.at(i)-= 0x20;
    }else if(s.at(i)>='A' && s.at(i) <= 'Z'){
      s.at(i)+=0x20;
    }
  }
  cout << s<<endl;
}


Measured memory_bytes: 3180
#include<stdio.h>

#include<stdio.h>
int main(){
  int step=0,i,j,num,tmp;
  int a[100];

  scanf("%d",&num);

  for(i=0;i<num;i++) scanf("%d",&a[i]);

  for(i=0;i<(num-1);i++){
    for(j=(num-1);j>i;j--){
      if(a[j-1] > a[j]){
        tmp = a[j-1];
        a[j-1] = a[j];
        a[j] = tmp;
        step++;
      }
    }
  }
  for(i = 0;i < num-1;i++) printf("%d ",a[i]);
  printf("%d",a[num-1]);
  printf("\n");
  printf("%d\n",step);
  return 0;
}

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

int main(){
  int N,k;
  cin>>N;
  vector<int> a(N,0);
  
  for(int i=0;i<N-1;i++){
    cin>>k;
    a[k-1]++;
  }
  for(int i=0;i<N;i++){
    cout<<a[i]<<endl;
  }
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define in(type,a) type a;cin >> a

using ll = long long;

int main() {
    in(int, a);
    cout << 3*a*a << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 *created by Kraken on 28-03-2020 at 17:05
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
		int[] res = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				int dis = Math.min(Math.abs(i - j), Math.min(Math.abs(i - x) + 1 + Math.abs(j - y), Math.abs(j - x) + 1 + Math.abs(i - y)));
				res[dis]++;
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < n; i++) {
			sb.append(res[i]).append("\n");
		}
		System.out.print(sb.toString());
	}

	static class FastReader {

		BufferedReader br;

		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


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

typedef long long ll;
#define fori(n) for(int i=0;i<n;i++)
#define pb push_back


ll power(ll base,ll e)
{
    ll answer=1;
    //ll e=1000000005;
    while(e)
    {
        if(e%2==1)
        {
            answer*=base;
        }
        base*=base;
       // base%=mod;
        e/=2;
       // answer%=mod;
    }
    return answer;
}

set<ll> ans;

void sieveprimes(ll n)
{
    bool prime[n+1];
    memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }

        }

    }

    /*for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";*/
    for(ll i=2;i<=n;i++)
    {
        if(prime[i])    ans.insert(i*i);
    }
}

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

    ll n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            {
                for(int k=1;k<=n;k++)
                {
                    sum+=gcd(i,gcd(j,k));
                }
            }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll K, N;
  cin >> K >> N;
  vll A(N);
  vll B(N);
  ll bmax = 0;
  ll result = 0;
  REP(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a;

    if (i > 0) {
      B[i - 1] = A[i] - A[i - 1];
      result += B[i - 1];
      if (bmax < B[i - 1]) {
        bmax = B[i - 1];
      }
    }
  }
  B[N - 1] = (K - A[N - 1]) + A[0];
  result += B[N - 1];
  if (bmax < B[N - 1]) {
    bmax = B[N - 1];
  }

  cout << result - bmax << endl;

  return 0;
}


Measured memory_bytes: 3456
# 解説放送

N, K = map(int, input().split())

e = [None for _ in range(N + 1)] # 種別の美味しさ
t_kinds_count = 0 # 何種類あるか
rest_length = 0 # 各種の2番手以降の個数の総数

tops = [] # 各種の最大美味しさ
c_tops = [0] # 各種の最大美味しさの累積和
rests = [] # 各種の2番手以降
c_rests = [0] # 各種の2番手以降の累積和

for _ in range(N):
    t, d = map(int, input().split())
    if e[t] is None:
        e[t] = []
        t_kinds_count += 1
    e[t].append(d)


for t in range(1, N + 1):
    if e[t] is None:
        continue
    e[t].sort(reverse=True)
    tops.append(e[t][0])
    rests.extend(e[t][1:])

tops.sort(reverse=True)
rests.sort(reverse=True)

s = 0
for tt in tops:
    s += tt
    c_tops.append(s)

s = 0
for rr in rests:
    s += rr
    c_rests.append(s)
    rest_length += 1

ans = 0
for yy in range(1, min(t_kinds_count, K) + 1):
    if 0 <= K - yy <= rest_length:
        ans = max(ans, c_tops[yy] + c_rests[K - yy] + yy * yy)

# print(e)
# print(tops)
# print(c_tops)
# print(rests)
# print(c_rests)
print(ans)


Measured memory_bytes: 23876
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n, x;
  cin >> n >> x;
  for(ll i = x-n+1; i <= x+n-1; i++){
    cout << i << (i!=x+n-1?' ':'\n');
  }
  return 0;
}

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

template <typename T>
void insertionSort(vector<T> &d, vector<T> &e);

int main() {
  vector<int> d(5, 0), e(5, 0);
  for (int i = 0; i < 5; ++i) {
    cin >> d[i];
    e[i] = ((int) ceil((double) d[i] / 10.0)) * 10;
  }
  
  insertionSort(d, e);
  
  cout << e[0] + e[1] + e[2] + e[3] + d[4] << endl;
  
  return 0;
}

template <typename T>
void insertionSort(vector<T> &d, vector<T> &e)
{
    for (int i = 1; i < d.size(); ++i)
    {
        T v = d[i], w = e[i];
        int j = i - 1;
        while (j >= 0 && e[j] - d[j] > w - v)
        {
            d[j + 1] = d[j];
            e[j + 1] = e[j];
            j--;
        }
        d[j + 1] = v;
        e[j + 1] = w;
    }
}

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

using namespace std;

string s;
int n;
vector<int> minv;

void updatelgr(int ind, int val) {
    minv[ind] = max(minv[ind], val + 1);
    if (ind > 0 && s[ind - 1] == '>') {
        updatelgr(ind - 1, val + 1);
    }
}

void updatergl(int ind, int val) {
    minv[ind] = max(minv[ind], val + 1);
    if (ind < n && s[ind] == '<') {
        updatergl(ind + 1, val + 1);
    }
}

void update(int ind) {
    if (ind > 0) {
        updatelgr(ind - 1, 0);
    }
    if (ind < n) {
        updatergl(ind + 1, 0);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> s;
    n = s.size() + 1;
    minv.assign(n, 0);
    if (s[0] == '<') {
        update(0);
    }
    if (s[n - 2] == '>') {
        update(n - 1);
    }
    for (int i = 1; i < n - 1; ++i) {
        if (s[i - 1] == '>' && s[i] == '<') {
            update(i);
        }
    }
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += minv[i];
        //cout << minv[i] << " ";
    }
    //cout << endl;
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 2844
N = int(input())
import math
sq = math.sqrt(N)

count = 0
min_num = N
while count <= sq:
    count += 1
    if N % count == 0:
        A = count
        B = N / count
        num = len(str(int(max(A, B))))
        if min_num > num:
            min_num = num
print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,k=0;
    cin>>n>>s;
    for(int i=0; s[i]; i++){
        if(i>=n){

                printf("...");
        break;
        }
        else{
            cout<<s[i];
        }
    }
}


Measured memory_bytes: 3724
import java.io.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] info = line.split(" ");
		int N = Integer.parseInt(info[0]);
		int M = Integer.parseInt(info[1]);
		
		System.out.println(N*(N-1)/2 + M*(M-1)/2);
	}
}

Measured memory_bytes: 21072
#include<stdio.h>
#include<ctype.h>
 
int main (void){
     
    char ch;
    int i=0,t;
    char str[1200] = {};
     
    while(1){
         
        scanf("%c",&ch);
        if(islower((int)ch) != 0){
        ch = toupper(ch);
        }else if(isupper((int)ch) != 0){
        ch = tolower(ch);
        }else{
            ;
        }
        str[i] = ch;
        i++;
    if( ch == '\n') break;
    }
     
    printf("%s",str);
return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string S; cin >> S;
    int N = S.size();
    ll sum = 0;
    ll d = 1;
    map<int,int> A;
    A[0]++;
    REPR(i,N-1){
        sum = (sum + (S[i]-'0')*d)%2019;
        A[sum] ++;

        d *= 10;
        d %= 2019;
    }
    ll ans = 0;
    for(auto a: A){
        //cout << a.first << " " << a.second << endl;
        ans += a.second*(a.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long Int;

int N, S;
char s[16], s2[16];

Int memo1[16][14 * 9];

Int func1(int N, int S)
{
	if (S < 0) return (0);
	if (N == 0) return (1);
	if (~memo1[N][S]) return (memo1[N][S]);
	
	Int ans = 0;
	for (int i = 0; i <= 9; i++){
		ans += func1(N - 1, S - i);
	}
	
	return (memo1[N][S] = ans);
}

Int pos;
Int fact[15], ten[15];

Int calcComb(int *a)
{
	Int den = 1, sum = 0;
	
	for (int i = 0; i <= 9; i++){
		sum += a[i]; den *= fact[a[i]];
	}
	
	return (fact[sum] / den);
}

Int prod;

void func2(int n, int sum, int l, Int tmp = 0, Int tprod = 1)
{
	if (sum < 0) return;
	if (n * l < sum) return;
	
	if (n == 0){
		if (sum == 0 && tprod < prod){
			int a[10] = {0};
			for (int i = 0; i < N; i++){
				a[tmp % 10]++; tmp /= 10;
			}
			pos += calcComb(a);
		}
		if (sum == 0 && tprod == prod){
			int a[10] = {0};
			for (int i = 0; i < N; i++){
				a[tmp % 10]++; tmp /= 10;
			}
			for (int i = 0; i < N; i++){
				for (int j = 0; j < s[i] - '0'; j++){
					if (a[j]){
						a[j]--;
						pos += calcComb(a);
						a[j]++;
					}
				}
				if (a[s[i] - '0']) a[s[i] - '0']--;
				else break;
			}
		}
		return;
	}
	
	Int orig = tmp;
	for (int i = min(l, sum); i >= 0; i--){
		tmp = tmp + i * ten[N - n];
		func2(n - 1, sum - i, i, tmp, tprod * (i + 1));
		tmp = orig;
	}
}

int main()
{	
	fact[0] = ten[0] = 1;
	for (int i = 1; i <= 14; i++){
		fact[i] = i * fact[i - 1];
		ten[i] = 10 * ten[i - 1];
	}
	
	scanf("%s", s);
	prod = 1;
	for (int i = 0; s[i]; i++){
		S += s[i] - '0';
		prod *= (s[i] - '0' + 1);
		N++;
	}
	
	memset(memo1, -1, sizeof(memo1));
	pos = func1(N, S - 1);
	
	func2(N, S, 9);
	
	printf("%lld\n", pos);
	
	return (0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    vector <int> v;
    for (int i = 0; i < n; ++ i) {
        int x; cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    auto chk = [&] (int forbid) {
        if (v[forbid] >= k) return 0;
        vector <vector <int> > dp(n + 1, vector <int> (k, 0));
        dp[0][0] = 1;
        for (int i = 0; i < n; ++ i) if (i != forbid) {
            for (int j = 0; j < k; ++ j) {
                if (j >= v[i]) dp[i + 1][j] |= dp[i][j - v[i]];
                dp[i + 1][j] |= dp[i][j];
            }
        } else dp[i + 1] = dp[i];
        for (int i = k - v[forbid]; i < k; ++ i) if (dp[n][i]) return 0;
        return 1;
    };
    if (!chk(0)) {
        cout << 0 << endl;
        return 0;
    }
    int lb = 0, rb = v.size() - 1;
    while (lb < rb) {
        int md = lb + rb + 1 >> 1;
        if (chk(md)) lb = md;
        else rb = md - 1;
    }
    cout << lb + 1 << endl;
    return 0;
}

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

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			var input_arr = Console.ReadLine().Split(' ');
			int a = int.Parse(input_arr[0]); int b = int.Parse(input_arr[1]);
			int d = (int)Math.Floor((double)a / b);
			int r = a % b;
			string str_d = $"{(double)a / b:F6}";
			Console.WriteLine($"{d} {r} {str_d}");
		}
	}
}



Measured memory_bytes: 17984
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    n = getN()
    nums = getList()
    
    b1, b2 = sorted(nums)[n//2 - 1], sorted(nums)[n//2]
    for i, num in enumerate(nums):
        if num <= b1:
            print(b2)
        else:
            print(b1)
def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


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

int main() {
  string s;
  int K;
  cin >> K >> s;
  if (s.size() <= K) {
    cout << s << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
# ABC129D - Lamp
def main():
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for x1 in range(H):
        for y1 in range(W):
            if S[x1][y1] == ".":  # left and upper sides of S[i][j]
                U[x1][y1] = U[x1 - 1][y1] + 1
                L[x1][y1] = L[x1][y1 - 1] + 1
            x2, y2 = -x1 - 1, -y1 - 1
            if S[x2][y2] == ".":  # right and under sides
                D[x2][y2] = D[x2 + 1][y2] + 1
                R[x2][y2] = R[x2][y2 + 1] + 1
    ans = -float("inf")
    for i in range(H):
        for j in range(W):
            x = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
            if x > ans:
                ans = x
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 176600
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 300000
#define INF 1000000000000000000LL
using namespace std;
typedef long long LL;
int N;
LL T[MAXN+5],sum[MAXN+5];
LL L[MAXN+5],R[MAXN+5];
int que[MAXN+5];
LL f[MAXN+5],h[MAXN+5],g[MAXN+5],ans[MAXN+5];
LL GetY(int j)
{
	return 1LL*f[j]+(1LL*j*j-1LL*j)/2LL+sum[j];
}
void Rev(LL seq[])
{
	for(int i=1;i<=N/2;i++)
		swap(seq[i],seq[N-i+1]);
}
void DP()
{
	int s=0,t=0;
	que[t++]=0;
	fill(f+1,f+1+N,-INF);
	for(int i=1;i<=N;i++)
	{
		while(s<t-1)
		{
			int j1=que[t-2],j2=que[t-1];
			LL y1=GetY(j1),y2=GetY(j2);
			if((y1-y2)>1LL*i*(1LL*j1-1LL*j2))
				t--;
			else
				break;
		}
		int j=que[t-1];
//		printf("fro:%d to:%d\n",j,i);
		f[i]=f[j]+((1LL*i-1LL*j)*(1LL*i-1LL*j+1LL))/2LL-(1LL*sum[i]-1LL*sum[j]);
		f[i]=max(f[i],f[i-1]);
		while(s<t-1)
		{
			int j1=que[t-2],j2=que[t-1];
			LL y1=GetY(que[t-2]),y2=GetY(que[t-1]),y3=GetY(i);
			if((1LL*y1-1LL*y2)*(1LL*j2-1LL*i)<(1LL*y2-1LL*y3)*(1LL*j1-1LL*j2))
				que[--t]=0;
			else
				break;
		}
		que[t++]=i;
	}
}
void MergeSort(int l,int r)
{
	if(l==r)
	{
		if(l!=0)
			g[l]=max(g[l],L[l-1]+R[l+1]+1LL-(sum[l]-sum[l-1]));
		else
			g[l]=0;
		return;
	}
	int mid=(l+r)/2;
	MergeSort(l,mid);
	int s=0,t=0;
	for(int i=l;i<=mid;i++)
	{
		f[i]=L[i];
		while(s<t-1)
		{
			int j1=que[t-2],j2=que[t-1];
			LL y1=GetY(que[t-2]),y2=GetY(que[t-1]),y3=GetY(i);
			if((1LL*y1-1LL*y2)*(1LL*j2-1LL*i)<(1LL*y2-1LL*y3)*(1LL*j1-1LL*j2))
				que[--t]=0;
			else
				break;
		}
		que[t++]=i;
	}
	for(int i=mid+1;i<=r;i++)
	{
		while(s<t-1)
		{
			int j1=que[t-2],j2=que[t-1];
			LL y1=GetY(j1),y2=GetY(j2);
			if((y1-y2)>1LL*i*(1LL*j1-1LL*j2))
				t--;
			else
				break;
		}
		int j=que[t-1];
//		if(i==3)
//			printf("fro:%d\n",j);
		h[i]=f[j]+((1LL*i-1LL*j)*(1LL*i-1LL*j+1LL))/2LL-(1LL*sum[i]-1LL*sum[j])+R[i+1];
	}
	for(int i=r-1;i>=mid+1;i--)
		h[i]=max(h[i],h[i+1]);
	for(int i=mid+1;i<=r;i++)
		g[i]=max(g[i],h[i]);
	MergeSort(mid+1,r);
}
int main()
{
	fill(ans+1,ans+1+MAXN,-INF);
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%lld",&T[i]);
	for(int i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	//处理初始DP
	//处理前缀DP数组 
	DP();
	for(int i=1;i<=N;i++)
		L[i]=f[i];
	//处理后缀DP数组 
	Rev(T);
	for(int i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	DP();
	for(int i=1;i<=N;i++)
		R[i]=f[N-i+1];
	Rev(T);
	for(int i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	//处理完成 
	//开始CDQ分治(计算必须选择某个元素的最大值)
	//先从左往右算贡献
	fill(f+1,f+1+N,-INF);
	fill(h+1,h+1+N,-INF);
	fill(g+1,g+1+N,-INF);
	MergeSort(0,N);
	for(int i=1;i<=N;i++)
		ans[i]=max(ans[i],g[i]);
	//再从右往左算贡献 
	Rev(T);
	for(int i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	for(int i=1;i<=N;i++)
		swap(L[i],R[N-i+1]);
	fill(f+1,f+1+N,-INF);
	fill(h+1,h+1+N,-INF);
	fill(g+1,g+1+N,-INF);
	MergeSort(0,N);
	for(int i=1;i<=N;i++)
		ans[i]=max(ans[i],g[N-i+1]);
	Rev(T);
	for(int i=1;i<=N;i++)
		sum[i]=sum[i-1]+T[i];
	for(int i=1;i<=N;i++)
		swap(L[i],R[N-i+1]);
	//预处理完成 
	//开始回答询问
	int M,P;
	LL X;
	scanf("%d",&M);
	for(int i=1;i<=M;i++)
	{
		scanf("%d %lld",&P,&X);
		LL ansn=max(L[P-1]+R[P+1],ans[P]-X+T[P]);
		printf("%lld\n",ansn);
	}
	return 0;
}
/*
4
3 5 1 6
5
2 1
4 2
3 1
1 1

*/

Measured memory_bytes: 22400
use proconio::{input,fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
  input!{n: usize, m: usize};
  let mut good_peaks = vec![true; n];
  input!{peaks: [usize; n]};
  for _ in 0..m {
    input!{a: Usize1, b: Usize1};
    if peaks[a] == peaks[b] {
      good_peaks[a] = false;
      good_peaks[b] = false;
    } else if peaks[a] < peaks[b] {
      good_peaks[a] = false;
    } else {
      good_peaks[b] = false;      
    }
  }
  println!("{}", good_peaks.into_iter().filter(|&x| x).count());
}

Measured memory_bytes: 5080
#include<iostream>
using namespace std;
int main()
{
  long long r,d,x;
  cin>>r>>d>>x;
  for(int i=0;i<10;++i)
  {
    int y=r*x-d;
    cout<<y<<'\n';
    x=y;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SORT(x) sort(all(x));
#define DSORT(x) sort(all(x), greater<>());
#define PI 3.14159265358979323846264338327950288
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;
bool prime(int n){for(int i=2;i<=sqrt(n);i++){if(n%i==0){return 0;}}return 1;}
void normal(int &a) {a=a%mod;(a<0)&&(a=a+mod);}
int Add(int a,int b) {a=a%mod,b=b%mod; normal(a),normal(b); return (a+b)%mod; }
int Sub(int a,int b) {a=a%mod,b=b%mod; normal(a),normal(b); a=a-b; normal(a); return a; }
int Mul(int a,int b) {a=a%mod,b=b%mod; normal(a),normal(b); return (a*b)%mod;}
int Pow(int n,int x){int res=1; while(x){ if(x&1) res=Mul(res,n); n=Mul(n,n); x=x>>1;} return res;} 
int modInverse(int n){return Pow(n,mod-2);}
int Div(int a,int b) { return Mul(a, modInverse(b));}
const int E3 = 1e3 + 7;
const int E4 = 1e4 + 7;
const int E5 = 1e5 + 7;
const int E6 = 1e6 + 7;
const int E9 = 1e9 + 7;


int n;
signed main(){
    fio;
    cin>>n;
    if(n==0)
    	cout<<1;
    else if(n==1)
    	cout<<0;
    return 0;
}



Measured memory_bytes: 3692
#include <stdio.h>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
struct cmp{
  bool operator()(const pi &a,const pi &b){
      return a.S>b.S;
  }  
};
int main(){
    int n,ans=0,last=0;
    pi temp;
    priority_queue<pi,vector<pi>,cmp>pq;
    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&temp.F,&temp.S);
        pq.push(temp);
    }
    while(!pq.empty()){
        if(pq.top().F<=last)pq.pop();
        else{
            ans++;
            last=pq.top().S;
            pq.pop();
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3344
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, temp, count;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			uint64 t = mask;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			while (~map[t].first) {
				--t;
			}
			while (++t <= (mask >> 1)) {
				mkey = map[t];
				map[t].first = ~static_cast<std::uint_fast64_t>(0);
				temp = mask&hash64(mkey.first);
				while (~map[temp].first) {
					temp = mask&(temp + 1);
				}
				map[temp] = mkey;
			}
			for (t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<std::uint_fast64_t>(0);
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(250);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

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

int main(){
  int A[3],mx,mn;
  for(int i=0; i<3; ++i) cin >> A[i];
  mx=max(max(A[0],A[1]),A[2]);
  mn=min(min(A[0],A[1]),A[2]);
  cout << mx-mn << endl;
}

Measured memory_bytes: 256
x = input()
x = [int(i) for i in x]
xCount = len(x)

aaa = 0
for i in range(2**(xCount -1)):
    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(xCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    for i in range(xCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+' 
        
        if binaryNumber[i] == 0 :
            binaryNumber[i] = '-'
            
    
    result = [None]*(len(x)+len(binaryNumber))
    result[::2] = x
    result[1::2] = binaryNumber
    
    result = map(str, result)
    resultStr = ''.join(result)
    a = eval(resultStr)    
    #print(resultStr)
    #print(a)
    if (a == 7) :
        print(str(resultStr) + '=7')
        break

    




Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int d[] = new int[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
        	d[i] = sc.nextInt();
        }
        for(int i = 0; i < n - 1; i++){
        	for(int j = i + 1; j < n; j++){
            	ans += d[i] * d[j];
            }
        }
        System.out.println(ans);
	}
}

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

#define ll long long

using namespace std;

const ll INF = 2e18;

int q;
ll n, a, b, c, d;

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

    cin >> q;
    while (q--){
        cin >> n >> a >> b >> c >> d;
        map<ll, ll> dp;
        map<ll, bool> vis;

        dp[n] = 0;
        priority_queue<ll> pq;
        pq.push(n);
        while (!pq.empty()){
            auto temp = pq.top();
            pq.pop();
            if (vis[temp]) continue;
            vis[temp] = 1;

            ll dpcur = dp[temp];
            for (ll i=-4;i<=4;i++){
                ll delta = abs(i) * d;
                ll ncur = i + temp;
                if (ncur >= 0){
                    if (ncur == 0){
                        if (dp[ncur] == 0) dp[ncur] = dp[temp] + delta;
                        else dp[ncur] = min(dp[ncur], dp[temp] + delta);
                        continue;
                    }
                    if (ncur % 2 == 0){
                        ll sim = dp[ncur / 2];
                        if (sim != 0) dp[ncur / 2] = min(sim, dp[temp] + delta + a);
                        else dp[ncur / 2] = dp[temp] + delta + a;
                        pq.push(ncur / 2);
                    }
                    if (ncur % 3 == 0){
                        ll sim = dp[ncur / 3];
                        if (sim != 0) dp[ncur / 3] = min(sim, dp[temp] + delta + b);
                        else dp[ncur / 3] = dp[temp] + delta + b;
                        pq.push(ncur / 3);
                    }
                    if (ncur % 5 == 0){
                        ll sim = dp[ncur / 5];
                        if (sim != 0) dp[ncur / 5] = min(sim, dp[temp] + delta + c);
                        else dp[ncur / 5] = dp[temp] + delta + c;
                        pq.push(ncur / 5);
                    }
                }
            }
        }
        ll ans = INF;
        for (auto x : dp){
            if (x.first >= INF / d) continue;
            ans = min(ans, x.second + x.first * d);
        }
        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 9596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sOd = Console.ReadLine().Trim();
            string sEv = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "";
            for (int i = 0; i < sOd.Length; i++)
            {
                sOut += sOd.Substring(i, 1);
                if (sEv.Length > i) { sOut += sEv.Substring(i, 1); }
            }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int n; cin >> n;
    ll ans = 0;
    rep(i,n){
        if((i+1) % 3 == 0 || (i+1)% 5 == 0){
            continue;
        }else{
            ans += i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007;

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll n , i , k ;
    cin >> n >> k ;
    ll h[n] ;
    for(i=0 ; i<n ; i++){
        cin >> h[i] ;
    }
    ll dp[n] ;
    dp[0]=0 ;
    dp[1]=abs(h[1]-h[0]) ;
    for(i=2 ; i<n ; i++){
        dp[i]=M ;
        for(ll j=i-1 ; j>=max(0LL , i-k) ; j--){
            dp[i] = min(dp[j] + abs(h[i]-h[j]) , dp[i]) ;
         }
    }
    cout << dp[n-1] ;
    
    
    return 0 ;
}

Measured memory_bytes: 1792