akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
ll a[100010];
ll cnt[100010];

int main(void) {
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cnt[a[i]]++;

	ll ans = 0;
	reps(X, 1, 100001) {
		chmax(ans, cnt[X - 1] + cnt[X] + cnt[X + 1]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    double T, X;
    cin >> T >> X;

    cout << fixed << T / X << endl;

    return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int h, w;
  while (cin >> h >> w) {
    if (h == 0 && w == 0) break;
    REP(i, h) {
      REP(j, w) {
        if ((i + j) % 2 == 0)
          cout << "#";
        else
          cout << ".";
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  Vi a(n,0),b(n,0);
  rep(i,0,n){
    cin >> a[i];
  }
  rep(i,0,n){
    cin >> b[i];
  }
  
  int maxx = 0;
  int sum = 0;
  
  repeq(i,0,n-1){
    sum = 0;
    repeq(j,0,i){
      sum += a[j];
    }
    
    //cout << sum << ' ';
    
    repeq(j,i,n-1){
      sum += b[j];
    }
    maxx = max(maxx,sum);
    
    //cout << sum << endl;
    
  }
  
  cout << maxx << endl;
}


Measured memory_bytes: 256
N, total = map(int, input().split())
A = list(map(int, input().split()))   
sumA = sum(A)
if total == sumA:
    print(N)
elif total > sumA:
    print(N-1)
else:
    A.sort()
    i, count = 0, 0
    while total > 0:
        total = total - A[i]
        if total >= 0: count += 1
        i += 1
    print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

int main(){
    string s;cin>>s>>s;
    if(s.size()%2!=0)cout<<"No"<<endl;
    else{
        ll sum=0,sum1=0;
        rep(i,s.size()/2)sum1+=s[i];
        for(int i=s.size()/2;i<s.size();i++)sum+=s[i];
        if(sum==sum1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll n;
	cin >> n;
	ll answer = 0;
	ll temp = 0;
	ll digit = 1;
	while (temp <= n  ) {
		for (int i = 1; i <= 9; i++) {
			temp += digit;
			if(temp<=n) {
				answer++;
			}
			else {
				break;
			}
		}
		digit *= 10;
	}
	cout << answer << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);
		long target = cin.nextLong();
		long tmp = 1L;

		for(long i=1L;i<=target;i++){
			tmp *=i;
			tmp %= (Math.pow(10, 9)+7);
		}

		System.out.println(tmp);
	}
}


Measured memory_bytes: 20564
#include<stdio.h>
#include<stdlib.h>
 
int main(){
  int d[2000], N, Y, flag, i, j;
  scanf("%d%d", &N, &Y);
  flag=0;
  for(i=0; i<=N; i++){
    if(i*10000>Y)continue;

    for(j=0; j<=N-i; j++){
      if(i*10000+j*5000+(N-i-j)*1000==Y){
        flag=1;
        break;
      }
    }

    if(flag)break;
  }

  if(flag)
    printf("%d %d %d\n", i, j, N-i-j);
  else
    printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
import sys

def get_gcd(a, b):
    if a < b:
        a, b = b, a

    if a % b == 0:
        return b
    else:
        return get_gcd(b, a % b)

def get_lcm(a, b, gcd):
    lcm = a * b // gcd
    return lcm

def main():
    while True:
        data = sys.stdin.readline().strip()
        if data is None or data == '':
            break

        nums = data.split(' ')
        a = int(nums[0])
        b = int(nums[1])
        gcd = get_gcd(a, b)
        lcm = get_lcm(a, b, gcd)
        print(gcd, lcm)
        
        
if __name__ == '__main__':
    main()
    

Measured memory_bytes: 7652
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
	return 0;
}

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

using namespace std;

int main()
{
string s;
int c=0;
cin>>s;
for(int i=0;i<s.size();i++)
{
    if(s[i]==s[i+1])c++;
}
if(c>=1)cout<<"Bad";
else cout<<"Good";
      return 0;
}


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


def main():
    m = int(input())
    sum = 0
    digits = 0
    for _ in range(m):
        d, c = map(int, input().split())
        sum += d * c
        digits += c

    ans = digits - 1 + (sum-1) // 9

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int main() {

	int n, k;
	cin >> n >> k;

	vector<ll> a(n);

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


	ll ans = 1<<30;
	for (int i = 0; i < n - k+1; i++) {
		
		ll al = a[i];
		ll ar = a[i + k-1];

		ll buf = 0;

		if (ar <= 0) {
			buf = abs(al);
		}
		else if (al >= 0) {
			buf = ar;
		}
		else {
			buf = abs(al) + abs(ar) + min(abs(al), abs(ar));
		}

		ans = min(ans, buf);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;

    vector<long long> v(n),b(n);

    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        b[i] = v[i];
    }

    long long ans = 0;
    for (int i = n - 2; i >= 0; i--) {
        b[i] += b[i + 1];
        b[i] %= mod;
        ans += (b[i + 1] * v[i]) % mod;
        ans %= mod;
    }

    cout << ans << "\n";

    
    return 0;
}


Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


ll modpow(ll x, ll n, ll md=MOD){
    ll res=1, dig=x;
    while(n){
        if(n&1) res = res*dig%md;
        dig = dig*dig%md;
        n /= 2;
    }
    return res;
}


int main(){
    ll n;   cin >> n;
    ll res = modpow(10, n)+modpow(8, n)%MOD;
    res -= modpow(9, n);
    res = (res+MOD)%MOD;
    res -= modpow(9, n);
    cout << (res+MOD)%MOD << endl;
}


Measured memory_bytes: 3616
from collections import deque
n = int(input())
ans = [-1] * n
ans[0] = 0
d = [[] for _ in range(n)]

for i in range(n - 1):
    u, v, w = map(int, input().split())
    d[u - 1].append([v - 1, w])
    d[v - 1].append([u - 1, w])

cnt = 0
queue = deque()
queue.append(0)
while queue:
    u = queue.pop()
    for v, w in d[u]:
        if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
            queue.append(v)


for i in range(n):
    print(ans[i])

Measured memory_bytes: 45892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

  int k = S.size();

  if (count(ALL(S), 'o') + (15-k) >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

int N;
int deg[MAXN+1],Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt;
LL mxt[MAXN+1]; int pos,mxd; int dep[MAXN+1],fa[MAXN+1];
inline void insert(int u,int v){
	deg[v]++; Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt;
} 
inline void dfs(int k,int Fa){
	dep[k]=dep[Fa]+1; fa[k]=Fa;
	if(dep[k]>mxd) mxd=dep[k],pos=k;
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue; 
		dfs(v,k);
	}
}
inline void dfs2(int k,int Fa){
	mxt[dep[k]]=max(mxt[dep[k]],(LL)deg[k]-(Fa?1:0));
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue;
		dep[v]=dep[k]+1;dfs2(v,k);
	}
}
int sta[MAXN+1],top;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read();
	for(int i=1;i<N;i++){
		int u=read(),v=read();
		insert(u,v); insert(v,u);
	} dfs(1,0); int s1=pos; pos=mxd=-1; dfs(s1,0);
	while(pos) sta[++top]=pos,pos=fa[pos];
	printf("%d ",(top+1)/2);
	for(int i=0;i<=N;i++) mxt[i]=1;
	if(top&1){
		int k=sta[(top+1)/2]; dep[k]=0;
		dfs2(k,0); LL ans=1;
		for(int i=0;i<=N;i++) ans=ans*mxt[i];
		for(int x=Root[k];x;x=Next[x]){
			int v=Node[x];
			for(int i=0;i<=N;i++) mxt[i]=1;
			dep[v]=dep[k]=0;
			dfs2(v,k); dfs2(k,v);
			LL ret=1; for(int i=0;i<=N;i++) ret=ret*mxt[i];
			ans=min(ans,ret*2);
		} printf("%lld\n",ans);
	} else{
		LL ans=1;
		int x=sta[top/2],y=sta[top/2+1];
		dep[x]=dep[y]=0; dfs2(x,y); dfs2(y,x);
		for(int i=0;i<=N;i++) ans=ans*mxt[i];
		printf("%lld\n",ans*2);
	}
	return 0;
}




Measured memory_bytes: 3796
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
for y in range(H):
    for x in range(W):
        if S[y][x] == ".":
            cnt = 0
            for c in range(8):
                nx = x + dx[c]
                ny = y + dy[c]
                if 0 <= nx <= W-1 and 0<= ny <= H-1:
                    if S[ny][nx] == "#":
                        cnt += 1
            S[y][x] = str(cnt)
for i in range(H):
    print(("".join(S[i])))




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

int n, k;
int a[5000];
bitset<5001> DP[5001];
bitset<5001> DQ[5001];

void pre() {
  DP[0][0] = true;
  DQ[0][0] = true;
  for (int i = 0; i < n; ++i) {
    DP[i + 1] = DP[i] | (DP[i] << a[i]);
    DQ[i + 1] = DQ[i] | (DQ[i] << a[n - 1 - i]);
  }
}

bool no_need(int i) {
  bitset<5001> x = DP[i];
  bitset<5001> y = DQ[n - 1 - i];
  
  const int lo = max(0, k - a[i]);
  const int hi = k;
  
  vector<int> p(k + 2);
  for (int i = 0; i <= k; ++i) {
    p[i + 1] = p[i] + y[i];
  }
  
  for (int i = 0; i < hi; ++i) {
    if (!x[i]) continue;
    int l = max(0, lo - i);
    int r = hi - i;
    if (p[r] - p[l] > 0) return false; 
  }
  return true;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  pre();
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += no_need(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)

const int N=3e3+5;
const int mod=998244353;

ll sumIndices[N][N];
int n,S,ar[N];

int solve(){
    ll ans=0;
    for(int i=1;i<=n;i++){
        sumIndices[0][i-1]=i;
        for(int j=1;j<=S;j++){
            // SUM OF THE INITIAL INDICES FORMING SUM J FROM 1..I INDEX
            if(j<ar[i]) sumIndices[j][i]=sumIndices[j][i-1];
            else sumIndices[j][i]=(
                sumIndices[j-ar[i]][i-1] // INC J
                +sumIndices[j][i-1] // EXCLUDING J
            )%mod;
        }
        if(ar[i]<=S) ans=ans+(sumIndices[S-ar[i]][i-1])*(n-i+1);
        ans%=mod;
    }
    return ans;
}

int main(){
    re n>>S;
    rep1(i,n) cin>>ar[i];
    pr solve();
    return 0;
}


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

using namespace std;

typedef long long ll;

#define FOR(a, b, i) for(int i=a; i<b; i++)
#define RFOR(a, b, i) for(int i=a; i>=b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1e9+7
#define newline cout<<"\n"


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    vector<int> h(n);
    FOR(0, n, i) cin>>h[i];

    vector<int> dp(n, 1e4+5);

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);

    FOR(2, n, i)
    {
        dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]));
    }

    cout<<dp[n-1]<<"\n";



    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int u[n - 1], v[n - 1], w[n - 1];
    vector<vector<pair<int, int>>> g(n);
    rep(i, 0, n - 1) {
        cin >> u[i] >> v[i] >> w[i];
        u[i]--;
        v[i]--;
        g[u[i]].push_back(make_pair(v[i], w[i]));
        g[v[i]].push_back(make_pair(u[i], w[i]));
    }

    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    int color[n];
    rep(i, 0, n) color[i] = -1;
    color[0] = 0;

    while (!q.empty()) {
        int now = q.front().first;
        q.pop();
        rep(i, 0, (int)g[now].size()) {
            int next_pos = g[now][i].first;
            int next_cost = g[now][i].second;
            if (color[next_pos] != -1) continue;
            if (next_cost % 2 == 0) color[next_pos] = color[now];
            else color[next_pos] = 1 - color[now];
            q.push(make_pair(next_pos, next_cost));
        }
    }

    rep(i, 0, n) cout << color[i] << endl;
    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main()//a=97 z=122 A=65 Z=90
{
    int a,b,c=0;
    int s[1010]={0};
    cin>>a>>b;
    for(int i=1;i<=a;i++) cin>>s[i];
    sort(s+1,s+1+a);
    for(int i=1;i<=b;i++) c+=s[i];
    cout<<c;
    }


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	vector<int> v(n);
	for(auto &i:v)
		cin>>i;
	sort(all(v));
	set<int> st;
	int ans=0;
	For(i,0,n-1){
		if((i>0 && v[i]==v[i-1]) || (i<n-1 && v[i]==v[i+1])){
			st.insert(v[i]);
			continue;
		}
		bool ac=true;
		for(int j=1;j*j<=v[i];j++){
			if(v[i]%j==0 && (st.count(j) || st.count(v[i]/j))){
				ac=false;
				break;
			}
		}
		if(ac) ans++;
		st.insert(v[i]);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 13420
/*
There was a time, looking through myself
Wanting to pretend
If I escaped, I could fill myself
I don't think you can
Been far and wide
But that hole inside
Never really leaves
When I went away, what I really left
Left behind was me

It's telling me
To be on my way home
Million miles away
I can't stay

Each passing day, every passing face
Seems like such a blur
I long to be
Home, silently
Lying next to her
Just to get back, by her side is all
All I need to be
Cause I went away
But what I really left
Left behind was me

I need to be
Getting on my way home
A million miles away
Million miles away
I can't take
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 510031;

int n;

int f[200][200],ans,P[200][200];
int cnt[200];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++){
		for (int j=0;j<10;j++){
			cin>>f[i][j];
		}
	}

	for (int i=1;i<=n;i++){
		for(int j=0;j<=10;j++){
			cin>>P[i][j];
		}
	}

	ans=-1e9;

	for (int mask=1;mask<(1<<10);mask++){
		for (int i=1;i<=n;i++){
			cnt[i]=0;
		}
		for (int i=1;i<=n;i++){
			for (int j=0;j<10;j++){
				if (f[i][j]==1&&(mask&(1<<j)))
					cnt[i]++;
			}
		}
		int score=0;
		for (int i=1;i<=n;i++){
			score+=P[i][cnt[i]];
		}
		ans=max(ans,score);
	}

	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(stdin io.Reader, stdout io.Writer) error {
	var t, x float32
	_, err := fmt.Fscanf(stdin, "%f %f", &t, &x)
	if err != nil {
		return err
	}
	ans := fmt.Sprint(t / x)
	buf := []byte(ans)

	stdout.Write(buf)
	return nil
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


int main() {
    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl; 
    return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    string s;
    cin >> s;
    s += '.';
   
    vector< int > r(s.size());
    whole(reverse, s);

    int k = 1;
    i64 ans = 0;
    map< int, i64 > cnt;
    cnt[0]++;
    range(i, 1, r.size()) {
        (k *= 10) %= 2019;
        (r[i] += (s[i] - '0') * k + r[i - 1]) %= 2019;
        ans += cnt[r[i]];
        cnt[r[i]]++;
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		ll int n,x,time,count=0;
      	string str;
      	cin >> n;
      vector<int> arr;
      	for(int i=0;i<n;i++){
        	cin >> x;
          arr.push_back(x);
        }
      int maxi = arr[0];
      	for(int i=1;i<n;i++){
        	if(arr[i]<maxi){
            	count += maxi - arr[i];
            }
          	else maxi = max(maxi,arr[i]);
        }
      cout << count << endl;
    }
}

Measured memory_bytes: 4312
# ?§£??¬??????
# ?????????????????????????????????...

n = gets.to_i
k = gets.to_i
panels = []
k.times { panels << gets.split.map(&:to_i) }

ans = []
panels.each do |(px, py)|
  ans << [n - px, n - py, py - 1, px - 1].min % 3 + 1
end

puts ans.join("\n")

Measured memory_bytes: 8808
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    int number = 1;
    cin >> n;
    vector<int> h;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        h.push_back(a);
    }

    int p = 0;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < i; j++){
            if(h[i] >= h[j]){
                p++;               
            }
        }
        if(p == i){
            number++;
        }
        p=0;
    }
    cout << number <<endl;
    return(0);
}

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

typedef struct{
  int p;
  int k;
  int *child;
}Node;

int depth(Node*,int,int);

int main(){
  int num,i,j,k,number;
  Node node[N]; 
  
  scanf("%d",&num);

  for(i=0; i<num; i++) node[i].p = -1;
  
  for(i=0; i<num; i++){
    scanf("%d",&number);
    scanf("%d",&node[number].k);
    node[number].child = (int *)malloc(sizeof(int) * node[number].k);
    for(j=0; j<node[number].k; j++){
      scanf("%d",&node[number].child[j]);
      node[node[number].child[j]].p = number;
    }
  }
  
  
  for(i=0; i<num; i++){
    printf("node %d: parent = %d, ",i,node[i].p);
    printf("depth = %d, ",depth(node,i,0));
    
    if(node[i].p==-1) printf("root, [");
    else if(node[i].k==0) printf("leaf, [");
    else printf("internal node, [");
    
    for(j=0; j<node[i].k; j++){
      printf("%d",node[i].child[j]);
      if(j+1<node[i].k) printf(", ");
    }
    printf("]\n");
  }
  

  return 0;
}


int depth(Node *node,int num,int count){
  if(node[num].p==-1)return count;
  count++;
  count = depth(node,node[num].p,count);

  return count;
}

Measured memory_bytes: 5692
N = gets.to_i
S = N.times.map{
	gets.strip.chars.map{|_| _=='1' }
}

Ds = lambda{|dbase|
	ds, d, q = [nil]*N, 1, {dbase=>true}
	ds[dbase] = d
	until q.empty?
		r = {}
		q.keys.each{|i|
			(0...N).each{|j|
				next unless S[i][j]
				if ds[j].nil?
					ds[j] = d+1
					r[j] = true
				elsif ds[j] == d+1
				elsif ds[j] == d-1
				else
					raise
				end
			}
		}
		q, d = r, d+1
	end
	return ds
}
begin
	p (0...N).map{|i| Ds[i].max }.max
rescue RuntimeError
	p(-1)
end


Measured memory_bytes: 4476
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
#include <forward_list>
#include <algorithm>
#include <tuple>

using namespace std;

struct edge {
  int to, cost, id;
};

using graph = vector<vector<edge>>;
auto dijkstra(graph const& gr, int start) {
  int const V = gr.size();
  constexpr int Inf = numeric_limits<int>::max() / 2;
  vector<pair<int, forward_list<int>>> result(V, {Inf, forward_list<int>()}); 
  using P = pair<int, int>;
  priority_queue<P, vector<P>, greater<P>> que;
  que.emplace(0, start);
  result[start].first = 0;
  while (!que.empty()) {
    int v, d;
    tie(d, v) = que.top();
    que.pop();
    if (d > result[v].first) continue;
    for (auto&& e : gr[v]) {
      if (result[e.to].first < d + e.cost) continue;
      if (result[e.to].first > d + e.cost)
        result[e.to].second.clear();
      result[e.to].first = d + e.cost;
      result[e.to].second.push_front(e.id);
      que.emplace(d + e.cost, e.to);
    }
  }
  return result;
}

int main() {
  int n, m;
  cin >> n >> m;
  graph gr(n);
  for (int i = 0; i < m; i++) {
    int a, b, cost;
    cin >> a >> b >> cost;
    a--; b--;
    gr[a].push_back({b, cost, i});
    gr[b].push_back({a, cost, i});
  }
  vector<bool> used(m, false);
  for (int i = 0; i < n; i++) {
    auto const& ds = dijkstra(gr, i);
    for (auto& v : ds)
      for (auto k : v.second)
        used[k] = true;
  }
  cout << count(begin(used), end(used), false) << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;

int main()
{
  int N; scanf("%d", &N);
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }

  vector<vector<int>> freqs(N, vector<int>(128, 0));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < (int)S[i].size(); ++j) {
      ++freqs[i][S[i][j] - 'a'];
    }
  }

  string ans = "";
  for (int i = 0; i < 26; ++i) {
    int cnt = INF;
    for (int j = 0; j < N; ++j) {
      cnt = min(cnt, freqs[j][i]);
    }
    if (cnt > 0) {
      ans += string(cnt, (char)('a' + i));
    }
  }
  printf("%s\n", ans.c_str());
  return 0;
}


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

int main()
{
	using namespace std;
	int h = 0;
	char a;
	char b[5] = { 'a', 'e', 'i', 'o', 'u' };
	cin >> a;
	for (int i = 0; i <= 5;i++) {

		if (b[i] == a) {
			h++;
		}
	}
	if (h != 0) {
		cout << "vowel";
	}
	else {
		cout << "consonant";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=998244353;
ll INF=1e18;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}
void solve()
{
     ll n,x,k;
     cin>>n>>x>>k;
     ll i;
     vector<ll> v;
     map<ll,ll> mp;
     v.pb(x);
     mp[x]=0;
     ll len=1;
     ll prev=x;
     while(1)
     {
          ll curr = (prev*prev)%k;
          // cout<<curr<<"#\n";
          if(mp.find(curr)==mp.end())
          {
               v.pb(curr);
               mp[curr]=len;
               prev=curr;
               len++;
          }
          else 
          {
               prev=curr;
               break;
          }
     }
     ll loopstart = mp[prev];
     ll looplen = (len-loopstart);
     ll ans=0;
     
     // cout<<loopstart<<" "<<looplen<<"!!\n";
     if(n<loopstart)
     {
          for(i=0;i<n;i++)
               ans+=v[i];
          cout<<ans;
          return ;
     }
     for(i=0;i<loopstart;i++)
          ans+=v[i];
     ll sum=0;
     for(i=loopstart;i<len;i++)
          sum+=v[i];
     ll times = (n-loopstart)/looplen;
     ll rem =   (n-loopstart)%looplen;
     ans+= sum*times;
     for(i=0;i<rem;i++)
          ans+=v[loopstart+i];
     cout<<ans;

     
     
}

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


Measured memory_bytes: 6740
grid = []
for i in range(3):
    grid.append([int(i) for i in input().split()])

for _ in range(100):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    if  grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3 and grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;++i) {
    cin>>a[i];
    a[i]--;
  }
  int ans = -1;
  int now = 0;
  for(int i=0;i<=N;++i) {
    if(now==1) {
      ans = i;
      break;
    }
    now = a[now];
  }
  cout<<ans<<endl;
}


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

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;

    vector<int> c(m+1);

    vector<int> tmp(3, 0);

    // 同じコインをいくつでも使ってよいとき、i種類のコインを使ってj円支払うときの最小枚数dp[i][j]
    vector<vector<int> > dp(m+1, vector<int>(n+1, 0));

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

    // 初期条件
    for(int j = 0; j <= n; j++) {
        if(j == 0) {
            dp[0][j] = 0;
        } else {
            dp[0][j] = 50000;
        }
    }

    // dp開始
    for(int i = 1; i <= m; i++) {
        for(int j = 0; j <= n; j++) {
            if(j - c[i] >= 0) {
                tmp = {};
                tmp.push_back(dp[i-1][j - c[i]] + 1);
                tmp.push_back(dp[i-1][j]);
                tmp.push_back(dp[i][j - c[i]] + 1);
                sort(tmp.begin(), tmp.end());
                dp[i][j] = tmp.front();
                // dp[i][j] = min({dp[i-1][j - c[i]] + 1, dp[i-1][j], dp[i][j - c[i]] + 1});
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[m][n] << endl;
	return 0;
}


Measured memory_bytes: 7120
import java.util.*;
public class Main {

	public static int finddiff(String s, String t)
	{
		int res = 0;
		if(t.length()>s.length())
			return Integer.MAX_VALUE;
		for(int i=0;i<t.length();i++)
				if(t.charAt(i)!=s.charAt(i))
					res++;
		return res;
	}
	public static void main(String[] args) {		
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		String t = scn.next();
		int min = t.length();
		for(int i=0;i<=s.length()-t.length();i++)
		{
			int val = finddiff(s.substring(i),t);
			if(min>val)
				min = val;
		}
		System.out.println(min);
	}
// codeforces coderraces
}


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

int main() {
  int N;
  cin >> N;
  int d[N];
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d, d + N, greater<int>());

  int max = 0;
  int prev = 0;
  for (int i = 0; i < N; i++) {
    if (d[i] != prev) {
      max++;
      prev = d[i];
    }
  }

  cout << max << endl;
  return 0;
}

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


int main(){
    int n,k;
    string s;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    int ans=0;
    rep(i,k){
       ans+=v[n-1-i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
/*
ID: sstfmsc1
TASK: milk2
LANG: C++
*/
#include <bits/stdc++.h>
 
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( int i = 0; i < (int)n; ++i )
#define MAXN 50000
#define INF 1000000
typedef long long ll;
const char nl = '\n';
ll MOD = (ll)(1e9 + 7);
 
void solve()
{
    int n; cin >> n;

    vector<ll> a(n);
    ll suma = 0;
    forin(i, n) { cin >> a[i]; suma += a[i]; }

    ll ans = 0;
    forin(i, n)
    {
        suma -= a[i];
        //cout << suma << nl;
        //cout << ( ( a[i] % MOD ) * ( suma % MOD ) ) % MOD << nl;
        ans = ( ans + ( ( a[i] % MOD ) * ( suma % MOD ) ) % MOD ) % MOD;

        //cout << ans << nl << nl;
    }

    cout << ans << nl;
    return;
}
 
int main()
{
    //freopen("milk2.in", "r", stdin);
    //freopen("milk2.out", "w", stdout);
    IOS
 
    solve();
    
    
    return 0;
}

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

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

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

using namespace std;

int main()
{
	double x1, y1, x2, y2, x3, y3;
	double px, py, r;
	int n;
	cin >> n;
	
	cout << fixed << setprecision(3);
	
	for (int i=0; i<n; i++) {
		cin >> x1; cin >> y1; cin >> x2; cin >> y2; cin >> x3; cin >> y3;

		double a,b,c,d,e,f;
		a = 2 * (x2 - x1);
		b = 2 * (y2 - y1);
		c = 2 * (x3 - x1);
		d = 2 * (y3 - y1);
		e = x2 * x2 + y2 * y2 - x1 * x1 - y1 * y1;
		f = x3 * x3 + y3 * y3 - x1 * x1 - y1 * y1;
		
		if (a*d==b*c) continue;
		
		double D = a*d - b*c;
		
		px = (d*e  - b*f) / D; px += 0;
		py = (-c*e + a*f) / D; py += 0;
		r  = sqrt((x1-px)*(x1-px) + (y1-py)*(y1-py));
		
		cout << px << " " << py << " " << r << endl;
	}
	
	return 0;
}

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

using namespace std;

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

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//









Int n, a;
vector<Int> x(n);

Int memo[55][55][2555];

Int rec(int idx, int maisuu, int sum){
        if(idx >= n){
                return ((maisuu*a)==sum) && (sum != 0);
        }

        if(memo[idx][maisuu][sum] != -1){
                return memo[idx][maisuu][sum];
        }

        Int ret = 0;

        Int yes = rec(idx+1, maisuu+1, sum+x[idx]);

        Int no = rec(idx+1,maisuu,sum);

        ret += yes + no;

        return memo[idx][maisuu][sum] = ret;
}

int main(){
        cin >> n >> a;
        x.resize(n);
        for(Int i = 0; i < n ; i++) cin >> x[i];

        memset(memo,-1,sizeof(memo));

        Int ans = rec(0,0,0);

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 60672
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int n,m;
    string s,t;
    cin>>n>>m;
    cin>>s>>t;
    int lcm=(n*m)/__gcd(n,m);
    map<int,int>no;
    f(i,0,n-1)
    {
        int val=(i*lcm)/n;
        no[val]=i;
    }
    f(i,0,m-1)
    {
        int val=(i*lcm)/m;
        if(no.count(val)==0)continue;
        int x=i;
        int y=no[val];
        if(s[y]!=t[x])
        {
            cout<<"-1"<<endl;
            return 0;
        }
    }
    cout<<lcm<<endl;
    return 0;

}





































Measured memory_bytes: 6144
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
    int N, W;
    cin >> N >> W;

    vector<int> weights(N);
    vector<ll> costs(N);

    for(int i = 0; i < N; ++i)
        cin >> weights[i] >> costs[i];

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

    for(int w = 0; w < W + 1; ++w) {
        for(int i = 0; i < N; ++i) {
            if(i - 1 >= 0)
                dp[w][i] = dp[w][i - 1];

            ll wo = w - weights[i];
            if(wo < 0)
                continue;
            ll prev = 0;
            if(i - 1 >= 0)
                prev = dp[wo][i - 1];

            dp[w][i] = max(dp[w][i], prev + costs[i]);
        }
    }

    cout << dp[W][N - 1] << endl;

    return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, b; cin >> a >> b;
    if(a+b == 15) cout << "+" << endl;
    else if(a*b == 15) cout << "*" << endl;
    else cout << "x" << endl; 
}

Measured memory_bytes: 256
from collections import deque

def bfs(meiro, start_x, start_y):
    visited = []
    for i in range(len(meiro)):
        visited.append([])
        for j in range(len(meiro[i])):
            visited[i].append(0)

    stack = deque()
    stack.append([start_x, start_y])
    visited[start_x][start_y] = 0
    max_distance = 0
    while len(stack) != 0:
        x, y = map(int, stack.popleft())
        distance = visited[x][y]
        for items in [[-1, 0], [0, -1], [1, 0], [0, 1]]:
            x_n = x + items[0]
            y_n = y + items[1]
            if x_n < 0 or x_n >= H or y_n < 0 or y_n >= W or (start_x == x_n and start_y == y_n) or visited[x_n][y_n] != 0 or meiro[x_n][y_n] == "#":
                continue
            stack.append([x_n, y_n])
            visited[x_n][y_n] = distance+1
            if max_distance < distance+1:
                max_distance = distance+1
    return max_distance

H, W = map(int, input().split())
meiro = []
for h in range(H):
    meiro.append(list(input()))

max_dist = 0
for h in range(H):
    for w in range(W):
        if meiro[h][w] == ".":
            dis = bfs(meiro, h, w)
            if max_dist < dis:
                max_dist = dis
print(max_dist)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f;
	cin>>n;
	if(n<=2){cout<<0;exit(0);}
	vc dp(n+1,1);
	for(i=4;i<=n;i++)
	{
	    for(j=3;i-j>=3;j++)
	        dp[i]=(dp[i]+dp[i-j])%MOD;
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 3568
x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))

q = list(map(int,input().split()))

r = list(map(int,input().split()))

p.sort(reverse=True)

q.sort(reverse=True)

r.sort(reverse=True)

ans = []

for i in range(x):
    ans.append(p[i])

for i in range(y):
    ans.append(q[i])

ans = ans + r

ans.sort(reverse=True)

print(sum(ans[:x+y]))


Measured memory_bytes: 115820
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<int> V(N), P(N), Q(N);

    rep(i, N) { V[i] = i; }

    rep(i, N) {
        int p;
        cin >> p;
        p--;
        P[i] = p;
    }

    rep(i, N) {
        int q;
        cin >> q;
        q--;
        Q[i] = q;
    }

    int a = 0, b = 0, cnt = 0;
    do {
        cnt++;
        bool judge1 = true, judge2 = true;
        rep(i, N) {
            if (V[i] != P[i]) {
                judge1 = false;
            }
            if (V[i] != Q[i]) {
                judge2 = false;
            }
        }
        if (judge1)
            a = cnt;
        if (judge2)
            b = cnt;
    } while (next_permutation(all(V)));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)

ans1 = X_sort[N // 2 - 1]
ans2 = X_sort[N // 2]
#print(X_sort)
for i in range(N):
  if X[i] <= ans1:
    print(ans2)
  else:
    print(ans1)





Measured memory_bytes: 25220
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int main(){
  int n ;
  cin>>n;
  int ans[10][10];
  rep(i,10)rep(j,10)ans[i][j]=0;

  rep(i,n+1){
    if(i==0)continue;
    string s = to_string(i);
    ans[s[0]-'0'][s[s.size()-1]-'0']++;
  }
  ll res =0;
  for(int i = 1;i<10;i++)for(int j =1;j<10;j++){
    //cout<<ans[i][j]<<endl;
    if(i==j){
    res+=pow(ans[i][j],2);}
    else{
      res+=ans[i][j]*ans[j][i];
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256