akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string S;
    cin >> S;
    
    string nS;
    for(int i=1; i<S.size(); i++) {
        if(S[i-1]=='B' && S[i]=='C') {
            nS += "D";
            i++;
        } else {
            nS.push_back(S[i-1]);
        }
    }
    // cout << nS << endl;

    long long int ans=0;
    vector<long long int> vec(nS.size()+1, 0);
    for(int i=0; i<nS.size(); i++) {
        if(nS[i]=='A') {
            vec[i+1]=vec[i]+1;
        } else if(nS[i]=='D') {
            vec[i+1]=vec[i];
        }
        
        if(nS[i]=='D') {
            ans += vec[i+1];
        }
        // cout << vec[i+1] << " ";
    }
    // cout << endl;

    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 2312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC81_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(a);
            Array.Reverse(a);
            long b = 0;
            int bi = 0;
            long c = 0;
            for (int i = 0; i < n-1; i++)
            {
                if (a[i] == a[i+1])
                {
                    b = a[i];
                    bi = i + 2;
                    break;
                }
            }
            if (bi > n-2)
            {
                Console.WriteLine(0);
                return;
            }
            for (int i = bi; i < n - 1; i++)
            {
                if(a[i] == a[i+1])
                {
                    c = a[i];
                    break;
                }
            }
            if (c == 0)
            {
                Console.WriteLine(0);
                return;
            }

            Console.WriteLine(c * b);
        }
    }
}


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

int main(){
   long long int a,b,c;
   cin>>a>>b>>c;
   if(a+b>=c)
   {
       cout<<b+c<<endl;
   }
   else
   cout <<a+2*b+1<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,n,m,k,count=0,kotae=0;
  cin>>n>>m>>k;
  a=max(n,m);
  count=k/a;
  if(k%a==0){
  }
  else{
    count++;
  }
  cout<<count;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
            var x1 = inputs[0];
            var y1 = inputs[1];
            var x2 = inputs[2];
            var y2 = inputs[3];

            var lineX = Math.Abs(x2 - x1);
            var lineY = Math.Abs(y2 - y1);
            var result = Math.Sqrt(Math.Pow(lineX, 2) + Math.Pow(lineY, 2));

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 5788
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new  Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double gal = a - b;
		if(gal>0) {
			System.out.println("GREATER");
		}else if(gal<0) {
			System.out.println("LESS");
		}else if(gal == 0) {
			System.out.println("EQUAL");
		}
	}
 
}

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

int main()
{

	//freopen("in.txt","r",stdin);
	int R,G,B;
	cin>>R>>G>>B;
	int k;
	cin>>k;

	for(int i=1;i<=k;i++)
	{
		if(R>=G)
			G*=2;
		else B*=2;
	}
	if(R<G and G<B)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

#define FOR(i, a, b) for(int(i)=(a);(i)<(b);(i)++)
#define REP(i, n) FOR((i), 0, (n))

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

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

	int a, b;
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b)cout<<"Alice"<<endl;
	else if(a<b)cout<<"Bob"<<endl;
	else cout<<"Draw"<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
int main(){
  int a,b,A[MAX]={-1},B[MAX],count=0,i,j,c,t;
  scanf("%d",&a);
  scanf("%d",&A[0]);
  for(i=1,c=1;i<a;i++){
    scanf("%d",&t);
    if(A[c-1]<t){A[c]=t;c++;}
  }

  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&B[i]);
  }
  i=c;
  for(i=0;i<b;i++){
    for(j=0;j<a;j++){
      if(A[j]==B[i]){count++;break;}
      if(A[j]>B[i]){break;}
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define mod 1000000009
#define int long long 
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
	return ans;
}
signed main() {
    garou;
    int n;
	cin>>n;
		int re=0;
		int x=1;
		map<int,int> mp;
		while((x*x)<=n){
			int y=1;
			while((y*y)<=n){
				int z=1;
				while((z*z)<=n){
					int a=pow(x,2)+pow(y,2)+pow(z,2)+(x*y)+(y*z)+(x*z);
					mp[a]++;
					z++;
				}
				y++;
			}
		x++;
		}
		for(int i=1;i<=n;i++)
		cout<<mp[i]<<endl;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

const int N = 2e5 + 5;
int par[N], fr[N], ans[N], sz[N], vis[N];
vector<int> e[N], blk[N];
int cnt;

int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
}

void join(int u, int v){
    u = find(u);
    v = find(v);
    if(sz[u] > sz[v]) swap(u, v);
    par[u] = v;
    sz[v] += sz[u];
}

void dfs(int u){
    vis[u] = 1;
    cnt++;
    for(int v : e[u]) if(!vis[v]){
        join(u, v);
        dfs(v);
    }
}

void dfs2(int u){
    vis[u] = 2;
    int bl = 0;
    for(int b : blk[u]) if(find(u) == find(b)) bl++;
    ans[u] = cnt - fr[u] - 1 - bl;
    for(int v : e[u]) if(vis[v] != 2) dfs2(v);
}

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

    for(int i = 1; i <= n; i++) par[i] = i;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
        fr[u]++;
        fr[v]++;
    }

    for(int i = 0; i < k; i++){
        int u, v;
        cin >> u >> v;

        blk[u].pb(v);
        blk[v].pb(u);
    }

    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            cnt = 0;
            dfs(i);
            dfs2(i);
        }
    }

    for(int i = 1; i <= n; i++) cout << ans[i] << " ";
    return 0;
}



Measured memory_bytes: 21112
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long solve(vector<long long> c, vector<long long> w, long long m) {
  if (c.empty()) {
    return 0;
  }
  if ((int)c.size() == 1) {
    return m / c[0] * w[0];
  }
  if ((int)c.size() == 2) {
    long long res = 0;
    for (int i = 0; c[0] * i <= m; ++i) {
      res = max(res, w[0] * i + (m - c[0] * i) / c[1] * w[1]);
    }
    return res;
  }
  long long res = 0;
  for (int i = 0; c[0] * i <= m; ++i) {
    for (int j = 0; c[0] * i + c[1] * j <= m; ++j) {
      res = max(res, w[0] * i + w[1] * j + (m - c[0] * i - c[1] * j) / c[2] * w[2]);
    }
  }
  return res;
}

int main() {
  int m;
  scanf("%d", &m);
  int xa[3];
  for (int i = 0; i < 3; ++i) {
    scanf("%d", xa + i);
  }
  vector<long long> ca, wa, cb, wb;
  for (int i = 0; i < 3; ++i) {
    int xb;
    scanf("%d", &xb);
    if (xb >= xa[i]) {
      ca.push_back(xa[i]);
      wa.push_back(xb - xa[i]);
    } else {
      cb.push_back(xb);
      wb.push_back(xa[i] - xb);
    }
  }
  long long ans = m;
  ans += solve(ca, wa, m);
  ans += solve(cb, wb, ans);
  printf("%lld\n", ans);
}


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

int main(){
  string s;
  cin >> s;
  int p=0,m=0;
  for (int i=0; i<4; i++){
    if (s.at(i)=='+'){
      p++;
    }
    else{
      m++;
    }
  }
  cout << p-m << endl;
}

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

const int INF = 1001001001;

int main(){
   long long n;
   cin >> n;
   long long m;
   m = sqrt(n);
   long long a;
   for(long long i=m;i>=1;i--){
       if(n%i == 0){
          a = i ;
          break;
       }
   }
   long long b = n / a;
   long long ans = a + b - 2;
   cout << ans  <<endl;
}

Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let v: Vec<i32> = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();
    if v[0] == v[1] && v[0] == v[2] {
        println!("1");
    } else if v[0] == v[1] || v[1] == v[2] || v[0] == v[2] {
        println!("2");
    } else {
        println!("3");
    }
}


Measured memory_bytes: 4352
#include <iostream>

typedef long long ll;
typedef unsigned long long ull;

constexpr size_t MAXN = 1e5;
constexpr int MOD = 1e9 + 7;

ll dp[MAXN + 1] = {};

void solve() {
  int N, W;
  std::cin >> N >> W;
  dp[0] = 0;

  for (int i = 0; i < N; ++i) {
    int w, v;
    std::cin >> w >> v;
    for (int w_in = W - w; w_in >= 0; --w_in) {
      dp[w_in + w] = std::max(dp[w_in] + v, dp[w_in + w]);
    }
  }
  ll answer = 0;
  for (int i = 0; i <= W; ++i) {
    answer = std::max(answer, dp[i]);
  }

  std::cout << answer << "\n";
}

void warp() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
}

int main() {
  warp();
  solve();
  return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <string.h>

using namespace std;




int main()
{
    int64_t n;
    cin>>n;
    char s[1000];
    int k=0,i;
    while(n)
    {
      if(n%26==0) { s[k++]='z';n/=26;n--;}
      else {s[k++]='a'+n%26-1;
        n/=26;}
    }
    for(i=k-1;i>=0;i--)
       printf("%c",s[i]);

    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int ans = max<int> ({
    A * 10 + B + C,
    A + B * 10 + C,
    A + B + C * 10,
  });
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
q = int(input())
s_s = []
s_e = []
sw = 0
for i in range(q):
    Q = list(map(str,input().split()))
    if int(Q[0]) == 1:
        sw += 1
    else:
        if (int(Q[1]) + sw)%2 == 0:
            s_s.append(Q[2])
        else:
            s_e.append(Q[2])
if sw%2 != 0:
    ans = s_s[::-1] + list(s[::-1]) + s_e
    print("".join(ans))
else:
    ans = s_e[::-1] + list(s) + s_s
    print("".join(ans))

Measured memory_bytes: 9360
#include<bits/stdc++.h>
#define ll long long
#define N 1123
#define endl '\n'

using namespace std;

ll n, x, ans, a, b, q;
map<ll, ll> f;

int main() {
    ios_base::sync_with_stdio(0);

    cin >> n;

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

    cin >> q;

    while(q--) {
        cin >> a >> b;
        ans -= (a * f[a]);
        ans += (b * f[a]);
        f[b] += f[a];
        f[a] = 0;
        cout << ans << endl;
    }


    return 0;

}


Measured memory_bytes: 9500
use std::io;
use std::i64;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main()
{
    // input
    let a = read::<i64>();



    // output
    println!("{0}", a + a*a+ a*a*a);
}

Measured memory_bytes: 2108
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    if (A % 2 == 0) {
        if (B % 2 == 0) {
            ll num = (B - A) / 2;
            if (num % 2 == 0) {
                ans = B;
            } else {
                ans = 1 ^ B;
            }
        } else {
            ll num = (B + 1 - A) / 2;
            if (num % 2 == 0) {
                ans = 0;
            } else {
                ans = 1;
            }
        }
    } else {
        if (B % 2 == 0) {
            ll num = (B - (A + 1)) / 2;
            if (num % 2 == 0) {
                ans = (A ^ B);
            } else {
                ans = (A ^ B) ^ 1;
            }
        } else {
            ll num = (B - A) / 2;
            if (num % 2 == 0) {
                ans = A;
            } else {
                ans = 1 ^ A;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
	string str;

	cin >> str;

	int ans = 0;

	for (int i = 0; i < str.length() / 2; i++) {
		if (str[i] != str[str.length() - i - 1]) {
			ans++;
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x%y);
}

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

	string S;
	cin >> S;
	int res = 0;
	int i = 0;
	int N = S.size();
	while (i < N) {
		int cnt = 0;
		while (i < N && (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')) {
			i++;
			cnt++;
		}
		res = max(res, cnt);
		i++;
	}
	cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  var N = Number(input[0]);
  var X = input[1].split(" ");
  X = X.map(x => Number(x));
  X.sort(function(a, b) {
    if (a < b) return -1;
    if (a > b) return 1;
    return 0;
  });

  var totalSum = [];
  for (var i = X[0]; i <= X[N - 1]; i++) {
    var total = X.map(x => {
      return (x - i) * (x - i);
    });
    totalSum.push(
      total.reduce(function(a, x) {
        return a + x;
      })
    );
    // more statements
  }

  console.log(Math.min.apply(null, totalSum));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7588
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a = 0, n, l, r;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &l, &r);
        a += (r - l + 1);
    }
    printf("%d\n", a);
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

class Program
{
	static void Main(string[] args)
	{
		long n = Scan.Long();
		long[] ary = new long[n];
		for (long i = 0; i < n; i++)
		{
			long a = Scan.Long();
			ary[i] = a;
		}

		Dictionary<long, long> dic = new Dictionary<long, long>();
		var sorted_ary = (long[])ary.Clone();
		Array.Sort(sorted_ary);
		for (long i = 0; i < n; i++)
		{
			dic[sorted_ary[i]] = i;
		}

		for (long i = 0; i < n; i++)
		{
			ary[i] = dic[ary[i]];
		}

		int sum = 0;
		for (long i = 0; i < n; i++)
		{
			if (i % 2 != ary[i] % 2)
			{
				sum++;
			}
		}

		Console.WriteLine((int)Math.Ceiling(sum / 2.0));
	}
}



static class Scan
{
	static Queue<string> _queue = new Queue<string>();
	public static string Str()
	{
		return Read();
	}
	public static char Char()
	{
		return Read()[0];
	}
	public static int Int()
	{
		return int.Parse(Read());
	}
	public static long Long()
	{
		return long.Parse(Read());
	}
	public static BigInteger BigInt()
	{
		return BigInteger.Parse(Read());
	}
	public static double Double()
	{
		return double.Parse(Read());
	}
	static string Read()
	{
		if (_queue.Count > 0)
			return _queue.Dequeue();
		foreach (var s in Console.ReadLine().Split()) _queue.Enqueue(s);
		return _queue.Dequeue();
	}
}


Measured memory_bytes: 16064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > 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());
  return (ret);
}
/*
小数の桁数を指定する
	cout << setprecision(8)<< mp[0]-mx << endl;
*/

int main()
{
	ll i,j,k,a,b,ans=0;
	char c;
	ll N,M,T;
	// vector<ll> mp;
	string s;
	cin>>N;
	cin>>s;
	for(i=0;i<s.size();++i)
	{
		cout << (char)('A'+(s[i]+N-'A')%26);
	}
	cout << endl;


	return 0;
}




















Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
   int k,n;
   cin>>k>>n;
  
   int arr[n];
   
   for(int i=0;i<n;i++)
     cin>>arr[i];
  
  
   int mx = arr[0]-arr[n-1]+k;
  
   for(int i=1;i<n;i++)
   {
     mx = max(mx , arr[i]-arr[i-1]);
   }
  
   cout<<(k-mx)<<endl;
}


Measured memory_bytes: 1152
//lcj ak ioi
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 998244353;
inline void upd(int &a,int b)
{
	a += b;
	if(a >= mod) a -= mod;
}
int N,M;
int fac[2000005],inq[2000005];
int qpow(int x,int y)
{
	int ans = 1;
	while(y)
	{
		if(y&1) ans = 1ll*ans*x%mod;
		x = 1ll*x*x%mod;y >>= 1;
	}
	return ans;
}
void init()
{
	fac[0] = 1;
	for(int i = 1;i <= 2000000;i ++)
		fac[i] = 1ll*i*fac[i-1]%mod;
	inq[2000000] = qpow(fac[2000000],mod-2);
	for(int i = 1999999;i >= 0;i --)
		inq[i] = 1ll*inq[i+1]*(i+1)%mod;
}
inline int C(int x,int y) { return 1ll*fac[x]*inq[x-y]%mod*inq[y]%mod; }
int solve(int sm)
{
	if(sm < 0)
		return 0;
	//sum = sm, atmost M odd
	int r = min(min(N,M),sm);
	int ans = 0;
	for(int i = sm&1;i <= r;i += 2)
		ans = (ans+1ll*C(N,i)*C(N+((sm-i)>>1)-1,N-1))%mod;
	return ans;
}
signed main()
{
	init();
	scanf("%lld%lld",&N,&M);
	printf("%lld\n",(solve(3*M)-1ll*solve(M-1)*N%mod+mod)%mod);
	return 0;
}

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

int main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(1, -1e18);
  while (a--) {
    ll x;
    cin >> x;
    s.push_back(x);
  }
  s.push_back(1e18);
  vector<ll> t(1, -1e18);
  while (b--) {
    ll x;
    cin >> x;
    t.push_back(x);
  }
  t.push_back(1e18);
  while (q--) {
    ll x;
    cin >> x;
    int i = lower_bound(begin(s), end(s), x) - begin(s);
    int j = lower_bound(begin(t), end(t), x) - begin(t);
    ll res = 1e18;
    for (int ii : {i - 1, i})
      for (int jj : {j - 1, j}) {
        res = min(res, abs(s[ii] - x) + abs(t[jj] - s[ii]));
        res = min(res, abs(t[jj] - x) + abs(s[ii] - t[jj]));
      }
    cout << res << endl;
  }
}


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n;
    cin >> n;
    string s;
    cin >> s;

    vvi cnt(n, vi(3));
    vector<vvi> v(n, vvi(n, vi(3)));
    rep(i, n) {
        for (int j = 1; j < n - i; j++) {
            if (s[i] == s[i + j]) continue;

            if (s[i] != 'R' && s[i + j] != 'R') v[i][j][0]++, cnt[i][0]++;
            else if (s[i] != 'G' && s[i + j] != 'G') v[i][j][1]++, cnt[i][1]++;
            else v[i][j][2]++, cnt[i][2]++;
        }
    }

    ll c = 0;
    rep(i, n) {
        for (int j = 1; j < n - i; j++) {
            int t = s[i] == 'R' ? 0 : s[i] == 'G' ? 1 : 2;
            c += cnt[i + j][t] - v[i + j][j][t];
        }
    }

    cout << c;

    return 0;
}


Measured memory_bytes: 878784
N = int(raw_input())
a = raw_input()

b = a.split()
c = [0 for i in range(9)]
for i in range(N):
	b[i] = int(b[i])
	if 1 <= b[i] <=399:
		c[0] = 1
	elif 400 <= b[i] <= 799:
		c[1] = 1
	elif 800 <= b[i] <=1199:
		c[2] = 1
	elif 1200<= b[i] <= 1599:
		c[3] = 1
	elif 1600 <= b[i] <= 1999:
		c[4] = 1
	elif 2000 <= b[i] <= 2399:
		c[5] = 1
	elif 2400 <= b[i] <= 2799:
		c[6] = 1
	elif 2800 <= b[i] <= 3199:
		c[7] = 1
	else:
		c[8] += 1

max = 0
min = 0
for i in range(9):
	max = max + c[i]

min = max - c[8]
if min == 0:
	min = 1
print min,
print max

Measured memory_bytes: 2696
package main

import "fmt"

func main() {
	var c int
	var a string

	fmt.Scanf("%s", &a)

	if a[0] == '1' {
		c++
	}
	if a[1] == '1' {
		c++
	}
	if a[2] == '1' {
		c++
	}
	fmt.Printf("%d\n", c)
}




Measured memory_bytes: 1832
#include<cstdio>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
map<pair<int,int>,int >mp;
struct Edge{
	int to,nxt,weigh;
}edge[2000100];
queue<int>qu1;
int cnt,head[2000100],dis[2000100],times[2000100],Find[2000100];
int n,m,idx,x,y,z;
void addedge(int x,int y,int z){
	edge[++cnt].to=y;
	edge[cnt].nxt=head[x];
	head[x]=cnt;
	edge[cnt].weigh=z;
}
void SPFA(){
	memset(dis,0x3f,sizeof(dis));
	memset(times,0,sizeof(times));
	memset(Find,false,sizeof(Find));
	times[1]=1;
	dis[1]=0;
	Find[1]=true;
	qu1.push(1);
	while(!qu1.empty()){
		int now=qu1.front();
		for(int i=head[now];i;i=edge[i].nxt){
			int upup=edge[i].to;
			if(dis[now]+edge[i].weigh<dis[upup]){
				dis[upup]=dis[now]+edge[i].weigh;
				if(!Find[upup]){
					qu1.push(upup);
					Find[upup]=true;
					times[upup]++;
					if(times[upup]>n) return;				
				}
			}
		}
		qu1.pop();
		Find[now]=false; 
	}
}
int get(int x,int y){
	if(mp[make_pair(x,y)]) return mp[make_pair(x,y)];
	else return mp[make_pair(x,y)]=++idx;
}
int main(){
    scanf("%d%d",&n,&m);
    idx=n;
    for(int i=1;i<=m;i++){
    	scanf("%d%d%d",&x,&y,&z);
    	int id1=get(x,z),id2=get(y,z);
    	addedge(id1,id2,0),addedge(id2,id1,0);
    	addedge(x,id1,1),addedge(id1,x,1);
    	addedge(y,id2,1),addedge(id2,y,1);
	}
	SPFA();
	if(dis[n]>2*n)puts("-1");
	else printf("%d\n",dis[n]/2);
}

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

int main() {
  int64_t A,B,m,n,temp,answer;
  cin >> A;
  cin >> B;
  m=A;
  n=B;
  while (m%n != 0){
    temp=n;
    n=(m%n); 
    m=temp;
  }
  answer = A * B / n;
  cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],ans,x,y;
int main()
{
	cin>>n;
	for(int i=1;i<=n*2;i++)
	{
		cin>>a[i];	
	}
	sort(a+1,a+1+2*n);
	for(int i=1;i<=n*2;i+=2)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
judge = []

while True:
    test_input = list(map(int, input().split()))
    if(test_input[0] == -1 and test_input[1] == -1 and test_input[2] == -1):
        break
    score = test_input[0] + test_input[1]
    if (score >= 80) and not(test_input[0] == -1 or test_input[1] == -1):
        judge.append("A")
    elif (score >= 65 and score < 80) and not(test_input[0] == -1 or test_input[1] == -1):
        judge.append("B")
    elif (score >= 50 and score < 65) and not(test_input[0] == -1 or test_input[1] == -1):
        judge.append("C")
    elif (score >= 30 and score < 50) and not(test_input[0] == -1 or test_input[1] == -1):
        if test_input[2] >= 50:
            judge.append("C")
        else:
            judge.append("D")
    else:
        judge.append("F")

for j in judge:
    print(j)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll q;
  cin >> q;
  deque<ll> dq;
  REP(i, SZ(s)) { dq.push_back(s[i] - 'a'); }
  bool reversed = false;
  while (q--) {
    ll type;
    cin >> type;
    if (type == 1) {
      reversed = !reversed;
      continue;
    }
    ll f;
    char c;
    cin >> f >> c;
    f--;
    if (!(reversed ^ f)) {
      dq.push_front(c - 'a');
    } else {
      dq.push_back(c - 'a');
    }
  }

  if (reversed) {
    IREP(i, SZ(dq)) { cout << (char)(dq[i] + 'a'); }
  } else {
    REP(i, SZ(dq)) { cout << (char)(dq[i] + 'a'); }
  }
  cout << endl;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

vi inds[26];

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

	string s, t;
	cin >> s >> t;
	ll res = 0;
	int n = (int) s.size();
	int m = (int) t.size();
	for(int i = 0; i < n; i++){
		inds[s[i] - 'a'].push_back(i);
	}
	int lst = -1;
	for(int i = 0; i < m; i++){
		if(inds[t[i] - 'a'].empty()) return cout << -1, 0;
		int j = (int) (t[i] - 'a');
		int ind = lower_bound(all(inds[j]), lst + 1) - inds[j].begin();
		int cur = 0;
		if(ind == (int) inds[j].size()) cur = inds[j][0];
		else cur = inds[j][ind];
		if(cur <= lst){
			res += (n - lst - 1);
			res += cur + 1;
		}
		else{
			res += (cur - lst);
		}
		lst = cur;
	}
	cout << res << endl;
}

Measured memory_bytes: 1228
s = input()
p = ['N', 'S', 'E', 'W']
cnt = []
for i in p:
    cnt.append(s.count(i))
if cnt[0] != 0 and cnt[1] != 0 or cnt[0] == 0 and cnt[1] == 0:
    if cnt[2] != 0 and cnt[3] != 0 or cnt[2] == 0 and cnt[3] == 0:
        print("Yes")
    else:
        print("No")
elif cnt[2] != 0 and cnt[3] != 0 or cnt[2] == 0 and cnt[3] == 0:
    if cnt[0] != 0 and cnt[1] != 0 or cnt[0] == 0 and cnt[1] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long hou = 998244353LL;
long long modmulti(long long a,long long b){
    a = a%hou;
    b = b%hou;
    return (a*b)%hou;
}
/*long long modpow(long long a,int p){
    long long ret = 1;
    while(p>0){
        if(p&1){
            ret = modmulti(ret,a);
        }
        a = modmulti(a,a);
        p>>=1;
    }
    return ret;
}*/
long long dp[4000][4000];
int main(){
    int n,s;
    cin >> n >> s;
    dp[0][0] = 1LL;
    vector<long long> a(n);
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    for(int i = 0;i<n;i++){
        for(int j = 0;j<3500;j++){
            if(j+a[i]<3600){
                dp[i+1][j+a[i]] = (dp[i+1][j+a[i]]+dp[i][j])%hou;
            }
            dp[i+1][j] = (dp[i+1][j]+modmulti(2LL,dp[i][j]))%hou;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 97360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
ll MOD = 1000000007;
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;}

int main()
{   
    int n; cin >> n;
    cout << 2*n/__gcd(2,n) << endl;
}

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;

using namespace std;

void print(int a[],int s,int e){for(int i=s;i<=e;i++)cout<<a[i]<<" ";cout<<"\n";}
void print(vector<int> &v,int s,int e){for(int i=s;i<=e;i++)cout<<v[i]<<" ";cout<<"\n";}
void print(vector<int> &v){for(int x:v)cout<<x<<" ";cout<<"\n";}

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*b;x%=m;return x;}

lli H,W,N;
lli a[100010],b[100010];
set<pair<lli,lli> > Set,PO;
lli ans[10];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    slli(H);slli(W);slli(N);
    for(lli i=1;i<=N;i++){
        slli(a[i]);slli(b[i]);
        lli x = a[i],y = b[i];
        PO.insert({x,y});
        Set.insert({x,y});
        Set.insert({x,y-1});
        Set.insert({x,y-2});
        Set.insert({x-1,y});
        Set.insert({x-1,y-1});
        Set.insert({x-1,y-2});
        Set.insert({x-2,y});
        Set.insert({x-2,y-1});
        Set.insert({x-2,y-2});
    }
    lli tot = (max(0ll,H-2)*max(0ll,W-2));
    for(set<pair<lli,lli> > ::iterator it = Set.begin();it != Set.end();it++){
        lli cnt = 0;
        lli x = (*it).F;
        lli y = (*it).S;
        if(x<1 || (x>H-2) || y<1 || y>(W-2))
            continue;
        for(lli i=0;i<=2;i++){
            for(lli j=0;j<=2;j++){
                if(PO.find({(*it).F+i,(*it).S+j}) != PO.end())
                    cnt++;
            }
        }
        ans[cnt]++;
    }
    lli sum = 0;
    for(lli i=1;i<=9;i++)
        sum += ans[i];
    ans[0] = tot - sum;
    for(lli i=0;i<=9;i++)
        cout<<ans[i]<<"\n";

    return 0;
}


Measured memory_bytes: 64256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a = str(input())
print(int(a[0])+int(a[1])+int(a[2]))


Measured memory_bytes: 2940
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n;
    ll x = ceil(n/1000.0);
    cout<<(x*1000)-n<<NL;

    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

const ld EPS = 0.0000000001;
const ld INF = 1e8 + 10;

struct Data {
	ld x, y;
	int dir;	
};

const ld xplus[] = {1, -1, 0, 0};
const ld yplus[] = {0, 0, 1, -1};

ld check(ld t, const vector<Data> &v, int n) {
	ld xmax = -INF, xmin = INF, ymax = -INF, ymin = INF;	
	for(int i = 1; i <= n; i ++) {
		xmax = max(xmax, v[i].x + xplus[v[i].dir] * t);
		xmin = min(xmin, v[i].x + xplus[v[i].dir] * t);

		ymax = max(ymax, v[i].y + yplus[v[i].dir] * t);
		ymin = min(ymin, v[i].y + yplus[v[i].dir] * t);
	}

	ld ans = (xmax - xmin) * (ymax - ymin);
	return ans;
}

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

	int n;
	cin >> n;
	vector<Data> v(n + 1);
	for(int i = 1; i <= n; i ++) {
		cin >> v[i].x >> v[i].y;
		char c;
		cin >> c;
		if(c == 'R')
			v[i].dir = 0;
		if(c == 'L')
			v[i].dir = 1;
		if(c == 'U')
			v[i].dir = 2;
		if(c == 'D')
			v[i].dir = 3;
	}

	ld left = 0, right = 1e8;
	for(int step = 1; step < 200; step ++) {
		ld a = (left * 2 + right) / 3;
		ld b = (left + right * 2) / 3;
		if(check(a, v, n) >=  check(b, v, n))
			left = a;
		else
			right = b;
	//	cout << setprecision(10) << fixed << a  << " " << b << endl;  
	}
	//cout << setprecision(10) << fixed << check(left, v, n) << " " << check(0, v, n) << endl;

	cout << setprecision(12) << fixed << check(left, v, n);	

	return 0;
}


Measured memory_bytes: 4992
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: u64,
        a: [u64; n as usize],
        b: [u64; m as usize],
    }

    solve(n, m, k, &a, &b);
}

fn solve(n: usize, m: usize, k: u64, a: &[u64], b: &[u64]) {
    let mut x: Vec<u64> = vec![0];
    for i in 0..n {
        x.push(x[i] + a[i]);
    }

    let mut y: Vec<u64> = vec![0];
    for i in 0..m {
        y.push(y[i] + b[i]);
    }

    let mut ans = 0;
    let mut j = m;
    for i in 0..(n + 1) {
        if x[i] > k {
            break;
        }
        while x[i] + y[j] > k {
            j -= 1;
        }
        if ans < i + j {
            ans = i + j;
        }
    }

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


Measured memory_bytes: 12600
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, bit;
    cin >> n;
    vector<int> opentime(n, 0);
    for(int i = 0; i < n; i++) {
        int mask = 0;
        for(int j = 0; j < 10; j++) {
            cin >> bit;
            mask = mask*2 + bit;
        }
        opentime[i] = mask;
    }
    vector<vector<int>> cost(n, vector<int>(11, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= 10; j++) {
            cin >> cost[i][j];
        }
    }
    int profit = INT_MIN;
    for(int state = 1; state < (1<<10); state++) {
        int acc = 0;
        //cout << "state " << state << endl;
        for(int i = 0; i < n; i++) {
            int tmp = (state & opentime[i]);
            int bit = 0;
            while(tmp > 0) {
                tmp -= tmp & (-tmp);
                bit += 1;
            }
            acc += cost[i][bit];
            //cout << "bit " << bit<< endl;
        }
        profit = max(profit, acc);
    }
    cout << profit << endl;
    return 0;
}




Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
#define mod 998244353
#define ll long long
string s;
map<string,ll>g,f;
ll F(string s);
ll G(string s){
	if(g.find(s)!=g.end()) return g[s];
	if(s.size()==1) return g[s]=s[0]-'0'+1;
	for(ll i=1;i<s.size();i++){
		if(s.size()%i==0){
			string t;
			for(ll j=0;j<i;j++){
				ll r=1;
				for(ll k=0;k<s.size()/i;k++){
					if(s[i*k+j]=='0') r=0;
				}
				t+=(char)(r+'0');
			}
			g[s]=(g[s]+F(t))%mod;
		}
	}
	return g[s];
}
ll F(string s){
	if(f.find(s)!=f.end()) return f[s];
	for(ll i=1;i<=s.size();i++){
		f[s]=(f[s]+F(s.substr(0,s.size()-i))*G(s.substr(s.size()-i,i)))%mod;
	}
	return f[s];
}
int main(){
	cin>>s;
	f[""]=1;
	cout<<F(s);
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    double n,m,d;
    cin>>n>>m>>d;
    double zero=max((double)0,d-(n-d));
    double two=max((double)0,(n-d)-d);
    double one=n-zero-two;
    cout<<fixed<<setprecision(10);
    //cout<<zero<<" "<<one<<" "<<two<<endl;
    if(d==0) cout<<(m-1)*two/(n*n)<<endl;
    else cout<<(m-1)*(one+two+two)/(n*n)<<endl;
}


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

int main() {
  string N;
  cin>>N;
  
  if (N.at(0)=='7')
    cout<<"Yes"<<endl;
  else if (N.at(1)=='7')
    cout<<"Yes"<<endl;
  else if (N.at(2)=='7')
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;
  cin>>n;
  vector<double> a(n);
  double c=0.0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]=1.0/a[i];
    c+=a[i];
  }
  cout<<fixed<<setprecision(10)<<1.0/c;
}

Measured memory_bytes: 256
k = int(input())
lists = [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]
print(lists[k-1])

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r <= N / R + 1; ++r) {
        for (int g = 0; g <= (N - r * R) / G + 1; ++g) {
            if (r * R + g * G > N) break;
            if ((N - r * R - g * G) % B == 0) ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int n, t;
    std::cin >> n >> t;
    std::vector<std::pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        v.emplace_back(a, b);
    }

    std::vector<std::vector<int>> pre { std::vector<int>(t) }, suf { std::vector<int>(t) };
    for (int i = 0; i < n; i++) {
        auto &prev = pre.back();
        auto dp(pre.back());
        for (int j = 0; j + v[i].first < t; j++) {
            int s = j + v[i].first;
            dp[s] = std::max(dp[s], prev[j] + v[i].second);
        }
        pre.push_back(std::move(dp));
    }

    for (int i = n - 1; i >= 0; i--) {
        auto &prev = suf.back();
        auto dp(suf.back());
        for (int j = 0; j + v[i].first < t; j++) {
            int s = j + v[i].first;
            dp[s] = std::max(dp[s], prev[j] + v[i].second);
        }
        suf.push_back(std::move(dp));
    }

    int ret = 0;
    for (int i = 0; i < n; i++) {
        auto &p = pre[i], &s = suf[n - i - 1];
        for (int j = 1; j < t; j++) s[j] = std::max(s[j], s[j - 1]);
        for (int j = 0; j < t; j++) ret = std::max(ret, v[i].second + p[j] + s[t - j - 1]);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define re(i , n) for(Long i = 0; i < (Long)n ; i++)
#define rer(i, a, b) for (Long i = a, to = b; i < to; i++)
#define rll(x) Long x;cin>>x;
#define rll2(x,y) Long x,y;cin>>x>>y;
#define rll3(x,y,z) Long x,y,z;cin>>x>>y>>z;
#define rs(s) string s;cin>>s;
using namespace std;
 
typedef long long Long;
typedef pair<Long,Long> pll;
typedef pair<Long,pll> tll;
 
typedef vector<Long> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<Long> si;
 
 
const long double PI = acos(-1);
const Long MX=2e5 + 1;
const Long MOD=1000000007;
const Long MX2=9223372036854775806;
 
 
int main(){
	rs(s1);rs(s2);
	s1=s1+s2[s2.size()-1];;
	if(s1==s2){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000000
long long n,a[1000005];
int nextmin[1000005];
int nextmax[1000005];
long long int dp[1000005]={0};
int main()
{

	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	a[0]=-INF;
	a[n+1]=-INF;	
	stack<long long int>s;
	s.push(n+1);
	for(int i=n;i>=1;i--)
	{
		while(a[i] <= a[s.top()])
			s.pop();
		nextmin[i]=s.top();
		s.push(i);
	}
	for(int i=n;i>=1;i--)
	{
		int len=nextmin[i]-i;
		dp[i] = len*a[i]+dp[nextmin[i]];
	}
	long long sum=0;
	for(int i=1;i<=n;i++)
		sum+=dp[i];
	printf("%lld\n",sum );
	return 0;
}

Measured memory_bytes: 11648