akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

unsigned long long func(string& S, int index, unsigned long long total)
{
	if (index >= S.length())
	{
		return total;
	}

	auto sum = 0ull;
	for (auto i = index + 1; i <= S.length(); ++i)
	{
		auto temp = 0ull;
		for (auto j = index; j < i; ++j)
		{
			temp = temp * 10 + (S[j] - '0');
		}
		sum += func(S, i, total + temp);
	}
	return sum;
};

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

	cout << func(S, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define chmax(a,b) if(a<b)a=b
const int N=17;

int n,m;
int g[N][N];
int cost[1<<N];
int dp[N][1<<N],dp2[1<<N];

int main()
{
	
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u--; v--;
		g[u][v]=g[v][u]=w;
	}
	for(int mask=0;mask<(1<<n);mask++)
	for(int u=0;u<n;u++)
	for(int v=u+1;v<n;v++)
		if(mask&(1<<u) && mask&(1<<v)) cost[mask]+=g[u][v];
	memset(dp,-1,sizeof(dp));
	for(int mask=1;mask<(1<<n);mask+=2)
		dp[0][mask]=cost[mask];
	for(int mask=1;mask<(1<<(n-1));mask+=2)
	for(int i=0;i<n-1;i++) if(dp[i][mask]!=-1)
	for(int j=0;j<n;j++)
		if(g[i][j] && !(mask&(1<<j))) chmax(dp[j][mask|(1<<j)],dp[i][mask]+g[i][j]);
	memset(dp2,-1,sizeof(dp2));
	for(int mask=1;mask<(1<<n);mask+=2)
		dp2[mask]=dp[n-1][mask];
	for(int mask=1+(1<<(n-1));mask<(1<<n);mask+=2) if(dp2[mask]!=-1)
	for(int i=0;i<n;i++) if(mask&(1<<i))
	{
		int _=(1<<n)-1-mask;
		for(int mask2=_;mask2>0;mask2=(mask2-1)&_)
			chmax(dp2[mask|mask2],dp2[mask]+cost[mask2|(1<<i)]);
	}
	printf("%d\n",cost[(1<<n)-1]-dp2[(1<<n)-1]);
	
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define ld long double
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
#define PI 3.14159265358979323846

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int sum = 0;
    sum = a+b+c;
    if (sum<22)
    {
        cout << "win" << endl;
    }else
    {
        cout << "bust" << endl;
    }
    
    
}

Measured memory_bytes: 256
import os
import math
import itertools
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

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

while(True):
    try:
        n = get_int()
        s, t = [input() for _ in range(2)]
        for i in range(len(s)):
            if s[i:] == t[:len(s) - i]:
                print(len(s) + i)
                exit()
        print(len(s + t))
    except EOFError:
        exit()


Measured memory_bytes: 3064
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//ios::sync_with_stdio(false);
  string S;
  cin >>S;

  int left = atoi(S.substr(0, 2).c_str());
  int right = atoi(S.substr(2, 2).c_str());
  int isYYMM = (right >= 1 && right <= 12);
  int isMMYY = (left >= 1 && left <= 12);
  if(isYYMM && isMMYY) cout <<"AMBIGUOUS" <<endl;
  else if(isYYMM) cout <<"YYMM" <<endl;
  else if(isMMYY) cout <<"MMYY" <<endl;
  else cout <<"NA" <<endl;
  
  return 0;
}


Measured memory_bytes: 256
#DP[i][j][k] = (i番目まで、j個選ぶ、有効重さの和kのときの最大得点)

N, W = map(int, input().split())
INF = 10**13
DP = [[[-INF for _ in range(3*N+1)] for _ in range(N+1)] for _ in range(N+1)]
w0, v = map(int, input().split())
DP[1][0][0] = 0
DP[1][1][0] = v

for i in range(2,N+1):
  w, v = map(int, input().split())
  w -= w0
  for j in range(N+1):
    for k in range(3*N+1):
      if k-w >= 0:
        DP[i][j][k] = max(DP[i-1][j-1][k-w] + v, DP[i-1][j][k])
      else:
        DP[i][j][k] = DP[i-1][j][k]

#print(w0)
#print(DP)
#print([max(DP[N][j]) + w0*j for j in range(N+1)])
#print(max([max(DP[N][j]) + w0*j for j in range(N+1)]))
ans = max([max([DP[N][j][k] for k in range(min(3*N,W-w0*j)+1)]) if W-w0*j >= 0 else -INF for j in range(N+1)])
print(ans)

Measured memory_bytes: 100116
n, k = map(int, input().split())
a = list(map(int, input().split()))
_sum = [0]*41
m = 0
f = 0
for x in a:
  for i in range(41):
    _sum[i] += (x >> i) & 1
for i in range(40, -1, -1):
  flg = 0 if _sum[i] > n//2 else 1
  s = flg << i
  m += s
  if m > k:
    m -= s
    f += min(_sum[i], n-_sum[i]) << i
  else:
    f += max(_sum[i], n-_sum[i]) << i
print(f)

Measured memory_bytes: 14620
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>

#define ll long long
using namespace std; 

void solve(){
  ll x,k,d; 
  cin >>x>> k>> d; 
  x = abs(x);
  d = abs(d);  
  if(x/d > k){
    cout << abs(x-d*k) << "\n"; 
  }else{
    k = k-x/d; 
    if(k&1){
      cout << d- x%d << "\n"; 
    }else{
      cout << x%d << "\n"; 
    }
  }

}

int main(){
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
 return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("O3")
            #pragma comment(linker, "/stack:200000000")
            #pragma GCC optimize("unroll-loops")
             
            #include <algorithm>
            #include <bitset>
            #include <cassert>
            #include <chrono>
            #include <cmath>
            #include <complex>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <ctime>
            #include <deque>
            #include <functional>
            #include <iomanip>
            #include <iostream>
            #include <iterator>
            #include <limits>
            #include <climits>
            #include <list>
            #include <map>
            #include <numeric>
            #include <queue>
            #include <random>
            #include <ratio>
            #include <set>
            #include <sstream>
            #include <stack>
            #include <string>
            #include <unordered_map>
            #include <unordered_set>
            #include <utility>
            #include <vector>
            using namespace std;
             
            typedef long long ll;
            typedef long double ld;
            #define int ll
            #define double ld
            #define pb push_back
            #define mp make_pair
            #define REP(i,n) for (int i = 0; i < n; i++)
            #define loop(i,n) for (int i = 0; i < n; i++)
            #define FOR(i,a,b) for (int i = a; i < b; i++)
            #define REPD(i,n) for (int i = n-1; i >= 0; i--)
            #define FORD(i,a,b) for (int i = a; i >= b; i--)
            #define remax(a,b) a = max(a,b)
            #define remin(a,b) a = min(a,b)
            #define mem(a, b) memset(a, b, sizeof a)
            #define append push_back
            #define all(v) v.begin(),v.end()
            #define F first
            #define S second
            #define print(x) cout << (x) << endl
            #define PRECISION(x) cout << fixed << setprecision(x)
            #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
            
            const double PI=acos(-1);
            const int MOD = 1000000007;
            const int FMOD = 998244353;
            const double eps = 1e-9;
             
            mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
 
signed main(){

	int x;
	cin>>x;
	
	int a[200];
	for(int i=0;i<=150;i++)
	{
		a[i]=pow(i,5);
	}
	int f=0;
	for(int i=0;i<=150;i++)
	{
		for(int j=0;j<=150;j++)
		{
			if(a[i]-a[j]==x)
			{
				cout<<i<<" "<<j;
				f=1;
				break;
			}
			if(a[i]+a[j]==x)
			{
				j=-j;
				cout<<i<<" "<<j;
				f=1;
				break;
			}
		}
		if(f==1)
		break;
	}
	
}
			

Measured memory_bytes: 4072
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
A = []
for i in range (0, N):
    A.append([int(j) for j in input().split()])

count = 0
for i in range(0, N):
    calc = 0
    for j in range(0, M):
        calc += B[j] * A[i][j]
    if (calc + C > 0):
        count += 1

print(count)
        

Measured memory_bytes: 3064
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int dp[3002][3002], trace[3002][3002];
int main(){
    FAST
    //Do awesome things here
    string s, t;
    cin >> s >> t;
    int l1 = s.length(), l2 = t.length();
    rp(i, l1 + 1)   dp[i][0] = 0;
    rp(i, l2 + 1)   dp[0][i] = 0;
    fre(i, 1, l1){
        fre(j, 1, l2){
            trace[i][j] = inf;
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = 1 + dp[i - 1][j - 1];
                trace[i][j] = 0;
            }
            if(dp[i][j] < dp[i - 1][j]) trace[i][j] = 1, dp[i][j] = dp[i - 1][j];
            if(dp[i][j] < dp[i][j - 1]) trace[i][j] = 2, dp[i][j] = dp[i][j - 1];
        }
    }
    int i = l1, j = l2;
    string ans = "";
    while(i > 0 && j > 0){
        if(trace[i][j] == 0){
            ans += s[i - 1];
            i = i - 1, j = j - 1;
        }
        else{
            if(trace[i][j] == 1)    i = i - 1;
            else   j = j - 1;
        }    
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//head

vi a;
vi b;
vi c;
ll dp[41][401][401];
ll solve(int n, int ai, int bi){
	if(dp[n][ai][bi] > 0) return dp[n][ai][bi];
	if(n == 0){
		if(ai == 0 && bi == 0){
			return dp[n][ai][bi] = 0;
		}
		else if(ai - a[0] == 0 && bi - b[0] == 0){
			return dp[n][ai][bi] = c[0];
		}
		else{
			return dp[n][ai][bi] = INT_MAX;
		}
	}
	else{
		if(ai - a[n] >= 0 && bi - b[n] >= 0){
			return dp[n][ai][bi] = min(solve(n-1, ai-a[n], bi - b[n]) + c[n], solve(n-1, ai, bi));
		}
		else{
			return dp[n][ai][bi] = solve(n-1, ai, bi);
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);

  	int n, ma, mb;
  	cin >> n >> ma >> mb;
  	a.resize(n);
  	b.resize(n);
  	c.resize(n);
  	memset(dp, 0, sizeof(dp));
  	for(int i = 0; i < n; i++){
  		cin >> a[i] >> b[i] >> c[i];
  	}
  	ll ans = INT_MAX;
  	for(int i = 1; i < 100; i++){
  		int sa = ma * i;
  		int sb = mb * i;
  		if(sa > 400 || sb > 400) break;
  		ans = min(ans, solve(n-1, sa, sb));
  	}
  	cout << (ans != INT_MAX ? ans : -1) << endl;
	return 0;
}


Measured memory_bytes: 51712
<?php
$inputs = explode(" ", fgets(STDIN));
$takahashi_cookie = (int)$inputs[0];
$aoki_cookie = (int)$inputs[1];
$times = (int)$inputs[2];

if ($takahashi_cookie > 0) {
  $takahashi_cookie = $takahashi_cookie - $times;
  
  // 高橋クッキーを食い尽くした場合は青木クッキーに手を出す
  if ($takahashi_cookie < 0) {
    $aoki_cookie = $aoki_cookie + $takahashi_cookie;

    $takahashi_cookie = 0;
    $aoki_cookie = $aoki_cookie > 0 ? $aoki_cookie : 0;
  }
} else {
  $aoki_cookie = $aoki_cookie - $times;
  
  if ($aoki_cookie < 0) {
    $aoki_cookie = 0;
  }
}

echo $takahashi_cookie.' '.$aoki_cookie;


Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
//#define int long long
using namespace std;
const int maxn=5e5+1000;
typedef long long ll;
int n,m;
const int mod=998244353;
int fr[maxn],ans;
inline int ksm(int num,int t){
	int res=1;
	for(;t;t>>=1,num=1ll*num*num%mod){
		if(t&1)res=1ll*res*num%mod;
	}
	return res;
}
inline int c(int m,int n){
	return 1ll*fr[n]*ksm((1ll*fr[m]*fr[n-m])%mod,mod-2)%mod;	
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	fr[0]=fr[1]=1;
	for(int i=2;i<maxn;i++)fr[i]=1ll*fr[i-1]*i%mod;	
	for(int i=0;i<=min(n,m);i++){
		ans=(ans+1ll*ksm(-1,i)*(1ll*c(i,n)*c(i,m)%mod*fr[i]%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i)%mod)%mod)%mod;	
	}
	ans=(ans%mod+mod)%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int l;
    int r;
    int d;
    cin>>l>>r>>d;
    int x=0;
    for(int i=l;i<=r;i++){
        if(i%d==0){
            x++;
        }
    }
    cout<<x<<endl;

}




Measured memory_bytes: 3612
N, K = map(int, input().split())
x = [int(x) for x in input().split()]

x1 = []
x2 = []
for i in range(N):
    if x[i] >= 0:
        x1.append(x[i])
    else:
        x2.append(-1 * x[i])
x2 = x2[::-1]

N1 = len(x1)
N2 = len(x2)

ans = float('inf')

if N1 >= K:
    ans = min(ans, x1[K - 1])
if N2 >= K:
    ans = min(ans, x2[K - 1])

for i in range(K - 1):
    if i < N1 and K - i - 2 < N2:
        d1 = 2 * x1[i] + x2[K - i - 2]
        d2 = x1[i] + 2 * x2[K - i - 2]
        ans = min(ans, d1, d2)
print(ans)





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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	char answer = '?';
	switch (s[0]) {
		case 'A':
			answer = 'T';
			break;
		case 'T':
			answer = 'A';
			break;
		case 'C':
			answer = 'G';
			break;
		case 'G':
			answer = 'C';
			break;
	}
	printf("%c\n", answer);
}


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

namespace ConsoleApp1
{
    class Program
    {
        static long Gcd(long a, long b)
        {
            if (a < b)
            {
                long temp = a;
                a = b;
                b = temp;
            }

            while (true)
            {
                long remainder = a % b;
                if (remainder == 0)
                {
                    return b;
                }

                a = b;
                b = remainder;
            }
        }

        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split();
            int n = int.Parse(array[0]);
            long m = long.Parse(array[1]);
            var X = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var appended = X.Concat(new[] { m }).OrderBy(x => x);
            var diffs = appended.Zip(appended.Skip(1), (a, b) => b - a).ToArray();

            long ans = diffs[0];
            foreach (var diff in diffs)
            {
                ans = Gcd(ans, diff);
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 25952
#!/usr/bin/python
# coding: UTF-8

def main():
    A,B,M = list(map(int, input().split(' ')))

    a_list = list(map(int, input().split(' ')))
    b_list = list(map(int, input().split(' ')))


    price_list = 2*10**5
    for i in range(M):
        temp = list(map(int, input().split(' ')))
        if price_list > a_list[temp[0]-1] + b_list[temp[1]-1] - temp[2]:
            price_list = a_list[temp[0]-1] + b_list[temp[1]-1] - temp[2]

    lower = min(a_list) + min(b_list)
    if lower < price_list:
        print(lower)
    else:
        print(price_list)

if __name__=='__main__':
    main()


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

#define MAX 100000

typedef struct{
  char name[10];
  int time;
} data;

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(data);
data dequeue(void);

int head,tail,n;
data Q[MAX+1];

int main(){
  int q,i,t,sum=0;
  data d;

  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s %d",Q[i].name,&Q[i].time);
  }

  initialize();

  tail=n;

  while(head!=tail){
    d=dequeue();

    if(d.time<=q){
      t=d.time;
    }else if(d.time>q){
      t=q;
    }
    d.time-=t;
    sum+=t;

    if(d.time<=0){
      printf("%s %d\n",d.name,sum);
    }else{
      enqueue(d);
    }
  }

  return 0;
}
  
    
void initialize(void){
  head=tail=0;
}

int isEmpty(void){
  if(head==tail){
    return 0; //empty
  }else{
    return 1;
  }
}

int isFull(void){
  if(head==((tail+1)%MAX)){
    return 1; //full
  }else{
    return 0;
  }
}

 void enqueue(data x){
  int full;

  full=isFull();
  if(full==1){
    fprintf(stderr,"overflow\n");
    exit(1);
  }

  Q[tail]=x;

  if(tail+1==MAX){
    tail=0;
  }else{
    tail++;
  }
}

data dequeue(void){
  int emp;
  data x;

  emp=isEmpty();
  if(emp==0){
    fprintf(stderr,"underflow\n");
    exit(8);
  }

  x=Q[head];

  if(head+1==MAX){
    head=0;
  }else{
    head++;
  }

  return x;
}

Measured memory_bytes: 2156
n=gets.to_i
as=(gets.split.map &:to_i).sort
max=as[-1]
res=[]
sieve=Array.new(max+1,true)
as.each_with_index do |a,i|
  if sieve[a]
    sieve[a]=false if a==as[i+1]
    res << a if sieve[a]
    mul=2*a
    while mul<=max
      sieve[mul] = false
      mul += a
    end
  end
end
p res.size

Measured memory_bytes: 39824
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const int N = 200005;
ll inf = 1e16;
ll mod = 1e9 + 7;

char en = '\n';
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll arr[4];
ll n;
ll dp[3005][5];
ll recur(ll rem, ll pos) {
  if (pos == 4 && rem == 0) {
    return 1;
  }
  if (pos == 4)
    return 0;

  if (rem < 0)
    return 0;

  ll &ans = dp[rem][pos];
  if (ans != -1)
    return ans;
  ans = 0;
  for (ll i = 0; i <= rem; i++) {
    ans += recur(rem - i * arr[pos], pos + 1);
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  for (ll i = 1; i <= 3; i++)
    cin >> arr[i];
  cin >> n;
  memset(dp, -1, sizeof(dp));
  cout << recur(n, 1) << en;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int k = 1; //部分集合の数-1
  bool exist = false;
  while (k <= n) {
    if (n == (k+1)*k/2) {
      exist = true;
      break;
    }
    k++;
  }
  if (!exist) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  if (n == 1) {
    cout << 2 << endl;
    cout << 1 << ' ' << 1 << endl;
    cout << 1 << ' ' << 1 << endl;
    return 0;
  }
  vector<vector<int>> ans(k+1);
  int num = 1, idx1 = 0, idx2 = 1;
  for (int i = k; i; i--) {
    while (idx2 < k+1) {
      ans[idx1].push_back(num);
      ans[idx2].push_back(num);
      idx2++;
      num++;
    }
    idx1++;
    idx2 = idx1+1;
  }
  cout << k+1 << endl;
  rep(i, ans.size()) {
    cout << ans[i].size();
    rep(j, ans[i].size()) {
      cout << ' ' << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

struct Edge {
	int to, cap, rev;
};

vector< vector<Edge> > G;
vector<bool> used;
int dfs(int s, int t, int f) {
	if (s == t) return f;
	used[s] = true;

	for (int i = 0; i < G[s].size(); ++i) {
		Edge& e = G[s][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(e.cap, f));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int res = 0;
	while (1) {
		int N = G.size();
		used = vector<bool>(G.size(), false);
		int flow = dfs(s, t, 1e9);
		if (flow > 0) {
			res += flow;
		}
		else {
			break;
		}
	}
	return res;
}
void add_edge(int u, int v, int cap) {
	G[u].push_back((Edge){v, cap, (int)G[v].size()});
	G[v].push_back((Edge){u, cap, (int)G[u].size()-1});
}

typedef pair<int, int> P;

int main() {
	int N, M; cin >> N >> M;
	G.resize(N);
	vector<P> edges;
	map<P, int> tbl;
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b; --a, --b;
		edges.push_back( P(a, b) );
		tbl[edges[i]] = i;
	}
	for (int i = 0; i < M; ++i) {
		int u = edges[i].first, v = edges[i].second;
		add_edge(u, v, 1);
	}
	int S, T; cin >> S >> T; --S, --T;
	cout << max_flow(S, T) << endl;

	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < G[i].size(); ++j) {
			Edge& e = G[i][j];
			if (e.cap == 0) {
				if (tbl.find(P(e.to, i)) != tbl.end()) {
					ans.push_back(tbl[P(e.to, i)]+1);
				}
			}
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1360
import java.util.*;
import java.awt.Point;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			LinkedList< LinkedList<Integer> > s = new LinkedList< LinkedList<Integer> >();

			for(int i=1;i<=n;i++){
				LinkedList<Integer> tmp = new LinkedList<Integer>();
				tmp.add(i);
				s.add(tmp);
			}

			while(true){
				int from = sc.nextInt(), to = sc.nextInt();
				if(from == 0 && to == 0) break;

				Point resA = find(s,from);
				Point resB = find(s,to);

				if(resB == null){
					if(resA.y == 0) continue;
					fall(s,resA);
					LinkedList<Integer> tmp = new LinkedList<Integer>();
					tmp.add(s.get(resA.x).removeLast());
					s.add(tmp);
				}
				else if(resA.x == resB.x && resA.y < resB.y){
					fall(s,resA);
					resB = find(s,to);
					s.get(resB.x).add(s.get(resA.x).removeLast());
				}
				else if(resA.x != resB.x){
					fall(s,resA);
					s.get(resB.x).add(s.get(resA.x).removeLast());
				}
			}

			ArrayList<Integer> ans = new ArrayList<Integer>();
			for(int i=0;i<s.size();i++)
				if(s.get(i).size() > 0) ans.add(s.get(i).size());

			Collections.sort(ans);
			for(int x : ans) System.out.println(x);
			System.out.println("end");
		}
	}

	private static Point find(LinkedList< LinkedList<Integer> > list, int x){
		for(int i=0;i<list.size();i++){
			LinkedList<Integer> tmp = list.get(i);
			if(tmp.contains(x)) return new Point(i,tmp.indexOf(x));
		}
		return null;
	}

	private static void fall(LinkedList< LinkedList<Integer> > list,Point p){
		while(list.get(p.x).size() > p.y + 1){
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			tmp.add(list.get(p.x).removeLast());
			list.add(tmp);
		}
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    if ((i + 1) % 2 == 1) ans += s[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6

int main()
{
	int x,y;sca(x);sca(y);
	if((y-2*x)%2==0&&(y-2*x)/2<=x&&(y-2*x)>=0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;


int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    
    const long long inf = 1ll << 60;
    
    vector<vector<pair<int, long long>>> costa(n + 1, vector<pair<int, long long>>());
    vector<vector<pair<int, long long>>> costb(n + 1, vector<pair<int, long long>>());
    
    for (int i = 0; i < m; ++i)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        costa[u].push_back(make_pair(v, a));
        costa[v].push_back(make_pair(u, a));
        costb[u].push_back(make_pair(v, b));
        costb[v].push_back(make_pair(u, b));
    }
    
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
    vector<long long> dist(n + 1, inf);
    dist[s] = 0;
    q.push(make_pair(0, s));
    
    while(!q.empty())
    {
        pair<long long, int> p = q.top();
        q.pop();
        int v = p.second;
        
        if (dist[v] < p.first)
        {
            continue;
        }
        
        for (int i = 0; i < costa[v].size(); ++i)
        {
            pair<int, long long> edge = costa[v][i];
            long long cost = edge.second;
            int nextv = edge.first;
            
            long long nextd = dist[v] + cost;
            
            if (dist[nextv] > nextd)
            {
                dist[nextv] = nextd;
                q.push(make_pair(nextd, nextv));
            }
        }
        
    }
    
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q2;
    vector<long long> dist2(n + 1, inf);
    dist2[t] = 0;
    q2.push(make_pair(0, t));
    
    while(!q2.empty())
    {
        pair<long long, int> p = q2.top();
        q2.pop();
        int v = p.second;

        if (dist2[v] < p.first)
        {
            continue;
        }
        
        for (int i = 0; i < costb[v].size(); ++i)
        {
            pair<int, long long> edge = costb[v][i];
            long long cost = edge.second;
            int nextv = edge.first;
            
            long long nextd = dist2[v] + cost;
            
            if (dist2[nextv] > nextd)
            {
                dist2[nextv] = nextd;
                q2.push(make_pair(nextd, nextv));
            }
        }
        
    }
    
    
    vector<long long> retdist(n + 1, 0);
    for (int i = 1; i <= n; ++i)
    {
        retdist[i] = dist[i] + dist2[i];
    }
    
    for (int i = n - 1; i >= 1; --i)
    {
        retdist[i] = min(retdist[i + 1], retdist[i]);
    }
    
    long long ret = pow(10, 15);
    for (int i = 1; i <= n; ++i)
    {
        cout << ret - retdist[i] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 20764
from collections import defaultdict
n = int(input())
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
temp_list = sorted([(k, v) for k, v in d.items() if v >= 2], reverse=True)
if len(temp_list) >= 2:
    print(temp_list[0][0] ** 2 if temp_list[0][1] >= 4 else temp_list[0][0] * temp_list[1][0])
else:
    print(0)

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int h,n; cin>>h>>n;

  for (int i=0; i<n; i++) {
    int x; cin>>x;
	h-=x;
    if (h<=0) out("Yes");
  }
  cout<<"No"<<endl;
  

  return 0;
}


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

using namespace std;

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

	int ans = 3;
	for(int i = 1; i < n; i++){
		ans *= 3;
	}

	int even = 1;
	for(int i = 0; i < n; i++){
		if(a[i] % 2 == 0)even *= 2;
	}
	ans -= even;
	
	cout << ans << endl;

	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}


#include <stdio.h>
int main()
{
    long long int r[200001]={0}, i, j, n, max=-1000000000, c,prev;
    prev = 1000000001;
    scanf("%lld", &n);
    for(i = 0; i < n; i++){
        scanf("%lld", &r[i]);
    }
    for(i = 0; i < n; i++){
    	if (prev <= r[i]) continue;
        for(j = i + 1; j < n; j++){
            c = r[j] - r[i];
            if(c > max){
                max = c;
            }
        }
        prev = r[i];
    }
    printf("%lld\n", max);
    return 0;
}

Measured memory_bytes: 2760
N=int(input())
for n in range(1,N+1):
    ans=0
    for x in range(1,101):
        tx=x**2
        if tx>n-2*x :
            break
        for y in range(x,101-x):
            ty=tx+y**2+x*y
            if ty>n-x-y :
                break
            ss=(x+y)**2-4*(ty-n)
            if ss<0:
                break
            s=ss**0.5
            if s.is_integer():
                z=int((-1*(x+y)+s)/2)
                if z>=y:
                    
                    if len(set([x,y,z]))==1:
                        ans+=1
                    if len(set([x,y,z]))==2:
                        ans+=3
                    if len(set([x,y,z]))==3:
                        ans+=6
    print(ans)

Measured memory_bytes: 70800
def solve(ls):
    n = len(ls)
    s = 0
    for i in range(n):
        s ^= ls[i]

    result = [0] * n
    for i in range(n):
        result[i] = s ^ ls[i]
    return result


def main(istr, ostr):
    (n,) = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(ls)
    print(*result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 31544
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin>>N;
	vector<vector<int>> A(N,vector<int>(N,0));

	rep(i,0,N)rep(j,0,N)cin>>A[i][j];

	vector<int> SUM(1<<N,0);
	vector<int> DP(1<<N,0);

	rep(k,0,1<<N)
	{
		rep(i,0,N)
		{
			if(!((k>>i)&1))continue;
			rep(j,0,N)
			{
				if(!((k>>j)&1))continue;
				SUM[k]+=A[i][j];
			}
		}
		SUM[k]/=2;
	}

	rep(k,0,1<<N)
	{
		chmax(DP[k],SUM[k]);
		for(int s=k;s>0;s=(s-1)&k)
		{
			chmax(DP[k],DP[s]+DP[s^k]);
		}
	}

	cout<<DP[(1<<N)-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1280
fn getline() -> String{
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let s = getline();
    let inp:Vec<_> = s.trim().split(' ').collect();
    let a = inp[0].to_string().chars().collect::<Vec<char>>();
    let s = getline();
    let inp:Vec<_> = s.trim().split(' ').collect();
    let b = inp[0].to_string().chars().collect::<Vec<char>>();
    let mut ans = "EQUAL";
    if a.len() < b.len() {
        ans = "LESS";
    }else if a.len() > b.len() {
        ans = "GREATER";
    }else{
        for i in 0..a.len() {
            if a[i] > b[i] {
                ans = "GREATER";
                break;
            }else if a[i] < b[i] {
                ans = "LESS";
                break;
            }
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline

N,M,L = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]
Q = int(input())
ST = [list(map(int,input().split())) for _ in [0]*Q]


INF = (L+1)*N
d = [[INF]*N for _ in [0]*N]
for i in range(N):
    d[i][i] = 0
for a,b,c in ABC:
    a-=1;b-=1
    d[a][b] = c
    d[b][a] = c

def Warshall_Floyd(d,N=None):
    if N==None : N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])

Warshall_Floyd(d,N)

d2 = [None]*N
for i,row in enumerate(d):
    d2[i] = [1 if e<=L else INF for e in row]
    d2[i][i] = 0

Warshall_Floyd(d2,N)

for s,t in ST:
    s-=1;t-=1
    ans = (d2[s][t]%INF)-1
    print(ans)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    ll N;
    cin >> N;
    double avg = 0;
    vector<double> A(N, 0);
    REP(i, N) {
        cin >> A[i];
        avg += A[i];
    }
    avg /= static_cast<double>(N);
    pair<ll, double> ans = make_pair(0, A[0]);
    for(ll i = 1; i < N; ++i) {
        if( abs(avg - ans.second) > abs(avg - A[i])) {
            ans = make_pair(i, A[i]);
        }
    }
    printf("%lld\n", ans.first);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
// #define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;


const int INF = 1e9;
int n, m;
int d[20][20];
int dp[20][(1 << 15) + 10];

signed main(){
    cin >> n >> m;
    int ans = 0;
    rep(i, 0, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
        ans += c;
    }
    vector<int> cost(1 << n);
    rep(i, 0, 1 << n){
        rep(j, 0, n){
            rep(k, 0, j){
                if((i & (1 << j)) && (i & (1 << k))){
                    cost[i] += d[j][k];
                }
            }
        }
    }
    rep(i, 0, 20) rep(j, 0, 1 << n) dp[i][j] = -INF;
    dp[0][1] = 0;
    rep(j, 0, 1 << n){
        rep(i, 0, n){
            if(dp[i][j] == -INF) continue;
            rep(k, 0, n){
                if(j & (1 << k)) continue;
                if(d[i][k] == 0) continue;
                chmax(dp[k][j + (1 << k)], dp[i][j] + d[i][k]);
            }
            int mask = (1 << n) - 1;
            mask ^= j;
            for(int k = mask; k; k = (k - 1) & mask){
                chmax(dp[i][j + k], dp[i][j] + cost[k + (1 << i)]);
            }
        }
    }
    cout << ans - dp[n - 1][(1 << n) - 1] << endl;
}

Measured memory_bytes: 2944
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        final int INF = Integer.MAX_VALUE;
        int[] dp = new int[n];
        Arrays.fill(dp,INF);

        dp[0] = 0;
        for(int i=0; i<n; i++){
            for(int j=1; j<=k && i+j<n; j++){
                dp[i+j] = Math.min(dp[i+j], dp[i] + Math.abs(h[i] - h[i+j]));
            }
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 49548
#include<iostream>
using namespace std;
int p, q; int gcd(int a, int b) { if (b == 0)return a; return gcd(b, a%b); }
int main() {
	cin >> p >> q; int res = 1; int r = gcd(p, q); q /= r;
	for (int i = 2; i*i <= q; i++) {
		if (q%i == 0) { res *= i; while (q%i == 0)q /= i; }
	}
	if (q >= 2)res *= q;
	cout << res << endl;
	return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<'\n'

const int N=233333;
const int M=400006;

int first[N], nxt[M], v[M];
bool b[N];
int n, m;
bool dfs(const int &k, const int &r) {
	b[k]=true;
	if (k==n) {
		return true;
	}
	if (!r) {
		return false;
	}
	for (int j=first[k]; j; j=nxt[j]) {
		if (!b[v[j]]) {
			if (dfs(v[j], r-1)) {
				return true;
			}
		}
	}
	return false;
}
		
int main(void) {
	memset(b, 0, sizeof(b));
	cin>>n>>m;
	int a, c;
	for (int i=1; i<=m; i++) {
		scanf("%d%d", &a, &c);
		v[i]=c; v[i+m]=a;
		nxt[i]=first[a];
		nxt[i+m]=first[c];
		first[a]=i; first[c]=i+m;
	}
	puts( dfs(1, 2) ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int rest = n % 500;
        if (rest > a) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int d;
    cin>>d;
    vector<ll> c(26),t(d);
    vector<vector<int>> s(d,vector<int>(26));
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<d;i++){
        int a;
        cin>>a;
        a--;
        t[i]=a;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int a,b,ans=0;
        vector<int> last(26,-1);
        cin>>a>>b;
        a--;
        b--;
        t[a]=b;
        for(int j=0;j<d;j++){
            last[t[j]]=j;
            ans+=s[j][t[j]];
            for(int k=0;k<26;k++) ans-=c[k]*(j-last[k]);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3628
#include <iostream>
//#include <vector>
//#include <string>

typedef long long ll;
//const ll INF = (ll)1e18;

ll H, W;

int main()
{
  ll N;
  std::cin >> N >> H >> W;

  ll ans = (N - H + 1) * (N - W + 1);
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll n;
  cin >> n;
  vec t(n),v(n);
  for(ll i=0;i<n;i++) cin >> t[i],t[i]*=2;
  for(ll i=0;i<n;i++) cin >> v[i],v[i]*=2;
  vec z(4e4+10);
  ll mv=0;
  ll ti=0;
  for(ll i=0;i<n;i++) {
    z[ti]=min(z[ti],v[i]);
    for(ll j=ti+1;j<=ti+t[i];j++) {
      z[j]=min(z[j-1]+1,v[i]);
    }
    ti+=t[i];
  }
  mv=0;
  double ans=0;
  for(ll i=ti-1;i;i--) {
    ans+=mv=min(mv+1,z[i]);
  }
  ans*=1/4.0;
  cout << fixed << setprecision(10) << ans << endl;
}

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

          using namespace std;
          typedef long long ll;
          ll s;
          int n;
int trt[4434];
          int main()
          {
            cin >> n;
            for(int i = 1; i <= n; i++)
              if(i % 3 && i % 5)
                s += i;
            cout << s;
          }

Measured memory_bytes: 3636
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> b;
		c = max(b, c);
		d += b;
	}
	if (d-c<=c)
	{
		cout << "No" << endl;

	}
	else
	{
		cout << "Yes" << endl;

	}
	//cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

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

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; }

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

string S;
int N;
stack<char> st;

int main(int argc, const char * argv[]) {
    cin >> S;
    N = S.length();

    int ans = 0;
    rep(i, N) {
        if (st.size() > 0 && st.top() != S[i]) {
            ans += 2;
            st.pop();

        } else {
            st.push(S[i]);
        }
    }

    output(ans);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<tuple<string, int, int>> v;
    for (int i = 0; i < n; ++i)
    {
        string s; int p;
        cin >> s >> p;
        v.emplace_back(s, -p, i + 1);
    }
    sort(all(v));
    for (int i = 0; i < n; ++i)
    {
        string s; int p, j;
        tie(s,p,j) = v[i];
        cout << j << '\n';
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j;
    int r,k;
    cin>>k>>r;
    if(k>=10)
    {
        cout<<r<<endl;
        return 0;
    }
    else
    {
        cout<<(r+(100*(10-k)))<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
c = 3.times.map{gets.chomp.split(" ").map(&:to_i)}
for i in 0..1
  for j in i+1..2
    for k in 0..1
      for l in k+1..2
        if c[i][k]+c[j][l] != c[i][l]+c[j][k]
          puts "No"
          exit
        end
      end
    end
  end
end
puts "Yes"

Measured memory_bytes: 1788
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    input! {
        a: u64, b: u64, n: u64
    };

    if n < b {
        println!("{}", (a * n / b) - (a * (n / b)));
    } else {
        println!("{}", (a * (b - 1) / b) - (a * ((b - 1) / b)));
    }
}


Measured memory_bytes: 2132