akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] nw = in.readLineAsIntArray();
        final int N = nw[0];
        final int W = nw[1];

        int[][] dp = new int[N + 1][W + 1];
        Arrays.fill(dp[0], 0);
        for (int i = 1; i <= N; i++) {
            int[] vw = in.readLineAsIntArray();
            int v = vw[0];
            int w = vw[1];
            dp[i][0] = 0;
            for (int j = 1; j <= W; j++) {
                dp[i][j] = dp[i - 1][j];
                if (j >= w) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - w] + v);
                    dp[i][j] = Math.max(dp[i][j], dp[i][j - w] + v);
                }
            }
        }
        System.out.println(dp[N][W]);
    }


    static class CustomReader extends BufferedReader {

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(this.readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}


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

using namespace std;

bool is_palindrome(string s, int b, int e) {
    bool res = true;
    for (int i = b; i <= e; i++) {
        res = res && s[i] == s[e - i];
    }
    return res;
}

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

    int n = s.size();
    bool res = is_palindrome(s, 0, n - 1);
    res = res && is_palindrome(s, 0, n / 2 - 1);
    res = res && is_palindrome(s, n / 2 + 1, n - 1);

    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[50];
int fib(int n) {
	if (n == 0 || n == 1)return dp[n] = 1;
	if (dp[n] != -1)return dp[n];
	return dp[n] = fib(n - 1) + fib(n - 2);
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < 50; i++)dp[i] = -1;
	cout << fib(n) << endl;
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e4 + 5;

ll dp[L];
vector <pll> p;

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

    ll H, N;
    cin >> H >> N;


    for(ll i=0; i<N; i++)
    {
        ll a, b;
        cin >> a >> b;

        p.pb(mp(a, b));
    }

    dp[0] = 0;

    for(ll i=1; i < L; i++)
    {
        dp[i] = 1e15;
    }

    for(ll i=1; i<=H; i++)
    {
        for(ll j=0; j<N; j++)
        {
            dp[i] = min(dp[i], p[j].ss + dp[max(i-p[j].ff, 0LL)]);
            // cout << dp[i] << endl;
        }
    }

    cout << dp[H] << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int INF = 1000100100;
const int MAX_H = 1010, MAX_W = 1010;


int dis[MAX_H][MAX_W];
int c[MAX_H][MAX_W];
int h, w; 

int tow[4] = {0, 1, 0, -1};
int toh[4] = {-1, 0, 1, 0};

void init(){
    rep(i,MAX_H){
        rep(j,MAX_W){
            dis[i][j] = INF;
            c[i][j] = 0;
        }
    }
}

int main()
{
    init();
    cin >> h >> w;
    int ch, cw, dh, dw; cin >> ch >> cw >> dh >> dw; --ch, --cw, --dh, --dw;
    rep(i,h){
        rep(j,w){
            char moji; cin >> moji;
            if(moji == '#') c[i][j] = 0;
            else c[i][j] = 1;
        }
    }

    int cnt = 0;

    queue<P> q;
    q.push(make_pair(ch, cw));
    dis[ch][cw] = 0;

    while(true){
        vector<P> re;
        while(!q.empty()){
            P pair_u = q.front(); q.pop();
            int uh = pair_u.first, uw = pair_u.second;
            dis[uh][uw] = cnt;
            re.push_back(make_pair(uh, uw));
            rep(i,4){
                int vh = uh + toh[i], vw = uw + tow[i];
                if(vh<0 || vw<0 || vh>=h || vw>=w) continue;
                if(dis[vh][vw] == INF && c[vh][vw] == 1){
                    dis[vh][vw] = cnt;
                    q.push(make_pair(vh, vw));
                }
            }
        }
        int rs = re.size();
        bool isok = true;
        rep(i,rs){
            P pair_u = re[i];
            int uh = re[i].first, uw = re[i].second;
            for(int ii=-2; ii<=2; ii++){
                for(int jj=-2; jj<=2; jj++){
                    int nh = uh + ii, nw = uw + jj;
                    if(nh<0 || nw<0 || nh>=h || nw>=w) continue;
                    if(dis[nh][nw] == INF && c[nh][nw] == 1){
                        q.push(make_pair(nh, nw));
                        // printf("%d %d\n", nh, nw);
                        isok = false;
                    }
                }
            }
        }
        if(isok) break;
        cnt++;
    }
    if(dis[dh][dw] == INF) cout << -1 << endl;
    else cout << dis[dh][dw] << endl;
}

Measured memory_bytes: 19760
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

s=int(input())

mod=10**9+7
MAX_N = s+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

lim=s//3
ans=0
for i in range(1,lim+1):
  zan=s-3*i
  ans+=nCk(i+zan-1,zan)
  ans%=mod

print(ans)

Measured memory_bytes: 9376
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

s=SI()
t=SI()
sn=len(s)
tn=len(t)
ans=100000
for i in range(sn-tn+1):
    cur=0
    for j in range(tn):
        cur+=s[i+j]!=t[j]
    ans=min(ans,cur)
print(ans)


Measured memory_bytes: 9016
from heapq import heappush, heappop
import sys

input = sys.stdin.readline

n, m = map(int, input().split())

vmax = pow(10, 5)

jobs = [[] for _ in range(vmax + 1)]
for _ in range(n):
    a, b = map(int, input().split())
    jobs[a].append(-b)

ans = 0
h = []
for i in range(1, m + 1):
    for j in jobs[i]:
        heappush(h, j)
    if h:
        v = heappop(h)
        v *= -1
        ans += v
print(ans)


Measured memory_bytes: 67120
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MX = 200005;

ll K, N;
ll A[MX];

ll solve(){
	vector<ll> B;
	for(ll i=1; i<N; i++){
		B.push_back(A[i] - A[i-1]);
	}
	B.push_back(K + A[0] - A[N-1]);
	sort(B.begin(), B.end());

	return K - *B.rbegin();
}


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

	cout<<solve()<<endl;

    return 0;
}


Measured memory_bytes: 3956
#include <cstdio>
#include <cstring>

int hash[7][7];

int cnt[7];
int height[300][300];

int mov[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int color[300][300];

int main(void)
{
	hash[1][2] = 3;
	hash[1][3] = 5;
	hash[1][5] = 4;
	hash[1][4] = 2;
	
	hash[2][1] = 4;
	hash[2][4] = 6;
	hash[2][6] = 3;
	hash[2][3] = 1;

	hash[3][6] = 5;
	hash[3][5] = 1;
	hash[3][1] = 2;
	hash[3][2] = 6;

	hash[4][1] = 5;
	hash[4][5] = 6;
	hash[4][6] = 2;
	hash[4][2] = 1;

	hash[5][1] = 3;
	hash[5][3] = 6;
	hash[5][6] = 4;
	hash[5][4] = 1;

	hash[6][5] = 3;
	hash[6][3] = 2;
	hash[6][2] = 4;
	hash[6][4] = 5;

	int n;
	while(scanf("%d", &n), n)
	{
		memset(height, 0, sizeof(height));
		memset(cnt, 0, sizeof(cnt));
		memset(color, 0, sizeof(color));

		for(int i=0;i<n;i++)
		{
			int y = 150, x = 150;
			int top, front;
			scanf("%d %d", &top, &front);

			while(1)
			{
				int last = 3, dir = -1;

				for(int j=0;j<4;j++)
				{
					int tar;
					if(j == 0) tar = front;
					else if (j == 1) tar = hash[top][front];
					else if (j == 2) tar = 7 - front;
					else tar = 7 - hash[top][front];

					if(tar > last && height[y][x] > height[y + mov[j][0]][x + mov[j][1]])
					{
						dir = j;
						last = tar;
					}
				}

				if(dir == -1) break;
				y += mov[dir][0], x += mov[dir][1];
				int ntop, nfront;
				if(dir == 0) { ntop = 7 - front; nfront = top; }
				else if (dir == 1) { ntop = 7 - hash[top][front]; nfront = front; }
				else if (dir == 2) { ntop = front; nfront = 7 - top; }
				else if (dir == 3) { ntop = hash[top][front]; nfront = front; }
				top = ntop, front = nfront;
			}

			cnt[color[y][x]]--;
			height[y][x]++;
			cnt[color[y][x] = top]++;
		}

		for(int i=1;i<=6;i++)
		{
			if(i >= 2) printf(" ");
			printf("%d", cnt[i]);
		}
		printf("\n");
	}

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

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

bool checkInt(string s)
{
  for(int i = 0; i < int(s.size()); i++)
    if(!isdigit(s[i])) return false;
  return true;
}

int main()
{
  int a, b;
  string s;
  cin >> a >> b >> s;
  if(s[a] != '-')
  {
    cout << "No" << endl;
    return 0;
  }

  string tmp1 = s.substr(0, a);
  string tmp2 = s.substr(a+1, b);
  // cout << tmp1 << endl;
  // cout << tmp2 << endl;

  if (checkInt(tmp1) && checkInt(tmp2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
int N,M,X,Y;
int main(void){
    scanf("%d%d%d%d",&N,&M,&X,&Y);
    printf("%.20lf %d\n",N*ll(M)/2.,X*2==N&&Y*2==M);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC122();
}

void ABC122(){
    char b;
    cin>>b;
    if(b=='A')cout<<'T'<<endl;
    if(b=='C')cout<<'G'<<endl;
    if(b=='G')cout<<'C'<<endl;
    if(b=='T')cout<<'A'<<endl;
}

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

int main() {
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while(1){
    
    if(c - b <= 0){
      cout << "Yes" << endl;
      break;
    }
    else{
      c = c - b;
      if(a - d <= 0){
        
        cout << "No" << endl;
        break;

      }
      else{
        a = a - d;
      }
      
    }
    
  }
  
  
}



Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
using namespace std;
using ll=long long;

int main(){
	const int M=100000;
	int n,m,p[M],y[M];
	vector<int> num[M];

	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>p[i]>>y[i];
		num[p[i]-1].push_back(y[i]);
	}
	for(int i=0;i<n;i++)sort(num[i].begin(),num[i].end());
	for(int i=0;i<m;i++){
		printf("%06d",p[i]);
		auto tmp=lower_bound(num[p[i]-1].begin(),num[p[i]-1].end(),y[i])-num[p[i]-1].begin()+1;
		printf("%06d\n",tmp);	
	}
}

Measured memory_bytes: 7808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    int N;
    int[] a, b;
    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        a = new int[N - 1];
        b = new int[N - 1];
        es = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            es[i] = new List<int>();
        }
        for (int i = 0; i < N - 1; i++)
        {
            a[i] = cin.nextInt() - 1;
            b[i] = cin.nextInt() - 1;
            es[a[i]].Add(b[i]);
            es[b[i]].Add(a[i]);
        }

        int start = 0;
        if(dfs(0,-1) == 2)
        {
            Console.WriteLine("First");
            return;
        }
        for (int t = 0; t < 2; t++)
        {
            Queue<int> q = new Queue<int>();
            bool[] used = new bool[N];
            used[start] = true;
            q.Enqueue(start);
            int last = start;
            while(q.Count > 0)
            {
                int now = q.Dequeue();
                foreach (var next in es[now])
                {
                    if (used[next]) continue;
                    used[next] = true;
                    q.Enqueue(next);
                }
            }
            if(dfs(last, -1) == 2)
            {
                Console.WriteLine("First");
                return;
            }
            foreach (var next in es[last])
            {
                if (dfs(next, -1) == 2)
                {
                    Console.WriteLine("First");
                    return;
                }
            }
            start = last;
        }
        Console.WriteLine("Second");
        return;

    }

    int dfs(int p, int pre)
    {
        int ans = 0;
        foreach (var next in es[p])
        {
            if (next == pre) continue;
            ans += dfs(next, p);
        }
        if (ans >= 2) return 2;
        return 1 - ans;
    }
}

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);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

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

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

}

Measured memory_bytes: 30092
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>
#include <fstream>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}
template<typename Iterator> void printVecPair(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << it->first << " " << it->second << " ";
    if ((it - begin) % 10 == 9 || it == end - 1) std::cout << std::endl;
  }
}

template<typename T> T bitnum(T x)
{
  T cnt = 1;
  T ret = 0;
  while (x > 0) {
    ret += (x % 2) * cnt;
    x /= 2;
    cnt *= 10;
  }
  return ret;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  ll N, M, C;
  std::cin >> N >> M >> C;
  std::vector<ll> vb(M);
  for (ll i = 0; i < M; i++) {
    std::cin >> vb[i];
  }
  std::vector< std::vector<ll> > va(N, std::vector<ll>(M, 0LL));
  for (ll y = 0; y < N; y++) {
    for (ll x = 0; x < M; x++) {
      std::cin >> va[y][x];
    }
  }
  ll cnt = 0;
  for (ll y = 0; y < N; y++) {
    ll point = C;
    for (ll x = 0; x < M; x++) {
      point += va[y][x] * vb[x];
    }
    if (point > 0LL) {
      cnt++;
    }
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n,t;
	string s,s1,s2;
	cin>>s;
	if(s[s.size()-1]=='s')
    {
        cout<<s+"es"<<"\n";
    }
    else
        cout<<s+"s"<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 505;
int a[maxn][maxn];

int main() {
	int H = read, W = read, h = read, w = read;
	if(w * h == 1) return puts("No"), 0;
	int k = (1000000000 - 1) / (w * h - 1);

	ll sum = 0;
	for(int i = 1; i <= H; i ++)
		for(int j = 1; j <= W; j ++) {
			if(i % h == 0 and j % w == 0)
				a[i][j] = k - w * h * k - 1;
			else
				a[i][j] = k;
			sum += a[i][j];
		}

	if(sum > 0) {
		puts("Yes");
		for(int i = 1; i <= H; i ++) {
			for(int j = 1; j <= W; j ++)
				printf("%d ", a[i][j]);
			puts("");
		}
	} else
		puts("No");
}


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

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


int main()
{
	startup();
				
				  		int n;
				  		cin>>n;
				  		int ar[n];
				  		for(int i=0 ; i<n ; ++i)
				  			cin>>ar[i];
				  		int ans=0;
				  		for(int i=0 ; i<n ; ++i)
				  		{
				  			for(int j=i+1 ; j<n ; ++j)
				  			{
				  				for(int k=j+1 ; k<n ; ++k)
				  				{
				  					if((ar[i]+ar[j])>ar[k] && (ar[k]+ar[j])>ar[i] && (ar[i]+ar[k])>ar[j] && ar[i]!=ar[j] && ar[j]!=ar[k] && ar[i]!=ar[k])
				  					{
				  						++ans;
				  					}
				  				}
				  			}
				  		}
				  		cout<<ans;

	
	return 0;
}



Measured memory_bytes: 3644
use proconio::input;


struct Burger {
    a: Vec<usize>,
    p: Vec<usize>,
}

impl Burger {
    fn new(n: usize) -> Self {
        let mut a = vec![1];
        let mut p = vec![1];
        for i in 0..n {
            a.push(2 * a[i] + 3);
            p.push(2 * p[i] + 1);
        }
        Self { a, p }
    }

    fn solve(&self, n: usize, x: isize) -> usize {
        if n == 0 {
            if x <= 0 {
                0
            } else {
                1
            }
        } else if x <= self.a[n-1] as isize + 1 {
            self.solve(n-1, x-1)
        } else {
            self.solve(n-1, x - self.a[n-1] as isize - 2) + self.p[n-1] + 1
        }
    }
}

fn main() {
    input! {
        n: usize,
        x: usize,
    }

    let burger = Burger::new(n);

    let ans = burger.solve(n, x as isize);
    
    println!("{}", ans);

}


Measured memory_bytes: 2152
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
              }
   cout<<dp[n-1]<<endl;
              }

Measured memory_bytes: 4404
using System;
using System.Linq;

class Program {
  static bool Hoge(int[] w, int k, int p) {
    int t = 0;
    for (int i = 0; i < w.Length; i++) {
      if (k < 0) return false;
      else if (w[i] <= p - t) {
        t += w[i];
        if (t == p) { k--; t = 0; }
      } else { k--; t = 0; i--; }
    }
    return true;
  }

  static void Main() {
    var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = a[0];
    int k = a[1];
    var w = Enumerable.Range(1, n).Select(_ => int.Parse(Console.ReadLine())).ToArray();
    int L = 0;
    int r = w.Sum();
    while (L < r) {
      int m = (L + r) / 2;
      if (Hoge(w, k - 1, m)) r = m;
      else L = m + 1;
    }
    Console.WriteLine(L);
  }
}


Measured memory_bytes: 21360
#include <stdio.h>

int main(void)
{ int num, co=0, w,y;
  char str[10];
  scanf("%s", &str);
 
  for(num=0; num<10; num++){
  if('A'==str[num]||'T'==str[num]||'C'==str[num]||'G'==str[num])
  {co=co+1;}
   
  else {
   if(w<=co)
  w=co;co=0;}}
  if(co>w)
    y=co;
  else
    y=w;
   printf("%d" ,y);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define zeros(x) ((x) & (-x))
#define inf 1e18

using namespace std;

typedef long long ll;
typedef long double ld;

ll a, b;

ll gcd(ll a, ll b)
{
    while (b)
    {
        ll r = a%b;
        a=b;
        b=r;
    }
    return a;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b;
    cout<<a*b/gcd(a, b);

    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int n=s.size(),r,l,count_r=1,count_l=0;
  vector<int> x(100000,0);
  char c1=s.at(0),c2;
  REP(i,n-1){
    c2=s.at(i+1);
    if(c1=='R' && c2=='R') count_r++;
    else if(c1=='R' && c2=='L'){
      r=i;
      l=i+1;
      x.at(r)+=(count_r+1)/2;
      x.at(l)+=(count_r+2)/2;
      count_l=0;
    }else if(c1=='L' && c2=='L'){
      count_l++;
      if(i==n-2){
        x.at(r)+=(count_l+1)/2;
        x.at(l)+=count_l/2;    
      }
    }else{
      x.at(r)+=(count_l+1)/2;
      x.at(l)+=count_l/2;      
      count_r=1;
    }
    c1=c2;
  }
  REP(i,n) cout<<x.at(i)<<" ";
}

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

using namespace std;

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

    int N;
    cin >> N;
    string s;
    int answer = 0;
    int last_A_and_first_B = 0;
    int last_A = 0;
    int first_B = 0;
    for (int n = 0; n < N; n++)
    {
        cin >> s;
        for (int i = 0; i < s.size() - 1; i++)
        {
            if (s[i] == 'A' && s[i + 1] == 'B')
            {
                answer++;
            }
        }
        if (s[0] == 'B' && s[s.size() - 1] == 'A')
        {
            last_A_and_first_B++;
        }
        else if (s[0] == 'B')
        {
            first_B++;
        }
        else if (s[s.size() - 1] == 'A')
        {
            last_A++;
        }
    }

    if (last_A_and_first_B == 0)
    {
        answer += min(last_A, first_B);
    }
    else if (last_A + first_B != 0)
    {
        answer += last_A_and_first_B + min(last_A, first_B);
    }
    else
    {
        answer += last_A_and_first_B - 1;
    }

    cout << answer << '\n';

    return 0;
}

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

void addVal(int* digit, int index){
	switch(digit[index]){
		case 0:
			digit[index] = 3;
			break;
		case 3:
			digit[index] = 5;
			break;
		case 5:
			digit[index] = 7;
			break;
		case 7:
			digit[index] = 3;
			addVal(digit, ++index);
			break;
	}
}

bool checkVal(int* digit){
	bool isThree, isFive, isSeven;
	isThree = false;
	isFive = false;
	isSeven = false;
	for(int index = 0; index < 10; index++){
		switch(digit[index]){
			case 3:
				isThree = true;
				break;
			case 5:
				isFive = true;
				break;
			case 7:
				isSeven = true;
				break;
		}
	}
	return isThree && isFive && isSeven;
}

int countSmall(int num){
	int digit[10];
	digit[0] = 7;
	digit[1] = 5;
	digit[2] = 3;
	digit[3] = 0;
	digit[4] = 0;
	digit[5] = 0;
	digit[6] = 0;
	digit[7] = 0;
	digit[8] = 0;
	digit[9] = 0;
	long long val = digit[2]*100+digit[1]*10+digit[0];
	int count = 0;
	while(num >= val){
		count++;
		do{
			addVal(digit, 0);
		}while(!checkVal(digit));
		val = 0;
		for(int index = 0; index < 10; index++){
			val += digit[index] * pow(10, index);
		}
	}
	return count;
}

int main(void){
	long long N;
	cin >> N;
	cout << countSmall(N) << endl;
	return 0;
}


Measured memory_bytes: 256
def c_4_over_n(N):
    for h in range(1, 3501):
        for n in range(1, h + 1):
            # 条件式をwについて整理したときの分子と分母
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h
            # このときwが正整数になる
            if denominator > 0 and numerator % denominator == 0:
                w = numerator // denominator
                # 分母の値が小さなもの順に表示する(趣味)
                ans = '{0} {1} {2}'.format(*sorted([h, n, w]))
                return ans
    return None

N = int(input())
print(c_4_over_n(N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;

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

    if(s[0]!='A'){
        cout<<"WA"<<"\n";
        return 0;
    }
    size_t l=s.length();
    int cnt=0;
    for(int i=1;i<l;i++){
        if(isupper(s[i])){
            if(i==1 || i==l-1 || s[i]!='C'){
                cout<<"WA"<<"\n";
                return 0;
            }
            else cnt++;
        }
    }
    if(cnt==1) cout<<"AC"<<"\n";
    else cout<<"WA"<<"\n";
    return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
arr = list(map(int, input().split()))
dp = [False]*(K+1)
for i in range(K+1):
    for k in range(N):
        if i >= arr[k] and not dp[i-arr[k]]:
            dp[i] = True
print('First' if dp[K] else 'Second')

Measured memory_bytes: 41812
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	g := makeGraph(n)
	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			c := getNextInt(scanner)
			g[u][v] = c
		}
	}

	ans := make([]int, n)
	im := make(IntMap, 1)
	im.increment(0)
	for len(im) < n {
		min := 1 << 30
		x := -1
		for u := range im {
			for v := 0; v < n; v++ {
				if im.get(v) != 0 {
					continue
				}
				if min > ans[u]+g[u][v] {
					min = ans[u] + g[u][v]
					x = v
				}
			}
		}
		im.increment(x)
		ans[x] = min
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, fmt.Sprintf("%d %d", i, ans[i]))
	}
	writer.Flush()
}

func makeGraph(n int) [][]int {
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		for ii := 0; ii < n; ii++ {
			g[i][ii] = 1 << 30
		}
	}

	return g
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}



Measured memory_bytes: 1348
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int r;
	cin >> r;
	cout << 2*PI*r << endl;
	return 0;
}


Measured memory_bytes: 3780
import java.util.Scanner;
import java.util.ArrayList;
import java.math.*;

public class Main {
    private static final int MAXN = 212;

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

        var data = new Long[2 * MAXN + 1];

        for (int i = -MAXN; i <= MAXN; ++i) {
            data[i + MAXN] = (long)Math.pow(i, 5);
        }

        for (int i = 0; i <= 2 * MAXN; ++i) {
            for (int j = 0; j <= 2 * MAXN; ++j) {
                if (data[i] - data[j] == x) {
                    System.out.printf("%d %d\n", i - MAXN, j - MAXN);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 36324
N, K = map(int, input().split())
a = list(map(int, input().split()))

max_bit = 40
ans = 0
for i in range(max_bit, -1, -1):
  bit = 2 ** i
  c = len([1 for j in a if j&bit > 0])
  if 2*c < N and bit <= K:
    c = N - c
    K -= bit
  ans += bit * c
print(ans)

Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


struct ConvexHullTrick {
  using R = double;
  static constexpr lint max_x = 2e6;
  static constexpr lint inf = numeric_limits<lint>::max();
  struct Line {
    lint a, b;
    R x; // 右端
    bool operator<(const Line& r) const {
      return a == inf or r.a == inf ? x < r.x : a < r.a;
    }
  };
  set<Line> se;
  bool need(const Line& l, const Line& m, const Line& r) {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
  void add(lint a, lint b) {
    auto itr = se.find({a});
    if (itr != end(se)) {
      if (b <= itr->b) return;
      itr = se.erase(itr);
    } else {
      itr = se.lower_bound({a});
      if (itr != begin(se) and itr != end(se) and !need(*prev(itr), {a, b}, *itr)) return;
    }
    if (itr != end(se)) {
      while (next(itr) != end(se) and !need({a, b}, *itr, *next(itr))) {
        itr = se.erase(itr);
      }
    }
    if (itr != begin(se)) {
      while (prev(itr) != begin(se) and !need(*prev(itr, 2), *prev(itr), {a, b})) {
        se.erase(prev(itr));
      }
    }
    R x = max_x;
    if (itr != end(se)) {
      x = -(R) (itr->b - b) / (itr->a - a);
    }
    itr = se.emplace_hint(itr, Line{a, b, x});
    if (itr != begin(se)) {
      auto e = *prev(itr);
      se.erase(prev(itr));
      e.x = -(R) (b - e.b) / (a - e.a);
      se.insert(e);
    }
  }
  lint max(lint x) const {
    auto itr = se.lower_bound({inf, inf, (R) x});
    return itr->a * x + itr->b;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  ConvexHullTrick cht;
  V<lint> dp(n, 1e18);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = -cht.max(h[i]) + h[i] * h[i] + c;
    }
    cht.add(2 * h[i], -(dp[i] + h[i] * h[i]));
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main()
{//manpreet
    int x, a, b;
    int dig, ans;
    cin >> x >> a >> b;
    ans = x - a;
    dig = ans / b;
    ans -= dig * b;
    cout << ans << endl; 
    return 0;
}

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

int main() {
    int a[2][100];
    int n;cin >> n;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<i+1;j++){
            sum += a[0][j];
        }
        for(int j=i;j<n;j++){
            sum += a[1][j];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
vector<vector<int>> grid_bfs(int h,int w,int x,int y,vector<string> &maze,char obstacle='#') {
  const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };//4方向移動
  const int init=1e7;
  vector<vector<int>>d(h,vector<int>(w,init));
  d[x][y]=0;
  queue<pair<int, int>>q;
	pair<int, int>p;
  q.emplace(x,y);
	while (!q.empty()) {
		p = q.front();
		q.pop();
		for (int i = 0; i < 4; ++i) {
			int nx = p.first+dx[i]; int ny = p.second+dy[i];
			if (0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != obstacle && d[nx][ny] == init) {
				q.push(make_pair(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
  return d;//initを含むことに注意
}


void solve(){
  int h,w;
  cin>>h>>w;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  int b=0;
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#')++b;
    }
  }
  vector<vector<int>>d=grid_bfs(h,w,0,0,s);
  if(d[h-1][w-1]==1e7)cout<<-1;
  else cout<<h*w-b-d[h-1][w-1]-1;
}

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N=int(input())
    
    A, B = [0] * N, [0] * N
    for i in range(N):
        A [i], x = map(str, input().split())
        B[i]=int(x)
    X=str(input())
    for i in range(N):
        if A[i]==X:
            print(sum(B[i+1:]))
            break
    

    

    

    
resolve()

Measured memory_bytes: 38384
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

int main(){
  
  int i, N, a, cnt = 0;

  cin >> N;
  while(N--) {
    cin >> a;
    bool judge = false;
    for(i = 1; i * i < a && (a - i) >= (2 * i + 1); i++) {
      if((a - i) % (2 * i + 1) == 0) {
        judge = true;
        break;
      } 
      // cout << a << endl;
    }
    if(!judge) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
 
using namespace std;
 
int main() {
    long a,b;
    cin >>a>>b;
   for(long i=0;;i+=b){
    if(i==0) continue;
    if(i%a == 0&&i%b==0){
     cout<<i;
     return 0;
    }
   }
  
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
const   int MaxN=1e5+5;
int n,W;
typedef pair<int,int> ii;
ii a[MaxN];
typedef long long ll;
ll f[105][MaxN],res;

void Xuli()
{
    for(int i=1;i<=n;i++)
        for(int j=1;j<=W;j++)
        {
            f[i][j]=f[i-1][j];
            if (j-a[i].X>=0) f[i][j]=max(f[i][j],f[i-1][j-a[i].X]+a[i].Y);
            res=max(res,f[i][j]);
        }
    printf("%lld",res);
}

int main()
{
   
    scanf("%d%d",&n,&W);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].X,&a[i].Y);
    Xuli();
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int sum=0;
    map<int,int> cnt;
    cnt[sum]++;
    REP(i,N){
        sum+=a[i];
        cnt[sum]++;
    }

    int ans=0;
    for(pint p:cnt){
        ans+=p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 14336
overflow x y
  | 10^80 > (read x + read y) = show (read x + read y)
  | otherwise = "overflow"

oF xs'@(x:y:xs)
  | xs == [] = [overflow x y]
  | otherwise  = (overflow x y) : oF xs

main = getContents >>=
         mapM_ putStrLn . oF . filter (/="") . tail . lines

Measured memory_bytes: 4192
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define ll long long
	#define ld long double
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		T=1;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			int n,i,j;
			cin>>n;
			int ar[n+1];
			int flag=1;
			for(i=1;i<=n;++i)
			{
				cin>>ar[i];
				if(ar[i]%2==0)
				{
					if(ar[i]%3!=0 && ar[i]%5!=0)
						flag=0;
				}
			}
			if(flag)
				cout<<"APPROVED"<<endl;
			else
				cout<<"DENIED"<<endl;
		}
		return 0;
	}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)

typedef vector<ll> vec;
typedef vector<vec> mat;

ll MOD = 1000000007ll;

mat mul(mat &A,mat &B)
{
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();i++)
	{
		for(int k=0;k<B.size();k++)
		{
			for(int j=0;j<B[0].size();j++)
			{
				C[i][j]=(C[i][j]+A[i][k]*B[k][j])%MOD;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n)
{
	mat B(A.size(),vec(A.size()));
	for(int i=0;i<A.size();i++)
	{
		B[i][i]=1ll;
	}
	while(n>0)
	{
		if(n&1)B = mul(B,A);
		A = mul(A,A);
		n >>= 1;
	}
	return B;
}

// 1 1 2 3 5 8 ...
ll fib(ll x)
{
	mat A(2,vec(2));
	A[0][0]=1;A[0][1]=1;A[1][0]=1;A[1][1]=0;
	A = pow(A,x);
	return A[1][0];
}
int N;
ll K;
int main(){
	cin >> N >> K;
	mat G;
	G.resize(N);
	for(int i=0;i<N;i++)G[i].resize(N);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> G[i][j];
		}
	}
	mat R = pow(G,K);
	ll ans = 0ll;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			ans += R[i][j];
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  int i;
  cin >> n;
  vector<int> a(n);
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int counter = 0;
  int temp = a[0];
  while(temp%2 == 0){
    temp = temp >> 1;
    counter++;
  }
  if(counter == 0){
    cout << 0 << endl;
    return 0;
  }
  int division = 1 << counter;
  while(1){
    for(i=0; i<a.size(); i++){
      if(a[i]%division != 0){
        break;
      }
      if(i == a.size()-1){
        cout << counter << endl;
        return 0;
      }
    }
    division = division >> 1;
    counter--;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int32_t main()
{
	fastIO
	inp_out();
	int n; 
	cin >> n; 
	vi a(n); 
	for(int i = 0; i < n;  ++ i)
		cin >> a[i]; 

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

	int ans = a[n - 1]; 

	int idx = n - 2, cnt = 0; 

	for(int i = n - 3; i >= 0;  -- i)
	{
		ans  += a[idx]; 
		 ++ cnt; 
		 if(cnt % 2  == 0)
		 	 -- idx; 
	}

	cout << ans; 


	return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int64_t d, g;
  cin >> d >> g;
  vi p(d), c(d);
  rep(i, d) cin >> p[i] >> c[i]; 

  int ans = 10000;
  rep(tmp, 1<<d) {
    bitset<10> bit(tmp);
    int64_t sum = 0;
    int curr = 0;
    int rest_max = 0;
    rep(i, d) {
      if (bit[i] == 0) rest_max = i;
      else {
        sum += 100*(i+1)*p[i] + c[i];
        curr += p[i];
      }
    }
    if (sum < g) {
      int curr_rest = ((g-sum)/100+rest_max)/(rest_max+1);
      if (curr_rest <= p[rest_max]) curr += curr_rest;
      else continue;
    }
    ans = min(ans, curr);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636