akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {

	int n;
	cin >> n;
	vector<vector<int>> a(3,vector<int>(n+1));
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}

	vector<vector<int>> max_candy(3, vector<int>(n+1));
	
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			max_candy[i][j] = max(max_candy[i - 1][j], max_candy[i][j - 1]) + a[i][j];
		}
	}

	cout << max_candy[2][n] << endl;
}

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

public class Main {

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

		int[] odd = new int[n/2];
		int[] even = new int[n/2];

		for(int i = 0 ; i < n ; i++){
			if(i%2 != 0){
				odd[i/2] = sc.nextInt();
			}
			else{
				even[i/2] = sc.nextInt();
			}
		}

		sc.close();

		int[][] checkodd = new int[100001][2];
		int[][] checkeven = new int[100001][2];

		for(int i = 0 ; i < n/2 ; i++){
			checkodd[odd[i]][0] = odd[i];
			checkodd[odd[i]][1] += 1;
			checkeven[even[i]][0] = even[i];
			checkeven[even[i]][1] += 1;
		}

	    Arrays.sort(checkodd, new Comparator<int[]>() {
	        public int compare(int[] o1, int[] o2) {
	            //return o1[0] - o2[0];    //[0] をキーにソート(昇順)
	            return o2[1] - o1[1];    //[0] をキーにソート(降順)
	        }
	    });
	    Arrays.sort(checkeven, new Comparator<int[]>() {
	        public int compare(int[] o1, int[] o2) {
	            //return o1[0] - o2[0];    //[0] をキーにソート(昇順)
	            return o2[1] - o1[1];    //[0] をキーにソート(降順)
	        }
	    });

/*
		for(int i = 0 ; i < 10 ; i++){
			for(int j = 0 ; j < 2 ; j++){
				System.out.print(checkeven[i][j] +" ");
			}
			System.out.println();
		}
*/


	    int oddmax = checkodd[0][1];
	    int oddp = checkodd[0][0];
	    int oddsecond = checkodd[1][1];
	    int oddpsecond = checkodd[1][0];

	    int evenmax = checkeven[0][1];
	    int evenp = checkeven[0][0];
	    int evensecond = checkeven[1][1];
	    int evenpsecond= checkeven[1][0];

		int ans = 0;

		if(oddmax == n/2 && evenmax == n/2){
			if(oddp == evenp){
				System.out.println(n/2);
			}
			else{
				System.out.println(0);
			}
		}

		else if(oddmax == n/2){
			if(oddp == evenp){
				//System.out.println(1);
				System.out.println((n/2)-evensecond);
			}
			else{
				//System.out.println(2);
				System.out.println((n/2)-evenmax);
			}
		}
		else if(evenmax == n/2){
			if(oddp == evenp){
				//System.out.println(3);
				System.out.println((n/2)-oddsecond);
			}
			else{
				//System.out.println(4);
				System.out.println((n/2)-oddmax);
			}
		}
		else{
			if(oddp == evenp){
				if(evensecond>oddsecond){
					//System.out.println(5);
					System.out.println(n-oddmax-evensecond);
				}
				else{
					//System.out.println(6);
					System.out.println(n-oddsecond-evenmax);
				}
			}
			else{
				//System.out.println(7);
				System.out.println(n-oddmax-evenmax);
			}
		}
	}
}



Measured memory_bytes: 54292
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == b) printf("%d\n", c);
    if(b == c) printf("%d\n", a);
    if(a == c) printf("%d\n", b);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int a[4];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	for (int i=0;i<4;i++) a[i]=read();
	sort(a,a+4);
	if (a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
<?php
 
list($a, $b, $h, $m) = fscanf(STDIN, '%d %d %d %d');

$xa = sin(2*pi()*($h+($m/60))/12.0)*$a;
$ya = cos(2*pi()*($h+($m/60))/12.0)*$a;
$xb = sin(2*pi()*$m/60.0)*$b;
$yb = cos(2*pi()*$m/60.0)*$b;

$l = sqrt(($xa-$xb)*($xa-$xb)+($ya-$yb)*($ya-$yb));
echo $l;


Measured memory_bytes: 16628
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<u64> vec = vector<u64>(100000, 0);

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

    u64 N, K;
    cin >> N >> K;

    u64 a, b;
    rep (i, N)
    {
        cin >> a >> b;
        vec[a - 1] += b;
    }

    int ret = 0;
    u64 sum = 0;
    while (sum < K && ret < 100000)
    {
        sum += vec[ret];
        ++ret;
    }

    cout << ret << "\n";
    return 0;
}



Measured memory_bytes: 1024
fn main() {
    let n: i32 = read();
    let a: i32 = read();
    let ans = n*n - a;
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub 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")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N, D;
  cin >> N >> D;
  i64 cnt = 0;
  rep(i,0, N) {
    i64 x, y;
    cin >> x >> y;
    if(x * x + y * y <= D * D) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

int main(void){
    int n, q, d;
    std::set<int> sset, tset;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &d);
        sset.insert(d);
    }
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%d", &d);
        tset.insert(d);
    }

    std::vector<int> s(sset.begin(), sset.end());
    std::vector<int> t(tset.begin(), tset.end());


    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            if(s[i] == t[j]){
                cnt++;
                //std::cout << s[i] << std::endl;
            }
        }
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;

bool checkfor(ll K) {
	if (K * (K - 1) / 2 != N)return false;
	vector<vector<ll>> ans;
	ans.resize(K);
	for (ll s = 0,n = 1; s < K; s++) {
		for (ll t = s + 1; t < K; t++,n++) {
			ans[s].push_back(n);
			ans[t].push_back(n);
		}
	}
	cout << "Yes" << endl;
	cout << K << endl;
	for (ll k = 0; k < K; k++) {
		cout << ans[k].size() << " ";
		for (ll num : ans[k])cout << num << " ";
		cout << endl;
	}
	return true;
}

int main() {
	cin >> N;
	bool flag = false;
	for (ll k = 1; k <= 1e3; k++) {
		if (checkfor(k)) {
			flag = true;
			break;
		}
	}
	if (!flag)cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#include<bitset>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
        a[i] = v[i];
    }
    sort(v.rbegin(),v.rend());

    for(int i=0;i<n;i++){
if(a[i] == v[0]){
cout << v[1] << endl;
}
else{
cout << v[0] << endl;
}
}
return 0;
}

Measured memory_bytes: 3200
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = k; i <= b; i += k) {
        if(a <= i && i <= b) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG"<< endl;
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    string A,B,result;
    for (int i=0;i<a;i++){
        A += to_string(b);
    }
    for (int i=0;i<b;i++){
        B += to_string(a);
    }
    if (A < B) result = A;
    else result = B;
    cout << result;
}

Measured memory_bytes: 256
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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

int kx[] = {0, -1, +1, -2, +2};
int ky[] = {0, -1, +1, -2, +2};

const int mx = 1e3+123;
char c[mx][mx];
int dist[mx][mx], n, m;

void dijkastra ( int sx, int sy )
{
	for ( int i = 1; i <= n; i++ ) {
		for ( int j = 1; j <= m; j++ ) dist[i][j] = inf;
	}

	priority_queue<pair<int, pair<int,int>>, vector<pair<int, pair<int,int>>>, greater<pair<int, pair<int,int>>>> q;

	q.push ( { 0, { sx, sy } } );
	dist[sx][sy] = 0;


	while ( !q.empty() ) {
		int cost = q.top().F;
		int x = q.top().S.F;
		int y = q.top().S.S;
		q.pop();

		if ( cost > dist[x][y] ) continue;

		for ( int i = 0; i < 4; i++ ) {
			int x1 = x + dx[i];
			int y1 = y + dy[i];

			if ( x1 >= 1 && x1 <= n && y1 >= 1 && y1 <= m && c[x1][y1] != '#' && cost < dist[x1][y1] ) {
				dist[x1][y1] = cost;
				q.push ( { dist[x1][y1], {x1, y1} } );
			}
		}

		for ( int i = 0; i < 5; i++ ) {
			for ( int j = 0; j < 5; j++ ) {
				int x1 = x + kx[i];
				int y1 = y + ky[j];

				if ( x1 >= 1 && x1 <= n && y1 >= 1 && y1 <= m && c[x1][y1] != '#' && cost+1 < dist[x1][y1] ) {
					dist[x1][y1] = cost+1;
					q.push ( { dist[x1][y1], {x1, y1} } );
				}
			}
		}

	}
}

int main()
{
	optimize();

	cin >> n >> m;

	int sx, sy, ex, ey;
	cin >> sx >> sy >> ex >> ey;

	for ( int i = 1; i <= n; i++ ) {
		for ( int j = 1; j <= m; j++ ) {
			cin >> c[i][j];
		}
	}

	dijkastra ( sx, sy );
	if ( dist[ex][ey] == inf ) dist[ex][ey] = -1;
	cout << dist[ex][ey] << endl;


	return 0;
}


















Measured memory_bytes: 9240
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
d=[]
if n==1:
    print(1)
else:
    for i in range(n):
        for j in range(n):
            if i!=j:
                d.append([xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]])
    d.sort()
    res = 1
    tres = 1
    for i in range(len(d)-1):
        if d[i] == d[i+1]:
            tres += 1
        else:
            tres = 1
        res = max(res,tres)
    print(n-res)

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(all(S));
    for (int i = 0; i < N; i++) {
        cout << S[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int a, b; cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		string s1 = s;
		reverse(s.begin(), s.end());
		ans += (s1 == s);
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def bfs(source, target, parent):
    queue = deque()
    queue.appendleft(source)
    visited = [False] * v_num
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if cp and not visited[adj]:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graph_FordFulkerson(source, sink):
    parent = [-1] * v_num
    max_flow = 0

    while bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 != source:
            parent_bk_1 = parent[bk_1]
            assert parent_bk_1 != -1
            path_flow = min(path_flow, adj_table[parent_bk_1][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 != source:
            parent_bk_2 = parent[bk_2]
            assert parent_bk_2 != -1
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    adj_table = tuple(dict() for _ in range(v_num))
    for edge in edges:
        s, t, cp = map(int, edge)
        adj_table[s][t] = cp

    ans = graph_FordFulkerson(source=0, sink=v_num - 1)
    print(ans)

Measured memory_bytes: 8108
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	static int N,dSum_i = 0;
	int Factorial;
	double[][] distance;
	double[] distanceSums;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		distance = new double[N][N];
		Factorial = factorial(N);
		distanceSums = new double [Factorial]; // 8!
		for(int i=0;i<N;i++) {
			x[i] = nextInt();
			y[i] = nextInt();
		}

		double sum = 0;

		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++) {
				distance [i][j] = getDistance(x[i],y[i],x[j],y[j]);
				if(i!=j)sum += distance[i][j];
			}
		}

		out.println(sum/N);

/*


		List<Integer> list = new ArrayList<Integer>(N);
		for(int i=1;i<=N;i++)list.add(i);
		for(int i=0;i<N;i++) {
			boolean[] f = new boolean [N];
			f[i] = true;

			SearchAllRoots(f,0+1,0);
		}
*/


	}

	/*
	Object SearchAllRoots(boolean[] f,int cnt, double sum) {
		if(cnt == N) {
			distanceSums[dSum_i] = sum;
			dSum_i++;
			return 0;
		}
		for(int i=0;i<N;i++) {
			if(f[i] == false) {
				f[i] = true;
				return SearchAllRoots(f, cnt+1, sum);
			}
		}

		return 0;
		//return SearchAllRoots(f, cnt+1, sum);
	}
	*/
	static int factorial(int n){
		  if(n == 0){
		    return 1;
		  }
		  return n * factorial(n-1);
		}
	static double getDistance (double x1, double y1, double x2, double y2) {
		double d = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
		return d;
	}
	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 23764
def extended_euclid(a,b):
	c = g = 1
	e = f = 0
	while b:
		div,mod = divmod(a,b)
		h = c - div * e
		i = f - div * g
		a,b = b,mod
		c,e = e,h
		f,g = g,i

	return (c,f)
n,m = map(int,input().split(" "))
print(*extended_euclid(n,m))




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

long long choose2(long long n){
  return n*(n-1)/2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    a.at(i) -=1;
  }
  vector<long long> cnt(n);
  for(int i=0;i<n;i++){
    cnt.at(a.at(i))++;
  }
  long long total=0;
  for(int i=0;i<n;i++){
    total +=cnt.at(i)*(cnt.at(i)-1)/2;
  }
  for(int i=0;i<n;i++){
    long long ans=total;
    ans -= choose2(cnt.at(a.at(i))) - choose2(cnt.at(a.at(i))-1);
    cout << ans << endl;
  }
}


Measured memory_bytes: 4992
import java.util.Scanner;
public class Main{
	Scanner cin = new Scanner(System.in);
	public void solve(){
		int a = cin.nextInt();
		int b = cin.nextInt();
		int c = cin.nextInt();
		
		for(int i = 0;i <= 60;i++){
			int t = 60 * i + c;
			if(t % (a + b) <= a){
				System.out.println(t);
				return;
			}
		}
		System.out.println(-1);
	}
	public static void main(String[] args){
		new Main().solve();
	}
}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){
    
    int X, Y;
    cin >> X >> Y;
    bool flag = false;
    for(int x = 0; x <= 100; x++){
        for(int y = 0; y <= 100; y++){
            if(2 * x + 4 * y == Y && x + y == X){
                flag = true;
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
const int MAX_E = 100000000;
const int MAX_V = 100000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int X;
bool dp[100011];

void MAIN(int x) {
	
	dp[0] = true;
	rep(i, x)if (dp[i]) {
		rep(t, 6) dp[i + 100 + t] = true;
	}
	cout << dp[x] << endl;

}

int main() {
	cin >> X;
	MAIN(X);
	return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
const Int INF = 1e10;

int main(){
    int N; cin >> N;
    vector<int> A(100010), B(100010), C(100010);
    rep1(i, N) cin >> A[i] >> B[i] >> C[i];

    // dp[i][j]: i日目に活動jをする場合の最大幸福度
    vector<vector<int>> dp(100010, vector<int>(3, 0));

    rep1(i, N){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + A[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + B[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + C[i];
    }

    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl; 
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> d;
  rep(i, n){
    int a;
    cin >> a;
    d[a]++;
  }
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    d[c] += b;
  }
  ll ans = 0;
  int cnt = 0;
  map<int, int>::reverse_iterator it = d.rbegin();
  while(it != d.rend()) {
    ll b = it->second, c = it->first;
    cnt += b;
    ans += ll(b * c);
    if (cnt >= n) {
      ans -= ll(c*(cnt-n));
      cout << ans << endl;
      return 0;
    }
    ++it;
  }

  // while( it != d.rend() ) {
  //   int z = it->first;
  //   ++z;
  //   cout << it->first << " " << z << endl;
  //   it++;
  // }
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,m;

main() {
    cin >> n >> m;
    cout << (m*1900+(n-m)*100)*pow(2,m) << endl;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    string c;
    c=a+b;
    int now=atoi(c.c_str());
    for(int i=1;i<1000;i++){
        if(now==i*i){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

int main() {
	int n;
	llint ans = 10000000000;
	llint sum = 0,abc=0;
	cin >> n;
	hei(llint) a(n);
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	sum -= a[0];
	abc = a[0];
	rep(i, 1, n) {
		ans = min(ans, abs(sum - abc));
		sum -= a[i];
		abc += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S == "AAA")
  {
    cout << "No" << endl;
  }
  else if (S == "BBB")
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3556
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    if (A>B && B!=1) {cout << "Alice" << endl;}
    else if (A<B && A!=1) {cout << "Bob" << endl;}
    else if (A==B) {cout << "Draw" << endl;}
    else if (A>B && B==1) {cout << "Bob" << endl;}
    else {cout << "Alice" << endl;}
    return 0;
}

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

using namespace std;

#define pb push_back
#define pp pop_back
#define ft first
#define sd second


typedef long long ll;
typedef long double ld;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}             
int main () {
	INeedIt();
	string s, a="";
	cin>>s;
	for (int i=0;i<s.size();i++) {
		if (s[i]!='B') a+=s[i];
		if (s[i]=='B' && a.size()!=0) a.erase(a.begin()+a.size()-1);
	}
	cout<<a;
	return 0;
}
 

Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 300 + 10;
const ll INF = 1e18;
const ll LOG = 20;

ll a[N][N], n, v, u, w;

int main(){
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			cin >> a[i][j];
		}
	}
	
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			for (int k = 1; k <= n; k++){
				if (a[i][k] + a[j][k] < a[i][j]) kill(-1);
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		for (int j = i + 1; j <= n; j++){
			bool f = 0;
			for (int k = 1; k <= n; k++){
				if (k == i || k == j) continue;
				if (a[i][j] == a[i][k] + a[k][j]) f = 1;
			}
			if (!f) ans += a[i][j];
		}
	}
	cout << ans;
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
const int MOD=1000000007;
using namespace std;
int vis[200005];
int cc=0;
vector<int>arr[200005];
void dfs(int node)
{
	cc++;
	vis[node]=1;
	for(int child:arr[node])
	{
		if(vis[child]==0)
		dfs(child);
	}
}
int main()
{
	
	int ans=1;
	int n,m;int a,b;
	cin>>n>>m;
	
	while(m--)
	{
		cin>>a>>b;
		arr[a].push_back(b);
		arr[b].push_back(a);
	}
	for(int i=1;i<=n;i++)
	{
		
		if(vis[i]==0)
		{
			cc=0;
			dfs(i);
			ans=max(ans,cc);
		}
	}
	cout<<ans<<"\n";
	
	return 0;
	
}

Measured memory_bytes: 21468
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

bool cmp(pair<int,int> a, pair<int,int> b){
	if(a.second==b.second){ return a.first < b.first; }
    else{ return a.second < b.second; }
}

void Main()
{
	int N;
  	cin >> N;
    vector<pair<int,int>> V(N);
    rep(i,N) cin >> V[i].first >> V[i].second;
    
	sort(V.begin(),V.end(),cmp);
	bool check = true;
    int sumA = 0;
    
    rep(i,N){
    	sumA += V[i].first;
		if(sumA > V[i].second){ //NG
        	check = false;
            break;
        }
    }
    if(check){ puts("Yes"); }
    else { puts("No"); }
	return;
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();

    for(int i = 0; i < n; i++) {
        if(k > 0) {
            if(i < n - 1 && s[i] - 'a' + k >= 26) {
                k -= (26 + 'a' - s[i]) % 26;
                s[i] = 'a';
            } else if(i == n - 1) {
                int code = (k + s[i] - 'a') % 26;
                s[i] = code + 'a';
            }
        }
    }

    cout << s << endl;
    return 0;
}


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

int a,b,c,d;

main(){
  set <int> s;
  cin>>a;
  int ans=1;
  b=7;
  s.insert(b);
  if(b%a==0) {cout<<ans; return 0;}
  if(a%2==0) {cout<<"-1"; return 0;}
  while(b%a!=0){
    
    b=b*10+7;
    ans++;
    b=b%a;
    s.insert(b);
    if(s.size()!=ans) {cout<<"-1";return 0;}
  }
  cout<<ans;}

Measured memory_bytes: 50392
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vstr s(n);
    rep(i, n) cin >> s[i];
    string que;
    que = s[0];
    cout << endl;
    srep(i, n, 1) {
        string n_que;
        for (char sx : s[i]) {
            auto f = find(all(que), sx);
            if (f != que.end()) {
                n_que.push_back(sx);
                int idx = distance(que.begin(), f); 
                que.erase(idx, 1);
            } else {
                continue;
            }
        }
        que = n_que;
    }
    if (que.size() == 0) cout << endl;
    else {
        sort(all(que));
        cout << que << endl;
    }
    return 0;
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
  int i,j,k;
  int A[4];
  char S[5];
  scanf("%s",S);
  for(i=0;i<4;i++)
    A[i] = (int)S[i];
  qsort(A,4,sizeof(int),compare_int);
  if(A[0] == A[1] && A[2] == A[3] && A[1] != A[2])
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 128
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const ll M=998244353;
int n,a[505],s,ans,i,b[505],k;
bool check(int o)
{
	int i,t=s/o,ans=0;
	for(i=1;i<=n;i++)
	{
		t-=a[i]/o;
		b[i]=a[i]%o;
	}
	sort(b+1,b+1+n);
	t=n-t;
	for(i=1;i<=t;i++)
		ans+=b[i];
	return (ans<=k);
}
int main(){
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=a[i];
	}
	for(i=1;i*i<=s;i++)
		if(s%i==0)
		{
			if(check(s/i))
			{
				printf("%d",s/i);
				return 0;
			}
			if(check(i))
				ans=i;
		}
	cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, t, b[55];
	int i, i2, num;
	double money[2], r, y;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		scanf("%lf", &y);
		money[1] = 0;
		
		
		for (i = 0; i < n; i++){
			
			scanf("%d %lf %d", &b[i], &r, &t);
			
			if (t == 1){
				money[0] = 1.0 + y * r / 100.0;
			}
			else{
				money[0] = 1.0 + r / 100.0;
				money[0] = pow(money[0], y);
			}
			if (money[1] < money[0]){
				num = i;
				money[1] = money[0];
			}
		}
		printf("%d\n", b[num]);
	}
	return (0);
}

Measured memory_bytes: 728
nums, weight = map(int,input().split())
ary  = [0 for i in range(nums)]
for i in range(nums):
    ary[i] = list(map(int,input().split()))
dp =[[0 for i in range(weight+1)]for i in range(nums+1)]
 
check = 0
for i in range(nums):
    for x in range(weight+1):
        if x - ary[i][0] >= 0:
            check = dp[i][x -ary[i][0]] + ary[i][1]
            if check > dp[i+1][x]:
                dp[i+1][x] = check
 
        check = dp[i][x]
        if check > dp[i+1][x]:
            dp[i+1][x] = check
 
print(dp[nums][weight])

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

vector<int> dijkstra(int V, int s, vector<vector<edge>> &G) {
  vector<int> d(V,INT_MAX);d[s]=0;
  priority_queue<P,vector<P>,greater<P>> q;q.push({0,s});
  while (!q.empty()) {
    P p = q.top();q.pop();
    int v = p.second;
    if (d[v]<p.first) continue;
    for (edge e:G[v]) {
      if (d[e.to]>d[v]+e.cost) {
        d[e.to] = d[v]+e.cost;
        q.push({d[e.to],e.to});
      }
    }
  }
  return d;
}

int main() {
  int N,M;cin>>N>>M;
  vector<vector<edge>> G(N);
  REP(i,M) {
    int a,b;cin>>a>>b;
    a--;b--;
    G[a].push_back({b,1});
    G[b].push_back({a,1});
  }
  // コスト１として、１からの最短を計算し、目的地までが2ならばposs
  vector<int> ds = dijkstra(N,0,G);
  ds[N-1]==2 ? OUT("POSSIBLE") : OUT("IMPOSSIBLE");

  return 0;
}

Measured memory_bytes: 15720
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            var A = ReadLongArray();
            if (A.Distinct().Count() == A.Length)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 49864
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    int c=1;
    int d=0;
    vector<string> a(n);
    REP(i,n){
      cin>>a[i];
    }
    int m;
    cin>>m;
    vector<string> b(m);
    REP(i,m){
        cin>>b[i];
    }
    REP(i,n){
        for(int j=i+1;j<n;j++){
            if(a[i]==a[j]){
                c++;
            }
        }
        REP(j,m){
            if(a[i]==b[j]){
                c--;
            }
        }
        d=max(d,c);
        c=1;
        }
        cout<<d;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	string* s = new string[n];
	string* p = new string[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	sort(s, s + n);
	p[0] = s[0];
	int k = 0;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[i - 1])
		{
			k++;
			p[k] = s[i];
		}
	}
    int* a = new int[k+1];
	for (int i = 0; i < k + 1; i++)
		a[i] = 1;
	int r = 0;
	for(int i=1;i<n;i++)
		if (s[i] == s[i - 1])
		{
			a[r] += 1;
		}
		else
		{
			r++;
		}
	int max = 0,temp=0;
	for(int i=0;i<=k;i++)
		if(a[i]>max) 
		{
			max = a[i];
			temp = i;
		}
	for (int i = temp; i <= k; i++)
		if (a[i] == max) cout << p[i]<<endl;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < n / 2; i++){
        if(s.at(i) != s.at(i + n / 2)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3600
N, X = map(int, input().split())
a = [1]
p = [1]
for _ in range(N):
  a += [2*a[-1]+3]
  p += [2*p[-1]+1]

def fx(N, X):
  if N == 0:
    if X <= 0:
      return 0
    else:
      return 1
  elif X <= a[N-1]+1:
    return fx(N-1, X-1)
  else:
    return p[N-1]+1+fx(N-1, X-2-a[N-1])


print(fx(N, X))

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnPodr[i];

  int nNode;
  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, vector<StNod> &rvoNod)
{
  int nParnt, nx;
  EnDir enDir;
  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    nParnt = END;
    nx = cnrvnPodr[0];
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx)
{
  static int stnPrt = 0;
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);

  if (stnPrt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  vector<StNod> voNod(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 3176