akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main() {
    int A, B, H, M;
    std::cin >> A >> B >> H >> M;

    double h = 30.0 * H + 30.0 * M / 60.0;
    double m = M / 60.0 * 360;

    double ans = std::sqrt(A * A + B * B - 2 * A * B * std::cos((h - m) * (M_PI / 180.0)));
    std::printf("%.10lf\n", ans);

    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = A + B + C;
  ans = ans - max({A, B, C}) + max({A, B, C}) * pow(2, K);
  cout << ans << endl;
  return 0;
}

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

int main() {
    int i,j,k,N,M;
    vector<vector<int> > matrix;
    cin >> N >> M;
    matrix.resize(N+2);
    for( i=0; i<N+2; i++ ){
        matrix[i].resize(M+2);
    }
    for (i=1;i<N+1;i++) {
        for (j=1;j<M+1;j++) {
            char c;
            cin >> c;
            if (c == '#') {
                matrix[i][j] = 1;
            }
        }
    }
    for (j=1;j<N+1;j++) {
        for (k=1;k<M+1;k++) {
            if (matrix[j][k] == 1) {
                if (matrix[j][k-1] == 0 && matrix[j][k+1] == 0 && matrix[j-1][k] == 0 && matrix[j+1][k] == 0) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[101][101],d[101],f[101],visited[101],n,time;

void dfs(int r){
	int i;
	if(visited[r]!=0)
		return ;
	d[r]=++time;
		visited[r]=1;

	for(i=1;i<=n;i++){
		if(A[r][i]==1)
			dfs(i);
	}
	f[r]=++time;
}

int main(){
	int i,j,u,k,v;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			A[u][v]=1;
		}
	}
	for(i=1;i<=n;i++)
		dfs(i);
	for(i=1;i<=n;i++)
		printf("%d %d %d\n",i,d[i],f[i]);
	return 0;
}


Measured memory_bytes: 2112
#include <cstdio>

int t[6];

int main(){
	for(int u = 0; u < 3; u++){
		int a = 0;
		for(int i = 0; i < 6; i++) scanf("%d", &t[i]);
		a = 3600*(t[3]-t[0])+60*(t[4]-t[1])+t[5]-t[2];
		printf("%d %d %d\n", a/3600, (a%3600)/60, a%60);
	}
}

Measured memory_bytes: 1028
N, K = [int(n) for n in input().split()]
D = set([int(n) for n in input().split()])

def digits(n):
  res = set()
  while n > 0:
    res = res.union(set([n%10]))
    n //= 10
  return res

for price in range(N, 10000000000000000):
  if digits(price).isdisjoint(D):
    print(price)
    break

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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
int n,m;
int a[1005];
int b[1005];
int cnt[1000005][2];
int main() {
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]][0]++;
  }
  for(int i = 0; i < m; i++) {
    cin >> b[i];
    cnt[b[i]][1]++;
  }
  sort(a,a+n,greater<int> ());
  sort(b,b+m,greater<int> ());
  ll cnti = 0,cntj = 0;
  ll ans = 1;

  for(int i = n * m; i > 0; i--) {
    if(cnt[i][0] == 1 && cnt[i][1] == 1) {
      cnti++;
      cntj++;
    }
    else if(cnt[i][0] == 1 && cnt[i][1] == 0) {
      ans = ans * cntj % mod;
      cnti++;
    }
    else if(cnt[i][0] == 0 && cnt[i][1] == 1) {
      ans = ans * cnti % mod;
      cntj++;
    }
    else if(cnt[i][0] == 0 && cnt[i][1] == 0) {
      ans = ans * (cnti * cntj - (n*m-i)) % mod;
    }
    else {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << ans << endl;
}


  
  
  


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
#define bin(x)     (bitset<3>(x))
using namespace std;
using ll = long long;

vector<int> solve(int n,int a,int b) {
	if (__builtin_parity(a)==__builtin_parity(b)) return {};

	if (n==1) return {a,b};

	int bit=1<<(n-1);
	if ((bit&a)!=(bit&b)) {
		auto p=solve(n-1,a,a^1);
		auto q=solve(n-1,a^1^bit,b);
		p.insert(p.end(),q.begin(),q.end());
		return p;
	} else {
		auto p=solve(n-1,a,b);
		auto q=solve(n-1,a^bit,p[1]^bit);
		p.insert(p.begin()+1,q.begin(),q.end());
		return p;
	}
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,A,B;
	cin>>N>>A>>B;
	auto res=solve(N,A,B);
	if (res.empty()) {
		cout<<"NO\n";
	} else {
		cout<<"YES\n";
		for (int x:res) cout<<x<<" ";
		cout<<"\n";
	}
}


Measured memory_bytes: 1648
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

alias MaxHeap = BinaryHeap!(Array!int, "a < b");

int calc(int m, int[][] a) {
    a.sort!((a, b) => a[0] > b[0]);
    int p = cast(int)a.length - 1;

    int ans = 0;
    auto pq = new MaxHeap;
    for (int i = m-1; i >= 0; i--) {

        while (p >= 0 && a[p][0] + i <= m) {
            pq.insert(a[p][1]);
            p--;
        }

        if (pq.length > 0) {
            ans += pq.front;
            pq.popFront();
        }
    }

    return ans;
}

void main() {
    int n, m; scan(n, m);
    int[][] a;
    foreach (_; 0..n) a ~= readints;

    writeln(calc(m, a));
}


Measured memory_bytes: 15452
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
using namespace std;

struct fastio {
	char s[100000];
	int it, len;
	fastio(): it(0), len(0) {}
	char get() {
		if (it >= len)
			len = fread(s, 1, 100000, stdin), it = 0;
		return s[it++];
	}
} _buff;

struct node {
	int val;
	char id;
	node *fa, *son[26];
} tr[1000010], *root, *tl[200010];

int n, idx;
char s[1000000], vis[26];
int readint();

int main() {
	root = &tr[idx++];
	n = readint();
	for (int i = 0; i < n; ++i) {
		s[0] = _buff.get();
		while (!isalpha(s[0]))
			s[0] = _buff.get();
		int len;
		for (len = 0; isalpha(s[len]); ++len)
			s[len + 1] = _buff.get();
		s[len] = '\0';
		node *p = root;
		for (int j = len - 1; j >= 0; --j) {
			if (p->son[s[j] - 'a'] == NULL)
				tr[idx].fa = p, tr[idx].id = s[j] - 'a',
					p->son[s[j] - 'a'] = &tr[idx++];
			p = p->son[s[j] - 'a'];
		}
		++p->val;
		tl[i] = p;
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		memset(vis, 0, sizeof(vis));
		for (node *p = tl[i]; p != root; p = p->fa) {
			vis[p->id] = 1;
			for (int j = 0; j < 26; ++j)
				if (vis[j] && p->fa->son[j] != NULL)
					ans += p->fa->son[j]->val;
		}
		--ans;
	}
	printf("%lld\n", ans);
	return 0;
}

int readint() {
	int ret = 0;
	char c = _buff.get();
	while (!isdigit(c))
		c = _buff.get();
	while (isdigit(c)) {
		ret = ret * 10 + c - '0';
		c = _buff.get();
	}
	return ret;
}



Measured memory_bytes: 222144
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    a' = max (a - k) 0
    b' = max (b - max (k - a) 0) 0
  putStrLn $ show a' ++ " " ++ show b'

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

int main() {
	int num = 10000;
	int x[10000] = {0};
	int i;

	for (i = 0; i < 10000; i++)
	{
		cin >> x[i];

		if (x[i] == 0)
			break;
	}
		
	for (int a = 1; a <= i; a++)
		cout << "Case " << a << ": " << x[a-1]<<endl;

	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = 0,y = 0;
	while (c > 0) {
		c -= b;
		x++;
	}
	while (a > 0) {
		a -= d;
		y++;
	}
	if (x <= y) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,count=0,pos=1;

  cin >> N;

  vector<int> to(N);
  vector<bool> flag(N);
  
  for (int i=0; i<N; i++){
    cin >> to.at(i);
    flag.at(i) = false;
  }
  

  while(1){
    
    flag.at(pos-1) = true;
    pos = to.at(pos-1);
    count++;
    
    if(pos==2){
      cout << count << endl;
      break;
    }else if(flag.at(pos-1)==true){
      cout << -1 << endl;
      break;
    }
    
  }

}

Measured memory_bytes: 1148
#include<iostream>
using std::cout; using std::endl;
int main()
{
	for (int x = 1; x <= 9; x++)
	{
		for (int y = 1; y <= 9; y++)
		{
			cout << x <<"x"<< y << "="<<x*y <<endl;
		}
	}
	return 0;
	
}

Measured memory_bytes: 1116
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n, i, j, sz, d[30], c[30];
char a[55];
string ans;
int main()
{
	cin >> n;
	for (i = 0; i < 26; i++) d[i] = 2e9;
	while (n--) {
		scanf ("%s", a);
		sz = strlen(a);
		memset(c, 0, sizeof(c));
		for (i = 0; i < sz; i++) {
			c[a[i] - 'a']++;
		}
		for (i = 0; i < 26; i++) {
			d[i] = min(d[i], c[i]);
		}
	}
	for (i = 0; i < 26; i++) {
		for (j =0 ; j < d[i]; j++) ans += (char)(i + 'a');
	}
	cout << ans;
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    string st;
    cin >> st;
    st[k - 1] = tolower(st[k - 1]);
    cout << st << endl;
    return 0;
}

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

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

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

    int n,m,ans=0; cin>>n>>m; int nu[n];
    UnionFind mo(n);
    for (int i = 0; i < n; i++)cin>>nu[i];
    for (int i = 0; i < m; i++){
        int a,b; cin>>a>>b; mo.unite(a-1,b-1);
    }
    for (int i = 0; i < n; i++)ans+=(mo.find(i)==mo.find(nu[i]-1));
    cout<<ans<<'\n';
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int sum = 0;
        int[] arr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int n = arr[0];
        int k = arr[1];
        int[] arr1 = new int[n];
        arr1 = arr1.Select(a => a = 1).ToArray();
        for(int i = 0; i < k; i++)
        {
            Console.ReadLine();
            int[] sunukeArr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            foreach(int sunuke in sunukeArr)
            {
                arr1[sunuke - 1]--;
            }
        }
        foreach(int value in arr1)
        {
            sum += (value == 1) ? 1 : 0;
        }
        Console.WriteLine(sum);
    }



}



Measured memory_bytes: 19396
while True:
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        break
    for i in range(a):
        for j in range(b):
            if j == 0 or j == b-1 or i == 0 or i == a-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007
#define moda 1000003


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W, X;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
bool f, ff,fff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[2];
vector <string> vs;
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;

bitset<5000> bits;

int main() {

	cin >> S;
	
	for (int i = 0; i< S.size(); i++) {
		if (S[i] == 'N') {
			A[0]++;
		}
		if (S[i] == 'S') {
			A[1]++;
		}
		if (S[i] == 'E') {
			A[2]++;
		}
		if (S[i] == 'W') {
			A[3]++;
		}
	}

	f = true;

	if (A[0] > 0 || A[1] > 0) {
		if (A[0] > 0 && A[1] > 0) {
		
		}
		else {
			f = false;
		}
	}

	if (A[2] > 0 || A[3] > 0) {
		if (A[2] > 0 && A[3] > 0) {

		}
		else {
			f = false;
		}
	}
	
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int a[200005],b[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	scanf("%d",&a[i]);
	for (int i=0;i<n;i++)
	scanf("%d",&b[i]);
	int l=n-1;
	long long ans=0;
	for (int i=0;;i=(i+1)%n)
	{
		bool ch=0;
		int x=b[(i-1+n)%n],y=b[i],z=b[(i+1)%n];
		if (y>x+z && y!=a[i])
		{
			b[i]%=(x+z);
			if (b[i]<a[i])
			{
				if ((a[i]-b[i])%(x+z))
				{
					printf("-1");
					return 0;
				}
				b[i]=a[i];
			}
			ans+=(y-b[i])/(x+z);
			l=i;
			ch=1;
		}
		if (l==i && !ch)
		break;
	}
	for (int i=0;i<n;i++)
	{
		if (a[i]!=b[i])
		{
			printf("-1");
			return 0;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5388
#include <iostream>
using namespace std;
int a, b, c, x, y;
int main(){
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    if(2*c <= a){
        ans += 2 * c * x;
        y = max(0, y - x);
        x = 0;
    }
    if(2*c <= b){
        ans += 2 * c * y;
        x = max(0, x - y);
        y = 0;
    }
    if(2*c <= a + b){
        int t = min(x, y);
        x -= t;
        y -= t;
        ans += 2 * c * t; 
    }
    ans += a * x;
    ans += b * y;
    cout << ans;
}

Measured memory_bytes: 256
N = int(input())
cards = {}
for n in range(N):
    s = input()
    if s in cards:
        cards[s] += 1
    else:
        cards[s] = 1

M = int(input())
for m in range(M):
    s = input()
    if s in cards and cards[s] > 0:
        cards[s] -= 1
    else:
        cards[s] = 0

sorted_cards = list(reversed(sorted(cards.items(), key=lambda x:x[1])))
print(sorted_cards[0][1])



Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef unsigned long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
  int N,M,A[11000];
  cin>>N>>M;
  int need[10]={0,2,5,5,4,5,6,3,7,6};

  for(int i=0;i<M;i++) cin>>A[i];

  sort(A,A+M,greater<int>());
  for(int i=1;i<N;i++) dp[i]=-1000;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      dp[i+need[A[j]]]=max(dp[i+need[A[j]]],dp[i]+1);
    }
  }
  int now=N;
  for(int i=0;i<dp[N]-1;i++){
    //cout<<i<<endl;
    for(int j=0;j<M;j++){
      if(now-need[A[j]]<0) continue;
      if(dp[now-need[A[j]]]==dp[now]-1){
        //cout<<"unko"<<endl;
        now-=need[A[j]];
        cout<<A[j];
        //cout<<now<<endl;
        break;
      }
    }
  }
  for(int i=0;i<M;i++){
    if(now==need[A[i]]){
      //cout<<now<<endl;
      cout<<A[i]<<endl;
      return 0;
    } 
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  LLI N, A, B;
  while(cin >> N >> A >> B){
    LLI ans;

    if(A > B) swap(A, B);
    
    if((A-B) % 2 == 0){
      ans = abs(A-B) / 2;
    }else{
      ans = min(A + abs(B-A-1) / 2,
                (N-B+1) + abs(A+(N-B+1)-N) / 2
                );
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int a, b, c, d, l, r;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  l = a+b;
  r = c+d;
  if (l > r) printf("Left\n");
  else if (l < r) printf("Right\n");
  else printf("Balanced\n");
  return 0;
}

Measured memory_bytes: 128
# LongestCommonSubsequences
import numpy as np
S = np.array([ord(i)-97 for i in input()], dtype=int)
T = np.array([ord(i)-97 for i in input()], dtype=int)
Ns = len(S)
Nt = len(T)
equal = np.equal.outer(S, T).astype(int)

dp = [np.zeros(Nt + 1, dtype=int)]
for i in range(Ns):
    x = dp[-1].copy()
    newDP = x.copy()
    newDP[1:] = np.maximum(x[:-1] + equal[i], newDP[1:])
    np.maximum.accumulate(newDP, out=newDP)
    dp.append(newDP)


ans = ""
i, j = Ns, Nt
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans += chr(S[i-1]+97)
        i -= 1
        j -= 1
        continue
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1

print(ans[::-1])


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

int main(){
  int n,a,b,c,x;
  while(cin >> n >> a >> b >> c >> x, c){
    int pic[n+1];
    for(int i=0; i<n; ++i){
      cin >> pic[i];
    }
    int cnt = 0;
    int ans = 0;
    for(; ans<=10000; ++ans){
      if(x==pic[cnt]){
        ++cnt;
        if(cnt==n){
          break;
        }
      }
      x = (a*x+b)%c;
    }
    if(ans>10000){
      cout << -1 << endl;
    }else{
      cout << ans << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3100
N = gets.to_i
a = gets.split.map(&:to_i)

def gcd(a, b)
  if b == 0
    return a
  end

  gcd(b, a % b)
end

def lcm(a, b)
  a * b / gcd(a, b)
end

l = lcm(1, a[0])

(1...a.size).each do |i|
  l = lcm(l, a[i])
end

def f(a, ad)
  sum = 0
  a.each do |aa|
    sum += ad % aa
  end
  sum
end

puts f(a, l - 1)

Measured memory_bytes: 11724
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }
#define errOutSeparator(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << "======" << std::endl; }

#include <bits/stdc++.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;
using range_t = struct {
  int64_t l;
  int64_t r;
};
std::ostream& operator<<(std::ostream& os, const range_t& r) {
  os << "Range L:" << r.l << " R:" << r.r << ";";
  return os;
}

static constexpr int64_t MaxN = 200000;
static constexpr int64_t MaxK = 10;
static constexpr int64_t MOD = 998244353;
static std::vector<range_t> rgs;
static std::array<int64_t, MaxN> diffs;
static std::array<int64_t, MaxN> values;
static int64_t n;

int64_t solve(void) {
  std::sort(rgs.begin(), rgs.end(),
            [](auto const& lhv, auto const& rhv) { return lhv.l < rhv.l; });
  values[0] = 1;
  diffs[0] = 1;
  diffs[1] = -1;
  for (auto i = 0; i < n; i++) {
    if (i > 0) {
      values[i] = values[i - 1] + diffs[i];
      values[i] %= MOD;
    }
    for (auto const& rg : rgs) {
      if (i + rg.l >= n) {
        break;
      }
      diffs[i + rg.l] += values[i];
      diffs[i + rg.l] %= MOD;
      if (i + rg.r + 1 >= n) {
        break;
      }
      diffs[i + rg.r + 1] -= values[i];
      if (diffs[i + rg.r + 1] < 0) {
        diffs[i + rg.r + 1] += MOD;
      } else {
        diffs[i + rg.r + 1] %= MOD;
      }
    }
  }
  return values[n - 1];
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n;
  int64_t k;
  std::cin >> k;
  rgs.resize(k);
  for (int i = 0; i < k; i++) {
    std::cin >> rgs[i].l;
    std::cin >> rgs[i].r;
  }
  auto const res = solve();
  std::cout << res << std::endl;
  return 0;
}


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

using namespace std;

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

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(NULL);
	
	int n, l;
	int sum = 0, ans = INT_MAX, d = INT_MAX;
	
	cin >> n >> l;
	
	REP1(i, n){
		sum += l + i - 1;
	}
	
	REP1(i, n){
		int t = sum - (l + i - 1);
	
		if(abs(sum - t) < d){
			ans = t;
			d = abs(sum - t);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int sum=0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            sum++;
        }
    }
    cout<<sum<<endl;
}


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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int N,A,B,C;
vector<int> l;

int rec(int dep,int a,int b,int c){
    if(dep>=N){
        if(a==0||b==0||c==0)return INT_MAX-10;
        return abs(a-A)+abs(b-B)+abs(c-C);//収縮分のコストを返す。
    }
    //depの竹をABCnotUseに振り分ける
    int mcost=rec(dep+1,a+l[dep],b,c)+(a>0 ? 10:0);//継ぎ足しなら+10MP
    chmin(mcost, rec(dep+1,a,b+l[dep],c) + (b>0 ? 10:0));
    chmin(mcost, rec(dep+1,a,b,c+l[dep]) + (c>0 ? 10:0));
    chmin(mcost, rec(dep+1,a,b,c));
    return mcost;
}


int main() {
    cin >>N>>A>>B>>C;
    l.resize(N);
    rep(i,N) cin >> l[i];
    
    //-----------------------------------
    //各々の竹をA,B,C,notUseに振り分ける4^n全列挙
    //一番近い竹を伸び縮み
    int ans=rec(0,0,0,0);

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a / b << ' ' << a % b << ' ';
    cout << fixed << setprecision(15) << static_cast<double>(a) / static_cast<double>(b) << endl;
    return 0;
}


Measured memory_bytes: 3284
#include<stdio.h>

class Dice {
public:
  void scan();
  int up();
  int front();
  int right();
  int left();
  int back();
  int down();
  void up(int x);
  void front(int x);
  void right(int x);
  void left(int x);
  void back(int x);
  void down(int x);
  void go(char dir);
private:
  int face[6];
};

int main(void)
{
  char dir;
  Dice dice;
  
  dice.scan();

  while ( (dir=getchar()) != EOF) {
    dice.go(dir);
  }

  printf("%d\n", dice.up());
  return 0;
}


void Dice::scan() {
  for ( int i=0; i<6; ++i)
    scanf("%d", &this->face[i]);
  getchar();
}
int Dice::up()    { return this->face[0];}
int Dice::front() { return this->face[1];}
int Dice::right() { return this->face[2];}
int Dice::left()  { return this->face[3];}
int Dice::back()  { return this->face[4];}
int Dice::down()  { return this->face[5];}
void Dice::up(int x)    { this->face[0] = x;}
void Dice::front(int x) { this->face[1] = x;}
void Dice::right(int x) { this->face[2] = x;}
void Dice::left(int x)  { this->face[3] = x;}
void Dice::back(int x)  { this->face[4] = x;}
void Dice::down(int x)  { this->face[5] = x;}
void Dice::go(char dir) {
  int tmp;
  switch (dir) {
  case 'E':
    tmp = this->up();
    this->up(this->left());
    this->left(this->down());
    this->down(this->right());
    this->right(tmp);
    break;
  case 'N':
    tmp = this->up();
    this->up(this->front());
    this->front(this->down());
    this->down(this->back());
    this->back(tmp);
    break;
  case 'S':
    tmp = this->up();
    this->up(this->back());
    this->back(this->down());
    this->down(this->front());
    this->front(tmp);
    break;
  case 'W':
    tmp = this->up();
    this->up(this->right());
    this->right(this->down());
    this->down(this->left());
    this->left(tmp);
    break;
  }
}



Measured memory_bytes: 2716
MOD = 10 ** 9 + 7
MAXN = 100005
factorial = [1]
for i in range(1, MAXN + 1):
    factorial.append(factorial[-1] * i % MOD)

inv_factorial = [-1] * (MAXN + 1)
inv_factorial[-1] = pow(factorial[-1], MOD-2, MOD)
for i in reversed(range(MAXN)):
    inv_factorial[i] = inv_factorial[i + 1] * (i + 1) % MOD

def fact(n):
    return factorial[n]

def nck(n, k):
    if k > n or k < 0:
        return 0
    else:
        return factorial[n]*inv_factorial[n - k]*inv_factorial[k]%MOD

def main():
    n = int(input())
    a = list(map(int,input().split()))
    dic = {i:[] for i in range(1,n + 1)}
    for i in range(n + 1):
        dic[a[i]].append(i)
        if len(dic[a[i]]) >= 2:
            l,r = dic[a[i]][0],dic[a[i]][1]
            break

    r = n - r
    print(n)
    for i in range(2,n + 2):
        print((nck(n + 1,i) - nck(l + r,i - 1) + MOD)%MOD)
if __name__ == '__main__':
    main()

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i, N) {
        ll temp;
        cin >> temp;
        if(temp % 2 && (i + 1) % 2) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (a[0] * a[1] < a[2]) { Console.WriteLine("No");return; }
            if (a[2] == 0) { Console.WriteLine("Yes");return; }
         for (int i = 0; i <= a[0]; i++)
        {
            for(int j = 0; j <= a[1]; j++)
            {
                if (i * a[1] + j * a[0] - i * j *2== a[2])
                {
                    Console.WriteLine("Yes");return;
                }
            }
        }Console.WriteLine("No");Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	string s; cin >> s;

	vector<int> rs(n);
	vector<int> gs(n);
	vector<int> bs(n);

	{
		int rc = 0;
		int gc = 0;
		int bc = 0;
		FOR_DW(i, n - 1, 0) {
			if (s[i] == 'R') rc++;
			if (s[i] == 'G') gc++;
			if (s[i] == 'B') bc++;

			rs[i] = rc;
			gs[i] = gc;
			bs[i] = bc;
		}
	}

	int64_t ans = 0;
	FOR_LT(i, 0, n) {
		FOR_LT(j, i + 1, n - 1) {
			if (s[i] == s[j]) continue;

			bool ss[256] = {};
			ss[s[i]] = true;
			ss[s[j]] = true;

			char r = ' ';
			if (!ss['R']) {
				r = 'R';
			}
			if (!ss['G']) {
				r = 'G';
			}
			if (!ss['B']) {
				r = 'B';
			}

			vector<int>& rems = (r == 'R' ? rs : r == 'G' ? gs : bs);
			ans += rems[j + 1];
			int k = j + (j - i);
			if (k < n && s[k] == r) ans--;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

enum {TOP=0,FRONT,RIGHT,LEFT,BACK,BOTTOM};
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rotate_swap(x,a,b,c,d) swap(x.m[a],x.m[b]);swap(x.m[b],x.m[c]);swap(x.m[c],x.m[d]);

class Dice{
public:
  int m[6];
  bool operator<(const Dice &a)const{
    rep(i,6)if(m[i]!=a.m[i])return m[i]<a.m[i];
    return false;
  }  
};

void rotate_r(Dice &x){
  rotate_swap(x,TOP,LEFT,BOTTOM,RIGHT);
}
void rotate_f(Dice &x){
  rotate_swap(x,TOP,BACK,BOTTOM,FRONT);
}
void rotate_cw(Dice &x){
  rotate_swap(x,BACK,LEFT,FRONT,RIGHT);
}

Dice ds[4];
Dice data[4][24];

void generate_all( int id, Dice x ){
  rep(i,6){
    rep(j,4){
      data[id][i*4+j]=x;
      rotate_cw(x);
    }
    
    if(i%2==0)rotate_r(x);
    else rotate_f(x);
  }
}


int main()
{
  int n;
  while(cin>>n&&n){
    int id = 0;
    map<string,int> D;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j <  6; ++j){
        string color;
        cin >> color;
        if( D.find(color) == D.end() ){
          D[color] = id++;
        }
        ds[i].m[j] = D[color];
        //cout << ds[i].m[j] << ' ';
      }
      //cout << endl;
      generate_all(i,ds[i]);
    }
    //cout <<"input end" << endl;

    int res = 1000;
    map<int,int> M;
    for(int a = 0; a < 24; ++a){
      for(int b = 0; b < (n>=2?24:1); ++b){
        for(int c = 0; c < (n>=3?24:1); ++c){
          for(int d = 0; d < (n>=4?24:1); ++d){
            int cost = 0;
            for(int k = 0; k < 6; ++k){
              int cs[24]={0,};
              int sz = 0;
              if(n>=1)
                cs[data[0][a].m[k]]++;
              if(n>=2)
                cs[data[1][b].m[k]]++;
              if(n>=3)
                cs[data[2][c].m[k]]++;
              if(n>=4)
                cs[data[3][d].m[k]]++;

              for(int l = 0; l < 24; ++l)sz+=cs[l]!=0?1:0;
              
              if( sz == 4 ){
                cost += 3;
              }else if( sz == 3 ){
                cost += 2;
              }else if( sz == 2 ){
                if( n == 2 ){
                  cost += 1;
                }else{
                  for(int l = 0; l < 24; ++l){
                    if( cs[l] != 0 ){
                      if( (n==4 && (cs[l] == 3||cs[l]==1) ) || n == 3 ){
                        cost += 1; break;
                      }else if( n == 4 && cs[l] == 2 ){
                        cost += 2; break;
                      }
                    }
                  }
                }
              }
              else if( sz == 1 ) continue;
              if( cost >= res ) break;
            }
            //cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << cost << endl;
            res = min( res, cost );
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    a, b, k = rli()
    if a >= k:
        print(a-k, b)
    elif a+b >= k:
        print(0, a+b-k)
    else:
        print(0, 0)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] a = in.nextIntArray(3);
            Arrays.sort(a);
            out.println(a[2] - a[0]);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}



Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,q,a,t,x;
    cin >> n >> q;
    std::queue<int> hoge[n];
    for (int i=0;i<q;i++) {
        cin >> a >> t;
        if ( a==0 ) {
            cin >> x;
            hoge[t].push(x);
        } else if ( a==1 ) {
            if ( hoge[t].empty()!=true ) {
                cout << hoge[t].front() << endl;
            }
        } else if ( a==2 ) {
            if ( hoge[t].empty()!=true ) {
                hoge[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4260
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct Edge{
    ll from,to,cost;
};
const ll INF = INT64_MAX>>3;
int main(){
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<Edge> Edges(m);
    rep(i,m) {
        cin >> Edges[i].from >> Edges[i].to >> Edges[i].cost;
        Edges[i].to--;Edges[i].from--;
    }

    vector<ll> tot(n,-INF);
    tot[0] = 0;
    rep(i,n) {
        bool end = true;
        for(auto e: Edges) {
            if(tot[e.from] != -INF && tot[e.from] + e.cost > tot[e.to]) {
                tot[e.to] = tot[e.from] + e.cost;
                end = false;
                if (i==n-1&&e.to==n-1) {
					cout << "inf" << endl;
					return 0;
				}
            }
        }
        if(end) break;
    }
    cout << tot[n-1] << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> X(N);
    for(int i=0; i<N; ++i) cin >> X[i];

    int res = 1001001001;
    for(int x=1; x<=100; ++x) {
        int tmp = 0;
        for(int i=0; i<N; ++i) tmp += (x - X[i]) * (x - X[i]);
        res = min(res, tmp);
    }
    cout << res << endl;
}

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

int G[100][100];
bool vis[100];

void dfs(int v){
    vis[v]=1;
    REP(u,100){
        if(G[v][u] and !vis[u]) dfs(u);
    }
}

signed main()
{   
    int N,M; cin>>N>>M;
    vint a(M),b(M);
    REP(i,M){
        cin>>a[i]>>b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]]=1;
        G[b[i]][a[i]]=1;
    }

    int ans=0;
    REP(i,M){
        G[a[i]][b[i]]=G[b[i]][a[i]]=0;
        REP(j,N) vis[j]=0;
        dfs(0);
        REP(j,N){
            if(!vis[j]){
                ans++;
                break;
            }
        }
        G[a[i]][b[i]]=G[b[i]][a[i]]=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

void inlld(ll &a){scanf("%lld", &a);}
void ind(int &a){scanf("%d", &a);}

int m, d;

int main()
{
	ind(m);
	ind(d);
	int ans=0;
	for(int a=2; a<=9; a++)
		for(int b=2; b<=9; b++)
		{
			int here=10*a+b;
			if(here>d)
				continue;
			if(a*b<=m)
				ans++;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define SIZE 100

int main() {
	int A[SIZE][SIZE];
	int n, i, j, row, col, cols;

	for (i = 0; i < SIZE; i++) {
		for (j = 0; j < SIZE; j++) {
			A[i][j] = 0;
		}
	}

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &row); row--;
		scanf("%d", &cols);
		for (j = 0; j < cols; j++) {
			scanf("%d", &col);
			A[row][--col] = 1;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			printf("%d", A[i][j]);
			if (j < n - 1) printf(" ");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2020
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n;
int main(){
	in(n);
    bool flag=0;
    while(n--){
        int x;
        in(x);
        if(x%2==0&&!(x%3==0||x%5==0)){
            flag=1;
            break;
        }
    }
    if(flag==0)puts("APPROVED");
    else puts("DENIED");
	return 0;
}


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

int main(){
  int n;
  scanf("%d",&n);
  int *ar;
  ar=malloc(sizeof(int)*n);
  for(int i=0;i<n;i++){
    scanf("%d",&ar[i]);}
  int sum=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum+=ar[i]*ar[j];}}
  printf("%d\n",sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  if (S == "SSS") cout << 0 << endl;
  if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") cout << 1 << endl;
  if (S == "SRR" || S == "RRS") cout << 2 << endl;
  if (S == "RRR") cout << 3 << endl;
}

Measured memory_bytes: 3624
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os; }
template<class T> istream& operator>>(istream& is, vector<T>& v) { for (auto i = begin(v); i != end(v); i++) is >> *i; return is; }
struct fast_io {
	fast_io& operator>> (int& target) { scanf("%" PRId32, &target);  return *this; }
	fast_io& operator>> (unsigned int& target) { scanf("%" PRIu32, &target);  return *this; }
	fast_io& operator>> (long long& target) { scanf("%" PRId64, &target);  return *this; }
	fast_io& operator>> (unsigned long long& target) { scanf("%" PRIu64, &target);  return *this; }
	template<typename T> fast_io& operator>> (vector<T>& target) { for (auto& value : target) { *this >> value; } return *this; }
	fast_io& operator<< (const int value) { printf("%" PRId32, value); return *this; }
	fast_io& operator<< (const unsigned int value) { printf("%" PRIu32, value); return *this; }
	fast_io& operator<< (const long long value) { printf("%" PRId64, value); return *this; }
	fast_io& operator<< (const unsigned long long value) { printf("%" PRIu64, value); return *this; }
	fast_io& operator<< (const string& value) { printf("%s", value.c_str()); return *this; }
	template<typename T> fast_io& operator<< (const vector<T>& target) { for (auto& value : target) { *this << value << " "; } return *this; }
}; fast_io fio;

template<class ForwardIt, class UnaryPredicate>
ForwardIt first_true(ForwardIt first, ForwardIt last, UnaryPredicate predicate) {
	ForwardIt it;
	typename std::iterator_traits<ForwardIt>::difference_type count, step; count = std::distance(first, last);
	while (count > 0) {
		it = first;	step = count / 2;
		std::advance(it, step);
		if (!predicate(*it)) { first = ++it; count -= step + 1; }
		else count = step;
	}
	return first;
}

#define MOD 1000000007
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())



int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string str;
	cin >> str;
	cout << str.substr(0, 3);

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long int
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,j,b) for(ll s = j;s < b;s++)
#define forllde(s,j) for(ll s = j;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n, ans = 0;
	string s;
	bool flag = false;

	cin >> n;

	ans = 1000 - (n % 1000);

	if (ans == 1000)
		ans = 0;

	cout << ans;
}


Measured memory_bytes: 3624
import collections
def prime_factor(n):
    factors = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            factors.append(i)
            n = n//i
    if n!=1:
        factors.append(n)
    return factors

N,P = map(int,input().split())
li = prime_factor(P)
c = collections.Counter(li)
ans = 1
for k,v in c.items():
    if v>=N:
        ans *= k**(v//N)
print(ans)

Measured memory_bytes: 3316