akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Iterator;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int A = NM[0];
		int B = NM[1];
		double H = NM[2];
		double M = NM[3];
		
		double degH = H/12+M/(60*12);
		double degM = M/60;
		
		double theta = Math.abs(degH-degM)*2*Math.PI;
		print(Math.sqrt(A*A+B*B-2*A*B*Math.cos(theta)));
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static long[] readLineLong(){
		try{
			String[] s = readLine();
			long[] ints = new long[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Long.parseLong(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 33292
N=gets.to_i
S=gets.chomp

stack = []

S.each_char do |c|
    if c == '('
        stack << c
    elsif stack[-1] == '('
        stack.pop
    else
        stack << ')'
    end
end

puts '(' * stack.count(')') + S + ')' * stack.count('(')

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef string s;
typedef int i;

map<string, int> mp;

int main() {
    i x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

const ll MOD = (ll) 1e9 + 7;

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

    map<int, ll> mp;
    for (int i = 0; i < n; ++i) {
        ++mp[s[i] - 'a'];
    }

    ll ans = 1;
    for (auto i : mp) {
        (ans *= (i.second + 1)) %= MOD;
    }

    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<utility>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;
using ll = long long;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

const long long MOD = 1e9+7;
const long long MAX = 3e5+1;

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

    ll A, B, C, K;
    in(A); in(B); in(C); in(K);
    ll ans = min(A, K);
    if (K <= A) {
        ans = K;
    }
    else {
        K -= A;
        if (K <= B) ans = A;
        else {
            K -= B;
            ans = A - K;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {

  public static void Main (string[] args) {
    //var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    var S = Console.ReadLine();
    var N = S.Length;
    var ans = "No";
    if(S.SequenceEqual(S.Reverse()) && S.Substring(0, (N - 1) / 2).SequenceEqual(S.Substring(0, (N - 1) / 2).Reverse()) && S.Substring(((N + 3) / 2) - 1).SequenceEqual(S.Substring(((N + 3) / 2) - 1).Reverse())){
      ans = "Yes";
    }
    
   
    Console.WriteLine(ans);
 
  }
  
}

Measured memory_bytes: 13268
program ABC_059_B_Comparison
   implicit none
   character(100) A, B
   read(*, *) A, B
   if(A == B) then 
      write(*, *)'EQUAL'
   else if(len_trim(A) > len_trim(B)) then
      write(*, *)'GREATER'
   else if(len_trim(A) < len_trim(B)) then
      write(*, *)'LESS'
   else if(LGE(A, B) .eqv. .TRUE.) then
      write(*, *)'GREATER'
   else
      write(*, *)'LESS'
   end if
end program ABC_059_B_Comparison

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
struct mint{
	ull v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(ull vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/* mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
    }*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
//aの逆元求めるならn=mod-2

int main(){
  init();
  int x,y;
   cin>>x>>y;  
   ll n=2*y-x,m=2*x-y;
   if(n<0||m<0||n%3!=0||m%3!=0)cout<<0<<endl;
   else cout<<COM((n+m)/3,n/3)<<endl;
}



Measured memory_bytes: 47104
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5+100;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+9;
const ll p = 29;

bool check(ll n,ll k){
    while(n%k==0){
        n/=k;
    }
    n%=k;
    return n==1;
}


int main(){
    FASTIO;
    PRECISION; 

    ll n;
    cin>>n;

    if(n==2){
        cout<<1<<"\n";
        return 0;
    }

    set<ll>ans;

    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            if(check(n,i)){
                ans.insert(i);
            }

            if(check(n,n/i)){
                ans.insert(n/i);
            }
        }
    }
    ans.insert(n);
    n--;

    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ans.insert(i);
            ans.insert(n/i);
        }
    }
    ans.insert(n);

    cout<<ans.size()<<"\n";


    
 
}

Measured memory_bytes: 256
from fractions import gcd
nums = [int(x) for x in input().split()]

def ngcd(nums):
	d = 0
	for num in nums:
		d = gcd(d,num)
	return d


t = ngcd(nums)
if t != 1:
	nums = [int(num / t) for num in nums]

t = gcd(nums[0],nums[1])
if t == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 5588
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e5;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18 + 10;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans;
}
/*

*/

Measured memory_bytes: 3644
#include<iostream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

#define N 104
#define C 53
#define INF 1000000007
#define rep(i, n) for(int i=0; i<n; ++i)
#define min(a,b) (a>b?b:a)

struct Edge {
	int to, cost;
};

typedef pair<int, int> P;
typedef pair<int, P> IP;

typedef vector<Edge> Graph;

Graph g[N];

int dist[N][C];
int n, c;
int dijkstra(int s, int t) {
	priority_queue<IP, vector<IP>, greater<IP> > q;
	rep(i, n) rep(j, c+2) dist[i][j] = INF;
	dist[s][0] = 0;
	q.push(IP(0, P(s, 0)));
	while(!q.empty()) {
		int cost = q.top().first, u = q.top().second.first;
		int p = q.top().second.second; q.pop();
		if(dist[u][p] < cost) continue;
		rep(i, g[u].size()) {
			Edge &e = g[u][i];
			if(dist[u][p] + e.cost < dist[e.to][p]) {
				dist[e.to][p] = dist[u][p] + e.cost;
				q.push(IP(dist[e.to][p], P(e.to, p)));
			}
			if(p < c && dist[u][p] + (e.cost / 2) < dist[e.to][p+1]) {
				dist[e.to][p+1] = dist[u][p] + (e.cost / 2);
				q.push(IP(dist[e.to][p+1], P(e.to, p+1)));
			}
		}
	}
	int ans = INF;
	rep(i, c+1) ans = min(ans, dist[t][i]);
	return ans;
}


int main() {
	int m, s, d;
	while(cin >> c >> n >> m >> s >> d && c && n && m && s && d) {
		--s; --d;
		rep(i, n) g[i].clear();
		rep(i, m) {
			int a, b, f;
			cin >> a >> b >> f; --a; --b;
			g[a].push_back((Edge){b, f});
			g[b].push_back((Edge){a, f});
		}
		cout << dijkstra(s, d) << endl;
	}
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"

int32_t main()
{
     IOS;

     int a[6]={0};
     for(int i=1;i<=3;i++)
     {
          int x,y;
          cin>>x>>y;
          a[x]++;
          a[y]++;
     }
     int c1=0,c2=0;
     for(int i=1;i<=4;i++)
     {
          if(a[i]==1)
               c1++;
          else
               c2++;
     }
     if(c1==2 && c2==2)
          cout<<"YES";
     else
          cout<<"NO";
     return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
INF=1e18
ans=1
f=0
for a in A:
    if ans*a>INF:
        f=1
        break
    ans*=a
if f==0:
    print(ans)
else:
    print(-1)

    

Measured memory_bytes: 21700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int y = Integer.parseInt(s[1]);
        int maxX = y / 10000;
        boolean success = false;
out:
        for (int X = 0; X <= maxX; X++) {
            int rest = y - X * 10000;
            int minY = 0;
            if (X + rest / 1000 > n) {
                minY = (rest - (n - X) * 1000) / 5000;
            }
            int maxY = (y - X * 10000) / 5000;
            for (int Y = minY; Y <= maxY; Y++) {
                int Z = (y - X * 10000 - Y * 5000) / 1000;
                if (y == X * 10000 + Y * 5000 + Z * 1000) {
                    if (n == X + Y + Z) {
                        System.out.println(X + " " + Y + " " + Z);
                        success = true;
                        break out;
                    }
                }
            }
        }
        if (!success) {
            System.out.println("-1 -1 -1");
        }
        scanner.close();
    }
}


Measured memory_bytes: 27112
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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 main(){
	int x; cin >> x;
	if(x == 1){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
}

Measured memory_bytes: 3632
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();

		for(int i = 0; i < q; i++) {
			int query = sc.nextInt();
			String key = sc.next();

			if(query == 0) {  //insert
				int x = sc.nextInt();
				map.put(key, x);
			}
			else {  //get
				System.out.println(map.get(key));
			}
		}
	}

}



Measured memory_bytes: 194560
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ctr= [0 for _ in range(N)]

A.sort()
B.sort()
C.sort()

ans = 0

for i in range(N):
	insert_index_A = bisect.bisect_left(A, B[i])
	insert_index_C = N - bisect.bisect_right(C, B[i])
	ans += insert_index_A * insert_index_C
	
print(ans)

Measured memory_bytes: 108772
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int a,b,c;

  cin>>a>>b>>c;
  if(a%2==0 || b%2==0 || c%2==0){
    cout<<"0"<<endl;
    return 0;
  }

  if(a<b){
    if(b<c)//c
      cout<<(ll)a*b<<endl;
    else//b
      cout<<(ll)a*c<<endl;
  }else{
    if(a<c)//c
      cout<<(ll)a*b<<endl;
    else//a
      cout<<(ll)b*c<<endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll k,n;
ll v1[200010],v2[200010];
ll v0;
int main() {
    cin >> n >> k;
    ll a = 0, b = 0;
    for (int i = 0; i < n; i++) {
        ll num;
        cin >> num;
        if (num > 0) v1[a++] = num;
        else if (num < 0) v2[b++] = num;
        else v0++;
    }
    if (k + v0 > n) {
        cout << 0 << endl;
        return 0;
    }
    sort(v1, v1+a);
    sort(v2, v2+b);
    //even -> greater than 0
    vector<ll> v3;
    for (int i = 0; i + 1 < b; i += 2) {
        v3.push_back(v2[i] * v2[i+1]);
    }
    ll tmp = k;
    ll p1 = a-1;
    ll p3 = 0;
    ll ans1 = 1;
    while (tmp > 0) {
        if (tmp >= 2 && (p1 >= 1 || p3 < v3.size())) {
            if (p1 >= 1 && p3 < v3.size()) {
                if (v1[p1] * v1[p1-1] > v3[p3]) {
                    ans1 *= v1[p1] * v1[p1-1] % mod;
                    ans1 %= mod;
                    p1 -= 2;
                } else {
                    ans1 *= v3[p3] % mod;
                    ans1 %= mod;
                    p3++;
                }
                tmp -= 2;
            } else if (p1 >= 1) {
                ans1 *= v1[p1] * v1[p1-1] % mod;
                ans1 %= mod;
                p1 -= 2;
                tmp -= 2;
            } else if (p3 < v3.size()) {
                ans1 *= v3[p3] % mod;
                ans1 %= mod;
                p3++;
                tmp -= 2;
            }
        } else {
            if (p1 >= 0) {
                ans1 *= v1[p1];
                ans1 %= mod;
                p1--;
                tmp--;
            } else {
                break;
            }
        }
    }
    if (tmp == 0) {
        cout << ans1 << endl;
        return 0;
    }

    //equal to 0
    if (v0 != 0) {
        cout << 0 << endl;
        return 0;
    }

    //odd -> less than 0
    // for (int i = 0; i < v1.size(); i++) {
    //     cout << v1[i] << " ";
    // }
    // cout << endl;
    // for (int i = 0; i < v2.size(); i++) {
    //     cout << v2[i] << " ";
    // }
    // cout << endl;
    ll ans2 = (v2[b-1] + mod * mod) % mod;
    for (int i = 0; i < b - 1; i++) {
        v1[a++] = -v2[i];
    }
    sort(v1, v1+a);
    for (int i = 0; i < k-1; i++) {
        ans2 *= v1[i];
        ans2 %= mod;
    }
    cout << ans2 << endl;
    return 0;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

int dp[333][333][333];
string s;
int k;

int dfs(int K,int L,int R)
{
//	cout << K << ' ' << L << ' ' << R << endl;
	if(K < 0)return -100000000;
	if(L > R)return 0;
	if(dp[K][L][R] != 0)return dp[K][L][R];
	int ret = 0;
	if(s[L] == s[R])ret = max(ret,dfs(K,L+1,R-1)+2);
	else ret = max(ret,dfs(K-1,L+1,R-1)+2);
	ret = max(ret,dfs(K,L+1,R));
	ret = max(ret,dfs(K,L,R-1));
	
	return dp[K][L][R] = ret;
}


int main()
{
	cin >> s >> k;
	
	REP(K,333)REP(i,333)dp[K][i][i] = 1;
	REP(K,333)REP(i,s.size()-1)
	{
		if(s[i] == s[i+1])dp[K][i][i+1] = 2;
		else dp[K][i][i+1] = 1;
		if(K > 0)dp[K][i][i+1] = 2;
	}
	
	cout << dfs(k,0,s.size()-1) << endl;
	
	return 0;
}


Measured memory_bytes: 144512
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    string s;
    ll x;
    cin>>x;
    ll xx=x/500;
    ll ans=0;
    ans=xx*1000;
    ans+=((x%500)/5)*5;
    cout<<ans<<endl;
}






Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static String[] s;
    public static void main(String[] args) {
        while(hantei()){
            bun();
        }
    }
    static boolean hantei(){
        if(sc.hasNext()){
            s = sc.nextLine().split(" ");    
            return true;
        }
        return false;
    }
    
    static void bun(){
        boolean f = false;
        for(int k = 0; k < 26; k++){
            for(int i = 0; i < s.length; i++){
                char[] tango = s[i].toCharArray();
                for(int j = 0; j < tango.length; j++){
                    if (tango[j] != '.') {
                        tango[j] = (char)((tango[j] - 'a' + 1)%26 +'a');
                        }
                }
                s[i] = new String(tango);
                if(s[i].equals("the") || s[i].equals("this") || s[i].equals("that")){
                    f = true;
                }
            }
            if(f){
                break;
            }
        }
        for(int i = 0; i < s.length-1; i++){
            System.out.print(s[i] + " ");
        }
        System.out.println(s[s.length-1]);
    }
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int n; cin >> n;
	vector<string> S(n);
	REP(i,n) cin >> S[i];

	REP(i,26){
		int min_value = 100;
		REP(j,n){
			int cnt = 0;
			REP(k,S[j].length()){
				char c = 'a' + i;
				if(c == S[j][k]) cnt++;
			}
			min_value = min(min_value, cnt);
		}
		REP(j,min_value) cout << (char)('a' + i);
	}
	cout << endl;




	return 0;

}


Measured memory_bytes: 256
function main(input) {
   input = input.trim();
  const replaced = 
        input.replace(/1/g, 'a').replace(/9/g, 'b').replace(/a/g, '9').replace(/b/g, '1')
  console.log(replaced);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);
		//ArrayList <Integer> list = new ArrayList <Integer>();
		int Rmin = Integer.MAX_VALUE;
		int Lmax = Integer.MIN_VALUE;
		for (int i = 0; i < M; i++) {
			line = reader.readLine();
			String[] LR = line.split(" ");
			int L = Integer.parseInt(LR[0]);
			int R = Integer.parseInt(LR[1]);
			if (L > Lmax) {
				Lmax = L;;
			}
			if  (R < Rmin) {
				Rmin = R;;
			}
		}
		if (Rmin >= Lmax) {
			System.out.println(Rmin - Lmax + 1);
		}
		else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 45348
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,sum=0;
    while(cin>>n)
    {
        long long int p=0,x;
        vector<long long int>v,u;
        long long int c=1000000007;
        for(i=0; i<n; i++)
        {
           cin>>x;
           v.push_back(x);
        }
        for(i=n-1;i>=0;i--)
        {
            sum=sum+v[i];
            u.push_back(sum);
        }
        reverse(u.begin(),u.end());
        long long int ans=0;
        for(i=0;i<n;i++)
        {
            p=u[i]-v[i];
            ans= ((ans%c)+(((p%c)*(v[i]%c))%c))%c;
        }
        cout<<ans%c<<endl;
    }
}


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

namespace ALDS1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToList();
            mergeSort(S, 0, S.Count(),ref count);
            Console.WriteLine(String.Join(" ", S));
            Console.WriteLine(count);
        }

        public static void mergeSort(List<int> A,int left, int right,ref int count)
        {
            if(left + 1 < right)
            {
                int mid = (left + right) / 2;
                mergeSort(A, left, mid,ref count);
                mergeSort(A, mid, right,ref count);
                merge(A, left, mid, right,ref count);
            }
        }

        public static void merge(List<int> A, int left, int mid, int right,ref int count)
        {
            int n1 = mid - left;
            int n2 = right - mid;

            var L = new List<int>();
            var R = new List<int>();

            for(int i = 0; i < n1; i++)
            {
                L.Add(A[left + i]);
            }
            for(int i = 0; i < n2; i++)
            {
                R.Add(A[mid + i]);
            }
            L.Add(1000000001);
            R.Add(1000000001);
            int l = 0;
            int r = 0;
            for(int k = left; k < right; k++)
            {
                if(L[l] <= R[r])
                {
                    A[k] = L[l];
                    l++;
                }
                else
                {
                    A[k] = R[r];
                    r++;
                }
                count++;
            }
        }
    }
}



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

using namespace std;
#define ll               long long
#define dl               double
#define ull              unsigned long long
#define ft               first
#define sd               second
#define pi               acos(-1)
#define ct(tc)           scanf("%lld",&tc)
#define scnm(n,m)        scanf("%lld %lld",&n,&m);
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(a,max(b,max(c,d)))
#define min3(a,b,c)      min(a,min(b,c))
#define min4(a,b,c,d)    min(a,min(b,min(c,d)))
#define pb               push_back
#define srt              sort(v.begin(),v.end())
#define rsrt             reverse(v.begin(),v.end())
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    char s[6];
    cin>>s;
    if((s[2]==s[3])&&(s[4]==s[5]))
    {
        printf("Yes\n");
    }

    else
    {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        h: i32,
        w: i32,
        a: i32,
        b: i32,
    }
    puts!("{}\n", h * w - (h / a) * (w / b) * a * b);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define max_n 200001


int main(void){
    ll n,k; cin >> n >> k;
    vector<ll>num(max_n,0);
    for(int i=0;i<n;i++){
        ll tmp; cin >> tmp;
        num[tmp]++;
    }
    sort(num.rbegin(),num.rend());
    cout << n-accumulate(num.begin(),num.begin()+k,0) << endl;
    return 0;
}

Measured memory_bytes: 1920
def sorts(*arr)
	arr.each do |i|
		i.each do |j|
			x = j[0]
			y = j[1]
			if (x < y)
				puts sprintf("%d %d", x, y)
			else
				puts sprintf("%d %d", y, x)
			end
		end
	end
end

input_arr = []
while input = gets
	x, y = input.split(' ').map(&:to_i)
	break if (x == 0 && y == 0)
	arr = [x, y]
	input_arr << arr
end

sorts(input_arr)

Measured memory_bytes: 8804
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		for(;;){
			int a = sc.nextInt(),b=sc.nextInt();
			if(a+b==0)break;
			int[][]dp = new int[a+2][b+2];
			int n = sc.nextInt();
			for(int i=0;i<n;i++){
				int x = sc.nextInt()-1;
				int y = sc.nextInt()-1;
				dp[x][y]=-1;
			}
			dp[0][0]=1;
			for(int i=0;i<a;i++){
				for(int j=0;j<b;j++){
					if(dp[i][j]==-1)continue;
					if(dp[i+1][j]!=-1)
						dp[i+1][j]+=dp[i][j];
					if(dp[i][j+1]!=-1)
						dp[i][j+1]+=dp[i][j];
				}
			}
			System.out.println(dp[a-1][b-1]);
		}

	}
}

Measured memory_bytes: 20224
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = A; i <= min(A + K - 1, B); i++)cout << i << endl;
	for (int i = max(A + K , B - K + 1); i <= B; i++)cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NIL -1
long long int min(long long int a, long long int b){
	if(a<b)
		return a;
	else
		return b;
}
int main(){
long long int n,k;
  cin>>n>>k;
 long long int ans[n];
 long long int a[n];
  for(int i=0;i<n;i++){
  cin>>a[i];
  }
   ans[1]=abs(a[0]-a[1]);
   ans[0]=0;
  for(int i=2;i<n;i++){
  	 long long int min=1000000000;
     int j =i-1;
     long long int count =k;
     while(count!=0 && j>=0)
    {
    	long long int s  = ans[j]+abs(a[i]-a[j]);
    	if(min>s)
    		min=s;
    	count--;
    	j--;
    }
    ans[i]=min;
   // cout<<min<<" ";
  }
  cout<<ans[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ff(i,s,n) for(int i=s;i<n;i++)
#define fr(i,s,n) for(int i=n-1;i>=s;i--)
#define llu long long int
const int mod=1000000007;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> v(n);
	
	ff(i,0,n)	cin>>v[i];
	
	llu ans=0;
	llu x=0;
	
	ff(i,0,n){
		ans=(ans+(v[i]*x)%mod)%mod;
		x=(x+v[i])%mod;
	}
	cout<<ans;
}

//1
//7 2
//3 5 4 5 1 1 1


Measured memory_bytes: 3964
#include <stdio.h>
 
int main(void)
{
    unsigned long long b1, b2;
    unsigned long long fib;
    int n;
    int i;
 
    scanf("%d", &n);
    b1 = b2 = fib = 1;
    for (i = 2; i <= n; i++){
        fib = b1 + b2;
        b1 = b2;
        b2 = fib;
    }
 
    printf("%llu\n", fib);
 
    return (0);
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(void){
  int K = 0;
  string S;
  cin >> K;
  cin >> S;
  string adding = "...";
  
  if(S.length() <= K ){
  	cout << S << endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S[i];
    }
    cout << adding << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(){

  int w,h,x,y,r;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
 
  if (0+r <= x && x <= w-r && 0+r <= y && y <= h-r) {
    printf("Yes\n");
  } else {
  printf("No\n");
  }
 
  return 0;
}



Measured memory_bytes: 2144
/* Trico */
#include <iostream>
#include <bits/stdc++.h>
#define inf 1e18
#define ll long long
#define x first
#define y second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mll map<ll, ll>
#define mii map<int, int>
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define p push
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k, s = 1, ans = 0;
    pll a[100001];
    a[0] = {0, 0};
    string t;
    cin>>n>>k>>t;
    for(int i = 0;t[i];i++){
        int temp = 1;
        while(t[i+1] == t[i]) i++, temp++;
        a[s] = {temp, t[i] - '0'};
        s++;
    }
    a[s] = {0, 0};
    s++;
    //cout<<s<<' ';
    for(int i = 1;i<s;i++) a[i].x += a[i-1].x;
    for(int i = 1;i<s-1;i++){
        int l = i-1, r = min(i+2*k-1, s-1);
        ll temp = 0;
        temp = a[r].x - a[l].x;
        if(a[r].y == 0 && r < s-1) temp += a[r+1].x - a[r].x;
        if(a[l+1].y == 0 && l > 0) temp += a[l].x - a[l-1].x;
        ans = max(ans, temp);
    }
    cout<<ans;
} 

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    if(accumulate(a.begin(), a.end(), 0) >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include<cmath>
//#include <numeric>
//#include <iomanip>

using namespace std;


constexpr auto BASE = 2019;


class atcalc {

public:
	static int add(int a, int b)
	{
		return (int)(((long long)a + b) % BASE);
	}
	static int times(int a, int b)
	{
		return (int)(((long long)a * b) % BASE);
	}
	static int div(int a, int b)
	{
		return (int)(((long long)a * atcalc::modinv(b, BASE)) % BASE);
	}

	static int comb(int a, int b)
	{
		if (a < b) { return 0; }
		if (b > a / 2) { b = a - b; }
		if (b == 0) { return 1; }


		int ans = 1;
		for (int i = 0; i < b; i++) {
			ans = atcalc::times(ans, a - i);
		}
		for (int i = 0; i < b; i++) {
			ans = atcalc::div(ans, i + 1);
		}


		return ans;
	}

	static int modinv(int a, int m)
	{

		long long x = 0, y = 1, gcd = m;
		long long  px = 1, py = 0, pgcd = a;
		long long temp = 0;

		while (gcd > 0)
		{
			long long quotient = pgcd / gcd;

			temp = x;
			x = px - quotient * temp;
			px = temp;

			temp = y;
			y = py - quotient * temp;
			py = temp;

			temp = gcd;
			gcd = pgcd - quotient * temp;
			pgcd = temp;
		}

		while (px < 0) {
			px += BASE;
		}
		return (int)px;
	}
};


int A, B;



int main()
{

	cin >> A;
	cin >> B;

	int ans = 0;

	if (B > 1) {
		ans = (B - 2) / (A - 1) + 1;
	}
	else {
		ans = 0;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>

using namespace std;

long long N;
int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.length()-1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			cout << "Yes";
			return  0;
		}

	}
	cout << "No";
	return 0;



	return 0;
}


Measured memory_bytes: 256
/* ex4_3 Stone Monument
    dada__              */
#include<stdio.h>
int depth(int height_a, int height_b); //プロトタイプ宣言

int main(void){
    int height_a, height_b, ans;

    scanf("%d %d", &height_a, &height_b); //入力
    ans = depth(height_a, height_b);
    printf("%d", ans); //出力
    
    return 0;
}

//depth関数の定義
int depth(int height_a, int height_b){
    int height_dif, ans;
    
    height_dif = height_b - height_a; //塔の高さの差の算出
    ans = height_dif*(height_dif+1)/2 - height_b; //雪の深さの算出
    return(ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[N];
ll pre[N];
int main()
{
       int n,k;
       cin>>n>>k;
       int a[n];
       arrin(a,n);
       memset(dp,0,sizeof dp);
       memset(pre,0,sizeof pre);
       fri(i,0,a[0]+1){dp[i] = 1;}
       fri(i,1,n)
       {
              pre[0] = dp[0];
              fri(j,1,k+1)
              {
                     pre[j] = pre[j-1]+dp[j];
                     pre[j] %= mod;
              }
              for(ll j = k ; j >= 1 ; j--)
              {
                     ll add = 0;
                     dp[j] = pre[j];
                     if(j>a[i])dp[j] += (mod-pre[j-a[i]-1]);
                     dp[j] %= mod;
                     //cout<<j<<" "<<dp[j]<<endl;
              }
       }
       cout<<dp[k]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while(t--){
		int n, k;
		cin >> n >> k;
		int a[n];
		for (int i = 0; i < n; ++i)
		{
			cin >> a[i];
		}
		sort(a, a + n);
		int ans = 0;
		for (int i = 0; i < k; ++i)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

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

char grade(int m, int f, int r)
{
    if (m == -1 || f == -1) {
        return 'F';
    }

    if (m + f >= 80) {
        return 'A';
    }

    if (m + f >= 65) {
        return 'B';
    }

    if (m + f >= 50) {
        return 'C';
    }

    if (m + f >= 30) {
        return r >= 50 ? 'C' : 'D';
    }

    return 'F';
}

int main()
{
    int m, f, r;

    while ((cin >> m >> f >> r), !(m == -1 && f == -1 && r == -1)) {
        cout << grade(m, f, r) << endl;
    }

    return 0;
}

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

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

    bool y = 0;
    for (int i = 1; i < 10; i++)
        if (((n / i) * i == n) && ((n / i) < 10))
            y = 1;
    cout << ((y) ? "Yes" : "No");
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int W = sc.nextInt();
		
		int [] w = new int [N];
		int [] v = new int [N];
		
		for (int i=0; i<N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		
		long [] dp = new long [W+1];
		
		for (int i=0; i<N; i++) 
			for (int j=W; j>=0; j--) 
				if (j - w[i] >= 0) 
					dp[j] = Math.max(dp[j], dp[j - w[i]] + v[i]);
		
		System.out.println(dp[W]);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,k,n) for(ll i=(k);i<(ll)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
 
using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
constexpr ll MOD = 998244353;

ll pm(ll x,ll i) {
  if(i==0)return 1;
  if(i%2) return x*pm(x,i-1)%MOD;
  ll h=pm(x,i/2);
  return h*h%MOD;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,s;
  cin>>n>>s;
  ll inv2 = (MOD + 1) / 2;
  vecll dp(s+1, 0);
  dp[0] = pm(2, n);
  REP(i,n) {
    vecll nx = dp;
    int a;
    cin>>a;
    REP(j,s+1) {
      if (j+a > s) break;
      nx[j+a] += dp[j] * inv2 % MOD;
      nx[j+a] %= MOD;
    }
    swap(nx, dp);
  }
  cout<<dp[s]<<endl;
  return 0;
}


Measured memory_bytes: 3704
S = input()
l = len(S)
ans = 0
for i in range(1<<(l-1)):
  l1 = l
  for j in range(l):
    if j ==l-1:
      ans += int(S[0:l1])
    elif (i>>j)&1:
      ans+=int(S[l-j-1:l1])
      l1 =l - j-1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (u == s) a--;
    else b--;
    cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256