akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define maxn 1000050
int n, t;
int ask[maxn];
inline int maxl(int x, int y){
	return x > y ? x : y;
}
inline int minl(int x, int y){
	return x < y ? x : y;
}
int main(void)
{
//	freopen("hat.in", "r", stdin);
//	freopen("hat.out", "w", stdout);
//	scanf("%d", &t);
//	while (t--){
		scanf("%d", &n);
		register int minn = n, maxx = 0, sum = 0, num = 0, hat;
		for (int i = 1;i <= n; i++){
			scanf("%d", &ask[i]);
			minn = minl(minn, ask[i]), maxx = maxl(maxx, ask[i]);
		}
		if (maxx - minn >= 2){
			printf("No\n");
//			continue;
			return 0;
		}
		if (maxx == minn && maxx == n - 1){
			printf("Yes\n");
//			continue;
			return 0;
		}
		for (int i = 1;i <= n; i++){
			if(ask[i] == maxx - 1){
				++sum;
			}else{
				++num;
			}
		}
		hat = maxx - sum;
		if (hat * 2 > num || hat <= 0){
			printf("No\n");
//			continue;
		}
		else printf("Yes\n");
	
//	}
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n;
ll a[100000],b[100000];

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

	cin>>n;
	REP(i,n) cin>>a[i]>>b[i];
	reverse(a,a+n);reverse(b,b+n);
	ll sum=0;
	REP(i,n) {
		a[i]+=sum;
		if(a[i]%b[i]==0) continue;
		ll cnt=(a[i]/b[i]+1)*b[i]-a[i];
		sum+=cnt;
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }

    sort(v.begin(), v.end());
    int numtri = 0, sum=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            while(v[i]==v[j]){
                j++;
            }
            sum = v[i]+v[j];
            for(int k=n-1; k>j; k--){
                if(v[k]==v[j]){
                    break;
                }
                if(sum>v[k]){
                    numtri++;
                }

            }
            
        }

        
    }

    cout<<numtri<<'\n';

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
 
using namespace std;
 
int conv(char c)
{
    if ('0' <= c && c <= '9') return (c - '0');
    if ('A' <= c && c <= 'Z') return (c - 'A' + 10);
    return (c - 'a' + 36);
}
 
int main()
{
    int n;
    vector<int> nim;
     
    scanf("%d", &n);
     
    for (int i = 0; i < n; i++){
        int p; char s[1024];
        scanf("%d %s", &p, s);
         
        int d = 0;
        for (int i = 0; s[i]; i++){
            int x = conv(s[i]);
            d = d * p + x;
        }
         
        int prev = 0;
        for (int i = 18; i >= 0; i--){
            if (d >> i & 1) prev = prev * 2 + 1;
            else {
                nim.push_back(prev); prev = 0;
            }
        }
        nim.push_back(prev);
    }
     
    int xo = 0;
    for (int i = 0; i < nim.size(); i++) xo ^= nim[i];
     
    if (!xo) printf("lose\n");
    else printf("win\n");
     
    return (0);
}

Measured memory_bytes: 11156
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll calcNumOfCombination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll calcNumOfPermutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  ll n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  ll nc, mc;
  if ((n + m) % 2 == 0) {
    nc = factorial(n);
    mc = factorial(m);
    cout << 2 * (nc * mc) % mod << endl;
  } else {
    nc = factorial(n);
    mc = factorial(m);
    cout << nc * mc % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		boolean jdg =true;
		for(int i =  c.length()-1;i >=2;i-=1) {
			if(i%2==1)continue;
			for(int k = 0;k < i/2;k++) {
				if(c.charAt(k) != c.charAt(k+(i/2))) {
					jdg = false;
					break;
				}
			}
			if(jdg == true) {
				System.out.println(i);
				break;
			}
			jdg = true;
		}
	}

}


Measured memory_bytes: 23760
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, A: number[], B: number[] } => {
  const N = +lines[0]
  const A = lines[1].split(' ').map(line => +line)
  const B = lines[2].split(' ').map(line => +line)
  const obj = { N, A, B }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, A: monsters, B: heros } = parseLines(lines)

  let killed = 0
  for (let i = 0; i < N; i++) {
    if (heros[i] > monsters[i]) {
      killed += monsters[i]
      const remainPower = heros[i] - monsters[i]
      if (remainPower >= monsters[i+1]) {
        killed += monsters[i+1]
        monsters[i+1] = 0
      } else {
        killed += remainPower
        monsters[i+1] = monsters[i+1] - remainPower
      }
    } else {
      killed += heros[i]
    }
  }
  return `${killed}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 30808
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 1000010;
const long long MOD = 1000000007;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init() {
  inv[1] = 1;
  for (int i=2; i<MAX_SIZE; i++) {
    inv[i] = ((MOD - inv[MOD%i]) * (MOD/i))%MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i=1; i<MAX_SIZE; i++) {
    fact[i] = (i * fact[i-1])%MOD;
    factinv[i] = (inv[i] * factinv[i-1])%MOD;
  }
}

long long C(int n, int k) {
  if (n >=0 && k >= 0 && n-k >= 0) {
    return ((fact[n] * factinv[k])%MOD * factinv[n-k])%MOD;
  }
  return 0;
}

long long power(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n%2 == 1) {
    return (x * power(x, n-1)) % MOD;
  } else {
    long long half = power(x, n/2);
    return (half * half) % MOD;
  }
}

long long gcm(long long a, long long b) {
  if (a < b) {
    return gcm(b, a);
  }
  if (b == 0) return a;
  return gcm(b, a%b);
}

int main() {
  init();
  ll N, M;
  cin >> N >> M;
  if (abs(N - M) > 1) {
    cout << 0 << endl;
  } else if (abs(N - M) == 1) {
    cout << (fact[N] * fact[M])%MOD << endl;
  } else {
    cout << (2 * fact[N] * fact[M])%MOD << endl;
  }
}


Measured memory_bytes: 23680
H,W = map(int,input().split())
mat = []
for i in range(H):
    a = list(input())
    mat.append(a)

def search(y,x):
    if mat[y][x] == '#':
        y2 = [0,0,1,-1]
        x2 = [1,-1,0,0]
        for i in range(4):
            if 0<=y+y2[i]<=H-1 and 0<=x+x2[i]<=W-1:
                if mat[y+y2[i]][x+x2[i]] == '#':
                    return True
        return False
    
    return True
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if ans == 'No':
            break
        if search(i,j):
            continue
        else:
            ans = 'No'
            break
print(ans)

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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

const int N = 3e5 + 20;
ll n, a[N], ans;

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= 3 * n; i++)
		cin >> a[i];
	sort(a + 1, a + 1 + 3 * n);
	for (int i = n + 1; i <= 3 * n; i += 2)
		ans += a[i];
	cout << ans << endl;
}



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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

string s;

int main()
{
    cin>>s;
    int n=s.size();
    string former,latter;
    former=s.substr(0,(n-1)/2);
    latter=s.substr((n+1)/2);
    reverse(latter.begin(),latter.end());
    if(former==latter){

        int m=former.size();
        string subf,subl;
        if(m%2==0){
            subf=former.substr(0,m/2);
            subl=former.substr(m/2);
        }else{
            subf=former.substr(0,(m-1)/2);
            subl=former.substr((m+1)/2);
        }
        reverse(subl.begin(),subl.end());
        if(subf==subl){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            cout<<"No" <<endl;
            return 0;
        }
    }else{
        cout<<"No" <<endl;
        return 0;
    }

    return 0;

}




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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


vector<bool> seen;  // 訪問済みの点
vector<ll> dist;

int main()
{
    int N, M;
    cin >> N >> M;

    // グラフ
    Graph G(3*N);

    REP(i, M){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1 + N);
        G[a-1 + N].push_back(b-1 + 2*N);
        G[a-1 + 2*N].push_back(b-1);
    }

    int S, T;
    cin >> S >> T;

    vector<int> dist(3*N, -1);
    queue<int> que;

    dist[S-1] = 0;
    que.push(S-1);

    while(!que.empty()){
        int p;
        p = que.front();
        que.pop();

        for(int next :G[p]){
            // もし次のノードが訪問済みなら処理を飛ばす
            if(dist[next] != -1) continue;

            dist[next] = dist[p] + 1;
            que.push(next);
        }
    }
    
    if(dist[T-1] == -1){
        cout << -1 << endl;
    }
    else{
        cout << dist[T-1]/3 << endl;
    }
    return 0;
}

Measured memory_bytes: 17792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        long n = scan.nextInt();
        
        long ans = 1;
        long a = bignum();
        for(int i=0;i<n;i++)
        {
            ans = (ans*(i+1))%a;
        }
        System.out.println(ans);
    }
    
    static long bignum(){
        int i=0;
        long ans=1;
        while(i<9)
        {
            ans*=10;
            i++;
        }
        return ans+7;
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,k;
  cin >> n >> k;
  vl h;
  inputv(h,n);
  vl dp(n+k,INF);
  dp[0] = 0;
  rep(i,n){
    rep(j,k){
      dp[i+1+j] = min(dp[i+j+1], (dp[i] + abs(h[i+j+1] - h[i])));
    }
                                   }
                                   
  cout << dp[n-1];
    
 return 0;
}

Measured memory_bytes: 1908
type UF
	n::Int
	pr::Array{Int}
	sz::Array{Int}
	UF(n)=new(n,1:n,ones(Int,n))
end
function find(uf::UF,a::Int)
	if uf.pr[a]==a
		a
	else
		uf.pr[a]=find(uf,uf.pr[a])
	end
end
same(uf::UF,a::Int,b::Int)=find(uf,a)==find(uf,b)
function unite(uf::UF,a::Int,b::Int)
	a=find(uf,a)
	b=find(uf,b)
	if a==b
		false
	else
		if uf.sz[a]<uf.sz[b]
			uf.pr[a]=b
			uf.sz[b]+=uf.sz[a]
		else
			uf.pr[b]=a
			uf.sz[a]+=uf.sz[b]
		end
		true
	end
end
size(uf::UF,a::Int)=uf.sz[find(uf,a)]
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	pr=-ones(Int,M)
	uf=UF(N)
	for i=1:N
		L=map(x->parse(Int,x),split(readline()))
		shift!(L)
		for l=L
			if pr[l]<0
				pr[l]=i
			else
				unite(uf,pr[l],i)
			end
		end
	end
	for i=1:N
		if !same(uf,1,i)
			println("NO")
			exit()
		end
	end
	println("YES")
end
main()


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  list<ll> lis;
  ll q;
  cin >> q;
  auto itr = lis.end();

  REP(i,q){
    ll com;
    cin >> com;
    if(com == 0){
      ll x;
      cin >> x;
      itr = lis.insert(itr,x);
    }
    else if(com == 1){
      ll d;
      cin >> d;
      if(d >= 0) for(ll j=1;j<=d;j++) ++itr;
      else for(ll j=1;j<=abs(d);j++) --itr;
    }
    else{
      itr = lis.erase(itr);
    }
  }

  IREP(i,lis) cout << (*i) <<endl;


  return 0;
}




Measured memory_bytes: 18572
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
ll r=1;
a=a%m;
while(b>0)
{
if(b&1)
r=(r*a)%m;
b=b/2;
a=(a*a)%m;
}
return r%m;
}

vi bit;//1-based indexing

void bit_update(ll x,ll n,ll val)
{
    while(x<n)
    {
        bit[x]+=val;
        x+=(x&(~x+1));
    }
}

ll bit_sum(ll x)
{
    ll sum=0;
    while(x>0)
    {
        sum+=bit[x];
        x-=(x&(~x+1));
    }
    return sum;
}
bool pos(ll x,ll n,ll m)
{
    double nn=n;
    double xx=x;
    ll c=ceil(nn/xx);
    c--;
    ll y=n/(x);
    y=y*1LL*(x-1);
    ll t=n%(x);
    if(t>0)t--;
    ll z;
    if(x==1)
    {
        z=1;
    }
   else if(x==2)z=n+1;
    else if(x==3)z=2*n;
    else z=2*n+((x-3)*n)/2;

    if(y+t+c<=m&&z>=m)return true;
    return false;
}


int main(){
    IOS

     int n;
     cin>>n;
    vi b(n-1);
    rep(i,0,n-1)cin>>b[i];
    vi a(n,INT_MAX);
    ll s=0;
    rep(i,0,n-1)
    {
       a[i]=min(a[i],b[i]);
       s+=a[i];
       a[i+1]=b[i];
    }
    s+=a[n-1];
    cout<<s;


}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import random

N,M = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(M)]
#%%
ans = -1
for i in range(1000):
    L = len(str(i))
    if L!=N:
        continue
    a = [0]*L
    tmp = i
    for j in range(L):
        a[L-j-1] = tmp%10
        tmp //= 10
    
    for s,c in sc:
        if a[s-1] != c:
            break
    else:
        if N==1:
            print(i)
        else:
            if a[L-N]!=0:
                print(i)
            else:
                continue
        
        sys.exit()
    continue
print(ans)
    

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

string s;

int main(){
    cin >> s;

    int n = s.size();
    for(int i=0;i<n-1;i++){
        if(s[i] == s[i+1]){
            cout << i + 1 << ' ' << i + 2 << endl;
            return 0;
        }
    }

    for(int i=0;i<n-2;i++){
        if(s[i] == s[i+2]){
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << ' ' << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=2e6+1;
const int M=1e9+7;
const int N=6e6+6;

ll mat[15][15],cost[15];

void solve(){
	int n,m,x;
	sfi(n) sfi(m) sfi(x)

	ll ans=llinf;

	f(i,0,n){
		sfl(cost[i])
		f(j,0,m){
			sfl(mat[i][j])
		}
	}

	for(int i=1;i<(1<<n);++i){
		vector<int> v(m,0);
		ll tempcost=0;
		for(int j=0;j<n;++j){
			if(i&(1<<j)){
				for(int k=0;k<m;k++){
					v[k]+=mat[j][k];
				}
				tempcost+=cost[j];
			}
		}

		if(*min_element(v.begin(),v.end())>=x){
			ans=min(ans,tempcost);
		}

	}

	if(ans==llinf){
		ans=-1;
	}

	pfln(ans)

}


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

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
 
const int N=1e5+5;
const int M=2e3+5;
 
int n, k, white=0, black=0;
int x[N], y[N];
char c[N];
int sz[M][M], sz2[M][M];
 
int rsum1(int x1, int y1, int x2, int y2)
{
	int ans=sz[x2][y2];
	if(x1>0)
		ans-=sz[x1-1][y2];
	if(y1>0)
		ans-=sz[x2][y1-1];
	if(x1>0&&y1>0)
		ans+=sz[x1-1][y1-1];
	return ans;
}
 
int rsum2(int x1, int y1, int x2, int y2)
{
	int ans=sz2[x2][y2];
	if(x1>0)
		ans-=sz2[x1-1][y2];
	if(y1>0)
		ans-=sz2[x2][y1-1];
	if(x1>0&&y1>0)
		ans+=sz2[x1-1][y1-1];
	return ans;
}
 
int calc(int i, int j)
{
	int w=white;
	w-=rsum1(i, 0, i+k-1, 2*k-1);
	w-=rsum1(0, j, 2*k-1, j+k-1);
	w+=2*rsum1(i, j, i+k-1, j+k-1);
	int b=0;
	b+=rsum2(i, 0, i+k-1, 2*k-1);
	b+=rsum2(0, j, 2*k-1, j+k-1);
	b-=2*rsum2(i, j, i+k-1, j+k-1);
	return (w+b);
}
 
int32_t main()
{
    IOS;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
    	cin>>x[i]>>y[i]>>c[i];
    	int xd=x[i]%(2*k);
    	int yd=y[i]%(2*k);
    	if(c[i]=='W')
    	{
    		white++;
    		sz[xd][yd]++;
    	}
    	else
    	{
    		sz2[xd][yd]++;
    		black++;
    	}
    }
    for(int i=0;i<2*k;i++)
    {
    	for(int j=1;j<2*k;j++)
    	{
    		sz[i][j]+=sz[i][j-1];
    		sz2[i][j]+=sz2[i][j-1];
    	}
    }
    for(int j=0;j<2*k;j++)
    {
    	for(int i=1;i<2*k;i++)
    	{
    		sz[i][j]+=sz[i-1][j];
    		sz2[i][j]+=sz2[i-1][j];
    	}
    }
    int ans=0;
    for(int i=0;i<=k;i++)
    {
    	for(int j=0;j<=k;j++)
    	{
    		ans=max(ans, max(calc(i, j), n-calc(i, j)));
    	}
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main(){
    int n, k, tmp;
    vector<int> v;
    cin >> n>> k;
    for(int i=0;i<n;i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end(), greater<int>());
    int sm=0;
    for(int i=0;i<k;i++){
        sm+=v[i];
    }
    cout << sm << endl;
}

Measured memory_bytes: 256
A, B, K = [int(_) for _ in input().split()]

count = 0
while count < K:
    if A % 2 == 1:
        A = A - 1
    B += A // 2
    A -= A // 2
    count += 1

    if count >= K:
        break

    if B % 2 == 1:
        B = B - 1
    A += B // 2
    B -= B // 2

    count += 1

print(A, B)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> Ns(3);
  cin >> Ns.at(0) >>  Ns.at(1) >> Ns.at(2);
  
  sort(Ns.begin(), Ns.end());
  
  cout << Ns.at(0) + Ns.at(1) + Ns.at(2) * 10 << endl;
  
  
  return 0;
}

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

using namespace std;



int main(int argc, char const *argv[]){
    int n, d, answer=0;
    cin >> n >> d;
    vector<int> x;
    int _x;
    for(int i=0;i<(n*d);i++){
        cin >> _x;
        x.push_back(_x);
    }
    for(int i=0;i<n;i++){
        for(int j=(i+1);j<n;j++){
            double sum1 = 0;
            for(int k=0;k<d;k++){
                sum1+=(x[i*d+k]-x[j*d+k])*(x[i*d+k]-x[j*d+k]);
            }
            sum1 = pow(sum1,0.5);
            answer += int(double(int(sum1))==sum1);
        }
    }
    cout << answer << endl;


    return 0;
}

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

using namespace std;
using LL = long long;

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> X(M), dist(M-1);
	rep(i,M) cin >> X[i];
	sort(X.begin(),X.end());
	rep(i,M-1) dist[i]=X[i+1]-X[i];
	sort(dist.begin(),dist.end());
	int ans=0;
	rep(i,M-N) ans+=dist[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b+c)
		cout<<0<<endl;
	else
	{
		cout<<b+c-a<<endl;
	}
	
}


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

using namespace std;

int main(){
  unsigned long long int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << ((double)W*(double)H/2) << " ";
  if(x*2 == W && y*2 == H) cout << 1;
  else cout << 0;
}


Measured memory_bytes: 256
import math
from math import fabs
def main(inp1, inp2, X):
    FinalValue = 0
    for all in range(inp1+1):
        for iterater in range(all + 1, inp1):
            var = 0.0
            for rangeinp2 in range(inp2):
                var += fabs( (int(X[all][rangeinp2]) - int(X[iterater][rangeinp2]))**2 )
            var = var ** 0.5
            varint=int(var)
            if var==varint:
                FinalValue += 1
    return FinalValue
inp1, inp2 = map(int, input().split())
X = [input().split() for _ in range(inp1)]
print(main(inp1, inp2, X))

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

int main() {
	int k, n;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, n) {
		cin >> p.at(i);
	}
	sort(p.begin(), p.end());
	int total = 0;
	rep(i, k) {
		total += p.at(i);
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	n=read();
	m=read();
	for(register int i=0;i<=n;i++)
	{
		for(register int j=0;j<=n-i;j++)
		{
		    int k=n-i-j;
			if(i*10000+j*5000+k*1000==m)
			{
				write(i);
				putchar(' ');
				write(j);
				putchar(' ');
				write(k);
				puts("");
				return 0;
			}
		}
	}
    puts("-1 -1 -1");
	return 0;
}

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

int main() {
    ll N, ans=0, r=0, g=0, b=0;
    cin >> N;
    string s;
    cin >> s;

    for(int i=0; i<N; i++){
	if(s[i]=='R')
	    r++;
	else if(s[i]=='G')
	    g++;
	else if(s[i]=='B')
	    b++;
    }


    for(int i=0; i<N; i++){
	if(s[i]=='R'){
	    ans += g*b;
	    r--;
	}
	else if(s[i]=='G'){
	    ans += r*b;
	    g--;

	}
	else if(s[i]=='B'){
	    ans += r*g;
	    b--;
	}
    }


    for(int st=0; st<N; st++){
	for(int d=0; d<N; d++){
	    if(st+2*d>=N)
		break;
	    if(s[st]==s[st+d] || s[st+d]==s[st+2*d] || s[st+2*d]==s[st])
		;
	    else
		ans--;
	}
    }


    cout << ans << endl;
} 




Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>

using namespace std;

int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
        printf("%d\n",a+b);
        break;
        case '-':
        printf("%d\n",a-b);
        break;
        case '/':
        printf("%d\n",a/b);
        break;
        case '*':
        printf("%d\n",a*b);
        break;
        }
    }
    
}


Measured memory_bytes: 2740
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100L)
#define MAX_W (100000L)

using namespace std;

long dpss[MAX_N + 1][MAX_W + 1] = {};

int main() {
  // read inputs
  long N, W, ws[MAX_N], vs[MAX_N];
  scanf("%ld %ld", &N, &W);
  for (long i = 0; i < N; i++) {
    scanf("%ld %ld", &ws[i], &vs[i]);
  }

  // solve dp
  for (long i = 0; i < N; i++) {
    for (long j = 0; j <= W; j++) {
      if (j >= ws[i]) {
        dpss[i + 1][j] = max(dpss[i][j], vs[i] + dpss[i][j - ws[i]]);
      } else {
        dpss[i + 1][j] = dpss[i][j];
      }
    }
  }
  printf("%ld\n", dpss[N][W]);
}

Measured memory_bytes: 78336
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main = getLine >>= print . solve
solve :: String -> Int
solve = go 0 0
  where
    go :: Int -> Int -> String -> Int
    go m i [] = max m i
    go m i (s:ss) = if elem s acgt 
                    then go m (i+1) ss
                    else go (max m i) 0 ss


acgt = "ACGT"

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;

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

	int x;
	cin >> x;
	int ans = 1;
	int max = 0;
	for (int i = 2; i <= x; i++) {
		for (int j = 2; j <= 9; j++) {
			if (pow(i, j) <= x && max < pow(i, j)) {
				ans = pow(i, j);
				max = ans;
			}
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
n,a,b,*h=map(int,open(0).read().split())
i,j=0,-(-max(h)*n//a)
while True:
  if j-i<2:
    print(j)
    break
  k=c=(j+i+1)//2
  for t in h:
    t-=b*k
    if t>0:
      c+=-t//(a-b)
  if c>=0:
    j=k
  else:
    i=k

Measured memory_bytes: 14092
# -*- coding: utf-8 -*-
import sys
N=input()

#1-indexed
bit=[ 0 for i in range(N+1) ]
bit[0]=None

def add(x,w):
	while x<=N:
		bit[x]+=w
		x+=x&(-1*x)

def bitsum(x):
	s=0
	while 0<x:
		s+=bit[x]
		x-=x&(-1)*x
	return s

def search(wa):
	if wa<=0: return 0
	if bitsum(N)<wa: return N+1
	r=N
	l=0
	while r-l!=1:
		m=(l+r)/2
		if bitsum(m)<wa:
			l=m
		else:
			r=m	
	return r


#0-indexed
A=map(int, sys.stdin.readline().split())
# 配列のAの数字の位置を1-indexedで格納。例 B[8]=1 は、Aで数字8が1番目（1-indexed)にあることを示す
B=[ 0 for i in range(N+1) ]
for i,a in enumerate(A):
	B[a]=i+1

ans=0
x=N
add(B[x],1)

for x in range(N-1,0,-1):
	cur_p=B[x]	#current position
	cur_v=bitsum(cur_p)
	l1=search(cur_v)
	l2=search(cur_v-1)
	r1=search(cur_v+1)
	r2=search(cur_v+2)
	#print "l2,l1,r1,r2 :: ",l2,l1,r1,r2
	#print "ans+=( (",l1-l2,")*(",r1-cur_p,")+(",cur_p-l1,")*(",r2-r1,") )*",x
	ans+=( (l1-l2)*(r1-cur_p)+(cur_p-l1)*(r2-r1) )*x
	add(B[x],1)

print ans


Measured memory_bytes: 51928
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    
    
    // calculation
    int count = 0;
    REP(i, A+1) {
        REP(j, B+1) {
            REP(k, C+1) {
                if ((500*i + 100*j + 50*k) == X) count++;
            }
        }
    }
    cout << count << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <assert.h>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <bitset>
#include <numeric>
#include <string.h>
#include <utility>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back 
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;


void solve(){
	string a,b;
	cin >> a >> b;
	forn(i,sz(a)){
		if(a[i]!=b[i]){
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <regex>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;


int main() {
    string tmp;
    stack<int> S;
    while(cin >> tmp) {
        if(tmp == "+") {
            int s1 = S.top();
            S.pop();
            int s2 = S.top();
            S.pop();
            S.push(s1+s2);
        } else if(tmp == "-") {
            int s1 = S.top();
            S.pop();
            int s2 = S.top();
            S.pop();
            S.push(s2-s1); 
        } else if(tmp == "*") {
            int s1 = S.top();
            S.pop();
            int s2 = S.top();
            S.pop();
            S.push(s1*s2);
        } else {
            S.push(stoi(tmp));    
        }
    }

    cout << S.top() << endl;
    return 0;
}

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

Measured memory_bytes: 128
#include <iostream>

int main(){
	int a,b,c,g,h;
	char j;
	std::cin>>a>>b;
    int d[a];
    for(int e=1;e<=a;e++){
    	d[e]=e;
    	
	}
	for(int f=0;f<b;f++){
		std::cin>>g>>j>>h;
		c=d[g];
		d[g]=d[h];
		d[h]=c;
	}
	for(int i=1;i<=a;i++){
		std::cout<<d[i]<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 2924
#include<stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
#define For(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define abs(a) ((a)>0?(a):(-a))

int i;

int main(){
  int a;
  char s[10];
  scanf("%d%s",&a,s);
  if(a>3199)
    printf("%s\n",s);
  else 
    printf("red\n");

  return 0;}


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

#define N 1001

char X[N], Y[N];

 
void LCS(char X[], char Y[]){
  int i,j;
  int C[1001][1001];  
  int m = strlen(X+1), n = strlen(Y+1);
 
  for(i = 1; i < m+1; i++){
    C[i][0] = 0;
  }
  for(i = 0; i < n+1; i++){
    C[0][i] = 0;
  }
  for(i = 1; i < m+1; i++){
    for(j =1; j < n+1; j++){
      if(X[i] == Y[j]){
        C[i][j] = C[i-1][j-1]+1;
      }else if(C[i-1][j] >= C[i][j-1]){
        C[i][j] = C[i-1][j];
      }else{
        C[i][j] = C[i][j-1];
      }
    }
  }
 
  printf("%d\n",C[i-1][j-1]);
}
 
int main(){
  int i,n;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",X+1);
    scanf("%s",Y+1);
    LCS(X,Y);
  }
 
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a1(n), a2(n);
  for(int i=0;i<n;i++)
    cin >> a1[i];

  for(int i=0;i<n;i++)
    cin >> a2[i];

  for(int i=1;i<n;i++) {
    a1[i] += a1[i-1];
    a2[i] += a2[i-1];
  }

  ll ans = 0;
  for(int i=0;i<n;i++) {
    ll x;
    if(i == 0) {
      x = a1[i] + a2[n-1];
    }  else {
      x = a1[i] + a2[n-1]-a2[i-1];
    }
    if(x > ans) {
      ans = x;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    VEC(int,b,n);
    int ans=0;
    rep(i,n){
        int d=0;
        rep(j,n){
            if(i<j)d+=b[j];
            if(i==j)d+=b[j];
            if(i==j)d+=a[j];
            if(i>j)d+=a[j];
        }
       // std::cout << d << std::endl;
        chmax(ans,d);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n, m;
	cin >> n >> m;
	int dis[100001] = {};
	ll res = 0;
	dis[0] = 0;
	REP(i, n-1){
		cin >> dis[i+1];
		dis[i+1] += dis[i];
	}
	int pos = 0;
	REP(i, m){
		int a;
		cin >> a;
		res = (res + ((dis[max(pos, pos+a)] - dis[min(pos, pos+a)])%100000))%100000;
		pos+= a;
	}
	cout << res << endl;
}

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

#define sz(x) (int)(x).size()

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
   string s;
   int k,i,j,sz1,x,mov;

   cin>>s>>k;

   sz1=sz(s);

   for(i=0;i<sz1;i++)
    {
        if(i==sz1-1)
        {
            if(s[i]+k > 'z')
            {
                k-=('z'-s[i])+1;

                k=k%26;

                s[i]='a'+k;
            }
            else
                s[i]+=k;
        }
        else if(s[i]!='a')
        {
            mov='z'-s[i]+1;

           // cout<<mov<<endl;

            if(k<mov)
                continue;
            else
            {
                k-=mov;
                s[i]='a';
            }

        }

    }


    cout<<s<<endl;

    return 0;
}


/*
za 32
af

az 27
aa

a 134
e

aaa 3
aad

*/



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

int main() {

	string S;
	cin >> S;

	string before = "ATCG";
	string after = "TAGC";

	char ans = 'A';

	for (int i = 0; i < before.size(); i++)
	{
		if (S[0] == before[i]) ans = after[i];
	}
    
	cout << ans << endl;
}



Measured memory_bytes: 256
from sys import exit
from fractions import gcd


N = int(input())
A = list(map(int, input().split()))
A.sort()

# List if length of 2 or shorter
if len(A) <= 2:
    print(max(A))
    exit()

# Left Side = [A0, 0, 0, 0, 0]
left_side = [0 for _ in range(N)]
left_side[0] = A[0]

# Right Side = [0, 0, 0, 0, An]
right_side = [0 for _ in range(N)]
right_side[-1] = A[-1]

for i in range(N - 1):  # DP: L1 = gcd(L0, A1); Maximum GCD on very RIGHT of list  (Dir -->)
    left_side[i + 1] = gcd(left_side[i], A[i + 1])

for i in range(1, N):   # DP: Rn-2 = gcd(An-2, Rn-1); Maximum GCD on very LEFT of list  (Dir <--)
    right_side[-1 * (i+1)] = gcd(A[-1*(i+1)], right_side[-1*i])

max_gcd = 1

# Left
max_gcd = max(max_gcd, right_side[1])
# Max of Right and Left
max_gcd = max(max_gcd, left_side[-2])

for i in range(1, N - 1):
    left = left_side[i - 1]
    # We exclude the number at i here, and compare whether new gcd is greater than previous
    right = right_side[i + 1]

    max_gcd = max(max_gcd, gcd(left, right))

print(max_gcd)

Measured memory_bytes: 16156
N, M = map(int, input().split())
A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]
ans = 'No'
for i in range(N - M + 1):
    for j in range(N - M + 1):
        count = 0
        for row in range(M):
            for col in range(M):
                if B[row][col] == A[i + row][j + col]:
                    count += 1
        if count == M * M:
            ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 1007
#define C 2019
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll l, r, rem, mini = 2020;
   cin >> l >> r;
   ll c = min(l + 2019, r + 1);
   for (ll i = l; i < c; i++)
   {
      rem = i % 2019;
      for (ll j = i + 1; j < c; j++)
         mini = min(mini, (rem * j) % 2019);
   }
   cout << mini << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, m, r;
	cin >> n >> m >> r;
	vector<int> rt(r);
	rep(i,r) {
		cin >> rt[i];
		rt[i]--;
	}
	vector<vector<ll>> d(n, vector<ll>(n, INF));
	rep(i,m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	ll ans = LINF;
	sort(ALL(rt));
	do {
		ll sum = 0;
		for (int i = 1; i < r; i++) {
			int x = rt[i-1];
			int y = rt[i];
			sum += d[x][y];
		}
		ans = min(ans, sum);
	} while (next_permutation(ALL(rt)));
	cout << ans << endl;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  long double h, w, x, y;
  cin >> w >> h >> x >> y;
  double sa = h/2;
  //printf("%lf\n", sa);
  double s = sa*w;
  printf("%lf", s);
  long double x2 = x*2;
  long double y2 = y*2;
  if(x2==w&&y2==h) cout << " " << 1 << endl;
  else cout << " " << 0 << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	int tmp;
	rep(i,s.size()){
		if(s[i] == 'A'){
			tmp = i;
			break;
		}
	}

	for(int i = s.size() - 1; i >= 0; i--){
		if(s[i] == 'Z'){
			cout << i - tmp + 1 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 640
import java.util.*;
import java.util.Map.Entry;

public class Main{
	static Scanner sc = new Scanner(System.in);
	static Map<String, Integer> map = new HashMap<String, Integer>();
	
	// main\bh----------------------------------------------------------------
	public static void main(String[] args){
		read();
		solve();
	}
	
	
	// read\bh-----------------------------------------------------------------
	static boolean read() {
		//±±ÅüÍðÇÝÞ
		while(sc.hasNext()){
			String str = sc.next();
			
			if(map.containsKey(str)){
				int i = map.get(str);
				i++;
				map.put(str, i);
			} else{
				map.put(str, 1);
			}
		}
		
		return true;
	}
	
	
	// solve\bh------------------------------------------------------
	static void solve() {
		//±±Åâèðð¢ÄoÍ·é
		int max = 0, max2 = 0;
		String maxKey = "\0", maxKey2 = "\0";
		
		
		//SGgÉANZX
		for(Entry<String, Integer> e : map.entrySet()){
			//Ååo»ñðT·
			if(max2 < e.getValue()){
				max2 = e.getValue();
				maxKey2 = e.getKey();
			}
			
			//Åå¶ðT·
			if (max < e.getKey().length()){
				max = e.getKey().length();
				maxKey = e.getKey();
			}
		}
		
		
		
		System.out.println(maxKey2 + " " + maxKey);
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[10];
for(int b = 0;b <= 9;b++) cin >> a[b];
sort(a,a+10);
for(int c = 1;c <= 3;c++) cout << a[10 - c] << endl; 
return 0;
}

Measured memory_bytes: 3140