akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 100000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

vector <int> Vl1;
vector <int> Vl2;
int main() {
	int N, K, i, j;
	scanf("%d %d", &N, &K);

	for (i = 1; i <= N; i++) {
		int t;
		scanf("%d", &t);
		if (t == 0) K--;
		else if (t < 0) Vl2.push_back(-t);
		else Vl1.push_back(t);
	}
	reverse(all(Vl2));

	if (K == 0) return !printf("0\n");

	int ans = INF;
	for (i = 0; i <= Vl2.size() && i <= K; i++) {
		int t = K - i;
		if (t > Vl1.size()) continue;

		if (i == 0) ans = min(ans, Vl1[K-1]);
		else if (t == 0) ans = min(ans, Vl2[K-1]);
		else ans = min(ans, Vl1[t-1] + Vl2[i-1] + min(Vl1[t-1], Vl2[i-1]));
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 1020
from sys import stdin
a,b,c,k = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
if k >= a:
    ans += a
    k -= a
else:
    ans += k
    k = 0
if k >= b:
    k -= b
if k >= 0:
    ans -= k
print(ans)

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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

  char a, b;
  cin >> a >> b;

  if(a == b) cout << "H" << endl;
  else cout << "D" << endl;

  return 0;
}


Measured memory_bytes: 256
-- GCD and LCM
main = getContents >>= putStr . solve

solve :: String -> String
solve = unlines . map (unwords . map show . gcdAndLcm . map read) . map words . lines

gcdAndLcm :: [Int] -> [Int]
gcdAndLcm [a,b] = [gcd a b,lcm a b]

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

void trace(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        cout << A[i];
        ( i == N - 1 ) ? cout << endl : cout << " ";
    }
}

void insertionSort(int A[], int N) {
    int i, j;
    for (i = 1; i < N; i++) {
        int v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main(int argc, char* argv[]) {
    int N, i;
    int A[100];

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

    trace(A, N);
    insertionSort(A, N);

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define PB push_back
#define MP make_pair
#define MOD (int)1e9 + 7
#define int long long
#define maxn 100000
#define inf (int) 3e18
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

vi f(maxn + 1, 0);
vi tree(4*maxn + 1, 0);
vi arr(maxn + 1);

void add (int idx, int val) {
	while (idx <= maxn) {
		f[idx] += val;
		idx += idx & -idx;
	}
}

int query (int idx) {
	int ans = 0;
	while (idx > 0) {
		ans += f[idx];
		idx -= idx & -idx;
	}
	return ans;
}

void build (int node, int l, int r) {
	if (l == r) {
		tree[node] = arr[l];
		return;
	}
	int mid = (l + r) >> 1;
	build (2*node + 1, l, mid);
	build (2*node + 2, mid + 1, r);
	tree[node] = max(tree[2*node + 2], tree[2*node + 1]);
}

int find_max (int node, int l, int r, int lq, int rq) {
	if (l == r && lq <= l && l <= rq) return tree[node];
	if (l > rq || r < lq) return -1;
	if (l >= lq && r <= rq) return tree[node];
	int mid = (l + r) >> 1;
	return max(find_max(2*node + 1, l, mid, lq, rq), find_max(2*node + 2, mid + 1, r, lq, rq));
}

int d (int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
signed main() {	
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;

	if (n % d(n) == 0) cout << "Yes";
	else cout << "No";
	end_routine;
}

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

bool  cmp(int  a, int  b)
{
    return  a>b;
}

int  main()
{
	int  n,s=0,t=0;
	
	cin>>n;
	
	int  a[n+1];
	
	for(int  i=1; i<=n; i++)
	   cin>>a[i];
	   
	sort(a+1,a+n+1,cmp);
	   
	for(int  i=1; i<=n; i++)
	{
		if(i%2==1)
		   s+=a[i];
		else
		   t+=a[i];
	}
	
	cout<<s-t<<endl;
	
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5]) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MOD = 998244353;

void add(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}

void sub(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}

int mul(int a, int b) {
  return (int) ((a * 1LL * b) % MOD);
}

int mpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int minv(int x) {
  return mpow(x, MOD - 2);
}

void adamar(vector<int> &x) {
  size_t n = x.size();
  for (size_t i = 1; i < n; i *= 2) {
    for (size_t j = 0; j < n; j++) {
      if (!(j & i)) {
        int a = x[j];
        int b = x[j ^ i];
//        eprintf("%d %d -> ", x[j], x[j ^ i]);
        x[j] = a;
        add(x[j], b);
        x[j ^ i] = a;
        sub(x[j ^ i], b);
//        eprintf("%d %d\n", x[j], x[j ^ i]);
      }
    }
  }
}

void out(int n) {
  for (int i = 1; i < 100; i++) {
    int x = mul(n, i);
    if (x < 100) {
      eprintf("%d/%d\n", x, i);
      return;
    } else if (x > MOD - 100) {
      eprintf("-%d/%d\n", MOD - x, i);
      return;
    }
  }
  eprintf("??[%d]", n);
}

int main() {
#ifdef LOCAL
  freopen("f.in", "r", stdin);
  freopen("f.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    n = (1 << n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    int s = 0;
    for (int i = 0; i < n; i++) {
      add(s, a[i]);
    }
    adamar(a);

    vector<int> result(n);
    int n2 = mul(s, n);
    result[0] = n2;
    for (int i = 1; i < n; i++) {
      int t = a[i];
      sub(t, a[0]);
      result[i] = mul(s, minv(t));
      sub(result[0], mul(a[i], result[i]));
    }
    result[0] = mul(result[0], minv(a[0]));

    int temp = 0;
    for (int i = 0; i < n; i++) {
      add(temp, mul(result[i], a[i]));
    }
    assert(temp == n2);

    adamar(result);
    for (int i = 0; i < n; i++) {
      sub(result[i], 1);
      printf("%d\n", result[i]);
    }
  }

  return 0;
}


Measured memory_bytes: 4864
#kubaru dp
N=int(input())
dp=[float('inf') for i in range((10**5)*2)]
L6=[6**i for i in range(1,8)]#7ko
L9=[9**i for i in range(1,7)]#6ko
a=[1]
L=a+L6+L9
L.sort()#14ko
dp[0]=0
for i in range(N+1):
    for j in range(14):
        if i+L[j]<=N:
            dp[i+L[j]]=min(dp[i+L[j]], dp[i]+1)
print(dp[N])

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

using namespace std;
typedef long long ll;

string s;
int d;
int dp[10010][110][2][2];
int md = 1e9+7;
void addMd(int &x, int y)
{
    x += y;
    if (x >= md) x -= md;
}
int f(int idx, int rem, bool smaller, bool taken)
{
    if (idx == s.size()) return !rem;
    int &ret = dp[idx][rem][smaller][taken];
    if (~ret) return ret;
    ret = 0;
    for (int j = 0; j <= 9; ++j)
    {
        if (idx == s.size()-1 && !j && !taken) continue;
        if (smaller)
//            addMd(ret, f(idx+1, (rem*10+j)%d, smaller, taken || j));
            addMd(ret, f(idx+1, (rem+j)%d, smaller, taken || j));
        else if (j == s[idx] - '0')
//            addMd(ret, f(idx+1, (rem*10+j)%d, 0, taken || j));
            addMd(ret, f(idx+1, (rem+j)%d, 0, taken || j));
        else if (j < s[idx] - '0')
//            addMd(ret, f(idx+1, (rem*10+j)%d, 1, taken || j));
            addMd(ret, f(idx+1, (rem+j)%d, 1, taken || j));
    }

    return ret;
}
int main()
{
    memset(dp, -1, sizeof dp);
    cin >> s >> d;
    cout << f(0, 0, 0, 0);

    return 0;
}


Measured memory_bytes: 18432
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d", &n);

	printf("%d\n",n*n*n);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){

    ll X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A),q(B),r(C);

    for(int i=0;i<A;i++){
        ll temp;
        cin >> temp;
        p[i] = temp;
    }
    for(int i=0;i<B;i++){
        ll temp;
        cin >> temp;
        q[i] = temp;
    }
    for(int i=0;i<C;i++){
        ll temp;
        cin >> temp;
        r[i] = temp;
    }

    sort(p.begin(),p.end(),greater<int>());
    p.erase(p.begin()+X,p.end());
    sort(q.begin(),q.end(),greater<int>());
    q.erase(q.begin()+Y,q.end());
    sort(r.begin(),r.end(),greater<int>());

    ll pi=X-1,qi=Y-1;

    for(auto& v:r){
        if (pi >= 0 && qi >= 0){
        if(p[pi] >= q[qi]){
            if(v>q[qi]){
                q[qi]=v;
                qi--;
            }else{
                break;
            }
            }else if(p[pi] < q[qi]){
            if(v>p[pi]){
                p[pi]=v;
                pi--;
            }else{
                break;
            }
        }
    }else if(pi<0){
        if(v>q[qi]){
                q[qi]=v;
                qi--;
            }else{
                break;
            }
    }else if (qi<0){
        if(v>p[pi]){
                p[pi]=v;
                pi--;
            }else{
                break;
            }
    }
       if (pi<0 && qi<0)break;
    }

    ll ans = 0;
    for(auto& i:p)ans+=i;
    for(auto& i:q)ans+=i;
    cout << ans << endl;

}

Measured memory_bytes: 2560
#include <stdio.h>

long ad(long,long,long); //Anti-Division
long ea(long,long); //Euclidean Algorithm

int main()
{
	long a,b,c,d;
	long ans1,ans2;

	scanf("%ld %ld %ld %ld", &a,&b,&c,&d);

	ans1 = ad(b, c, d);
	ans2 = ad(a-1, c, d);

	printf("%ld\n",(ans1-ans2));

	return 0;
}

long ad(long x,long c,long d)
{
	long countC,countD;
	long l,g;

	countC = x/c;
	countD = x/d;
	g = ea(c,d);
	l = c*d/g;
	return (x - countC - countD + x/l);
}

long ea(long c,long d)
{
	long g,y;

	while(1)
	{
		if(c%d!=0) 
		{
			y = c;
			c = d;
			d = y%d;	
		}
		else
		{
			g = d;
			break;
		}
	}
	return g;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

void solve()
{
    ll n;
    cin>>n;
    if(n<2)
    {
        cout<<0<<endl;
        return;
    }
    ll ans=mod_pow(10,n,mod);
    ans-=((mod_pow(9,n,mod)));
    ans%=mod;
    ans-=((mod_pow(9,n,mod)));
    ans%=mod;
    ans+=(mod_pow(8,n,mod));
    ans=(ans+mod)%mod;
    cout<<ans;
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
    ll q;
    q=1;
    // sieve();
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i,k;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	bool dp[k+1];
	memset(dp,0,sizeof(dp));
	for(i=0;i<=k;i++)
	{
		int j;
		for(j=0;j<n;j++)
		{
			if(a[j]<=i)
				dp[i]|=(!dp[i-a[j]]);
		}
	}
	if(dp[k]==1)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	return 0;
}

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

const int N = 2e5 + 10;

int k, l, n, c, comp[N], nb[N];
vector <int> adjk[N], adjl[N], ver;
bool mark1[N], mark2[N];
map <int, int> m;

void input();
void dfs1(int);
void dfs2(int);

int main() {
	
	input();
	for (int i = 0; i < n; i++) {
		if (!mark1[i]) {
			dfs1(i);
			c++;
		}	
	}
	 	
	for (int i = 0; i < n; i++) {
		if (!mark2[i]) {
			ver.clear();
			m.clear();
			dfs2(i);
			for (auto x: ver) {
				nb[x] = m[comp[x]];
			}
		}	
	}
	
//	for (int i = 0; i < c; i++) {
//		cout << comps[i] << ' '; 
//		comps[i] = (comps[i] * (comps[i] - 1)) / 2;
//	}
	
	for (int i = 0; i < n; i++) {
//		cout << i << ' ' << comp[i] << ':' << comp2[i] << '\n';
		cout << nb[i] << ' ';
	}
	
}

void input() {
	
	cin >> n >> k >> l;
	
	for (int i = 0; i < k; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjk[u].push_back(v);
		adjk[v].push_back(u);
	}
	
	for (int i = 0; i < l; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjl[u].push_back(v);
		adjl[v].push_back(u);
	}		
	
}

void dfs1(int u) {
	
	mark1[u] = true;
	comp[u] = c;
	
	for (auto v: adjk[u]) {
		if (!mark1[v])
			dfs1(v);
	}
	
}

void dfs2(int u) {
	
	mark2[u] = true;
	m[comp[u]]++;
	ver.push_back(u);
	
	for (auto v: adjl[u]) {
		if (!mark2[v])
			dfs2(v);
	}
	
}

Measured memory_bytes: 20344
n = int(input())
a = list(map(int, input().split()))
ans = 0
MOD = 10**9 + 7
for i in range(60):
    tmp0 = 0
    tmp1 = 0
    for j in range(n):
        if a[j]>>i&1 == 0: tmp0 += 1
        else: tmp1 += 1
    ans += (tmp0*tmp1%MOD)*(2**i%MOD)
print(ans%MOD)

Measured memory_bytes: 122808
N, A, *x = map(int, open(0).read().split())

c_nx = N * max(x + [A])
dp = [[[0] * (c_nx + 1) for _ in range(N + 1)] 
      for _ in range(N + 1)]
x = [0] + x

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(c_nx + 1):
            if s < x[j]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif s >= x[j]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]]
                
print(sum(dp[N][k][k * A] for k in range(1, N + 1)))

Measured memory_bytes: 93148
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
 
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    
    int N; cin >> N;
    vector<vector<char> > data;
    F0R(i, N) {
		vector<char> cur(10);
		F0R(i, 10) cin >> cur[i];
		sort(all(cur)); data.pb(cur);
	}
	sort(all(data));
	ll ans = 0;
	int start = 0;
	FOR(i, 1, N) {
		if (data[start] != data[i]) {
			ll dif = i-start;
			ans += dif * (dif-1) / 2;
			start = i;
		}
	}
	ll dif = N-start;
	ans += dif*(dif-1) / 2;
	
	cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6708
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sy >> sx >> ty >> tx;
	/////////////////////////////////
	for (int i = 0; i < tx - sx; i++)
	{
		cout << "U";
	}
	for (int i = 0; i < ty - sy; i++)
	{
		cout << "R";
	}
	for (int i = 0; i < tx - sx; i++)
	{
		cout << "D";
	}
	for (int i = 0; i < ty - sy; i++)
	{
		cout << "L";
	}
	/////////////////////////////////
	cout << "L";
	for (int i = 0; i < tx - sx + 1; i++)
	{
		cout << "U";
	}
	for (int i = 0; i < ty - sy + 1; i++)
	{
		cout << "R";
	}
	cout << "D" << "R";
	for (int i = 0; i < tx - sx + 1; i++)
	{
		cout << "D";
	}
	for (int i = 0; i < ty - sy + 1; i++)
	{
		cout << "L";
	}
	cout << "U" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<unsigned long long> a(n);
	rep(i, n)
		cin >> a[i];
	unsigned long long ans = 0;
	unsigned long long sumofA = 0;
	rep(i, n-1) {
		sumofA += a[i];
		ans += (sumofA % (1000000007)) * a[i + 1];
		ans = ans % (1000000007);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4836
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

for ti, ai in zip(t, a):
    if ti == ai == t[-1] == a[0]:
        break
else:
    print(0)
    exit()

ans, frag = 1, 0
for i in range(n):
    if t[i] == a[i] == t[-1] == a[0]:
        frag = 1
    if 0 < i < n - 1 and t[i - 1] == t[i] and a[i] == a[i + 1]:
        ans = ans * min(t[i], a[i]) % mod
print(ans if frag == 1 else 0)


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

int main(){

    ll l,r;
    cin >> l >> r;
    
    int ans = 1;

    while(l >= r){
        ans++;
        l /= r;
    }

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




Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
  long long a,ib;
  long double b;
  cin >> a >> b;
  
  ib = (b*100)+0.5;
  a *= ib;
  a /= 100;
  
  cout << a << endl;
  
  return 0;
}


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

int main() {
    float t,x;
    cin >> t >> x;
    cout << fixed << setprecision(10) << t/x << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

bool is_triangle(int a, int b, int c){
    return (a < b+c) && (b < c+a) && (c < a+b);
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    for(int i = 0; i <= n-3; i++){
        for(int j = i+1; j <= n-2; j++){
            for(int k = j+1; k < n; k++){
                if(is_triangle(a[i], a[j], a[k])) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <atcoder/scc>

using namespace std;
using namespace atcoder;
typedef long long ll;

int main()
{
   int N, M;
   cin >> N >> M;
   scc_graph graph(N);
   for (int i = 0; i < M; i++)
   {
      int a, b;
      cin >> a >> b;
      graph.add_edge(a, b);
   }
   auto result = graph.scc();
   cout << result.size() << endl;
   for (auto r : result)
   {
      cout << r.size() << " ";
      for (auto v : r)
      {
         cout << v << " ";
      }
      cout << endl;
   }
   return 0;
}


Measured memory_bytes: 40604
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if (a*100+b*10+c)%4==0{"YES"}else{"NO"})
}

Measured memory_bytes: 2028
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 1000005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS
   
  int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a<b){
    if(a+v*t>=b+w*t){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
  else{
    if(a-v*t<=b-w*t){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,c;
  cin >> n >>c;
  bool a[c+1][100001];
  REP(i,c+1){
    REP(j,100001){
      a[i][j] = false;
    }
  }
  
  REP(i,n){
    int s,t,cc;
    cin >> s >> t >> cc;
    for(int j = s;j <= t;j++){
      a[cc][j] = true;
    }
  }
  ll m = 0;
  REP(i,100001){
    ll sum = 0;
    REP(j,c+1){
      if(a[j][i] == true)
	sum++;
    }
    //if(sum > 0)
    //cout << i << "   " << sum << endl;
    //cout << sum << endl;
    m = max(m,sum);
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(3*max(max(a,b),c)+3*min(min(a,b),c)==2*a+2*b+2*c){
	cout<<"YES"<<endl;
	return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int h,w;
string s[30];
int dp[30][30][30][30];
int grundy(int sy,int sx,int ty,int tx){
  if(~dp[sy][sx][ty][tx]) return dp[sy][sx][ty][tx];
  set<int> g;
  for(int i=sy;i<ty;i++){
    for(int j=sx;j<tx;j++){
      if(s[i][j]=='X') continue;
      int k=0;
      k^=grundy(sy,sx,i,j);
      k^=grundy(i+1,j+1,ty,tx);
      k^=grundy(sy,j+1,i,tx);
      k^=grundy(i+1,sx,ty,j);
      g.insert(k);
    }
  }
  int r=0;
  while(g.count(r)) r++;
  return dp[sy][sx][ty][tx]=r;
}
signed main(){
  cin>>h>>w;
  for(int i=0;i<h;i++) cin>>s[i];
  memset(dp,-1,sizeof(dp));
  cout<<(grundy(0,0,h,w)?"First":"Second")<<endl;
  return 0;
}

Measured memory_bytes: 9532
#include<stdio.h>
int main()
{
	double l,r;
	int al=0,bl=0,cl=0,dl=0,ar=0,br=0,cr=0,dr=0;
	while(scanf("%lf%lf",&l,&r)!=EOF){
		if(l>=1.1){
			al++;
		}else if(l>=0.6){
			bl++;
		}else if(l>=0.2){
			cl++;
		}else{
			dl++;
		}
		if(r>=1.1){
			ar++;
		}else if(r>=0.6){
			br++;
		}else if(r>=0.2){
			cr++;
		}else{
			dr++;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",al,ar,bl,br,cl,cr,dl,dr);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> ws(n);
    for(auto& w : ws) cin >> w;
    vector<int> ss(n);
    ss[0] = ws[0];
    for(size_t i = 1; i < ss.size(); ++i)
    {
        ss[i] = ss[i-1] + ws[i];
    }
    int mindiff = numeric_limits<int>::max();
    for(size_t i = 0; i < ss.size() - 1; ++i)
    {
        int s1 = ss[i];
        int s2 = ss.back() - s1;
        mindiff = min(mindiff, abs(s2-s1));
    }
    
    cout << mindiff << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


int N;
int A[100000];

int main() {
	cin >> N;
	rep(i, N) cin >> A[i];

	map<int, int> m;

	rep(i, N){
		if(m.find(A[i]) == m.end()){
			m.insert(make_pair(A[i], 0));
		}
		m[A[i]]++;
	}

	int ret = 0;
	for(auto itr = m.begin(); itr != m.end(); ++itr) {
		if(itr->second % 2 == 1) ret++;
	}

	cout << ret << endl;

}

Measured memory_bytes: 5376
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int n,a,b,c;

vector<char> ans;

string s[N];

int dp[N][3][3][3];

bool solve(int idx,int a,int b,int c){
    if (a < 0 || b < 0 || c < 0)
        return false;
    if (idx >= n)
        return true;
    int& r = dp[idx][min(2,a)][min(2,b)][min(2,c)];
    if (~r)
        return r;
    if (s[idx] == "AB")
        r = solve(idx + 1, a + 1, b - 1, c) || solve(idx + 1, a - 1, b + 1, c);
    else if (s[idx] == "AC")
        r = solve(idx + 1, a + 1, b, c - 1) || solve(idx + 1, a - 1, b, c + 1);
    else
        r = solve(idx + 1, a, b + 1, c - 1) || solve(idx + 1, a, b - 1, c + 1);
    return r;
}

void trace(int idx = 0,int a = a,int b = b,int c = c){
    if (idx >= n)
        return ;
    if (s[idx] == "AB"){
        if (solve(idx + 1, a + 1, b - 1, c)){
            ans.push_back('A');
            trace(idx + 1, a + 1, b - 1, c);
        }
        else if (solve(idx + 1, a - 1, b + 1, c)){
            ans.push_back('B');
            trace(idx + 1, a - 1, b +  1, c);
        }
    }
    else if (s[idx] == "AC"){
        if (solve(idx + 1, a + 1, b, c - 1)){
            ans.push_back('A');
            trace(idx + 1, a + 1, b, c - 1);
        }
        else if (solve(idx + 1, a - 1, b, c + 1)){
            ans.push_back('C');
            trace(idx + 1, a - 1, b, c + 1);
        }
    }
    else{
        if (solve(idx + 1, a, b + 1, c - 1)){
            ans.push_back('B');
            trace(idx + 1, a, b + 1, c - 1);
        }
        else if (solve(idx + 1, a, b - 1, c + 1)){
            ans.push_back('C');
            trace(idx + 1, a, b - 1, c + 1);
        }
    }
}

int main(){
    IO();
    cin >> n >> a >> b >> c;
    memset(dp, -1, sizeof dp);
    for(int i = 0 ; i < n ; i++)
        cin >> s[i];
    trace();
    if (ans.empty())
        cout << "No\n";
    else{
        cout << "Yes\n";
        for(auto c : ans)
            cout << c << "\n";
    }
}


Measured memory_bytes: 149804
#include <stdio.h>
 
int main(void){
  int L;
  long double edge_size;
  long double result;
    
  scanf("%d",&L);
   
  edge_size = (long double)L / 3;
  result = edge_size * edge_size * edge_size;
  printf("%Lf\n",result);
  
  return 0;
}

Measured memory_bytes: 128
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    let previous = null;
    
    for(let i in S) {
        if(previous === "A" && S[i] === "C") {
            console.log("Yes");
            return;
        }
        
        previous = S[i];
    }
    
    console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  string s, t;
  cin >> s >> t;
  
  if((s.size() == (t.size() - 1)) && equal(s.begin(), s.end(), t.begin()) == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
from collections import Counter
def collatz(n):
    if n%2:
        return n*3 + 1
    else:
        return n//2
    
i = int(input())
dic = dict()
dic[i] = 1
cur = i
for n in range(1,10000):
    cur = collatz(cur)
    if cur in dic:
        print(n+1)
        break
    else:
        dic[cur] = 1

Measured memory_bytes: 39792
#include<bits/stdc++.h>
 
int main()
{
    int n,k;
    std::cin >> n >> k;
    std::vector<std::pair<int,bool>> a(n);
    for(int i = 0; i < n; i++){a[i].first = 0; a[i].second = 0;}
    for(int i = 0; i < k; i++){
        int tmp;
        std::string s;
        std::cin >> tmp >> s;
        tmp--;
        if(a[tmp].second == false && s == "WA")a[tmp].first++;
        if(s == "AC")a[tmp].second = true;
    }
    int x = 0, y = 0;
    for(int i = 0; i < n; i++){
        if(a[i].second)x++;
        if(a[i].first && a[i].second)y += a[i].first;
        //std::cout << i + 1 <<" : " << a[i].second << " : " << a[i].second << std::endl;
    }
 
    std::cout << x << " " << y << std::endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

void ans(bool b){
	puts(b ? "Yes" : "No");
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vi as(n);
	trav(x, as) cin >> x;
	int mn = n;
	trav(x, as) mn = min(mn, x);
	int a = count(all(as), mn);
	int b = count(all(as), mn+1);
	if(a+b != n) ans(0);
	if(b == 0){
		if(mn+1 == n) ans(1);
		swap(a,b);
		--mn;
	}
	int lo = a + bool(b);
	int hi = a + b/2;
	if(lo <= mn+1 && mn+1 <= hi) ans(1);
	else ans(0);
}

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

std::vector<std::vector<int> > hen;
// hen[i] : i->?

std::vector<int> parent;
std::vector<int> add;
std::vector<int> num;

void dfs(int i, int prev, int cur_add) {
	cur_add += add[i];
	num[i] = cur_add;
	for (auto j : hen[i]) {
		if (j == prev) continue;
		dfs(j, i, cur_add);
	}
}

int main() {
	int n, q;
	std::cin >> n >> q;
	int a[n - 1], b[n - 1];
	hen.resize(n);
	for (int i = 0; i + 1 < n; i++) {
		std::cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		hen[a[i]].push_back(b[i]);
		hen[b[i]].push_back(a[i]);
	}
	parent.resize(n);
	num.resize(n);
	add.resize(n);
	for (int i = 0; i < q; i++) {
		int p, x;
		std::cin >> p >> x;
		p--;
		add[p] += x;
	}
	dfs(0, -1, 0);
	for (int i = 0; i < n; i++) std::cout << num[i] << " ";
	return 0;
}


Measured memory_bytes: 26624
import itertools
N,M = map(int,input().split())
X=[]
for i in range(M):
  X+=[[int(x) for x in input().split()]]
P=[int(x) for x in input().split()]
result=0
for switch in itertools.product([0,1],repeat=N):
  on=0
  for i in range(M):
    count=0
    for j in range(X[i][0]):
      if switch[X[i][j+1]-1]==1:
        count +=1
    if count%2==P[i]:
      on +=1
    else:
      break
  if on==M:
    result +=1
print(result)

Measured memory_bytes: 3064
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int MOD = (int)1e9 + 7;
const int N = 23;

int n, a[N][N], dp[N][(1<<N)];
bool vis[N][(1<<N)];

int licz(int nr, int mask) {
  if (vis[nr][mask])
    return dp[nr][mask];
  if (mask == 0) {
    vis[nr][mask] = true;
    return dp[nr][mask] = 1;
  }
  int res = 0;
  for (int i = 0; i < n; ++i)
    if ((mask&(1<<i)) && a[nr][i] == 1)
      res = (res+licz(nr+1, mask^(1<<i)))%MOD;
  vis[nr][mask] = true;
  return dp[nr][mask] = res;
}

signed main() {
  init_ios();
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      cin >> a[i][j];
  cout<<licz(0, (1<<n)-1)<<"\n";
}

Measured memory_bytes: 397568
#include <stdio.h>

int main(void){
double max,min,n;
scanf("%lf",&n);
max=min=n;
while(scanf("%lf",&n)!=EOF){
if(n>max) max=n;
if(n<min) min=n;
}
printf("%f\n",max-min);
return 0;
}

Measured memory_bytes: 1076
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define pb push_back
//2部グラフがa個、そうでないグラフがb個、頂点1のグラフがc個の時、
//連結成分は2a^2 + 2ab + 2ac + b^2+ 2bc + c^2
//2部グラフに属する頂点数がp個、そうでないグラフに属する頂点数がq個の時、
//c=n-p-qで算出される

vector<vi> edge;
vi number;
bool flag;

ll dfs(int cur,int info){
	if(number[cur]!=0){
		if(info!=number[cur])	flag=true;
		return 0;
	}
	number[cur]=info;
	ll ret=1;
	for(int i=0;i<edge[cur].size();i++){
		ret+=dfs(edge[cur][i],info^3);
	}
	return ret;
}

int main(){
	ll n,m;	cin>>n>>m;
	number=vi(n,0);
	edge=vector<vi>(n);
	for(int i=0;i<m;i++){
		int u,v;	cin>>u>>v;	u--;	v--;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	ll a=0,p=0,b=0,q=0;
	for(int i=0;i<n;i++){
		if(number[i]==0){
			if(edge[i].size()>0){
				flag=false;
				ll s=dfs(i,1);
				if(flag){
					b++;	q+=s;
				}
				else {
					a++;	p+=s;
				}
			}
		}
	}
	ll c=n-p-q;
	ll ret=2*a*a+2*a*b+b*b+c*(c+2*p+2*q);
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 9984
#include <stdio.h>
#define rep(i, n) for(int i=1; i<(int)(n);i++)

int main(){
  int a, b, c, k, ans=0;
  int gcd_3(int ,int ,int );
  scanf("%d",&k);
  rep(a,k+1){
    rep(b,k+1){
      rep(c,k+1){
        ans += gcd_3(a,b,c);
      }
    }
  }
  printf("%d",ans);
}


int gcd_3(int a,int b,int c){
  int gcd(int ,int );
  return gcd(gcd(a,b),c);
}
int gcd(int a, int b) { return b?gcd(b,a%b):a;}


Measured memory_bytes: 1728
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stdlib.h>
#include<vector>
#include<stack>
#include<bitset>
#include<set>
#define maxn 200005
using namespace std;
typedef long long ll;
int n,m,k;
int a[maxn];
priority_queue<ll> q;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	ll ans=a[n];
	q.push(a[n-1]); q.push(a[n-1]);
	for(int i=n-2;i>=1;i--)
	{
		ll now=q.top(); q.pop();
		q.push(a[i]);
		q.push(a[i]);
		ans+=now;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 6184
from collections import deque


class Dinic:
	def __init__(self, N):
		self.N = N
		self.edges = [[] for _ in range(N)]
		self.level = None
		self.iter = None

	def add_edges(self, u, v, cap):
		self.edges[u].append([v, cap, len(self.edges[v])])
		self.edges[v].append([u, 0, len(self.edges[u]) - 1])

	def bfs(self, s):
		self.level = [-1] * self.N
		self.level[s] = 0
		q = deque([s])
		while q:
			cur = q.popleft()
			for nxt, cap, _ in self.edges[cur]:
				if cap > 0 > self.level[nxt]:
					self.level[nxt] = self.level[cur] + 1
					q.append(nxt)

	def dfs(self, s, flow):
		if s == self.end:
			return flow
		for i in range(self.iter[s], len(self.edges[s])):
			self.iter[s] = i
			to, cap, opp = self.edges[s][i]
			if cap > 0 and self.level[s] < self.level[to]:
				d = self.dfs(to, cap if cap < flow else flow)
				if d > 0:
					self.edges[s][i][1] -= d
					self.edges[to][opp][1] += d
					return d
		return 0

	def maximum_flow(self, source, end):
		self.end = end
		max_flow = 0
		INF = float('inf')
		while True:
			self.bfs(source)
			if self.level[end] < 0:
				return max_flow
			self.iter = [0] * self.N
			flow = self.dfs(source, INF)
			while flow:
				max_flow += flow
				flow = self.dfs(source, INF)


v, e, *L = map(int, open(0).read().split())
dinic = Dinic(v)
for s, t, c in zip(*[iter(L)] * 3):
	dinic.add_edges(s, t, c)
print(dinic.maximum_flow(0, v - 1))


Measured memory_bytes: 6280
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int x, y;

int main() {
scanf("%d %d", &x, &y);
if (x % y == 0) printf("-1\n"); else printf("%d\n", x);
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll a,b,M;
  ll A[100010]={0};
  ll B[100010]={0};
  cin>>a>>b>>M;
  ll x,y,z;
  ll ans=1000000;
  rep(i,a)cin>>A[i];
  rep(i,b)cin>>B[i];
  rep(i,M){
    cin>>x>>y>>z;
    ans=min(A[x-1]+B[y-1]-z,ans);
  }
  sort(A,A+a);
  sort(B,B+b);
  ans=min(A[0]+B[0],ans);
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
N,M=map(int,input().split())
edge=[list(map(int,input().split())) for i in range(M)]
inf=10**20
c=[[] for i in range(N*3+1)]
for i,j in edge:
    c[i].append(N+j)
    c[N+i].append(N+N+j)
    c[N+N+i].append(j)
S,T=map(int, input().split())
from collections import deque
d=[inf]*(N*3+1)
d[S]=0
q=deque([S])
x=1
while q:
    q2=deque()
    for i in q:
        for j in c[i]:
            if d[j]>x:
                d[j]=x
                q2.append(j)
    q=q2
    x+=1
print(d[T]//3 if d[T]<inf else -1)


Measured memory_bytes: 101476
import java.util.Scanner;
import java.util.TreeSet;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int n,r;
            n=sc.nextInt();
            r=sc.nextInt();
            if(n==0&&r==0)break;
            int x[]=new int[n];
            int y[]=new int[50];
            for(int i=0;i<n;i++){
                x[i]=n-i;
            }
            for(int i=0;i<r;i++){
                int a,b;
                a=sc.nextInt();
                b=sc.nextInt();
                --a;
                for(int j=a;j<a+b;j++){
                    y[j-a]=x[j];
                }
                for(int j=a-1;j>=0;j--){
                    x[j+b]=x[j];
                }
                for(int j=0;j<b;j++){
                        x[j]=y[j];
                }
            }
            System.out.println(x[0]);

        }
    }
}



Measured memory_bytes: 36636
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    long long l,r;
  	int ans=2019;
  
    cin >> l >> r;
	if(r-l>=2019){
      ans = 0;
    }
  	else{
      for(int i = (int)l%2019;i<=(int)r%(2019)-1;i++){
        for(int j = i+1;j<=(int)r%2019;j++){
          
          ans = min(ans,(int)(i*j)%2019);
        }
      }
    }
    
 
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def resolve():
	n = input()
	a = [int(i) for i in input().split()]
	if 0 in a:
	    print(0); return
	ans = 1
	for i in a:
	    ans = ans * i
	    if ans > 10**18:
	        print(-1); return
	print(ans)

resolve()

Measured memory_bytes: 21624
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b,c;  cin  >> a >> b >> c;
    if(a == b && a != c){
        cout << "Yes" << endl;
    }else if(a == c && a != b){
        cout << "Yes" << endl;
    }else if(b == c && b != a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
queue<int> q;
int n,a,k,u,c[101],i,j;
vector<int> d[101];
cin>>n;for(i=0;i<n;i++){
cin>>u>>k;c[i+1]=-1;
d[u].resize(k);
for(j=0;j<k;j++)cin>>d[u][j];
}q.push(1),c[1]=0;
while(!q.empty()){
a=q.front(),q.pop();
for(i=0;i<d[a].size();i++)
if(d[a][i]>1&&c[d[a][i]]==-1)q.push(d[a][i]),c[d[a][i]]=c[a]+1;
}for(i=1;i<=n;i++)cout<<i<<" "<<c[i]<<endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------
int gcd(int a, int b){
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//main
//------------------------------------------
signed main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int lcm = (C*D)/gcd(C, D);

  int ans = (B-B/C-B/D+B/lcm - ((A-1)-(A-1)/C-(A-1)/D+(A-1)/lcm));

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


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

namespace ConsoleApp33 {
    class Program {
        static void Main(string[] args) {
            int X = int.Parse(Console.ReadLine());
            
            if (X == 1) {
                Console.WriteLine("Hello World");

            } else if (X == 2) {
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());

                Console.WriteLine(A + B);

            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N, K, L, R, M, l, r, m, cnt;
vector<ll> num;
int main()
{
    cin>>N>>K;
    num.clear();
    for(ll i = 0; i<N; ++i)
    {
        ll n;
        cin>>n;
        num.push_back(n);
    }
    sort(num.begin(), num.end());
    L = -2e18;
    R = 2e18;
    //L = -15;
    //R = 15;
    while(R-L>1)
    {
        M = (L+R)/2;
        cnt = 0;
        
        for(ll i = 0; i<N; ++i)
        {
            int l = i, r = N; 
            while(r-l>1)
            {
                int m = (l+r)/2;
                if(num[i]*num[m]<=M) //too small
                    (num[i]>0) ? l = m : r = m;
                else //too big
                    (num[i]>0) ? r = m : l = m;
                //cout<<"(l, r, m, cnt) = ("<<l<<", "<<r<<", "<<m<<", "<<cnt<<")\n";
            }
            if(num[i]>0) cnt+=l-i;//not sure
            else cnt+=N-r;// not sure
        }
        (cnt<K) ? L = M : R = M; //too small
        //cout<<"(L, R, M) = ("<<L<<", "<<R<<", "<<M<<")\n";
    }
    cout<<R<<"\n";
}

Measured memory_bytes: 2420
from collections import deque
h, w = [int(x) for x in raw_input().split()]
c = [[int(x) for x in raw_input().split()] for line in xrange(10)]
a = [[int(x) for x in raw_input().split()] for line in xrange(h)]
for t in xrange(10):
    for i in xrange(10):
        for j in xrange(10):
            for k in xrange(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])
cost = 0
for line in xrange(h):
    for col in xrange(w):
        if a[line][col] in [-1, 1]:
            continue
        else:
            cost += c[a[line][col]][1]
print cost

Measured memory_bytes: 3192
def solve(N,T):
    import math
    ans = 0
    for i in range(len(T)):
        ans = max(ans, math.ceil(N/T[i]))
    ans += 4
    print(ans)

def main():
    N = int(input())
    T = [int(input()) for _ in range(5)]
    solve(N, T)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    int x;
    cin >> x;
    int kazu=0;
    int ans=1;
    if(x<=3){
        cout << "1" <<endl;
        return 0;
    }
    for(int l=2;l<x;l++){
        kazu=l;
        int cnt=0;
        while(kazu<=x){
            kazu*=l;
            cnt++;
        }
        if(cnt>=2)ans=max(ans,kazu/l);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256