akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
//using ll = long long;
//using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    map<string, int> a;
    int ans = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        a[s] = 1;
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 19120
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(p[0] > p[1] ? p[0] - 1 : p[0]);

            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int cnt,ans=1e9;
string s;
int main(){
    cin>>s>>s;
    for(char c:s)
        if(c=='E')
           cnt++;
    for(char c:s){
        if(c=='E'){
            cnt--;
        }
        ans=min(ans,cnt);
        if(c=='W'){
            cnt++;
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 900
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int n=int.Parse(Console.ReadLine());
    string s=Console.ReadLine();
    int max=0;
    bool[] alpha_check=new bool[26];
    for(int i=1;i<n;i++)
    {
      string front=s.Substring(0,i);
      string back =s.Substring(i);
      int samenumber=0;
      for(int j=0;j<i;j++)
      {
        alpha_check[front[j]-'a']=true;
      }
      for(int j=0;j<n-i;j++)
      {
        if(alpha_check[back[j]-'a']==true){alpha_check[back[j]-'a']=false;samenumber++;}
      }
      if(samenumber>=max)max=samenumber;
    }
    Console.WriteLine(max);
  }
}

Measured memory_bytes: 13140
while True:
    try:
        N = int(input())
        B = map(int, input().split())
        prev = None
        result = list()
        for i in B:
            if prev is None:
                result.append(i)
            else:
                result.append(min(prev, i))
            prev = i
        result.append(prev)
        print(sum(result))
    except EOFError:
        break

Measured memory_bytes: 3060
#include <stdio.h>
#define N 500001

int A[N],H;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,largest,tmp;
  l = left(i);
  r = right(i);
  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
void buil_max_h(void){
  for(int i = H/2; i >= 1; i--) maxHeapify(i);
}

int main(){
  int i,n;
  scanf("%d",&H);
  for(i = 1; i <= H; i++){
    scanf("%d",&A[i]);
  }
  buil_max_h();
  for(i = 1; i <= H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
#define ALL(obj) (obj).begin(),(obj).end()
struct edge{
    ll to, cost;
};

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

// 数字の桁数
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// ---------------------------------------------

int main(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;

    ll ans = max(a * c, max(a * d, max(b * c, b * d)));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
 
int main(){
  string s;
  cin>>s;
  ll sum = 0;
  rep(i,s.size()-1){
    if (s.at(i) != s.at(i+1)){
      sum++;
    }
  }
  cout << sum << endl;
}

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

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

  vector<ll> h(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> h[i];

  //モンスターのHPを昇順に並べる
  sort(h.begin(), h.end());

  //必殺技をHPの高いモンスターに使用して残りの攻撃回数をカウントする
  ll ans = 0;
  for (int i = n - k - 1; i >= 0; --i) {
    ans += h[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *

n = int(input())
s = input()
s = [0 if t == 'o' else 1 for t in s]
x = [None]*n
for a, b in [(0,0), (0,1), (1,0), (1,1)]:
    x[0], x[1] = a, b
    flag = 1
    for i in range(2, n):
        x[i] = 1^x[i-2] if x[i-1]^s[i-1] else x[i-2]
    for i in range(n-1):
        if (x[i]^s[i])^(x[i-1] != x[i+1]):
            flag = 0
            break
    if flag and ((x[n-1]^s[n-1])^(x[n-2] != x[0])) == 0:
        x = ['S' if t == 0 else 'W' for t in x]
        print(*x, sep='')
        exit()
print(-1)


Measured memory_bytes: 7944
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n,t;
ll a[200010];
ll ans;
int main(){
	scanf("%lld%lld\n",&n,&t);
	rep(i,0,n)scanf("%lld\n",a+i);
	rep(i,1,n)ans+=min(a[i]-a[i-1],t);
	printf("%lld\n",ans+t);
}

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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;



int main() {
	int A,B,X;cin>>A>>B>>X;
	int answer=1e8;
	for (int i = 0; i < 100; ++i) {
		for (int j = 0; j < 100; ++j) {
			int cost=i*A+B*j;
			int water=i*1000+j*500;
			if (water >= X) {
				answer=min(answer,cost);
			}
		}
	}
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<string.h>
char s[1000001];
int main()
{
    scanf("%s",s);
    int ans=0,x=0,y=0;
    for(int i=0;i<strlen(s);i++)
    {
        if(x==y)
        {
            x++;
            if(s[i]=='p')
            ans--;
        }
        else
        {
            y++;
            if(s[i]=='g')
            ans++;
        }
    }
    printf("%d",ans);
}

Measured memory_bytes: 256
import numpy as np

H, W = map(int, input().split(' '))

S = np.array([[int(c == '.') for c in input()] for _ in range(H)])

up = S.copy()
down = S.copy()
left = S.copy()
right = S.copy()

for i in range(1, H):
    up[i] = (up[i - 1] + 1) * up[i]
    down[-i - 1] = (down[-i] + 1) * down[-i - 1]

for i in range(1, W):
    left[:, i] = (left[:, i - 1] + 1) * left[:, i]
    right[:, -i - 1] = (right[:, -i] + 1) * right[:, -i - 1]

print(np.max(up + down + left + right) - 3)


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

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

	if(n == 1){
		printf("Yes");
		return 0;
	}

	for(int i=2;i<10;i++){
		if(n%i==0){
			int b = n/i;
			if(b <10){
				printf("Yes");
				return 0;
			}
		}
	}

	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    vector<int> vec(3, 0);
    for(int i = 0; i < 3; i++)
        cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec[2]*10+vec[0]+vec[1] << endl;
    return 0;
}



Measured memory_bytes: 256
//Volume0-0060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		//declare
		String[] s;
		int C1,C2,C3,less;
		
		//input
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			less=0;
			s = sc.nextLine().split("\\s");
			C1 = Integer.parseInt(s[0]);
			C2 = Integer.parseInt(s[1]);
			C3 = Integer.parseInt(s[2]);

			//calculate
			for(int i=1;i<=10;i++){
				if(i != C1 &&
				   i != C2 &&
				   i != C3    ){
					if (i <= 20 - (C1 + C2)){
						less++;
					}
				}
			}
			
			//output
			if   (3 < less){System.out.println("YES");}
			else           {System.out.println("NO");}
		}
	}
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    int allsum = 0;
    cin >> n;
    vector<int> a(2 * n + 1, 0);
    vector<int> sum_a(n);
    for(int i = 0; i < 2 * n; i++){
        cin >> a[i];
        allsum += a[i];
    }
    int sub = 0;
    for(int i = 1; i < n; i++){
        sub += a[i];
    }
    
    for(int i = 0; i < n; i++){
        sum_a[i] = allsum - sub;
        sub = sub - a[i + 1] + a[n + i];
    }
    int max = *max_element(sum_a.begin(), sum_a.end());
    cout << max;
    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    int l[8], totallength = 0,ans=10000;
    for(int i = 0; i < 8; i++) {
        if(i < N) {
            cin >> l[i];
            totallength += l[i];
        } else {
            l[i] = 0;
        }
    }

    for(int i = 0; i < 256; i++) {
        for(int j = 0; j < 256; j++) {
            if(i&j){continue;}
            for(int k = 0; k < 255; k++) {
                if(!(i&k || j&k)) {
                    int first = 0, second = 0, third = 0, MP = 0;
                    for(int m = 0; m < 8; m++) {
                        if(i & (1 << m)) {
                            if(first > 0) {
                                MP += 10;
                            }
                            first += l[m];
                        }
                        if(j & (1 << m)) {
                            if(second > 0) {
                                MP += 10;
                            }
                            second += l[m];
                        }
                        if(k & (1 << m)) {
                            if(third > 0) {
                                MP += 10;
                            }
                            third += l[m];
                        }
                    }
                    if(first*second*third==0)continue;
                    int mimMP=abs(first-A)+abs(second-B)+abs(third-C)+MP;
                    if( abs(first-A)+abs(second-C)+abs(third-B)+MP < mimMP )mimMP= abs(first-A)+abs(second-C)+abs(third-B)+MP;
                    if( abs(first-B)+abs(second-A)+abs(third-C)+MP < mimMP )mimMP= abs(first-B)+abs(second-A)+abs(third-C)+MP;
                    if( abs(first-B)+abs(second-C)+abs(third-A)+MP < mimMP )mimMP= abs(first-B)+abs(second-C)+abs(third-A)+MP;
                    if( abs(first-C)+abs(second-A)+abs(third-B)+MP < mimMP )mimMP= abs(first-C)+abs(second-A)+abs(third-B)+MP;
                    if( abs(first-C)+abs(second-B)+abs(third-A)+MP < mimMP )mimMP= abs(first-C)+abs(second-B)+abs(third-A)+MP;
                    if(ans>mimMP)ans=mimMP;

                }
            }
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

template<class T> T getAs(){ T v; std::cin >> v; return v; }
inline int getInt(){ return getAs<int>(); }

int smemo[1024];
int memo[1024][110];

int main(){
  while(true){
    int L = getInt();
    int N = getInt();
    int M = getInt();
    int X = getInt();

    if(L + N + M + X == 0) break;

    {
      // Secret
      vector<int> s(N);
      vector<int> e(N);

      REP(i, 1024) smemo[i] = 0;
      
      REP(i,N){
	string name = getAs<string>();
	e[i] = getInt();
	s[i] = getInt();
      }

      REP(i,N) smemo[e[i]] = max(smemo[e[i]], s[i]);
      REP(i,N) for(int j = i + 1; j < N; j++){
	int ee = e[i] + e[j];
	int ss = s[i] + s[j];

	if(ee <= L){
	  smemo[ee] = max(smemo[ee], ss);
	}
      }

      REP(i, L){
	smemo[i + 1] = max(smemo[i], smemo[i + 1]);
      }
      //REP(i, L + 1) printf("smemo[%d]: %d\n",i, smemo[i]);
    }

    {
      // normal
      vector<int> s(M);
      vector<int> e(M);

      REP(i,M){
	string name = getAs<string>();
	e[i] = getInt();
	s[i] = getInt();
      }

      REP(i, 1024) REP(j, M + 1)
	memo[i][j] = -1;
      memo[0][0] = 0;

      REP(i,M){
	for(int j = L; j >= 0; j--){
	  REP(k, i + 1) if(memo[j][k] >= 0){
	    int ee = e[i] + j;
	    int ss = s[i] + memo[j][k];

	    if(ee <= L)
	      memo[ee][k + 1] = max(memo[ee][k + 1], ss);
	  }
	}
      }

      int ans = 0;
      REP(i, L + 1) for(int j = X; j <= M; j++){
	int rest = L - i;

	if(memo[i][j] >= 0 && smemo[rest] > 0){
	  ans = max(ans, smemo[rest] + memo[i][j]);
	}
      }

      printf("%d\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 1376
x1,y1,x2,y2 = map(int,input().split())

s,t = x2-x1, y2-y1

x3,y3 = x2-t, y2+s

s,t = x3-x2, y3-y2

x4,y4 = x3-t, y3+s

print(x3,y3,x4,y4)

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

const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x = 0): x((x % mod + mod) % mod) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        return mint(*this) += a;
    }
    mint operator-(const mint a) const {
        return mint(*this) -= a;
    }
    mint operator*(const mint a) const {
        return mint(*this) *= a;
    }
    mint pow(long long t) const {
        if (!t) {
            return 1;
        }
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) {
            a *= *this;
        }
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, const mint& a) {
    return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
    return os << a.x;
}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) {
            return 0;
        }
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(200005);

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

    int n, m, k;
    cin >> n >> m >> k;

    mint ans = 0;
    mint color = m;
    for (int x = n - 1; x >= 0; --x) {
        mint now = color;
        now *= comb(n - 1, x); // 色のパターンにグループの分け方を掛ける
        if (x <= k) {
            ans += now;
        }
        color *= m - 1; // 色のパターン数を計算してる
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> t(N), d(N);
    for (ll i = 0; i < N; i++) {
        cin >> t[i] >> d[i];
    }
    
    vector<llll> di(N);
    for (ll i = 0; i < N; i++) {
        di[i] = make_pair(d[i], i);
    }

    sort(ALL(di), greater<llll> ());
    ll tmp, ans; ans = 0;
    for (ll i = 0; i < K; i++) {
        ans += di[i].first;
    }
    set<ll> S, Si;
    for (ll i = 0; i < K; i++) {
        S.insert(t[di[i].second]);
        Si.insert(di[i].second);
    }
    ll x = S.size();
    ans = ans + x * x;

    map<ll, ll> m;
    priority_queue<ll> p;
    for (ll i = 0; i < N; i++) {
        if(!S.count(t[i])){
            if(m.count(t[i])){
                m[t[i]] = max(d[i], m[t[i]]);
            }
            else{
                m[t[i]] = d[i];
            }
        }
    }
    for (auto v : m){
        p.push(v.second);
    }

    map<ll, llll> mm;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    for (ll i = 0; i < N; i++) {
        if(S.count(t[i])){
            if(mm.count(t[i])){
                mm[t[i]] = max(make_pair(d[i], i), mm[t[i]]);
            }
            else{
                mm[t[i]] = make_pair(d[i], i);
            }
        }
    }
    for (ll i = 0; i < N; i++) {
        if(S.count(t[i])){
            if(mm[t[i]].second != i && Si.count(i)){
                q.push(d[i]);
            }
        }
    }

    tmp = ans;
    while(!p.empty() && !q.empty()){
        ll v = p.top(); p.pop();
        ll w = q.top(); q.pop();
        tmp += v; tmp -= w;
        tmp -= x*x; x++;
        tmp += x*x;
        ans = max(tmp, ans);
    }

    printf("%lld\n", ans);

}

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

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<double>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    input();
    ll n,final=1;
    cin>>n;
    vector<ll>ans(n+1,1);
    rep(i,2,n+1)
    {
    	for(ll j=1;j*i<=n;j++)
    	{
    		ans[j*i]++;
    	}
    	final+=i*ans[i];
    }
    cout<<final;
}





Measured memory_bytes: 81316
#include <iostream>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) if (scanf("%d", &v)<1);
#define out(v) printf("%d\n", v)

int main() {
  int N; in(N);

  int X[N], sorted[N];
  rep(i, N) {
    in(X[i]);
    sorted[i] = X[i];
  }
  sort(sorted, sorted+N);
  int center_l = sorted[(N-1)/2], center_r = sorted[N/2];
  rep(i, N) {
    int index = lower_bound(sorted, sorted+N, X[i]) - sorted;
    out(index < N/2 ? center_r : center_l);
  }

  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ long long
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
long long n,m,i,j,mod1=1e9+7,mod2=1e9+9,e=1e6+3,inv1,inv2,p1,p2,f1[250005],f2[250005],ans;
string st;
map<pair<long long,long long>,long long> mp;
long long qp(long long x,long long y,long long mod)
{
	if (y==0) return 1;
	long long z=qp(x,y/2,mod);
	z=z*z%mod;
	if (y&1) z=z*x%mod;
	return z;
}
int main()
{
	inv1=qp(e,mod1-2,mod1);
	inv2=qp(e,mod2-2,mod2);
	scanf("%lld",&n);
	rdst(st,250005);st=" "+st;
	p1=p2=1;
	fz1(i,n)
	{
		f1[i]=f1[i-1];f2[i]=f2[i-1];
		if (st[i]=='+')
		{
			(f1[i]+=p1)%=mod1;
			(f2[i]+=p2)%=mod2;
		}
		if (st[i]=='-')
		{
			(f1[i]+=mod1-p1)%=mod1;
			(f2[i]+=mod2-p2)%=mod2;
		}
		if (st[i]=='>')
		{
			(p1*=e)%=mod1;
			(p2*=e)%=mod2;
		}
		if (st[i]=='<')
		{
			(p1*=inv1)%=mod1;
			(p2*=inv2)%=mod2;
		}
		mp[make_pair(f1[i],f2[i])]++;
	}
	p1=p2=1;
	fz1(i,n)
	{
		ans+=mp[make_pair((f1[n]*p1+f1[i-1])%mod1,(f2[n]*p2+f2[i-1])%mod2)];
		if (st[i]=='>')
		{
			(p1*=e)%=mod1;
			(p2*=e)%=mod2;
		}
		if (st[i]=='<')
		{
			(p1*=inv1)%=mod1;
			(p2*=inv2)%=mod2;
		}
		mp[make_pair(f1[i],f2[i])]--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35848
a, b = map(int, input().split())

ans = 0
for i in [a-1,b]:
    if i % 2 == 1:
        if ((i+1) // 2) % 2 == 0:
            num_1 = 0
        else:
            num_1 = 1
    else:
        if (i // 2) % 2 == 0:
            num_1 = 0
        else:
            num_1 = 1
        num_1 = i ^ num_1
    ans = ans ^ num_1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
#define MAX_INPUT_NUM 3

int main()
{
    char inp[MAX_INPUT_NUM];
    for (int i = 0; i < MAX_INPUT_NUM; i++)
    {
        cin >> inp[i];
    }
    for (int i = 1; i < MAX_INPUT_NUM; i++)
    {
        if (inp[i] != inp[0])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// Date: 2020-08-28

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3);

    return 0;
}

Measured memory_bytes: 3600
n=gets.to_i()
while(n != 0)
  sumt = 0
  t=[]
  k = 0
  n.times do |i|
    t[i] = gets.to_i()
  end
  t.sort!
  t.each do |i|
    sumt += k
    k += i
  end
  puts sumt
  n=gets.to_i()
end

Measured memory_bytes: 6260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int a,b,c;
	int k,mx=0,sum=0;
	
	cin >> a >> b >> c;
	cin >> k;
	
	mx=max(max(a,b),c);
	sum=a+b+c-mx;

	for(int i=0;i<k;i++){
		mx=2*mx;
	}
	sum+=mx;
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()
S_list = list(S)
#print(S_list)
count = 0
if len(S_list) != A + B + 1:
  print("No")
else:
    if S_list[A] != "-":
      print("No")
    else:
      for i in S_list:
        if i == "-":
          count +=1
        else:
          continue
      if count == 1:
        print("Yes")
      else:
        print("No")

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

int main() {
  int N;
  cin >> N;
  string ns = to_string(N);
  int nn = 0;
  for(int i = 0; i < ns.size(); ++i) {
    nn += ns[i] - '0';
  }
  if(N % nn == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define sf(i,s) for(ll i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define inf 1e18
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tr(v,i) for(typeof(v).begin() i = v.begin(); i != v.end(); i++)
#define pre(v,x) (v.find(x) != v.end())
#define vpre(v,x) (find(all(v),x) != v.end())
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a % mod;
    else
    {
        ll t = power(a, b / 2);
        if (b % 2 == 0)
            return ((t % mod) * (t % mod)) % mod;
        else
            return ((((t % mod) * (t % mod)) % mod) * ((a % mod) % mod)) % mod;
    }
}
void solve()
{
  ll n,i,ans=0,s=0;
  cin>>n;
  ll a[n+1];
  f(i,0,n)
  {
      cin>>a[i];
      s=(s+a[i]);
  }
  f(i,0,n)
  {
      s-=a[i];
      ans+=((a[i]%mod)*(s%mod))%mod;
      ans=ans%mod;
  }
  cout<<ans<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
  //  cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> A(20);

int MC(int i,int m){
  if(m == 0) return 1;
  if(i >=N) return 0;
  int res = MC(i+1,m) || MC(i+1,m - A.at(i));
  return res;
}


int main() {
  int i;
  cin >> N;
  int q;
  for(int j = 0;j<N;j++){
    cin >> A.at(j) ;
  }
  cin >> q;
  int B[q];
  for(int j = 0;j<q;j++){
    cin >> B[j] ;
  }
  for(int j = 0;j<q;j++){
    if(MC(0,B[j])){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  vector<bool> g(n + 1, false);
  vector<int> c(n + 1, 0);

  int a_c = 0; int p_c = 0;
  REP(i, m) {
    int no;
    string r;
    cin >> no >> r;
    if(!g[no]) {
      if(r == "AC") {
        a_c++;
        p_c += c[no];
        g[no] = true;
      } else {
        c[no]++;
      }
    }
  }

  cout << a_c << " " << p_c << endl;
}


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

ll cd(ll x,ll y){
        if(x == 0 || y == 0) return max(x,y);
        else return(cd(y,x%y));
    }

int main(){
    ll A,B;
    cin >> A >> B;
    ll N = cd(A,B);
    map<int,int> mp;
    for(int i = 2;i <= sqrt(N);++i){
        while(N%i == 0){
            N /= i;
            mp[i] = 0;
        }
    }
    if(N != 1) mp[N] = 0; 
    cout << mp.size() + 1 << endl;
}

Measured memory_bytes: 256
import sys
table={}
def dfs(a,b):
    global table
    if not (a,b) in table:
        if a==0:return 1
        elif b==0 or a < 0:return 0
        table[(a,b)]=sum([dfs(a-i,b-1) for i in xrange(10)])
    return table[(a,b)]
for i in sys.stdin.readlines():
    print dfs(int(i.strip()),4)

Measured memory_bytes: 5068
/**
 *      ABC 63 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 01:58:41
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B; cin >> A >> B;
    A + B < 10 ? cout << A + B : cout << "error";

    return 0;
}

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	for(int i=0; i<100; i++){
		for(int j=0; j<100; j++){
			if(i*4+j*7==n){
				cout<<"Yes"<<endl;
				return;
			}
		}
	}
	cout<<"No"<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
($a,$b,$c,$d,$e,$f)=glob<>;
sub f{
	my($x,$y)=@_;
	$h{"@_"}//=$x*100+$y>$f||$x*$e<$y?-1:(f($x+$a,$y),f($x+$b,$y),f($x,$y+$c),f($x,$y+$d),$y/$x);
}
f($a,0);
f($b,0);
$_="$a 0";
$h{$_}>$h{$s}&&($s=$_)for keys%h;
($a,$b)=glob$s;
print$a*100+$b,$",$b;

Measured memory_bytes: 3584
n, m = map(int, input().split())
k = []
for i in range(m):
    s = list(map(int, input().split()))
    k.append(s[1:])
p = list(map(int, input().split()))

ans = 0
for patterns in range(2**n):
    ptn = bin(patterns)[2:].rjust(n, '0')
    light = True
    for i in range(m):
        num = 0
        for j in range(len(k[i])):
            num += int(ptn[k[i][j] - 1])
        if ((num+p[i]) % 2 == 1):
            light = False
    if light:
        ans += 1
print(ans)


Measured memory_bytes: 42736
#include <bits/stdc++.h> 
using namespace std; 
const int mod = 1e9 + 7;
// Returns sum of bitwise OR 
// of all pairs
long long int sumXOR(long long int arr[], int n) 
{ 
    long long int sum = 0; 
    for (int i = 0; i < 60; i++)  
    { 
        //  Count of zeros and ones 
        int zc = 0, oc = 0;  
          
        // Individual sum at each bit position
        long long int idsum = 0;
        for (int j = 0; j < n; j++) 
        {
            if (arr[j] % 2 == 0)
                zc++;
            else
                oc++;
            arr[j] /= 2;
        } 
          
        // calculating individual bit sum
        idsum = ((oc * ((zc * ((1ll << i) % mod)) % mod) % mod) % mod) % mod;  
  
        // final sum     
        sum = (sum + idsum) % mod;  
    } 
    return (sum + mod) % mod; 
} 
  
int main() 
{ 
    int n;
    cin >> n;
    long long int arr[n];
    for(int i = 0; i<n; i++)
    {
    	cin>>arr[i];
	}
    long long int sum = sumXOR(arr, n); 
    cout << sum; 
    return 0; 
}

Measured memory_bytes: 2560
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() 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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


x, y = LI()
ret = 0
for i in (x, y):
    if i == 1:
        ret += 300000
    elif i == 2:
        ret += 200000
    elif i == 3:
        ret += 100000


if x == 1 and y == 1:
    ret += 400000



print(ret)



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

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;

void solve() {
    int n, k;
    cin >> n >> k;

    vector<bool> dp(k+1); // dp[i] ~ whether player 1 wins if there are initially i stones
    // dp[i] = true if there exists x in A such that i-x >= 0 and dp[i-x] is false

    vector<int> a(n+1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            int x = a[j];
            if (i - x >= 0 && dp[i-x] == false)
                dp[i] = true;
        }
    }

    cout.precision(20);
    cout << ((dp[k] == true) ? "First" : "Second") << endl;
}


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



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

int main() {

    int N ;

    double M ;

    cin >> N >> M ;

    vector<int> vec(N) ;

    for ( int i = 0 ; i < N ; i++){

        cin >> vec[i] ;

    }

    int sum = 0;

    for ( int i = 0 ; i < N ; i++){

        sum += vec[i] ;

    }

    sort (vec.begin() , vec.end());
    reverse (vec.begin() , vec.end());

    if ( vec.at(M-1)  < sum/ (4*M) ) cout << "No" << endl ;

    else cout << "Yes" << endl ;

}

    

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

// スペース区切りの文字列から int のスライスを得る
func intSlice(s string) []int {
	ss := strings.Split(s, " ")
	res := make([]int, len(ss))
	for i, v := range ss {
		iv, _ := strconv.Atoi(v)
		res[i] = iv
	}

	return res
}

func main() {
	var n int
	fmt.Scan(&n)
	input := nextLine()
	ws := intSlice(input)

	ans := (1 << 32)
	for i := 0; i < n-1; i++ {

		var s1, s2 int
		for j, v := range ws {
			if j <= i {
				s1 += v
			} else {
				s2 += v
			}
		}

		a := absSub(s1, s2)

		if a < ans {
			ans = a
		}
	}

	fmt.Println(ans)
}

func absSub(s1, s2 int) int {
	if s1 > s2 {
		return s1 - s2
	} else {
		return s2 - s1
	}
}


Measured memory_bytes: 640
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 10

int
main(int argc, char **argv)
{
	int sum[MAX_N];
	int total;
	int n;
	int i, j;

	while (true)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		for (i = 0; i < n; ++i)
			sum[i] = 0;

		for (j = 0; j < n; ++j)
		{
			int x;

			total = 0;
			for (i = 0; i < n; ++i)
			{
				scanf("%d", &x);
				printf("%5d", x);
				sum[i] += x;
				total += x;
			}

			printf("%5d\n", total);
		}

		total = 0;
		for (i = 0; i < n; ++i)
		{
			printf("%5d", sum[i]);
			total += sum[i];
		}

		printf("%5d\n", total);
	}

	return 0;
}

Measured memory_bytes: 608
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a = readLine()!!.split(" ")
            .mapIndexed { index, s -> s.toLong()-(index+1) }
            .sorted()
    val med = a[n/2]

    a.map{ Math.abs(it-med) }
            .sum()
            .let{ println(it) }
}

Measured memory_bytes: 81780
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int A,B,T;
    cin >> A >> B >> T;
    cout << B*(T/A);
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
Hs = [int(input()) for _ in range(N)]
l, r = 0, 10**9+1
while r-l>1:
    half = (l+r)//2
    cum = 0
    for i in range(N):
        h = Hs[i]
        if h<=half*B:
            continue
        cum += -(-(h-half*B)//(A-B))
    if cum>half:
        l = half
    else:
        r = half

print(r)

Measured memory_bytes: 77772
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> d(n);
  rep(i,n){
      cin >> d[i];
  }
  sort(all(d));
  cout << d[n/2] - d[n/2-1] << endl;

}

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

int d, ans, m, x, q;
int c[30], s[370][30], lst[30];

int main() {
	int i, j, re, mx, mj;
	cin >> d;
	for(i=1; i<=26; i++) cin >> c[i];
	for(i=1; i<=d; i++) for(j=1; j<=26; j++) cin >> s[i][j];
	for(i=1; i<=d; i++) {
		mx = -1e9;
		for(j=1; j<=26; j++) {
			re = s[i][j] - c[j] * (i-lst[j]) * 6 + c[j] * 5;
			if(re > mx) {
				mx = re;
				mj = j;
			}
		}
		lst[mj] = i;
		cout << mj << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	
	while (1) {
		long long int n, m;

		cin >> n >> m;
		if (n == 0 && m == 0) {
			break;
		}

		vector< vector<long long int> > dp(256, vector<long long int>(n + 1, LINF));
		vector<long long int > c(m + 1);
		vector<long long int> x(n + 1);

		FOR(i, 1, m) {
			cin >> c[i];
		}
		FOR(i, 1, n) {
			cin >> x[i];
		}

		dp[128][0] = 0;

		long long int now;

		long long int mini = LINF;

		LFOR(i, 1, n) {
			LFOR(k, 0, 255) {
				if (dp[k][i - 1] != LINF) {
					LFOR(j, 1, m) {
						if (k + c[j] > 255) {
							now = 255;
						}
						else if (k + c[j] < 0) {
							now = 0;
						}
						else {
							now = k + c[j];
						}

						dp[now][i] = min(dp[now][i],dp[k][i - 1] + (now - x[i])*(now - x[i]));
					}
				}
			}

		}

		FOR(i, 0, 255) {
			mini = min(mini, dp[i][n]);
		}

		cout << mini << endl;



	}



	
	

	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << max({a1, a2, a3}) - min({a1, a2, a3}) << endl;

    return 0;
}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N, K;
    cin >> N >> K;

    vector<int> u, v;
    for (int i=1; i<=N; ++i) {
        for (int j=i+1; j<=N; ++j) {
            if (K > 0 && i != 1) {
                K--;
                continue;
            }
            u.push_back(i);
            v.push_back(j);
        }
    }

    int M = u.size();
    if (M < N-1 || K > 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << M << endl;
    for (int i=0; i<M; ++i) {
        cout << u[i] << " " << v[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
m = []
for i in range(100):
	m.append([])
	for j in range(100):
		m[i].append('.' if (i//50 > 0) else '#')
a,b = map(int,input().split())
for i in range(1,a):
	x = (i // 50)*2
	y = (i % 50)*2
	m[x][y] = '.'
for i in range(1,b):
	x = 99 - (i // 50)*2
	y = 99 - (i % 50)*2
	m[x][y] = '#'
print("100 100")
for i in range(100):
	print(''.join(m[i]))


Measured memory_bytes: 3188
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A.sort(reverse=True)

ans = 0

print(sum(A[1::2][:N]))



Measured memory_bytes: 37852
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define pb push_back
using namespace std;
long long digs(long long x){
	long long res=0;
	while(x>0){
		res += x%10;
		x/=10;
	}
	return res;
}
int main(){
	int k;
	cin>>k;
	long long up=1, down=0;
	for(int i=0;i<k;i++){
		long long cur = up * (down+1) + down;
		if(up%10==0){
			long long cur2 = (up+9) * (down+1) + down;
			double re1,re2;
			re1 = cur * 1.0 / digs(cur);
			re2 = cur2 * 1.0 / digs(cur2);
			if(re1>re2){
				cur = cur2;
				down = down*10 + 9;
				up = up/10;
			}
		}
		cout<<cur<<endl;
		up++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

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

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

int main() {
	int N;
	scanf("%d", &N);
	int abc[26][50];
	SET_ZERO(abc);
	for (int i = 0; i < N; i++) {
		char str[51];
		scanf("%s", str);
		for (int  l = 0; str[l] != '\0'; l++) {
			unsigned t = str[l] - 'a';
			abc[t][i]++;
		}
	}

	string ans = "";
	for (int i = 0; i < 26; i++) {
		sort(&abc[i][0], &abc[i][0] + N);
		for (int j = 0; j < abc[i][0]; j++) {
			ans += (char)i + 'a';
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::vector<char> odd, even;
  for (i64 i = 0; i < static_cast<i64>(S.size()); i += 2) {
    odd.push_back(S[i]);
  }
  for (i64 i = 1; i < static_cast<i64>(S.size()); i += 2) {
    even.push_back(S[i]);
  }
  std::cout << (std::all_of(odd.begin(), odd.end(), [](const char& S_i) { return S_i != 'L'; }) && std::all_of(even.begin(), even.end(), [](const char& S_i) { return S_i != 'R'; }) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  cout << size(a) << endl;
}

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

void solve () {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    if (n >= m) {
        cout << 0;
        return;
    }
    sort(a.begin(), a.end());
    vector<int> dif(m - 1);
    for (int i = 1; i < m; i++) {
        dif[i - 1] = a[i] - a[i - 1];
    }
    sort (dif.rbegin(), dif.rend());
    long long sum = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += dif[i];
    }
    cout << accumulate(dif.begin(), dif.end(), 0) - sum;

}

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


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

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;


int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  
  int n;
  cin >> n;
  cout << n * (n - 1) / 2;
  return 0;
}

Measured memory_bytes: 256