akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	ll n, h, w, a, b, ans = 0;
	cin >> n >> h >> w;
	rep (i, n) {
		cin >> a >> b;
		if (a >= h && b >= w)
			ans++;
	}
	cout << ans << endl;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  string s;cin>>s;
  ll k;cin>>k;
  ll cnt=0;
  bool flag=false;
  while(s[cnt]=='1'){
    //cout<<cnt<<endl;
    if(cnt+1==k){flag=true;cout<<1<<endl;break;}
    cnt++;
  }
  if(flag==false)cout<<s[cnt]<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ans = 1
INF = 10 ** 9 + 7
if abs(N - M) > 1:
  print(0)
else:
  for i in range(1, min(N, M) + 1):
    ans = (ans * (i ** 2)) % INF
  if N == M:
    print((ans * 2) % INF)
  else:
    ans = (ans * max(N, M)) % INF
    print(ans)


Measured memory_bytes: 38896
s=int(input())
x1=0
y1=0
x2=10**9
y2=1
y3=s//(10**9)
x3=s%(10**9)
if x3!=0:
    y3+=1
    x3=x2-x3
print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
using namespace std;
int try1(int array[][5], int a, int b ,int len);
int max(int a, int b);
void sort(int array[][5], int len, int key);
int try2(int array[][5], int a , int b, int H, int len);
int main()
{
    int x, y, len, H;
    int array[100][5];
    scanf("%d", &len);
    for(int iter = 0;iter < len; iter++)
    {
        scanf("%d%d%d",&array[iter][0], &array[iter][1], &array[iter][2]);
    }
    for(x = 0; x <= 100;x++)
    {
        for(y = 0; y <= 100; y++)
        {
            H = try1(array, x, y, len);
            if((H >= 1)&&try2(array, x, y, H, len))
                break;
        }
        if(y != 101)
            break;
    }
    printf("%d %d %d", x, y, H);
}
int try1(int array[][5], int a, int b ,int len)
{
    int iter, i;
    for(iter = 0; iter < len; iter ++)
    {
        if(array[iter][2] == 0)//取max取出来的
        {
            array[iter][3] = -1;
            array[iter][4] = abs(array[iter][0] - a) + abs(array[iter][1] - b) +array[iter][2];
            continue;
        }
        else
            array[iter][3] = abs(array[iter][0] - a) + abs(array[iter][1] - b) +array[iter][2];
    }
    sort(array, len ,3);
    for(iter = 0; iter < len-1;iter++)
    {
        if((array[iter][3] == -1)||(array[iter+1][3] == -1))
            continue;
        else
            if(array[iter][3]!=array[iter+1][3])
                return -1;
    }
    if(array[len-1][3]!=-1)
        return array[len-1][3];
    else//全部取0
        sort(array, len, 4);
    return array[0][4];
}
void sort(int array[][5],int len, int key)
{
    int temp[5];
    int iter = 0;
    for(;iter < len-1;iter ++)
    {
        for(int j = 0;j < len -1 - iter;j++)
            if(array[j][key] >array[j+1][key])
            {
                temp[0] = array[j][0];
                temp[1] = array[j][1];
                temp[2] = array[j][2];
                temp[3] = array[j][3];
                temp[4] = array[j][4];
                array[j][0] = array[j+1][0];
                array[j][1] = array[j+1][1];
                array[j][2] = array[j+1][2];
                array[j][3] = array[j+1][3];
                array[j][4] = array[j+1][4];
                array[j+1][0]=temp[0];
                array[j+1][1]=temp[1];
                array[j+1][2]=temp[2];
                array[j+1][3]=temp[3];
                array[j+1][4]=temp[4];
            }
    }
}
int try2(int array[][5], int a , int b, int H, int len)
{
    for(int i = 0;i< len; i++)
    if(max(H-abs(a-array[i][0])-abs(b-array[i][1]),0) != array[i][2])
        return 0;
    return 1;
}
int max(int a, int b)
{
    return (a>b)?a:b;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;} cout << endl;
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, x;
    cin >> n >> x;
    vi a(n + 1);
    rep(i, n) cin >> a[i];

    vi b = a;
    rep2(i, 1, n + 1) {
        if (a[i - 1] > x) {
            a[i] = 0;
            a[i - 1] = min(a[i - 1], x);
        } else if (a[i - 1] + a[i] > x) {
            a[i] = max(0ll, x - a[i - 1]);
        }
    }

    int ans = 0;
    rep(i, n + 1) {
        ans += b[i] - a[i];
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
	if(x<1200) cout << "ABC" << endl;
	else cout << "ARC" << endl; 
    
	return 0;
}


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

typedef pair<int, int> P;

const int MAX_N = 101;
const int MAX_DMG = 200001;
const int INF = 1<<24;
int N;
int HP[MAX_N];
vector<P> vs, va;

int Ts[MAX_DMG];
int Ta[MAX_DMG];

int solve() {
  Ts[0] = Ta[0] = 0;
  for(int d = 1; d < MAX_DMG; ++d) {
    Ts[d] = Ta[d] = INF;
    for(int i = 0; i < vs.size(); ++i) {
      int t = max(0, d-vs[i].first);
      Ts[d] = min(Ts[d], Ts[t] + vs[i].second);
    }
    for(int i = 0; i < va.size(); ++i) {
      int t = d-va[i].first;
      if(t < 0) continue;
      Ta[d] = min(Ta[d], Ta[t] + va[i].second);
    }
  }

  int ans = INF;
  for(int d = 0; d < MAX_DMG; ++d) {
    if(Ta[d] == INF) continue;
    int res = Ta[d];
    for(int i = 0; i < N; ++i) {
      int hp = max(0, HP[i] - d);
      res += Ts[hp];
    }
    ans = min(ans, res);
  }
  return ans;
}

int main() {
  while(cin >> N && N) {
    vs.clear();
    va.clear();
    for(int i = 0; i < N; ++i) {
      cin >> HP[i];
    }
    int m;
    bool costZero = false;
    cin >> m;
    for(int i = 0; i < m; ++i) {
      string name, target;
      int mp, d;
      cin >> name >> mp >> target >> d;
      P p(min(100000, d), mp);
      if(p.first == 0) continue;
      if(mp == 0) costZero = true;
      if(target == "Single") vs.push_back(p);
      else va.push_back(p);
    }
    if(costZero) cout << 0 << endl;
    else cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);

    int n;
    cin >> n;
    function<void(string, char)> dfs = [&](string s, char d){
        if(s.size() == n){
            cout << s << '\n';
        }else{
            for(char c = 'a'; c <= d; ++c){
                if(c == d){
                    dfs(s+c, static_cast<char>(d+1));
                }else{
                    dfs(s+c, d);
                }
            }
        }
    };
    dfs("", 'a');
    
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int n,k,a[1<<17];
main()
{
	cin>>n>>k;
	int j;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==1)j=i;
	}
	int cnt=0;
	int f=j,l=j;
	while(f>0)
	{
		cnt++;
		f-=k-1;
		if(f<0)l+=-f,f=0;
	}
	while(l<n-1)
	{
		cnt++;
		l+=k-1;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
/**
 *  author: mahfuzz
 *  created: 23.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n; cin >> n;
    
    cout << (n + 1) / 2 << "\n";
    
        
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp
K = gets.to_i

subs = []
n = s.size
s.chars.each_with_index.sort.each do |c, i|
  next if subs.size == K && c > subs.last
  j = [i + K - 1, n - 1].min
  subs = (subs + (i..j).map { |k| s[i..k] }).uniq.sort.take(K)
end

puts subs.last


Measured memory_bytes: 2936
#include<stdio.h>

#define MAX 200000

int Max(int x, int y);
int Min(int x, int y);

int main(void) {
  long A[MAX];
  int n;
  long minv, maxv;
  scanf("%d", &n);

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

  minv = A[0];
  maxv = A[1] - A[0];
  for(int j=1; j<=n-1; ++j) {
    maxv = Max(maxv, A[j] - minv);
    minv = Min(minv, A[j]);
  }

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

  return 0;
}

int Max(int x, int y) {
  return x > y ? x : y;
}

int Min(int x, int y) {
  return x < y ? x : y;
}



Measured memory_bytes: 3384
import sys

fin = sys.stdin.readline
N, M = [int(elem) for elem in fin().split()]
conditions = [tuple(int(elem) for elem in fin().split()) for _ in range(M)]

l_list = [x[0] for x in conditions]
r_list = [x[1] for x in conditions]

print(max(0, min(r_list) - max(l_list) + 1))


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

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

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

pub trait LexicalPermutation {
  /// Return `true` if the slice was permuted, `false` if it is already
  /// at the last ordered permutation.
  fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
  /// Original author in Rust: Thomas Backman <serenity@exscape.org>
  fn next_permutation(&mut self) -> bool {
    // These cases only have 1 permutation each, so we can't do anything.
    if self.len() < 2 { return false; }

    // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
    let mut i = self.len() - 1;
    while i > 0 && self[i-1] >= self[i] {
      i -= 1;
    }

    // If that is the entire vector, this is the last-ordered permutation.
    if i == 0 {
      return false;
    }

    // Step 2: Find the rightmost element larger than the pivot (i-1)
    let mut j = self.len() - 1;
    while j >= i && self[j] <= self[i-1]  {
      j -= 1;
    }

    // Step 3: Swap that element with the pivot
    self.swap(j, i-1);

    // Step 4: Reverse the (previously) weakly decreasing part
    self[i..].reverse();

    true
  }
}
fn main() {
  let n: usize = read();
  let mut d: Vec<usize> = read_vec();

  d.sort_by(|a, b| a.cmp(b));

  if n % 2 != 0 {
    println!("0");
  } else {
    let center = n / 2;
    let ans = d[center] - d[center-1];
    println!("{}", ans);
  }
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string S; cin >>S;
  if(S.size()==1){
    cout<<0<<endl;
    return 0;
  }
  int count0=0;
  int count1=0;
  rep(i,S.size()){
    if(S[i]=='0')count0++;
    else count1++;
  }
  int kotae=min(count0,count1)*2;
  cout <<kotae<<endl;
  return 0;
}

Measured memory_bytes: 512
//AtCoder ABC049 B - たてなが / Thin
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int H,W;
    cin>>H>>W;
    vector<string> ctbl(H);
    for(auto&&c:ctbl){
        cin>>c;
    }
    for(const auto&c:ctbl){
        cout<<c<<endl;
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
from math import sqrt, pi
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    r = I()
    print(2 * r * pi)


if __name__ == "__main__":
    main()


Measured memory_bytes: 65232
from collections import defaultdict
start = defaultdict(lambda: -1)
goal = defaultdict(lambda: -1)
for s, t in zip(input(), input()):
    if start[s] != -1 or goal[t] != -1:
        if start[s] != t or goal[t] != s:
            print('No')
            exit()
    start[s], goal[t] = t, s
print('Yes')

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string
//string→int   int num = atoi(numStr.c_str());

int main() {
    double a,b,ans;cin>>a>>b;
    ans=a/b;
    cout<<ans<<endl;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	while(true){
		int n,x; cin>>n>>x;
		if(n==x && n==0)return 0;
		int ans=0;
		rep(i,1,n-1){
			rep(j,i+1,n){
				rep(k,j+1,n+1){
					if(i+j+k==x){
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, k, v[200002];
int main() {
    DAU
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
    }
    for (int i = 1; i <= n - k; ++i)
        if (v[i] < v[i+k])
            cout << "Yes\n";
        else cout << "No\n";
    PLEC

}


Measured memory_bytes: 4436
#include<stdio.h>


int main(void){
int x,y;int cnt=0;
scanf("%d %d",&x,&y);

if(x==0&&y==0)printf("%d\n",cnt%3+1);cnt++;
if(x==1&&y==0)printf("%d\n",cnt%3+1);cnt++;

int f[100];
for(int i=0;i<45;i++)f[i]=0;
f[0]=1;f[1]=1;
for(int i=2;i<45;i++)f[i]=f[i-2]+f[i-1];

int x0=1,y0=0;
int z0=2,w0=1;

for(int i=2;i<40;i++){
	if(i%4==1){
	x0=x0+f[i-1];y0=y0;z0=z0+f[i];w0=w0+f[i-2];	
	}else if(i%4==2){
	x0=x0-f[i-2];y0=w0;z0=z0;w0=w0+f[i];
	}else if(i%4==3){
	x0=x0-f[i];y0=y0-f[i-2];z0=x0+f[i];w0=w0;	
	}else if(i%4==0){
	x0=x0;y0=y0-f[i];z0=x0+f[i];w0=w0-f[i-1];	
	}
	if(x>=x0 && x<x0+f[i] && y>=y0 && y<y0+f[i]){
		printf("%d\n",cnt%3+1);
//		printf("x0=%d y0=%d f=%d %d\n",x0,y0,f[i],cnt%3+1);
	}
	cnt++;
}

return 0;
}



Measured memory_bytes: 2108
N = int(input())
S = input()
alphabets = ['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']
new_string = ''

for s in S:
    new_string += (alphabets[(alphabets.index(s) + N) % 26])

print(new_string)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    // C - Vacation
    public static int vacation(int[][] points) {
        int n = points.length;
        int[][] dp = new int[n][3];
        dp[0][0] = points[0][0];
        dp[0][1] = points[0][1];
        dp[0][2] = points[0][2];

        for (int i = 1; i < n; i++) {
            dp[i][0] = points[i][0] + Math.max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = points[i][1] + Math.max(dp[i-1][0], dp[i-1][2]);
            dp[i][2] = points[i][2] + Math.max(dp[i-1][0], dp[i-1][1]);
        }

        return Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2]));
    }

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

        int[][] arr = new int[N][3];
        for (int i = 0; i < N; i++) {
            arr[i][0] = in.nextInt();
            arr[i][1] = in.nextInt();
            arr[i][2] = in.nextInt();
        }
        in.close();

        // call function hear
        int ret = vacation(arr);
        System.out.println(ret);
    }
}

Measured memory_bytes: 100520
#include <stdio.h>
#include <string.h>

#define ll long long

const ll mod = 1e9 + 7;

ll triples[100005] = { 1LL, };
char L[100005];
ll dp[100005];
int len;

ll get_dp(int idx)
{
	if (L[idx] == 0) return dp[idx] = 1;
	if (dp[idx] != -1) return dp[idx];

	if (L[idx] == '0') return dp[idx] = get_dp(idx + 1);
	dp[idx] = (2 * get_dp(idx + 1)) % mod;
	dp[idx] = (dp[idx] + triples[len - idx - 1]) % mod;
	return dp[idx];
}

int main()
{
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i < 100005; ++i) triples[i] = (3LL * triples[i - 1]) % mod;

	scanf("%s", L);
	len = strlen(L);

	printf("%lld\n", get_dp(0));

	return 0;
}

Measured memory_bytes: 4992
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] A = nextIntArray(sc, N);

		sc.close();

		Arrays.sort(A);

		double ans = 0;
		double tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp += 1.0 / A[i];
		}

		ans = 1.0 / tmp;

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23124
require 'prime'

Q = gets.to_i

list = Array.new(10 ** 5, 0)

cnt = 0

(1..10**5).each do |i|
  if i.prime? && ((i + 1) / 2).prime?
    cnt += 1
  end

  list[i] = cnt
end

Q.times do
  l, r = gets.chomp.split.map(&:to_i)

  puts list[r] - list[l-1]
end


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

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

int main() {
    int N;
    cin >> N;
    cout << N*(N + 1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
stack<char>q;
stack<char>p;
string s;



int main(){
	cin>>s;
int i=1;q.push(s[0]);
//SSSS ST ST ST TTTT
while(i<s.size())
{
   if(q.empty())q.push(s[i]),i++;
   if(q.top()=='S'&&s[i]=='T'&&!q.empty())
   {
     	q.pop();
     	i++;
   }
   else
   {
   	  q.push(s[i]);
   	  i++;
   }	 
}
cout<<q.size()<<endl;	
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<long> v;
    if (n==0)return 0;
	for(long i=0;i<n;i++){
            long a;
    cin >> a;
        v.push_back(a);
	}

	long m=v[0];
	long stool=0;
	for(long i=1;i<n;i++){
        if (v[i] <m){
            long sdif=m-v[i];
            stool=stool+sdif;
        }
        else if (v[i] > m){
            m=v[i];
        }
	}
	cout << stool;
    return 0;
}


Measured memory_bytes: 5248
// Created by sz
#include <bits/stdc++.h>
using namespace std;

long long  N, height[100005], dp[100005];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    for(int i = 1; i <= N; i++){
        cin>>height[i];
    }
    
    dp[1] = 0;
    dp[2] = abs(height[2] - height[1]);
    for(int i = 3; i<= N; i++){
        dp[i] = min(dp[i-1]+ abs(height[i] - height[i-1]), dp[i-2] + abs(height[i] - height[i-2]));
    }
    cout<<dp[N]<<endl;
    
    
    return 0;
}


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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    vector<vvi> rooms(4, vvi(3, vi(10)));
    int n; cin >> n;
    REP(i, n)
    {
        int b, f, r, v; cin >> b >> f >> r >> v;
        rooms[b-1][f-1][r-1] += v;
    }
    REP(i, 4)
    {
        if(i != 0) cout << "####################" << endl;
        REP(j, 3)
        {
            REP(k, 10)
            {
                cout << " " << rooms[i][j][k];
            }
            cout << endl;
        }
    }
}


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

#define MAX_N 100000

int a[MAX_N];
priority_queue <int> edge;

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    for (int i = 0; i < n;) {
        if (a[i] == a[i + 1]) {
            edge.push(a[i]);
            i += 2;
        }
        else i++;
    }
    int64_t ans = edge.size() >= 2;
    for (int i = 0; i < 2; i++) {
        if (edge.empty()) break;
        ans *= edge.top();
        edge.pop();
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  while(cin>>n,n){
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int b = 31;
  
    int i = 0;
    cout<<b<<endl;
    while(b-a[i]>0){
      b -= a[i];
      i=(i+1)%n;
      cout<<b<<endl;
      if(b-(b-1)%5<=0)break;
      b -= (b-1)%5;
      cout<<b<<endl;
    }
    cout<<0<<endl;
  }
}

Measured memory_bytes: 1192
'use strict'

function main(input) {
    let sum = 100;
    let count = 0;
    const x = Number(input.split('\n')[0].split(' ')[0]);
    while(sum<x) {
        sum = parseInt(sum*1.01);
        count++;
    }
    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30060
N, A, B = map( int, input().split())
hmax = 0
H = [ int( input()) for _ in range(N)]
hmax = max(H)
L = 0
R = hmax//B + 1
add = A-B
while L != R:
    now = (L+R)//2
    need = 0
    for i in range(N):
        r = H[i] - now*B
        if r > 0:
            need += (r-1)//add+1
    if need <= now:#うまくいくとき
        R = now
    else:#うまくいかないとき
        L = now+1#うまく行かないので+1している．これがないと無限ループが発生する。
print(L)

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

#define mod 1000000007

using namespace std;

vector <int> v[100010];

int main()
{
    int n,m,q;
    cin >> n >> m >> q;

    int x,y;

    for(int i=0;i<m;i++)
    {
        cin >> x >> y;

        v[x].push_back(y);
    }

    for(int i=1;i<=n;i++)
         sort(v[i].begin(),v[i].end());

    while(q--)
    {
        cin >> x >> y;

        int ans = 0;

        for(int i=x;i<=y;i++)
        {
            int temp = upper_bound(v[i].begin(),v[i].end(),y) - v[i].begin();

            ans += temp;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 4480
n=int(input())
a=list(map(int,input().split()))
ans=1
flag=True
zero=a.count(0)
if zero!=0:
    print(0)
    flag=False
else:
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            print(-1)
            flag=False
            break
if flag:
    print(ans)


Measured memory_bytes: 21788
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>
 
class Tree {
    public:
    struct Node {
        std::vector<int> edge;
        int rank;
        int direction;
    };
    std::vector<Node> node;
    Tree() {}
    Tree(const int node_num_max) {
        node.resize(node_num_max);
    }
    void add_directed_edge(const int from, const int to) {
        node[from].edge.push_back(to);
    }
    void add_undirected_edge(const int node1, const int node2) {
        add_directed_edge(node1, node2);
        add_directed_edge(node2, node1);
    }
    void set_rank(int n, int rank, int parent) { // 辺が有向でも無向でも使える。呼び出すとき、parentは-1にしておくとよい。
        node[n].rank = rank;
        for (int c : node[n].edge) {
            if (c != parent) {
                set_rank(c, rank + 1, n);
            }
        }
    }
};
 
const int MAX_SIZE = 100050;
int N, K, a[MAX_SIZE];
Tree tree = Tree(MAX_SIZE);
bool is_checked[MAX_SIZE];
 
void set_checked(int n) {
    if (is_checked[n]) {
        return;
    }
    is_checked[n] = true;
    for (int c : tree.node[n].edge) {
        set_checked(c);
    }
}
 
int main(int argc, char **argv) {
    std::cin >> N >> K;
 
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }
 
    int ret = 0;
 
    if (K == 1) {
        for (int i = 1; i <= N; i++) {
            if (a[i] != 1) {
                ret++;
            }
        }
        std::cout << ret << std::endl;
        return 0;
    }
 
    if (a[1] != 1) {
        a[1] = 1;
        ret++;
    }
    is_checked[1] = true;
 
    for (int i = 2; i <= N; i++) {
        tree.add_directed_edge(a[i], i);
        is_checked[i] = false;
    }
 
    tree.set_rank(1, 0, -1);
 
    std::vector<std::pair<int, int>> node_rank;
    for (int i = 2; i <= N; i++) {
        node_rank.push_back(std::pair<int, int>({i, tree.node[i].rank}));
    }
    std::sort(node_rank.begin(), node_rank.end(),
        [](const std::pair<int, int>& a, const std::pair<int, int>& b) { return a.second > b.second; }
    );
 
    for (auto pair : node_rank) {
        int i = pair.first;
        if (is_checked[i]) {
            continue;
        }
        if (pair.second <= K) {
            break;
        }
        int num = 0;
        while (true) {
            i = a[i];
            num++;
            if (num == K - 1) {
                break;
            }
        }
        a[i] = 1;
        ret++;
        set_checked(i);
    }
 
    std::cout << ret << std::endl;
 
    return 0;
}

Measured memory_bytes: 11128
import queue

def main():
    K = int(input())

    q = queue.Queue()
    for i in range(9):
        q.put(i+1)

    count = 0
    while True:
        count = count+1
        a = q.get()

        if count == K:
            break

        tail = int(str(a)[-1])
        for i in range(10):
            if abs(tail-i) > 1:
                continue
            q.put(int(str(a)+str(i)))

    print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 12768
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;

int findSumOfDigits(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

vector<string> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N, A, B;
    cin >> N >> A >> B;
    ll sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if(A <= findSumOfDigits(i) &&findSumOfDigits(i) <= B){
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
a = [int(input()) for i in range(N)]

i = 0
c = 0
while a[i] != 2:
    if a[i] == 0:
        c = -2
        break
    tmp = a[i]
    a[i] = 0
    i = tmp - 1
    c += 1
print(c + 1)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d, r, l;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (r > l) {
    cout << "Right" << endl;
  }
  else if (r < l) {
    cout << "Left" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  int n;
  R n;
  if(n%10==3) pr("bon");
  else if(n%10==0||n%10==1||n%10==6||n%10==8) pr("pon");
  else pr("hon");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;

int main() 
{   cin>>s;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]=='?')
			cout<<'D';
		else
			cout<<s[i]; 
	}
	cout<<endl;
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H1,M1,H2,M2,K;
	cin>>H1>>M1>>H2>>M2>>K;
	int t1=H1*60 + M1;
	int t2=H2*60 + M2;
	cout<<t2-t1-K<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1e9+7;
using namespace std;
using ll = long long;

int main() {
	int n, ans = 0;
	cin >> n;
	ans = n + n*n + n*n*n;
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    int m = n, sum=0;
    while(m){
        sum+=m%10;
        m/=10;
    }
    if (n%sum==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n,d;
	std::cin >> n >> d;

	std::cout << n / (2 * d + 1) + !!(n % (2 * d + 1)) << '\n';
	return 0;
}


Measured memory_bytes: 256
import Data.Char (digitToInt)

f :: [Int] -> Int -> Bool -> Int
f _ 0 _ = 1
f [] _ _ = 0
f (s:ss) k less
  | less = f ss k True + 9 * f ss (k - 1) True
  | s > 0 = f ss k True + (s - 1) * f ss (k - 1) True + f ss (k - 1) False
  | otherwise = f ss k False

main = do
    s <- map digitToInt <$> getLine :: IO [Int]
    k <- readLn :: IO Int
    print $ f s k False


Measured memory_bytes: 508
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;
int64_t R=1;
void solution(){
    int k=0,x=0,l,r;
    cin>>k>>x;k--;
    l=x-k;
    r=x+k;
    for(int i=l;i<=r;i++){cout<<i<<" ";}
}
int main()
{
    FOR(i,R){solution();}
    return 0;
}


Measured memory_bytes: 256
H,W,M = map(int,input().split(" "))

bomb = set()
RMAX = 0
CMAX = 0
rmax = []
cmax = []
row = [0]*(H+1)
col = [0]*(W+1)

for _ in range(M) :
    bi, bj = map(int,input().split(" "))
    bomb.add((bi,bj))
    row[bi]+=1
    if row[bi] > RMAX :
        RMAX = row[bi]
        rmax = [bi]
    elif row[bi] == RMAX:
        rmax.append(bi)
    
    col[bj] += 1
    if col[bj] > CMAX:
        CMAX = col[bj]
        cmax = [bj]
    elif col[bj] == CMAX:
        cmax.append(bj)



if M < len(cmax)*len(rmax):
    print(CMAX+RMAX)
else:
    res = CMAX+RMAX-1
    done = False
    for i in rmax :
        for j in cmax : 
            if (i,j) not in bomb:
                res+=1
                done = True
                break
            
        if done :
            break
    print(res)


Measured memory_bytes: 65192
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nm=(Arr.shift()).split(" ").map(Number);
   if(nm[0]==0 && nm[1]==0)break;
   var M=nm[1];
   var DP=[];
   for(var i=0;i<nm[0];i++){
      var dp=(Arr.shift()).split(" ").map(Number);
      DP.push(dp);
   }
   DP.sort(function(a,b){return b[1]-a[1]});
   var sum=0;
   DP.forEach(function(v){
      var d=v[0];
      var p=v[1];
      while(true){
         if(M==0 || d==0)break;
         M--;
         d--;
      }
      sum+=d*p;
   });
   console.log(sum);
}

Measured memory_bytes: 34656
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int m=1000001;
  int k;
  while(1){
    m=1000001;
    cin >> n;
    if(n==0)break;
    for(int i=0;i*i*i<=n;i++){
      if(n-i*i*i==0){
	m=min(m,i);
	continue;
      }
      for(int j=0;i*i*i+j*j<=n;j++){
	k=n-(i*i*i+j*j);
	//	cout << k << " "<< j <<" "<<i<< endl;
	m=min(m,i+j+k);
      }
    }    
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 3004
n = int(input())
R = [int(input()) for i in range(n)]

maxv = R[1] - R[0]
minv = R[0]

for j in range(1, n):
  if maxv < R[j] - minv:
    maxv = R[j] - minv
  
  if minv > R[j]:
    minv = R[j]

print(maxv)


Measured memory_bytes: 13596
N, M = map(int, input().split())
den_lists = []
for m in range(M):
    den_lists.append(list(map(int, input().split())))
p = list(map(int, input().split()))
count = 0

for i in range(2**N):
    s_list = []
    for j in range(N):
        if (i >> j) & 1:
            s_list.append(j+1)
    #print(f"s_list:{s_list}")     
    den_count = 0
    for m, den in enumerate(den_lists):
        tmp = 0
        for d in den[1:]:
            if d in s_list:
                tmp += 1# 繋がったスイッチのうち何個ついてるか
        #print(f"tmp:{tmp}")        
        if tmp % 2 == p[m]:
            #print(m)
            den_count += 1# 今のスイッチのon,offの組み合わせで全体の電球が何個ついてるか.
    #print(f"den_count:{den_count}")
        
    if den_count == len(den_lists):
        count += 1
        
    
    

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  #define FASTIO std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  using namespace std;
  #define endl '\n'
  #define deb cout<<"sab_badhiya"<<endl;
  typedef long long int ll;
  // const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
  const long INF = 1000 * 1000 * 1000 + 7;
  vector<pair<long, long>>v;
  long dp[105][100005];
  int main() {
    FASTIO
    long n, w, ans = 0;
    cin >> n >> w;
    v.resize(n + 1);
    for (int i = 0; i < 105; i++) {
      for (int j = 1; j < 100005; j++) {
        dp[i][j] = INF;
      }
    }
    for (int i = 1; i <= n; i++) {
      cin >> v[i].first >> v[i].second;
    }
    for (int i = 1; i <= n; i++) {
      dp[i][v[i].second] = v[i].first;
      for (long j = 1; j <= 100000; j++) {
        if (j > v[i].second) {
          dp[i][j] = min(dp[i][j], v[i].first + dp[i - 1][j - v[i].second]);
        }
        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        if (dp[i][j] <= w) {
          ans = max(ans, j);
        }
      }
    }
    cout << ans << endl;
  }


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

bool checkrock(int sta,int G,string S);
bool checkrock2(int B,int C,string S);
int main() {
    int N,A,B,C,D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    bool ans = true;
    if(C>D){
        ans = checkrock(A,C,S)&&checkrock2(B,D,S);
    }else
    {
        ans = checkrock(A,D,S);
    }
    string as = (ans)?"Yes":"No";
    cout << as << endl;
    
    return 0;
}
bool checkrock(int sta,int G,string S){
    bool flag=false,result=true;
    for(int i = sta;i<G-1;i++){
        if(S.at(i)=='#'){
            if(flag==true){
                result = false;
                break;
            }
            flag=true;
        }else
        {
            flag=false;
        }
        
    }
    return result;
}
bool checkrock2(int B,int D,string S){
    bool result = false;
    int interval = 0;
    for(int i = B-2;i<D+1;i++){
        if(S.at(i)=='.'){
            interval++;
        }else
        {
            interval=0;
        }
        if(interval>2){
            result=true;
            break;
        }
    }
    return result;
}

Measured memory_bytes: 900
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back



/* do your best */

int main() {
  
  lint n; cin >> n;
  vector<lint> a(n + 1, 0);
  for(int i = 0; i < n; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }

  map<lint, lint> mp;
  for(int i = 0; i <= n; i++) mp[a[i]]++;

  lint ans = 0;
  for(auto x : mp) {
    ans += x.second * (x.second - 1) / 2;
  }

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


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

namespace ABC096D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var primes = new List<long>();
            primes.Add(2);
            for(int i = 3; i <= 55555; i++)
            {
                if(IsPrime(primes, i))
                {
                    primes.Add(i);
                }
            }

            var correctPrimes = primes.Where(p => p % 5 == 1).ToArray();

            var result = correctPrimes.Take(n);

            foreach(var r in result)
            {
                Console.Write($"{r} ");
            }
        }

        private static bool IsPrime(IEnumerable<long> primes, long value)
        {
            foreach(var p in primes)
            {
                if (value % p == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}


Measured memory_bytes: 13464
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    cout << (v > w && (v - w) * t >= abs(a - b) ? "YES" : "NO") << endl;

return 0;
}


Measured memory_bytes: 3652
n = int(input())

t = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    x=i+1
    l = x % 10
    f = x
    while f // 10 > 0:
        f = f // 10
#    print("{}: {},{}".format(i,f,l))    
    t[f][l] = t[f][l] + 1

count = 0    
for i in range(10):
    for j in range(10):        
        count = count + t[i][j] * t[j][i]             

print("{}".format(count))


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
const int MAX_N = 100000;
const int INF = 1000000000;
int N, K;
int xs[MAX_N];

void solve() {
    int ans = INF;
    for (int i = 0; i < N - K + 1; ++i) {
        int x_min = xs[i], x_max = xs[i + K - 1];
        ans = min(ans, min(abs(x_min) + x_max - x_min, abs(x_max) + x_max - x_min));
    }
    printf("%d", ans);
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> xs[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 640
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

main = do
  getLine
  a <- map (\x -> (head x, length x)) . group . sort <$> getIntListBC
  print $ judge a

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntBC :: IO Int
getIntBC = bsToInt <$> BC.getLine

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

judge :: [(Int, Int)] -> Int
judge [] = 0
judge (x:xs)
  | fst x == snd x = judge xs
  | fst x < snd x  = (snd x - fst x) + judge xs
  | otherwise      = (snd x) + judge xs


Measured memory_bytes: 16764