akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    string s;
    ll k;
    cin >> s >> k;
    rep(i, min(k, (ll)s.size())) {
        if(s[i] != '1') {
            cout << s[i];
            return 0;
        }
    }
    cout << 1;
}


Measured memory_bytes: 256
n = int(input())
ans = 1
flg = True
input_a = list(input().split())

if '0' in input_a:
    print(0)
else:
    for a in input_a:
        _a = int(a)
        ans *= _a
        if ans > 10 ** 18:
            print(-1)
            flg = False
            break

    if flg:
        print(ans)


Measured memory_bytes: 19336
#include <cstdio>
#include <cstring>

using namespace std;

const int MAX_WIDTH = 1005, MAX_HEIGHT = 1005, MOD = 1e9 + 7;
const char WALL = '#';
char grid[MAX_WIDTH][MAX_HEIGHT];
long long no_of_paths[MAX_WIDTH][MAX_HEIGHT];

int main()
{
    int height, width;
    scanf("%d %d", &height, &width);

    for(int i = 1; i <= height; i++)
        scanf("%s", grid[i] + 1);

    memset(no_of_paths, 0, sizeof(no_of_paths));

    for(int i = 1; i <= height; i++)
    {
        for(int j = 1; j <= width; j++)
        {
            if(grid[i][j] == WALL) continue;

            if(i == 1 && j == 1)
            {
                no_of_paths[i][j] = 1;
            }
            else
            {
                no_of_paths[i][j] = (no_of_paths[i - 1][j] + no_of_paths[i][j - 1])%MOD;
            }
        }
    }

    printf("%lld", no_of_paths[height][width]);
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;


ll N, M, X;
vector<ll> C;
ll A[20][20];

int main() {
    cin >> N >> M >> X;
    C.resize(N);
    rep(i, N) {
        cin >> C[i];

        rep(j, M) {
            cin >> A[i][j];
        }
    }

    ll ans = INF;
    // 何個オンにするか
    for (int i = 0; i < 1 << N; i++) {
    // for (int i = 7; i < 1 << N; i++) {
        vector<ll> target;
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) {
                target.push_back(j);
            }
        }

        ll total = 0;
        map<ll, ll> mp;
        for (int j = 0; j < target.size(); j++) {
            int idx = target[j];
            // cout << idx << " ";
            for (int k = 0; k < M; k++) {
                mp[k] += A[idx][k];
            }
            total += C[idx];
        }

        // for (auto v : mp) {
        //     cout << v.first << " " << v.second << endl;
        // }
        // cout << total << endl;
        // return 0;

        ll fill_cnt = 0;
        for (auto v : mp) {
            if (v.second >= X) {
                fill_cnt++;
            }
        }
        if (fill_cnt == M) {
            ans = min(ans, total);
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX = 20;
const int NMAX = 50000;
const int INF = 999999999;
int main()
{
	int n, m;
	int min[NMAX], faceVal[MAX];
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> faceVal[i];
	min[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		min[i] = INF;
		for (int j = 0; j < m; j++)
			if (i >= faceVal[j] && min[i] > min[i - faceVal[j]] + 1)
				min[i] = min[i - faceVal[j]] + 1;
	}
	cout << min[n] << endl;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define VI vector<int>
#define pb push_back
#define LL long long
#define mp make_pair
#define pii pair<int,int>
using namespace std;
map<int,int> s;
const int MAXN = 2e5;
int n, k;
int A[MAXN+10];
LL S[MAXN+10];
int main(){
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%d", &A[i]);
		A[i] = (A[i]-1 + k)%k;
	}

	S[0] = A[0];
	for(int i = 1; i < n; i++){
		S[i] = S[i-1] + A[i];
		S[i] %= k;
	}
	for(int i = 0; i < min(n, k - 1); i++) s[S[i]]++;
	int req = 0;
	LL ans = 0;
	for(int i = 0; i < n; i++){
		ans += s[req];
		s[S[i]]--;
		if(i + k - 1 < n) s[S[i+k-1]]++;
		req = (req + A[i])%k;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  vector<string> ans(0);
  for (int i = 1; i <= min(5,(int)(s.size())); i++) {
    for (int j = 0; j <= s.size() - i; j++) {
      string str = s.substr(j,i);
      ans.push_back(str);
    }
  }
  sort(ans.begin(),ans.end());
  vector<string> ansans(1);
  ansans[0] = ans[0];
  for (int i = 1; i < ans.size(); i++) {
    if (ans[i] != ans[i - 1]) {
      ansans.push_back(ans[i]);
    }
  }
  cout << ansans[k - 1] << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int height = 0;
  int bottom = 0;
  int left = 0;
  int right = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '('){
      height++;
    }else{
      height--;
      if(height < bottom){
	bottom = height;
      }
    }
  }
  if(height <= 0){
    left = -height;
    bottom += left;
  }else{
    right = height;
  }

  if(bottom < 0){
    left += - bottom;
    right +=  - bottom;
  }
  
  for(int i = 0; i < left; i++){
    cout << '(' ;
  }
  
  cout << S;

  for(int i = 0; i < right; i++){
    cout << ')';
  }

  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>

#define MAX_HW 32

using namespace std;

int H, W, S;
int usum;
int u[MAX_HW][MAX_HW];

typedef pair<int, int> P;// ??°???????????°???????????????
P dp[MAX_HW+1][MAX_HW+1][MAX_HW+1][MAX_HW+1];
P unknown = P(-1,-1);

int calc_sum(int x1, int y1, int x2, int y2){
	int res = 0;
	for (int i = y1; i < y2; i++)
	{
		for (int j = x1; j < x2; j++)
		{
			res += u[i][j];
		}
	}
	return res;
}

P dfs(int sx, int sy, int ex, int ey){
	if(dp[sy][sx][ey][ex] != unknown) return dp[sy][sx][ey][ex];
	P res;
	res.first = 1;
	res.second = S-(usum - calc_sum(sx, sy, ex, ey));
	for (int i = sx+1; i < ex; i++)
	{
		if((usum - calc_sum(sx, sy, i, ey) <= S) && (usum - calc_sum(i, sy, ex, ey) <= S)){
			P r1 = dfs(sx, sy, i, ey);
			P r2 = dfs(i, sy, ex, ey);
			if(res.first < r1.first + r2.first){
				res.first = r1.first + r2.first;
				res.second = min(r1.second, r2.second);
			}else if(res.first == r1.first + r2.first && res.second < min(r1.second, r2.second)){
				res.second = min(r1.second, r2.second);
			}
		}
	}
	for (int i = sy+1; i < ey; i++)
	{
		if((usum - calc_sum(sx, sy, ex, i) <= S) && (usum - calc_sum(sx, i, ex, ey) <= S)){
			P r1 = dfs(sx, sy, ex, i);
			P r2 = dfs(sx, i, ex, ey);
			if(res.first < r1.first + r2.first){
				res.first = r1.first + r2.first;
				res.second = min(r1.second, r2.second);
			}else if(res.first == r1.first + r2.first && res.second < min(r1.second, r2.second)){
				res.second = min(r1.second, r2.second);
			}
		}
	}

	return dp[sy][sx][ey][ex] = res;
}

int main(){
	while(1){
		cin >> H >> W >> S;
		if(H == 0) break;
		usum = 0;
		for (int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++){
				cin >> u[i][j];
				usum += u[i][j];
			}
		}
		for (int i = 0; i <= H; i++)
		{
			for (int k = i; k <= H; k++)
			{
				for (int j = 0; j <= W; j++)
				{
					for (int l = j; l <= W; l++)
					{
						dp[i][j][k][l] = unknown;
					}
				}
			}
		}

		P ans = dfs(0, 0, W, H);
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 10436
N,A = map(int, input().split())
xs = list(map(int, input().split()))
"""
dp[i][j][n] : i枚目において、j枚選んだときの合計がnになる場合の数
dp[i+1][j+1][n+x] = dp[i][j][n] * (x) + dp[i][j+1][n+x]
dp[0][0][0] = 1
"""
Nx = 2550
dp = [[[0]*Nx for i in range(N+10)] for j in range(N+10)]
dp[0][0][0] = 1

for i in range(N):
    x = xs[i]
    for j in range(N):
        for n in range(Nx):
            dp[i+1][j][n] = dp[i][j][n]
    for j in range(N):
        for n in range(Nx):
            if n + x >= Nx:continue
            dp[i+1][j+1][n+x] = dp[i][j][n] + dp[i][j+1][n+x]
    # print(i,dp[i])
cnts = dp[N]
ans = 0
for i in range(1,N+1):
    ans += cnts[i][A*i]
print(ans)

Measured memory_bytes: 114908
import numpy as np
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

root = np.array([a,b,c,d,e])
min_crew = np.min(root)
first_wait = n//min_crew
if  n%min_crew == 0:
    first_wait-=1
print(first_wait+5)

Measured memory_bytes: 14440
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
const string YES = "Yes";
const string NO = "No";
void solve(long long N, std::vector<long long> a){
  if(N%3 == 0){
    ll n = 0;
    sort(all(a));
    for (int i = 0; i < 3; i++) {
      bool can = true;
      for (int l = 0; l < N/3; l++) {
        n ^= a[l+i*(N/3)];
        if(l != 0){
          if(a[l + i*(N/3)] != a[l + i*(N/3) - 1])can = false;
        }
      }
      if(!can){
        cout << NO << endl;
        return;
      }
    }
    cout << (n == 0 ? YES : NO) << endl;
    return;
  }else{ //Nが3の倍数では無いとき
    bool all_zero = true;
    for (int i = 0; i < N; i++) {
      if(a[i] != 0)all_zero = false;
    }
    cout << (all_zero ? YES : NO) << endl;
    return;
  }
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> 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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b) {
			if (a != c)
				System.out.println("Yes");
			else
				System.out.println("No");
		} else {
			if (b == c || a == c)
				System.out.println("Yes");
			else
				System.out.println("No");
		}

		sc.close();

	}
}

Measured memory_bytes: 23764
def d_AnOrdinaryGame(s):
    # 解説通り
    cond1 = len(s) % 2 == 0  # sの長さが偶数であるか
    cond2 = s[0] == s[-1]  # sの先頭と末尾の文字が同一か
    cond = cond1 ^ cond2
    if cond:
        return 'Second'
    else:
        return 'First'

s = input().strip()
print(d_AnOrdinaryGame(s))

Measured memory_bytes: 3316
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    string s;
    in s;
    int ans=0;
    int fmax=-1;
    rep(i,s.size())
    {
        if(s[i]=='A')INF=min(INF,i);
        else if(s[i]=='Z')fmax=max(fmax,i);
    }
    cout<<fmax-INF+1<<endl;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 101;

int n, m, vis[N];
set < int > G[N];
vector < PII > E;

int cnt = 0;

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

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

int main()
{
    _upgrade
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        G[a].insert(b);
        G[b].insert(a);
        E.push_back({a, b});
    }
    int ans = 0;
    for(auto p: E)
    {
        int a  = p.first, b = p.second;
        G[a].erase(b), G[b].erase(a);
        if(bad()) ans++;
        G[a].insert(b), G[b].insert(a);
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
l,m,k = map(int, input().split())
g = [a, b, c, d, e, f, l, m, k]
a1 = [a, b, c]
a2 = [d, e, f]
a3 = [l, m, k]
a4 = [a, d, l]
a5 = [b, e, m]
a6 = [c, f, k]
a7 = [a, e, k]
a8 = [c, e, l]
lis1 = []
n = int(input())
for i in range(n):
    op = int(input())
    lis1.append(op)
    
if set(a1) <= set(lis1) or set(a2) <= set(lis1) or set(a3) <= set(lis1) or set(a4) <= set(lis1) or set(a5) <= set(lis1) or set(a6) <= set(lis1) or set(a7) <= set(lis1) or set(a8) <= set(lis1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>

#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>

using namespace std;
//const char a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};



void solver() {
    // Write your code here
    int my=0,n;
    cin>>n;
    int arr[n];

    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        my+=arr[i];
    }
    int var,var1;
        var=my/n;
        var1=var+1;

    int ans=0;
    int ans1=0;
    for(int i=0;i<n;i++)
    {
        int m=(var-arr[i])*(var-arr[i]);
        ans+=m;
        int m1=(var1-arr[i])*(var1-arr[i]);
        ans1+=m1;
    }
    cout<<min(ans,ans1);
























}


int main() {
    int n=1;
    //cin>>n;
    while(n--)
    {
        solver();
    }
}


Measured memory_bytes: 3172
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
string s;
const int mod = 998244353;
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
map < string, int > mp;
int solve(const string& s) {
    if (s.empty()) return 1;
    if (s.size() == 1) {
        return (1 + (s[0] == '1'));
    }
    if (mp.find(s) != mp.end()) return mp[s];
    int ans = 0;
    ans = mult((1 + (s[0] == '1')), solve(s.substr(1)));
    vector < int > vals(s.size() + 1);
    for (int len = 1; len <= s.size(); len++) {
        vals[len] = solve(s.substr(len));
    }
    for (int len = 1; len <= s.size(); len++) {
        string f = s.substr(0, len);
        for (int cnt = 2; cnt * len <= s.size(); cnt++) {
            for (int c = 0; c < len; c++) {
                int pos = (cnt - 1) * len + c;
                if (s[pos] == '0') f[c] = '0';
            }
            ans = sum(ans, mult(solve(f), vals[cnt * len]));
        }
    }
    return mp[s] = ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    string s(100, '0');
    cin >> s;
    cout << solve(s);
    return 0;
}

Measured memory_bytes: 8060
#include <iostream>

using namespace std;

int n;

int main() {
  cin >> n;

  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      int group = 32 - __builtin_clz(i ^ j);
      cout << group << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
use proconio::input;
use proconio::marker::*;
use std::collections::VecDeque;

fn main() {
  input!{
    n: usize,
    vals: [[usize;n];2],
  }
  
  let mut twos = vec![0;n];
  twos[n-1] = vals[1][n-1];
  for i in (0..n-1).rev() {
    twos[i] = twos[i+1] + vals[1][i];
  }
  
  let mut max:usize = vals[0].iter().sum();
  let mut now = 0;
  for i in 0..n {
    now += vals[0][i];
    let v = now + twos[i];
    max = std::cmp::max(max, v);
  }
  
  println!("{}", max);
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算 COMinit()を先に使用すること
long long COM(int n, int k){
	if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int n,m;
    cin>>n>>m;
    map<int,int>w;
    int tmp=m;
    for(int i=2;i<=sqrt(m);i++){
        while(tmp%i==0){
            tmp/=i;
            w[i]++;
        }
    }
    if(tmp!=1)w[tmp]++;
    COMinit();
    ll ans=1;
    for(auto i:w){
        ans*=COM(i.second+n-1,i.second);
        ans%=MOD;
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    int res=0;
    rep(i,0,n-1){
        if(a[i]==a[i+1]){
            res++;
            a[i+1]=i+1e9;//被らない数字(iが可変なのでなんでも)
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N ;

    string s[N];
    int t[N];


    for(int i=0;i<N;i++){
        cin >> s[i] >> t[i];
    }

    string X;

    cin >> X;

    int cont=0,ans=0;

    while(cont<N-1){

        if(s[cont]==X){
            for(int i=cont+1;i<N;i++){
                ans = ans + t[i];
            }         
        }
        cont++;
    }

    cout << ans << endl;
    


    return 0;

}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;

  return 0;
}


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


bool chk_pal (string s)
{
ll l = s.size();
for (int i=0; i<l/2; i++){
    if (s[i] != s[l-i-1]){return false;}
}
return true;

}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    string s, s1, s2;
    cin >> s;
    ll len = s.size();
    ll len1 = (len - 1) / 2;
    ll len2 = (len + 3) / 2;
    for (int i=0; i<len1; i++){
        s1 += s[i];
    }
    for (int i=len2-1; i<len; i++){
        s2 += s[i];
    }
    if ((chk_pal(s1)) && (chk_pal(s2)) && (chk_pal(s))){cout << "Yes" << endl;}
    else {cout << "No" << endl;}

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)

vector<ll> prime_factor(ll n){
    vector<ll> ret;
    for(ll i=2; i*i<=n; i++){
        if(n % i == 0){
            while(n % i == 0) n /= i;
            ret.push_back(i);
        }
    }
    if(n > 1) ret.push_back(n);
    return ret;
}

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

    ll a, b; cin >> a >> b;
    map<ll, int> mp;
    for(auto e : prime_factor(a)) mp[e]++;
    for(auto e : prime_factor(b)) mp[e]++;
    int ans = 1;
    for(auto e : mp) if(e.second == 2) ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return k*kk;
}using namespace std;
int n,mi,a[1000],ff,f[1000];
bool pd(int x){
	for (int i=1;i<=n;i++){
		ff=0;f[i]=a[i];
		for (int j=0;j<i;j++)
			if (min(max(f[i],f[j])-min(f[i],f[j]),min(f[i],f[j])-max(f[i],f[j])+24)<x)ff=1;
		if (ff)ff=0,f[i]=24-a[i];
		for (int j=0;j<i;j++)
			if (min(max(f[i],f[j])-min(f[i],f[j]),min(f[i],f[j])-max(f[i],f[j])+24)<x)ff=1;
		if (ff)return 0;
	}return 1;
}
int main(){
	n=read();mi=100;
	for (int i=1;i<=n;i++)a[i]=read();sort(a+1,a+1+n);
	for (int i=a[1];i>=0;i--)
		if (pd(i)){cout<<i<<endl;return 0;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  dump((a+b)*h/2);
  return 0;
}


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

void solve() {
    int N; cin >> N;
    vector<int> A(N + 2);
    rep(i, N) cin >> A[i + 1];
    int total = 0;
    rep(i, N + 1) total += abs(A[i + 1] - A[i]);
    for(int i = 1; i <= N; ++i) {
        int sub = abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]);
        int add = abs(A[i - 1] - A[i + 1]);
        cout << total - sub + add << '\n';
    }
}

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


Measured memory_bytes: 3708
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int h,w;
	cin >> h >> w;
	string a;
	for(int i =0; i<w+2; i++) cout << '#';
	cout << endl;
	for(int i=0; i<h; i++){
		cin >> a;
		cout << '#' << a << '#' << endl; 
	}
	for(int i =0; i<w+2; i++) cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
	int h,w;
  	while(true){
    	cin>>h>>w;
      	if(h==0 && w==0) break;

      	for(int i=1;i<=h;i++){
        	for(int j=1;j<=w;j++){
        		if(i==1 || j==1 || i==h || j==w){
                  cout<<'#';
                }else{
                  cout<<'.';
                }
        	}
          cout<<endl;
        }
       cout<<endl;
    }
}



Measured memory_bytes: 3088
W,H,N = map(int, input().split())
p = [list(map(int, input().split())) for i in range(N)]
x, y = 0, 0
for i in p:
    if (i[2] == 1) and (x < i[0]):
        x = i[0]
    elif (i[2] == 2) and (W > i[0]):
        W = i[0]
    elif (i[2] == 3) and (y < i[1]):
        y = i[1]
    elif (i[2] == 4) and (H > i[1]):
        H = i[1]
area = (W-x)*(H-y)
if ((W-x) <= 0) or ((H-y) <= 0):
    print(0)
else:
    print(area)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	print(6 / n / m)
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long tmp1 = 0;
        long tmp2 = 0;
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                tmp1 = i;
                //if (i != n / i) {
                    tmp2 = n / i;
                //}
                if(tmp2 <= tmp1) break;
            }
        }
        long ans = tmp2 + tmp1 -2;
        System.out.println(ans);
    }
}

Measured memory_bytes: 35620
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
int n,he;
ll a[1000009],b[1000009];
ll ans=0;
bool check(ll sum,ll k)
{
  he=1;
  for (int i=n;i>=1;i--)
  {
    if (a[he]*b[i]<=sum) {he++;continue;}
    if ((a[he]-sum/b[i])>k) return false;
    k-=a[he]-sum/b[i];
    he++;
  }
  return true;
}
int main()
{
  ll k;
  scanf("%d%lld",&n,&k);
  for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
  for (int i=1;i<=n;i++) scanf("%lld",&b[i]);
  sort(a+1,a+1+n); sort(b+1,b+1+n);
  ll l=0,r=0;
  r=b[n]*a[n];ans=r;
  while (l<=r)
  {
      ll mid=(l+r)/(ll)2;
      if (check(mid,k)) ans=mid,r=mid-1;
      else l=mid+1;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 5888
import java.util.Scanner;
public class Main {
    static int[][] cost;
    static int[] row, col;
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	row = new int[n];
	col = new int[n];
	String[] input;
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    row[i] = Integer.parseInt(input[0]);
	    col[i] = Integer.parseInt(input[1]);
	}
	cost = new int[n][n];
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < n; j++) {
		if (i != j) {
		    cost[i][j] = Integer.MAX_VALUE;
		}
	    }
	}
	minCost(0, n-1);
	System.out.println(cost[0][n-1]);
    }
    
    static void minCost (int first, int last) {
	for (int k = first; k < last; k++) {
	    int m1 = cost[first][k], m2 = cost[k+1][last];
	    if (cost[first][k] == Integer.MAX_VALUE) {
		 minCost(first, k);
	    }
	    if (cost[k+1][last] == Integer.MAX_VALUE) {
		minCost(k+1, last);
	    }
	    int min = cost[first][k] + cost[k+1][last] + row[first] * col[k] * col[last];
	    if (cost[first][last] > min) {
		cost[first][last] = min;
	    }
	}
    }
}

Measured memory_bytes: 26880
#include <stdio.h>
int main(void){
	long long n,k;
	scanf("%lld %lld",&n,&k);
	long long ans=0;
	long long i;
	long long temp = 0;
	
	//kが奇数のとき
	if( k%2 != 0){
		temp = n/k;
		ans = temp * temp * temp;
	}else{
		long long a = n/k;
		long long b = 0;
		for(i=1;i<=n;i++){
			if( (i%k) ==(k/2)){
				b++;
			}
		}
		ans = a*a*a + b*b*b;
	}
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 128
/*
問題文
すぬけ君は 1 〜 N の整数が等確率で出る N 面サイコロと表と裏が等確率で出るコインを持っています。
すぬけ君は、このサイコロとコインを使って今から次のようなゲームをします。
まず、サイコロを 1 回振り、出た目を現在の得点とする。
得点が 1 以上 K−1 以下である限り、すぬけ君はコインを振り続ける。
表が出たら得点は 2 倍になり、裏が出たら得点は 0 になる。得点が 0 になった、もしくは K 以上になった時点でゲームが終了する。
このとき、得点が K 以上である場合すぬけ君の勝ち、 0 である場合すぬけ君の負けである。
N と K が与えられるので、このゲームですぬけ君が勝つ確率を求めてください。
*/

function f(a, b) {
  var ans = 0;
  while (Math.pow(2, ans) * a < b) {
    ans += 1
  }
  return ans
}

function main(input) {
  const inputChars = input.split(" ");
  const N = parseInt(inputChars[0]);
  const K = parseInt(inputChars[1]);

  var sum = 0;
  for (var n = 1; n < N + 1; n++) {
    var fnk = f(n, K);
    sum += Math.pow(0.5, fnk);
  }
  console.log(sum / N);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10040
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxn = 1e5;
const ll mod = 998244353;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int siz = 1e5+20;
ll fact[siz], inv[siz];
void pre(){
	fact[0] = 1;
	for(int i=1;i<siz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxn;i++) spf[i]=i;
    for(int i=4;i<mxn;i+=2) spf[i]=2;
    for(int i=3;i*i<mxn;i++){
    }
}

vector<int> adj[100000];
int p[100000];

int find(int a){
    if(a==p[a]) return a;
    return (p[a]=find(p[a]));
}

bool un(int a,int b){

    int x = find(a);
    int y = find(b);

    if(x==y) return 0;
    p[y]=x;
    return 1;
}

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

    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++){
        p[i]=i;
    }
    int c = 0;

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        
        if(un(a,b)){
            c++;
        }
    }

    cout<<(n-1)-c<<endl;

}

Measured memory_bytes: 6352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int hr=0,mn=0,sc=0;
		int time=0;
		int rest=0;

		int r_hr=0,r_mn=0,r_sc=0;

		try {
			while(true) {
				str=bfr.readLine();
				stk=new StringTokenizer(str," ");
				hr=Integer.parseInt(stk.nextToken());
				mn=Integer.parseInt(stk.nextToken());
				sc=Integer.parseInt(stk.nextToken());

				if(hr==-1 && mn==-1 && sc==-1) {
					break;
				}
				else {
					time=hr*3600+mn*60+sc;
					rest=7200-time;

					r_hr=rest/3600;
					r_mn=(rest%3600)/60;
					r_sc=rest%60;
					System.out.println(String.format("%02d", r_hr)+":"+String.format("%02d", r_mn)+":"+String.format("%02d", r_sc));

					rest=(7200-time)*3;
					r_hr=rest/3600;
					r_mn=(rest%3600)/60;
					r_sc=rest%60;
					System.out.println(String.format("%02d", r_hr)+":"+String.format("%02d", r_mn)+":"+String.format("%02d", r_sc));
				}
			}
		}catch(IOException e) {

		}
	}
}


Measured memory_bytes: 24812
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

int n,m,q,ans;
vector<int>a,b,c,d;
vector<vector<int>>vs;

void add(int n,int m,vector<int> &a){
    if(a.size()==n&&a.back()<=m){vs.push_back(a);}
    else{
        int st = (a.size()?a.back():1);
        for(int i=st;i<=m;i++){
            vector<int>b = a;
            b.push_back(i);
            add(n,m,b);
        }
    }
}

int val(vector<int>&A){
    int ret = 0;
    rep(i,0,q){
        if(A[b[i]-1] - A[a[i]-1] == c[i]){
            ret +=d[i];
        }
    }
    return ret;
}

void solve(){
    for(vector<int>x: vs){
        ans = max(ans,val(x));
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    cin>>n>>m>>q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,0,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int>v;
    add(n,m,v);
    solve();
    cout<<ans<<endl;
}

Measured memory_bytes: 13896
w,b=map(int, input().split())
A,B,C,D=['##'],['..'],['#.'],['.#']
w-=1
b-=1
print(100,50)
for i in range(100):
  if i<50:
    if i%2==1:
      print(*A*25,sep='')
    elif w>=25 and i%2==0:
      print(*C*25,sep='')
      w-=25
    else:
      E=C*w+A*(25-w)
      print(*E,sep='')
      w=0
  else:
    if i%2==0:
      print(*B*25,sep='')
    elif b>=25 and i%2==1:
      print(*D*25,sep='')
      b-=25
    else:
      F=D*b+B*(25-b)
      print(*F,sep='')
      b=0

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define mem( f, x ) memset( f, x, sizeof(f))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
#define pk push_back
typedef long long LL;
using namespace std;
const int M = 2*1e5+50;
const int N = 2*1e5+50;
const int INF = 1e9+50;
int m, n;
LL a[N];
bool cmp( LL p1, LL p2 ){
    return p1 > p2;
}

int main( ){
    while( scanf( "%d", &n ) != EOF ){
        for( int i = 0; i < n; i++ )
            scanf( "%lld", a+i );
        sort( a, a+n, cmp );
        int ct = n-1;
        LL sum = 0;
        for( int i = 0; i < n, ct > 0; i++ ){
            sum += a[i];
            ct--;
            if( !ct ) break;
            if( i ){
                sum += a[i];
                ct--;
                if( !ct ) break;
            }
        }
        printf( "%lld\n", sum );
    }
    return 0;
}


Measured memory_bytes: 5316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        char c = obj.next().charAt(0);
        if(c>='A' && c<='Z')
            System.out.println("A");
        else
            System.out.println("a");
    }
}


Measured memory_bytes: 32748
# 参考: https://atcoder.jp/contests/exawizards2019/submissions/4780769
def c_snuke_the_wizard(N, Q, S, Magic):
    # ゴーレムが隣のゴーレムを追い抜くことはありえない
    # (複数体重なれば、その後同じように動いていくため)。
    # よって、 左端で消滅する、最初に最も右にいるゴーレムleftと、
    # 右端で消滅する、最初に最も左にいるゴーレムrightが分かればいい。
    # (left >= right とはなりえない)
    # これを二分探索で求めれば O(Qlog(N)) で解を得られる。
    def is_vanished(x, direction):
        """
        x番のゴーレムがdirection(leftまたはrightのいずれか)で指定される端で
        消滅するかどうか判定する
        """
        for t, d in Magic:
            if t == S[x]:
                # 呪文で指定されたマスに注目したゴーレムがいた。
                # 呪文の内容に従ってゴーレムを移動させる
                x = x - 1 if d == 'L' else x + 1
            if x in (-1, N):
                return True  # 左端/右端 で消滅することとなった
        return False

    def binary_search(accept, reject, direction):
        """
        direction が 'left' の場合は accept番とその左側のゴーレムが消滅する。
        direction が 'right' の場合は accept番とその右側のゴーレムが消滅する。
        direction によって accept と reject の位置関係が逆転することに注意。
        """
        while abs(accept - reject) > 1:
            mid = (accept + reject) // 2
            if is_vanished(mid, direction):
                accept = mid
            else:
                reject = mid
        return accept + 1 if direction == 'left' else N - accept
    return max(N - binary_search(-1, N, 'left') - binary_search(N, -1, 'right'), 0)

N, Q = [int(i) for i in input().split()]
S = input()
Magic = [input().split() for j in range(Q)]
print(c_snuke_the_wizard(N, Q, S, Magic))

Measured memory_bytes: 91980
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

string s;

int main() {
  cin >> s;
  auto n = s.size();
  int ans = 0;
  rep(i, n) {
    if (s.at(i) == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

const int MAX = 3000000;
long long fac[MAX], finv[MAX], inv[MAX];

void pre() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

int c(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void solve() {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
		return;
	}
	int m = (2 * x) / 3 - y / 3;
	int n = x - 2 * m;
	pre();
	cout << c(n + m, n) << "\n";
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

Measured memory_bytes: 73972
<?php
fscanf(STDIN,"%s",$a);

$lit = array("a","b","c","d","e","f","g","h");
array_push($lit,"i","j","k","l","m","n","o","p","q","r","s","t","u");
array_push($lit,"v","w","x","y","z");

$result = array_search($a, $lit);
$ans = $lit[$result + 1];
echo $ans;
?>


Measured memory_bytes: 3828
n,m,c = (int(i) for i in input().split())
b = list(int(i) for i in input().split())
ct = 0

for i in range(n):
  judge = 0
  a = list(int(i) for i in input().split())
  for j in range(m):
    judge += a[j]*b[j]
  if judge+c >0:
    ct+= 1
print(ct)

Measured memory_bytes: 3060
a = []

def h(t):
  return 3 in t and 5 in t and 7 in t

def comb(t):
  l = 0
  for i in t:
    l += i
    l = l * 10
  return l // 10

import itertools

for i in range(10):
  a += [comb(x) for x in list(itertools.product([3, 5, 7], repeat=i)) if h(x)]

n = int(input())

t = 0

for i in a:
  if i <= n:
    t += 1

print(t)

Measured memory_bytes: 7204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double>> q;
	rep(i, n) {
		double v;
		cin >> v;
		q.push(v);
	}

	rep(i, n - 1) {
		double v, w;
		v = q.top();
		q.pop();
		w = q.top();
		q.pop();
		q.push((v + w) / 2.0);
	}
	cout << q.top() << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<double> p(n);
  rep(i,n)cin >> p[i];
  vector<vector<double>> dp(n+1,vector<double>(n+1,0));
  dp[0][0] = 1;
  rep(i,n)rep(j,n){
    dp[i+1][j+1] += dp[i][j]*p[i];
    dp[i+1][j] += dp[i][j]*(1-p[i]);
  }
  double res = 0;
  rep(i,n+1)if(i > n-i)res += dp[n][i];
  cout << res << "\n";

  

  return 0;
}

Measured memory_bytes: 73760
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int minn = 200000;
  int maxx = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='A'){
      minn = min(minn,i);
    }
    if(s[i]=='Z') maxx = max(maxx, i);
  }
  cout << maxx - minn + 1 << endl;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);
            int c = Integer.parseInt(strArr[2]);
            if (a == b) {
                if (a == c) {
                    System.out.println(1);
                } else {
                    System.out.println(2);
                }
            } else {
                if (a == c) {
                    System.out.println(2);
                } else if (b == c) {
                    System.out.println(2);
                } else {
                    System.out.println(3);
                }
            }
       } catch (IOException e) {
            e.printStackTrace();
       }
    }
}


Measured memory_bytes: 21460
S = input()
for i in range(len(S)):
    if (i + 1) % 2 == 1 :
        if not S[i] in ['R', 'U', 'D'] :
            print("No")
            exit()
    else : 
        if not S[i] in ['L', 'U', 'D'] :
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>  
#include <bitset>
#include <cassert>
#include <ctime>  
#include <cmath>  
#include <cstdlib>  
#include <cstring>  
#include <functional>  
#include <iostream>  
#include <deque>  
#include <stack>
#include <queue>  
#include <vector>  
#include <map>  
#include <set>  
#include <string>  
#include <unordered_map>  
#include <unordered_set>  
#pragma warning(disable:4996)

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const int INF = 1e9;
const int MAXN = 2e5 + 5;

int N, M;

int f(int n, int r) {
	if(n < r) return 0;
	if(r == 0) return 1;
	if(r == 1) return n;
	if(n == r) return 1;
	return f(n-1, r) + f(n-1, r-1);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	cout << f(N, 2) + f(M, 2);
}


Measured memory_bytes: 256
program prob5
    implicit none
    integer::n, i, x, y
    integer, allocatable::u(:), v(:)
    read*, n
    allocate(u(n), v(n))
    do i = 1, n
        read(*,*) x, y
        u(i) = x + y
        v(i) = x - y
    end do
    write(*,*) max(maxval(u) - minval(u), maxval(v) - minval(v))
    deallocate(u, v)
    stop
end program

Measured memory_bytes: 3988
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int x[][]=new int[n+1][11];
			int y[][]=new int[n+1][11];
			int m[]=new int[51];
			TreeSet<Integer>TS=new TreeSet<Integer>();
			for(int i=0;i<=n;i++)
			{
				m[i]=in.nextInt();
				for(int j=0;j<m[i];j++)
				{
					x[i][j]=in.nextInt();
					y[i][j]=in.nextInt();
				}
			}

			for(int I=0;I<=m[0];I+=m[0]-1)
			{

				for(int i=0;i<=n;i++)
				{
					if(I!=0&&i==0)
						continue;
					int mx=0;
					int my=0;
					if(x[i][I]!=0) mx=x[i][I];
					if(y[i][I]!=0) my=y[i][I];
					for(int j=0;j<m[0];j++)
					{
						x[i][j]-=mx;
						y[i][j]-=my;
					}
				}
				for(int i=1;i<=n;i++)
				{
					if(m[0]!=m[i])
						continue;
					boolean judge=true;
					int tx[]=x[i].clone();
					int ty[]=y[i].clone();
					for(int j=0;j<4;j++)//90度回転を4回試す
					{
						judge=true;
						if(I==0)
							for(int k=0;k<m[0];k++)
							{
								int tmp=tx[k];
								tx[k]=ty[k];
								ty[k]=-tmp;
								if(tx[k]!=x[0][k]||ty[k]!=y[0][k])
									judge=false;
							}
						else
							for(int k=m[0]-1;k>=0;k--)
							{
								int tmp=tx[k];
								tx[k]=ty[k];
								ty[k]=-tmp;
								if(tx[k]!=x[0][m[0]-k-1]||ty[k]!=y[0][m[0]-k-1])
									judge=false;
							}
						if(judge)
							TS.add(i);
					}
				}
			}
			for(int p:TS)
				System.out.println(p);
			System.out.println("+++++");
		}
	}

	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 29160
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(N + 1);
  rep(i, N) {
    int a;
    cin >> a;
    A[i + 1] = A[i] + a;
  }

  vector<int> B(M + 1);
  rep(i, M) {
    int b;
    cin >> b;
    B[i + 1] = B[i] + b;
  }

  int ans = 0;
  rep(n, N + 1) {
    int res = K - A[n];
    if (res < 0)
      break;

    auto iter = upper_bound(all(B), res);
    int ind = distance(B.begin(), iter);
    int m = ind - 1;

    int sum = n + m;
    chmax(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6404