akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var (N, M, K) = ReadLineInt3();
            var A = ReadLineLongList();
            var B = ReadLineLongList();

            var a = new List<long> { 0 };
            var b = new List<long> { 0 };
            
            for( var i = 0; i < N; i++)
            {
                a.Add(a[i] + A[i]);
            }

            for(var i = 0; i < M; i++)
            {
                b.Add(b[i] + B[i]);
            }

            var ans = 0L;
            var j = M;

            for(var i = 0; i < N + 1; i++)
            {
                if(a[i] > K) { break; }

                while(b[j] > K - a[i])
                {
                    j -= 1;
                }

                ans = Math.Max(ans, i + j);
            }

            Console.WriteLine(ans);
        }

        #region 使いまわし
        static string ReadLineStr() { return Console.ReadLine(); }

        static int ReadLineInt() { return Convert.ToInt32(Console.ReadLine()); }
        static (int, int) ReadLineInt2()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]));
        }
        static (int, int, int) ReadLineInt3()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[2]));
        }
        static List<int> ReadLineIntList()
        {
            var data = new List<int>();
            foreach (var temp in Console.ReadLine().Split(' '))
            {
                data.Add(Convert.ToInt32(temp));
            }

            return data;
        }

        static long ReadLineLong() { return Convert.ToInt64(Console.ReadLine()); }
        static (long, long, long) ReadLineLong3()
        {
            var temp = Console.ReadLine().Split(' ');
            return (Convert.ToInt64(temp[0]), Convert.ToInt64(temp[1]), Convert.ToInt64(temp[2]));
        }
        static List<long> ReadLineLongList()
        {
            var data = new List<long>();
            foreach (var temp in Console.ReadLine().Split(' '))
            {
                data.Add(Convert.ToInt64(temp));
            }

            return data;
        }
        #endregion
    }
}


Measured memory_bytes: 74780
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half % mod;
	}
	else {

		return a * modpow(a, p - 1) % mod;
	}
}



int comb(int a, int b) {
	if (b > a - b) return comb(a, a - b);


	int ansMul = 1;
	int ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}

	int ans = ansMul * modpow(ansDiv, mod - 2) % mod;

	return ans;
}



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

	int X, Y;
	cin >> X >> Y;

	if ((X + Y) % 3) {
		cout << 0 << endl;
		return 0;
	}
	int M = (Y - 2 * X) / -3;
	int N = X - 2 * M;
	if (N < 0 || M < 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << comb(N + M, M) << endl;

	return 0;
}



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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;

int main(){
  scanf("%d", &N);
  rep(i, N){
    int x, y, b, p;
    double per = 1;
    scanf("%d%d%d%d", &x, &y, &b, &p);
    if(b >= 5 && p >= 2) per = 0.8;
    int res = (int)((x*b+y*p)*per);
    if(b < 5) b = 5;
    if(p < 2) p = 2;
    res = min(res, (int)((x*b+y*p)*0.8));
    printf("%d\n", res);
  }
  return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
    char c;
    cin>>c;
    if(c>='A' && c<='Z')cout<<"A";
    else cout<<"a";
}

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
rd()
{
	int x=0,k;
	for(;;)
	{
		k=getchar_unlocked();
		if(k<'0'||k>'9')break;
		x=x*10+k-'0';
	}
	return x;
}
wt(int x)
{
	int s=0;
	char f[10];
	while(x)
	{
		f[s++]=x%10;
		x/=10;
	}
	if(!s)f[s++]=0;
	while(s--)putchar_unlocked(f[s]+'0');
	putchar_unlocked('\n');
}
sum[3<<17],cnt[3<<17];
N,i,acc,t;
main()
{
	N=rd();
	for(i=0;i<N;i++)
	{
		++sum[cnt[rd()]++];
	}
	i=0;
	for(t=N;t>0;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		cnt[t]=i-1;
	}
	for(i=1;i<=N;i++)wt(cnt[i]);
}

Measured memory_bytes: 3072
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int x, ans = 0;
	cin >> x;
	ans += (x / 500 * 1000);
	x %= 500;
	ans += (x / 5 * 5);
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input()) 
B = list(map(int, input().split())) 
A = [0] * (len(B)+1)
A[0] = B[0]
for i in range(1,len(B)):
  if B[i] <= B[i-1]:
    A[i] = B[i]
  elif B[i] > B[i-1]:
    A[i] = B[i-1]
A[-1] = B[-1]
print(sum(A))

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

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

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

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

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 998244353;

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

int N;
vector<P> robots;

void solve() {
  sort(robots.begin(), robots.end());
  robots.emplace_back(INT_MAX, 0);
  vector<int> next(N);
  vector<ll> dp(N + 1, 0);
  dp[N] = 1;
  for (int i = N - 1; i >= 0; i--) {
    int far = robots[i].first + robots[i].second;
    int j = i + 1;
    while (far > robots[j].first) {
      j = next[j];
    }
    next[i] = j;
    dp[i] = (dp[i + 1] + dp[j]) % MOD;
  }
  cout << dp[0] << endl;
}

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

  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, d;
    cin >> x >> d;
    robots.emplace_back(x, d);
  }

  solve();
}

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        if(a==c){
            cout<<1<<'\n';
        }else{
            cout<<2<<'\n';
        }
    }else if(a==c){
        if(b==c){
            cout<<1<<'\n';
        }else{
            cout<<2<<'\n';
        }
    }else if(b==c){
        cout<<2<<'\n';
    }else{
        cout<<3<<'\n';
    }
    return(0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;

	cin >> n;

	int *a = new int[n];
	int max = 0, min = 1000000000;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max) {
			max = a[i];
		}
		if (a[i] < min) {
			min = a[i];
		}
	}

	cout << max - min << endl;

	delete[] a;

	return 0;
}


Measured memory_bytes: 256
"use strict"
function main(arg) {
    var s = arg.trim().split("\n")[0]
    if (s[2] === s[3] && s[4] === s[5]) {
        console.log('Yes')
    } else {
        console.log('No')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {

	int N;
	cin >> N;

	int n = N;
	int sum = 0;
	while (n) {
		sum += n % 10;
		n = n / 10;
	}
	
	if (N%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

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

void fnMaximumProfit(const vector<int> &argviValue, int &argiMinval, int &argiMaxProfit)
{
  for (int i = 1; i < argviValue.size(); i++)
  {
    argiMinval = min(argiMinval, argviValue[i - 1]);
    int iMaxProfit = argviValue[i] - argiMinval; 
    argiMaxProfit = max(argiMaxProfit, iMaxProfit);
  }
}

int main()
{
  vector<int> viValue;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iValue;
    cin >> iValue;
    viValue.push_back(iValue);
  }

  int iMinval = viValue[0];
  int iMaxProfit = -1000000000;
  fnMaximumProfit(viValue, iMinval, iMaxProfit);
  cout << iMaxProfit << endl;

  return 0;
}

Measured memory_bytes: 2064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
const int P=1000003;
using namespace std;

ll fac[1100000];
ll rev_fac[1100000];

ll my_pow(ll x,ll n)
{
    if (n==0) return 1;
    ll ans = my_pow(x,n/2);
    ans = ans*ans%P;
    if (n%2==1) ans = (ans*x)%P;
    return ans;
}


ll get_rev(ll x)
{
    return my_pow(x,P-2);
}


void init()
{
    fac[0] = 1;
    for(int i=1; i<=1000010; ++i)
        fac[i] = (fac[i-1]*i)%P;
    rev_fac[1000002] = get_rev(fac[1000002]);
    for (int i=1000001; i>=0; --i)
        rev_fac[i] = rev_fac[i+1] * (i+1) % P;
}

ll solve(ll x, ll d, ll n)
{
    if (d==0)
        return my_pow(x,n);
    else
    {
        ll xd = (x * get_rev(d))%P;
        if (xd + (n-1) >=1000003) return 0;
        xd = (fac[xd+n-1]*rev_fac[xd-1])%P;
        ll rev = my_pow(d,n);
        return (xd*rev)%P;
    }
}

int main()
{
    init();
    ll q,x,d,n;
    cin >> q;
    while (q--)
    {
        scanf("%lld %lld %lld",&x,&d,&n);
        printf("%lld\n",solve(x,d,n));
    }
    return 0;
}



Measured memory_bytes: 17280
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	string n;
	cin >> n;
	for (char c : n) {
		if (c == '1') {
			cout << 9;
		}
		else if (c == '9') {
			cout << 1;
			}
		else {
			cout << c;
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	a := make([]int, 3)
	fmt.Scan(&a[0], &a[1], &a[2])
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Println(abs(a[1]-a[0]) + abs(a[2]-a[1]))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 998244353
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,a,b,k;
int dp[300010];
int kaijo(int x){
	int ans=1;
	for(int i=1;i<=x;i++){
		ans*=i;
		ans%=moder;
	}
	return ans;
}
int mypow(int x,int y){
	if(y==0)return 1;
	if(y%2)return mypow(x,y-1)*x%moder;
	return mypow(x,y/2)*mypow(x,y/2)%moder;
}
int comb(int x,int y){
	return dp[x]*mypow(dp[y],moder-2)%moder*mypow(dp[x-y],moder-2)%moder;
}
int gcd(int x,int y){
	if(y==0)return x;
	return gcd(y,x%y);
}
signed main(){
	cin>>n>>a>>b>>k;
	int cnt=INF;
	rep(i,n){
		if((k-a*i)%b==0){
			cnt=i;
			break;
		}
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=dp[i-1]*i;
		dp[i]%=moder;
	}
	if(cnt==INF){
		cout<<0<<endl;
		return 0;
	}
	int ans=0;
	int memo=b/gcd(a,b);
	while(k>=a*cnt){
		if(cnt<=n&&(k-a*cnt)/b<=n)ans+=comb(n,cnt)*comb(n,(k-a*cnt)/b)%moder;
		cnt+=memo;
		ans%=moder;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    cin >> A >> B;
    if (A == 1) A = 100;
    if (B == 1) B = 100;
    if (A > B) cout << "Alice" << endl;
    else if (A == B) cout << "Draw" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

var mat = make(map[int][]int)

func main() {
	n, m := readInt(), readInt()

	for i := 0; i < m; i++ {
		a, b := readInt(), readInt()
		if _, ok := mat[a]; !ok {
			mat[a] = make([]int, 0)
		}
		mat[a] = append(mat[a], b)
		if _, ok := mat[b]; !ok {
			mat[b] = make([]int, 0)
		}
		mat[b] = append(mat[b], a)
	}

	nexts := make([]move, len(mat[1]))
	for i := range mat[1] {
		nexts[i] = move{mat[1][i], 1}
	}

	visited := map[int]bool{1: true}
	ans := make([]int, n)
	for len(nexts) > 0 && len(visited) < n {
		tmpNexts := make([]move, 0)
		// fmt.Println(nexts)
		for i := range nexts {
			if visited[nexts[i].cur] {
				continue
			}
			visited[nexts[i].cur] = true

			ans[nexts[i].cur-1] = nexts[i].pre

			if _, ok := mat[nexts[i].cur]; !ok {
				continue
			}
			for j := range mat[nexts[i].cur] {
				tmpNexts = append(tmpNexts, move{mat[nexts[i].cur][j], nexts[i].cur})
			}
		}
		nexts = tmpNexts
	}

	fmt.Println("Yes")
	for i := range ans[1:] {
		fmt.Println(ans[i+1])
	}
}

type move struct {
	cur int
	pre int
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 45496
import java.util.*;

public class Main {

	public static void main(String[] args) {
    
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();


        int count = 0;
        int ans = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                count++;
                if (count == K) {
                    ans = i;
                }
            }
        }

        System.out.println(ans);
    }

}


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

namespace ALDS1_4_B_BinarySearch
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			Console.ReadLine ();
			int[] searchArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			Console.ReadLine ();
			int[] elementArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			//process
			int count = 0;

			foreach (var item in elementArray)
			{
				bool isFind = BinarySearch (searchArray, item);

				if (isFind)
				{
					count++;
				}
			}

			Console.WriteLine (count);
		}

		static bool BinarySearch ( int[] numArray, int searchNum )
		{
			int lowerIndex = 0;
			int upperIndex = numArray.Length - 1;

			while (lowerIndex <= upperIndex)
			{
				int middleIndex = (lowerIndex + upperIndex) / 2;
				int item = numArray[middleIndex];

				bool isFind = item == searchNum;

				if (isFind)
				{
					return true;
				}
				else
				{
					if (item < searchNum)
					{
						lowerIndex = middleIndex + 1;
					}
					else
					{
						upperIndex = middleIndex - 1;
					}
				}
			}

			return false;
		}
	}
}

Measured memory_bytes: 22944
n,m = map(int, input().split())

ac = [False]*n
wa = [0]*n

for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == 'AC':
    ac[p] = True
  else:
    if ac[p] == False:
      wa[p] += 1

a = 0
b = 0

for i in range(n):
  if ac[i]:
    a += 1
    b += wa[i]
print(a,b)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int n,m,x[100009],y[100009],xsum,ysum;
signed main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>x[i];
        if(i)(xsum+=(x[i]-x[i-1])*i*(n-i))%=mod;
    }for(int i=0;i<m;i++){
        cin>>y[i];
        if(i)(ysum+=(y[i]-y[i-1])*i*(m-i))%=mod;
    }cout<<xsum*ysum%mod<<endl;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> numList = new ArrayList<Integer>();
        while(sc.hasNext()){
            int a = sc.nextInt();
            String s = sc.next();
            int b = sc.nextInt();
            if(s.contains("?")){
                break;
            }else if(s.contains("+")){
                numList.add(a + b);
            }else if(s.contains("-")){
                numList.add(a - b);
            }else if(s.contains("*")){
                numList.add(a * b);
            }else if(s.contains("/")){
                numList.add(a / b);
            }
        }
        for(int i = 0; i < numList.size(); i++){
            System.out.println(numList.get(i));
        }
    }
}


Measured memory_bytes: 26252
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int a[100];

int abs(int a) {
    return (a < 0 ? -a : a);
}

int main() {
    int n = gi();
    int s = 0;
    for (int i = 0; i < n; i++) {
        a[i] = gi();
        s += a[i];
    }

    int b = 0;
    for (int i = 1; i < n; i++) {
        int bv = a[b]*n;
        int iv = a[i]*n;
        if (abs(s-iv) < abs(s-bv))
            b = i;
    }

    printf("%d\n", b);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

string str;

int main(){
	cin>>str;
	for(int i=1;i<str.size();i++){
		if(str[i]==str[i-1]){
			cout<<i<<' '<<i+1<<endl;
			return 0;
		}
		if(i==1) continue;
		if(str[i]==str[i-2]){
			cout<<i-1<<' '<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 512
S = input()
T = input()


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


alphabet = [0] * 26
alphabet2 = [0] * 26

for i in range(97, 97+26):
    alphabet[i-97] = my_index_multi(S, chr(i))
    alphabet2[i-97] = my_index_multi(T, chr(i))

ans = 'Yes'
for i in range(26):
    if not alphabet[i]:
        continue
    else:
        if not alphabet[i] in alphabet2:
            ans = 'No'
            break

print(ans)


Measured memory_bytes: 19648
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,ans = 1;
string s;
void solve(){
	for(int i = 1;i < s.size();i++){
		if(s[i] != s[i-1]) ans++;
	}
	cout << ans << endl;
} 
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s;	
	solve();	
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
long long int a[n];
long long sum=0,count=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
for(int i=0;i<n;i++)
{
if(4*a[i]*m>=sum)
{
count++;
}
}
if(count>=m)
cout<<"Yes\n";
else cout<<"No\n";
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a <= c && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VLL l(n,-1);
    int index = 0, cnt = 0;
    while (cnt < k && l[index] == -1) {
        l[index] = cnt;
        ++cnt;
        index = a[index] - 1;
    }
    if (cnt == k || cnt - l[index] == 0) {
        cout << index + 1 << endl;
        return;
    }
    int rem = (k - cnt) % (cnt - l[index]);
    while (rem > 0) {
        --rem;
        index = a[index] - 1;
    }
    cout << index + 1 << endl;
}

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

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 200000 + 233;
int n, m, k;
int sx, sy;
char s[maxN], t[maxN];

bool remain(int n, char up, char down, int st) {
	int top = 0, bot = n + 1;
	for(int i = k; i >= 1; --i) {
		if(t[i] == up) bot = min(n + 1, bot + 1);
		if(t[i] == down) top = max(0, top - 1);
		if(s[i] == up) top++;
		if(s[i] == down) bot--;
		if(top + 1 == bot) return false;
	}
	return top < st && st < bot;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m >> k;
	cin >> sx >> sy;
	cin >> (s + 1) >> (t + 1);
	cout << ((remain(n, 'U', 'D', sx) && remain(m, 'L', 'R', sy)) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 640
from sys import stdin
import collections

input = stdin.readline

Y, X, M = map(int, input().split())
bomb = set([tuple(map(int,inp.split())) for inp in stdin.read().splitlines()])
cx = collections.defaultdict(int)
cy = collections.defaultdict(int)
for y,x in bomb:
    cx[x] += 1
    cy[y] += 1
mx = max(cx.values())
my = max(cy.values())
candidateX = [x for (x,v) in cx.items() if v == mx]
candidateY = [y for (y,v) in cy.items() if v == my]
res = mx + my -1
for x in candidateX:
    for y in candidateY:
        if (y,x) not in bomb:
            res += 1
            break
    else:
        continue
    break
print(res)

Measured memory_bytes: 243384
/*
* @FileName: D:\代码与算法\2017训练比赛\11.18-atcoder\a.cpp
* @Author: Pic
* @Created Time: 2017/11/18 19:49:23
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	int n;
	cin>>n;
	if(n==0){
		cout<<2<<endl;
		return 0;
	}
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	unsigned  long long pre=1,ppre=2;
	unsigned  long long  res=0;
	for(int i=2;i<=n;i++){
		res=pre+ppre;
		ppre=pre;
		pre=res;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
N=int(input())
S=input()
T=""
if S.isalpha() and S.isupper() and 1 <= len(S) <= 100000 and 0 <= N <= 26:
    for i in range(len(S)):
       T += chr(( ord(S[i]) - ord("A") + N ) % 26 + ord("A"))
    print(T)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int calc(int n){
  int ans = 0;
  while(n!=0){
    ans+=n%10;
    n/=10;
  }
  return ans;
}
int main() {
  cout << fixed << setprecision(10);
  int n,a,b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i<=n; i++){
    int tmp = calc(i);
    if(tmp>=a&&tmp<=b){
      ans+=i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	string res = "Yay!";
	int a[10]; cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6];

    for(int i= 1; i<= 5; i++) {for(int j = 1; j <= 5; j++) {if (abs(a[i] - a[j]) > a[6]) res = ":(";}}
   
	cout << res << endl;
}

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

int main() {
	int money,point,kaisu500;
	cin>>money;
	
	while(1){
	if(money>=500){
		money-=500;
		kaisu500++;
	}
	else break;
	}
	point=kaisu500*500;
	
	cout<<point<<endl;
	return 0;
}


Measured memory_bytes: 3096
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 20001
int main(void)
{
	//		10			2
	double a, s = 0;
	while (scanf_s("%lf", &a) != EOF) {
		s += a;
		for (int i = 2; i <= 10; ++i) {
			if (i % 2) a /= 3;
			else a *= 2;
			s += a;
		}
		printf("%f\n",s);
		s = 0;
	}
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

void solve(long long N){
    if (N % 2 == 1) {
        cout << 0 << endl;
        return;
    }

    LL x = 10;
    LL ans = 0;
    while(N >= x) {
        ans += N / x;
        x *= 5;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(10000) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#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 SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int n;
    double sum = 0;
    cin >> n;
    vector<double> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    SORT(v);
    sum += v[0];
    for(int i=1;i<n;i++){
        sum = (sum+v[i])/2;
    }
    printf("%.10lf\n", sum);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val a, b = List.fill(n)(sc.nextInt())
    val c = List.fill(n - 1)(sc.nextInt())
    var sum = 0
    var before = -10
    for (i <- 0 until n) {
      sum += b(a(i) - 1)
      if (before + 1 == a(i)) {
        sum += c(before - 1)
      }
      before = a(i)
    }
    println(sum)
  }
}

Measured memory_bytes: 25920
#include <iostream>

using namespace std;

int n, v[101];

int main()
{
    int i, j;
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>v[i];
    for (i=1; i<n; i++)
        for (j=i+1; j<=n; j++)
            if (v[i]==v[j])
                v[j]=0;
    int c=0;
    for (i=1; i<=n; i++)
        if(v[i]!=0)
            c++;
    cout<<c;
    return 0;
}


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

int n,m,q;
struct node{int l,r,i;};
node a[205000],b[105000];

int tableau[510];
int ans[105000];

int cmp(node alpha,node beta){
    return alpha.r < beta.r;
}

int main(){
   // freopen("express.in","r",stdin);
   // freopen("express.out","w",stdout);
    cin >> n >> m >> q;
    for(int i=1;i<=m;i++) cin >> a[i].l >> a[i].r;
    for(int i=1;i<=q;i++) cin >> b[i].l >> b[i].r,b[i].i=i;
    sort(a+1,a+m+1,cmp);
    sort(b+1,b+q+1,cmp);
    int j = 1;
    for(int i=1;i<=q;i++){
	while(j <= m && a[j].r <= b[i].r)tableau[a[j].l]++,j++;
	for(int k=b[i].l;k<=n;k++)ans[b[i].i]+=tableau[k];
    }
    for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 4864
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,k = mi()
    p = li()

    for i in range(len(p)):
        p[i]+=1

    tmpl = [0]
    tmp = 0
    for i in range(len(p)):
        tmp+=p[i]
        tmpl.append(tmp)

    #print("c")

    ans = 0
    for i in range(n-k+1):
        ans = max(ans,(tmpl[i+k]-tmpl[i])/2)

    print(ans)



main()


Measured memory_bytes: 27188
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

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


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

int main() {
  int N;
  
  cin >> N;
  
  if(N > 63) cout << 64 << endl;
  else if(N > 31) cout << 32 << endl;
  else if(N > 15) cout << 16 << endl;
  else if(N > 7) cout << 8 << endl;
  else if(N > 3) cout << 4 << endl;
  else if(N > 1) cout << 2 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3600
import math

a,b,x = map(int,input().split())

v = (a**2) * b

if x > v / 2:
	ans = math.degrees(math.atan(2*(b-x/(a**2))/a))
else:
	ans = math.degrees(math.atan(a*(b**2)/(2*x)))
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);

int main() {
    int n;
	cin >> n;
    int m = 2;
    if (n%m == 0){
        print (n);
    } 

    else if (n%m == 1){
        print (2*n);
    }
        
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] nums = new boolean[h][w];
        String tmp;
        for (int i = 0; i < h; i++) {
            tmp = sc.next();
            for (int j = 0; j < w; j++) {
                if (tmp.charAt(j) == '#') {
                    nums[i][j] = true;
                }
            }
        }
        int[][] dp = new int[h][w];
        int tmpa;
        int tmpb;
        if (nums[0][0]) {
            dp[0][0] = 1;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 && j == 0) {
                    continue;
                }else if(i == 0) {
                    if (!(nums[0][j - 1]) && nums[0][j]) {
                        dp[0][j] = dp[0][j - 1] + 1;
                    } else {
                        dp[0][j] = dp[0][j - 1];
                    }
                }else if(j == 0) {
                    if (!(nums[i - 1][0]) && nums[i][0]) {
                        dp[i][0] = dp[i - 1][0] + 1;
                    } else {
                        dp[i][0] = dp[i - 1][0];
                    }
                } else {
                    if (!(nums[i - 1][j]) && nums[i][j]) {
                        tmpa = dp[i - 1][j] + 1;
                    } else {
                        tmpa=dp[i-1][j];
                    }
                    if((!nums[i][j-1])&&nums[i][j]){
                        tmpb=dp[i][j-1]+1;
                    }else{
                        tmpb=dp[i][j-1];
                    }
                    dp[i][j]=Math.min(tmpa, tmpb);
                }
            }
        }
        System.out.println(dp[h-1][w-1]);

    }

}

Measured memory_bytes: 21972
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int x, n, sa;
	int ans;
	sa = 100;
	cin >> x >> n;
	vector<int> pp(n);
	rep(i, n) cin >> pp[i];
	rep(i, 102) {
		bool ok = true;
		for (int a = 0;a < n;a++) {
			if (i == pp[a]) {
				ok = false;
				break;
			}
		}
		if (ok == false) continue;
		if (sa > abs(x - i)) {
			sa = abs(x - i);
			ans = i;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3608
def tw(n,x):
  r=[0]*x
  i=0
  while (n>=2 and i<x-1):
    r[i]=n%2
    n=int(n/2)
    i+=1
  r[i]=n%2
  return r

H,W,K=input().split()
H,W,K=int(H),int(W),int(K)
c2=["."*W]*H
#print(c2)
for i in range(H): 
  tmp=input()
  #print(tmp)
  c2[i]=str(tmp)


a=2**(H+W)
cnt=0
for i in range(a):
  lis=tw(i,a)
  c=c2[:]
  for j in range(H):
    if lis[j]==1: c[j]="a"*W
  for j in range(W):
    if lis[H+j]==1: 
      for k in range(H): c[k]=c[k][:j]+"a"+c[k][j+1:]
  cnt2=0
  for s in range(H):
    for t in range(W):
      if c[s][t]=="#": cnt2+=1
  #print(cnt2)
  if cnt2==K: cnt+=1
print(cnt)

    


Measured memory_bytes: 9324
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static Dictionary<int, int> dic;

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var dic = new DefaultDectionary<int, int>(0);


        foreach(var a in ary) {
            dic[a] += 1;
        }

        for(int i= n-1; i >= 1; i-=2) {
            if(dic[i] == 2) {
            } else {
                return 0;
            }
        }

        if(n % 2 == 1) {
            if(dic[0] == 0) return 0;
        }

        return ModPow(2, n/2);
    }

    static long ModPow(long x1, long x2) {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % Mod;
            }
            x1 = (x1 * x1) % Mod;
            x2 /= 2;
        }
        return ans % Mod;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

    class DefaultDectionary<Tkey, TValue> : Dictionary<Tkey, TValue>
    {
        TValue DefaultValue;
        public DefaultDectionary(TValue defaultvalue) {
            this.DefaultValue = defaultvalue;
        }
        public new TValue this[Tkey key] {
            get {
                if (this.ContainsKey(key)) return base[key];
                else return DefaultValue;
            }
            set {
                base[key] = value;
            }
        }
    }


}


Measured memory_bytes: 23520
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x)
#define printl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;

int main(){
    string N; cin >> N;
    ll n = sz(N);
    ll c = 0;
    ll s = 0;
    ll t = 0;
    for(int i=n-1; i>=0; i--){
        int p = N[i] - '0';
        if(i == 0){
            if(p <= 5){
                p += s;
            }else{
                p += s+t;
            }
            if(p <= 5){
                c += p;
            }else{
                c += 11 - p;
            }
        }
        else{
        if(p < 5){
            p += s;
            s = 0; t = 0;
            if(p == 5){
                t++;
            }
        }else if(p == 5){
            p += s + t;
            if(p == 5){
                s = 0;
                t = 1;
            }else{
                s = 1; t = 0;
            }
        }else if(p > 5){
            p += s + t;
            s = 1; t = 0;
        }
        if(p < 5){
            c += p;
        }else{
            c += 10 - p;
        }
        }
    }
    cout << c;
}

Measured memory_bytes: 1412
N = int(input())
A = list(map(int, input().split()))
LN = max(A) + 1
L = [0 for i in range(LN)]
count = 0
for i in A:
    for j in range(i, LN, i):
        L[j] += 1
for i in A:
    if L[i] == 1:
        count += 1
print(count)

Measured memory_bytes: 195544
from decimal import *
Q = int(input())#100

for i in range(Q):
  a, b = map(int, input().split())
  a = Decimal(a)
  b = Decimal(b)
  m = int((Decimal(a * b) - 1) ** Decimal(1 / 2))
  ans = 2 * m
  if a == b:
    ans -= 0
  else:
    if int((Decimal(a * b) - Decimal(1)) / Decimal(m)) == m:
      ans -= 2
    else:
      ans -= 1
  print(ans)

Measured memory_bytes: 78372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 20

void get_int2(char *line, int size, int *a1, int *a2) {
  if(!fgets(line, size, stdin)) return;
  sscanf(line, "%d %d", a1, a2);
}

int get_int(char *line, int size) {
  if(!fgets(line, size, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}

struct list {
  struct list *next;
  int dst;
};

struct list *create_graph(int size) {
  struct list *graph = malloc(sizeof(struct list)*size);
  int i;
  for(i = 0; i < size; i++) {
    graph[i].next = &graph[i];
  }
  return graph;
}

void insert(struct list *graph, int src, int dst) {
  struct list *head = &graph[src];
  struct list *elem = malloc(sizeof(struct list));
  elem->next = head->next;
  elem->dst = dst;
  head->next = elem;
  return;
}

#define VERTEX_MAX 100000

static int queue[VERTEX_MAX];
static int start = 0;
static int end = 0;
void enqueue(int idx) {
  queue[start++] = idx;
}

int dequeue() {
  return queue[end++];
}

int is_empty(void) {
  return start == end;
}

int main(void) {
  char line[BUF_SIZE];
  int es = get_int(line, BUF_SIZE);
  int vs = es;
  struct list *graph = create_graph(vs+1);
  int i, j;
  static int dst_count[VERTEX_MAX+1];
  for(i = 0; i < es; i++) {
    int v1, v2;
    get_int2(line, BUF_SIZE, &v1, &v2);
    insert(graph, v1, v2);
    insert(graph, v2, v1);
    dst_count[v1]++; dst_count[v2]++;
  }

  for(i = 1; i <= es; i++) {
    if(dst_count[i]==1) enqueue(i);
  }

  static char res[VERTEX_MAX+1];
  while(!is_empty()) {
    int idx = dequeue();
    dst_count[idx]--;
    res[idx]=1;
    struct list *head = &graph[idx];
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
      dst_count[elem->dst]--;
      if(res[elem->dst]) continue;
      if(dst_count[elem->dst]==1) {
        enqueue(elem->dst); res[elem->dst]=1;
      }
    }
  }

  int queries = get_int(line, BUF_SIZE);
  for(i = 0; i < queries; i++) {
    int v1, v2;
    get_int2(line, BUF_SIZE, &v1, &v2);
    int flag = res[v1]==0 && res[v2]==0;
    printf("%d\n", flag ? 2 : 1);
  }

  return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, m, other, k; cin >> n >> m >> other >> k;
    vector<ll> a(n), b(m), c(other);
    for (ll &x : a) {
        cin >> x;
    }
    for (ll &x : b) {
        cin >> x;
    }
    for (ll &x : c) {
        cin >> x;
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    vector<ll> all;
    for (ll &x : a) {
        for (ll &y : b) {
            all.push_back(x + y);
        }
    }
    sort(all.rbegin(), all.rend());
    vector<ll> finalSums;
    for (int i = 0; i < min(k, SZ(all)); i++) {
        for (ll &x : c) {
            finalSums.push_back(all[i] + x);
        }
    }
    sort(finalSums.rbegin(), finalSums.rend());
    for (int i = 0; i < k; i++) {
        cout << finalSums[i] << "\n";
    }
}


Measured memory_bytes: 43408