akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e12;

const long double eps = 1e-8;

const i64 MAXN = 400'000 + 5;

i64 n, k;
vector<i64> p;
vector<i64> c;

vector<i64> x;
vector<i64> s;

i64 R;

void calc(i64 b) {
    i64 i = b;
    do {
        x[b] += 1;
        s[b] += c[i];
        i = p[i];
    } while (i != b || x[b] > n);

    if (x[b] > n) {
        x[b] = 0;
        s[b] = 0;
    }
}

void simul(i64 b) {
    i64 i = b;
    i64 t = 0;
    i64 z = k;

    while (z > 0 && !x[i]) {
        t += c[i];
        R = max(R, t);
        z -= 1;
        i = p[i];
    }


    i64 w = max(0ll, z / x[i] - 1);
    if (s[i] > 0) {
        t += s[i] * w;
        R = max(R, t);
    }
    z -= w * x[i];

    while (z > 0) {
        t += c[i];
        R = max(R, t);
        z -= 1;
        i = p[i];
    }
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    cin >> n >> k;
    p = vector<i64>(n);
    c = vector<i64>(n);

    for (i64 i = 0; i < n; i++) {
        cin >> p[i];
        p[i] -= 1;
    }

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

    x = vector<i64>(n);
    s = vector<i64>(n);

    for (i64 i = 0; i < n; i++) {
        calc(i);
    }

    R = c[0];
    for (i64 i = 1; i < n; i++) {
        R = max(R, c[i]);
    }

    for (i64 i = 0; i < n; i++) {
        simul(i);
    }

    cout << R << endl;

    return 0;
}

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


int main(){
  int n,b;
  double f = 0;
  cin >> n;

  rep(i,n){
    cin >> b;
    f += (double)1/b;
  }

  f = (double)1/f;

  cout << fixed;
  cout << setprecision(6) << f << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;

constexpr int INF = 1e9;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    ll sum = accumulate(a.begin(), a.end(), 0LL);
    vector<bool> dp(K, false);
    dp[0] = true;
    int res = 0;
    for(int i=0; i<N; ++i) {
        bool f = false;
        for(int j=0; j<K; ++j) {
            f |= dp[j] && K <= j+sum;
        }
        res += !f;
        sum -= a[i];
        for(int j=K-1-a[i]; j>=0; --j) {
            dp[j+a[i]] = dp[j+a[i]] | dp[j];
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    ll x, y;    cin >> x >> y;

    if(abs(x - y) <= 1) cout << "Brown";
    else cout << "Alice";

}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	string s[H];
	for(int i = 0; i < H; i++) cin >> s[i];

	int dx[4] = {0, 0, -1, 1};
	int dy[4] = {-1, 1, 0, 0};
	bool flag = false;

	for(int y = 0; y < H; y++) {
		for(int x = 0; x < W; x++) {
			if(s[y][x] == '#') {
				flag = false;
				for(int i = 0; i < 4; i++) {
					if(s[y + dy[i]][x + dx[i]] == '#') flag = true;
				}
				if(!flag) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
}


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

int main() {

  double d1,d2,d3,d4;
  int i,j,k,l,n;
  double x[1020] = {0};
  double y[1020] = {0};
  double z[1020] = {0};
  double o,p,q,max;
  max = -1;
  o=0;
  p=0;
  q=0;
  d1 = 0;
  d2 = 0;
  d3 = 0;
  d4 = 0;

  scanf("%d",&n);

  for(i=0; i<n; i++) {
    scanf("%lf",&x[i]);
  }

  for(i=0; i<n; i++) {
    scanf("%lf",&y[i]);
  }

  for(i=0; i<n;i++) {

    o = (x[i] - y[i]) * (x[i] - y[i]);
    p = (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
    p = p*p;
    p = sqrt(p);
  
    d3 = d3 + p;
    d2 = d2+o;
    d1 = d1 + sqrt(o); 

    if(max < sqrt(o)) {
      max = sqrt(o);
    }

   
  }

  d2 = pow(d2,1.0/2);
  d3 = pow(d3,1.0/3);
  d4 = max;

  printf("%.11lf\n%.11lf\n%.11lf\n%.11lf\n" ,d1,d2,d3,d4);

  return 0;

}

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

int main() {
	int R;
	cin >> R;
	
	if(R < 1200) cout << "ABC";
	else if(R >= 1200 && R < 2800) cout << "ARC";
	else if(R >= 2800) cout << "AGC";
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
zoro = 0
res = []

for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        zoro += 1
        res.append(zoro)
    else:
        zoro = 0
        res.append(zoro)

if max(res) >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar
#define putchar putchar
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

long a[100001];
long b[100001];
int main(void){
	int n=nextint();
	int k=nextint();
	for(int i=0; i<n; i++){
		int A=nextint();
		a[i+1]=a[i]+A;
		if(A>=0){
			b[i+1]=b[i]+A;
		}else{
			b[i+1]=b[i];
		}
	}
	long ans=0;
	for(int r=k; r<=n; r++){
		int l=r-k;
		long pnt=a[r]-a[l];
		if(pnt<0) pnt=0;
		long now=(b[l]-b[0])+pnt+(b[n]-b[r]);
		if(now>ans) ans=now;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 3156
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}//約数求める


ll kaijou(int n) {
	ll temp = 1;
	for (int i = 2; i <= n; i++) {
		temp *= i;
		temp %= MOD;
	}
	return temp;
}

int main() {
	int n;
	cin >> n;
	int temp[3];
	temp[0] = n / 100;
	temp[1] = (n - 100 * temp[0]) / 10;
	temp[2] = n - 100 * temp[0] - 10 * temp[1];
	if (temp[0] >= temp[1] && temp[0] >= temp[2]) {
		cout << temp[0] << temp[0] << temp[0];
	}
	else {
		cout << temp[0] + 1 << temp[0] + 1 << temp[0] + 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,W;
int a[10][10];
int main(void)
{
    cin>>H>>W;
    for(int i=0;i<=9;++i)
    {
        for(int j=0;j<=9;++j)
        {
            cin>>a[i][j];
        }
    }
    for(int k=0;k<=9;++k)
    {
        for(int i=0;i<=9;++i)
        {
            for(int j=0;j<=9;++j)
            {
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
            }
        }
    }
    int ans=0;
    int temp=0;
    for(int i=0;i<H;++i)
    {
        for(int j=0;j<W;++j)
        {
            cin>>temp;
            if(temp!=-1&&temp!=1)
            {
                ans+=a[temp][1];
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}


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

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 15
dp = [INF] * (H + 1)
dp[0] = 0

answer = INF
for a, b in AB:
  for i in range(H + 1):
    if dp[i] != INF:
      if i + a < H:
        dp[i + a] = min(dp[i + a], dp[i] + b)
      else:
        answer = min(dp[i] + b, answer)
        
print(answer)

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

#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      ll n,x,t;
      cin>>n>>x>>t;
      ll vagfol=n/x;

      ll ans=vagfol*t;
      if(n%x) ans+=t;
      cout<<ans<<endl;


      bye;
}


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

int main(){
  int X,c500=0,c5=0;
  cin >>X;
  while(1){
    c500++;
    if(X-c500*500<0){
      c500--;
      break;
    }
  }
  X=X-(c500*500);
  while(1){
    c5++;
    if(X-c5*5<0){
      c5--;
      break;
    }
  }
  cout<<c500*1000+c5*5<<endl;

}


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

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

  vector<ll> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll K; cin >> K;
  cout << A[K - 1] << '\n';
  return 0;
}

Measured memory_bytes: 256
//ツ三ツ角ツ形ABCツづ個陳?づ可点Pツつェツ甘慊づ慊づェツづゥツつゥツづ?つ、ツつゥツづ個板サツ津ィツづ個仕ツ陛サ
//ツ「ツ三ツ角ツ形ABP, BCP, CAPツづ個姪環静渉づ個債?計 == ツ三ツ角ツ形ABCツづ個姪環静渉」
//ツづ可づ按づ?づ?つ「ツづェツづ? ツ点Pツづ債三ツ角ツ形ツづ可甘慊づ慊づェツづゥ

#include <iostream>
#include <complex>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef complex<double> P;

#define EPS (1e-8)

P t[3], p;

//3ツづつづ個点ツづ個湘ョツ陛アツつゥツづァ, ツ三ツ角ツ形ツづ個姪環静渉づーツ仰?づ淞づゥ
//ツヘツδ債δ督づ個古カツ篠ョツづーツ用ツつ「ツづゥ
double getArea(const P &a, const P &b, const P &c){
  double A = abs(a - b);
  double B = abs(b - c);
  double C = abs(c - a);
  double S = (A + B + C) / 2.0;

  return sqrt(S * (S - A) * (S - B) * (S - C));
}

void solve(){
  double sum = 0;

  //ABP, BCP, CAPツづ個三ツ角ツ形ツづ個姪環静渉づーツ仰?づ淞づ? ツ堕ォツつオツ債?づュツつケツづゥ
  for(int i = 0; i < 3; i++){
    sum += getArea(t[i], t[(i + 1) % 3], p);
  }

  //ツ三ツ角ツ形ABCツづ個姪環静渉づーツ仰?づ淞づゥ
  double abc = getArea(t[0], t[1], t[2]);

  //sumツづ?bcツづ個債キツつェ, ツ古?づィツづ按つュ0ツづ可凝淞つ「ツづ按づァツ督卍つオツつ「ツづ個づ? YES
  if(fabs(sum - abc) < EPS){
    cout << "YES\n";
  }
  else{
    cout << "NO\n";
  }
}

int main(){
  while(true){
    for(int i = 0; i < 3; i++){
      if(!(cin >> t[i].real() >> t[i].imag())) return 0;
    }
    cin >> p.real() >> p.imag();
    solve();
  }
}

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

const int D=1350,P=1000000007;
int n,K,fac[D],tot,f[D];

int power(int a,int x)
{
	int ans=1;
	for(;x;x>>=1,a=1ll*a*a%P)
		if(x&1)ans=1ll*ans*a%P;
	return ans;
}

int main()
{
	scanf("%d%d",&n,&K);
	int t=n;
	for(int i=1;i*i<=t;i++)
		if(t%i==0)
		{
			fac[++tot]=i;
			if(i*i!=t)fac[++tot]=t/i;
		}
	sort(fac+1,fac+1+tot);
	for(int i=1;i<=tot;i++)
	{
		f[i]=power(K,fac[i]+1>>1);
		for(int j=1;j<i;j++)
			if(fac[i]%fac[j]==0)
				f[i]=(f[i]-f[j])%P;
	}
	const int inv2=P+1>>1;
	int ans=0;
	for(int i=1;i<=tot;i++)
		if(fac[i]&1)ans=(ans+1ll*f[i]*fac[i])%P;
		else ans=(ans+1ll*inv2*f[i]%P*fac[i])%P;
	printf("%d\n",(ans+P)%P);
	return 0;
}


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


void solve(std::string s, long long K){
    set<string> strs;
    long long N = s.length();

    for(int i=0; i<N; i++) {
        for (int n = 1; n <= min(N - i, K); n++) {
            auto subs = s.substr(i, n);
            strs.insert(subs);
        }
    }

    vector<string> vec(strs.size());
    vec.assign(strs.begin(), strs.end());
    sort(vec.begin(), vec.end());

    cout << vec[K-1] << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    long long K;
    scanf("%lld",&K);
    solve(s, K);
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		execute();
	}
 
	private static void execute() {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
 
			int ans = (int)(a / 1.08);
			if (calc((int)ans)==a) {
				System.out.println((int)ans);
 			} else if(calc(ans-1)==a) {
 				System.out.println((int)ans-1);
 			} else if(calc(ans+1)==a) {
 				System.out.println((int)ans+1);
 			} else {
 				System.out.println(":(");
			}
 
		}
	}
	
	private static int calc(int arg) {
		return (int)(arg*1.08);
	}
}

Measured memory_bytes: 23764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,Q = map(int,readline().split())
data = np.array(read().split(),np.int64)

ABCD = data[:4*N-4].reshape(-1,4).tolist()

graph = [[] for _ in range(N+1)]
for a,b,c,d in ABCD:
    graph[a].append((b,c,d))
    graph[b].append((a,c,d))

color = [0] * (N+1) # 自身と親を結ぶ辺の色
length = [0] * (N+1) # 自身と親を結ぶ辺の長さ

def EulerTour(graph,start=1):
    """
    1-indexed graph
    graphを破壊しているので場合によっては注意
    """
    V = len(graph)
    par = [0] * V
    depth = [0] * V; depth[start] = 0
    tour = [start]; st = [start]
    while st:
        x = st[-1]
        if not graph[x]:
            st.pop()
            tour.append(par[x])
            continue
        y,c,d = graph[x].pop()
        if y == par[x]:
            continue
        par[y] = x
        color[y] = c
        length[y] = d
        depth[y] = depth[x] + 1
        st.append(y)
        tour.append(y)
    return tour,depth

tour,depth = EulerTour(graph)

Ltour = len(tour)
tour_arr = np.array(tour)
depth_arr = np.array(depth)
tour_d = depth_arr[tour_arr]
idx = np.arange(len(depth))
idx[tour_arr] = np.arange(Ltour)

# depth最小を実現するインデックスのsparse tableを作る
sp = np.empty((Ltour.bit_length(),Ltour),np.int32)
sp[0] = np.arange(Ltour)
for n in range(1,Ltour.bit_length()):
    prev,width = sp[n-1],1<<(n-1)
    x = prev[:-width]; y = prev[width:]
    condition = tour_d[x] > tour_d[y]
    sp[n] = prev
    sp[n,:-width][condition] = y[condition]

def LCA(A,B):
    AB = np.vstack([A,B]).T
    LR = idx[AB]
    LR.sort(axis=1)
    # [L,R] におけるRmQ
    L = LR[:,0]; R = LR[:,1]
    x = R-L
    n = np.zeros_like(x) # 2^n <= R-L
    for _ in range(20):
        x >>= 1
        n[x>0] += 1
    x = sp[n,L]; y = sp[n,R-(1<<n)+1]
    return np.where(tour_d[x] < tour_d[y], tour_arr[x], tour_arr[y])

XYUV = data[4*N-4:]
U = XYUV[2::4]; V = XYUV[3::4]
lca = LCA(U,V)

answer = [0] * Q
task = [[] for _ in range(N+1)]
for i,((x,y,u,v),w) in enumerate(zip(XYUV.reshape(-1,4),lca)):
    # x,yの条件下での距離の何倍かをanswer[i]に加算する
    task[u].append((x,y,1,i))
    task[v].append((x,y,1,i))
    task[w].append((x,y,-2,i))

color_cnt = [0] * N
color_sum = [0] * N
d = 0 # いじらないときの距離

for fr,to in zip(tour,tour[1:]):
    d1 = depth[fr]; d2 = depth[to]
    if d1 > d2:
        # 上る前にクエリ処理
        for x,y,coef,i in task[fr]:
            answer[i] += coef * (d - color_sum[x] + color_cnt[x] * y)
    if d1 < d2:
        c = color[to]; l = length[to]
        color_cnt[c] += 1
        color_sum[c] += l; d += l
    else:
        c = color[fr]; l = length[fr]
        color_cnt[c] -= 1
        color_sum[c] -= l; d -= l

print('\n'.join(map(str,answer)))

Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i==0){
            int j=n/i;
            if(j>=1 && j<=9){
                cout<<"Yes"; return 0;
            }
        }
    }
    cout<<"No";
}

Measured memory_bytes: 256
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

//#define MOD (int)(1e5 + 7)
#define MOD (100007)

void invalid(void)
{
	printf("-1\n");
	exit(0);
}

static inline int *readNint(int n)
{
	int *a = calloc(sizeof(int), n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	return a;
}

static inline int comp(const void *a, const void *b)
{
	return *(int *)a < *(int *)b;
}

int main(int argc, char **argv)
{
	int H, N;
	scanf("%d%d", &H, &N);
	int *A = readNint(N);
	//qsort(A, N, sizeof(int), comp);
	int t = 0;
	for (int i = 0; i < N; i++)
		t += A[i];
	if (t >= H)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

int main(){
	fastio;
	ll n,k;
	cin>>n>>k;
	vll a(n);
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	vll dp(n, INF);
	dp[0]=0;
	for(ll i=1; i<n; i++){
		for(ll j=max(0ll, i-k); j<i; j++){
			dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i];
	}
	vector<int> dp(k + 1);
	for(auto i = 1; i <= k; ++ i){
		for(auto x: a){
			if(x > i){
				break;
			}
			if(!dp[i - x]){
				dp[i] = 1;
				break;
			}
		}
	}
	dp[k] ? cout << "First" : cout << "Second";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 640
/*राधे कृष्णा*//*राधे कृष्णा*//*राधे कृष्णा*//*राधे कृष्णा*/
#include <iostream>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
#include <cstdio> 
#include <string> 
#include <vector> 
#include<bits/stdc++.h>
#include<queue>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define test ll t;cin >> t;while(t--)
#define ll long long int
#define  sll stack<ll>
#define  qll queue<ll>
#define  pll pair<ll,ll>
#define  vll vector<ll>
#define  vpi vector<pair<int,int>>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ln "\n"
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define fab(i,a,b) for(i=a;i<b;i++)
//typical dp problem
void solve() {
	ll n,k,i,j;
	cin >> n >> k;
	ll h[n+1];
	for(i=1;i<=n;i++) cin >> h[i];
	ll dp[n+1];
	dp[0] =0; dp[1]=0; dp[2]=abs(h[2]-h[1]);
	for(i=3;i<=n;i++){
		ll x = 1e9 + 100;
		j=max(1LL,i-k);
		for(;j<i;j++){
			//if(i-j >k) {j=j+(i-j) ;continue;}
			x=min(x,(dp[j] + abs(h[i]-h[j])) );
		}
		dp[i]=x;
	}
	//for(i=1;i<=n;i++)
		cout << dp[n] ;//<< "   ";
}
int main(){
	fastio
	/*ll t;
	cin >> t;
	while(t--){*/
		solve();
	//}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

class osa_k{
private:
    vector<int> prime_sieve;
    vector<int> set_prime;
    int N;
    void eratosthenes(){
        for(int i=2;i*i<N;i++) {
            if(prime_sieve[i]<i) continue;
            for(int j=i*i;j<N;j+=i){
                if(prime_sieve[j]==j) prime_sieve[j] = i;
            }
        }                
    }

    void setPrimeSet(){
        for(int i=2;i<N;i++){
            if(prime_sieve[i]==i){
                set_prime.emplace_back(i);
            }
        }        
    }
public:    
    osa_k(const int n):N(n){
        prime_sieve.resize(n);
        iota(prime_sieve.begin(),prime_sieve.end(),0);
        eratosthenes();
        setPrimeSet();
    }

    //例えばi=8の時、{2,2,2}
    vector<int> getFactor(int i) {
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        return res;
    }
    //例えばi=8の時、{2}
    vector<int> getFactorSet(int i){
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        //重複を省く
        sort(res.begin(),res.end());
        decltype(res)::iterator result = unique(res.begin(), res.end());
        res.erase(result, res.end());
        return res;
    }
    //素数の集合を得る {2,3,5,7,11,...}
    vector<int> getPrimeSet(){
        return prime_sieve;
    }
    //iが素数:true
    bool isPrime(const int i){
        if(prime_sieve[i]==i){
            return true;
        }
        return false;
    }
};



int main(){
    int n;cin>>n;
    osa_k o(1000005);
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int> s(1000005);
    int co=a[0];
    for(int i=0;i<n;i++){
        co=gcd(co,a[i]);
    }
    if(co!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        vector<int> tmp=o.getFactorSet(a[i]);
        for(int j=0;j<tmp.size();j++){
            if(s[tmp[j]]>0){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            else{
                s[tmp[j]]+=1;
            }
        }
    }
    cout<<"pairwise coprime"<<endl;    

    return 0;
}

Measured memory_bytes: 15272
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s; cin >> s;
  REP(i,s.size()) {
    if (i%2) continue;
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<P, vector<P>, greater<P>> PQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
vector<vector<P>> costs;
ll n;
Vector mincost;
void djk(ll start){
  PQueue pq;
  mincost.resize(n,INF);
  mincost[start] = 0;
  pq.push({0,start});
  while(pq.size()){
    P state = pq.top();pq.pop();
    if(mincost[state.se] < state.fi)continue;
    each(itr,costs[state.se])if(mincost[itr.fi] > mincost[state.se] + itr.se){
      mincost[itr.fi] = mincost[state.se] + itr.se;
      pq.push({mincost[itr.fi],itr.fi});
    }
  }
}

int main(){
  cin.sync_with_stdio(false);
  cin >> n;
  costs.resize(n);
  rep(i,n){
    ll u,k;
    cin >> u >> k;
    rep(j,k){
      ll v,c;
      cin >> v >> c;
      costs[u].pb({v,c});
    }
  }
  djk(0);
  rep(i,n)cout << i << " " << mincost[i] << endl;
}



Measured memory_bytes: 11872
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

#define MOD 998244353
#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()

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

int main() {
  int n;
  cin >> n;
  int d[n];
  REP(i, n) cin >> d[i];
  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, n) {
    if (0 < i && d[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  map<int, int> mp;
  REP(i, n) mp[d[i]]++;
  ll ans = 1;
  for (auto a : mp) {
    if (a.first == 0) continue;
    ans *= mod_pow(mp[a.first - 1], a.second);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <algorithm>

int f(const std::string& s1, const std::string& s2)
{
    char a1[26] = {0};
    char a2[26] = {0};

    for (int i = 0; i < s1.length(); i++) {
        a1[s1[i]-'a']++;
    }

    for (int i = 0; i < s2.length(); i++) {
        a2[s2[i]-'a']++;
    }

    int ans = 0;
    for (int i = 0; i < 26; i++) {
        if (a1[i] > 0 && a2[i] > 0) ans++;
    }

    return ans;
}

int main()
{
    int N;
    std::cin >> N;

    std::string S;
    std::cin >> S;

    int ans = 0;
    for (int i = 1; i < N-1; i++) {
        ans = std::max(ans, f(S.substr(0, i), S.substr(i)));
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
from collections import Counter
def main():
    S = input()
    K = int( input())
    CS = Counter(S)
    if CS[ S[0]] == len(S):
        print( len(S)*K//2)
        return
    N = len(S)

    for i in range(N-1):
        if S[i] != S[i+1]:
            check = i+1
            break

    T = S[check:] + S[:check]
    ans = 0
    now = S[0]
    cnt = 1

    for t in S[1:check]:
        if now == t:
            cnt += 1
            continue
        ans += cnt//2
        cnt = 1
        now = t
    ans += cnt//2

    cnt = 1
    now = S[check]
    for t in S[check+1:]:
        if now == t:
            cnt += 1
            continue
        ans += cnt//2
        cnt = 1
        now = t
    ans += cnt//2
    
    cnt = 1
    now = T[0]
    cc = 0

    for t in T[1:]:
        if t == now:
            cnt += 1
            continue
        cc += cnt//2
        cnt = 1
        now = t
    cc += cnt //2
    ans += cc*(K-1)
    
    print(ans)
        
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
from collections import defaultdict

N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1

total = 0
for v in d.values():
    if v != 1 and v != 0:
        total += int(v * (v - 1) / 2)

for i in range(N):
    tmp = d[A[i]] - 1
    print(total - tmp)

Measured memory_bytes: 88652
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	char str[1000001];
	scnaf("%s", str);
	int len = strlen(str);

	int l = 0, r = strlen(str) / 3 + 4;
	int ans = 0;
	REP(i, len) {
		int cons = 0, cc = 0;
		if (str[i] != 'J') {
			continue;
		}
		for (; len > i; i++) {
			if (str[i] != 'J')
				break;
			cc++;
		}
		cons = cc;
		cc = 0;
		if (str[i] != 'O') {
			i--;
			continue;
		}
		for (; len > i; i++) {
			if (str[i] != 'O')
				break;
			cc++;
		}
		if (cons < cc) {
			i--;
			continue;
		}
		cons = cc;
		cc = 0;
		if (str[i] != 'I') {
			i--;
			continue;
		}
		for (; len > i; i++) {
			if (str[i] != 'I')
				break;
			cc++;
		}
		if (cons > cc) {
			i--;
			continue;
		}
		ans = max(ans, min(cons,cc));
	}
	printf("%d\n", ans);
	return 0;
}

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

template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);

struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c, d> e) {
    return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
    cerr << boolalpha << a;
    return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
    *this << "[";
    for (auto it = a.begin(); it != a.end(); ++it)
        *this << ","[1 - (it != a.begin())] << *it;
    return *this << "]";
}
#else
template<class c> debug& operator << (c) {
    return *this;
}
#endif
};

#define aty(x) " [" << #x ": " << x << "] "

using ll = long long;




int main() {
    
    string s, t;
    cin >> s >> t;
    
    s += t;
    
    int n = atoi(s.c_str());
    
    int sq = sqrt(n);
    
    if (sq * sq == n) cout << "Yes\n";
    else cout << "No" << endl;
    
    
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();

    let s = iter.next().unwrap();
    let t = iter.next().unwrap();

    let a: u8 = iter.next().unwrap().parse().unwrap();
    let b: u8 = iter.next().unwrap().parse().unwrap();

    let u = iter.next().unwrap();

    if s == u {
        return format!("{} {}", a - 1, b);
    } else {
        return format!("{} {}", a, b - 1);
    }
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int main() {
	string n;
	cin >> n;
	int hoge = 0;
	int hogehoge = 0;
	REP(i, n.length()) {
		if (n[i] == 'N') {
			hoge = hoge | 1;
		}
		if (n[i] == 'S') {
			hoge = hoge | 2;
		}
		if (n[i] == 'W') {
			hogehoge = hogehoge | 1;
		}
		if (n[i] == 'E') {
			hogehoge = hogehoge | 2;
		}
	}
	if (hoge == 0 || hoge == 3) {
		if (hogehoge == 0 || hogehoge == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

string s, t;
vector<int> pos1[26];
vector<int> pos2[26];

int main() {
	int i;
	
	cin >> s >> t;
	for (i = 0; i < s.length(); i++) {
		pos1[s[i] - 'a'].push_back(i);
		pos2[t[i] - 'a'].push_back(i);
	}
	
	sort(pos1, pos1 + 26);
	sort(pos2, pos2 + 26);
	for (i = 0; i < 26; i++) {
		if (pos1[i] != pos2[i]) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main(){
	int l,n,m,i,j,k,ans;
	cin >>i;
	cin >>j;
	cin >>k;
	n=min(i,j);
	n=min(n,k);
	m=max(i,j);
	m=max(m,k);
	if(((i<=j)&&(j<=k))||((k<=j)&&(j<=i)))l=j;
	if(((j<=k)&&(k<=i))||((i<=k)&&(k<=j)))l=k;
	if(((k<=i)&&(i<=j))||((j<=i)&&(i<=k)))l=i;
	ans=abs((abs(n-l))+abs(m-l));
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int q[1000000],C[100010];
int ta[100010],nt[200010],to[200010],co[200010];
int f[100010];
/*int dfs(int v,int e,int s){
  int i,max=C[s];
  for(i=ta[s];i+1;i=nt[i]){
    if(f[to[i]])continue;
    f[to[i]]=1;
    C[to[i]]=C[s]+co[i];
    max=MAX(max,dfs(v,e,to[i]));
  }
  return max;
}//*/
int bfs(int v,int e,int s){
  int t,r,i,max=0;
  for(i=0;i<v;i++)C[i]=1000000000;
  C[q[0]=s]=t=0;//printf("a\n");
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d %d\n",q[t],to[i],co[i]);
      if(C[to[i]]>C[q[t]]+co[i])C[q[r++]=to[i]]=C[q[t]]+co[i];
      max=MAX(max,C[to[i]]);//printf("m%d\n",max);
    }//printf("\n");
  }//printf("%d\n",r);
  return max;
}//*/
int tyokkei(int v,int e,int *a){
  int i,max=0,g;
  for(i=0;i<v;i++){
    ta[i]=-1;
    C[i]=1000000000;
    f[i]=0;
  }
  C[0]=0;
  f[0]=1;
  for(i=0;i<e;i++){
    nt[i]=ta[a[i]];
    ta[a[i]]=i;
    nt[i+e]=ta[to[i]];
    to[i+e]=a[i];
    co[i+e]=co[i];
    ta[to[i]]=i+e;    
  }
  max=bfs(v,e*2,0);
  for(i=0;i<v;i++){
    if(max==C[i])g=i;
    C[i]=1000000000;
    f[i]=0;
  }
  C[g]=0;
  f[g]=1;//printf("g%d m%d\n",g,max);
  return bfs(v,e*2,g);
}
int main(){
  int n,a[100010],i;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)scanf("%d %d %d",&a[i],&to[i],&co[i]);
  printf("%d\n",tyokkei(n,n-1,a));
  return 0;
}

Measured memory_bytes: 5864
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 126656
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  int x;
  cin >> x;
  cout << lcm(360,x)/x << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for(int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while(std::next_permutation(indexes, indexes + n));
}

int main() {
  int N;
  cin >> N;
  auto P = vector<int>();
  auto Q = vector<int>();
  REP(i, N) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  REP(i, N) {
    int q;
    cin >> q;
    Q.push_back(q);
  }

  auto nums = vector<int>();
  int a, b;
  ll cnt = 0;
  REP(i, N) { nums.push_back(i + 1); }
  do {
    cnt++;
    if(P == nums) {
      a = cnt;
    }
    if(Q == nums) {
      b = cnt;
    }
  } while(next_permutation(nums.begin(), nums.end()));
  cout << abs(a - b) << endl;
}


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

int main() {
  int64_t N,K,m;
  m=pow(10,9)+7;
  cin >> N >> K;
  cout << ((K*(K-1)*(2*K-1)-(N+1)*(N+2)*(2*N+3)+3*(N+1)*(N+1)*(N+2)-3*K*(K-1)*(N+1)+6*(N-K+2))/6)%m << endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        // O(n) time and space
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        String numbers = in.next();

        final int MOD = 2019;
        long result = 0;
        long moder = 1;
        long prev = 0;

        int[] seen = new int[MOD];
        seen[0] += 1;
        for (int i = numbers.length() - 1; i >= 0; i--) {
            long num = (moder * (numbers.charAt(i) - '0') + prev) % MOD;
            result += seen[(int) num];
            seen[(int) num] += 1;
            prev = num;
            moder = (moder * 10) % MOD;
        }
        out.println(result);

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

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

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


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

template <class T>
void scrib_impl(char const* title, T v){
    cout << title << " ...... " << v << endl;
}
#define SCRIB(EXPR) (scrib_impl(#EXPR, (EXPR)))

int main() {
    int a,b;
    cin >> a >> b;
    
    map<int, bool> u{{1,true}, {2,true}, {3,true} };
    u[a] = false;
    u[b] = false;
    
    for(auto kv : u) {
        if (kv.second == 1) {
            cout << kv.first << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        c : [chars;3],
    }
    println!("{}{}{}",c[0][0],c[1][1],c[2][2]);
}


Measured memory_bytes: 2112
N, M = map(int, input().split())
g = [[] for _ in range(N)]

A, B = [0]*M, [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    g[A[i]-1].append(B[i]-1)
    g[B[i]-1].append(A[i]-1)

ans_list = [-1] * N

queue = [0]
seen = [False]*N

while queue:
    qi = queue.pop(0)
    # qi から 1 遠い頂点が gi
    for gi in g[qi]:
        if seen[gi] == False:
            queue.append(gi)
            if ans_list[gi] == -1:
                ans_list[gi] = qi
                seen[gi] = True

print("Yes")
for ans in ans_list[1:]:
    print(ans+1)  # 1-index に直す


Measured memory_bytes: 50940
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(int n)
{
  long result = 1;
  for (int i = 3; i <= n; ++i) {
    for (int j = 1; j * j <= i; ++j) {
      if ((i - 1) % j == 0) {
        ++result;
        if ((i - 1) / j != j) ++result;
      }
    }
  }
  return result;
}

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

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			char[] nums = sc.next().toCharArray();
			int sum = 0;

			int length = nums.length;
			for (int i = 0; i <length; i++) {
				sum += nums[i] - '0';
			}

			String ans = "No";
			if (sum % 9 == 0) {
				ans = "Yes";
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}


Measured memory_bytes: 40880