akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let (n, mut m): (usize, usize) = (read::<usize>(), read::<usize>());
    if n % 2 == 1 {
        let (mut l, mut r) = (1, n / 2 + 1);
        while l + 1 <= r && m > 0 {
            println!("{} {}", l, r);
            l += 1;
            r -= 1;
            m -= 1;
        }
        let (mut l, mut r) = (n / 2 + 2, n);
        while l + 1 <= r && m > 0 {
            println!("{} {}", l, r);
            l += 1;
            r -= 1;
            m -= 1;
        }
    } else {
        let (mut l, mut r) = (1, n / 2);
        while l + 1 <= r && m > 0 {
            println!("{} {}", l, r);
            l += 1;
            r -= 1;
            m -= 1;
        }
        let (mut l, mut r) = (n / 2 + 2, n);
        while l + 1 <= r && m > 0 {
            println!("{} {}", l, r);
            l += 1;
            r -= 1;
            m -= 1;
        }
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2164
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 5e5 + 5;
typedef long long ll; 
using namespace std;

int n, l, r;
ll lim, v[N], m, t[N]; 
double Q; 
struct node
{
	ll v; double t;
	node(ll x = 0, double y = 0) { v = x, t = y; }
} q[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> (); 
	for(int i = 1; i <= n; i++) t[i] = read <ll> (), v[i] = read <ll> (); 
	l = 1, r = 0; ll mn; 
	for(int i = 1; i <= n; i++)
	{
		while(lim + v[i] > m)
		{
			mn = min(lim + v[i] - m, q[l].v), lim -= mn; 
			q[l].v -= mn, Q -= q[l].t * mn;
			if(!q[l].v) l++; 
		}
		q[++r] = node(v[i], t[i]), Q += 1.0 * t[i] * v[i], lim += v[i]; 
		while(l < r && q[r].t < q[r - 1].t)
		{
			q[r - 1].t = (q[r - 1].t * q[r - 1].v + q[r].t * q[r].v) / (q[r - 1].v + q[r].v);
			q[r - 1].v += q[r].v, r--; 
		}
		printf("%.6lf\n", Q / m); 
	}
	return 0; 
}


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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        int m = cin.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];

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

        var ab = a.Zip(b, (a_, b_) => new { a_, b_ }).ToArray();
        Array.Sort(ab, (a_, b_) => a_.a_.CompareTo(b_.a_));

        int drinkCount = m;
        long drinkFee = 0;

        for (int i = 0; i < n; ++i)
        {
            if (drinkCount <= ab[i].b_)
            {
                drinkFee += (long)ab[i].a_ * drinkCount;
                break;
            }
            else
            {
                drinkFee += (long)ab[i].a_ * ab[i].b_;
                drinkCount -= ab[i].b_;
            }
        }

        Console.WriteLine(drinkFee);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 21320
def main():
    A, B = (int(i) for i in input().split())
    from fractions import gcd
    g = gcd(A,B)
    divs = []
    for i in range(1,int(g**0.5)+1):
        if g % i == 0:
            divs.append(i)
            if i != g//i:
                divs.append(g//i)
    divs.sort()
    ans = {1}
    n = len(divs)
    for i in range(n):
        cur = divs[i]
        for j in ans:
            if gcd(cur,j) != 1:
                break
        else:
            ans.add(cur)
    print(len(ans))
if __name__ == '__main__':
    main()

Measured memory_bytes: 66920
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] X = new long[N+1];
		long[] xx = new long[N+1];
		for( int i=1; i<=N; i++ ){
			X[i] = sc.nextLong();
			xx[i] = X[i];
		}
		Arrays.sort(xx);
		long med1 = xx[N/2];
		long med2 = xx[N/2+1];
		for( int i=1; i<=N; i++ ){
			if( X[i]<=med1 ){
				System.out.println(med2);
			}else{
				System.out.println(med1);
			}
		}
	}
}


Measured memory_bytes: 96044
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    if(N==1)
    {
        cout<<"Hello World"<<endl;
    }
    else if(N==2)
    {
        int A,B;
        cin>>A>>B;
        cout<<(A+B)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int x,a,b;

  cin>>x>>a>>b;

  if(abs(a-x)>abs(b-x)){
    cout<<"B"<<endl;
  }else{
    cout<<"A"<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    while(n>0){
        n-=1000;
    }
    cout<<abs(n)<<endl;
}

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

const int MAXN = 51;

using val = vector<int>;

string ans[MAXN];

string solve(int x, int y, int z) {
    int n = x + y + z;
    if (!x) {
        string ans = solve(y, z, 0);
        for (char& c : ans) {
            c++;
        }
        return ans;
    }

    if (y + z == 0) {
        string ans = "";
        for (int i = 0; i < n; i++)
            ans += 'a';
        return ans;
    }

    string vala;
    string valb;
    string valc;

    int nx, ny, nz;

    if (x <= z) {
        nx = x;
        ny = y;
        nz = z - x;
        vala = "ac";
        valb = "b";
        valc = "c";
    } else {
        if (x - z < y) {
            vala = "ab";
            valb = "ac";
            valc = "b";
            nx = x - z;
            ny = z;
            nz = y - (x - z);
        } else {
            vala = "a";
            valb = "ab";
            valc = "ac";
            nx = x - y - z;
            ny = y;
            nz = z;
        }
    }

    string ans = solve(nx, ny, nz);
    string vl = "";
    for (char c : ans) {
        if (c == 'a')
            vl += vala;
        else if (c == 'b')
            vl += valb;
        else vl += valc;
    }
    return vl;
}

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
    int x, y, z;
    cin >> x >> y >> z;
    string ans = solve(x, y, z);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stack>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const int dy[] = {0,1,0,-1};
const int dx[] = {1,0,-1,0};
// RDLU

int N, M, Q;
char F[2011][2011];

int B[2011][2011];
int D[4][2011][2011];

bool in(int y, int x) {
    return 0 <= y && y < N && 0 <= x && x < M;
}

void scan(int a[2011][2011]) {
    REP (i, N+1) REP (j, M+1) a[i][j+1] += a[i][j];
    REP (i, N+1) REP (j, M+1) a[i+1][j] += a[i][j];
}

int box(int a[2011][2011], int h1, int w1, int h2, int w2) {
    return a[h2][w2] - a[h2][w1] - a[h1][w2] + a[h1][w1];
}

void MAIN() {
    scanf("%d%d%d", &N, &M, &Q);
    REP (i, N) scanf("%s", F[i]);

    REP (i, N) REP (j, M) if (F[i][j] == '1') {
	stack<pair<int, int> > st;
	B[i+1][j+1] = 1;
	st.emplace(i, j);
	F[i][j] = '2';

	while (!st.empty()) {
	    int y = st.top().first;
	    int x = st.top().second;
	    st.pop();
	    REP (d, 4) {
		int yy = y + dy[d];
		int xx = x + dx[d];
		if (in(yy, xx) && F[yy][xx] == '1') {
		    D[d][yy+1][xx+1] = 1;
		    st.emplace(yy, xx);
		    F[yy][xx] = '2';
		}
	    }
	}
    }

    scan(B);
    REP (d, 4) scan(D[d]);

    REP ($, Q) {
	int h1, w1, h2, w2;
	scanf("%d%d%d%d", &h1, &w1, &h2, &w2);
	h1--; w1--;

	int ans = box(B, h1, w1, h2, w2);
	ans += box(D[0], h1, w1, h2, w1+1);
	ans += box(D[1], h1, w1, h1+1, w2);
	ans += box(D[2], h1, w2-1, h2, w2);
	ans += box(D[3], h2-1, w1, h2, w2);

	printf("%d\n", ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 84736
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
const int _max=5e5+50;
ll tree[5*_max];
string str;
void bd(int node,int start,int end)
{
	if(start==end)
	{
		tree[node]=1ll<<(int(str[start])-int('a'));
		return;
	}
	int mid=(start+end)>>1;
	bd(node*2,start,mid);
	bd(node*2+1,mid+1,end);
	tree[node]=(tree[node*2]|tree[node*2+1]);
	return;
}
void update(int node,int start,int end,int idx,char val)
{
	if(start==end)
	{
		str[idx]=val;
		tree[node]=0;
		tree[node]|=(1ll<<(int(val)-int('a')));
		return;
	}
	/*if(start==end)
	{
		str[idx]=val;
		tree[node]&=(~(1ll<<(int(str[idx])-int('a'))));
		tree[node]|=1ll<<(int(val)-int('a'));
		return;
	}*/
	int mid=(start+end)>>1;
	if(idx<=mid)
	  update(node*2,start,mid,idx,val);
	else
	  update(node*2+1,mid+1,end,idx,val);
	tree[node]=(tree[node*2]|tree[node*2+1]);
}
ll query(int node,int start,int end,int l,int r)
{
	if(l<=start&&r>=end)
	  return tree[node];
	int mid=(start+end)>>1;
	ll ans=0;
	if(l<=mid)
	  ans|=query(node*2,start,mid,l,r);
	if(r>mid)
	  ans|=query(node*2+1,mid+1,end,l,r);
	return ans;
}
int main()
{
	int len;
	cin>>len;
	cin>>str;
	str='0'+str;
	bd(1,1,len);
	int t;
	cin>>t;
	while(t--)
	{
		int c,l,r;
		char r1;
		cin>>c;
		if(c==1)
		{
			cin>>l>>r1;
			update(1,1,len,l,r1);
		}
		else
		{
			cin>>l>>r;
			ll ans=query(1,1,len,l,r);
			ll cnt=0;
			while(ans)
			{
				if(ans&1)
				  cnt++;  
				ans>>=1;
			}
			cout<<cnt<<endl;
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 11160
r,c = map(int,input().split())
table = [None] * r
sum_c = [0] * (c+1)
for i in range(r):
    tmp = list(map(int,input().split()))
    sum_r = sum(tmp)
    tmp.append(sum_r)
    for j in range(c+1):
        sum_c[j] += tmp[j]
    table[i] = tmp
table.append(sum_c)

for line in table:
    print(" ".join(map(str, line)))



Measured memory_bytes: 5704
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,a,b) for (int i = a; i < (b); i++)
#define sz(t) int(t.size())
#define INF 1000000000
const int DIV = 1000000000 + 7;
using namespace std;
typedef long long ll;

#define MOD 10007

int main(void) {
    int n;
    for (;;) {
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> W(n + 1);
        REP(i, 0, n) {
            cin >> W[i];
        }
        vector<vector<int> > dp(n + 1, vector<int>(n + 1, 0));
        REP(w, 2, n + 1) {
            REP(l, 0, n) {
                int r = l + w;
                if (r > n) {
                    continue;
                }
                if (dp[l + 1][r - 1] == w - 2 && abs(W[l] - W[r - 1]) <= 1) {
                    dp[l][r] = dp[l + 1][r - 1] + 2;
                }
                REP(mid, l, r + 1) {
                    dp[l][r] = max(dp[l][r], dp[l][mid] + dp[mid][r]);
                }
            }
        }
        cout << dp[0][n] << endl;
    }
}



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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int Dup = int.Parse(Console.ReadLine());
            int DupPl = Dup / 2;
            int Amari = Dup % 2;

            Console.WriteLine((DupPl + Amari).ToString());

        }
    }
}

Measured memory_bytes: 11092
/* Educational DP Contest 2019/1/6
 * A Frog-1
 * 2020.3.29 練習
 *  メモ探索の場合TLEに．
 */
#include<iostream>
#include<vector>
#include<algorithm> // max
//#include<cmath>
using namespace std;

int abs(int x){
  return (x>=0)?x:-x;
}

// 最長増加部分列(LIS)
int n;  // 2~10^5
vector<int> h; // 数字列 1~10^4
vector<int> cost; // コストのメモ

//入力
void init(){
  cin >> n;
  h.assign(n+1,0);
  cost.assign(n+1,0);
  for(int i=1; i<n+1; i++){
    cin >> h[i];
  }
  return;
}

/* 再帰関数で実装した場合
int recur(int k){
  // メモがある場合
  if(cost[k]) return cost[k];  //メモあり
  // 境界条件
  if(k==n) return 0;
  if(k==n-1) return abs(h[n-1]-h[n]);
  // 再帰
  // メモ化
  cost[k] = min( recur(k+1)+abs(h[k]-h[k+1]), recur(k+2)+abs(h[k]-h[k+2]) );
  cout << "mem: k=" << k << ", cost=" << cost[k] << endl;
  return cost[k];
}
//*/

//* DPで実装した場合
void dodp(){
  // 境界条件
  cost[n] = 0;
  cost[n-1] = abs(h[n-1]-h[n]);
  for(int i=n-2; i>0; i--){
    cost[i] = min( cost[i+1]+abs(h[i]-h[i+1]), cost[i+2]+abs(h[i]-h[i+2]) );
  }
}
//*/

int main(void){
  init();
  dodp();
  cout << cost[1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,k,v[100001],h[100001];
 
int main(){
    cin >> n >> k;
    k++;
    for(int i = 0 ; i < k ; i += 1){
        h[i] = -100000;
    }
    for(int i = 0 ; i < n ; i += 1){
        cin >> h[k-1];
        if(i){
            v[k-1] = 2000000000;
            for(int j = 0 ; j < k-1 ; j += 1){
                v[k-1] = min(v[k-1],v[j]+abs(h[k-1]-h[j]));
            }
        }
        for(int j = 0 ; j < k-1 ; j += 1){
            v[j] = v[j+1];
            h[j] = h[j+1];
        }
    }
    cout << v[k-1] << endl;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val S = next() //.map { if (it == 'o') 1 else 0 }
    val a = IntArray(N + 1)
    val b = IntArray(N + 1)
    val c = IntArray(N + 1)
    for (i in 1 .. N) a[i] = if (S[i - 1] == 'o') 0 else 1
    for (b1 in 0 .. 1) {
        for (b2 in 0 .. 1) {
            b[1] = b1
            b[2] = b2
            for (i in 1 .. N) c[i] = a[i]
            c[1] = c[1] xor b[1]
            for (i in 2 until N) {
                c[i] = c[i] xor b[i]
                b[i + 1] = b[i - 1] xor c[i]
            }
            c[N] = c[N] xor b[N]
            if ((b[1] == (b[N - 1] xor c[N])) && (b[N] == (b[2] xor c[1]))) {
                val sb = StringBuilder()
                for (i in 1 .. N) sb.append(if (b[i] == 0) 'S' else 'W')
                return println(sb.toString())
            }
        }
    }
    println(-1)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta


Measured memory_bytes: 36920
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
N,M = m()
a,b,c = m()
s = input()
kkk = [0 for i in range(N)]
co = 0
for i in range(N):
    if i < M:
        if s[i] == "s":
            co += a
        elif s[i] == "p":
            co += b
        else:
            co += c
        kkk[i] = 1
    else:
        if s[i] != s[i-M] or (kkk[i-M] == 0 and s[i] == s[i-M]):
            if s[i] == "s":
                co += a
                kkk[i] = 1
            elif s[i] == "p":
                co += b
                kkk[i] = 1
            else:
                co += c
                kkk[i] = 1

print(co)








Measured memory_bytes: 45456
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int count1 = 0;
    int count2 = 0;
    
    for (int i = 0; i < 3; i++) {
      int token1 = sc.nextInt();
      
      if(token1 == 7 && count1 <= 1) {
          count1++;
      }else if(token1 == 5 && count1 <= 2) {
          count2++;
      }
    }
    
    if(count1 == 1 && count2 == 2) {
        System.out.println("YES");
    }else {
        System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23636
import math

def modinv(a,m):
	b = m
	u = 1
	v = 0
	while(b):
		t = a // b
		a -= t * b
		a,b = b,a
		u -= t * v
		u,v = v,u
	u %= m
	if u < 0:
		u += m
	return u

inp = input().split(' ')
inpint = [int(i) for i in inp]
h = inpint[0]
w = inpint[1]
a = inpint[2]
b = inpint[3]

xfac = [0 for r in range(h+w-2)]
xfac_inv = [0 for r in range(h+w-2)]

for i in range(h+w-2):
	if i == 0:
		xfac[i] = 1
	else:
		xfac[i] = (xfac[i-1]*i)%1000000007

for i in reversed(range(h+w-2)):
	if i == h+w-3:
		xfac_inv[i] = modinv(math.factorial(i),1000000007)
	else:
		xfac_inv[i] = xfac_inv[i+1] * (i+1) % 1000000007

# print(xfac)
# print(xfac_inv)

# for i in range(h+w-2):
# 	print(xfac[i]*xfac_inv[i]%1000000007)

def com(a,b):
	return (xfac[a] * xfac_inv[b] * xfac_inv[a-b])%1000000007

sum = 0
for i in range(b,w):
	sum += com(i + h-a-1,h-a-1) * com((a-1)+w-i-1, w-i-1)
	sum %= 1000000007

print(sum)

Measured memory_bytes: 18980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
  ll N, M, K;
  cin>>N>>M>>K;
  vector<ll> A(N+1), B(M+1);
  rep(i, N){
    cin>>A[i];
  }
  rep(i, M){
    cin>>B[i];
  }
  ll Ans=0;
  ll NowA, NowB;
  NowA=0;
  NowB=0;
  ll Sum=0;
  ll cnt=0;
  while(Sum<=K&&NowA<N){
    if(Sum+A[NowA]<=K){
      Sum+=A[NowA];
      NowA++;
      cnt++;
    }
    else{
      break;
    }
  }
  while(Sum<=K&&NowB<M){
    if(Sum+B[NowB]<=K){
      Sum+=B[NowB];
      NowB++;
      cnt++;
    }
    else{
      break;
    }
  }
  Ans=cnt;
  while(NowA>=1){
    cnt--;
    NowA--;
    Sum-=A[NowA];
    while(Sum<=K&&NowB<M){
      if(Sum+B[NowB]<=K){
        Sum+=B[NowB];
        NowB++;
        cnt++;
      }
      else{
        break;
      }
    }
    Ans=max(Ans, cnt);
  }
  cout<<Ans<<endl;

}
     

Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 1 << 18;
int n, a[N], b[2][N], ans[N];
inline void add(int i, int val){
	if(val >= b[0][i]) b[1][i] = b[0][i], b[0][i] = val;
	else if(val >= b[1][i]) b[1][i] = val;
}
inline void insert(int i, int j){
	add(i, b[0][j]); add(i, b[1][j]);
}
inline void FWT(){
	for(Rint i = 0;i < n;i ++)
		for(Rint S = 0;S < (1 << n);S ++) if(!((S >> i) & 1))
			insert(S | (1 << i), S);
}
int main(){
	scanf("%d", &n);
	for(Rint i = 0;i < (1 << n);i ++) scanf("%d", a + i), add(i, a[i]); FWT();
	ans[0] = b[0][0] + b[1][0];
	for(Rint i = 1;i < (1 << n);i ++){
		ans[i] = max(ans[i - 1], b[0][i] + b[1][i]);
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 7168
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
bool check(int n){
    string s = to_string(n);
    string r = s;
    reverse(all(r));
    return s == r;
}


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

    int A,B;
    cin >> A >> B;
    int ans = 0;
    for(int i = A; i <= B; ++i){
        if(check(i))
            ans++;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 404;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int dp[N][N];
int pre[N];

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n; cin>>n;
    For(i, 0, n){
        cin>>pre[i];
    }
    For(i, 1, n){
        pre[i]+=pre[i-1];
    }
    For(i, 0, n){
        dp[i][i]=0;
    }
    for(int len=1; len<n; len++){
        for(int i=0; i<n-len; i++){
            int k=i+len;
            dp[i][k]=INF;
            for(int j=i; j<k; j++){
                // sum(i, j) //sum(j+1, k)
                int s1, s2;
                if(i==0){
                    s1=pre[j];
                }
                else{
                    s1=pre[j]-pre[i-1];
                }
                s2 = pre[k]-pre[j];
                dp[i][k]=min(dp[i][k], dp[i][j]+dp[j+1][k]+s1+s2);
            }
        }
    }
    cout<<dp[0][n-1];
    return 0;
}





Measured memory_bytes: 1536
def solve():
  N, M = map(int, input().split())
  if abs(N-M)>1:
    return 0
  mod = 10**9+7
  ans = 2-abs(N-M)
  for i in range(N):
    ans *= i+1
    ans %= mod
  for i in range(M):
    ans *= i+1
    ans %= mod
  return ans
print(solve())

Measured memory_bytes: 9024
#include <cstdio>
#include <algorithm>

using namespace std;
int v[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int vv[10000 + 5] = {1};
int a[10];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++)
        scanf("%d", &a[i]);
    sort(a + 1, a + 1 + m);
    for (int i = 1; i <= m; i++)
        for (int j = v[a[i]]; j <= n; j++)
            vv[j] = max(vv[j], vv[j - v[a[i]]] + 1);
    while (n) {
        if ((n - v[a[m]] >= 0) && (vv[n] == vv[n - v[a[m]]] + 1)) {
            n -= v[a[m]];
            printf("%d", a[m]);
        } else
            m--;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    n, s = int(input()), int(input())

    if n < s:
        print(-1)
        return
    if n == s:
        print(n+1)
        return

    for b in range(2, int(n**0.5)+1):
        x, sb = n, 0
        while 0 < x:
            sb += x % b
            x //= b
        if sb == s:
            print(b)
            return

    for p in range(1, int(n**0.5)+1)[::-1]:
        if (n-s) % p:
            continue
        b, x, sb = (n-s) // p + 1, n, 0
        while 0 < x:
            sb += x % b
            x //= b
        if sb == s:
            print(b)
            return

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
fn solve(nab: &str) -> i64 {
    let mut nab = nab.split_whitespace().map(|x|x.parse().unwrap());
    let n = nab.next().unwrap();
    let a = nab.next().unwrap();
    let b = nab.next().unwrap();
    let mut h = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        h.push(s.trim_right().parse().unwrap());
    }
    let mut lo=0;
    let mut hi=h.iter().fold(0,|m,v|std::cmp::max(m,(v+b-1)/b));
    while lo+1<hi {
        let m = (lo+hi)/2;
        let r: i64 = h.iter().map(|&v|
            if v<=m*b {0}
            else {(v-m*b+(a-b)-1)/(a-b)}
        ).sum();
        if r>m { lo=m; }
        else { hi=m; }
    }
    hi
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  vector<bool>S(26,false);
  for(int i = 0;i<s.size();i++){
    if( S.at(s.at(i) - 'a') != true){
      S.at(s.at(i) - 'a') = true;
    }
    else{
      cout <<"no";
      return 0;
    }
  }
  cout << "yes";
  
  
  
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
  #include<string>
 #define rep(i, n) for(int i = 0; i < (n); i++)
  #define shosu(n) setprecision(n)
  using namespace std;
// clang-format on
int main() {
  int W, a, b, ans;
  cin >> W >> a >> b;
  if (abs(a - b) <= W)
    cout << 0 << endl;
  else if (abs(a - b) > W)
    cout << abs(a - b) - W << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

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

        HashMap<String, Boolean> map = new HashMap<String, Boolean>();
        map.put("A", true);
        map.put("B", false);
        map.put("C", false);

        String line;
        while ((line = br.readLine()) != null) {
            String[] input = line.split(",");
            if (map.get(input[0]) != map.get(input[1])) {
                map.put(input[0], !map.get(input[0]));
                map.put(input[1], !map.get(input[1]));
            }
        }

        for (String s : map.keySet()) {
            if (map.get(s)) {
                System.out.println(s);
                return;
            }
        }

    }
}


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

struct Ans{
    uint_fast64_t val[222];
    constexpr Ans() : val(){
        val[105] = val[135] = val[165] = val[195] = val[189] = 1;
        for(int i = 1; i < 220; ++i)val[i] += val[i - 1];
    }
    constexpr uint_fast64_t operator[](size_t i) const{
        return val[i];
    }
};

constexpr Ans a = Ans();
long long int N;

int main(){
    scanf("%lld", &N);
    cout << a[N] << endl;
    return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    int ans=0;
    for (int i=a;i<=b;i++) {
        string s=to_string(i),t=s;
        reverse(t.begin(),t.end());
        if (s==t)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
cvs = [[c for c in input()] for _ in range(H)]

dw = [1, 0, -1, 0]
dh = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if cvs[i][j] == '#':
            ok = False
            for k in range(4):
                if 0<=i+dh[k]<=H-1 and 0<=j+dw[k]<=W-1:
                    if cvs[i+dh[k]][j+dw[k]] == '#':
                        ok = True
                        break
            if ok == False:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
ll MAX = 1000000007;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> dp(N+1, 0);
    vector<ll> a(N+1, 0);
    for(ll i=0; i<M; ++i) {
        ll v;
        cin >> v;
        a[v] = 1;

    }

    dp[0] = 1;
    if(a[1]!=1) dp[1] = 1;

    for(ll i=2; i<=N; ++i) {
        if(a[i-1]!=1) {
            dp[i] += dp[i-1];
            // cout << "called" << endl;
        }
        if(a[i-2]!=1) dp[i] += dp[i-2];
        dp[i] %= MAX;
    }
    cout << dp.back() << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	string A, B, C;
	cin >> A >> B >> C;
	char next='a';
	while (1) {
	//	cout << A << ' ' << B << ' ' << C << ' ' << next << endl;
		if (next == 'a') {
			if (A.empty()) {
				cout << 'A' << endl;
				return 0;
			}
			next = A[0];
			A.erase(0,1);
		}
		else if (next == 'b') {
			if (B.empty()) {
				cout << 'B' << endl;
				return 0;
			}
			next = B[0];
			B.erase(0,1);
		}
		else if (next == 'c') {
			if (C.empty()) {
				cout << 'C' << endl;
				return 0;
			}
			next = C[0];
			C.erase(0,1);
		}
		
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define reps(i,n) for(int i = 0 ; i < (n) ; ++i )
#define rep(i,a,n) for(int i = (a) ; i < (n) ; ++i)
typedef long long ll;
int main(){
  int n;
  while(cin >> n , n){
    ll d[n] , v[n];
    reps(i,n) cin >> d[i] >> v[i];
    ll a = d[0];
    rep(i,1,n) a = d[i]*a / __gcd(d[i],a);
    ll b[n];
    reps(i,n) b[i] = v[i] * a / d[i];
    ll c = b[0];
    rep(i,1,n) c = __gcd(c,b[i]);
    reps(i,n) cout << b[i] / c << endl;;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
    int X, Y;
    int A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<long long> p(A, 0);
    vector<long long> q(B, 0);
    vector<long long> r(C, 0);
    for (int i = 0; i < A; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> q[i];
    }
    for (int i = 0; i < C; ++i) {
        cin >> r[i];
    }

    sort(p.begin(), p.end(), greater<long long>());
    sort(q.begin(), q.end(), greater<long long>());
    sort(r.begin(), r.end(), greater<long long>());

    //vector<long long> redgreen(X + Y, 0ll);
    //for (int i = 0; i < X; ++i) {
    //    redgreen[i] = p[i];
    //}
    //for (int i = 0; i < Y; ++i) {
    //    redgreen[X + i] = q[i];
    //}
    //for (int i = 0; i < r.size(); ++i) {
    //    redgreen.push_back(r[i]);
    //}
    //sort(redgreen.begin(), redgreen.end(), greater<long long>());
    //long long sum = 0ll;
    //for (int i = 0; i < X + Y; ++i) {
    //    sum += redgreen[i];
    //}

    vector<long long> red(X, 0ll);
    vector<long long> green(Y, 0ll);
    for (int i = 0; i < X; ++i) {
        red[i] = p[i];
    }
    for (int i = 0; i < Y; ++i) {
        green[i] = q[i];
    }
    sort(red.begin(), red.end());
    sort(green.begin(), green.end());

    int ired = 0;
    int igreen = 0;
    int itrans = 0;
    while (true) {
        bool redOK = ired < red.size();
        bool greenOK = igreen < green.size();
        if ((!redOK && !greenOK) || itrans >= r.size()) {
            break;
        }
        bool encolor = false;
        if (redOK && greenOK) {
            if (red[ired] < green[igreen]) {
                if (red[ired] < r[itrans]) {
                    red[ired] = r[itrans];
                    ++ired;
                    ++itrans;
                    encolor = true;
                }
            }
            else {
                if (green[igreen] < r[itrans]) {
                    green[igreen] = r[itrans];
                    ++igreen;
                    ++itrans;
                    encolor = true;
                }
            }
        }
        else if (redOK) {
            if (red[ired] < r[itrans]) {
                red[ired] = r[itrans];
                ++ired;
                ++itrans;
                encolor = true;
            }
        }
        else if (greenOK) {
            if (green[igreen] < r[itrans]) {
                green[igreen] = r[itrans];
                ++igreen;
                ++itrans;
                encolor = true;
            }
        }
        if (!encolor) {
            break;
        }
    }
    long long sum = accumulate(red.begin(), red.end(), 0ll);
    sum += accumulate(green.begin(), green.end(), 0ll);

    cout << sum << endl;
    //cout << setprecision(15) << endl;
    return 0;
}


Measured memory_bytes: 3968
n = int(input())
judge_list = [input() for _ in range(n)]

ac = judge_list.count('AC')
wa = judge_list.count('WA')
tle = judge_list.count('TLE')
re = judge_list.count('RE')

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 16296
from collections import deque
 
N, M = map(int, input().split())
 
a = []
aindex = 0
for _ in range(M):
    a.append(int(input()))
 
before1 = 1
before2 = 0
ai=0
if len(a)>0:
    ai = a[aindex]
 
for i in range(1, N+1):
    if i == ai:
        before2 = before1
        before1 = 0
        if aindex < len(a)-1:
            aindex += 1
            ai = a[aindex]
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current
 
 
print(before1)

Measured memory_bytes: 7416
#include <stdio.h>

int main(void){

    int i,i1,i2;
    int flag;
    scanf("%d%d%d",&i,&i1,&i2);

    flag=0;
    if(i==i1 && i1!=i2){
    flag=1;
    }if(i1==i2 && i2!=i){
    flag=1;
    }if(i2==i && i!=i1){
        flag=1;
    }
    if(flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

string alpha;
int n;

void rec(int i, int j, string s) {
    if (i == n) {
        cout << s << "\n";
    } else {
        for (int k = 0; k <= j; k++) {
            rec(i + 1, j, s + alpha[k]);
        }
        rec(i + 1, j + 1, s + alpha[j + 1]);
    }
}

int main() {
    fastio();

    cin >> n;

    forn(i, n) {
        alpha.push_back(i + 'a');
    }

    rec(1, 0, "a");

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
i64 d[31][31];
i64 s[3][31];
int main() {
  cin >> n >> m;
  for (i64 i = 1; i <= m; ++i) {
    for (i64 j = 1; j <= m; ++j) {
      cin >> d[i][j];
    }
  }
  for (i64 i = 1; i <= n; ++i) {
    for (i64 j = 1; j <= n; ++j) {
      i64 c;
      cin >> c;
      for (i64 k = 1; k <= m; ++k) {
        if (k != c) s[(i + j) % 3][k] += d[c][k];
      }
    }
  }
  i64 ans = 1ll << 50;
  for (i64 a = 1; a <= m; ++a) {
    for (i64 b = 1; b <= m; ++b) {
      if (a == b) continue;
      for (i64 c = 1; c <= m; ++c) {
        if (a == c || b == c) continue;
        ans = min(ans, s[0][a] + s[1][b] + s[2][c]);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    int n;
    scanf("%d",&n);
    string s;
    int a,t,w,r;
    a=t=w=r=0;
    while(n--){
        cin>>s;
        if(s=="AC")a++;
        else if(s=="WA")w++;
        else if(s=="TLE")t++;
        else r++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
    
    return 0;
}

Measured memory_bytes: 3692
package main
import "fmt"

func contain(slice []int, value int) bool {
  for _,v := range slice {
    if v == value {
      return true
    }
  }
  return false
}

func main() {
  var x,y int
  fmt.Scan(&x)
  fmt.Scan(&y)
  if contain([]int{2}, x) && contain([]int{2}, y) {
    fmt.Println("Yes")
  } else if contain([]int{4,6,9,11}, x) && contain([]int{4,6,9,11}, y) {
    fmt.Println("Yes")
  } else if contain([]int{1,3,5,7,8,10,12}, x) && contain([]int{1,3,5,7,8,10,12}, y) {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

const int L=100000+1;
vector<int> ps[L];
int f(int r,int p)
{
	int ret=0;
	for(auto k:ps[r]){
		if(k==p)continue;
		ret^=f(k,r)+1;
	}
	return ret;
}
void solve(long long N, std::vector<long long> x, std::vector<long long> y){
	for(int i=0;i<N-1;i++){
		ps[x[i]].push_back(y[i]);
		ps[y[i]].push_back(x[i]);
	}

	if(f(1,0)){
		cout << "Alice" << endl;
	}
	else{
		cout << "Bob" << endl;
	}



}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N-1);
    std::vector<long long> y(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 14804
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a  * b);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

    }

}


Measured memory_bytes: 34072
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    if(n*a<b)
    cout<<n*a;
    else
    cout<<b;
}

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

signed main(){
	ll n, m, K;cin >> n >> m >> K;
	vector<ll> a(n), b(m);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < m; i++) cin >> b[i];
	ll num = 0, i = 0, j = 0;
	while(num + a[i] <= K && i < n){
		num += a[i];
		i++;
	}
	ll ans = 0;
	while(num + b[j] <= K && j < m){
		num += b[j]; j++;
	}
	ans = i + j;
	for(int k = i - 1; k >= 0; k--){
		num -= a[k];
		while(num + b[j] <= K && j < m){
			num += b[j]; j++;
		}
		ans = max(k + j, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6424