akhauriyash/Code-Regression huggingface dataset:
#n,m,q = 3,4,3 # n個で m以下の A
#arr = [[1, 3, 3, 100], [1, 2, 2, 10], [2, 3, 2, 10]]

n,m,q = map(int,input().split())
arr = [list(map(int,input().split())) for i in range(q)]

#n,m,q=map(int,input().split())
#arr=[list(map(int,input().split())) for _ in range(q)]

score = 0
for a1 in range(1,m+1):
  for a2 in range(a1,m+1):
    for a3 in range(a2,m+1):
      for a4 in range(a3,m+1):
        for a5 in range(a4,m+1):
          for a6 in range(a5,m+1):
            for a7 in range(a6,m+1):
              for a8 in range(a7,m+1):
                for a9 in range(a8,m+1):
                  for a10 in range(a9,m+1):
                    x = [0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
                    tmp_score=0
                    for a,b,c,d in arr:
                      if(x[b]-x[a] == c):
                        tmp_score += d
                    score = max(score,tmp_score)
print(score)


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    vector<int>q(n);
    f(i,0,n){
        cin >> q[i];  
    }
    sort(all(q));
    int s = 0;
    f(i,0,k){
        s += q[i];
    }
    cout << s << "\n";
    
    return 0;
}
 

Measured memory_bytes: 3584
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    from math import floor
    a, b = map(int, input().split())
    ax = 0
    bx = 0
    for i in range(1,1500):
        ax = floor(i * 0.08)
        bx = floor(i * 0.1)
        if ax == a and bx == b:
            print(i)
            return 0
    print(-1)

if __name__ == '__main__':
    main()



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

#define mx 100005
#define md 1000000007

using namespace std;

int n, m, a, b, pr[mx], an[mx], ans;
vector<int> p[mx];
stack<int> st;

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d%d", &a, &b); a--; b--;
    p[a].push_back(b);
    pr[b]++;
  }
  for(int i = 0; i < n; i++) if(!pr[i]) st.push(i);
  while(!st.empty()){
    int tmp = st.top(); st.pop();
    for(int it: p[tmp]){
      an[it] = max(an[it], an[tmp]+1);
      ans = max(ans, an[it]);
      if(!(--pr[it])) st.push(it);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 6528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EigenFunk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStationAndBus solver = new AStationAndBus();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStationAndBus {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.nextLine();
            if (str.indexOf("A") == -1 || str.indexOf("B") == -1) {
                out.println("No");
            } else {
                out.println("Yes");
            }
        }

    }
}



Measured memory_bytes: 23636
#include <stdio.h>
 
int main() {
  int i,n,j,k;
  int b,f,r,v;
  int p[4][3][10]={0};
 
 
 
  scanf("%d",&n);
 
  for(i =0; i <n; i++) {
    scanf("%d %d %d %d",&b,&f,&r,&v);
    p[b-1][f-1][r-1] += v;
  }
 
  for(k=0; k<4; k++) {
    for(j=0; j<3; j++) {
      for(i=0; i<10;i++) {
    printf(" %d",p[k][j][i]);
      }
      printf("\n");
    }
    if(k == 3){
      break;
    }
    printf("####################\n");
 
  }
  return 0;
}


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


#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

const long long mx = 1e7 + 1;
long long a[mx] = {0};

int main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	long long n;
	cin >> n;
	for(long long i=1; i<=n; i++){
	    for(long long j=0; j<=n; j+=i){
		a[j]++;
	    }
	}
	long long  ans = 0;
	for(long long i=1; i<=n; i++){
	    ans += (i*a[i]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 81728
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    for(int CASE = 1; CASE <= N; ++CASE) {
        vector<string> field(8);
        for(int i = 0; i < 8; ++i) cin >> field[i];
        int sx, sy;
        cin >> sx >> sy;
        sx--; sy--;

        queue<pair<int,int> > q;
        q.push(make_pair(sx, sy));
        field[sy][sx] = '0';
        while(!q.empty()) {
            int x = q.front().first, y = q.front().second;
            q.pop();

            for(int xx = max(0, x-3); xx <= min(7, x+3); ++xx) {
                if(field[y][xx] == '1') q.push(make_pair(xx, y));
                field[y][xx] = '0';
            }
            for(int yy = max(0, y-3); yy <= min(7, y+3); ++yy) {
                if(field[yy][x] == '1') q.push(make_pair(x, yy));
                field[yy][x] = '0';
            }
        }
        cout << "Data " << CASE << ":" << endl;
        for(int i = 0; i < 8; ++i) cout << field[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define ff first
#define ss second

int main() {
    ll n, ai, bi, ci, sum = 0, q;
    int arra[100002];
    memset(arra, 0, sizeof(arra));
    cin >> n;
    while(n--){
        cin >> ai;
        arra[ai]++;
        sum += ai;
    }
    cin >> q;
    while(q--){
        cin >> bi >> ci;
        sum = sum - (bi*arra[bi]) + (ci*arra[bi]);
        arra[ci] += arra[bi];
        arra[bi] = 0;
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 4028
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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




  cin >> n;
  rep(i, 5) {
    cin >> tmp;
    mi = min(mi, tmp);
  }
  ans = 5;
  n -= mi;
  if (n > 0) ans += (n + mi - 1) / mi;
  cout << ans << endl;



  return 0;
}

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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;
	if (a > b)	return 0;
	if (a < 1 || a > 10000 || b < 1 || b  > 10000 || c < 1 || c > 10000)	return 0;

	int divisors = 0;
	for (int i = a; i <= b; ++i)
	{
		if (c % i == 0)	++divisors;
	}

	cout << divisors << endl;

	return 0;
}


Measured memory_bytes: 3112
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        int N = sc.nextInt();
        int[] s = new int[N];
        for (int i = 0; i < s.length; ++i) {
            s[i] = sc.nextInt();
        }

        System.out.println(solve(s));

        sc.close();
    }

    static long solve(int[] s) {
        long result = 0;
        for (int delta = 1; delta * 2 < s.length - 1; ++delta) {
            Set<Integer> backIndices = new HashSet<>();
            int backIndex = delta;
            long backSum = 0;
            while (backIndex < s.length - 1 - delta) {
                backSum += s[backIndex];
                backIndices.add(backIndex);
                backIndex += delta;
            }

            Set<Integer> frontIndices = new HashSet<>();
            int frontIndex = s.length - 1 - delta;
            long frontSum = 0;
            int duplicateCount = 0;
            for (int i = 0; i < backIndices.size(); ++i) {
                if (backIndices.contains(frontIndex)) {
                    ++duplicateCount;
                }

                frontSum += s[frontIndex];
                frontIndices.add(frontIndex);
                frontIndex -= delta;
            }

            int lastBackIndex = backIndex - delta;
            int firstFrontIndex = frontIndex + delta;
            while (!frontIndices.isEmpty()) {
                if (duplicateCount == 0) {
                    result = Math.max(result, frontSum + backSum);
                }

                if (frontIndices.contains(lastBackIndex)) {
                    --duplicateCount;
                }
                backSum -= s[lastBackIndex];
                backIndices.remove(lastBackIndex);
                lastBackIndex -= delta;

                if (backIndices.contains(firstFrontIndex)) {
                    --duplicateCount;
                }
                frontSum -= s[firstFrontIndex];
                frontIndices.remove(firstFrontIndex);
                firstFrontIndex += delta;
            }
        }

        return result;
    }
}

Measured memory_bytes: 75980
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,sum=0;
	scanf("%d",&n);
	int n1=n;
	while(n--)
	{
		scanf("%d",&a);
		sum+=a;
	}
	printf("%d\n",sum-n1);
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pll>> edges(2 * n);
    for (int i = 0; i < m; ++i) {
        ll u, v, s;
        cin >> u >> v >> s;
        u--, v--;
        edges[u].emplace_back(v + n, s);
        edges[v].emplace_back(u + n, s);
        edges[u + n].emplace_back(v, s);
        edges[v + n].emplace_back(u, s);
    }
    vl dist(2 * n, INF);
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int c = q.front();
        q.pop();
        for (auto &p : edges[c]) {
            int v = p.first;
            ll ne = p.second - dist[c];
            if (dist[v] != INF) {
                if (dist[v] != ne) {
                    // assert(false);
                    cout << 0 << "\n";
                    return 0;
                }
            } else {
                dist[v] = ne;
                q.push(v);
            }
        }
    }
    bool nibu = true;
    ll nzero  = INF;
    for (int i = 0; i < n; ++i) {
        if (dist[i] != INF && dist[i + n] != INF) {
            if (nzero == INF) {
                nzero = (dist[i + n] - dist[i]) / 2;
                if (nzero < 1 || (dist[i + n] - dist[i]) % 2 == 1) {
                    // assert(false);
                    cout << 0 << "\n";
                    return 0;
                }
                nibu = false;
            } else {
                if (dist[i] + nzero != dist[i + n] - nzero || dist[i] + nzero < 1) {
                    cout << 0 << "\n";
                    return 0;
                }
            }
        }
    }
    if (nibu) {
        ll odd  = INF;
        ll even = INF;
        for (int i = 0; i < n; ++i) {
            chmin(odd, dist[i]);
            chmin(even, dist[i + n]);
        }
        cout << max(0LL, odd + even - 1) << "\n";
    } else {
        cout << 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 17280
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> table(h);
    for (auto& r : table)
    {
        cin >> r;
    }
    vector<vector<int>> ans(h, vector<int>(w, -1));

    int index = 1;

    for (int i = 0; i < h; i++)
    {
        vector<int> berry = { -1 };
        for (int j = 0; j < w; j++)
        {
            if (table[i][j] == '#')
            {
                for (int l = berry.back() + 1; l <= j; l++)
                {
                    ans[i][l] = index;
                }
                index++;
                berry.push_back(j);
            }
        }
        if (berry.back() != -1)
        {
            for (int l = w - 1; l > berry.back(); l--)
            {
                ans[i][l] = ans[i][berry.back()];
            }
        }
    }

    if (ans[0][0] == -1)
    {
        for (int i = 1; i < h; i++)
        {
            if (ans[i][0] != -1)
            {
                for (int ii = 0; ii < i; ii++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        ans[ii][j] = ans[i][j];
                    }
                }
                break;
            }
        }
    }

    for (int i = 1; i < h; i++)
    {
        if (ans[i][0] == -1)
        {
            for (int j = 0; j < w; j++)
            {
                ans[i][j] = ans[i - 1][j];
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (j > 0)
            {
                cout << " ";
            }
            cout << ans[i][j];
        }
        cout << endl;
    }
}


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

int main()
{
	int N;
	int A[100005];
	int num_1, num_2, num_4;

	num_1 = num_2 = num_4 = 0;
	cin >> N;

	for ( int i = 0; i < N; i++ ) {
		cin >> A[i];
		if ( A[i] % 4 == 0 ) {
			num_4++;
		} else if ( A[i] % 2 == 0 ) {
			num_2++;
		} else {
			num_1++;
		}
	}

	if ( num_2 > 0 ) {
		num_1++;
	}

	if ( num_1 > num_4 + 1 ) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

struct Item {
  long w, v;
};

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

  Item items[n + 1];
  for (int i = 1; i <= n; i++) { cin >> items[i].w >> items[i].v; }

  long dp[n + 1][w + 1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= w; j++) { dp[i][j] = 0; }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= w; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j - items[i].w >= 0) { dp[i][j] = max(dp[i][j], dp[i - 1][j - items[i].w] + items[i].v); }
    }
  }

  cout << dp[n][w] << endl;
}



Measured memory_bytes: 79104
import java.util.Scanner
import scala.collection.mutable

object Main extends App {

  val sc = new Scanner(System.in)

  def nextInt() = sc.next.toInt

  val n = nextInt
  val seq = mutable.Seq.fill(n)(nextInt)

  var cnt = 0

  for (i <- 0 until seq.length) {
    var minj = i

    for (j <- i until seq.length)
      if (seq(j) < seq(minj))
        minj = j

    if (minj != i) {
      val tmp = seq(i)
      seq(i) = seq(minj)
      seq(minj) = tmp
      cnt += 1
    }
  }

  println(seq mkString " ")
  println(cnt)
}



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

int a[9], c[9], n = 0;
bool f[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
vector <int> b;

int main()
{
	for (int i = 0; i < 9; i++) {
		cin >> a[i];
		if (a[i] > 0)
			f[a[i] - 1] = 1;
	}

	for (int i = 0; i < 9; i++)
		if (!f[i])
			b.push_back(i + 1);

	do {
		int j = 0;
		for (int i = 0; i < 9; i++) {
			if (a[i] > 0)
				c[i] = a[i];
			else {
				c[i] = b[j];
				j++;
			}
		}
		if (c[0] + c[2] + c[5] - c[8] + (c[1] + c[4] - c[7]) * 10 + (c[3] - c[6]) * 100 == 0)
			n++;		
	} while (next_permutation(b.begin(), b.end()));

	cout << n << endl;

	return 0;
}


Measured memory_bytes: 3168
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{
        int ans = 0;
        while (N)
        {
                ans++;
                N /= 10;
        }
        return ans;
}

int main()
{
        int S;
        cin >> S;
        int ans = 0;

        for (int i = 1; i <= S; i++)
        {
                int cnt = count(i);
                if (cnt % 2 == 1)
                        ans++;
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
char str[500005];
int dp[500005];

struct s{
	int seg[(1<<20)];
	#define SZ (1<<19)
	s(){
		fill(seg,seg+(1<<20),-INF);
	}
	void update(int a,int v){
		a += SZ-1; seg[a] = v;
		while(a){
			a = (a-1)/2;
			seg[a] = max(seg[a*2+1],seg[a*2+2]);
		}
	}
	int query(int a,int b,int k,int l,int r){
		if(a > b || b < l || r < a) return -INF;
		if(a <= l && r <= b) return seg[k];
		return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2+1,r));
	}
}kaede;

int main(){
	scanf("%d",&n);
	scanf("%s",&str);
	dp[0] = 0;
	kaede.update(0,0);
	vector<int>zero;
	zero.pb(0);
	repn(i,n){
		dp[i] = dp[i-1];
		if(str[i-1] == '0'){
			zero.pb(i);
		}
		else if(zero.size() == 1){
		}
		else{
			if(str[i-2] == '0'){
				int L = zero[zero.size()-2]+1;
				int R = zero[zero.size()-1]-1;
				dp[i] = max(dp[i],kaede.query(L-1,R-1,0,0,SZ-1)+i-2);
			}
			else{
				int L = zero[zero.size()-2]+1;
				int R = zero[zero.size()-1]-1;
				if(L-1 <= R-1){
					dp[i] = max(dp[i],kaede.query(R-1,R-1,0,0,SZ-1)+i-2);
				}
			}
		}
		
		kaede.update(i,dp[i]-i); //cout << i << " " << dp[i] << endl;
	}
	
	cout << dp[n] << endl;
}

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    string s; cin >> s;
    string t = "";
    rep(i,s.size()) {
        if(t.empty() and s[i] == 'B') continue;
        if(s[i] == 'B') t.pob();
        else if(s[i] == '1') t.pub('1');
        else t.pub('0');
    }
    cout << t << endl;
    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextInt();

            var deg = 0;
            var ans = 0;
            while (true)
            {
                deg += x;
                ans++;
                if (deg == 360)
                {
                    Console.WriteLine(ans);
                    return;
                }
                if (deg > 360) deg -= 360;
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27476
fun luca(n:Int): Long {
  return (0..n).fold(Pair(0L,0L)) {sum,i ->
    when (i) {
      0 -> Pair(0L,2L)
      1 -> Pair(2L,1L)
      else -> Pair(sum.second,sum.second + sum.first)
    }
  }.second
}
fun main(args:Array<String>) {
  val N = readLine()!!.toInt()
  println(luca(N))
}


Measured memory_bytes: 33820
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)

int main(){
   long long N;
   long long D;
   int ans = 0 ;
   cin >> N >> D;
   vector <int> A(N);
   vector <int> B(N);
   for(int i = 0;i < N;i++){
       cin >> A.at(i);
       cin >> B.at(i);
   }
   
   double Z;
   for(int i = 0;i < N ; i++){
       Z = pow(A.at(i),2.0) + pow(B.at(i),2.0);
       Z = sqrt(Z);
       if(Z <= D){
           ans++;
       }

   }
   cout << ans << endl;

}


Measured memory_bytes: 4740
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<limits.h>
#include<queue>


using namespace std;


int main()
{
    char ch;
    scanf("%c",&ch);
    if(ch=='A')
    {
        printf("T");
    }
    if(ch=='T')
    {
        printf("A");
    }
    if(ch=='G')
    {
        printf("C");
    }
    if(ch=='C')
    {
        printf("G");
    }
    return 0;
}


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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll res = 0;
  ll tmp = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a > tmp) res += a-tmp;
    tmp = a;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
use input::{Input, ReadMode};

fn main() {
    let mut input = Input::new(ReadMode::Line);

    let n = input.parse();
    let k = input.parse();
    let mut s = vec![0u32; n];

    for _ in 0..k {
        let d = input.parse();
        for _ in 0..d {
            let a: usize = input.parse();
            s[a - 1] += 1;
        }
    }

    let mut ans = 0;
    for x in s.into_iter() {
        if x == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
pub mod input {
    use std::io::{BufRead, Read};

    pub enum ReadMode {
        Full,
        Line,
    }

    pub struct Input<'a> {
        lock: std::io::StdinLock<'static>,
        iter: Option<std::str::SplitAsciiWhitespace<'a>>,
        mode: ReadMode,
    }

    impl<'a> Input<'a> {
        fn naive_read(&mut self) -> Option<std::str::SplitAsciiWhitespace<'a>> {
            let mut s = Box::leak(Box::new(String::new()));
            let res = match self.mode {
                ReadMode::Full => self.lock.read_to_string(&mut s),
                ReadMode::Line => self.lock.read_line(&mut s),
            };
            res.ok().expect("failed to read");
            Some(s.split_ascii_whitespace())
        }
        pub fn new(mode: ReadMode) -> Self {
            let lock = Box::leak(Box::new(std::io::stdin())).lock();
            let iter = None;
            Self { lock, iter, mode }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.lock.read_line(&mut s).ok().expect("failed to read");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            match &mut self.iter {
                Some(iter) => {
                    let x = match iter.next() {
                        Some(x) => x,
                        None => {
                            self.iter = self.naive_read();
                            self.iter.as_mut().unwrap().next().expect("reached EOF")
                        }
                    };
                    x.parse().ok().expect("failed to parse")
                }
                None => {
                    self.iter = self.naive_read();
                    self.parse()
                }
            }
        }
    }
}


Measured memory_bytes: 2140
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1000000000000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int a[301][301];
int n;

int main(void){
	int n;
	cin >> n;
	rep(i,n)
		rep(j,n)
			cin >> a[i][j];
	rep(i,n)
		rep(j,n)
			rep(k,n) {
				if (a[i][j] + a[j][k] < a[i][k]) {
					cout << -1 << endl;
					return 0;
				}
			}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i+1; j < n; ++j) {
			bool edge = true;
			rep(k,n) {
				if (k != i && k != j && a[i][k] + a[k][j] == a[i][j]) {
					edge = false;
					break;
				}
			}
			if (edge)
				ans += a[i][j];
		}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

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

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

	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}

	int a, b;
	cin >> a >> b;

	cout << a + b << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Delivery Fee
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] s = {60,80,100,120,140,160};
		int[] w = {2,5,10,15,20,25};
		int[] p = {600,800,1000,1200,1400,1600,0};
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int t = 0;
			for(int i=0;i<n;i++){
				int size = sc.nextInt()+sc.nextInt()+sc.nextInt();
				int we = sc.nextInt();
				int k = 0;
				while(k<6 && !(size<=s[k]&&we<=w[k]))k++;
				t+=p[k];
			}
			System.out.println(t);
		}
	}
}

Measured memory_bytes: 0
import sys
from collections import deque

def solve(tree, u, v):

    colors = {}
    colors[u] = 0
    stack = deque([u])
    while stack:
        u = stack.pop()
        for v in tree[u]:
            if v in colors:
                continue

            stack.append(v)
            if tree[u][v] % 2 == 0:
                colors[v] = colors[u]
            else:
                colors[v] = 0 if colors[u] == 1 else 1

    sorted(colors)
    for c in colors:
        print colors[c]

if __name__ == '__main__':

    tree = {}
    n = sys.stdin.readline().strip()
    for _ in xrange(int(n)-1):
        u, v ,w = map(int, sys.stdin.readline().strip().split(" "))
        if u not in tree:
            tree[u] = {}
        if v not in tree:
            tree[v] = {}
        tree[u][v] = w
        tree[v][u] = w

    solve(tree, u, v)

Measured memory_bytes: 55724
N = int(input())
B =[0] + [int(i) for i in input().split()]

ans = []

for i in range(N,0,-1):
    for j in range(i,0,-1):
        if B[j] == j:
            ans = [j] + ans
            B.pop(j)
            break
    else:
        print(-1)
        break
else:
    for a in ans:
        print(a)


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

int main(){
	int m,n1,n2;
	while(cin>>m>>n1>>n2,m){
		vector<int> p(m);
		for(int i=0;i<m;++i) cin>>p[i];
		int resgap=0;
		int resi=0;
		for(int i=n1;i<=n2;i++){
			int gap=p[i-1]-p[i];
			if(resgap<=gap){
				resgap=gap;
				resi=i;
			}
		}
		cout<<resi<<endl;
	}
}

Measured memory_bytes: 3072
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: chars, y: chars
    }
    let a = x[0].to_digit(16).unwrap();
    let b = y[0].to_digit(16).unwrap();
    let ans = if a < b { "<" } else if a > b { ">" } else { "=" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int X = 0; X <= K; X++){
    if(S < X) break;
  	for(int Y = 0; Y <= K; Y++){
      if(S < X + Y) break;
      if(S - (X + Y) <= K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<string> ret(n, string(n, '.'));
    if (n < 3) {
        cout << -1 << "\n";
        return 0;
    }
    if (n == 3) {
        vector<string> th(3, string(3, '.'));
        th[0] = "aab";
        th[1] = "d.b";
        th[2] = "dcc";
        for (auto &t : th) {
            cout << t << "\n";
        }
        return 0;
    }
    vector<string> fo(4, string(4, '.'));
    fo[0] = "aacd";
    fo[1] = "bbcd";
    fo[2] = "efgg";
    fo[3] = "efhh";
    vector<string> fi(5, string(5, '.'));
    fi[0] = "abc..";
    fi[1] = "abc..";
    fi[2] = "ddegg";
    fi[3] = "j.ehh";
    fi[4] = "jffii";
    vector<string> si(6, string(6, '.'));
    si[0] = "add.gg";
    si[1] = "a.ch..";
    si[2] = "bbch..";
    si[3] = ".eeiil";
    si[4] = "f..j.l";
    si[5] = "f..jkk";
    vector<string> se(7, string(7, '.'));
    se[0] = "aabbgg.";
    se[1] = "ccdd..h";
    se[2] = "eeff..h";
    se[3] = "....ikm";
    se[4] = "....ikm";
    se[5] = "....jln";
    se[6] = "....jln";
    int y = 0, x = 0;
    if (n % 4 == 0) {
        y = 0, x = 0;
    } else if (n % 4 == 1) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                ret[i][j] = fi[i][j];
            }
        }
        y = 5, x = 5;
    } else if (n % 4 == 2) {
        for (int i = 0; i < 6; ++i) {
            for (int j = 0; j < 6; ++j) {
                ret[i][j] = si[i][j];
            }
        }
        y = 6, x = 6;
    } else if (n % 4 == 3) {
        for (int i = 0; i < 7; ++i) {
            for (int j = 0; j < 7; ++j) {
                ret[i][j] = se[i][j];
            }
        }
        y = 7, x = 7;
    }
    for (int i = y; i < n; i += 4) {
        for (int k = 0; k < 4; ++k) {
            for (int l = 0; l < 4; ++l) {
                ret[i + k][i + l] = fo[k][l];
            }
        }
    }
    for (auto &r : ret) {
        cout << r << "\n";
    }
    return 0;
}

Measured memory_bytes: 2304
from collections import defaultdict


N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

problemsinHand = defaultdict(int)
problemsNeeded = defaultdict(int)

for d in D:
    problemsinHand[d] += 1
for t in T:
    problemsNeeded[t] += 1

for key, value in list(problemsNeeded.items()):
    if value > problemsinHand[key]:
        print('NO')
        quit()

print('YES')

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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
LL ans;
void dfs(LL x, LL res) {
	if (!x) { ans += res; return ; }
	LL y = 10;
	while (y <= x) {
		dfs(x / y, res + x % y);
		y = y * 10;
	}
	dfs(0, res + x);
	return ;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	LL S; read(S);
	dfs(S, 0);
	write(ans);
	return 0;
}


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

using namespace std;

set <int> s;

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

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

        if(x%2)
            cnt = 1;
    }

    if(cnt)
        cout << "first\n";
    else
        cout << "second\n";
}

Measured memory_bytes: 256
n, w = (int(x) for x in input().split())
wv = [[0, 0]]
for _ in range(n):
    wv.append([int(x) for x in input().split()])
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(w + 1):
    dp[0][i] = 0
for i in range(1, n + 1):
    for j in range(1, w + 1):
        if j - wv[i][0] >= 0:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wv[i][0]] + wv[i][1])
        else:
            dp[i][j] = dp[i - 1][j]
print(dp[n][w])

Measured memory_bytes: 120172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi X(N),Y(N),H(N);
  rep(i,0,N) cin>>X[i]>>Y[i]>>H[i];
  rep(i,1,N){
    if(H[0]>0)
      break;
    swap(H[0],H[i]);
    swap(X[0],X[i]);
    swap(Y[0],Y[i]);
  }
  REP(x,0,100){
    REP(y,0,100){
      bool flag=1;
      int h=H[0]+abs(X[0]-x)+abs(Y[0]-y);
      rep(i,1,N){
        int T=max(0LL,h-abs(X[i]-x)-abs(Y[i]-y));
        if(T!=H[i]){
          flag=0;
          break;
        }
      }
      if(flag){
        cout<<x<<" "<<y<<" "<<h;
        goto XYZ;
      }
    }
  }
  XYZ: cout<<endl;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    int A, B;
    cin >> A >> B;
    ll ans = B * 10;
    while(!(floor(ans * 0.08) == A && floor(ans * 0.1) == B)){
        if(floor(ans * 0.08) >= A){
            ans = -1;
            break;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

string Caesar(string str, int shift){
    string ret="";
    REP(i, str.size()){
        if('a'<=str[i] && str[i]<='z') ret += (str[i] - 'a' + shift) % 26 + 'a';
        else ret+=str[i];
    }
    return ret;
}

int main(){
	string str;
	while(getline(cin, str, '\n')){
		REP(i, 26){
			string fix = Caesar(str, i);
	    	if( fix.find( "the", 0 ) != string::npos ||
	    		fix.find( "this", 0 ) != string::npos ||
	    		fix.find( "that", 0 ) != string::npos ){
				cout<<fix<<endl;
				break;
			}
		}
	}
	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const double
    PI = acos(-1),
    WIN = 20 * (1 - PI/4),
    LOSS = 20 * (PI/2 - 1);

int btw(int a, int x, int b) {
    return abs(a-b) == abs(a-x) + abs(x-b);
}

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

    int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    int sx = (x1 <= x2 ? 1 : -1), sy (y1 <= y2 ? 1 : -1);

    x1 *= sx; x2 *= sx;
    y1 *= sy; y2 *= sy;

    int n; cin >> n;
    vector<pii> f;
    forn(i,n) {
        int x,y; cin >> x >> y;
        x *= sx; y *= sy;
        if (btw(x1,x,x2) && btw(y1,y,y2)) f.eb(x,y);
    }
    sort(all(f));
    vi lis;
    for (auto xy : f) {
        int x,y; tie(x,y) = xy;
        int ind = lower_bound(all(lis), y) - lis.begin();
        if (ind == si(lis)) lis.pb(y);
        else lis[ind] = y;
    }

    double ans = 0;
    int dimX = abs(x1-x2), dimY = abs(y1-y2);
    int dim = 1 + min(dimX, dimY);

    ans = 100.0 * (dimX + dimY);
    ans -= WIN * si(lis);
    if (si(lis) == dim) ans += LOSS + WIN;
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		
		long sum=0;
		for(int i=1;i<=a-1;i++) {
			sum+=i;
			
		}
		
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    vector<vector<int>> cnt(h + 1, vector<int>(w + 1));
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        for (int j = 0; j < w; j++) {
            cnt[i + 1][j + 1] = s[i][j] - '0';
            cnt[i + 1][j + 1] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i][j];
        }
    }
    int ans = 1e9;
    for (int b = 0; b < (1 << (h - 1)); b++) {
        int res = 0;
        vector<int> a(1, -1);
        for (int i = 0; i < h - 1; i++) {
            if (b & (1 << i)) {
                a.emplace_back(i);
                res++;
            }
        }
        vector<int> tmp(a.size());
        a.emplace_back(h);
        for (int j = 0; j < w; j++) {
            int pos = 0;
            for (int i = 0; i < h; i++) {
                tmp[pos] += s[i][j] - '0';
                if (a[pos + 1] == i) {
                    pos++;
                }
            }
            if (*max_element(tmp.begin(), tmp.end()) > k) {
                pos = 0;
                res++;
                tmp = vector<int>(a.size() - 1, 0);
                for (int i = 0; i < h; i++) {
                    tmp[pos] += s[i][j] - '0';
                    if (a[pos + 1] == i) {
                        pos++;
                    }
                }
                if (*max_element(tmp.begin(), tmp.end()) > k) {
                    res = 1e9;
                    break;
                }
            }
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import sys


CAKE = 4
DOUNAT = 7


def check_amount(i, j, n):
    return i*4 + j*7 == n


n = int(input())
count = 0
for i in range(int(n/CAKE+1)):
    for j in range(int(n/DOUNAT+1)):
        if check_amount(i, j, n):
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  if(n>=m){
    for(int i=0;i<n;i++)cout<<m;
  }else{
    for(int i=0;i<m;i++)cout<<n;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int h1,m1,h2,m2,k; 
scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

m1 = h1*60 + m1;
m2 = h2*60 + m2;

printf("%d\n", m2 - m1 - k );

return 0;
} 


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  vector<int> A(3);
  rep(i,3) cin>>A[i];
  sort(all(A));
  cout<<A[0]+A[1]<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8
from numba.types import Omitted

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], i8, i8), cache=True)
def main(A, M, K):
    # 右端ごとの最高得点を管理。まずは 1 回目。
    INF = 1 << 60
    dp = A.copy()

    q = np.empty(len(A) + 100, np.int32)
    q[:2] = 2, 2

    def push(q, x):
        q[q[1]] = x
        q[1] += 1

    def is_empty(q):
        return q[0] == q[1]

    for k in range(2, K + 1):
        newdp = np.full_like(A, -INF)
        q[:2] = 2, 2
        for i in range(len(A)):
            if not is_empty(q):
                x = dp[q[q[0]]]
                newdp[i] = x + A[i] * k
            x = dp[i]
            while not is_empty(q) and dp[q[q[1] - 1]] < x:
                q[1] -= 1
            push(q, i)
            while q[q[0]] <= i - M:
                q[0] += 1
        dp = newdp
    return dp.max()

N, M, K = map(int, readline().split())
A = np.array(read().split(), np.int64)

print(main(A, M, K))

Measured memory_bytes: 113128