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

int n, d, c1, c2;
vector<int> g[105];
int mini = 1000;
int maxd[105];
int depth[105];

int dfs(int v, int f = -1) {
	int dep = 0;
	for (int u : g[v])
		if (u != f)
			dep = max(dep, dfs(u, v) + 1);
	return dep;
}

void dfsc(int v, int dep = 0, int f = -1) {
	if (f == -1)
		maxd[dep] = max(maxd[dep], (int)g[v].size());
	else
		maxd[dep] = max(maxd[dep], (int)g[v].size() - 1);
	for (int u : g[v])
		if (u != f)
			dfsc(u, dep+1, v);
}

int main() {
	cin >> n;
	c1 = c2 = -1;

	for (int i = 0; i < 105; ++i)
		maxd[i] = 1;

	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < n; ++i) {
		int dep = dfs(i);
		depth[i] = dep;
		if (dep < mini) {
			c1 = i;
			c2 = -1;
			mini = dep;
		} else if (dep == mini) {
			c2 = i;
		}
	}

	ll ans = 1;

	if (c2 == -1) {
		cout << mini+1 << ' ';
		dfsc(c1);
		ans = (1LL<<62);
		ll prod = 1;
		for (int i = 0; i < 105; ++i)
			prod *= maxd[i];
		ans = min(ans, prod);

		for (int u : g[c1]) {
			prod = 1;
			for (int i = 0; i < 105; ++i)
				maxd[i] = 1;
			if (depth[u] > mini+1)
				continue;
			dfsc(c1, 0, u);
			dfsc(u, 0, c1);
			for (int i = 0; i < 105; ++i)
				prod *= maxd[i];
			ans = min(ans, 2*prod);
		}

		cout << ans << endl;
	} else {
		cout << mini << ' ';
		dfsc(c1, 0, c2);
		dfsc(c2, 0, c1);
		for (int i = 0; i < 105; ++i)
			ans *= maxd[i];
		cout << 2*ans << endl;
	}
}

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

int main() {
    int n, x[101];
    long long total, ans;
    cin >> n;
    for (int i = 0;i < n; i++) cin >> x[i];
    for (int i = 1; i <= 100; i++) {
        total = 0;
        for (int j = 0; j < n; j++) {
            total += pow(x[j] - i, 2);
        }
        if (i == 1) ans = total;
        else if (ans > total) ans = total;
    }
    cout << ans << endl;
}

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


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

	int ans = 0;
	map<string, int> s;
	for (int i = 0; i < n; i++) {
		string s_in;
		cin >> s_in;
		if (!s.count(s_in)) {
			ans++;
			s[s_in] = 1;
		}
	}

	cout << ans << endl;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long n,m,k;
	cin>>n>>m>>k;
	vector<long long> a(n),b(m);
	long long ans=0;
	vector<long long> ruisekiA(n+1,0),ruisekiB(m+1,0);

	for(int i=0;i<n;i++){
		cin>>a.at(i);
		ruisekiA.at(i+1)=ruisekiA.at(i)+a.at(i);
	}
	for(int i=0;i<m;i++){
		cin>>b.at(i);
		ruisekiB.at(i+1)=ruisekiB.at(i)+b.at(i);
	}

	for(long long i=0;i<=n;i++){
		long long left=k-ruisekiA.at(i);
		auto it=upper_bound(ruisekiB.begin(),ruisekiB.end(),left);
		if(it==ruisekiB.begin()) continue;

		ans=max(ans,i+distance(ruisekiB.begin(),it)-1);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 9588
X = int(input())

if 400 <= X and X < 600:
    print(8)
elif 600 <= X and X < 800:
    print(7)
elif 800 <= X and X < 1000:
    print(6)
elif 1000 <= X and X < 1200:
    print(5)
elif 1200 <= X and X < 1400:
    print(4)
elif 1400 <= X and X < 1600:
    print(3)
elif 1600 <= X and X < 1800:
    print(2)
elif 1800 <= X and X < 2000:
    print(1)

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(max(A,C)-min(A,C)<=D || (max(A,B)-min(A,B)<=D && max(B,C)-min(B,C)<=D)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())

if x/(a**2)>=b:
    print(0)
elif x/(a**2)>=b*0.5:
    print(90-math.degrees(math.atan((a*0.5)/(b-x/a**2))))
else:
    print(math.degrees(math.atan(b/(2*x/(a*b)))))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e5 + 5;
set<int> p[2];
int b[2][MAX];
int mn[2];

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

    ll ans = 1LL * (n - 2) * (n - 2);
    mn[0] = mn[1] = n;

    fori (i, 0, q) {
        int type, x;
        cin >> type >> x;

        type--;

        auto &s = p[type];
        auto it = s.lower_bound(x);

        if (it != begin(s)) b[type][x] = b[type][*prev(it)];
        else b[type][x] = mn[!type];

        ans -= b[type][x] - 2;

        s.insert(x);
        mn[type] = min(mn[type], x);
    }

    cout << ans << endl;
}

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



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

int main(){
  string a; cin >>a;
  int n, sum=0; n=a.length();

  for(int i=0; i<n/2; i++)
  {if(a[i] != a[n-i-1]) sum++;}
  
  cout <<sum;

return 0;
}

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

#define lint long long

lint MOD = 1000000007;

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; ++i){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    
    cout << d[N/2] - d[N/2 - 1] << endl;
    
}

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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXH=300001;
const int MAXW=300001;
int main(){
    int H,W,M;cin >> H >> W >> M;
    ll tate[MAXW];
    ll yoko[MAXH];
    bool onw[MAXW];
    bool onh[MAXW];

    memset(onw, false, sizeof(onw));  
    memset(onh, false, sizeof(onh));  
    memset(tate, 0, sizeof(tate));
    memset(yoko, 0, sizeof(yoko));
    int h[MAXH];
    int w[MAXW];
    rep(i,M){
        cin >> h[i] >> w[i];
        tate[w[i]]++;
        yoko[h[i]]++;
    }
    ll ans = 0;
    ll maxw=0,maxh=0;
    ll x=0,y=0;
    Rep(i,W){
        maxw = max(tate[i],maxw);
    }
    Rep(i,W){
        if(maxw==tate[i]){
            onw[i] = true;
            x++;
        }
    }

    Rep(i,H){
        maxh = max(maxh,yoko[i]);
    }

    Rep(i,H){
        if(maxh==yoko[i]){
            onh[i] = true;
            y++;
        }
    }

    ans = x*y;
    rep(i,M){
        if(onw[w[i]] && onh[h[i]]){
            ans--;
        }
    }

    ll tma = maxh+maxw;
    if(ans>0)cout << tma << endl;
    else cout << tma-1 << endl;

    return 0;
}

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


using namespace std;

long long n, a[100002], v[100002], ans[100002];
vector<int>p;

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    a[i] = v[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = n; i >= 1; i--) {
    while (!p.empty() && v[i] >= v[p.back()])
      p.pop_back();
    p.push_back(i);
  }
  p.push_back(0);
  int poz = n;
  for (int i = 0; i < p.size() - 1;i++) {
    ans[p[i]] += (v[p[i]] - v[p[i + 1]]) * (n - poz);
    while (poz > 0 && a[poz] > v[p[i + 1]]) {
      ans[p[i]] += (a[poz] - v[p[i + 1]]);
      poz--;
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 3960
/*
 *  Author: Tara Prasad
 */
#include <bits/stdc++.h>
// #include "prettyprint.h"
using namespace std;

// #define LOGGING // May cause TLE or CE
#ifdef LOGGING
	#define LOG(x) cerr << "*** " << x << " ***" << endl;
	#define wi(x) what_is(x, '\n')
	#define wisp(x) what_is(x, ", ")
	#define what_is(x, terminator) cerr << #x << " = " << x << terminator;
#else
	#define LOG(x)
	#define wi(x)
	#define wisp(x)
	#define what_is(x, terminator)
#endif

#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define REV_ALL(x) x.rbegin(), x.rend()
#define SZ(x) (int)x.size()
#define CONTAINS(cont, val) (cont.find(val) != cont.end())
#define endl '\n'
#define IO_SPEED_UP ios::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, s, e) for(ll i = s; i < e; i++)
#define leftmost_set(x) __builtin_clzll(x)
#define PARENT(n) ((n) >> 1LL)
#define LCHILD(n) ((n) << 1LL)
#define RCHILD(n) (((n) << 1LL) + 1LL)
#define TWO_POWER(n) (1LL << (n))

typedef long long ll;typedef pair<ll, ll> ii;
typedef vector<ll> vi;typedef vector<bool> vb;
typedef vector<ii> vii;typedef vector<vi> vvi;

const ll PINF = 1E9 + 5;
const ll NINF = -1E9 - 5;
const ll M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

void get_arr(vi& a, int n) {
	if(SZ(a) < n) a.resize(n); for(int i = 0; i < n; i++) cin >> a[i];
}

void print_arr(const vi &a) {
	for(int i = 0; i < SZ(a); i++) {cout << a[i] << " ";} cout << endl;
}

int main() {
	IO_SPEED_UP;
	if(fopen("tupni.txt", "r")) {
		freopen("tupni.txt", "r", stdin);
		freopen("tuptuo.txt", "w", stdout);
	}

	vector<pair<double, pair<ll, ll> > > costs(4);
	vi values(4);
	for (ll i = 0; i < 4; ++i) {
		cin >> values[i];
		costs[i].S.F = values[i];
		costs[i].S.S = TWO_POWER(i);
		costs[i].F = costs[i].S.F / (double)costs[i].S.S;
	}
	sort(ALL(costs));
	ll n; cin >> n;
	ll cost = 0;
	for (int i = 0; i < 4; ++i) {
		if(n > 0) {
			int q = (4 * n) / costs[i].S.S;
			n -= (q * costs[i].S.S) / 4;
			cost += q * costs[i].S.F;
		}
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  s,w = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  if s > w:
    print("safe")
  else:
    print("unsafe")

if __name__ == '__main__':
  main()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,S;
    cin >> N >> K >> S;
    vec<ll> ans;
    int inf = 1e9;
    for(int i=0;i<K;i++) ans.push_back(S);
    for(int i=K;i<N;i++) ans.push_back((S!=inf? S+1:inf-1));
    for(int i=0;i<N;i++) cout << ans[i] << (i!=N-1? " ":"\n");
}

Measured memory_bytes: 2292
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
       int n = in.nextInt();
       int k = in.nextInt();
       ArrayList<Integer> list = new ArrayList<>(k);
      while(k--!=0){
          list.add(in.nextInt());}
      while(true){
          boolean flag = true;
          String s = n+"";
           for (int i =0;i<s.length();i++){
              if (list.contains(Character.getNumericValue(s.charAt(i)))){
                  flag = false;}}
              if(flag){
                  break;}
              else{
                  n++;}}
        System.out.println(n);
      }
}
     


Measured memory_bytes: 36572
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            
            String s = br.readLine();
            String t = br.readLine();
            t = t.substring(0, s.length());
            
            PrintWriter pw = new PrintWriter(System.out);
            pw.println((s.equals(t)) ? "Yes" : "No");
            pw.flush();
            
        }
    }
}

Measured memory_bytes: 32468
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
LL cost[80 + 1];
LL n;
LL solve(LL prev_cash, LL prev_stocks)
{
    LL i, j, k, t, temp, next_day;
    LL ans = -1;
    for (i = 1; i <= n;)
    {
        //debug(i);
       // debug(prev_cash);
       // debug(prev_stocks);
        LL now = i;
        while (now <= n - 1 && cost[now + 1] >= cost[now])
        {
           // debug(now);
            now++;
        }

        LL final_day = now;
       // debug(final_day);
        LL money_got = prev_cash + prev_stocks * (cost[final_day]);
        if (final_day < n)
        {
            next_day = final_day + 1;
            prev_stocks = money_got / cost[next_day];
            prev_cash = money_got % cost[next_day];
        }
        else
        {
            break;
        }

        i = next_day;
        //part;
    }
    return prev_cash + cost[n] * prev_stocks;
}

const LL M = 1000;
LL dp[81][M + 1] = {0};

int main()
{
    fastinput;
    LL i, j, k, t, temp, tc;
    cin >> n;
    //dp[i][j]->ith day, j stocks

    const LL INF = 10000000000000000;

    for (i = 1; i <= n; i++)
    {
        cin >> cost[i];
    }
    LL prev_money = 1000;
    LL prev_stocks = 0;
    LL maxima = 1000;
    for (i = 0; i <= 10; i++)
    {
        LL spend = cost[1] * i;
        LL left = 1000 - spend;
        if (left >= 0)
        {
            LL ans = solve(left, i);
            maxima=max(maxima,ans);
        }
    }
    cout << maxima << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

  vector<int> start(26, -1);
  vector<int> goal(26, -1);

  REP(i,s.size()) {
    int a = s[i] - 'a';
    int b = t[i] - 'a';

    if (start[a] != -1 || goal[b] != -1) {
      if (start[a] != b || goal[b] != a) {
        COUT("No");
        return 0;
      }
    }
    start[a] = b;
    goal[b] = a;
  }

  COUT("Yes");
  return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int N,K;
	int dp[11][2001];
	int c,g;
	vector<int> tp[11];
	
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d %d",&c,&g);
		tp[g].push_back(c);
	}
	for(int i=1;i<=10;i++){
		sort(tp[i].begin(),tp[i].end());
		reverse(tp[i].begin(),tp[i].end());
		for(int j=1;j<=K;j++){
			int sum=0;
			for(int k=0;k<=(int)tp[i].size();k++){
				if(j-k<0)
				break;
				if(k)
				sum+=tp[i][k-1];
				dp[i][j]=max(dp[i][j],dp[i-1][j-k]+(k-1)*k+sum);
			}
		}
	}
	printf("%d\n",dp[10][K]);
}


Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int bemiho,katoshi,kosakana = 0;
  cin >> bemiho >> katoshi >> kosakana;
  int nibuchan = 0;
  nibuchan = 10*katoshi + kosakana;
  if(nibuchan % 4 == 0){
    cout << "YES" << endl;
  }
  else{ 
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
mod = 998244353
N = int(input())
X = input()
X_ = []
for i in range(N):
    if X[i]=='0':
        X_.append('1')
    else:
        X_.append('0')
X_ = ''.join(X_)

d = []
for n in range(1,N+1):
    if N%n==0 and (N//n)%2==1:
        d.append(n)

p_d = {}

for n in d:
    p_d[n] = 0
    S = (X[:n]+X_[:n])*(N//n//2)+X[:n]
    p_d[n] += int(X[:n],2)%mod
    if S<=X:
        p_d[n] += 1

ans = 0
for i in range(len(d)):
    n = d[i]
    for j in range(i):
        m = d[j]
        if n%m==0:
            p_d[n] -= p_d[m]
    ans += p_d[n]*2*n
ans %= mod
print(ans)

Measured memory_bytes: 5220
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n;
int main() {
    IOS
    cin >> n;
    vector<int> arr(n), arr2(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        arr2[i] = arr[i];
    }
    sort(arr.rbegin(), arr.rend());
    for (int i = 0; i < n; ++i) {
        if (arr2[i] == arr[0]) {
            cout << arr[1] << endl;
        } else {
            cout << arr[0] << endl;
        }
    }

    return 0;


}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=5005;
int n,K,mn=233,mx;
char s[N],t[N],ans[N];

void doit(int K,int l,int r){
	rep(T,1,K-1){
		rep(i,1,l-1)t[i]=t[i+n-(l-1)];
		reverse(t+l,t+n+1);
		if(r<n)l=n-(r-l),r=n;
		else l=2*l-n-1;
		if(l<=0)return;
	}
	rep(i,l,n)t[i-l+1]=t[i];
	reverse(t+n-l+2,t+n+1);
}

int main(){
	read(n),read(K);
	K=min(K,15);
	scanf("%s",s+1);
	memcpy(ans,s,sizeof s);
	rep(i,1,n)
		mn=min(mn,(int)s[i]);
	for(int l=1,r;l<=n;l++)
		if(s[l]==mn){
			for(r=l;r<n&&s[r+1]==mn;r++);
			if(r-l<mx&&r<n)continue;
			mx=max(mx,r-l);
			memcpy(t,s,sizeof s);
			doit(K,l,r);
			if(strcmp(t+1,ans+1)<0)memcpy(ans,t,sizeof t);
			l=r;
		}
	puts(ans+1);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
using ll = long long int;

const int C_NUM = 26;
const int D_MAX = 366;
int D;
int c[C_NUM+5];
int s[D_MAX][C_NUM+5];

int t[D_MAX];
int last[C_NUM+5];


int main(){
    cin >> D;
    for(int i = 1; i <= C_NUM; i++)cin >> c[i];
    for(int i = 1; i <= D; i++){
        for(int j = 1; j <= C_NUM; j++){
            cin >> s[i][j];
        }
    }
    memset(last, 0, sizeof(last));
    for(int i = 1; i <= D; i++){
        ll merit = 0;
        int choice = 1;
        for(int j = 1; j <= C_NUM; j++){
            ll nowm = s[i][j];
            nowm += c[j] * (i - last[j]);
            if (nowm > merit){
                merit = nowm;
                choice = j;
            }
        }
        last[choice] = i;
        t[i] = choice;
        cout << choice << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
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 ar = sc.next();
String[] s = ar.split("");
               boolean flg = true;
		for(int i = 0; i < a; i++){
                     if( s[i].equals("-")) flg = false;
               }
               if ( !(s[a].equals("-"))) flg =false;
		for(int i = a+1; i < a+b+1; i++){
                     if( s[i].equals("-") )flg =false;
               }
              if (flg)                System.out.print("Yes");
             else  System.out.print("No");
	}
}


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

int main(){
    int a,b,c,d,e,k;
    cin>>a;cin>>b;cin>>c;cin>>d;cin>>e;cin>>k;
    if(e-a<=k){
        cout<<"Yay!"<<endl;
    }   
    else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n=sc.nextInt();
            if(n==0) {
                break;
            }
            Integer[] l=d(n);
            if(l[0]==l[1]&&l[1]==l[2]&&l[2]==l[3]) {
                System.out.println("NA");
                continue;
            }
            int c=0;
            while(n!=6174) {
                c++;
                l=d(n);
                Arrays.sort(l,Comparator.reverseOrder());
                int a=c(l);
                Arrays.sort(l);
                int b=c(l);
                n=a-b;
            }
            System.out.println(c);
        }
    }
    static int c(Integer[] l) {
        int n=0;
        for(int i=0,j=1000;i<4;i++,j/=10) {
            n+=l[i]*j;
        }
        return n;
    }
    static Integer[] d(int n) {
        Integer[] l=new Integer[4];
        for(int i=0,j=1000;i<4;i++,j/=10) {
            l[i]=n/j;
            n%=j;
        }
        return l;
    }
}


Measured memory_bytes: 43440
// ------------------------------------
// Date:2018/ 3/17
// Problem:ARC 077 PushPush c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;
typedef vector< ll > V;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head;CINT(move(tail)...);
}

#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1000000007;
static const int MAX_N = 1e4;

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

  CIN(N);
  vector< int > a(N);
  REP(i, N) cin >> a[i];
  deque< int > dq;
  int tmp = N % 2;
  REP(i, N) {
    if (i % 2 == tmp) {
      dq.push_back(a[i]);
    } else {
      dq.push_front(a[i]);
    }
  }

  while(!dq.empty()) {
    cout << dq.front();
    dq.pop_front();
    if (!dq.empty()) cout << " ";
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n, r;
        cin >> n >> r;
        if(n == r && r == 0) break;
        int p[55];
        int c[55];
        for(int i = 1; i <= r; i++) cin >> p[i] >> c[i];
        int pos = 1;
        for(int i = r; i >= 1; i--) {
            if(pos > c[i] + p[i] - 1) continue;
            if(pos <= c[i]) {
                pos += p[i] - 1;
                continue;
            }
            pos -= c[i];
        }
        cout << n + 1 - pos << endl;
    }
    return 0;
}


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

std::set<uint64_t> set;

void check(uint64_t n) {
  const auto str = std::to_string(n);
  if (std::find(str.begin(), str.end(), '3') != str.end()
    && std::find(str.begin(), str.end(), '5') != str.end()
    && std::find(str.begin(), str.end(), '7') != str.end()) {
      set.insert(n);
  }
}
void gen(int i, uint64_t n) {
  if (i == 0) {
    check(n);
  } else {
    if (n == 0) {
      gen(i - 1, 0);
    }
    gen(i - 1, n * 10 + 3);
    gen(i - 1, n * 10 + 5);
    gen(i - 1, n * 10 + 7);
  }
}

int main() {
  gen(9, 0);

  uint64_t n;
  std::cin >> n;
  uint64_t count = 0;
  for (const auto i : set) {
    if (i <= n) {
      count++;
    } else {
      break;
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include<string>

int main() {
	int n;
  	scanf("%d", &n);
  
  	int ac = 0, wa = 0, tle = 0, re = 0;
  	for (int i = 0; i < n; i++) {
    	std::string testCase;
      	std::cin >> testCase;
      	
      	if (testCase == "AC") {
        	ac++;
        } else if (testCase == "WA") {
        	wa++;
        } else if (testCase == "TLE") {
        	tle++;
        } else if (testCase == "RE") {
        	re++;
        }
    }
  
  	std::cout << "AC x ";
  	std::cout << ac << std::endl;
  	std::cout << "WA x ";
  	std::cout << wa << std::endl;
  	std::cout << "TLE x ";
  	std::cout << tle << std::endl;
  	std::cout << "RE x ";
  	std::cout << re << std::endl;
  	return 0;
}

Measured memory_bytes: 3692
package main

import (
	"bufio"
	"fmt"
	"os"
)

var writer = bufio.NewWriter(os.Stdout)

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)

	var max = A
	if B < A {
		max = B
	}
	var min = A + B - N
	if min < 0 {
		min = 0
	}
	fmt.Fprintf(writer, "%d %d\n", max, min)
	_ = writer.Flush()
}


Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int diff = 0;
		
		String[] ss = s.split("");
		String[] tt = t.split("");
		
		for(int i=0;i<ss.length;i++) {
			if(ss[i].equals(tt[i])) {
			}else {
				diff++;
			}
		}
		
		System.out.println(diff);

	}
}

Measured memory_bytes: 67184
n = gets.chomp.to_i
ama = n % 2
aa = gets.chomp.split.map(&:to_i)
stt = n / 2
hd = Array.new(stt)
tl = Array.new(stt)

if ama == 1
    ct = aa.shift
else
    ct = nil
end

if aa.size == 0
    puts ct
    exit
end


j = 0
k = 0
n.times do |i|
    if i % 2 == 0
        tl[j] = aa[i]
        j += 1
    else
        pos = stt - k - 1
      hd[pos] = aa[i]
      k += 1
    end
end


# print hd.join(' ')
print hd.join(' ')
if ct
   print ' '
   print ct
   print ' '
else
   print ' '
end

puts tl.join(' ')


Measured memory_bytes: 27276
k = int(input())
n = [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]
print(n[k-1])




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


int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> array(n);
    int cnt = 0;
    for(int i=1;i<n;i++){
        if(s.at(i-1) == 'A' && s.at(i) == 'C'){
            array.at(i) = array.at(i-1)+1;
        }else{
            array.at(i) = array.at(i-1);
        }
    }

    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        cout << array.at(r-1) - array.at(l-1) << endl;
    }
}

Measured memory_bytes: 3756
#include <iostream>
#include <cstring>
using namespace std;
using namespace std;
int main(){
    string s;
    while(cin >> s){
        char res = '0';
        for(int i=0; i<3; ++i){
            if(s[3*i] == s[3*i+1] && s[3*i] == s[3*i+2] && s[3*i] != 's'){
                res = s[3*i];
            } else if(s[i] == s[i+3] && s[i] == s[i+6] && s[i] != 's'){
                res = s[i];
            } else if(s[0] == s[4] && s[0] == s[8] && s[0] != 's'){
                res = s[0];
            } else if(s[2] == s[4] && s[2] == s[6] && s[2] != 's'){
                res = s[2];
            }
        }
 
        if(res == '0'){
            res = 'd';
        }
 
        cout << res << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1176
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            S = 500*i + 100*j + 50*k
            if S == X:
                cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  sort(d.begin(),d.end());
  int ans = 0;
  for(int i=0;i<N-1;i++){
    if(d.at(i)==d.at(i+1)){
      ans++;
    }
  }
  cout<<N-ans<<endl;
  return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


int main() {
	li n;
	cin >> n;

	cout << 0 << endl;

	string state0;
	cin >> state0;
	if (state0 == "Vacant") {
		return 0;
	}
	cout << n - 1 << endl;
	string state1;
	cin >> state1;
	if (state1 == "Vacant") {
		return 0;
	}

	li left = 0;
	li right = n - 1;
	rep(i, 19) {
		li med = (left + right) / 2;
		cout << med << endl;
		string state;
		cin >> state;
		if (state == "Vacant") {
			return 0;
		}
		if ((med - left) % 2 == 0) {
			if (state == state0) {
				left = med;
				state0 = state;
			} else {
				right = med;
			}
		} else {
			if (state == state0) {
				right = med;
			} else {
				left = med;
				state0 = state;
			}
		}
	}
	throw;


	return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    auto p_s = p;
    sort(p_s.begin(), p_s.end());
    int check = 0;
    for (int i = 0; i < n; ++i) {
        if (p[i] != p_s[i]) ++check;
    }
    if (check <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;

int main(){
  int N, L;
  cin >> N >> L;
  int mini = 1e7, taste = 0, sum = 0;
  for (int i=0; i<N; i++){
    if (mini > abs(L + i)){
      mini = abs(L + i);
      taste = L + i;
    }
    sum += L + i;
  }
  cout << sum - taste << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

ll N, Q;
string s;
char t[MAX*2], d[MAX*2];

//左から脱落するなら1を返す
ll LC(ll u) {
  for(ll i=0; i<Q; i++) {
    if(t[i]==s[u]) {
      if(d[i]=='L') u--;
      if(d[i]=='R') u++;
      
      if(u<0) return 1;
      if(u>=N) return 0;
    }
  }
  
  return 0;
}

//右から脱落するなら1を返す
ll RC(ll u) {
  for(ll i=0; i<Q; i++) {
    if(t[i]==s[u]) {
      if(d[i]=='L') u--;
      if(d[i]=='R') u++;
      
      if(u<0) return 0;
      if(u>=N) return 1;
    }
  }
  
  return 0;
}

int main(void) {
  cin >> N >> Q;
  cin >> s;
  ll i;
  
  for(i=0; i<Q; i++) {
    cin >> t[i] >> d[i];
  }
  
  ll lan=0, ran=0;
  
  ll l=0, r=N;
  while(l+1<r) {
    ll mid=(l+r)/2;
    if(LC(mid)) l=mid;
    else r=mid;
  }
  lan=l;
  
  l=0; r=N;
  while(l+1<r) {
    ll mid=(l+r)/2;
    if(RC(mid)) r=mid;
    else l=mid;
  }
  ran=l;
  
  pt(max(0, ran-lan));
  
}




Measured memory_bytes: 900
#include <cstdio>

int main(){
    char o[51],e[51];
    scanf("%s\n%s",o,e);

    int count_o = 0;
    int count_e = 0;
    int count_d;
    for(int i = 0; o[i] != '\0'; i++){
        count_o++;
    }
    for(int i = 0; e[i] != '\0'; i++){
        count_e++;
    }
    count_d = count_o + count_e;

    if(count_d % 2 == 0){
        for(int i = 0; i < count_o; i++){
            printf("%c%c",o[i],e[i]);
        }
    }else{
        for(int i = 0; i < count_e; i++){
                printf("%c%c",o[i],e[i]);
        }
        printf("%c",o[count_o - 1]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
main () {
	int n, a=0, b=0;
	cin >> n;
	for (int i=0; i<n; i++) {
		string s1, s2;
		cin >> s1 >> s2;
		if (s1 > s2) a += 3;
		else if (s1 < s2) b += 3;
		else {
			a++;
			b++;
		}
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 3152
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let l: usize = sc.next();
    let mut m = l;
    let mut bits: Vec<usize> = Vec::new();
    let mut ones = 0;
    while m > 1 {
        bits.push(m % 2);
        if m % 2 == 1 {
            ones += 1;
        }
        m /= 2;
    }
    let len = bits.len();
    println!("{} {}", len+1, 2 * len + ones);
    let mut max = 2usize.pow(len as u32);
    for i in 0..len {
        println!("{} {} 0", i+1, i+2);
        println!("{} {} {}", i+1, i+2, 2usize.pow(i as u32));
    }
    for i in 0..len {
        if bits[len-i-1] == 1 {
            println!("{} {} {}", len - i, len+1, max);
            max += 2usize.pow((len-i-1) as u32);
        }
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=1000;i++){
        if(i*2/25==a && i/10==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<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 reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

string s[100][100];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    char a = 'A';
    cin >> h >> w;
    reps(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }   
    reps(i,h){
        rep(j,w){
            if(s[i][j] == "snuke"){
                cout << char(a + j) << i << '\n';
                return 0;
            }
        }
    }   
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
int cnt[N];

int32_t main()
{
	fast;

	for(int i=1;i<=4;i++)
	{
		char x;
		cin>>x;
		cnt[x]++;
	}
	int f = 0;
	for(int i='A';i<='Z';i++)
		if(cnt[i]==2)
			f++;

	if(f==2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

using namespace std;

int main()
{
    vector<int> num;
    int u,k;

    for(int i=0;i<3;i++)
    {
        cin>>u;
        num.push_back(u);
    }
    cin>>k;

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

    long long rmax = num[2];

    for(int i=0;i<k;i++)
    {
        rmax = rmax * 2;
    }

    cout<<rmax + num[0] + num[1]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a,b) for(it=a;it!=b;it++)
#define dzkt int T;cin>>T;while(T--)
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int pow2(int a,int b) {int s=1; while(b) {if(b&1) s*=a; a*=a; b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
const int N=2e5+10,inf=1e9+10;
const ll ma=1e18;
char ch[N];
ll a[N],n,f=0;
int main()
{
    iosks;
    cin>>n;
    xh1(0,n) {cin>>a[i]; if(a[i]==0) f=1;}
    if(f) {cout<<0<<endl;return 0; }
    ldb c=1.0;
    ll ans=1;
    xh1(0,n){
        c*=a[i];ans*=a[i];
        if(c>ma) {cout<<-1<<endl; return 0; }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4440
h,w=map(int,input().split())
pattern=[h//2+w//3+1,h//3+w//2+1,h,w]
if h%3==0 or w%3==0:
    pattern+=[0]
if h%2==0:
    pattern+=[h//2]
if w%2==0:
    pattern+=[w//2]
print(min(pattern))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

typedef pair<int, P> PP;

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

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    auto dist = make_vec(h, w, INF);
    priority_queue<PP, vector<PP>, greater<PP>> que;
    dist[sy][sx] = 0;
    que.emplace(dist[sy][sx], P(sy, sx));
    while(!que.empty())
    {
        //auto [d, v] = que.top();
        auto p = que.top();
        que.pop();
        int d = p.first; auto v = p.second;
        int y = v.first, x = v.second;
        if(dist[y][x] < d) continue;
        rep2(dy,-2,3) rep2(dx,-2,3)
        {
            int ny = y + dy;
            int nx = x + dx;
            int nd = d;
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(field[ny][nx] == '#') continue;
            if(abs(dy) + abs(dx) > 1) //移動2を使う
            {
                nd++;
            }
            if(chmin(dist[ny][nx], nd))
            {
                que.emplace(nd, P(ny, nx));
            }
        }
    }

    int ans = dist[gy][gx];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    //cout << dist << endl;

    return 0;
}

Measured memory_bytes: 8600
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define triiset(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll

int main()
{
    fast();
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ele=1;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==ele)
        {
            ele++;
        }
    }
    if(ele==1)
    {
        cout<<-1<<nl;
    }
    else
    {
        ele--;
        cout<<n-ele<<nl;
    }
}


Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;

int solve(int n, int k) {
  return (n - k + 1);
}

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

  cin >> n;
  cin >> k;

  cout << solve(n, k);

  return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto numbers = aryread();
    auto max_num = reduce!max(numbers);
    long count;
    foreach (ref e; numbers)
    {
        e = max_num - e;
        while(e > 1)
        {
            e -= 2;
            count++;
        }
    }
    auto ary_sum = numbers.sum();
    if(ary_sum > 0)
    {
        count += 3 - ary_sum;
    }

    writeln(count);
}

Measured memory_bytes: 256
using System;
public class Hello
{
    private static long DivisorCount(long b, long e)
    {
        long count = e / b;
        return (b + e) * count / 2;
    }
    
    public static void Main()
    {
        long sum = 0;
        long N = int.Parse(Console.ReadLine());
        for  (int i = 1; i <= N; i++)
        {
            sum += DivisorCount(i, N / i * i);
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 27532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String args[]) throws IOException{
		Scanner sc = new Scanner(System.in);
		
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st = new StringTokenizer(br.readLine());
		
		//StringBuilder sb = new StringBuilder();
		
		int n = sc.nextInt();
		
		System.out.println(n<3 ? 0 : n/3);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define LL long long
 
const int N = 2e5 + 5;
 
LL n, ans, a[N], cnt[N];
 
int main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        ++cnt[a[i]];
    }
	for (int i = 1; i <= n; ++i) ans += cnt[i] * (cnt[i] - 1) / 2;
	for (int i = 1; i <= n; ++i)
		printf("%lld\n", ans - cnt[a[i]] + 1);
	return 0;
}

Measured memory_bytes: 4736
// written by IftekharMd.Shishir   :)   12.4.2020

#include<bits/stdc++.h>

#define ll          long long int
#define ull         unsigned long long int
#define f(i,n)      for(i=0;i<n;i++)
#define F(i,n)      for(i=n;i>=0;i--)
#define fa(i,a,b)   for(i=a;i<b;i++)
#define Fa(i,a,b)   for(i=a;i>=b;i--)
#define vec         vector<long long int>
#define que         queue<long long int>        //a.push(x)   a.pop()    a.back()    a.front()
#define pb(x)       push_back(x)
#define pob()       pop_back()
#define sor(a)      sort(a.begin(),a.end())
#define rev(a)      reverse(a.begin(),a.end())  // string or array reverse
#define ins(a,x)    insert(a.begin(),x)         // push in front
#define points(x)   fixed<<setprecision(x)
#define done        return 0

/*----------[ string to integer ]--------------
string str;  int x=0;
stringstream demo(str);
demo >> x;
cout<< x <<endl;
*/

/*----------[ integer to string ]--------------
string name;  int x=345;
stringstream demo;
demo << x;
name=demo.str();
cout<< name <<endl;
*/
using namespace std;

int main()
{
    ll i,n,s=0;
    cin>>n;
    fa(i,1,n+1){
        if(i%3!=0 && i%5!=0) s+=i;
    }
    cout<<s<<endl;
    done;
}






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

bool is_sum(const int n,const int a,const int b){
   int mod_val,sum_val,num;
   num = n;
   sum_val = 0;
   while(num){
      mod_val = num % 10;
      sum_val += mod_val;
      num /= 10;
   }
   if(a <= sum_val && sum_val <= b){
      return true;
   }
   return false;
}

int main(int argc, char const *argv[]){
   int N,A,B;
   long long result;
   cin >> N >> A >> B;
   result = 0;
   for(int i = 1;i <= N;i++){
      if(is_sum(i,A,B)){
         result+=i;
      }
   }
   cout << result << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef _LOCAL
    #define test(x) cerr << #x << "=" << x << endl
#else
    #define test(x)
#endif

typedef long long LL;

const int N = 2e5+5;

int main(){
    #ifdef _LOCAL
        freopen("data.in", "r", stdin);
    #endif
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int ans = b + c - a;
    if(ans < 0) ans = 0;
    cout << ans << endl;
    #ifdef _LOCAL
        fprintf(stderr, "T: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC));
    #endif
    return 0;
}

Measured memory_bytes: 256