akhauriyash/Code-Regression huggingface dataset:
P,S=print,sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a<1<exit(P(-1)),a-1,i:=i+1]for a in t)[::-1]
*_,r=zip(*l)
*_,b=r
while k:
 for t in S(l)[::-1]:
  if t[2]-b:t[1]or exit(P(-1));t[1]-=1;r+=t[2],
 b=r[-1];k-=1
P(len(r),*r)

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  VVI c(10, VI(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int res = 0;
  VVI a(h, VI(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      if (a[i][j] != -1) {
        res += c[a[i][j]][1];
      }
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 472
import java.util.Scanner;

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

		long count = 0;
		if (n % 2 == 0) {
			for (int i = 0; i < 25; i++) {
				count += (n / (long)(Math.pow(5, i + 1) * 2));
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    double a,b,c; cin >> a >> b >> c;
    cout << a*b/2 << endl; return 0;
}


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

int main() {
  int a, b;
  std::string op;
  int ans;
  for (int i = 0; i < 10000; i++) {
    std::cin >> a >> op >> b;
    if (op == "?") {
      return 0;
    }
    if (op == "+") {
      ans = a + b;
    }
    if (op == "-") {
      ans = a - b;
    }
    if (op == "*") {
      ans = a * b;
    }
    if (op == "/") {
      ans = a / b;
    }
    std::cout << ans << std::endl;
  }
}



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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    int x;
    scanf("%d",&x);
    while(1){
        bool result = IsPrime(x);
        if(result) break;
        else x++;
    }

    printf("%d\n",x);
}





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

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

        vector<vector<char>> s(h+2, vector<char>(w+2, '.'));

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                cin >> s.at(i+1).at(j+1);
            }
        } 

        vector<vector<int>> c(h+1, vector<int>(w+1, 0));

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (s.at(i+1).at(j+1) == '#') {
                    if (i > 0 && j > 0) {
                        if (s.at(i).at(j+1) == '.' && s.at(i+1).at(j) == '.') {
                            if (c.at(i).at(j+1) < c.at(i+1).at(j)) c.at(i+1).at(j+1) = c.at(i).at(j+1) + 1;
                            else c.at(i+1).at(j+1) = c.at(i+1).at(j) + 1;
                        } else if (s.at(i).at(j+1) == '#' && s.at(i+1).at(j) == '#') {
                            if (c.at(i+1).at(j) > c.at(i).at(j+1)) c.at(i+1).at(j+1) = c.at(i).at(j+1);
                            else c.at(i+1).at(j+1) = c.at(i+1).at(j);
                        } else if (s.at(i).at(j+1) == '#') {
                            if (c.at(i+1).at(j) + 1 > c.at(i).at(j+1)) c.at(i+1).at(j+1) = c.at(i).at(j+1);
                            else c.at(i+1).at(j+1) = c.at(i+1).at(j) + 1;
                        } else if (s.at(i+1).at(j) == '#') {
                            if (c.at(i).at(j+1) + 1 > c.at(i+1).at(j)) c.at(i+1).at(j+1) = c.at(i+1).at(j);
                            else c.at(i+1).at(j+1) = c.at(i).at(j+1) + 1;
                        }
                    } else if (i == 0) {  
                        if (s.at(1).at(j) == '.') c.at(1).at(j+1) = c.at(1).at(j) + 1;
                        else c.at(1).at(j+1) = c.at(1).at(j);
                    } else {
                        if (s.at(i).at(1) == '.') c.at(i+1).at(1) = c.at(i).at(1) + 1;
                        else c.at(i+1).at(1) = c.at(i).at(1);
                    }
                } else {
                    if (i > 0 && j > 0) {
                        if (c.at(i).at(j+1) < c.at(i+1).at(j)) c.at(i+1).at(j+1) = c.at(i).at(j+1);
                        else c.at(i+1).at(j+1) = c.at(i+1).at(j);
                    } else if (i == 0) {
                        c.at(1).at(j+1) = c.at(1).at(j);
                    } else {
                        c.at(i+1).at(j+1) = c.at(i).at(j+1);
                    }
                    
                }
            }
        }

        
        cout << c.at(h).at(w) << endl;

        // for (int i=0; i<h; i++) {
        //     for (int j=0; j<w; j++) {
        //         cout << c.at(i+1).at(j+1);
        //     }
        //     cout << endl;
        // }
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, K; 
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  REP(use, K+1){
    REP(left, use+1){
      int right = use-left;
      if(left+right > N) continue;

      priority_queue<int, vector<int>, greater<int>> q;
      REP(i, left) q.push(A[i]);
      REP(i, right) q.push(A[N-1-i]);

      int pass = K-use;
      int ret = 0;
      while(!q.empty()){
        int p = q.top(); q.pop();
        if(p < 0 && pass) pass--;
        else ret += p;
      }

      chmax(ans, ret);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import Data.List
import Text.Printf

ans x = maximumBy (\(a,b) (c,d) -> if b /= d
                                   then compare b d
                                   else compare c a ) x

main = do
  _ <- getLine
  c <- getContents
  let i = map (\[a,b] -> (a,b)) $ map (map read) $ map words $ lines c :: [(Int,Int)]
      (a,b) = ans i
  printf "%d %d\n" a b

Measured memory_bytes: 3784
N = int(input())
a = list(map(int,input().split()))
s = {}
w = {}
for i in range(N):
	if i+1-a[i] < 2:
		pass
	elif i+1-a[i] in s:
		s[i+1-a[i]] += 1
	else:
		s[i+1-a[i]] = 1
	if i+1+a[i] >= N:
		pass
	elif i+1+a[i] in w:
		w[i+1+a[i]] += 1
	else:
		w[i+1+a[i]] = 1
ans = 0
for key, value in s.items():
	if key in w:
		ans += value*(w[key])
print(ans)

Measured memory_bytes: 36028
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;


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

  long long int ans=0;
  for(int i=0;i<n;i++){
    int l,r;
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, w; scanf("%d%d", &h, &w); std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];
	
	const int MOD = 1e9 + 7;
	
	auto dp = make_v<int>(h + 1, w + 1); dp[0][0] = 1;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(s[i][j] == '#') continue;
			(dp[i + 1][j] += dp[i][j]) %= MOD;
			(dp[i][j + 1] += dp[i][j]) %= MOD;
		}
	}
	printf("%d\n", dp[h - 1][w - 1]);
	return 0;
}


Measured memory_bytes: 5248
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int p, q, r;
  cin >> p >> q >> r;
  int min = std::min({p + q, q + r, r + p});
  cout << min << endl;

  return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code


int main()
{
  int n;
  cin>>n;
  if(n < 1200)puts("ABC");
  else puts("ARC");
  return 0;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

void printIce(int* freq,int kind){
	if(freq[kind] == 0){
		printf("-\n");
		return;
	}

	for(int i=0;i<freq[kind];i++){
		printf("%s",(i == freq[kind] - 1) ? "*\n" : "*");
	}
}

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

		int* freq = new int[10]();
		for(int i=0;i<n;i++){
			int kind;
			scanf("%d",&kind);
			freq[kind]++;
		}

		for(int i=0;i<10;i++){
			printIce(freq,i);
		}

		delete[] freq;
	}
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  char c;
  cin >> c;
  if(c >= 'A' && c <= 'Z')
    cout << 'A' << endl;
  else
    cout << 'a' << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
void sp(int n, int m) {
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1)
				putchar('#');
			else
				putchar('.');
		}putchar('\n');
	}
}


int main() {
	int H[300], W[300];
	int i;

	for (i = 0;; i++) {
		scanf("%d %d", &H[i], &W[i]);
		if (H[i] == 0 && W[i] == 0)
			break;
	}

	for (int k = 0; k < i; k++) {
		sp(H[k], W[k]);
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 1808
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const int MAXN = 3e3 + 10; 
int n ; 
vector<long double> v(MAXN) ; 
long double dp[MAXN][MAXN] ; 
long double dfs(int x,int curHeads){
	if ( x == n ){
		if ( curHeads > n / 2 ) return 1 ;
		return 0 ; 
	}
	if ( dp[x][curHeads] != -1 ) return dp[x][curHeads] ; 
	long double ans = 0 ; 
	ans += v[x] * dfs(x+1,curHeads+1) ; 
	ans += (1.0-v[x]) * dfs(x+1,curHeads) ; 
	return dp[x][curHeads] = ans; 
}
int main(){
    fastio
    for(int i=0;i<MAXN;i++){
    	for(int j=0;j<MAXN;j++){
    		dp[i][j] = -1;
    	}
    }
    cin >> n ; 
    for(int i=0;i<n;i++){
    	cin >> v[i] ; 
    }
    cout << fixed << setprecision(12) << dfs(0,0) << endl;
    return 0 ;
}


Measured memory_bytes: 142336
#include <iostream>
using namespace std;
int main(){
    int N, Y;
    cin >> N >> Y;
    int i, j, k;
    bool found = false;
    for(i=0;i<=N;i++){
        for(j=0;j<=N-i;j++){
            k = N-i-j;
            if(Y - 1000*i - 5000*j == 10000*k){
                found = true;
                break;
            }
        }
        if(found) break;
    }
    if(found) cout << k << ' ' << j << ' '<<i<<endl;
    else cout <<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
def partition(a, p, r):
    x = a[r][1]
    i = p - 1
    for j in range(p, r):
        if a[j][1] <= x:
            i = i + 1
            a[i], a[j] = a[j], a[i]
    a[i + 1], a[r] = a[r], a[i + 1]
    return i + 1


def quicksort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quicksort(a, p, q - 1)
        quicksort(a, q + 1, r)


def checkstable(a):
    for i in range(1, len(a)):
        if a[i - 1][1] == a[i][1]:
            if a[i - 1][2] > a[i][2]:
                return "Not stable"
    return "Stable"


import sys
n = int(input())
a = []
for i in range(n):
    suit, num = sys.stdin.readline().split()
    a += [[suit, int(num), i]]

quicksort(a, 0, len(a) - 1)
print(checkstable(a))

for line in a:
    print(line[0], line[1])

Measured memory_bytes: 24680
#初期data
input_number = int(input())
input_list = list(map(int, input().split()))
exchange_count = 0

#アルゴリズム
for i in range(input_number):
    for j in range(input_number-1, i, -1):
        if input_list[j] < input_list[j-1]:
            input_list[j], input_list[j-1] = input_list[j-1], input_list[j]
            exchange_count += 1
    
#処理の実行
print(" ".join(map(str, input_list)))
print(exchange_count)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  cout << s[0]<<s.size()-2<<s[s.length()-1]<<endl;

}

Measured memory_bytes: 256
x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
ab = a.product(b).map { |x, y| x + y }.sort.reverse[0, k]
abc = ab.product(c).map{ |x, y| x + y }.sort.reverse[0, k]
puts abc


Measured memory_bytes: 287464
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    A,B,C=map(int,input().split())
    def main():
        for i in range(10**4):
                if i*A%B==C:
                    return 'YES'
        return 'NO'
    print(main())

resolve()

Measured memory_bytes: 38512
#include <iostream>
#include <vector>

using namespace std;

namespace util {
    vector<int> read_int_vector() {
        int n;
        cin >> n;

        vector<int> v;
        for (int i = 0; i < n; i++) {
            int in;
            cin >> in;
            v.push_back(in);
        }
        return v;
    }
    void print_vector(vector<int> &v) {
        for (auto it = v.begin(); it != v.end(); it++) {
            cout << *it;
            if (it + 1 != v.end())
                cout << " ";
        }
        cout << endl;
    }
}

namespace {
    void run_insertion_sort(vector<int>& v) {
        for (int i = 1; i < v.size(); i++) {
            util::print_vector(v);
            int key = v[i];
            int j = i - 1;
            while(j >= 0 && v[j] > key) {
                v[j+1] = v[j];
                j--;
            }
            v[j+1] = key;
        }
    }
}

int main() {
    vector<int> in = util::read_int_vector();
    run_insertion_sort(in);
    util::print_vector(in);
    return 0;
}

Measured memory_bytes: 1220
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
if (a1*t1-b1*t1)*(a1*t1+a2*t2-b1*t1-b2*t2)>0:print(0)
elif (a1*t1-b1*t1)*(a1*t1+a2*t2-b1*t1-b2*t2)==0:print('infinity')
else:print(-(a1*t1-b1*t1)//(a1*t1+a2*t2-b1*t1-b2*t2)*2+((a1*t1-b1*t1)%(a1*t1+a2*t2-b1*t1-b2*t2)!=0))

Measured memory_bytes: 61940
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int d,n;
    cin >> d >> n;
    ll res = pow(100,d)*n;
    if (n == 100) res += pow(100,d);
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


bool ab[100000]={0};
bool ac[100000]={0};
bool bc[100000]={0};

bool isMatch(const char a, const char b){
    return ((a==b)||(a=='?')||(b=='?'));
}

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    int sa, sb, sc;
    sa = (int)a.size();
    sb = (int)b.size();
    sc = (int)c.size();

    rep(i, sa)rep(j, sb) if(!isMatch(a[i],b[j])) ab[50000+i-j]=true;
    rep(i, sa)rep(j, sc) if(!isMatch(a[i],c[j])) ac[50000+i-j]=true;
    rep(i, sb)rep(j, sc) if(!isMatch(b[i],c[j])) bc[50000+i-j]=true;

    int M = 2000;
    int ans = 3*M;
    for(int i=-2*M; i<=2*M;i++) for(int j=-2*M; j<=2*M;j++){
        if(!ab[50000+i] && !ac[50000+j] && !bc[j-i+50000]){
            int L = min(0, min(i,j));
            int R = max(sa, max(i+sb,j+sc));
            ans = min(ans, R-L);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
	int key;
	struct node *prev;
	struct node *next;
}*Node;

Node nil;

Node listSearch( int );
void init();
void printList();
void deleteNode( Node );
void deleteFirst();
void deleteLast();
void deleteKey( int );
void insert( int );

int main( void ){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;

	scanf("%d", &n);
	init();
	
	for( i = 0; i < n; i++ ){
		scanf("%s%d", com, &key);
		if( com[0] == 'i' ){
			insert(key); 
			np++;
			size++;
		}
		else if( com[0] == 'd' ){
			if(strlen(com) > 6){
				if( com[6] == 'F' ){
					deleteFirst();
				}
				else if( com[6] == 'L' ){
					deleteLast();
				}
			}
			else{
				deleteKey(key);
				nd++; 
			}
		size--;
		}
	}
	
	printList();
	return 0;
}

Node listSearch( int key ){
	Node cur = nil->next;
	while( cur != nil && cur->key != key ){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = malloc(sizeof(struct node));
	nil->prev = nil;
	nil->next = nil;
}

void printList(){
	Node cur = nil->next;
	int isf = 1;
	
	while(1){
		if( cur == nil ){
			break;
		
		}
		if( isf == 0 ){
			printf(" ");
		}
		
		printf("%d", cur->key );
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode( Node t ){
	if( t != nil ){
		t->prev->next = t->next;
		t->next->prev = t->prev;
	}
}

void deleteFirst(){
	Node t = nil->next;
	if( t != nil ){
		deleteNode(t);
	}
}

void deleteLast(){
	deleteNode( nil->prev );
}

void deleteKey( int key ){
	deleteNode( listSearch(key) );
}

void insert( int key ){
	Node x = (Node)malloc(sizeof(Node));
	x->key = key;
	
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}


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

int gcd(int a, int b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}

int main() {
	int K;
	cin >> K;
	int ans = 0;
	for (int a = 1;a<=K;++a) {
		for (int b = 1;b<=K;++b) {
			for (int c = 1;c<=K; ++c) {
				ans += gcd(gcd(a, b), c);
			}
		}
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
using namespace std;
int main()
{

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

    if (b % 100 == 0)
    {
        b++;
    }
    long long int ans = b;
    for (int i = 0; i < a; i++)
    {
        ans *= 100;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    if(a+1==b)cout<<a+b<<endl;
    else if(a==b)cout<<a+b<<endl;
    else cout<<b+(b-1)<<endl;
return 0;
}


Measured memory_bytes: 4992
using System;

namespace ABC165
{
    public class Tolve
    {
        public static void Main(string[] args)
        {
          
          var k = int.Parse(Console.ReadLine());
          
          String [] s = Console.ReadLine().Split(' ');
          int a = int.Parse(s[0]);
          int b = int.Parse(s[1]);
          
          int tt = 0;
          int ttt = 0;
          
          for(int i = a; i <= b; i++) {
            	if(i % k == 0) {
                  tt = 1;
                  break;
                } else {
                  ttt = 0;
                }
          }
          
          if(tt == 1) {
           	Console.WriteLine("OK"); 
          } else {
            Console.WriteLine("NG"); 
          }
          
     
	}
    }
}

Measured memory_bytes: 17896
def main():
    from decimal import Decimal
    a, b, c = map(int, input().split())

    x = Decimal(a).sqrt()
    y = Decimal(b).sqrt()
    z = Decimal(c).sqrt()

    print('Yes' if x + y < z else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 5460
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define all(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  n--;
  int ans=(n*(n+1));
  ans=ans/2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define db(x) cout << x << endl;
using namespace std;
typedef long long ll;
#define MAXN 100005

int abi[MAXN];

void update(int p,int v)
{
    while(p<MAXN)
    {
        abi[p]+=v;
        p+=(p&-p);
    }
}

int query(int p)
{
    int res=0;
    while(p)
    {
        res+=abi[p];
        p-=(p&-p);
    }
    return res;
}

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

    int n,t,l,r;
    cin >> n >> t;
    for(int i=0;i<n;i++)
    {
        cin >> l >> r;
        l++;
        update(l,1);
        update(r+1,-1);
    }

    int res=0;
    for(int i=0;i<=t+1;i++)
        res=max(res,query(i));
    db(res)

    return 0;
}



Measured memory_bytes: 3580
n=int(input())
ans=[0]*(10001)
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      index=i**2+j**2+k**2+i*j+j*k+i*k
      if index<=10000:
        ans[index]+=1
     
for i in range(1,n+1):
  print(ans[i])


Measured memory_bytes: 74192
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll  LINF = 1e18;

struct UnionFind{
	vector<int> d;
	UnionFind(int n):d(n,-1){}
	int find(int x){
		if(d[x]<0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x,int  y){
		x = find(x);y = find(y);
		if(x==y) return false;
		if(d[x] > d[y]) swap(x,y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x,int y) {return find(x) == find(y);}
	int size(int x) {return -d[find(x)];}
};

int main(){
	int n,m;cin >> n >> m;
	UnionFind tree(100005);
	vector<vector<int>> lan(100005,vector<int>());
	rep(i,n){
		int k;cin >> k;
		rep(j,k){
			int l;cin >> l;
			--l;
			lan[l].push_back(i);
		}
	}
	rep(l,m){
		if(lan[l].size()==0) continue;
		rep(i,lan[l].size()-1){
			tree.unite(lan[l][0],lan[l][i+1]);
		}
	}
	if(tree.size(0)!=n) cout << "NO" << endl;
	else cout << "YES" << endl;
} 


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;
const ll 	N		=  	1000000;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w,summ;
string s,t;
vll a,b;

// <------------- Implement Functions Here ----------> //
ll par[N], sz[N];
ll comp;

void make(ll n) {
	for(ll i=1;i<=n;i++) {
		par[i] = i;
		sz[i] = 1;
	}
}

ll find(ll x) {
	return x == par[x]?x:par[x] = find(par[x]);
}

void merge(ll x, ll y) {
	ll u = find(x);
	ll v = find(y);

	if(u == v) return;

	if(sz[u] < sz[v]) swap(u,v);
	sz[u] += sz[v];
	par[v] = u; 
	comp--;
}

// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	cin >> n >> m;
	make(n);
	for(ll i=0;i<m;i++) {
		cin>>x>>y;
		merge(x,y);
	}

	ll maxi = 1;
	for(ll i=1;i<=n;i++) {
		if(par[i]==i) {
			maxi = max(maxi,sz[i]);
		}
	}

	cout<<maxi;newl;
}	

int main() {
	fastio;randomINT;
	//freopen("out_hc.txt","w+",stdout);
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



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

std::vector<long int> enum_div(long int n)//nの約数を列挙
{
	std::vector<long int> ret;
	for(long int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main()
{   
    long int n,res=0;
    cin>>n;
	std::vector<long int> r = enum_div(n);
	r.push_back(n);
	for(auto i : r){
	    if(i-1!=0 and n%(i-1)==n/(i-1)) {res+=i-1;}
	} 
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 384
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/
int n;
vvvd dp;

double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0)return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0)return 0.0;

	double res = 0.0;
	if (i > 0) {
		res += rec(i - 1, j, k)*i;
	}
	if (j > 0) {
		res += rec(i + 1, j - 1, k)*j;
	}
	if (k > 0) {
		res += rec(i, j + 1, k - 1)*k;
	}
	res += n;
	res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}

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

	cin >> n;
	int one = 0, two = 0, three = 0;
	f(i, 0, n) {
		int a;
		cin >> a;
		if (a == 1) {
			one++;
		}ei(a == 2) {
			two++;
		}
		else {
			three++;
		}
	}

	dp.resize(n + 1, vvd(n + 1, vd(n + 1)));
	f(i, 0, n + 1) {
		f(j, 0, n + 1) {
			f(k, 0, n + 1) {
				dp[i][j][k] = -1;
			}
		}
	}

	cout << fixed << setprecision(10) << rec(one, two, three);
	return 0;
}

Measured memory_bytes: 216964
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;
void solve(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int ans = v[1] - v[0], minv = v[0];
  for(int i = 1; i < n; i++){
    ans = max(v[i] - minv, ans);
    minv = min(v[i], minv);
  }
  cout << ans << endl;
  return;
}

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



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vector<ll> adp(n + 1, 0), bdp(m + 1, 0);
    rep(i, n) adp[i + 1] = adp[i] + a[i];
    rep(i, m) bdp[i + 1] = bdp[i] + b[i];
    ll ans = 0;
    rep(ac, n + 1) {
        ll av = adp[ac];
        if (av > k) continue;
        ll bv = k - av;
        auto it = upper_bound(all(bdp), bv);
        if (it != bdp.begin()) {
            it--;
        }
        ll bc = it - bdp.begin();
        ans = max(ans, ac + bc);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MAX = 1e6+7;

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

  Ml m;
  vector<ll> a(MAX);
  m[s] = 1;
  a[0] = s;
  ll ans = -1;
  rep(i, MAX) {
    if (a[i] % 2 != 0) a[i+1] = 3*a[i]+1;
    else a[i+1] = a[i] / 2;
    if (m[a[i+1]] != 0) {
      ans = i+2;
      break;
    }
    m[a[i+1]] = 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[401][401] = {};

int main(){
  int n;
  ll a[SIZE] = {};

  scanf("%d", &n);

  for(int i=1;i<=n;i++){
    scanf("%lld", a+i);
    a[i] += a[i-1];
  }

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

  for(int i=2;i<=n;i++){
    for(int j=0;j+i<=n;j++){
      for(int k=j+1;k<i+j;k++){
        dp[j][i+j] = min(dp[j][i+j], dp[j][k] + dp[k][i+j] + a[i+j] - a[j]);
      }
    }
  }

  cout << dp[0][n] << endl;


  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int x,n,p[110],d=200,k;
  cin>>x>>n;
   for (int i = 0; i < n; ++i) cin >> p[i];
  vector<int> v(102);
  for(int i=0;i<102;i++){
    v.at(i)=i;
  }
  for(int i=0;i<n;i++){
  int value_to_remove = p[i];
v.erase(std::remove(v.begin(), v.end(), value_to_remove), v.end());
  }
  for(int i=0;i<102-n;i++){
    if(abs(x-v.at(i))<d){
	k=v.at(i);
    d=abs(x-v.at(i));
    }
  }
  cout<<k<<endl;
}
  

Measured memory_bytes: 3596
# Problem A - Study Scheduling

# input
h_1, m_1, h_2, m_2, k = map(int, input().split())

# initialization
if m_2-k>=0:
    m_2 -= k
else:
    tmp = k - m_2
    m_2 = 60 - tmp
    h_2 -= 1
tmp_1 = h_1 * 60 + m_1
tmp_2 = h_2 * 60 + m_2

# calc
ans = tmp_2 - tmp_1

# output
print(ans)


Measured memory_bytes: 9112
//Powered by caibiCH2 at 2020/04/17,19:45:01
#include<bits/stdc++.h>
#define elif else if
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
int n,k,a[100],flag;
void dfs(int dep){
	if(dep>n){
		--k;
		if(k==0){
			for(int i=1;i<=n;++i)cout<<a[i];
			flag=1;
		}
	}
	else{
		int l=(dep==1?1:max(a[dep-1]-1,0)),r=(dep==1?9:min(a[dep-1]+1,9));
		for(int i=l;i<=r;++i){
			if(dep==1||abs(a[dep-1]-i)<=1){
				a[dep]=i;
				dfs(dep+1);
			}
		}
	}
}
signed main(){
	ios::sync_with_stdio(0);
	//cin.tie(0);
	cin>>k;
	for(int i=1;i<=100;++i){
		n=i;
		dfs(1);
		if(flag)break;
	}
	return 0;
}

Measured memory_bytes: 256
import java.text.ParseException;
import java.util.Scanner;

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

		String s = sc.next();

		switch (s) {
		case "A":
			System.out.println("T");
			break;
		case "T":
			System.out.println("A");
			break;
		case "G":
			System.out.println("C");
			break;
		case "C":
			System.out.println("G");
			break;
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
   int n,m,c;
   cin>>n>>m>>c;
   vector<int> b(m);
   rep(i,0,m) cin>>b[i];
   vector<vector<int>> a(n,vector<int>(m));
   rep(i,0,n) rep(j,0,m) cin>>a[i][j];

   int ans=0;
   rep(i,0,n){
      int sum=0;
      rep(j,0,m){
         sum+=b[j]*a[i][j];
      }
      sum+=c;
      if(sum>0) ans++;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    int i;
    for(i=0;i<n;i++) {
        cin>>a[i];
    }
    for(i=0;i<n;i++) {
        cin>>b[i];
    }
    for(i=0;i<n-1;i++) {
        cin>>c[i];
    }
    int sum=b[a[0]-1];
    for(i=1;i<n;i++) {
        sum+=b[a[i]-1];
        if(a[i-1]+1==a[i]) {
            sum+=c[a[i-1]-1];
        }
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	l := make([]bool, n)

	var d int
	var a int
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			fmt.Scan(&a)
			if l[a-1] == false {
				l[a-1] = true
			}
		}
	}
	count := 0
	for _, v := range l {
		if !v {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 2312
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long int a[n][3];
    for(int i = 0; i < n; i++){
        cin >> a[i][0];
        cin >> a[i][1];
        cin >> a[i][2];
    }
    bool ans = false;
    
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            for(int k = 0; k < n; k++){
                if(a[k][2] != 0){
                    long long int check = a[k][2] + abs(a[k][0] - i) + abs(a[k][1] - j);
                    for(int l = 0; l < n; l++){
                        if(a[l][2] != 0){
                            long long int c = a[l][2] + abs(a[l][0] - i) + abs(a[l][1] - j);
                            if(c != check){
                                break;
                            }
                        }else{
                            if(check > abs(a[l][0] - i) + abs(a[l][1] - j)){
                                break;
                            }
                        }
                        if(l == n - 1){
                            cout << i << " " << j << " " << check;
                            ans = true;
                        }
                    }
                }
                if(ans){
                    break;
                }
            }
            if(ans){
                break;
            }
        }
        if(ans){
            break;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<ctime>
#include<cmath>
using namespace std;
#define int long long
const int maxn=5005;
int d[maxn],real[maxn],front[maxn];
signed main()
{
    int k,q;
    scanf("%lld%lld",&k,&q);
    for(int i=1;i<=k;i++)
        scanf("%lld",&d[i]);
    while(q--)
    {
        int n,s,mod;
        scanf("%lld%lld%lld",&n,&s,&mod);
        memset(real,0,sizeof(real));
        for(int i=1;i<=k;i++)
            real[i]=d[i]%mod;
        int rounds=(n-1)/k,left=(n-1)%k;
        s%=mod;
        int check=0;
        for(int i=1;i<=k;i++)
            check+=real[i];
        check=rounds*check;
        for(int i=1;i<=left;i++)
            check+=real[i];
        check+=s;
        int ans=(n-1)-check/mod;
        int cnt=0;
        for(int i=1;i<=k;i++)
            if(real[i]==0)
                cnt++;
        ans=ans-rounds*cnt;
        for(int i=1;i<=left;i++)
            if(real[i]==0)
                ans--;
        printf("%lld\n",ans);
    }
    return 0;
}


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

using namespace std;

int main()
{
    long n, m;
    long sum = 0;
    vector<long> vec;
    cin >> n >> m;
    long res = 0;
    for (long i = 0; i < n; ++i)
    {
        long a;
        cin >> a;
        vec.push_back(a);
        sum += a;
    }

    double tmp = sum  / (4.0 * m);

    auto itrend = vec.end();
    for (auto itr = vec.begin(); itr != itrend; ++itr)
    {
        if ((*itr) >= tmp )
        {
            res += 1;
        }
    }

    if (res >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 998244353;
const int N = 3e3 + 10;

int n, s;
int dp[N][N][3], a[N];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, s;
	cin >> n >> s;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= s; j++) {
			dp[i][j][0] = (dp[i][j][0] + dp[i - 1][j][0]) % mod;
			dp[i][j][1] = (dp[i][j][1] + dp[i - 1][j][1] + dp[i - 1][j][0]) % mod;
			dp[i][j][2] = (dp[i][j][2] + dp[i - 1][j][2] + dp[i - 1][j][1] + dp[i][j][0]) % mod;
			if(j + a[i] <= s) {
				dp[i][j + a[i]][1] = (dp[i][j + a[i]][1] + dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
				dp[i][j + a[i]][2] = (dp[i][j + a[i]][2] + dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
			}
		}
	}
	cout << dp[n][s][2];

	return 0;
}

Measured memory_bytes: 211968