akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
//#include <stdlib.h>
//using namespace std;
//
//typedef long long ll;
//typedef unsigned long long ull;
//
//#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
//
//struct node {
//    node(int w, int s, int idx) {
//        this->w = w;
//        this->s = s;
//        this->idx = idx;
//    }
//    node() { }
//    int w, s, idx;
//    bool operator < (node a) {
//        if (this->w == a.w) {
//            return this->s > a.s;
//        }
//        return this->w < a.w;
//    }
//};
//
//vector<pair<int, int> > v;
//vector<node> res, res_final;
//
//int dp[1500];
//
//bool valid(vector<node> v) {
//    for (int i = 1; i < v.size(); i++) {
//        if (v[i].w > v[i-1].w && v[i].s < v[i-1].s)
//            continue;
//        else return 0;
//    }
//    return 1;
//}
//
//ll solve(int idx) {
//    if (idx == v.size()) {
//        if (!valid(res))
//            return 0;
//        if (res.size() >= res_final.size())
//            res_final = res;
//        return 1;
//    }
//
//    res.push_back(node(v[idx].first, v[idx].second, idx));
//    bool a = solve(idx+1);
//    res.pop_back();
//    bool b = solve(idx+1);
//    return (a || b);
//}
//
//int main() {
//#ifndef ONLINE_JUDGE
//    freopen("file.in", "r", stdin);
//#endif
//    int x, y;
//    while (cin >> x >> y) {
//        v.push_back({x, y});
//    }
//    memset(dp, -1, sizeof(dp));
//    solve(0);
//    cout << res_final.size() << endl;
//    for (int i = 0; i < res_final.size(); i++) {
//        cout << res_final[i].idx + 1 << endl;
//    }
//}

#include <iostream>
using namespace std;

int main() {
    string s;
    cin >> s;
    int res = 700;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o')
            res += 100;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string first, second, third;
  string answer = "123";
  cin >> first >> second >> third;
  answer.at(0) = first.at(0);
  answer.at(1) = second.at(0);
  answer.at(2) = third.at(0);
  cout << answer << endl;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    W, a, b = map(int, input().split())
    if a <= b <= a + W or a <= b + W <= a + W:
        print(0)
    else:
        print(min(abs(b - (a + W)), abs(a - (b + W))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll N;
  string s;

  cin >> N;
  cin >> s;
  ll r_count = 0;

  for (ll i = 0; i < N; i++)
  {
    if (s[i] == 'R')
    {
      r_count++;
    }
  }

  if (r_count > N - r_count)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  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 n = sc.nextInt();
        int candy = sc.nextInt();
        int rejoice[] = new int[n];
        int sum = 0;
        int count = 0;
        for(int i = 0; i < n; i++){
        	rejoice[i] = sc.nextInt();
            if(!(sum + rejoice[i] > Math.pow(10, 9))){
            	sum += rejoice[i];
            }
        }
        Arrays.sort(rejoice);
        if(rejoice[0] > candy){
        	System.out.println("0");
        }else if(sum < candy){
        	System.out.println(n - 1);
    	}else{
        	for(int i = 0; i < n; i++){
            	if(candy >= rejoice[i]){
                	candy -= rejoice[i];
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 35976
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string n; cin >> n;
	int c = n.at(0) - '0';
	int ans = c + 9 * (n.size() - 1);
	bool ok = true;
	rep(i, n.size()) {
		if (i == 0)continue;
		if (n.at(i) != '9') {
			ok = false; break;
		}
	}
	if(!ok)cout << ans -1<< endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# E - Red and Green Apples
from collections import deque

X,Y,A,B,C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
P = deque(P)
Q = deque(Q)
R = deque(R)
red,green = 0,0
apple = [P.popleft(), Q.popleft(), R.popleft()]
ans = 0

for _ in range(X+Y):
    mapple = max(apple)
    ans += mapple
    if apple[2]==mapple:
        if len(R)>0:
            apple[2] = R.popleft()
        else:
            apple[2] = -1
    elif apple[0]==mapple:
        red += 1
        if red<X:
            apple[0] = P.popleft()
        else:
            apple[0] = -1
    else:
        green += 1
        if green<Y:
            apple[1] = Q.popleft()
        else:
            apple[1] = -1

print(ans)

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

typedef long long int ll;
ll n, a, ans[200007];

int main() {
    cin >> n;
    for(ll i = 2; i <= n; ++i) {
        cin >> a;
        ans[a]++;
    }

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

Measured memory_bytes: 5160
s = list(input())
k = int(input())
n = len(s)
alph_map = {chr(ord('a') + i): (26 - i) % 26 for i in range(26)}
for i in range(n):
    if k >= alph_map[s[i]]:
        k -= alph_map[s[i]]
        s[i] = 'a'
if k > 0:
    s[n-1] = chr((ord(s[n-1]) + k % 26) % 123)
print(''.join(s))


Measured memory_bytes: 9924
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);

        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();

        ArrayList<Integer> list = new ArrayList<>();

        list.add(a);
        list.add(b);
        list.add(c);

        Collections.sort(list);

        for (int l = 0; l < list.size(); l++) {
            if (l == 0) {
                System.out.printf("%d", list.get(l));
            } else {
                System.out.printf(" %d", list.get(l));
            }
        }
        
        System.out.print("\n");

    }

}



Measured memory_bytes: 26324
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		int count = 0;
		for (int i = 0; i < n - 2; i++) {
			if ((l[i + 1] >= l[i] && l[i + 1] <= l[i + 2]) || (l[i + 1] >= l[i + 2] && l[i + 1] <= l[i])) {
				count++;
			}
			
		}
System.out.println(count);
	}
}


Measured memory_bytes: 23380
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 200005;
ll a[MAX];
vll G[MAX];
ll parent[MAX]={};
ll ord[MAX];

void bfs(ll n) {
	queue<ll> qu;
	qu.push(1);
	parent[1] = 1;
	ll cnt = 1;
	while (!qu.empty()) {
		ll cur = qu.front();
		qu.pop();
		ord[cnt] = cur;
		cnt++;
		REP(i, 0, SIZE(G[cur]) - 1) {
			ll next = G[cur][i];
			if (parent[next] != 0)continue;
			parent[next] = cur;
			qu.push(next);
		}
	}
}

bool judge(ll i, ll n) {
	if (i != 1 && SIZE(G[i]) == 1) {
		return true;
	}
	ll c = 0;
	ll max_c = 0;
	REP(j, 0, SIZE(G[i]) - 1) {
		ll chi = G[i][j];
		if (chi != parent[i]) {
			c += a[chi];
			max_c = max(max_c, a[chi]);
		}
	}
	ll s, t;
	s = c - a[i];
	t = a[i] - s;
	if (s < 0 || t < 0) return false;
	if (s > min(c - max_c, c / 2)) return false;
	a[i] = t;
	return true;
}

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
	}
	REP(i, 1, n - 1) {
		ll x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	ll orig = a[1];
	bfs(n);
	PER(i, n, 1) {
		ll cur = ord[i];
		if (!judge(cur, n)) {
			cout << "NO" << endl;
			return 0;
		}
	}	
	if (a[1] == 0 && G[1].size() != 1) {
		cout << "YES" << endl;
	}
	else if (a[1] == orig && G[1].size() == 1) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int ans = n + (n * n) + (n * n * n);
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

char get_value(const vector<string> &grid, int i, int j, int a, int b) {
  int n = grid.size();
  int row = i + a;
  if (row >= n) row -= n;

  int col = j + b;
  if (col >= n) col -= n;

  return grid[row][col];
}

int main() { IO;
  int n;
  cin >> n;

  vector<string> grid(n);
  for (auto &line : grid) cin >> line;
  map<pair<int,int>, int> dp;

  int ans = 0;
  for (int a = 0; a < n; ++a) {
    for (int b = 0; b < n; ++b) {
      int mx = max(a, b);
      if (dp.count({a - mx, b - mx}) == 0) {
        int is_good = 1;
        for (int i = 0; is_good and i < n; ++i) {
          for (int j = i; is_good and j < n; ++j) {
            if (get_value(grid, i, j, a, b) != get_value(grid, j, i, a, b)) {
              is_good = 0;
            }
          }
        }
        dp[{a - mx, b - mx}] = is_good;
      }

      ans += dp[{a - mx, b - mx}];
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a * b % 2 == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


vector<vector<int>> w;
vector<vector<int>> z;


void f(int n, int k, int now, int cnt, vector<int> v) {
	if (now == n)return;
	f(n, k, now + 1, cnt, v);
	vector<int> a = v;
	a.push_back(now);
	if (cnt + 1 == k) {
		w.push_back(a);
		return;
	}
	f(n, k, now + 1, cnt + 1, a);
}

void ff(int n, int k, int now, int cnt, vector<int> v) {
	if (now == n)return;
	ff(n, k, now + 1, cnt, v);
	vector<int> a = v;
	a.push_back(now);
	if (cnt + 1 == k) {
		z.push_back(a);
		return;
	}
	ff(n, k, now + 1, cnt + 1, a);
}



int main() {

	int h, ww, k;
	cin >> h >> ww >> k;
	
	VVB b(h, VB(ww, false));
	int cnt = 0;
	REP(i, h)REP(j, ww) {
		char c;
		cin >> c;
		if (c == '#'){
			b[i][j] = true;
			cnt++;
		}
	}
	int ans = 0;
	//if (cnt == k)ans++;

	REP(i, h + 1) {
		f(h, i, 0, 0, {});
	}

	
	REP(i, ww + 1) {
		ff(ww, i, 0, 0, {});
	}



	w.push_back({});
	z.push_back({});

	REP(i, w.size()) {
		REP(j, z.size()) {
			VVB bb = b;
			int aa = cnt;
			for (int ii : w[i]) {
				REP(k, ww) {
					if (bb[ii][k]) {
						bb[ii][k] = false;
						aa--;
					}
				}
			}
			for (int jj : z[j]) {
				REP(k, h) {
					if (bb[k][jj]) {
						bb[k][jj] = false;
						aa--;
					}
				}
			}
			if (aa == k)ans++;
		}

	}
	cout << ans << endl;

}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int k, n;
  cin >> k >> n;
  int a[n];
  vector<int> dists(n);
  int ans = 0;

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (i > 0)
    {
      dists[i - 1] = a[i] - a[i - 1];
    }
  }
  dists[n - 1] = k - a[n - 1] + a[0];

  vector<int>::iterator iter = max_element(dists.begin(), dists.end());
  int index = distance(dists.begin(), iter);
  if (index == n - 1)
  {
    for (int i = index - 1; i >= 0; i--)
    {
      ans += dists[i];
    }
  }
  else
  {
    for (int i = 0; i < index; i++)
    {
      ans += dists[i];
    }

    for (int i = index + 1; i < n; i++)
    {
      ans += dists[i];
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  regex code("\\d{"+to_string(a)+"}-\\d{"+to_string(b)+"}");
  if(regex_match(s,code)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val X = nextInt()
    val y500 = X / 500
    val y5 = (X - y500 * 500) / 5
    val ans = 1000L * y500 + 5L * y5
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)


Measured memory_bytes: 33744
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(seq[int(input()) - 1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  ul k;
  cin >> s >> k;
  k--;
  for (ul i=0; i<s.size(); ++i) {
    if (i==k) {
      cout << s[i] << endl;
      return 0;
    }
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin >> p[i];
    int count = 0;
    for(int i=1;i<n-1;i++){
        if((p[i-1] < p[i] && p[i] <= p[i+1]) || (p[i-1] >= p[i] && p[i] > p[i+1])) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	double HP_taka, ATK_taka, HP_aoki, ATK_aoki;
	cin >> HP_taka >> ATK_taka >> HP_aoki >> ATK_aoki;

	int count_taka = ceil(HP_taka / ATK_aoki);
	int count_aoki = ceil(HP_aoki / ATK_taka);
	if (count_taka < count_aoki) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, k, q;
	int tmp;
	cin >> n >> k >> q;
	vector<int> answ(n, 0);
	for ( int i = 0 ; i < q ; i++ ){
		cin >> tmp;
		answ[tmp-1]++;
	}
	ll sum = 0;
	for ( auto i : answ ) {
		sum += i;
	}
	for ( int i = 0 ; i < n ; i++ ){
		if ( sum - answ[i] >= k )
			cout << "No" << "\n";
		else
			cout << "Yes" << "\n";
	}

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int a, b;
	cin >> a >> b;
	PRI(max(max(a + b, a - b), a * b));
	return 0;
}

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

const int N = 1e5+7;
char A[N];
bool ans[N];

int n;

void print() {
    for( int i = 0; i < n; ++i ) {
        if( ans[i] ) {
            putchar( 'S' );
        } else {
            putchar( 'W' );
        }
    }
    puts( "" );
}

bool solve() {
    for( int i = 1; i < n-1; ++i ) {

        if( ans[i] ) {
            if( A[i] == 'o' ) {
                ans[i+1] = ans[i-1];
            } else {
                ans[i+1] = !ans[i-1];
            }
        } else {
            if( A[i] == 'o' ) {
                ans[i+1] = !ans[i-1];
            } else {
                ans[i+1] = ans[i-1];
            }
        }
    }

    if( ans[n-1] ) {
        if( A[n-1] == 'o' ) {
            if( ans[n-2] != ans[0] ) {
                return false;
            }
        } else {
            if( ans[n-2] == ans[0] ) {
                return false;
            }
        }
    } else {
        if( A[n-1] == 'o' ) {
            if( ans[n-2] == ans[0] ) {
                return false;
            }
        } else {
            if( ans[n-2] != ans[0] ) {
                return false;
            }
        }
    }

    if( ans[0] ) {
        if( A[0] == 'o' ) {
            if( ans[n-1] != ans[1] ) {
                return false;
            }
        } else {
            if( ans[n-1] == ans[1] ) {
                return false;
            }
        }
    } else {
        if( A[0] == 'o' ) {
            if( ans[n-1] == ans[1] ) {
                return false;
            }
        } else {
            if( ans[n-1] != ans[1] ) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    scanf( "%d", &n );
    scanf( "%s", A );

    ans[0] = 0;
    ans[1] = 1;
    if( solve() ) {
        print();
        return 0;
    }

    ans[0] = 0;
    ans[1] = 0;
    if( solve() ) {
        print();
        return 0;
    }

    ans[0] = 1;
    ans[1] = 1;
    if( solve() ) {
        print();
        return 0;
    }

    ans[0] = 1;
    ans[1] = 0;
    if( solve() ) {
        print();
        return 0;
    }

    puts( "-1" );
    return 0;
}


Measured memory_bytes: 512
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
a_moji=str(a)
b_moji=str(b)
c_moji=str(c)
d_moji=str(d)
e_moji=str(e)

a1=int(a_moji[-1])
a1_moji=str(a1)
if a1==0:
    a1=10
a_kiriage=a+10-a1

b1=int(b_moji[-1])
b1_moji=str(b1)
if b1==0:
    b1=10
b_kiriage=b+10-b1

c1=int(c_moji[-1])
c1_moji=str(c1)
if c1==0:
    c1=10
c_kiriage=c+10-c1

d1=int(d_moji[-1])
d1_moji=str(d1)
if d1==0:
    d1=10
d_kiriage=d+10-d1

e1=int(e_moji[-1])
e1_moji=str(e1)
if e1==0:
    e1=10
e_kiriage=e+10-e1

k=10
if k>a1:
    k=a1
if k>b1:
    k=b1
if k>c1:
    k=c1
if k>d1:
    k=d1
if k>e1:
    k=e1
goke=a_kiriage+b_kiriage+c_kiriage+d_kiriage+e_kiriage+k-10
print(goke)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		int k;
		cin >> k;
		int n = s.size();
		int i =0 ;
		while(i < n && k){
			int c = s[i]-'a';
			if(c){
				if( k >=26-c){
					s[i]='a';
					k-=(26-c);
				}
			}
			i++;
		}
		s[n-1] = (char)( 'a'+( (s[n-1]-'a' +k)%26));
		cout << s << endl;
	
	}
	
	return 0;
}


Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define INF (1000000000000000000L)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long L, R;
  scanf("%ld %ld", &L, &R);

  // solve
  long ans = INF;
  for (long i = L; i < min(R, L + 2019); i++) {
    for (long j = i + 1; j <= min(R, i + 2019); j++) {
      ans = min(ans, i * j % 2019L);
    }
  }
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
while (n = gets.chomp.to_i) != 0
  pa,pb = [0, 0]
  n.times do
    a,b = gets.chomp.split.map(&:to_i)
    if a > b
      pa += a + b
    elsif a == b
      pa += a
      pb += b
    elsif a < b
      pb += a + b
    end
  end
  puts "#{pa} #{pb}"
end

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

using namespace std;

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

    int a,b,c;
    cin>>a>>b>>c;

    if(c>=a && c<=b)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, std::vector<long long> A)
{

  int MAXN = 1100000;
  vector<int> field(MAXN);
  for (auto a : A)
    field[a]++;

  LL ans = 0;
  for (int i = 1; i < MAXN; i++)
  {
    if (field[i] > 0)
    {
      if (field[i] == 1)
        ans += field[i];
    }
    for (int j = 2; i * j < MAXN; j++)
    {
      if (field[i] > 0)
        field[i * j] = -1;
    }
  }
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  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));
  return 0;
}


Measured memory_bytes: 9024
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n, s;

ll digitSum(ll n, ll b) {
  if (n == 0) return 0;
  return digitSum(n/b, b) + n%b;
}

int main() {
  cin >> n >> s;

  if (n == s) {
    cout << n+1 << endl;
    return 0;
  }

  ll r = sqrt(n);
  for (int b = 2; b <= r; ++b) {
    if (digitSum(n,b) == s) {
      cout << b << endl;
      return 0;
    }
  }

  vector<ll> bases;
  for (int p = 1; p <= r; ++p) {
    ll b = (n-s)/p + 1;
    if (b > 1) {
      if (digitSum(n, b) == s) {
        bases.push_back(b);
      }
    }
  }

  if (bases.size() == 0) {
    cout << -1 << endl;
  } else {
    sort(all(bases));
    cout << bases[0] << endl;
  }

  return 0;
}


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

int main(){
  int amount=700;
  string s;
  cin >> s;
  if(s[0]=='o')
    amount+=100;
  if(s[1]=='o')
    amount+=100;
  if(s[2]=='o')
    amount+=100;
  
  cout << amount << endl;

}

Measured memory_bytes: 3612
suits, cards = ['S', 'H', 'C', 'D'], [[i for i in range(1,14)] for j in range(4)]
n = int(input())
for i in range(n):
    s, i = input().split()
    cards[suits.index(s)].remove(int(i))
for si in range(4):
    for i in cards[si]:
        print('%s %d' %(suits[si], i))

Measured memory_bytes: 7696
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    BigInteger x = new BigInteger(sc.next());
    BigInteger n = new BigInteger("360");
    BigInteger gcd = x.gcd(n);
    System.out.println(n.divide(gcd));
  }
}


Measured memory_bytes: 27144
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long e, f, g, h;
	e = max(a, b);
	f = min(a, b);
	g = max(c, d);
	h = min(c, d);
	long long ans,l;
	ans = max(e*g, e*h);
	l = max(f*g, f*h);
	ans = ans > l ? ans : l;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int count;
  for(int i=A; i<=B; i++){
    int c, d, c1, c2, d1, d2;
    c=i/1000;
    d=i%100;
    c1=c/10;
    c2=c%10;
    d1=d/10;
    d2=d%10;
    if(c1==d2 & c2==d1){
      count++;
    }
  }
  cout << count << endl;
  
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for(int i = 1; i <= n; i++){
            if(i % 3 == 0 || i % 5 == 0){
                continue;
            }
            ans += i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27192
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt())
  val d = a.distinct.length
  val ans = if ((a.length - d) % 2 == 0) d else d-1
  println(ans)
}


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

int main() {
  int n,ans=1;
  cin>>n;
  vector<string> s;

  rep(i,0,n){
    string tmp;
    cin>>tmp;
    s.emplace_back(tmp);
  }
  sort(s.begin(),s.end());
  if(n==1){cout<<ans<<endl;return 0;}
  rep(i,1,n){
    //cout<<s[i]<<endl;
    if(s[i-1]!=s[i]){ans++;}
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 11664
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

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

/*   *   *   *   *   *   *   *   *   *   *   */

ll n;
ll h[100010];
ll dp[100010];

ll rec(ll i){
    if(dp[i] < INF) return dp[i];
    if(i == 0) return 0;
    ll res = INF;
    chmin(res, rec(i-1)+abs(h[i]-h[i-1]));
    if(i > 1) chmin(res, rec(i-2)+abs(h[i]-h[i-2]));
    return dp[i] = res;
}

void solve() {
    cin >> n;
    rep(i, 0, n) cin >> h[i];
    rep(i, 0, n) dp[i] = INF;
    cout << rec(n-1) << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int partition(int *A,int p,int r)
{
	int x,j,temp;

	x = A[r];
	j = p-1;

	for(int i = p; i < r; i++)
	{
		if (A[i] <= x)
		{
			j++;
			temp = A[j];
			A[j] = A[i];
			A[i] = temp;
		}
	}

	temp = A[j+1];
	A[j+1] = A[r];
	A[r] = temp;

	return j+1;
}

int main()
{
	int n,a[100000] = {0};
	int q;

	scanf("%d", &n);

	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	q = partition(a,0,n-1);

	for(int i = 0; i < n; i++)
	{
		if (i == q)
		{
			printf("[%d] ", a[i]);
		}else if (i == n-1)
		{
			printf("%d\n", a[i]);
		}else
		{
			printf("%d ", a[i]);
		}
	}

	return 0;
}
	

Measured memory_bytes: 3600
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: x,k,d,n

    read*, x,k,d
    x = abs(x)

    if (x/d >= k) then
        print*, x-k*d
    else
        n = x/d
        if (mod(n,2_8) == mod(k,2_8)) then
            print*, mod(x,d)
        else
            print*, -(mod(x,d)-d)
        end if
    end if
end program main

Measured memory_bytes: 2928
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        long long int syain,kakaku,kosuu,syains[5000]={0};
        long long int bango[5000]={0},flag[5000]={0};
        bool flag2=0;
        for(int i=0;i<n;i++){
            cin>>syain>>kakaku>>kosuu;
            bango[i]=syain;
            syains[syain]+=kakaku*kosuu;
        }
        for(int i=0;i<5000;i++){
            if(syains[bango[i]]>=1000000){
                if(flag[bango[i]]==0){
                        cout<<bango[i]<<endl;
                        flag[bango[i]]=1;
                }
            }
        }
        for(int i=0;i<5000;i++){
            if(flag[i]==1)flag2=1;
        }
    if(flag2==0)cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
 
using namespace std;
 
int main() {
 
    int N;
 
    cin >> N;
 
    set<int> S;
 
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
 
        if (S.find(t) == S.end()) {
            S.insert(t);
        } else {
            S.erase(S.find(t));
        }
    }
 
    cout << S.size() << endl;
 
    return 0;
}

Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
class Program
{
	//static long[,] dp;
	//static	Dictionary<string, long> dp;
	//static int[] weight, value;
    //static List<string> str = new List<string>();
	static int INT_MAX = 1000000007;
	static void Main(string[] args)
	{
			// 入力フェーズ
			//int N = Int32.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' '); // H,W
			int H = Int32.Parse(input[0]);
			int W = Int32.Parse(input[1]);

			string[] grid = new string[H];
			for(int i=0; i<H; i++)
			{
					grid[i] = Console.ReadLine();
			}

			int[,] dp = new int[H+1,W+1];
			dp[0,1] = 1; // 初期値→dp[1,1] = 1になる
			for(int i=0; i<H; i++)
			{
				for(int j=0; j<W; j++)
				{
					// dp[i+1, j+1] には上から＋左からの経路数 壁なら０
					if(grid[i][j] == '#')
						dp[i+1, j+1] = 0;
					else
						dp[i+1, j+1] = (dp[i,j+1] + dp[i+1,j])%INT_MAX;
				}
			}

			Console.WriteLine(dp[H,W] + "");
    }
}


Measured memory_bytes: 20828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
  ll n;
  cin >> n;
  ll test = n;
  vl primes;
  for (ll prime = 2; prime <= sqrt(n);prime++){
    if(test%prime==0){
      primes.pb(prime);
    //  ll tmp = test / prime;
     // if(tmp%prime!=0)primes.pb(tmp);
      while (test % prime == 0){
        test /= prime;
      }
    }
  }
//  for(auto i:primes)cout<<i<<" ";
  //cout<<endl;
  if(test!=1)primes.pb(test);
  ll m = sz(primes);
  
  ll res = 0;
  for (ll bit = 1; bit < (1 << m);bit++){
    ll k = 1;
    for (ll i = 0; i < m;i++){
      if(bit&(1<<i)){
        k *= primes[i];
      }
    }
    ll num = __builtin_popcountll(bit);
    if(num%2==1)res += n / k;
    else res -= n / k;
  }
  print(n-res);
}


Measured memory_bytes: 3168
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let n = io.read::<usize>();
    let a = io.readn::<usize>(n);
    let mut sowa = 0f64;

    for &x in a.iter() {
        sowa += 1.0f64 / x as f64;
    }
    io.writeln(1f64 / sowa);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2200
from sys import stdin, stdout
import sys
INF=1e9
import bisect
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
#from collections import defaultdict 
#for _ in range(int(stdin.readline())):
x,n=get_ints()
p=get_array()
if n==0:
    print(x)
else:
    diff1=INF
    ans=0
    for i in range(-101,102):
        if i not in p:
            diff=abs(i-x)
            if diff<diff1:
                diff1=diff
                ans=i
    print(ans)



Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(),x.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n,0);
  rep(i,n) cin >> a.at(i);

  bool flag = false;
  rep(i,n) {
    if(a.at(i)%2==0 and (a.at(i)%3!=0 and a.at(i)%5!=0)) flag = true;
  }
  if(flag) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int a,b,c,k;
        cin>>a>>b>>c>>k;
        int ans = min(a,k);
        k-=min(a,k);
        k-=min(b,k);
        ans-=min(c,k);
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(){
	int No1 = 0; 
	int No2 = 0; 
	int No3 = 0; 
	int No4 = 0;
	int Solns = 0;
	int Sum = 0;
	
	while(scanf("%d", &Sum) != EOF) {
		Solns = 0;
		for (No1 = 0; No1 < 10; No1++) {
			for (No2 = 0; No2 < 10; No2++) {
				for (No3 = 0; No3 < 10; No3++) {
					for (No4 = 0; No4 < 10; No4++) {
						if (No1 + No2 + No3 + No4 == Sum) {
							Solns++;
						}
					}
				}
			}
		}
		printf("%d\n", Solns);
	}
	return 0;
}

Measured memory_bytes: 596