akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    int a,b,c;

    void solve(){
        cin >> a >> b >> c;
        int ans = INF;
        for(int i=-200; i<=250; ++i){
            int tmp = 0;
            tmp += (a>=i? a-i:(i-a+1)/2+(i-a)%2);
            tmp += (b>=i? b-i:(i-b+1)/2+(i-b)%2);
            tmp += (c>=i? c-i:(i-c+1)/2+(i-c)%2);
            ans = min(ans,tmp);
        }
        cout << ans <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    Problem::Solver sol;
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if(T[u].p == NIL) cout << "root, ";
	else if(T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
		if(i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p){
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r, p);
	if(T[u].l != NIL) rec(T[u].l, p + 1);
}

int main(){
	int i, j, d, v, c, l, r;
	cin >> n;
	for(i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for(i = 0; i < n; i++) {
		cin >> v >> d;
		for(j = 0; j < d; j++) {
			cin >> c;
			if(j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for(i = 0; i < n; i++) if(T[i].p == NIL) r = i;

	rec(r, 0);

	for(i = 0; i < n; i++) print(i);

	return 0;
}



Measured memory_bytes: 7756
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s;
    ll k;
    cin >> s >> k;
    char buf = ' ';
    int cnt = 1;
    ll ans = 0;
    for(int i=0;i<s.size();i++){
        if(buf != s[i]){
            if(cnt > 1) ans += cnt/2;
            buf = s[i];
            cnt = 1;
        }else{
            cnt++;
        }
    }
    if(cnt > 1) ans += cnt/2;
    if(s[0] == s[s.size()-1]){
        int scnt = 1, ecnt = 1;buf = s[0];
        int i = 1;
        while(s[i++] == buf) scnt++;
        i = s.size() -2;
        while(s[i--] == buf) ecnt++;
        if(scnt + ecnt > s.size()) {// same all alphabet
            cout << s.size() * (k/2) + (s.size()/2) * (k%2) << endl;
            return 0;
        }else{
            ans -= scnt/2 + ecnt/2;
            cout << (ans * k) + ((scnt+ecnt)/2) * (k-1) + scnt/2 + ecnt/2 << endl;
            return 0;
        }
   }
    cout << ans * k << endl;
}

Measured memory_bytes: 256
//
//	Created by shamim_nik
//

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

typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define br printf("\n")

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int N;
  	cin >> N;
	N %= 10;
	if (N == 3) {
		cout << "bon" << endl;
	} else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon" << endl;
	} else {
		cout << "hon" << endl;
	}
	return 0;
}

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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a= int.Parse(Console.ReadLine());
            string n;
            n = Console.ReadLine();
            if (a < 3200)
                Console.WriteLine("red");
            else
                Console.WriteLine(n);
            Console.ReadKey();

            
        }
    }
}


Measured memory_bytes: 13140
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  a.append(list(map(int,input().split())))
for i in range(m):
  b.append(list(map(int,input().split())))
for i in range(n):
  tmp=10**9
  for j in range(m):
    man=abs(a[i][0]-b[j][0]) + abs(a[i][1]-b[j][1])
    if man < tmp:
      tmp=man
      ans=j+1
  print(ans)

Measured memory_bytes: 3064
s = input().rstrip().split(' ')
h = int(s[0])
w = int(s[1])
lst = [[0] * w for i in range(h)]
for i in range(h):
  t = input().rstrip().split(' ')
  for j in range(w):
    lst[i][j] = int(t[j])
anssum = [0] * (w+1)
for k in range(h):
  ans = ""
  for l in range(w):
    ans += str(lst[k][l]) + " "
    anssum[l] += int(lst[k][l])
  ans += str(sum(lst[k]))
  anssum[w] += int(sum(lst[k]))
  print(ans)
ansbottom = ""
for m in range(w):
  ansbottom += str(anssum[m]) + " "
ansbottom += str(anssum[w])
print(ansbottom)

  
  



Measured memory_bytes: 5692
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c>d) swap(c,d);
    ll ans=b-a+1;
    ans-=b/c-(a-1)/c;
    ans-=b/d-(a-1)/d;
    ans+=b/lcm(d,c)-(a-1)/lcm(d,c);
    cout<<ans;
}


Measured memory_bytes: 256
N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 100
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs >= abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste

min_taste_index = tastes.index(min_taste)
if len(tastes) == min_taste_index+1:
    print(sum(tastes[:min_taste_index]))
else:
    print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

ll fact[2000002];

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

ll modinv(ll a){
	return modpow(a, MOD-2);
}

ll nCr(ll n, ll r){
	if (n < r) return 0;
	return ((fact[n]*modinv(fact[n-r]))%MOD*modinv(fact[r]))%MOD;
}

int main(){
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	fact[0] = 1;
	for (int i = 1; i <= 2000001; i++){
		fact[i] = (fact[i-1]*i)%MOD;
	}

	ll ans = 0;
	for (int i = r1; i <= r2; i++){
		ans += nCr(c2+i+1, i+1) - nCr(c1+i, i+1);
		ans %= MOD;
		if (ans < 0) ans += MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19216
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;

    int a = n / 100, b = n % 100;

    if(1 <= a && a <= 12) {
        if(1 <= b && b <= 12) {
            cout << "AMBIGUOUS\n";
        } else {
            cout << "MMYY\n";
        }
    } else {
        if(1 <= b && b <= 12) {
            cout << "YYMM\n";
        } else  {
            cout << "NA\n";
        }
    }
}


Measured memory_bytes: 256
N = int(input())
x_list = list(map(int, input().split()))
maxValue = max(x_list)
minValue = 1000000
for i in range(1,100):
    ans = 0
    for j in range(N):
        ans += ( x_list[j] - i ) **2

    if(ans < minValue):
        minValue = ans

print(minValue)

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

int main(void) {
char c;
cin >> c;
if(c == 'a' || c =='i' || c=='u' || c=='e' || c=='o') {
 cout << "vowel" << endl;
} else {
cout << "consonant" << endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int A,B;
	int N;
	cin>>A>>B>>N;
	FOR(i,0,N){
		int S,F;
		cin>>S>>F;
		if(F<=A||B<=S){
			continue;
		}else{
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3104
N = int(input())
huga = input().split()
p = []
for i in range(N):
  p.append(int(huga[i]))
count = 0
for i in range(1,N-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
    count += 1
  if p[i-1] > p[i] and p[i] > p[i+1]:
    count += 1
    
print(count)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var n = Sarray()[0];
            var ai = Sarray();
            var ans = new long[n];
            for (long i = n - 1, l = 0; 0 <= i; i -= 2)
                ans[l++] = ai[i];
            for (long i = n - 2, r = n - 1; 0 <= i; i -= 2)
                ans[r--] = ai[i];
            WriteLine(string.Join(" ", ans));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 64088
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N, M;
int root;
vector<vector<int> > G;

vector<int> dist, pre;
int rec(int v) {
    if (dist[v] != -1) return dist[v];
    int res = 0;
    for (auto nv : G[v]) {
        if (chmax(res, rec(nv) + 1)) {
            pre[v] = nv;
        }
    }

    //cout << v << ": " << res << ", " << pre[v] << endl;
    return dist[v] = res;
}

int main() {
    vector<int> deg;
    while (cin >> N >> M) {
        G.assign(N, vector<int>());
        deg.assign(N, 0);
        dist.assign(N, -1);
        pre.assign(N, -1);
        for (int i = 0; i < N + M - 1; ++i) {
            int a, b; cin >> a >> b; --a, --b;
            G[b].push_back(a);
            deg[b]++;
        }

        root = -1;
        for (int v = 0; v < N; ++v) {
            if (deg[v] == 0) root = v;
        }
        dist[root] = 0;
        for (int v = 0; v < N; ++v) {
            rec(v);
        }
        
        for (int v = 0; v < N; ++v) {
            cout << pre[v] + 1 << endl;
        }
    }
}















Measured memory_bytes: 10496
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N=int(input())
print(A[N-1])

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

using namespace std;

int main(){
    int n,sum = 0;
    cin >> n;
    
    vector<int>vb(n,100001);

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

    sum = vb[0];

    for(int i = 1;i < n;i++){
        sum += min(vb[i],vb[i-1]);
    }

    cout << sum << endl;
    
    return 0;
}

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

using namespace std;

int main(){
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2){
        int count = 0;
        for(int j = 1; j <= i; ++j){
            if(i%j == 0) count++;
        }
        if(count == 8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
H,W=gets.split.map &:to_i
h=Hash.new 0
$<.read.chars{|c|c!="\n"&&h[c]+=1}
g=0;puts h.values.count{|e|g+=e%4>1?1:0;e%2>0}>1||g>W%2*H/2+H%2*W/2 ? :No : :Yes

Measured memory_bytes: 3836
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn abs(x:i64)->i64{
    if x<0{
	-1*x
    }else {
	x
    }
}

//main function
fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let c:i64 = read();
    let d:i64 = read();
    if (abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <= d) {
	println!("Yes");
    }else{
	println!("No");
    }
}


Measured memory_bytes: 4352
package main

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

var stdin = initStdin()
 
func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func scanInt() int {
	stdin.Scan()
	i, _ := strconv.Atoi(stdin.Text())
	return i
}

func scanStr() string {
	stdin.Scan()
	return stdin.Text()
}

type ia []int

func (ia ia)Len() int {
	return len(ia)
}
func (ia ia)Swap(i, j int) {
	ia[i], ia[j] = ia[j], ia[i]
}
func (ia ia)Less(i, j int) bool {
	return ia[i] < ia[j]
}

func main() {
	h := scanInt()
	w := scanInt()
	var m [][]byte
	scw := make([][]int, h)
	sch := make([][]int, h)
	for i := 0; i < h; i++ {
		m = append(m, []byte(scanStr()))
		scw[i] = make([]int, w)
		sch[i] = make([]int, w)
	}

	for i := 0; i < h; i++ {
		sq := 0
		for j := 0; j < w; j++ {
			if m[i][j] == '.' {
				sq++
				if j == w-1 {
					scw[i][j] = sq
				}
			} else if sq > 0 {
				scw[i][j - 1] = sq
				sq = 0
			}
		}
	}

	for i := 0; i < w; i++ {
		sq := 0
		for j := 0; j < h; j++ {
			if m[j][i] == '.' {
				sq++
				if j == h-1 {
					sch[j][i] = sq 
				}
			} else if sq > 0 {
				sch[j - 1][i] = sq
				sq = 0
			}		
		}
	}

	for i := h-1; i >= 0; i-- {
		sq := 0
		for j := w-1; j >= 0; j-- {
			if m[i][j] == '.' {
				if sq < scw[i][j] {
					sq = scw[i][j]
				} else {
					scw[i][j] = sq
				}
			} else {
				sq = 0
			}
		}
	}

	for i := w-1; i >= 0; i-- {
		sq := 0
		for j := h-1; j >= 0; j-- {
			if m[j][i] == '.' {
				if sq < sch[j][i] {
					sq = sch[j][i]
				} else {
					sch[j][i] = sq
				}
			} else {
				sq = 0
			}
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			tmp := scw[i][j] + sch[i][j] - 1
			if ans < tmp && m[i][j] == '.' {
				ans = tmp
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 73856
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)


int power(int x, int y) 
{ 
    int res = 1;    
    x = x % mod; 
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % mod; 
  
        y = y>>1; 
        x = (x*x) % mod;   
    } 
    return res; 
} 

int32_t main()
{
    speed upp
    int n,m,ans=0;
    cin>>n>>m;
    int dp[n+1][m+1],a[n+1][2];
    f(i,0,n)
    f(j,0,m)
        dp[i][j]=0;
    f(i,1,n)
        cin>>a[i][1]>>a[i][0];
    f(i,1,n)
    {   
        f(j,1,m)
        {
            if(j>=a[i][1])
                dp[i][j]=max(dp[i-1][j-a[i][1]]+a[i][0],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
            //  cout<<dp[i][j]<<" ";
            ans=max(ans,dp[i][j]);
        }
        // cout<<endl;
    }
    cout<<ans;
}

Measured memory_bytes: 79232
n=int(input())
a=list(map(int,input().split()))
print(*a)
for i in range(1,n):
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        a[j+1]=a[j]
        j-=1
        a[j+1]=v
    print(*a)


Measured memory_bytes: 5976
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
int dp[MAX];
int a[MAX];
int n;
const int inf = 0x3f3f3f3f;

int run(int idx) {
	if(idx >= n)return inf;
	if(idx == n-1)return 0;
	int &res = dp[idx];
	if(res != -1)return res;
	res = inf;
	if(idx+1 < n)res = min(res, abs(a[idx] - a[idx+1]) + run(idx+1));
	if(idx+2 < n)res = min(res, abs(a[idx] - a[idx+2]) + run(idx+2));
	return res;
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", a+i);
	}
	memset(dp, -1, sizeof(dp));
	printf("%d\n", run(0));


	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;
   vector<int>wtf(N);
   int min=10000000;
   int answer=0;
   for(int i=0; i<N; i++){
    cin>>wtf.at(i);
    if(min>wtf.at(i)){
    min=wtf.at(i);
    answer++;
    }
      }   
   cout<<answer<<endl;
}

Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdint.h>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <tuple>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

int main() {
//     5 3 1 2 4
// 6 4 2 1 3 5
    int n;
    cin >> n;
    VI a(n);
    REP(i, n) scanf("%d", &a[i]);
    VI ans;
    for (int i = n; i >= 1; i -= 2) {
        ans.PB(a[i - 1]);
    }
    int i = n % 2 ? 2 : 1;
    for (; i <= n; i += 2) {
        ans.PB(a[i - 1]);
    }
    REP(i, n) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3828
# -*- coding: utf-8 -*-

n = int(input())
dic = {}
for i in range(n):
    s = list(input())
    for j in range(97, 123):
        if i == 0:
            dic[chr(j)] = s.count(chr(j))
        else:
            dic[chr(j)] = min(dic[chr(j)], s.count(chr(j)))
ans = []
for key in dic:
    if dic[key] != 0:
        for _ in range(dic[key]):
            ans.append(key)
ans.sort()
print(''.join(ans))


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

int main(void){
    int a;
    char b;
    int c;
    while(1){
    cin >> a >> b >> c;
    if(b == '+'){
        cout << a+c << endl;
    }
    if(b == '-'){
        cout << a-c << endl;
    }
    if(b == '*'){
        cout << a*c << endl;
    }
    if(b == '/'){
        cout << a/c << endl;
    }
    if(b == '?'){
        break;
    }
    }
    
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

string joi = "JOI";

int main() {
	int n;
	string s;
	cin >> n >> s;
	
	vector<vector<ll>> v1(3, vector<ll>(n+2, 0));//0 - n
	vector<vector<ll>> v2(3, vector<ll>(n+2, 0));//1 - n+1

	REP(i, 1, n+1){
		v1[0][i] = v1[0][i-1] + (s[i-1] == 'J' ? 1 : 0);
		v1[1][i] = v1[1][i-1] + (s[i-1] == 'O' ? v1[0][i-1] : 0);
		v1[2][i] = v1[2][i-1] + (s[i-1] == 'I' ? v1[1][i-1] : 0);
	}
	
	for(int i = n; i >= 1; i--){
		v2[0][i] = v2[0][i+1] + (s[i-1] == 'J' ? v2[1][i+1] : 0);
		v2[1][i] = v2[1][i+1] + (s[i-1] == 'O' ? v2[2][i+1] : 0);
		v2[2][i] = v2[2][i+1] + (s[i-1] == 'I' ? 1 : 0);
	}
	
	ll ans = v1[2][n];
	ll maxi = 0;
	rep(i, n+1){
		maxi = max(maxi, v2[1][i+1]);//J
		maxi = max(maxi, v1[0][i]*v2[2][i+1]);//'O'
		maxi = max(maxi, v1[1][i+1]);//'I'
	}
	ans += maxi;
	cout << ans << endl;
}

Measured memory_bytes: 8564
N, M = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
arr = make_divisors(M)
from bisect import bisect_left, bisect_right
l = bisect_left(arr, N)
print(M//arr[l])

Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int c[3][3];
  FOR(i,0,3) FOR(j,0,3) cin >> c[i][j];
  FOR(a1,-101,101) {
    FOR(a2,-101,101) {
      FOR(a3,-101,101) {
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
        bool ok = true;
        if(c[1][0] != a2 + b1) ok = false;
        if(c[1][1] != a2 + b2) ok = false;
        if(c[1][2] != a2 + b3) ok = false;
        if(c[2][0] != a3 + b1) ok = false;
        if(c[2][1] != a3 + b2) ok = false;
        if(c[2][2] != a3 + b3) ok = false;
        if(ok) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
a=[]
for x in input().split(" "):
    a.append(int(x))
b=a[0]
c=a[1]
d=[]
i=0
c=str(a[1])
for x in c:
    d.append(int(x))
m=1
da=1
dal=[]
while m<=a[0]:
    while da<=a[1]:
        for x in str(da):
            if len(str(da))==1:
                dal=[0,int(x)]
            else:
                dal.append(int(x))
        if dal[0]*dal[1]==m and dal[0]>=2 and dal[1]>=2:
            i+=1
        da+=1
        dal=[]
    m+=1
    da=0
print(i)

Measured memory_bytes: 3064
def get_input():
    N,K = [int(_) for _ in input().split()]
    S = [int(_) for _  in list(input())]
    return N,K,S

def solve(N,K,S):
    length = len(S)
    array = count_array(S)
    start_char = S[0]
    ans = find_max(array,K,start_char)
    return ans

def find_max(array,K,start_char):
    if start_char ==0 and len(array) <= 2 * K:
        return sum(array)
    elif start_char == 1 and len(array) <=2 * K+1 :
        return sum(array)
    else:
        if start_char == 0:
            start,end = 1,2*K+2
        else:
            start,end = 0,2*K+1
        idx = 0
                    
        current_sum = sum(array[start:end])
        ret = [current_sum]
        if start_char == 0:
            ret.append(sum(array[0:2*K]))
        ret.append(sum(array[-2*K:]))
        while(1):
            start+=2
            end+=2
            if end > len(array):
                break
            current_sum = current_sum- sum(array[start-2:start]) + sum(array[end-2:end])
            ret.append(current_sum)
    return max(ret)
            

def count_array(S):
    array = []
    cur_char = S[0]
    cur_val = 1
    for char in S[1:]:
        if cur_char != char:
            array.append(cur_val)
            cur_char = char
            cur_val = 1
        else:
            cur_val+=1
    array.append(cur_val)

    return array





if __name__ == "__main__":
    N,K,S = get_input()
    ans = solve(N,K,S)
    print(ans)

Measured memory_bytes: 6536
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int p[n]={0};
    int count = n;
    int i,j, d, a;
    for(i=0;i<k;i++){
        cin >> d;
        for(j=0;j<d;j++){
            cin >> a;
            if(p[a-1]==0){
                p[a-1]=1;
                count--;
            }
        }
    }cout << count << endl;
    return 0;
}

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

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

int main(){ 
  ll n;
  cin >> n;
  ll a = 100;

  ll ans = 0;
  while(a < n){
    ans ++;
    a += a/100;
  }

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



Measured memory_bytes: 3636
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int,input().split()))

    ans = 0
    for i in range(1,N):
        diff = A[i-1] - A[i]
        if(diff > 0):
            ans += diff
            A[i] += diff
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 31396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;

int32_t main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;

    //Problem code start

    int n;
    cin >> n;
    int doublets{0};
    while(n--){
        int a,b;
        cin >> a >> b;
        if(a==b){
            doublets++;
        }else{
            doublets=0;
        }
        if(doublets==3){
            cout << "Yes";
            break;
        }
    }
    if(doublets<3){
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI 3.14159265358979
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};
vector<long long> divisor(long long n)
{
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  sort(A.begin(), A.end());
  int cnt = 0;
  set<ll> st;
  if (N == 1)
    cout << 1 << endl;
  else
  {
    bool same = true;
    for (int i = 0; i < N; i++)
    {
      if (A[i] != A[0])
        same = false;
    }
    if (same)
      cout << 0 << endl;
    else
    {
      for (int i = 0; i < N; i++)
      {
        vector<ll> div = divisor(A[i]);
        bool exist = false;
        for (auto it : div)
        {
          if (st.find(it) != st.end())
            exist = true;
        }
        if (!exist)
          if (i == N - 1 || A[i] != A[i + 1])
            cnt++;
        st.insert(A[i]);
      }
      cout << cnt << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 14244
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    long long N;
    cin >> N;
    long long ans = 0;
    for(long long i=1;i*i+i<N;++i){
        if((N-i)%i==0){
            ans += (N-i)/i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input())
tfs = []
rt = str(A)
for bt in (True, False):
  for ct in (True, False):
    for dt in (True, False):
      tfs.append([bt,ct,dt])
for bt,ct,dt in tfs:
  tmp=7-A
  tmp = tmp-B if bt else tmp+B
  tmp = tmp-C if ct else tmp+C
  tmp = tmp-D if dt else tmp+D
  if tmp == 0:
    rt+="+" if bt else "-"
    rt+=str(B)
    rt+="+" if ct else "-"
    rt+=str(C)
    rt+="+" if dt else "-"
    rt+=str(D)
    rt+="=7"
    break

print(rt)

Measured memory_bytes: 9068
x1, y1, x2, y2 = gets.split.map(&:to_i)

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)
puts "#{x3} #{y3} #{x4} #{y4}" 

Measured memory_bytes: 1788
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline().rstrip

N, K = map(int, input().split())

ans = 0
if K == 100:
    K = 101

if N == 0:
    ans = K
else:
    ans = (100 ** N) * K

print(ans)



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

int main()
{
  int n, m, i, j, count;
  cin >> n;
  cin >> m;
  vector<int> a(m), b(m), toshi(n,0);
  for(i=0; i<m; i++)
  {
    cin >> a[i];
    cin >> b[i];
  }
  count = 1;
  for(i=0; i<n; i++)
  {
    for(j=0; j<m; j++)
    {
      if(count == a[j])toshi[i]++;
      if(count == b[j])toshi[i]++;
    }
    count++;
  }
  for(i=0; i<n; i++)
  {
    cout << toshi[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 764
package main

import(
    "fmt"
)



func main() {
    var a,b string
    fmt.Scan(&a,&b)
    ans := "D"
    if (a=="H" && b=="H") || (a=="D" && b=="D"){
        ans = "H"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
	int sumA = 0;
	int sumB = 0;
	for(int i=0; i<4; i++){
	    sumA += kbd.nextInt();
	}
	for(int i=0; i<4; i++){
	    sumB += kbd.nextInt();
	}

	if(sumA>=sumB) System.out.println(sumA);
	else System.out.println(sumB);
    }
}

Measured memory_bytes: 12000
from collections import defaultdict

N,M=map(int,input().split())
d=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    d[a].add(b)
    d[b].add(a)

for i in d[1]:
    if N in d[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

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

int main() {
  int a,b,x,y;
  cin >> a >>b;
  x = min(a,b);
  y = max(a,b);
  
  if(y-2>=x){
  cout << y*2-1 << endl;
  }
  else{
  cout << x+y << endl;
  }
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
        var N = input[0];
        var K = input[1];
        var A = Console.ReadLine().Split(" ").Select(int.Parse);

        var bucket = new int[N + 10];
        foreach (var a in A)
        {
            bucket[a] += 1;
        }
        
        Array.Sort(bucket);
        Array.Reverse(bucket);
        
        var list = new List<int>(bucket);
        list.RemoveAll(n => n == 0);
        var count = 0;
        for (var i = list.Count - 1; 0 <= i; i--)
        {
            if (K >= list.Count) break;
            count += list[i];
            list.RemoveAt(i);
        }
        
        Console.Write(count);
    }
}


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

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> f(n, vector<int>(10));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 10; j++)
			cin >> f.at(i).at(j);
	vector<vector<int>> p(n, vector<int>(11));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 11; j++)
			cin >> p.at(i).at(j);
	int max = -(1 << 30);
	for (int bit = 1; bit < (1 << 10); ++bit)
	{
		int b = 0;
		for (int i = 0; i < n; i++)
		{
			int c = 0;
			for (int j = 0; j < 10; j++)
			{
				if ((bit >> j & 1) && f.at(i).at(j))
					c++;
			}
			b += p.at(i).at(c);
		}
		if (b > max)
			max = b;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
par = list(range(N))
siz = [1] * N
n_friend = [0] * N


def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]


def same(x, y):
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if siz[x] > siz[y]:
        x, y = y, x
    siz[y] += siz[x]
    par[x] = y


def tree_size(x):
    return siz[root(x)]


B = {}
for i in range(N):
    B[i] = set()
for _ in range(M):
    p, q = map(int, input().split())
    n_friend[p - 1] += 1
    n_friend[q - 1] += 1
    unite(p - 1, q - 1)
for _ in range(K):
    p, q = map(int, input().split())
    B[p - 1].add(q - 1)
    B[q - 1].add(p - 1)


# calc friend candidate
i, blocked = 0, 0
for b in B[0]:
    if same(i, b):
        blocked += 1
print(tree_size(i) - 1 - n_friend[i] - blocked, end='')
for i in range(1, N):
    print(' ', end='')
    blocked = 0
    for b in B[i]:
        if same(i, b):
            blocked += 1
    print(tree_size(i) - 1 - n_friend[i] - blocked, end='')
print('')


Measured memory_bytes: 130660
s = input()

if s[-1]=="3":
    print("bon")
elif s[-1]=="0":
    print("pon")
elif s[-1]=="1":
    print("pon")
elif s[-1]=="6":
    print("pon")
elif s[-1]=="8":
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
bool sortDescByFirst(const pair<int,int>&a, const pair<int,int>&b){
    return a.first>=b.first;
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str;
    for(int i=0;i<3;i++){
        cin>>str;
        cout<<str[i];
    }cout<<endl;
    return 0;
}


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


int n;
int mat[100][100];
int acc1[100][100];
int acc2[100][100];
int s = -999999999;


void accum1() {
	for (int y = 0; y < n; y++) acc1[y][0] = mat[y][0];
	for (int y = 0; y < n; y++)
		for (int x = 1; x < n; x++)
			acc1[y][x] = acc1[y][x - 1] + mat[y][x];
}


void accum2() {
	for (int x = 0; x < n; x++) acc2[0][x] = acc1[0][x];
	for (int y = 1; y < n; y++)
		for (int x = 0; x < n; x++)
			acc2[y][x] = acc2[y - 1][x] + acc1[y][x];
}


int getAccum(int xs, int ys, int xe, int ye) {
	if(xs == 0 && ys == 0) return acc2[ye][xe];
	if (xs == 0) return acc2[ye][xe] - acc2[ys - 1][xe];
	if (ys == 0) return acc2[ye][xe] - acc2[ye][xs - 1];
	return acc2[ye][xe] - acc2[ye][xs - 1] - acc2[ys - 1][xe] + acc2[ys - 1][xs - 1];
}


void solve() {
	accum1();
	accum2();
	for (int ys = 0; ys < n; ys++) {
		for (int xs = 0; xs < n; xs++) {
			for (int ye = ys; ye < n; ye++) {
				for (int xe = xs; xe < n; xe++) {
					s = max(s, getAccum(xs, ys, xe, ye));
				}
			}
		}
	}
}


int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> mat[i][j];

	solve();

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 3204
import sys

n = int(sys.stdin.readline())
s = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
t = [int(x) for x in sys.stdin.readline().split()]
cnt = 0

for i in t:
    if i in s:
        cnt += 1

print(cnt)

Measured memory_bytes: 8468
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <string>
#include <queue>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B + C >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
// AISing.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>

using namespace std;

using ll = long long;

int main()
{
    int n;
    
    cin >> n;
    vector<int>v(n + 1, 0);

    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int f = x * x + y * y + z * z + x * y + y * z + z * x;
                if (f > n)break;
                //if(x==y && x==z){v[f]+=1 }
                //else if (x == y || x == z || y == z) {

                //}
                v[f]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << v[i] << endl;
    }
}



Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int fac=1;
	while(n--){
		int x;
		cin>>x;
		if(x%2==0){
			if(x%3==0||x%5==0) continue;
			else{ fac=0; break; }
		}
	}
	cout<<(fac?"APPROVED":"DENIED")<<endl;
	return 0;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N=int(input())
A=input().split()
A=[int(a) for a in A]

ans=0
dp=dict()
for i in range(N):
    b=i+1-A[i]
    if b in dp:
        ans+=dp[b]

    a=A[i]+i+1
    if a not in dp:
        dp[a]=1
    else:
        dp[a]+=1

  

print(ans)

Measured memory_bytes: 40428
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

#define MAXN   100001 
  
int spf[MAXN]; 
  
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)
        spf[i] = i; 

    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
vector<int> getFactorization(ll x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

vector<ll> primeFactors(ll n)  { 
	vector<ll> res;
    while (n % 2 == 0)  {  
    	res.push_back(2);
        n = n/2;  
    }  
    for (ll i = 3; i * i <= n; i = i + 2)  {   
        while (n % i == 0)  {  
            res.push_back(i);
            n = n/i;  
        }  
    }  
    if (n > 2)  
        res.push_back(n);
    return res; 
}  

void testcase() {
	//sieve();
    ll n; cin >> n;
    vector<ll> fac = primeFactors(n);
    sort(fac.begin(), fac.end());
    int m = fac.size();

    int i=0;
    int res = 0;
    while (i < m) {
    	ll cur = fac[i];
    	int ct = 0;
    	while (i < m && cur == fac[i]) {
    		ct++;
    		i++;
    	}
    	int sum = 0, c = 0;
    	while (true) {
    		sum += c; 
    		if (sum  > ct) {
    			c--;
    			break;
    		}
    		c++;
    	}
    	res += c;
    }
    cout << res;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {

	uint N;
	ull W;
	cin >> N >> W;

	vector<pair<uint, uint>> wv(N);
	for(uint i=0; i<N; i++) {
		uint w, v;
		cin >> w >> v;
		wv[i] = make_pair(w, v);
	}

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

	vector<vector<ull>> dp(W+1, vector<ull>(N+1, 0));

	for(ull j=1; j<=W; j++) {
			for(uint i=1; i<=N; i++) {
				uint wi = wv[i-1].first;
				uint vi = wv[i-1].second;
				if(j >= wi) {
					dp[j][i] = max(dp[j-wi][i-1] + vi, dp[j][i-1]);
				} else {
					dp[j][i] = dp[j][i-1];
				}
		}
	}

	ull ans = *max_element(dp[W].begin(), dp[W].end());
	cout << ans;

	return 0;
}


Measured memory_bytes: 82304