akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  long long N, M;
  long long ans=0;
  long long tmps = 0;
  long long tmpe = 0;
  long long use=0;
  long long ES =0;
  long long X = 0;

  cin >> N >> M;

  vector<long long > x(N);
  for(long long  i = 0; i < N; i++){
    cin >> x[i];
  }

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

  //  for(long long  i = 0; i < N; i++){
  //    cout << x[i] << ", ";
  //  }
  //  cout << endl;

  vector<long long > s(M), e(M);
  vector<pair<long long , long long >> es(M);
  for(long long  i = 0; i < M; i++){
    cin >> s[i] >> e[i];
    es[i] = make_pair(e[i], s[i]);
  }
  
  sort(es.begin(), es.end(), greater<pair<long long,long long>>());
  
    for(long long  i = 0; i < M; i++){
      //    cout << "es[" << i << "] = [" << es[i].first
      //         << ", "<< es[i].second << "]" <<  endl;
    }
  
  for(long long  i = 0; i < N; i++){
    if(ES < M){
      if(x[i] < es[ES].first){
        ans += es[ES].first;
        //        cout << 1 << " " << es[ES].first << endl;
        use++;
        if(es[ES].second == use){
          ES++;
          use = 0;
        }
      }else{
        ans += x[i];
        //        cout << x[i] << endl;
        //        cout << 2 << " " << x[i] << endl;
      }
    }else{
      ans += x[i];
      //        cout << x[i] << endl;
        //        cout << 3 << " " << x[i] << endl;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int n; cin >> n;
  Graph G(n, vi(2));
  rep(i,n) rep(j,2) cin >> G[i][j];

  double sum = 0;
  rep(i,n) {
    rep(j,i) {
      int x = G[i][0] - G[j][0];
      int y = G[i][1] - G[j][1];
      double tmp = x * x + y * y;
      sum += sqrt(tmp);
    }
  }

  double denom = n * (n-1) / 2;
  sum *= (n-1) / denom;
  cout << sum << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int h, w;
char s[210][210];
int d[210][210];
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    int sy = 0, sx = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> s[i][j];
            if(s[i][j] == '%'){
                sy = i; sx = j;
            }
        }
    }
    rep(i, 0, h) rep(j, 0, w) d[i][j] = INF;
    d[sy][sx] = 0;
    queue<P> q;
    q.push(P(sy, sx));
    while(!q.empty()){
        P p = q.front(); q.pop();
        int y = p.first;
        int x = p.second;
        rep(i, 0, 4){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(!contain(ny, nx) || d[ny][nx] != INF || s[ny][nx] == '#') continue;
            d[ny][nx] = d[y][x] + 1;
            q.push(P(ny, nx));
        }
    }
    int MIN = INF, princess;
    rep(i, 0, h){
        rep(j, 0, w){
            if(s[i][j] == '@') princess = d[i][j];
            else if(s[i][j] == '$') chmin(MIN, d[i][j]);
        }
    }
    if(princess < MIN) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3556
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

// use std::cmp::{max, min};

fn main() {
  let n = read::<u64>();
  let n_str = n.to_string();
  let mut sum = 0;

  sum += dfs(String::from("3"), n_str.len(), n);
  sum += dfs(String::from("5"), n_str.len(), n);
  sum += dfs(String::from("7"), n_str.len(), n);

  println!("{}", sum);
}

fn dfs(num: String, l_keta: usize, limit: u64) -> u64 {
  let num_i = num.parse::<u64>().unwrap();

  let mut sum = 0;

  if num.contains('3') && num.contains('5') && num.contains('7') && num_i <= limit {
    sum += 1;
  }
  if num.len() > l_keta {
    return 0;
  }
  let num_3 = num.clone();
  let num_5 = num.clone();
  let num_7 = num.clone();
  sum += dfs(num_3 + "3", l_keta, limit);
  sum += dfs(num_5 + "5", l_keta, limit);
  sum += dfs(num_7 + "7", l_keta, limit);
  sum
}

Measured memory_bytes: 4352
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

lint Sum(vector<lint> nums)
{
    lint sum = 0;
    rep (i, SZ(nums))
    {
        sum += nums[i];
    }
    return sum;
}

int main()
{
    int N;
    cin >> N;
    vector<lint> B(N-1);
    rep (i, N-1)
    {
        cin >> B[i];
    }

    vector<lint> A(N);
    A[0] = B[0];
    for (int i = 1; i+1 < N; ++i)
    {
        if (B[i-1] > B[i])
        {
            cerr<< "1 " ;
            A[i] = B[i];
        }
        else if (B[i-1] <= B[i])
        {
            A[i] = B[i-1];
            if (B[i] <= B[i+1])
            {
                cerr<< "2 " ;
                A[i+1] = B[i];
            }
            else if (B[i] > B[i+1])
            {
                cerr<< "3 " ;
                A[i+1] = B[i+1];
            }
            ++i;
        }
    }
    cerr << endl;

    A[N-1] = B[N-2];

    rep (i, N-1)
    {
        if (!(B[i] >= max(A[i], A[i+1])))
        {
            cerr << "no" << endl;
        }
        cerr << A[i] << " ";
    }
    cerr << endl;

    lint sum = Sum(A);
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int K;
    cin >> K;

    vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << A[K - 1] << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
    int m;
    int mon;
    int d;
    int d1,d10;
    int ans=0;
    int i,j;


    scanf("%d%d",&mon,&d);
    for(i=1;i<=mon;i++){
        for(j=1;j<=d;j++){
            //printf("%d\n",j/10);
            if(j/10>=2){
                
            d10=j/10;
            d1=j-10*d10;
            if(d1>=2){
            if(i==d10*d1){
                ans++;
            }
            }
            }
        }
    }
    printf("%d",ans);

    



    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int a;
    cin>>a;

    cout<<a + a*a + a*a*a;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, ch;
  cin >> n;
  ch = n;
  int sum = 0;
  rep(i, 8){
    sum += ch % 10;
    ch /= 10;
  }
  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 1e6 + 11;
LL dp[111][111];
const LL mod = 1e9 + 7;
LL Fac[N], Inv[N];
LL Get(int l, int r) {
	return Fac[l] * Inv[r] % mod * Inv[l - r] % mod;
}
int main() {
	ios::sync_with_stdio(false);
	dp[0][0] = 1;
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3)return cout << 0, 0;
	Fac[0] = 1;
	for (int i = 1; i < N; i++)Fac[i] = Fac[i - 1] * i % mod;
	Inv[N - 1] = powmod(Fac[N - 1], mod - 2, mod);
	for (int i = N - 2; i >= 0; i--)Inv[i] = Inv[i + 1] * (i + 1) % mod;
	int res = -1, TMP;
	for (int i = 0; i <= x && 2 * i <= y; i++) {
		int X = x - i;
		int Y = y - 2 * i;
		int tmp = min(X / 2, Y);
		if (Y == tmp && X == 2 * tmp) {
			res = tmp + i;
			TMP = tmp;
			break;
		}
	}
	if (res == -1)return cout << 0, 0;
	cout << Get(res, TMP) << endl;

	return 0;
}


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

using namespace std;
static const int INF =(1<<21);

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

	int a[1000], b[1000], c[1000],d[100][100];

	for (int i = 0;i < m;i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (i == j) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}

	for (int i = 0;i < m;i++) {
		d[a[i]][b[i]] = min(c[i], d[a[i]][b[i]]);
		d[b[i]][a[i]] = min(c[i], d[b[i]][a[i]]);
	}

	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]);

	int ans = m;
	for (int i = 0;i < m;i++) {
		int s = 0;
		for (int j = 0;j < n;j++) if (d[j][a[i]] + c[i] == d[j][b[i]]) s = 1;
		ans -= s;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=[input() for i in range(H)]
table=[[0]*(H+W-1) for i in range(H+W-1)]
for j in range(H):
    for i in range(W):
        if S[j][i]=='#':
            table[i+j][i-j+H-1]=1
yoko=[[0]*(H+W) for i in range(H+W-1)]
for j in range(H+W-1):
    for i in range(1,H+W):
            yoko[j][i]=yoko[j][i-1]+table[j][i-1]
tate=[[0]*(H+W-1) for i in range(H+W)]
for j in range(1,H+W):
    for i in range(H+W-1):
        tate[j][i]=tate[j-1][i]+table[j-1][i]

ans=0
for y in range(H+W-1):
    for x in range((y+H-1)%2,H+W-1,2):
        if table[y][x]!=1:
            continue
        for z in range(x+2,H+W-1,2):
            if table[y][z]==1:
                d=z-x
                if y+d<H+W-1:
                    ans+=yoko[y+d][z+1]-yoko[y+d][x]
                    #print(1,'.',ans,':',x,y,z)
                if y-d>=0:
                    ans+=yoko[y-d][z+1]-yoko[y-d][x]
                    #print(2,'.',ans,':',x,y,z)
        for w in range(y+2,H+W-1,2):
            if table[w][x]==1:
                e=w-y
                if x+e<H+W-1:
                    ans+=tate[w][x+e]-tate[y+1][x+e]
                    #print(3,'.',ans,':',x,y,w)
                if x-e>=0:
                    ans+=tate[w][x-e]-tate[y+1][x-e]
                    #print(4,'.',ans,':',x,y,w)

print(ans)




Measured memory_bytes: 55516
def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
while True:
    iCount = 0
    n = input().split()
    if int(n[1]) == 0:
        break
    num = n.pop(0)
    m = int(n[0])
    numStr = list(num)
    while len(numStr) < m:
        numStr.insert(0, "0")
    numSub = [int(numStr[l]) for l in range(m)]
    num0 = "".join([str(k) for k in numSub])
    count = []
    count.append(num0)
    answer = "False"
    while answer:
        numSub.sort()
        #print(numSub)
        Min = "".join([str(j) for j in numSub])
        numSub.reverse()
        #print(numSub)
        Max = "".join([str(i) for i in numSub])
        num1 = int(Max) - int(Min)
        num1 = str(num1)
        xxx = list(num1)
        while len(xxx) < m:
            xxx.insert(0, "0")
        numSub = [int(xxx[g]) for g in range(m)]
        xxxx = "".join([str(h) for h in xxx])
        count.append(str(xxxx))
        answer = is_unique2(count)
        iCount += 1
    print(count.index(count[-1]) ,end=" ")
    print(int(count[-1]) ,end=" ")
    print(str(iCount - count.index(count[-1])))


Measured memory_bytes: 5628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNextInt()) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                System.out.println((a<9&&b<9)?"Yay!":":(");
            }
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>
int main() {
	int h, w, a, b; std::cin >> h >> w >> a >> b;
	std::string line(w, '0');
	std::fill(line.begin(), line.begin() + a, '1');
	for (auto i = 0; i < b; ++i) {
		std::cout << line << '\n';
	}
	std::fill(line.begin(), line.end(), '1');
	std::fill(line.begin(), line.begin() + a, '0');
	for (auto i = b; i < h; ++i) {
		std::cout << line << '\n';
	}
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e[1000];
	scanf("%d",&a);
	for(b=0;b<a;b++){
	scanf("%d",&e[b]);
	}
	for(c=b-1;c>=0;c--){
	if(c==0){printf("%d\n",e[c]);
	}else{
	printf("%d ",e[c]);
	}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    int test=0;
    for(int i=1;i<=n;i++)
    {
        int d=0;
        int j=i;
        while(j!=0)
        {
            d++;
            j/=10;
        }
        if(d%2)
            test++;
    }
    cout<<test<<endl;
    
    return 0;   
}


 
 


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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=1,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<char,char>mp,nq,qr; string str,ttr,ntr;

        char ch,th,rh;


        cin>>rh;

        if(rh>='a'&&rh<='z')cout<<"a"<<endl;
        else{  cout<<"A"<<endl;  }






        return 0;

}





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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

ll MOD = 1000000007;

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

  vi L(M), R(M);
  for (ll i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
    L[i] -= 1;
    R[i] -= 1;
  }

  vi p(Q), q(Q);
  for (ll i = 0; i < Q; i++) {
    cin >> p[i] >> q[i];
    p[i] -= 1;
    q[i] -= 1;
  }

  vvi m1(N, vi(N));
  for (ll i = 0; i < M; i++) {
    m1[L[i]][R[i]] += 1;
  }

  vvi m2(N, vi(N));
  for (ll i = N - 1; i >= 0; i--) {
    for (ll j = 0; j < N; j++) {
      if (i == N - 1) {
        for (ll k = 0; k <= j; k++) {
          m2[i][j] += m1[i][k];
        }
      } else if (j == 0) {
        for (ll k = N - 1; k >= i; k--) {
          m2[i][j] += m1[k][j];
        }
      } else {
        m2[i][j] = m2[i + 1][j - 1] + m1[i][j];
        for (ll k = N - 1; k > i; k--) {
          m2[i][j] += m1[k][j];
        }
        for (ll k = 0; k < j; k++) {
          m2[i][j] += m1[i][k];
        }
      }
    }
  }

  for (ll i = 0; i < Q; i++) {
    cout << m2[p[i]][q[i]] << endl;
  }
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
int n, m, a[N], ans;
int pos[N], val[N];
bool check(int x) {
	int t = 0;
	for (int i = 2; i <= n; ++i) {
		if (a[i] > a[i - 1]) continue;
		while (t && pos[t] > a[i]) --t;
		if (t == 0 || pos[t] < a[i]) {
			++t;
			pos[t] = a[i];
			val[t] = 2;
			if (x == 1) return 0;
		} else {
			if (t == 0) return 0;
			bool ok = 0;
			for (int j = t; j >= 1 && !ok; --j) {
				if (val[j] < x) {
					t = j;
					val[j]++;
					ok = 1;
				} else
				if (val[j] == x && pos[j] - 1 > pos[j - 1]) {
					t = j;
					val[j] = 2;
					pos[j] = pos[j] - 1;
					if (x == 1) return 0;
					ok = 1;
				}
			}
			if (!ok) return 0;
		}
	}
	return 1;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	int l = 1, r = n;
	while (l < r) {
		int mid = l + r >> 1;
		if (l + 1 == r) {
			if (check(l))
				--r;
			else 
				++l;
			break;
		}
		if (check(mid))
			r = mid;
		else 
			l = mid;
	}
	cout << l;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (n, y) = readInputLine().split(" ").map { it.toInt() }
    
    for (i in 0..n) {
        for (j in 0..(n - i)) {
            if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
                println("$i $j ${n - i - j}")
                return
            }
        }
    }
    
    println("-1 -1 -1")
}
 
fun readInputLine(): String {
    return readLine()!!
}


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

char line[100];

int main() {
    char c;

    fgets(line, sizeof(line), stdin);
    sscanf(line, "%c", &c);

    if ('a' <= c && c <= 'z') {
        printf("a\n");
    } else if ('A' <= c && c <= 'Z') {
        printf("A\n");
    }

    return 0;
}


Measured memory_bytes: 1648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	string s;
	cin >> s;
	if(s[5]=='0' && (s[6]-'0')<=4) cout << "Heisei\n";
	else cout << "TBD\n";
	return 0;
}


Measured memory_bytes: 256
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
void solve() {
    string s;
    while(cin >> s) {
        cout << s[0];
        cin >> s;
        cout <<s[0];
        cin >> s;
        cout << s[0] << endl;
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


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

#define INF (1e9)
#define INF_LL (1e17)

using LL = long long;
using ULL = unsigned long long;

using namespace std;

#define MAX_N 5005
#define MAX_K 5005

int N, K;
LL A[MAX_N];
bool used[MAX_N];

int main()
{
  cin >> N >> K;
  LL checkSum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    checkSum += A[i];
  }

  if(checkSum < K){
    cout << N << endl;
    return 0;
  }

  sort(A, A+N);

  reverse(A, A+N);

  int ans = 0;
  for (int i = 0; i < N; i++) {
    memset(used, 0, sizeof(used));
    LL tmpAns = 0;
    for (int j = 0; j < N; j++) {
      if(i == j){
        continue;
      }
      if(tmpAns + A[j] < K){
        tmpAns += A[j];
      }
    }
    if(tmpAns >= K-A[i]){
      ans++; //cerr << i << endl;
    }
  }

  cout << N - ans << 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 REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

int main()
{
	ll p=0;
	string s;
	cin >> s;
	rep(i,SIZE(s)){
		if(s[i]=='p'){
			++p;
		}
	}
	cout << SIZE(s)/2-p << endl;
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll A[200000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	int l = 0, r = 0;
	ll sum = 0;
	ll ans = 0;
	while (l < N) {
		while (r < N) {
			if (sum&A[r]) break;
			sum += A[r];
			r++;
		}
		sum -= A[l];
		ans += r - l;
		l++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

   class Main{
      public static void main(String args[]){
       Scanner scan = new Scanner(System.in);

       int []m =new int[6];

       for(int i =0;i<6;i++){
          m[i] =scan.nextInt();
       }

       String str = scan.next();

       for(int i =0;i<str.length();i++){
          char b = str.charAt(i);

             if(b=='N'){
                int x = m[0];
                m[0] = m[1];
                m[1] = m[5];
                m[5] = m[4];
                m[4] = x;
             } else if(b=='S'){
                int x = m[0];
                m[0] = m[4];
                m[4] = m[5];
                m[5] = m[1];
                m[1] = x;
             } else if(b=='E'){
                int x = m[0]; 
                m[0] = m[3];
                m[3] = m[5];
                m[5] = m[2];
                m[2] = x;
             } else {
                int x = m[0];
                m[0] = m[2];
                m[2] = m[5];
                m[5] = m[3];
                m[3] = x;
             }

       }

       System.out.println(m[0]);

 
       }
   }


Measured memory_bytes: 26256
M, D = map(int, input().split())

count = 0
for a in range(1, M+1):
    for b in range(22, D+1):
        d10, d1 = int(str(b)[0]), int(str(b)[1])
        if d10 >= 2 and d1 >= 2 and d10*d1 == a:
            count += 1
            
    
    
print(count)              
    


Measured memory_bytes: 3060
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long N = sc.nextLong();
        // long K = sc.nextLong();
        int N = sc.nextInt();
        int D = sc.nextInt();

        int tmp = ((D * 2) + 1);
        System.out.println(N % tmp != 0 ? N / tmp + 1 : N / tmp);
    }
}

Measured memory_bytes: 20948
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

string s;
const int MAX = 201001;
int dp[MAX][3];
int n;
bool spr(int a,int b,int dl){
  R(i,dl){
    if(s[a + i] != s[b + i])return 1;
  }
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> s;
  n = SZ(s);
  R(i,min(n,3ll)){
    dp[i+1][i] = 1;
  }
  R(i,n)R(j,3)if(dp[i][j]){
    debug(i,j,dp[i][j]);
    R(k,3)if(i + k + 1 <= n)if(j != k || spr(i - j - 1, i, j + 1)){
      maxi(dp[i + k + 1][k], dp[i][j] + 1);
    }
  }
  int res = 0;
  R(i,3)maxi(res,dp[n][i]);
  cout << res << "\n";
}


Measured memory_bytes: 5268
import java.util.*;



/**
 * Created by santa on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] a = new int[3];
        a[0] = scanner.nextInt();
        a[1] = scanner.nextInt();
        a[2] = scanner.nextInt();
        Arrays.sort(a);

        System.out.println(a[1] + a[0]);
    }




} // MainClass


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

namespace abc123a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            Console.ReadLine();
            Console.ReadLine();
            Console.ReadLine();
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            if (e-a > k)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}



//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
*/



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

ll N;
  cin>>N;
  string S;
  cin>>S;
  ll sumW=0;
  ll sumR=0;
  for(int i=0;i<N;i++){
    if(S[i]=='W'){
      sumW++;
    }else{
      sumR++;
    }
  }
  ll leftR=0;
  for(int i=0;i<sumR;i++){
    if(S[i]=='R'){
      leftR++;
    }
  }
  cout<<sumR-leftR<<endl;
}




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

using namespace std;
vector<int> ans;
int main(){
	while(1){
		int m,nmin,nmax;
		cin >> m >> nmin >> nmax;
		if(m + nmin + nmax == 0) break;
		int n;
		int p[200];
		for(int i = 0;i<m;i++){
			cin >> p[i];
		}
		sort(p,p+m);
		reverse(p,p+m);
		int maxg = 0;
		for(int i = nmin;i <= nmax;i++){
			int gap;
			gap = p[i-1] - p[i];
			if(gap >= maxg){
				maxg = gap;
				n = i;
			}
		}
		ans.push_back(n);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  ll x;
  cin>>x;
  for (ll i = -200; i <= 200; ++i)
  {
    for (ll j = -200; j <= 200; ++j)
    {
      ll k = pow(i,5);
      ll ka = pow(j,5);
      debugs(k,ka)
      if(k-ka==x){
        cout<<i<<" "<<j<<'\n';
        exit(0);
      }
    }
  }
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 4056
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

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

    int n;

    cin>>n;

    if(n % 3 == 0){
        int k = n / 3;
        cout<<(k * k * k)<<endl;
    }
    else{
        double k = (double)n / 3;
        double ans = k * k * k;
        cout<<fixed<<setprecision(8);
        cout<<ans<<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++)
typedef long long ll;
 
int main() {
  ll a,b;cin>>a>>b;
  if (a>=13) cout<<b;
  else if (a<=5) cout<<0;
  else cout<<b/2;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    String ans = "";
    if (a < b) {
      for(int i = 0; i < b; i++) {
        ans += String.valueOf(a);
      }
    } else {
      for(int i = 0; i < a; i++) {
        ans += String.valueOf(b);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25812
#include <stdio.h>
int main(){
    int a[5],i,c;
    for(i=0;i<5;i++){
    scanf("%d\n",&a[i]);
    if(a[i]<40){c+=40;}
    else c+=a[i];
    }




printf("%d\n",c/5);
return 0;
}

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

int main() {
	string s;
	cin >> s;
	int mn = 100000;
	for (int i = 0; i < s.size() - 2; i++) {
		string t;
		t += s[i];
		t += s[i + 1];
		t += s[i + 2];
		if (mn > abs(753 - stoi(t))) {
			mn = abs(753 - stoi(t));
		}
	}

	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] W = Console.ReadLine().Split(' ');
            int N = int.Parse(W[0]);
            int K = int.Parse(W[1]);
            int Q = int.Parse(W[2]);

            int[] A = new int[N];
            for(int i=0;i<N;i++)
            {
                A[i] = K;
            }
            for(int i=0;i<Q;i++)
            {
                int t = int.Parse(Console.ReadLine());
                A[--t]++;
            }
            for(int i=0;i<N;i++)
            {
                A[i] = A[i] - Q;
            }
            for (int i = 0; i < N; i++)
            {
                if (A[i] <= 0)
                {
                    Console.WriteLine("No");
                }
                else
                {
                    Console.WriteLine("Yes");
                }
            }
        }
    }
}


Measured memory_bytes: 17600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll x;cin>>x;
    ll yokin=100;
    for(int i=1;;i++){
        yokin+=yokin/100;
        if(yokin>=x){
            cout << i << endl;
            break;
        }
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		//変更必要回数をカウント
		int count = 0;
		for(int i=0; i<n; i++) {
			boolean aIsB = a.charAt(i) == b.charAt(i);
			boolean bIsC = b.charAt(i) == c.charAt(i);
			boolean cIsA = c.charAt(i) == a.charAt(i);
			
			if(aIsB==false && bIsC==false && cIsA==false) {
				count = count+2;
			} else if(aIsB==false && bIsC==false && cIsA==true
					||aIsB==false && bIsC==true && cIsA==false
					||aIsB==true && bIsC==false && cIsA==false) {
				count = count+1;
			}	
		}
		System.out.print(count);
	}
}

Measured memory_bytes: 23636
length=int(input())
c=input()

if length==1:
    print("No")
elif length%2!=0:
    print("No")
else:
    a=''
    b=''

    for i in range(length//2):
        a+=c[i]
        b+=c[length//2 + i]

    if a==b:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
S=[int(i) for i in input()]
ans=0
for x in range(1<<len(S)-1):
    a=S[0]
    for n in range(len(S)-1):
        if x>>n & 1:
            ans+=a
            a=0
        a = a * 10 + S[n+1]
    ans += a
print(ans)
            

Measured memory_bytes: 3060
from collections import Counter
import sys
from random import randint
from time import time
start = time()
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline


def get_sat():
    sat = 0
    when = [-1] * 26
    for i in range(d):
        sat += s[i][t[i]]
        when[t[i]] = i
        for j in range(26):
            sat -= c[j] * (i - when[j])
    return sat


d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [randint(0, 25) for i in range(d)]
ans = get_sat()
told = t[:]
while time() - start < 1.8:
    p, q = randint(0, d - 1), randint(0, 25)
    t[p] = q
    if ans <= get_sat():
        told = t[:]
    else:
        t = told[:]
for i in range(d):
    print(t[i] + 1)


Measured memory_bytes: 81640
#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;cin>>n;
    ll a[n];rep(i,n)cin>>a[i];
    ll ans = 0;
    ll MOD = 1000000007;
    ll s[n];s[0]=a[0];
    rep(i,n-1)s[i+1]=s[i]+a[i+1];
    
    rep(i,n){
        ll tmp=s[n-1]-s[i];
        tmp%=MOD;
        tmp*=a[i];
        ans+=tmp;
        ans%=MOD;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6748
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b=sc.nextInt();
        if(a>=b){
            for(int i = 0;i<a;i++){
                System.out.print(b);
            }
        } else {
            for(int i = 0;i<b;i++){
                System.out.print(a);
            }
        }
    }
}

Measured memory_bytes: 21972
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for _ in [0]*n]
minx = max([x for x,y,a in xya if a==1]+[0])
maxx = min([x for x,y,a in xya if a==2]+[w])
miny = max([y for x,y,a in xya if a==3]+[0])
maxy = min([y for x,y,a in xya if a==4]+[h])
print(max(0,maxx-minx)*max(0,maxy-miny))

Measured memory_bytes: 3064
#include <stdio.h>

int main (void){
  int charcters[26] = {0};
  char ch;
  int i;

  while (scanf("%c", &ch) != EOF) {
    if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) {
      if('a' <= ch && ch <= 'z') {
        charcters[ch - 'a']++;
      } else {
        charcters[ch - 'A']++;
      }
    }
  }

  for (i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, charcters[i]);
  }

  return 0;
}

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
  int n;
  cin>>n;
  vector<int> a(n+2, 0);
  rep(i,n) cin>>a[i+1];

  long acc = 0;
  rep(i,n+1) acc += abs(a[i]-a[i+1]);

  rep(i,1,n+1){
    long ans = acc - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]);
    cout << ans << "\n";
  }

  return 0;
}


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

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

    int mod = N % 1000;
    //if ((a * b) % 2 == 0) cout << "Even" << endl;
    //else cout << "Odd" << endl;    
    if(mod == 0){
        cout<< 0 << endl;
    }else{
        cout << 1000 - mod << endl;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int x,y,a,b,lim[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int main()
{
	char s[1001];
	scanf("%s",s);
	x=(s[0]-'0')*10+s[1]-'0';
	y=(s[2]-'0')*10+s[3]-'0';
	if(y&&y<=12)a=1;
	if(x&&x<=12)b=1;
	if(a&&b)puts("AMBIGUOUS");
	else if(a)puts("YYMM");
	else if(b)puts("MMYY");
	else puts("NA");
}

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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e18 + 7);

int n;
int a[N];
int ans = inf;

int f(int x) {
    int res = 0;
    for (int i = 1; i <= n; i ++) {
        res += abs(a[i] - x);
    }
    return res;
}
main () {
    cin >> n;

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

    int l = -1e9,r = 1e9;

    while (r - l > 2) {
        int m1 = l + (r - l) / 3;
        int m2 = r - (r - l) / 3;

        if (f(m1) < f(m2)) r = m2;
        else l = m1;
    }
    for (int i = l; i <= r; i ++) {
        ans = min(ans,f(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

string s;
int bg,ed;
int ans=0; 
bool chk=true;

int main()
{
	cin>>s;
	bg=0,ed=s.size()-1;
	
	while(bg<=ed)
	{
		if(s[bg]=='x'&&s[ed]!='x') bg++,ans++;
		else if(s[bg]!='x'&&s[ed]=='x') ed--,ans++;
		else if(s[bg]=='x'&&s[ed]=='x') bg++,ed--;
		else if(s[bg]!='x'&&s[ed]!='x')
		{
			if(s[bg]==s[ed]) bg++,ed--;
			else 
			{
				chk=false;
				break;
			}
		}
	}	
	
	if(!chk)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> X(3);
    cin >> X[0] >> X[1] >> X[2];
    int K;
    cin >> K;
    sort(X.begin(),X.end());
    for(int i = 0; i < K; i++) X[2] *= 2;
    cout << X[0] + X[1] + X[2] << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    vector<int>x(6);
    vector<int>y(4);
    for(int i=0;i<6;i++){
        cin >> x[i];
    }
    for(int i=1;i<=4;i++){
        y[i-1]=count(x.begin(),x.end(),i);
    }
    int w=count(y.begin(),y.end(),2);
    int z=count(y.begin(),y.end(),1);
    if(w==2&&z==2){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define long long ll
using namespace std;
const int N=2*1e5+5;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	map<string,int> mapn;
	int n,ans=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(mapn.find(s)==mapn.end()){
			ans++;
			mapn[s]=1;
		}
	}
	cout<<ans;
    return 0;
}



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

typedef int ll;

#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

vector<int>v;

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	int n;
	cin>>n;

	for (int i=0 ; i<3*n ; i++) {
		int x;
		cin>>x;

		v.pb(x);
	}	

	sort(v.rbegin(),v.rend());
	int ans=0;
	for (int i=1,j=0 ; j<n ; j++,i+=2) {
		ans+=v[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6512