akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int> edges[100007];
vector<int> visited(1e5+7);
vector<int> indeg(1e5+7);
vector<int> maxd(1e5+7);
void dfs(int i)
{
  visited[i]=true;
  for(int x:edges[i])
  {
    maxd[x]=max(maxd[x],maxd[i]+1);
    visited[x]=true;
    --indeg[x];
    if(indeg[x]==0)
    dfs(x);
  }
}

int main()
{ 
  int n,e;
  cin>>n>>e;
  int a,b;
  while(e--)
  {
    cin>>a>>b;
    edges[a].push_back(b);
    ++indeg[b];
  }
  for(int i=1;i<=n;i++)
  {
    if(!visited[i]&&indeg[i]==0)
    dfs(i);
  }
  int ans=0;
  for(int x:maxd)
  {
    if(x>ans)
    ans=x;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 9984
class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*) / k.factorial
  end

  def permutation(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*)
  end

  def factorial
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end

n, k = gets.split.map( &:to_i)
1.upto(k) do |i|
  if i > n - k + 1
    puts 0
  else
    puts (n - k + 1).combination(i)  * (k - 1).combination(i - 1) % (10 ** 9 + 7)
  end
end


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000005,M=998244353;
int n,m,fac[N],inv[N],ans;
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
int C(int x,int y){
	return fac[x]*inv[y]%M*inv[x-y]%M;
} 
signed main(){
	scanf("%lld%lld",&n,&m);
	fac[0]=inv[0]=1;
	for (int i=1;i<=max(n,m);i++){
		fac[i]=fac[i-1]*i%M;
		inv[i]=ksm(fac[i],M-2);
	}
	for (int i=min(n,m);~i;i--)(ans+=ksm(n+1,m-i)*ksm(m+1,n-i)%M*ksm(M-1,i)%M*C(n,i)%M*C(m,i)%M*fac[i])%=M;
	printf("%lld\n",ans);
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long int T;
  cin >> N>>T;
  vector<long long int> sugita(N);
  cin >> sugita.at(0);
  long long int ans=0;
  for(int i=1;i<N;i++){
    cin >> sugita.at(i);
    if (sugita.at(i)-sugita.at(i-1) >T) ans += T;
    else ans+=sugita.at(i)-sugita.at(i-1);
  }
  ans += T;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,ans;map<int,int>M;
int main() {cin>>n;
	for (int i=1,x;i<=n;i++)
		cin>>x,++M[x];
	for (map<int,int>::iterator it=M.begin();it!=M.end();it++)
		if ((*it).second&1) ans++;
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

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

		Integer r = sc.nextInt();
		Integer g = sc.nextInt();
		Integer b = sc.nextInt();

		Integer k = sc.nextInt();

		for (Integer i = 0; i < k; i++) {

			if (g <= r) {
				g *= 2;
				continue;
			} else if (b <= g) {
				b *= 2;
				continue;
			}
		}

		if (r < g && g < b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");

		}

	}

}

Measured memory_bytes: 35780
import qualified Data.ByteString.Char8 as B
import Data.Maybe

main = do
    [d,t,s] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    putStrLn $ answer d t s

answer d t s
    | t*s >= d = "Yes"
    | otherwise = "No"

Measured memory_bytes: 3772
#include <stdio.h>

int main(){
  int n,y;
  scanf("%d%d",&n,&y);
  int i,j,k;
  for(i=0;i<=n;i++)for(j=0;j<=n-i;j++){
    k=n-i-j;
    if(i*10000+j*5000+(k)*1000 == y){
      printf("%d %d %d\n",i,j,k);
      return 0;
    }
  }
  
  printf("-1 -1 -1\n");
  return 0;
}
 


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  int A,B;
  cin >> A >>B ;
  if(A==B)
    cout << A*2 << endl;
  else
    cout << max(A,B)*2-1 << endl;
}


Measured memory_bytes: 256
#ABC115C-ChristmasEve.py

from sys import stdin

input = stdin.readline

N, K = list(map(int, input().split()))

h = [int(input()) for _ in range(N)]
h.sort()

hdiff = [None]*(N-K+1)

for i in range(N-K+1):
    hdiff[i] = h[i+K-1] - h[i]

print(min(hdiff))


Measured memory_bytes: 11036
#if 0
time: 30min

dp[i][j] = min( dp[i???1][j] , dp[i][j???c[i]]+1 )
					||
dp[i] = min ( dp[j] , dp[j-c[i]]+1 )					
#endif

#include <iostream>  
using namespace std;  
 
  
const int MAX_NUM = 50010;  
const int MAX_WEIGHT = 50000+20;  

   
int c[MAX_NUM];  
 
int dp[MAX_WEIGHT];  
  

void Solve( int n, int m )  
{     
	for (int i=0; i<m; i++ )  
	{  
		for (int j=c[i]; j<=n; j++)  
		{   
			dp[j] = min(dp[j],dp[j-c[i]]+1);      	         
		}  
	}  
	cout << dp[n] << endl;  
}  

int main()  
{    
	int n, m;  
	cin >> n >> m;        
	for (int i=0; i<m; i++ )  
	{  
		cin >> c[i];  
	}  
	for (int i=1; i<=n; i++)
	{
		dp[i] = 50000+10;
	}
	Solve( n, m );  
 
	return 0;  
}  

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

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

    int tn = n % 10;
    if (tn == 3)
        cout << "bon" << endl;
    else if (tn == 0 || tn == 1 || tn == 6 || tn == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int x[2];
	while(1){
	cin>>x[0]>>x[1];
	if(x[0]==0 && x[1]==0)
		break;
	sort(x,x+2);
	cout<<x[0]<<" "<<x[1]<<endl;
    }
	return 0;
}

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

using namespace std;

int main()
{
    int n,k,x,y;
    int s1=0,s2=0;

    cin>>n>>k>>x>>y;

    if((n-k)>0)
    {
        s1 = k*x;
        s2 = (n-k)*y;
    }

    else
    {
        s1 = n*x;
    }

    cout<<s1+s2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[200005];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; ++i)
        cout << a[i] << '\n';
}


Measured memory_bytes: 4328
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
#define sz(x)                 (int)(x.size())
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.14159265358979;

#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; scanf("%d", &_x); return _x; }
long long lin() {long long _x; scanf("%lld", &_x); return _x; };

signed main() { 
        int h, w;
        cin >> h >> w;
        int ans = INF;
        int s1, s2, s3;
        rep(f, 2) {
                if (f == 1) swap(h, w);
                reu(i, 1, h) {
                        s1 = w * i;
                        int hh = h - i;
                        int hhh = hh / 2;
                        int hhhh = hh - hhh;
                        s2 = hhh * w;
                        s3 = hhhh * w;
                        amin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
                        int ww = w / 2;
                        int www = w - ww;
                        s2 = hh * ww;
                        s3 = hh * www;
                        amin(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
                }
        }
        cout << ans << endl;
        return 0;
}               



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

int main() {
	int n, d[101], sum=0;
	cin>>n; for(int i=0;i<n;i++) cin>>d[i];
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			sum+=d[i]*d[j];
		}
	}
	cout<<sum;
	return 0;
}

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if ((b - a + 1) <= k * 2) {
    for (int i = a; i <= b; i++) {
      cout << i << endl;
    }
  }
  else {
    for (int i = 0; i < k; i++) {
      cout << i + a << endl;
    }
    for (int i = k - 1; i >= 0; i--) {
      cout << b - i << endl;
    }
  }
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main ()
{
 int n;
 cin>>n;
 int a=n%10;
 if(a==2 || a==4 || a==5 || a==7 || a==9) {cout<<"hon"<<endl;return 0;}
 if(a==0 || a==1 || a==6 || a==8) {cout<<"pon"<<endl;return 0;}
  if(a==3 ) {cout<<"bon"<<endl;return 0;}
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fifo ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define ll long long int
#define w(t) ll t; cin>>t; while(t--)
#define pb push_back
#define vll vector<long long int>
#define vi vector<int>
#define mp make_pair
/*
ll GCD(ll a,ll b)
{
	if(b==0)
	return a;
	else
	return GCD(b,a%b);
}

ll LCM(ll a,ll b){return a/GCD(a,b)*b;}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}

ll x,y,d;       //d is gcd x and y are coefficients
void exten_euclid(ll a,ll b)
{	ll temp;
	if(b==0)
	{
		d=a;
		x=1;
		y=0;	
	}
	else
	{
		exten_euclid(b,a%b);
		temp=x;
		x=y;
		y=temp-(a/b)*y;	
	}
return;
}

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


bool isPrime(ll n) {
	if(n==1)
      return false;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;               //O(root(N))
        }
    }
    return true;
}

vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

/*************FACTORIZE IN 0(LOG(N)) PROVIDED N IS INTEGER**************

int minPrime[100000];

void modified_sieve(int n){
for (int i = 2; i * i <= n; ++i) {
    if (minPrime[i] == 0) {         //If i is prime
        for (int j = i * i; j <= n; j += i) {
            if (minPrime[j] == 0) {
                minPrime[j] = i;
            }
        }
    }
}
for (int i = 2; i <= n; ++i) {
    if (minPrime[i] == 0) {
        minPrime[i] = i;
    }
}
}

vector<int> factorize(int n) {
    vector<int> res;
    while (n != 1) {
        res.push_back(minPrime[n]);
        n /= minPrime[n];
    }
    return res;
}

/*************************************************
void sieve(int N) {
        bool isPrime[N+1];
        for(int i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }


ll binomialCoeff(ll n, ll k)  
{  
     ll res = 1; 
	if(n<k)
	return 0; 
  
    // Since C(n, k) = C(n, n-k)  
    if ( k > n - k )  
        k = n - k;  
  
    // Calculate value of  
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
    for (ll i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
}  

*/
int main()
{
fifo;
ll n;
cin>>n;
ll a=n/500;
ll b=n%500;
ll c=b/5;
ll d=b%5;
ll ans=1000*a+c*5;
cout<<ans;
return 0;
}

Measured memory_bytes: 256
n, k = (map(int, input().split()))
p = list(map(int, input().split()))

s = sum(p[:k])
left = p[0]
m = s
for i in range(n - k):
    s = s - p[i] + p[i + k]
    m = max(m, s)

ans = (k + m) / 2
print(ans)

Measured memory_bytes: 24812
n = int(input())

ans = int(0)

if n < 10:
  ans = n
if 100 > n and n >= 10:
  ans = 9
if 1000 > n and n >= 100:
  ans = n-90
if 10000 > n and n >= 1000:
  ans = 909
if 100000 > n and n >= 10000:
  ans = n-9090
if 100000 == n:
  ans = 90909

print(ans)



Measured memory_bytes: 3060
# Author: cr4zjh0bp
# Created: Sun Mar  8 12:19:06 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

A, B, M = na()
a = na()
b = na()
xyc = nan(M)
ans = min(a) + min(b)
for i in range(M):
    x, y, c = xyc[i]
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)

print(ans)

Measured memory_bytes: 38428
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
using namespace std;
int main(){
    int N;  cin>>N;
    if(N<105){
        cout<<"0"<<endl;
        return 0;
    }
    if(N>=105&&N<135){
        cout<<"1"<<endl;
        return 0;
    }
    if(N>=135&&N<165){
        cout<<"2"<<endl;
        return 0;
    }
    if(N>=165&&N<189){
        cout<<"3"<<endl;
        return 0;
    }
    if(N>=189&&N<195){
        cout<<"4"<<endl;
        return 0;
    }
    cout<<"5"<<endl;
}

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

int main() {

  while( true ) {

    long long int x, y, s;
    cin >> x >> y >> s;
    if ( s == 0 ) break;

    x += 100;
    y += 100;

    long long int ans = 0;

    for ( long long int i = 1; i < s; i++ ) {

      for ( long long int j = 1; j < s; j++ ) {

	if ( i * x / 100 + j * x / 100 != s ) continue;
	ans = max( ans, i * y / 100 + j * y / 100 );

      }

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1156
h,w = map(int,input().split())
c = []
for i in range(10):
    tmp = list(map(int,input().split()))
    c.append(tmp)
    
for i in range(10): ##経由する頂点
    for j in range(10): ## 始点
        for k in range(10): ## 終点
            c[j][k] = min(c[j][k] , c[j][i] + c[i][k])
            
            
num_list = [0]*10
for i in range(h):
    tmp = list(map(int,input().split()))
    for j in tmp:
        if j != -1:
            num_list[j] += 1
ans = 0      
for i in range(len(num_list)):
    ans += c[i][1]*num_list[i]
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
#define mod  1000000007
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
ll i, j, k;
void solve(){
    ll a , b; cin >> a >> b;
    if(a<b){
       for(i = 0; i <b; i++) cout<<a;
        cnl;
    }
    else {
      for(i = 0 ;i < a; i++) cout<<b;
        cnl;
    }
           

     return ; 
} 
    signed main(){
   
    //CASET
    solve();
    
   
    return 0;
  }

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

int main(){
    ll h, a;  cin >> h >> a;
    ll sum = 0;
    for(int i = 0; i < a; i++){
        ll mid; cin >> mid;
        sum += mid;
    }
    if(h <= sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (b - 1 + a - 2) / (a - 1) << "\n";

    return 0;
}


Measured memory_bytes: 256
require 'set'
Move = [ [2, -1, -1, -1],
         [2, 5, -1, -1], [0, 1, 3, 6], [2, 7, -1, -1],
         [5, -1, -1, -1], [1, 4, 6, 9], [2, 5, 7, 10], [3, 6, 8, 11], [7, -1, -1, -1],
         [5, 10, -1, -1], [6, 9, 11, 12], [7, 10, -1, -1],
         [10, -1, -1, -1] ]
R = [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4]
C = [2, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 2]
 

while n = gets.to_i
  break if n == -1
  brd = [n, 4.times.map{ gets.split.map(&:to_i) } ].flatten
  q = [[brd, 0]]
  ans = -1
  set = SortedSet.new([])
  set.add(brd)
  until q.empty?
    b, d = q.shift
    if (1..11).all?{ |v| b[v] == v }
      ans = d
      break
    end
    x = d
    13.times do |i|
      if b[i] > 0
        [R, C].each do |a|
          x += (a[i] - a[b[i]]).abs
        end
      end
    end
    unless x > 20
      13.times do |i|
        if b[i] == 0
          4.times do |j|
            unless Move[i][j] == -1
              b[i], b[Move[i][j]] = b[Move[i][j]], b[i]
              unless set.include?(b)
                set.add(nb = b.dup)
                q << [nb, d + 1]
              end
              b[i], b[Move[i][j]] = b[Move[i][j]], b[i]
            end
          end
        end
      end
    end
  end
  puts ans == -1 ? 'NA' : ans
end

Measured memory_bytes: 12608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int N, M;
vector<int>G[10];
bool visited[10];
int ans = 0;
void dfs(int n, int cnt) {
	if (visited[n])return;
	if (cnt == N - 1) {
		ans++;
		return;
	}
	visited[n] = true;
	for (auto e : G[n]) {
		dfs(e, cnt + 1);
	}
	visited[n] = false;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < 10; ++i) {
		visited[i] = false;
	}
	dfs(0, 0);
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Wed 08/07/2020
 * 23:27:06.51
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(all(v));
    double ans = v[0];
    for(int i = 1; i < n; ++i) {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
  

int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  for(int i = k; i < n; ++i) {
    if(a[i] <= a[i-k]) cout << "No" << endl;
    else cout << "Yes" << endl; 
  }
}

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

int main(){
	string S;
	cin >> S;
	int l = S.size();
	int cnt = l/2;
	int ans = 0;

	for(int i=0;i<cnt;i++){
		if(S[i]!=S[l-1-i]) ans++;
	}
	cout << ans <<endl;
}



Measured memory_bytes: 256
def init(n):
    global par, rank
    par = [i for i in range(n)]
    rank = [0] * n

def find(x):
    global par
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    global par, rank
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

def same(x, y):
    return find(x) == find(y)

N, M = map(int, input().split())
init(N + M)
for i in range(N):
    a = list(map(int, input().split()))
    for L in a[1:]:
        unite(i, L - 1 + N)
ans = "YES"
for i in range(N):
    if not same(0, i):
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 12592
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char S[110];
char T[110];
int main(){
	scanf("%s%s",S,T);printf("%s%s\n",T,S);
}

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

int main(){
    string s;
    cin >> s;
    int n= s.size();
    long long count=0,sum=0,ans=0;
    for(int i=0;i<n;i++){
        if(s[i] == 'B'){
            sum += i;
            count++;
        }
    }
    for(int i=n-1;i>=n-count;i--){
        ans += i;
    }
    
    cout << ans-sum << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

#define DATA 100

int main(void)
{
	int n, i;
	int seq[DATA];

	scanf("%d", &n);
	for(i = 0;i < n;i++)
		scanf("%d", &seq[i]);
	for(n--;n >= 0;n--)
	{
		if(n != 0)
			printf("%d ", seq[n]);
		else
			printf("%d\n", seq[n]);
	}

	return 0;
}

Measured memory_bytes: 596
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] X = new long[N];
		for (int i = 0; i < N; ++i) {
			X[i] = sc.nextLong();
		}
		long ans = Long.MAX_VALUE / 3;
		for (int i = 0; i + K - 1 < N; ++i) {
			long lx = X[i];
			long rx = X[i + K - 1];
			// 0 , lx, rx
			ans = Math.min(ans, Math.abs(lx) + Math.abs(rx - lx));
			// 0 , rx , lx
			ans = Math.min(ans, Math.abs(rx) + Math.abs(rx - lx));
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 22452
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int dp[100001];

int main() {

    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    
    REP(i, n) dp[i] = inf;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    RREP(i, 2, n) {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << endl;
    

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

Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split('/');
            var length = input.Length;
            var numbers = new int[3];

            for (int i = 0; i < length; i++)
            {
                numbers[i] = int.Parse(input[i]);
            }

            if (numbers[0] < 2019)
            {
                Console.WriteLine("Heisei");
            }
            else if (numbers[1] > 4)
            {
                Console.WriteLine("TBD");
            }
            else if (numbers[1] == 4 && numbers[2] == 30)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("Heisei");
            }
        }
    }
}


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

using namespace std;

#define LL long long int
#define INF 1 << 29

vector<int> rvec(8);
vector<vector<LL>> dist(201,vector<LL>(201,INF));
vector<bool> sel(8,false);
vector<int> shuffle(8);

LL dfs(int r,int i){
    if(i == r){
        LL d = 0;
        for(int j = 0; j < r-1; j++){
            d += dist[shuffle[j]][shuffle[j+1]];
        }
        return d;
    }
    LL result = INF;
    for(int j = 0; j < r; j++){
        if(!sel[j]){
            sel[j] = true;
            shuffle[i] = rvec[j];
            LL tmp = dfs(r,i+1);
            if(tmp < result){
                result = tmp;
            }
            sel[j] = false;
        }
    }

    return result;
}

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

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

    for(int i = 0; i < m; i++){
        LL a,b,c;
        cin >> a >> b >> c;
        dist[a][b] = dist[b][a] = c;
    }

    for(int k = 1; k < n+1; k++){
        for(int i = 1; i < n+1; i++){
            for(int j = 1; j < n+1; j++){
                if(dist[i][j] > dist[i][k] + dist[k][j]){
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }

    cout << dfs(r,0) << endl;

    return 0;
}

Measured memory_bytes: 512
///只能动x!!!
#include<cstdio>
#include<algorithm>
using namespace std;
int s(int x,int y)
{
	if(x<=y) return y-x;
		else return x-y+2;
}
int main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	printf("%d\n",min(s(x,y),min(s(-x,y)+1,min(s(x,-y)+1,s(-x,-y)+2))));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    if(n<1200){
        cout<<"ABC";
    }else{
        cout<<"ARC";
    }
    return 0;
}


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

int main() {
	string input;
	cin >> input;
	replace(input.begin(), input.end(), '9', '/');
	replace(input.begin(), input.end(), '1', '9');
	replace(input.begin(), input.end(), '/', '1');
	cout << input << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char s[1000000], t[1000000];
	char to[256], from[256];
	for(int i = 0; i < 256; i++){
		to[i] = 0;
		from[i] = 0;
	}
	scanf("%s", s);
	scanf("%s", t);
	for(int i = 0; s[i] != '\0'; i++){
		if(to[s[i]] == 0){
			to[s[i]] = t[i];
			if(from[t[i]] == 0){
				from[t[i]] = s[i];
			}else{
				printf("No\n");
				return 0;
			}
		}else if(to[s[i]] != t[i] || from[t[i]] != s[i]){
			printf("No\n");
			return 0;
		}
	}
	/*
	for(int i = 'a'; i <= 'z'; i++){
		if(dic[i] != 0){
			printf("%c<->%c\n", i, dic[i]);
		}
	}
	*/
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 512
L=int(input())
A=[int(input()) for i in range(L)]
su=sum(A)
#print(A)

DP=[[0 for i in range(5)] for j in range(L+1)]

mod=A[0]%2
if A[0]==0 :
    mod=2
DP[1]=[A[0],min(A[0],mod%2),min(A[0],mod%2,(mod+1)%2),min(A[0],mod%2,(mod+1)%2),min(A[0],mod%2,(mod+1)%2)]

for i in range(2,L+1):
    mod=A[i-1]%2
    if A[i-1]==0 :
        mod=2
    DP[i][0]+=DP[i-1][0]+A[i-1]
    DP[i][1]+=min(DP[i-1][0],DP[i-1][1])+mod
    DP[i][2]+=min(DP[i-1][j] for j in range(3))+(mod+1)%2
    DP[i][3]+=min(DP[i-1][j] for j in range(4))+mod
    DP[i][4]+=min(DP[i-1][j] for j in range(5))+A[i-1]

#print(DP)
print(min(DP[L]))


Measured memory_bytes: 74044
#E
n=int(input())
a=tuple(map(int,input().split()))
import fractions
lcm=a[0]
b_sum=0
for i in range(1,n):
    lcm=lcm*a[i]//fractions.gcd(lcm,a[i])

num=10**9+7
for i in range(n):
    b_sum+=(lcm//a[i])

print(b_sum%num)

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

int main()
{
    std::string s;
    std::cin >> s;
    
    std::vector<int> v(s.size());
    int depth = 0;
    long long res = 0;
    
    for (char c : s) {
        res += v[depth];
        v[depth]++;
        if (c == '(') {
            depth++;
        } else {
            depth--;
        }
    }
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 3428
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    x = C + sum([A[i] * B[i] for i in range(M)])
    if x > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
use itertools::join;
fn main() {
    proconio::input! {
        n: usize,
        s: [u8;n],
        t: [u8;n],
        u: [u64;n],
        v: [u64;n],
    }
    let mut m = vec![vec![0;n];n];
    for i in 0..n { for j in 0..n {
        let mut a = u[i]&v[j];
        if s[i]==0 {a |= u[i];}
        if t[j]==0 {a |= v[j];}
        if s[i]!=0 {a &= u[i];}
        if t[j]!=0 {a &= v[j];}
        m[i][j] = a;
    }}
    for i in 0..n { if s[i]!=0 {
        let mut b = ((0..n).fold(0, |a,j| a|m[i][j]) ^ u[i]) & u[i];
        while b>0 {
            let c = b & !(b-1);
            for j in 0..n {
                if t[j]==0 && 0==(0..n).fold(c, |a,k| if i==k {a} else {a&m[k][j]}){
                    m[i][j]|=c;
                    break;
                }
            }
            b &= b-1;
        }
    }}
    for j in 0..n { if t[j]!=0 {
        let mut b = ((0..n).fold(0, |a,i| a|m[i][j]) ^ v[j]) & v[j];
        while b>0 {
            let c = b & !(b-1);
            for i in 0..n {
                if s[i]==0 && 0==(0..n).fold(c, |a,k| if j==k {a} else {a&m[i][k]}){
                    m[i][j]|=c;
                    break;
                }
            }
            b &= b-1;
        }
    }}
    if (0..n).any(|k|
        u[k] != if s[k]!=0 {
            (0..n).fold(0, |a,j| a|m[k][j])
        }
        else {
            (0..n).fold(std::u64::MAX, |a,j| a&m[k][j])
        }
        ||
        v[k] != if t[k]!=0 {
            (0..n).fold(0, |a,i| a|m[i][k])
        }
        else {
            (0..n).fold(std::u64::MAX, |a,i| a&m[i][k])
        }
    ) {
        println!("{}",-1);
        return;
    }
    for a in m {
        println!("{}",join(a.iter(), " "));
    }
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n, m, k; cin >> n >> m >> k;
    vll a(n+1, 0), b(m+1, 0);
    rep2(i, 1, n+1){
        cin >> a[i];
        a[i] += a[i-1];
    }
    rep2(i, 1, m+1){
        cin >> b[i];
        b[i] += b[i-1];
    }

    ll jmax = m;
    ll mx = 0;
    rep(i, n+1){
        if(a[i]>k) break;
        for(ll j=jmax;j>=0;j--){
            if(b[j] <= k-a[i]){
                jmax = j;
                break;
            }
        }
        mx = max(mx, i+jmax);
    }

    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 6396
a = int(input())
nums = input().split()
flag = True
for i in range (a):
    x = int(nums[i])
    if (x % 2 == 0):
        if not (x % 3 == 0 or x % 5 == 0):
            flag = False
            break

if (flag):
    print('APPROVED')
else:
    print('DENIED')

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

using namespace std;

int h1,m1,h2,m2,m;

int main() {
 	ios_base::sync_with_stdio(0); cin.tie(0);
  	cin>>h1>>m1>>h2>>m2>>m;
  	int ans = (h2-h1)*60 + (m2-m1);
  	cout<<max(0,ans-m)<<endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int a,b,c;cin>>a>>b>>c;
	int k;cin>>k;
	int count=0;
	while(b<=a){
		b *= 2;
		count++;
	}
	while(c<=b){
		c *= 2;
		count++;
	}
	if(count<=k){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3652
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if(N <= K) System.out.println(N*X);
		else System.out.println(K*X+(N-K)*Y);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			int a = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();

			if (a >= 3200)
			{
				Console.WriteLine(s);
			}
			else
			{
				Console.WriteLine("red");
			}
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//素数判定
//#include <cmath>
bool is_prime(long long n) {
	if (n == 1) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	for (long long i = 3; i <= sqrt(n); i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;

	vector<queue<ll>> p(5);
	for (ll i = 2; i <= 55555; i++) {
		if (is_prime(i)) {
			p[i % 5].push(i);
		}
	}

	for (ll i = 0; i < 5; i++) {
		if (p[i].size() >= n) {
			for (ll j = 0; j < n - 1; j++) {
				cout << p[i].front() << " ";
				p[i].pop();
			}
			cout << p[i].front() << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
s=gets.chomp
k=gets.to_i
n=s.size
0.upto(n-2){|i|
  next if k<j=(97-s[i].ord)%26
  s[i]=?a
  break if 0==k-=j
}
s[-1]=((s[-1].ord-97+k)%26+97).chr
puts s

Measured memory_bytes: 2172
#include <stdio.h>
#define inf 1000000
#define NIL -1
#define WHITE 0
#define BLACK 1
#define MAX 100

void dijkstra();
int n,w[MAX][MAX];

int main(){
  int i,j,u,k,v,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      w[i][j]=inf;
    }

  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      w[u][v]=c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra(){
  int d[MAX], pi[MAX], color[MAX];
  int u,mincost,i,v,sum=0,j;

  for(u=0;u<n;u++){
    d[u]=inf;
    pi[u]=NIL;
    color[u]=WHITE;
  }

  d[0]=0;

  while(1){
    mincost=inf;

    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }

    if(mincost==inf) break;

    color[u]=BLACK;

    for(v=0;v<n;v++){
      if(color[v]!=BLACK && d[u]+w[u][v]<d[v]){
        pi[v]=u;
        d[v]=d[u]+w[u][v];
      }
    }

  }

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


Measured memory_bytes: 2108
<?php
  $result = 0;
	fscanf(STDIN, "%d", $N);
  for($rem=1;$rem<=$N;$rem+=2){
    $divisor = 0;
    for($i=1;$i<=$rem;$i++){
      if($rem % $i == 0){
        $divisor++;
      }
    }
    if($divisor == 8){
      $result++;
    }
  }
  echo $result;
?>

Measured memory_bytes: 3576
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt()

    val ans = math.pow(2, m) * (1900 * m + 100 * (n - m))
    println(ans.toInt)
  }
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

int n;
vector<int> v,u;
int x;
int cnt[5];

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>x;
        v.pb(x);
        u.pb(x);
    }
    sort(all(v));
    int N=unique(all(v))-v.begin();
    if (N==1&&v[0]==0) return cout<<"Yes"<<endl,0;
    if (n%3!=0) return cout<<"No"<<endl,0;
    if (N>3) return cout<<"No"<<endl,0;
    for (int i=0;i<N;i++)
    {
        for (int j=0;j<n;j++)
        {
            if (u[j]==v[i]) cnt[i]++;
        }
    }
    if (N==2&&v[0]==0&&cnt[0]==n/3) return cout<<"Yes"<<endl,0;
    if (N==3&&v[0]==(v[1]^v[2])&&cnt[0]==cnt[1]&&cnt[1]==cnt[2]) return cout<<"Yes"<<endl,0;
    cout<<"No"<<endl;
}



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int X = 100 * a + 10 * b + c;
  
  if(X % 4 == 0){
	cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 256