akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ECoinsRespawn {
public:

    vector<P> edge;
    vector<ll> cost;
    vector<int> graph[2501];
    vector<bool> used;
    vector<bool> avail;

    void dfs(int p) {
      used[p] = true;
      for(auto e: graph[p]) {
        if (!used[e]) dfs(e);
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m, p; cin >> n >> m >> p;
      edge.resize(m);
      cost.resize(m);
      used.resize(n);
      avail.resize(m);
      rep(i, m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        edge[i] = P(a, b);
        cost[i] = p-c;
        graph[b].push_back(a);
      }

      dfs(n-1);
      rep(i, m) {
        auto a = edge[i].first;
        auto b = edge[i].second;
        avail[i] = (used[a] && used[b]);
      }

      vector<ll> d(n, LLONG_MAX/2);
      d[0] = 0;
      int cnt = 0;
      while(true) {
        bool update = false;
        rep(i, m) {
          if (!avail[i]) continue;
          auto from = edge[i].first;
          auto to = edge[i].second;
          if (d[from] != LLONG_MAX/2 && d[to] > d[from] + cost[i]) {
            d[to] = d[from] + cost[i];
            update = true;
          }
        }
        if (!update) break;
        cnt++;
        if (cnt >= n+1) {
          cout << -1 << endl;
          return;
        }
      }
      cout << max(0LL, -d[n-1]) << endl;
    }
};

signed main() {
  ECoinsRespawn solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 512
"use strict";
// import bigInt from 'big-integer'

const Main = input => {
  const wrongAnswers = input.trim().split("\n");
  const answer = ["1", "2", "3"].filter(num => !wrongAnswers.some(wa => wa === num));
  console.log(answer[0]);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a <= 5){
        cout << 0 << endl;
    }else if(a <= 12){
        cout << b/2 << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	char s[1111], a[1111]={};
	int i, n, t=0;
	
	scanf("%s", s);
	
	n=strlen(s);
	
	for(i=0;i<n;i++){
		if(s[i]=='1')
		a[t++]='1';
		if(s[i]=='0')
		a[t++]='0';
		if(s[i]=='B'){
			if(t!=0)
			a[--t]='\0';
			
		}
		
	}
	
	printf("%s\n", a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
string s;
int k;
set<string> se;
 
int main() {    
    cin >> s >> k;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j > s.size()) break;
            se.insert(s.substr(i, j));
        }
    }
    for (int i = 1; i < k; i++) se.erase(se.begin());
    cout << *se.begin() << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007; 
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, h; cin >> n >> h;
	vector<int>a(n), b(n);
	rep(i, n)cin >> a[i] >> b[i];
	sort(a.rbegin(), a.rend()); 
	sort(ALLR(b));
	int ans = 0;
	int now = 0;
	int ma = a[0];
	rep(i, n) {
		if (b[i] == -1)break;
		if (b[i] >= ma) {
			ans++;
			now += b[i];
			b[i] = -1;
		}
		else {
			break;
		}
		if (now >= h) {
			cout << ans << endl; return 0;
		}
	}
	if (now >= h) {
		cout << ans << endl; return 0;
	}
	h -= now;
	cout << ans + (h + ma - 1) / ma << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    
    int vec[10][10] = {0};
    int pw=1; 
    for(int i=1; i<=N; i++) {
        int l = i / pw; // 最高位がl
        if(l==10) { pw *= 10; l = 1; }
        int r = i % 10; // 最低位がr
        vec[l][r]++;
    }

    long ans = 0;
    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            ans += vec[i][j]*vec[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) {
    val time = readLine().toInt
    val h = time / 3600
    val m = ((time - (h * 3600)) / 60)
    val s = time % 60
    println(h.toString + ":"  + m.toString + ":" + s.toString)
  }
}

Measured memory_bytes: 43528
# coding: utf-8
# Your code here!

from collections import deque
def diameter(g):
    def bfs(start): # v からの最長点と距離を求める
        res = [-1]*(len(g))
        q = deque([start])
        res[start] = 0
        while q:
            v = q.popleft()
            rv = res[v]
            for c in g[v]:
                if res[c] >= 0: continue
                res[c] = rv + 1 #重みつきのときは+1でなく +cost(v,c)
                q.append(c) 
        return (rv,v)

    d0,v0 = bfs(0)
    d1,v1 = bfs(v0)
    return d1 # i0, i1 が最遠頂点対


##################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n = int(input())
#n,q = [int(i) for i in readline().split()]
 
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

d = diameter(g)
if d%3 != 1:
    print("First")
else:
    print("Second")
    

    







Measured memory_bytes: 47512
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
    int a,b,c,d,k;cin>>a>>b>>c>>d>>k;
    int tmp=0;
    tmp=(60*c+d)-(60*a+b);
    int ans=0;
    ans=tmp-k;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

struct Graph {
    vertices: Vec<Vertex>
}

impl Graph {
    fn new(n: usize) -> Self {
        Graph { vertices: vec![Vertex::new(); n] }
    }

    fn add_edge(&mut self, u: usize, v: usize, value: i32) {
        self.vertices[u].edges.push(Edge { to: v, value: value })
    }

    fn find_nonzero_loop(&self) -> bool {
        let n = self.vertices.len();
        let mut values = vec![0; n];
        let mut visited = vec![false; n];
        for i in 0..n {
            if !visited[i] {
                if !self.dfs(i, 0, &mut visited, &mut values) {
                    return true;
                }
            }
        }
        false
    }

    fn dfs(&self, idx: usize, dist: i32, visited: &mut Vec<bool>, values: &mut Vec<i32>) -> bool {
        if visited[idx] {
            return values[idx] == dist;
        }
        visited[idx] = true;
        values[idx] = dist;

        let mut res = true;
        for e in &self.vertices[idx].edges {
            res &= self.dfs(e.to, dist + e.value, visited, values);
        }
        res
    }
}

#[derive(Clone)]
struct Vertex {
    edges: Vec<Edge>
}

impl Vertex {
    fn new() -> Self {
        Vertex { edges: vec![] }
    }
}

#[derive(Clone)]
struct Edge {
    to: usize,
    value: i32
}


fn main() {
    let (n, m): (usize, usize) = read();
    let mut graph = Graph::new(n);
    for i in 0..m {
        let (u, v, d): (usize, usize, i32) = read();
        graph.add_edge(u-1, v-1, d);
        graph.add_edge(v-1, u-1, -d);
    }

    if graph.find_nonzero_loop() {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 22396
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, m = 0;
  cin >> N;
  vector<int> C(N), V(N);
  for (int i = 0; i < N; i++)
  {
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> C.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    if (V[i] > C[i])
    {
      m += V[i] - C[i];
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007

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

    string S;
    cin >> S;

    cout << S[0] << S[1] << S[2] << endl;
}

Measured memory_bytes: 3644
#include<iostream>

int main(){
  int n,t,i;
  int cost=0,time=0,mincost=1001;
  std::cin>> n >> t;
  for(i=0;i<n;i++){
    std::cin>>cost>>time;
    if(time <= t){
      if(cost<=mincost){
	mincost=cost;
      }
      else{
	//do nothing
      }
    }
    else{
      //do nothing
    }
  }
  if(mincost != 1001){
    std::cout << mincost<<std::endl;
  }
  else{
    std::cout<< "TLE" <<std::endl;
  }
  return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	
	if (a<b){
		cout << "a < b" << endl ;
	}
	else if(a>b){
		cout << "a > b" << endl ;
	}
	else{
		cout << "a == b" << endl ;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int a[101];
  rep(i, 0, n) cin >> a[i];
  int ans = 1145141919;
  rep(i, -100, 101) {
    int r = 0;
    rep(j, 0, n) {
      if(a[j] == i) continue;
      r += (a[j] - i) * (a[j] - i);
    }
    ans = min(ans, r);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

D = dict()
for i in range(N):
    a = input()
    a = ''.join(sorted(a))
    if a in D:
        D[a] = D[a]+1
    else:
        D[a] = 1

ans = 0
for i in D:
    ans += D[i]*(D[i]-1)//2

print(ans)

Measured memory_bytes: 17928
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	
	int ans = 0;
	REP(i, S.size()) FOR(j, i + 1, S.size()) {
		int sz = j - i + 1;
		if (sz & 1) continue;
		if (sz == S.size()) continue;
		bool ok = true;
		REP(k, sz / 2) ok &= S[i + k] == S[i + sz / 2 + k];
		if (ok) chmax(ans, sz);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

fa = [x for x in range (n + 1)]
siz = [1 for i in range (n + 1)]
dep = [0 for i in range (n + 1)]
e = [1 for i in range (n + 1)]

def find (x) :
    if (fa[x] == x) :
        return x
    fa[x] = find (fa[x])
    return fa[x]

def uni (x, y) :
    u, v = find (x), find (y)
    if (dep[u] >= dep[v]) :
        fa[v] = u
        if (u != v) :
            siz[u] += siz[v]
        if (dep[u] == dep[v]) :
            dep[u] += 1
    else :
        fa[u] = v
        if (u != v) :
            siz[v] += siz[u]

for i in range (m) :
    a, b = list (map (int, input ().split ()))
    uni (a, b)
    e[a] += 1
    e[b] += 1

for i in range (1, n + 1) :
    siz[i] = siz[find (i)]

for i in range (k) :
    c, d = list (map (int, input ().split ()))
    if (find (c) == find (d)) :
        siz[c] -= 1
        siz[d] -= 1

siz = [siz[i] - e[i] for i in range (1, n + 1)]

print (' '.join (list (map (str, siz))))

Measured memory_bytes: 19480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        double x = 0.0;
        double y = 0.0;
        int dir = 90;

        while (true) {
            String[] input = br.readLine().split(",");
            if (input[0].equals(input[1]) && input[0].equals("0")) {
                break;
            }

            int distance = Integer.parseInt(input[0]);
            int rotate = Integer.parseInt(input[1]);

            x += Math.cos(dir / 180.0 * Math.PI) * distance;
            y += Math.sin(dir / 180.0 * Math.PI) * distance;
            dir -= rotate;
        }

        Double xx = new Double(x);
        Double yy = new Double(y);

        System.out.printf("%d%n%d%n", xx.intValue(), yy.intValue());
    }
}


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

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#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(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
int K;

signed main()
{
    cin >> N >> K;

    int ans = N - (K - 1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstdlib>
#include <cmath>
#define MAX 10001
using namespace std;
typedef long long lld;
int main(void) {
    int x, ans=1, tmp;
    cin >> x;
    
    for(int i=2; i<=x; i++) {
        tmp=i*i;
        if(tmp > x) break;
        while(tmp<=x) {
            ans = max(ans, tmp);
            tmp *= i;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
    ll x,a,n=100,cun=0;
    cin>>x;
    while(x > n){
        a = n * 0.01;
        n += a;
        cun++;
    }
    cout<<cun<<"\n";
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int x,y,z;
int main(){
  cin>>x>>y>>z;
  int u=99999;
  u=min(u,x+y);u=min(u,z+y);u=min(u,x+z);
  cout<<u;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string a,b,c;

	cin>>a;
	cin>>b;
	cin>>c;
	int r=1;
	int a2=a.size(),b2=b.size(),c2=c.size();
	int a3=-1,b3=-1,c3=-1;
	rep(i,1000000){
		if(r==1){
			if(a[a3+1]=='a')r=1;
			if(a[a3+1]=='b')r=2;
			if(a[a3+1]=='c')r=3;
			a3++;
			if(a2==0){
				cout<<"A"<<endl;
				return 0;
			}
			a2--;
		}else if(r==2){
			if(b[b3+1]=='a')r=1;
			if(b[b3+1]=='b')r=2;
			if(b[b3+1]=='c')r=3;
			b3++;
			if(b2==0){
				cout<<"B"<<endl;
				return 0;
			}
			b2--;
		}else if(r==3){
			if(c[c3+1]=='a')r=1;
			if(c[c3+1]=='b')r=2;
			if(c[c3+1]=='c')r=3;
			c3++;
			if(c2==0){
				cout<<"C"<<endl;
				return 0;
			}
			c2--;
		}
	}
	return 0;
}


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

int main(void) {
  char R[256], S[108];
  scanf("%s\n", R); scanf("%s\n", S);
  strncat(R, R, strlen(S));

  if (strstr(R, S)) printf("Yes\n");
  else              printf("No\n");
  return 0;
}

Measured memory_bytes: 536
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            sbyte[] l = Console.ReadLine().Split(' ').Select(x => sbyte.Parse(x)).ToArray();
            if (l[0] + l[1] + l[2] == -3) break;

            if (l[0] < 0 || l[1] < 0 || l[0] + l[1] < 30)
            {
                Console.WriteLine("F");
            }
            else if (l[0] + l[1] < 50 && l[2] < 50)
            {
                Console.WriteLine("D");
            }
            else if (l[0] + l[1] < 65)
            {
                Console.WriteLine("C");
            }
            else if (l[0] + l[1] < 80)
            {
                Console.WriteLine("B");
            }
            else
            {
                Console.WriteLine("A");
            }
        }
    }
}

Measured memory_bytes: 9208
import java.util.*;
import java.lang.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int d =0;
        int count =1;
        for(int i = 0; i < n; i++){
            d = d + sc.nextInt();
            if(d <= x){
                count ++;
            }else if(d >x){
                break;
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define LIMIT 100

int main(void){
    int row,col,i,j,rowjudge[LIMIT]={0},coljudge[LIMIT]={0};
    char matrix[LIMIT][LIMIT];
    scanf("%d %d",&row,&col);

    // 初期化
    for(i=0; i<LIMIT; i++){
        for(j=0; j<LIMIT; j++){
            matrix[i][j]='\0';
        }
    }

    // 入力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            scanf(" %c",&matrix[i][j]);
        }
    }

    // 各行、各列に黒が１つでもあるかを判別
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(matrix[i][j]=='#'){
                rowjudge[i]=1;
            }
        }
    }
    for(j=0; j<col; j++){
        for(i=0; i<row; i++){
            if(matrix[i][j]=='#'){
                coljudge[j]=1;
            }
        }
    }

    // 黒が１つでもある行と列の重なる要素のみを出力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(rowjudge[i]==1 && coljudge[j]==1){
                printf("%c",matrix[i][j]);
            }
        }
        if(rowjudge[i]==1){
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1672
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
inf = float('inf')
def main():
    n = I()
    s = [0]*n
    for i in range(n):
        s[i] = I()
    s_sum = sum(s)
    if s_sum%10 != 0:
        print(s_sum)
        sys.exit()
    s_min = inf
    for ss in s:
        if (ss%10 != 0) and (ss < s_min):
            s_min = ss
    if s_min == inf:
        print(0)
    else:
        print(s_sum-s_min)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
import sys
from string import ascii_lowercase as a2z

input = sys.stdin.readline


def main():
    S = input().rstrip()
    T = input().rstrip()

    N = len(S)
    memo = [None] * N
    memo[-1] = {alphabet: -1 for alphabet in a2z}
    memo[-1][S[-1]] = N - 1
    for i in reversed(range(N - 1)):
        memo[i] = memo[i + 1].copy()
        memo[i][S[i]] = i

    ans = 0
    idx_S = 0
    for t in T:
        i = memo[idx_S][t]
        if i == -1:
            ans += (N - idx_S)
            idx_S = 0
            i = memo[idx_S][t]
            if i == -1:
                ans = -1
                break
            else:
                ans += i - idx_S + 1
                if i == N - 1:
                    idx_S = 0
                else:
                    idx_S = i + 1
        else:
            ans += i - idx_S + 1
            if i == N - 1:
                idx_S = 0
            else:
                idx_S = i + 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 129472
if isfile("in.txt");mystdin=open("in.txt","r");redirect_stdin(mystdin);end
macro p(z);:((x->parse(Int,x)).(split($z)));end
function main()
  a,b=@p(readline())
  print(b%a==0 ? a+b : b-a)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 115036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
//int main() {
//    cin.tie(0);
//    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(10);
//
//}
// GET A[i]: the longest common prefix size of S and S[i:n-1]
template<typename S>
void z_algorithm(const S& s, vector<int>& A) {
    int n = s.size();
    A.resize(n);
    A[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue; }
        int k = 1;
        while (i+k < n && k+A[k] < j) { A[i+k] = A[k]; ++k; }
        i += k; j -= k;
    }
}
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        vector<int> a;
        z_algorithm(s.substr(i, n-i), a);
        for (int j = 0; j < a.size(); ++j) {
            if (a[j] <= j) {
                ans = max(ans, a[j]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a_in[3],b_in[3],c_in[3],a_out[3],b_out[3],c_out[3],a,b,c,ah,as,am,bh,bm,bs,ch,cm,cs;
cin>>a_in[0]>>a_in[1]>>a_in[2]>>a_out[0]>>a_out[1]>>a_out[2];
cin>>b_in[0]>>b_in[1]>>b_in[2]>>b_out[0]>>b_out[1]>>b_out[2];
cin>>c_in[0]>>c_in[1]>>c_in[2]>>c_out[0]>>c_out[1]>>c_out[2];
a=((a_out[0]*3600)+(a_out[1]*60)+a_out[2])-((a_in[0]*3600)+(a_in[1]*60)+a_in[2]);
b=((b_out[0]*3600)+(b_out[1]*60)+b_out[2])-((b_in[0]*3600)+(b_in[1]*60)+b_in[2]);
c=((c_out[0]*3600)+(c_out[1]*60)+c_out[2])-((c_in[0]*3600)+(c_in[1]*60)+c_in[2]);
ah=a/3600;
am=(a%3600)/60;
as=(a%3600)%60;
bh=b/3600;
bm=(b%3600)/60;
bs=(b%3600)%60;
ch=c/3600;
cm=(c%3600)/60;
cs=(c%3600)%60;
cout<<ah<<" "<<am<<" "<<as<<endl;
cout<<bh<<" "<<bm<<" "<<bs<<endl;
cout<<ch<<" "<<cm<<" "<<cs<<endl;
return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int H = int.Parse(str[1]);
		int W = int.Parse(str[2]);
		int ans = 0;
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			int A = int.Parse(str2[0]);
			int B = int.Parse(str2[1]);
			if(A>=H && B>=W){
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define max 1e9+7
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, k;
    cin>>n>>k;

    vector<long long> a(n);
    vector<long long> dp(n, max);
    dp[0]=0;
    
    for(long long i=0; i<n; i++) 
        cin>>a[i];
    for(long long i=0; i<n; i++){
        for(long long j=i+1; j<=i+k; j++){
            if(j<n){
                dp[j] = min(dp[j], dp[i] + abs(a[i]-a[j]));
            }
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
arr = [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]

k = int(input())
print(arr[k-1])

Measured memory_bytes: 3060
#include <iostream>
#include <map>
using namespace std;
int n, res;
map<int, int> mp;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int a = itr -> first, b = itr -> second;
        if (a < b) res += b - a;
        if (a > b) res += b;
    }
    cout << res << endl;
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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

int main() {
    string S;
    cin >> S;
    
    vector<int> v(26,0);
    
    REP(i,S.size()){
        v[S[i]-'a'] = 1;
    }
    
    REP(i,26){
        //cout << v[i] << endl;
        if ( v[i] == 0 ) {
            char x = i + 'a';
            cout << x << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    
    
    return 0;
}


Measured memory_bytes: 3724
N = int(input())

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


x = sum(a)
y = 0
su = N
ans = float("inf")

a.reverse()

for i in a:

        x -= i
        y += i
        su -= 1

        if su != N and su != 0:
            ans = min (ans , abs(x-y))

            #print (su,x,y)

print (ans)

Measured memory_bytes: 76880
/*
 * main.c
 *
 *  Created on: 2019/03/03
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int ans[100] = {0};

int main()
{
	int a = 0, b = 0, k = 0;
	int i = 1;
	int ar = 0, br = 0;
	int j = 0;
	scanf("%d %d %d", &a, &b, &k);

	for(i = 1; i <= 100; i++ ) {
		ar = a%i;
		br = b%i;
		if ((ar == 0) && (br == 0)) {
			ans[j] = i;
			// printf("%d\n",i);
			j++;
		}
	}
	printf("%d\n", ans[j-k]);
	return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	LL n, m;
	cin >> n >> m;
	LL lt = 0, rt = n + m;
	while(lt < rt){
		LL md = (lt + rt + 1) >> 1;
		LL d = max(md - n, 0LL);
		if((d + md) * 2 <= m){
			lt = md;
		}
		else{
			rt = md - 1;
		}
	}
	cout << lt << endl;
	
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

#define MAX_M 100000
typedef long long int ll;

struct UnionFind {
  std::vector<int> par;

  UnionFind(int n) : par(n, -1) {}

  int root(int i) {
    if(par[i] < 0) return i;
    return par[i] = root(par[i]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;

    if(size(rx) < size(ry)) std::swap(rx, ry);
    par[rx] += par[ry];
    par[ry] = rx;
    return;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }

  int size(int x) {
    return -par[root(x)];
  }

};

int main() {
  int n, m, a[MAX_M], b[MAX_M];
  std::cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    std::cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; ++i) {
    a[i]--;
    b[i]--;
  }

  UnionFind tree(n);
  ll ans[MAX_M];
  ans[m-1] = (ll) n * (n - 1) / 2;

  for(int i = m - 1; i >= 0; --i) {
    if(tree.same(a[i], b[i])) {
      ans[i - 1] = ans[i];
    } else {
      ll na = tree.size(a[i]), nb = tree.size(b[i]);
      ans[i - 1] = ans[i] - na * nb;
    }
    tree.unite(a[i], b[i]);
  }

  for(int i = 0; i < m; ++i) {
    std::cout << ans[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

string s;
int res[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s;
    s = s + "R";
    int lastR = -1, firstL = -1, cntE = 0, cntO = 0;
    FOR(i,0,SZ(s)-1) {
        if (s[i] == 'R') {
            if (firstL == -1) {
                lastR = i;
            }
            else {
                // handle here
                if (firstL % 2) {
                    res[firstL] = cntO;
                    res[lastR] = cntE;
                }
                else {
                    res[firstL] = cntE;
                    res[lastR] = cntO;
                }

                cntE = cntO = 0;
                lastR = i;
                firstL = -1;
            }
        }
        else {
            if (firstL == -1) {
                firstL = i;
            }
        }
        if (i % 2) cntO++;
        else cntE++;
    }
    FOR(i,0,SZ(s)-2) cout << res[i] << " ";
    return 0;
}


Measured memory_bytes: 1004
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;



int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int ans=0;
        for(int i=105;i<=n;i+=2)
        {
            int tnt=0;
            for(int j=1;j<=i;j++)
            {
                if(i%j==0) tnt++;
            }
            if(tnt==8) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long l = sc.nextLong();
		long r = sc.nextLong();
		long CONST_YEAR = 2019l;
		long resultMod =2019l;

		for (long i = l; i < r; i++) {
			for (long j = i+1; j <= r; j++) {
				long result = i*j;
				long mod = result % CONST_YEAR;
				if(mod == 0l){
					resultMod =0;
					break;
				}
				resultMod =Math.min(mod, resultMod);
			}
			if(resultMod==0l){
				break;
			}
		}

		System.out.println(resultMod);

	}

}


Measured memory_bytes: 22996
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	cout << n * 800 - (n/15)*200 << endl;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a>=b&&a%b==0){
    cout<<a/b<<endl;
  }
  else if(a>=b&&a%b!=0){
    cout<<a/b+1<<endl;
  }
  else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int rui[200001];

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    int time = 0;
    for(int i = 0;i<N;i++) {
        cin >> retu.at(i);
        time += retu.at(i);
    }
    vector<int> ans;

    int M;cin >> M;
    for(int i = 0;i<M;i++){
        int A,B;cin >>A >> B;
        A--;
        ans.push_back(time+(B-retu.at(A)));
    }

    for(int i = 0;i<ans.size();i++)cout << ans.at(i) << endl;


    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;

string s;
string target = "keyence";
int main() {
	cin >> s;
	int n = s.length();

	bool ans = false;
	for (int i = 0; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			string t = s.substr(0, i) + s.substr(j);
			if (t == "keyence") {
				ans = true;
			}
		}
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}
}



Measured memory_bytes: 256
#include<stdio.h>
void swap(int *x,int *y);

int main(void){
  int w,n,tate[30],a[30],b[30],i;
  scanf("%d %d",&w,&n);
  for(i=0;i<w;i++) tate[i]=i+1;
  for(i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
    swap(&tate[a[i]-1],&tate[b[i]-1]);
  }
  for(i=0;i<w;i++) printf("%d\n",tate[i]);


  return 0;
}

void swap(int *x,int *y){
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,p[11];
  cin>>n;
  FOR(i,n) cin>>p[i];
  int ans=0;
  sort(p,p+n,greater<int>());
  ans+=p[0]/2;
  SFOR(i,1,n) ans+=p[i];
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
const int MAX=2e5+5;
int a[MAX],b[MAX],pref[MAX];
int32_t main()
{
  BOOST;
	int n,m,k;
	cin>>n>>m>>k;
	int ans=0;
	for (int i=1;i<=n;i++)cin>>a[i];
	for (int i=1;i<=m;i++)cin>>b[i],pref[i]=pref[i-1]+b[i];
	int sum=0;
	int wskaznik=m;
	for (int i=1;i<=m;i++)
	{
		if (pref[i]<=k)ans=max(ans,i);
	}
	for (int i=1;i<=n;i++)
	{
		sum+=a[i];
				if (sum>k)break;
		while (m>=1 && sum+pref[wskaznik]>k)wskaznik--;
		ans=max(ans,i+wskaznik);
	}
	cout<<ans;
  return 0;
}

Measured memory_bytes: 8324
# https://atcoder.jp/contests/abc082/tasks/arc087_a
# C - Good Sequence
import collections

n = int(input().split()[0])
a_list = list(map(int, input().split()))

# 取り除くことはできる
# 追加はできない

counter = collections.Counter(a_list)

c = 0

# x個より小さい値xは完全に取り除くしかない
c += sum([v for k, v in counter.items() if v < k])
# x個ちょうどの値xには何もしない
# x個より多い値xは、値xと個数の差分を数える
c += sum([v - k for k, v in counter.items() if v > k])

print(c)


Measured memory_bytes: 18676
using System;
using System.Linq;
using System.Collections.Generic;

class PriorityQueue<T>
{
    private readonly List<T> heap;
    private readonly Comparison<T> compare;
    private int size;
    public PriorityQueue() : this(Comparer<T>.Default) { }
    public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) { }
    public PriorityQueue(Comparison<T> comparison) : this(16, comparison) { }
    public PriorityQueue(int capacity, Comparison<T> comparison)
    {
        this.heap = new List<T>(capacity);
        this.compare = comparison;
    }
    public void Enqueue(T item)
    {
        this.heap.Add(item);
        var i = size++;
        while (i > 0)
        {
            var p = (i - 1) >> 1;
            if (compare(this.heap[p], item) <= 0)
                break;
            this.heap[i] = heap[p];
            i = p;
        }
        this.heap[i] = item;

    }
    public T Dequeue()
    {
        var ret = this.heap[0];
        var x = this.heap[--size];
        var i = 0;
        while ((i << 1) + 1 < size)
        {
            var a = (i << 1) + 1;
            var b = (i << 1) + 2;
            if (b < size && compare(heap[b], heap[a]) < 0) a = b;
            if (compare(heap[a], x) >= 0)
                break;
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        heap.RemoveAt(size);
        return ret;
    }
    public T Peek() { return heap[0]; }
    public int Count { get { return size; } }
    public bool Any() { return size > 0; }
}

class MyClass
{
    public static void Main(string[] args)
    {
        var q = new PriorityQueue<int>((x, y) => y - x);
        string s;
        while ((s = Console.ReadLine()) != "end")
        {
            if (s == "extract")
            {
                Console.WriteLine(q.Dequeue());
            }
            else
            {
                var n = int.Parse(s.Split()[1]);
                q.Enqueue(n);
            }
        }
    }
}


Measured memory_bytes: 27616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/scc>

int main() {
	int N, M;
	cin >> N >> M;
	
	atcoder::scc_graph g(N);
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		g.add_edge(a, b);
	}
	auto dat = g.scc();
	cout << dat.size() << endl;
	for (auto &v : dat) {
		printf("%d", v.size());
		REP(i, v.size()) printf(" %d", v[i]);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 40096
icase=0
if icase==0:
    n,m=map(int, input().split())
    a=[]
    b=[]
    for i in range(m):
        ai,bi=map(int, input().split())
        a.append(ai)
        b.append(bi)
elif icase==1:
    n=6
    m=5
#    a=[[1],[2],[3],[4],[5]]
#    b=[[2],[3],[4],[5],[6]]
    a=[1,2,3,4,5]
    b=[2,3,4,5,6]
elif icase==2:
    n=7
    m=7
    a=[1,2,3,4,4,5,6]
    b=[3,7,4,5,6,6,7]

    
vtx=[]
for i in range(n):
    vtx.append([i+1])
icnt=0

for j in range(m):    
    vtx1=vtx.copy()
    a1=a.copy()
    b1=b.copy()
    del a1[j]
    del b1[j]
    
    for i in range(m-1):
        for v1 in vtx1:
            if a1[i] in v1:
                if not b1[i] in v1:
                    for v2 in vtx1:
                        if v1!=v2:
                            if b1[i] in v2:
                                break
                    vtx1.remove(v1)
                    vtx1.remove(v2)
                    v3=v1+v2
                    vtx1.append(v3)
#        print(a[i],b[i],len(vtx1),vtx1)
#    print(len(vtx1),vtx1)
    if len(vtx1)!=1:
        icnt=icnt+1
print(icnt)        

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

res = n
for i in range(0, n+1):
    cnt = 0
    val = i
    while val > 0:
        cnt += val % 6
        val //= 6
    val = n - i
    while val > 0:
        cnt += val % 9
        val //= 9
    if res > cnt:
        res = cnt

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N=110;

int main()
{
    int L;
    scanf("%d",&L);
    double ans=1.0*L/3;
    printf("%.6f\n",ans*ans*ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(s,t) for (int s = 0; s < t; ++s);
using ll = long long;


int main() {
  int n;

  cin >> n;

  if (n % 2 == 0){
    cout << n / 2 << endl;
  }

  if (n % 2 == 1){
    cout << n / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256