akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    bool ans=0;
    for(ll i=0;i<s.size();i++){
        if(s==t)ans=1;
        s=s[s.size()-1]+s.substr(0,s.size()-1)
    ;}
    if(ans)print("Yes");
    else print("No");

    return 0;
}


Measured memory_bytes: 256
K = int(input())
A, B = map(int, input().split())


ps = int(A / K)
pa = A % K
qs = int(B / K)
qa = B % K

if A==B:
	if pa==0:
		print("OK")
	else:
		print("NG")
else:
	if qs-ps>0:
		print("OK")
	else:
		if pa==0 or qa ==0:
			print("OK")
		else:
			print("NG")

Measured memory_bytes: 9196
S = input()

size = len(S)
n = "".join("1" if i % 2 == 0 else "0" for i in range(size))

nc, mc = 0, 0
for i in range(size):
    if S[i] == n[i]:
        nc += 1
    else:
        mc += 1

print(min(nc, mc))


Measured memory_bytes: 4084
#include<stdio.h>

int main(void)
{
int a,b,c,i;
 
  scanf("%d",&a);scanf("%d",&b);
  
  for(i=0;i<b;i++){
     scanf("%d",&c);
  a-=c;
  }
  if(a<0)
    a=-1;
  printf("%d",a);
  
 return 0;
}

Measured memory_bytes: 1724
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

bool pchk[100050];

int sum[100050];
int main() {
	int i, j;
	pchk[1] = true;
	for (i = 2; i <= 100000; i++) {
		if (pchk[i]) continue;
		for (j = 2 * i; j <= 100000; j += i) pchk[j] = true;
	}
	for (i = 1; i <= 100000; i++) {
		sum[i] = sum[i - 1];
		if (!pchk[i] && !pchk[(i + 1) / 2]) sum[i]++;
	}

	int Q;
	scanf("%d", &Q);
	while (Q--) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		printf("%d\n", sum[t2] - sum[t1 - 1]);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

const int MOD = 1000000007;

int back[100000][26];

int main() {
    string s, t;
    cin >> s >> t;
    
    int sl = s.length();
    int tl = t.length();
    s = s + s;
    int last[26];
    rep(i, 26) {
        last[i] = -1;
    }
    for(int i = sl * 2 - 1; i >= 0; i--) {
        last[s[i] - 'a'] = i;
        if(i < sl) {
            rep(j, 26) {
                back[i][j] = last[j];
            }
        }
    }

    ll ans = -1;
    bool flag = true;
    rep(i, tl) {
        if(last[t[i] - 'a'] == -1) {
            flag = false;
            break;
        }
        ans++;
        ans = ans / sl * sl + back[ans % sl][t[i] - 'a'];
    }

    cout << (flag? (ans + 1) : -1) << endl;

    return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
}
int n,A,B,C,D;
void input()
{
	n=read<int>();
	A=read<int>(),B=read<int>();
	C=read<int>(),D=read<int>();
}
void work()
{
	For(i,0,n-1)
	{
		ll down=1ll*i*C-1ll*(n-i-1)*D;
		ll up=1ll*i*D-1ll*(n-i-1)*C;
		if(down<=B-A&&B-A<=up){puts("YES");return;}
	}
	puts("NO");
}
int main()
{
//	file();
	input();
	work();
	return 0;
}



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

template <typename T>
struct twodimBIT{
    private:
        vector<vector<T> > array;
        const int n;
        const int m;
    public:
        //初期化
        twodimBIT(int _n, int _m) : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

        // (1,1)から(x, y)までの累積和を求める
        T sum(int x, int y){
            T s = 0;
            for(int i = x; i > 0; i -= i & (-i))
                for(int j = y; j > 0; j -= j & (-j))
                    s += array[i][j];
            return s;
        }

        //[(x1, y1), (x2, y2)]の要素のわ
        T sum(int x1, int y1, int x2, int y2){
            return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1-1, y1-1);
        }

        //(x, y)に要素kを追加
        void add(int x, int y, T k){
            for(int i = x; i <= n; i+=i&(-i))
                for(int j = y; j <= m; j += j&(-j))
                    array[i][j] += k;
        }
};

int main(){
    int N, M, Q; cin >> N >> M >> Q;
    vector<pair<int, int>> Trn(M), Qst(Q);
    
    rep(i, M) cin >> Trn[i].first >> Trn[i].second;
    rep(i, Q) cin >> Qst[i].first >> Qst[i].second;

    twodimBIT<int> cnt(N,N);
    rep(i, M){
        cnt.add(Trn[i].first, Trn[i].second, 1);
    }

    rep(i, Q){
        cout << cnt.sum(Qst[i].first, Qst[i].first, Qst[i].second, Qst[i].second) << endl;
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int k,s;
    scanf("%d%d",&k,&s);
    int ans = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-(i+j)<=k && s-(i+j)>=0) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int n;
  cin >> n;
  unordered_map <int,int> mp;

  int tmp;
  REP(i,n){
    cin >> tmp;
    mp[tmp]++;
  }
  int ans = 0;
  for(auto itr = mp.begin();itr!=mp.end();itr++){
    int diff = itr->first - itr->second;
    if(diff > 0) ans+=itr->second;
    if(diff < 0) ans-=diff;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4260
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//141_A
		Scanner sc = new Scanner(System.in);
		String today = sc.next();
		String[] weather = new String[3];
		String ans ="";
		weather[0] = "Sunny";
		weather[1] = "Cloudy";
		weather[2] = "Rainy";

		if(today.equals(weather[0])) {
			ans = weather[1] ;
		} else if(today.equals(weather[1])) {
			ans = weather[2] ;
		} else if(today.equals(weather[2])) {
			ans = weather[0] ;
		}
		System.out.println(ans);
		// Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


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

/* #include<cstdio>*/
int main(){
	double r;
	cin >> r;
	double p;
	p = 3.141592653589;
	printf("%f %f\n", p*r*r, 2 * p*r);
	return 0; 
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d);
}

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



using namespace std;



int main()
{
    int x;
    cin>>x;
    int ans=1,karry;
    for(int i=1;i<32;i++)
    {
        for(int j=2;j<10;j++)
        {
            karry=pow(i,j);
            if((ans<karry) && (karry<=x))
            ans=karry;
        }
    } 
    cout<<ans<<endl;
    //system("pause");
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 2005
using namespace std;

typedef long long ll;
ll n, c, a[N];
int main()
{
	ll i, j, k;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		k = 0;
		for (j = i + 1; j < n; j++) {
			for (k = max(j + 1, k); k < n && a[i] + a[j] > a[k]; k++);
			c += k - j - 1;
		}
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

	public static void main(String args[])
	{

		int temp = 0;

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		for(int i = 0; i < x; i++)
		{
			temp += 2;

			if((i + 1) == x)
			{
				if(temp == y)
				{
					System.out.println("Yes");
				}else
				{

					for(int j = i; j >= 0; j--)
					{
						temp -=2;
						temp +=4;

						if(temp == y)
						{
							System.out.println("Yes");
							break;
						}

						if(j == 0)
						{
							System.out.println("No");
						}

					}
				}
			}

		}

	}

}


Measured memory_bytes: 27088
#include <iostream>
using namespace std;
long long d(long long n,long long p){ return p > n ? 0 : n/p + d(n/p,p);}
int main(){
	int n;
	long long ans = 1, mod = 1e9+7;
	cin >> n;
	bool p[3000] = {};
	for(int i = 2; i <= n; ++i) if(!p[i]){
		ans = ans*(d(n,i)+1)%mod;
		for(int j = 2*i; j <= n; j += i) p[j] = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,r;
int main(){
	cin>>n>>r;
	if(n>=10)
	{
		cout<<r<<endl;
	}
	else
	{
		cout<<r+100*(10-n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, i = 1;

    while (1) {
        cin >> x;
        if (x == 0) {
            break;
        } else {
            cout << "Case " << i++ << ": " << x << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3124
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    if a % 2 != b % 2 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (a + b) / 2);
    }
}


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

using namespace std;
typedef pair<int, int> pii;

int N, W;
vector<int> w(100), v(100);
map<pii, int> mp;

long long f(int i, int j) {
    if (mp[pii(i, j)]) return mp[pii(i, j)];
    
    int res;
    if (i == N) res = 0;
    else if (j < w[i]) res = f(i + 1, j);
    else res = max(f(i + 1, j), f(i + 1, j - w[i]) + v[i]);
    return mp[pii(i, j)] = res;
}

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        scanf("%d %d", &w[i], &v[i]);
    
    cout << f(0, W) << endl;

    return 0;
}

Measured memory_bytes: 6400
import java.util.*;
import java.awt.geom.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int a = 1000 - n;
			int count = 0;
			int [] table = {500, 100, 50, 10, 5,1};
			for(int i = 0; i < table.length; i++){
				while(table[i] <= a){
					a -= table[i];
					count++;
				}
			}
			System.out.println(count);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 17168
def c(a):
    global y,r,d
    for _ in range(y):a+=int(a*r)-d
    return a

def s(a):
    global y,r,d
    b=0
    for _ in range(y):
        b+=int(a*r)
        a-=d
    return a+b

for _ in range(int(input())):
    m=0
    a=int(input());y=int(input())
    for _ in range(int(input())):
        b,r,d=map(float,input().split())
        m=max(m,c(a) if b==1 else s(a))
    print(int(m))

Measured memory_bytes: 7640
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n; cin >> n;
	double sum = 0.0;
	rep(i, n){
		double a; cin >> a;
		sum += 1 / a;
	}
	double ans = 1 / sum;
	printf("%.9lf\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<tuple<string, int, int>> v(n);
  for(int i = 0; i < n; i++) {
    string s;
    int a;
    cin >> s >> a;
    v[i] = make_tuple(s, -a, i);
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++) {
    cout << get<2>(v[i]) + 1 << endl;
  }
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int a,b,k;cin>>a>>b>>k;
   FORR(i,min(a,b),1){
      if(a%i==0 && b%i==0){
         k--;
      }
      if(k == 0){
         cout << i;
         return 0;
      }
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define out2(x,y) cout<<x<<" : "<<y<<endl;
#define out(x) cout<<x<<endl;
#define in(x) int x;cin>>x;
#define in2(x,y) int x,y;cin>>x>>y;
#define in3(x,y,z) int x,y,z;cin>>x>>y>>z;


//Frog jump======================================================

//There are N stones, numbered 1 , 2 , … , N . For each i ( 1 ≤ i ≤ N ), the height of Stone i is h i .
//There is a frog who is initially on Stone 1 .
//He will repeat the following action some number of times to reach Stone N : If the frog is currently on Stone i , jump to Stone i + 1 or Stone i + 2 .
//Here, a cost of | h i − h j | is incurred, where j is the stone to land on.
//Find the minimum possible total cost incurred before the frog reaches Stone N .

int jump_cost(int n,int A[],int dp[])
{
    if(n==0){return 0;}
    if(n==1){return abs(A[1]-A[0]);}
    if(dp[n]!=-1){return dp[n];}

    int jump_1 = abs(A[n]-A[n-1]) + jump_cost(n-1,A,dp);
    //out2("jump1",jump_1);
    int jump_2 = abs(A[n]-A[n-2]) + jump_cost(n-2,A,dp);
    //out2("jump2",jump_2);

    dp[n]=min(jump_1,jump_2);
    return dp[n];
}

int32_t main()
{
    in(n);
    int A[n];
    int dp[n]={-1};

    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        dp[i]=-1;
    }

    out(jump_cost(n-1,A,dp));
   // for(int i=0;i<n;i++)
     //   out(dp[i]);
}


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

using namespace std;

int main(){
    int n, K;
    int h[100005];
    int dp[100005];

    cin >> n >> K;

    for(int i=1;i<=n;i++){
        cin >> h[i];
    }
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        int minc = 10000000000;
        for(int k=1;k<=K;k++){
            if(i-k <= 0) break;
            minc = min(minc,dp[i-k]+abs(h[i]-h[i-k]));
        }
        dp[i] = minc;
    }
    cout << dp[n] << "\n";

    return 0;
}


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

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int t = Integer.parseInt(sc.next());
    int num = n / x + 1;
    if (n % x == 0) {
      num--;
    }
    pw.println(num * t);
  }
}


Measured memory_bytes: 35528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

// 2020.07.22

int main() {
  int p, a; cin >> p >> a;

  cout << (p*3+a)/2 << endl;
}


Measured memory_bytes: 3576
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        switch (sc.nextInt()) {
        case 7:
        case 5:
        case 3:
            System.out.println("YES");
            break;

        default:
            System.out.println("NO");
            break;
        }
    }
}

Measured memory_bytes: 21716
import java.util.Scanner

import scala.collection.immutable

object Main extends App {

  def read(): (Int, immutable.IndexedSeq[Int]) = {
    val sc: Scanner = new Scanner(System.in)
    val n = sc.nextInt
    val arr = (1 to n).map { _ =>
      sc.nextInt
    }
    sc.close()
    (n, arr)
  }

  def solve(): String = {
    val (n, arr) = read()
    val arrAndIndex = arr.zipWithIndex.sortBy(- _._1)
    val ans = for(i <- 0 until arr.length) yield {
      if(arrAndIndex(0)._2 == i) arrAndIndex(1)._1
      else arrAndIndex(0)._1
    }
    ans.mkString("\n")
  }
  println(solve)

}


Measured memory_bytes: 134500
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string s1, s2, s3;
    io.read(s1, s2, s3);
    cout << s1[0] << s2[1] << s3[2];
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
  int M, ans;
  public static void main(String[] args) {
    Main m = new Main();
    m.input();
    m.solve();
    m.out();
  }

  public void input() {
    Scanner sc = new Scanner(System.in);
    M = sc.nextInt();
  }

  public void solve() {
    ans = (24 - M) + 24;
  }

  public void out() {
    System.out.println(ans);
  }
}


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

long long N;
long long A, B;
long long h[100005];


bool beat(long long num){
	long long cur = 0;

	for(long long i = 0; i < N; i++){
		long long rest;
		rest = h[i] - num * B;
		if(rest > 0){
			if((rest % (A - B)) == 0){
				cur += rest / (A - B);
			}else{
				cur += rest / (A - B);
				cur++;
			}
		}
	}
	return num >=  cur;
}

int main(){
	cin >> N >> A >> B;
	for(long long i = 0; i < N; i++){
		cin >> h[i];
	}

	long long s = 0;
	long long e = 1e9;
	while(s + 1 < e){
		long long m = (s+e)/2;
		if(beat(m)){
			e = m;
		}else{
			s = m;
		}
	}
	cout << e << endl;
}


Measured memory_bytes: 1024
from bisect import bisect

n,l = map(int,input().split())

apple = [i for i in range(l,l+n)]
eat_idx = bisect(apple,0)
if eat_idx == n:
	eat_idx -= 1
# print(apple,eat_idx)
#- or +
if abs(apple[eat_idx]) > abs(apple[eat_idx-1]):
	eat = apple[eat_idx-1]
else:
	eat = apple[eat_idx]
print(sum(apple)-eat)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
h1, w1 = map(int, input().split())
h2, w2 = map(int, input().split())
  
# 文字列の入力
#s = input()
# 出力
print("{}".format((h1-h2)*(w1-w2)))

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;
const int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    int p[10], q[10];
    rep(i, n)cin >> p[i];
    rep(i, n)cin >> q[i];

    vector<int> tmp_case;
    for(int i = 1; i <= n; i++)tmp_case.push_back(i);

    int flag1, flag2;
    int x = 0, a, b;
    do{
        flag1 = 1;
        flag2 = 1;
        x++;
        for(int i = 0; i < n; i++){
            if(tmp_case[i] != p[i])flag1 = 0;
            if(tmp_case[i] != q[i])flag2 = 0;
        }
        if(flag1 == 1)a = x;
        if(flag2 == 1)b = x;
    }while(next_permutation(tmp_case.begin(), tmp_case.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    int N;cin>>N;
    int x[N];REP(i,N)cin>>x[i];
    map<int,int> mp;
    REP(i,N)mp[x[i]]=i+1;
    int ans[N*N+1];
    fill_n(ans,N*N+1,-1);
    REP(i,N)ans[x[i]]=i+1;
    sort(x,x+N);
    int index=1;
    REP(i,N){
        int p = ans[x[i]];//埋める数字
        int cnt = p-1;
        while(cnt){
            if(index>x[i]){
                cout<<"No"<<endl;
                return 0;
            }

            if(ans[index]<0){
                ans[index]=p;
                cnt--;
            }
            index++;
        }
    }
    index = N*N;
    for(int i=N-1;i>=0;i--){
        int p = ans[x[i]];//埋める数字
        int cnt = N-p;
        while(cnt){

            if(index<x[i]){
                cout<<"No"<<endl;
                return 0;
            }
            if(ans[index]<0){
                ans[index]=p;
                cnt--;
            }
            index--;
        }
    }
    cout<<"Yes"<<endl;
    REP(i,N*N)cout<<ans[i+1]<<" ";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int H;
	int A;

	scanf("%d %d\n", &H, &A);

	if(H < 1 || 10000 < H) {
		return 1;
	}
	if(A < 1 || 10000 < A) {
		return 1;
	}
	
  	int cnt = 0;
  	while(H > 0) {
      H -= A;
      cnt++;
    }
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int count = 0;
      	while(n >= 3) {
          n -= 3;
          count++;
        }
      	System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
#define N 45
 
int main(){
int i,n,F[N];
F[0]=F[1]=1;

for(i=2;i<N;i++){
F[i]=F[i-1]+F[i-2];
}
scanf("%d",&n);
printf("%d\n",F[n]);
return 0;
}

Measured memory_bytes: 2712
#include <stdio.h> 

int main()	
{
	long int N, p = 1;
	long int i;

	scanf("%d", &N);

	for(i=1; i<=N; i++){
		p = p * i;
		p = p%1000000007;
	}

	printf("%ld", p);

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>

using namespace std;

typedef complex<double> Point;

const double EPS = 1e-8;

int n;
Point data[300];

int calc(Point a, Point b){
  int res = 0;
  double d = abs(b - a) / 2.0;
  Point ab = (b - a) / (2.0 * d);
  if(d < 1){
    Point o = ab * d;
    d = sqrt(1.0 - d * d);
    o += Point(d * ab.imag() + a.real(), -d * ab.real() + a.imag());
    for(int i=0;i<n;i++) if(abs(o - data[i]) < 1.0 + EPS) res++;
  }
  return res;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> data[i].imag() >> data[i].real();
    int ans = 1;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        ans = max(ans, calc(data[i], data[j]));
        ans = max(ans, calc(data[j], data[i]));
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
using namespace std;
int n, a[101];
long long ans;
void dfs(int x) {
	if (x == n + 1) {
		long long s = 0;
		for (int i = 1; i <= n; i++) {
			s += a[i];
		}
		ans = max(ans, s);
		return;
	}
	if (a[x] < 0) {
		int b[101] = {0};
		for (int i = 1; i <= n; i++) {
			b[i] = a[i];
		}
		for (int i = x; i <= n; i += x) {
			a[i] = 0;
		}
		dfs(x + 1);
		for (int i = 1; i <= n; i++) {
			a[i] = b[i];
		}
	}
	dfs(x + 1);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if(i*2>n && a[i]<0)
			a[i]=0;
	}
	
	dfs(1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
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; }

int sx,sy,tx,ty,dx,dy,i;
string ans;

inline void solve(){
  IN2(sx,sy);
  IN2(tx,ty);
  dx=tx-sx;
  dy=ty-sy;
  REP(i,dy)ans+='U';
  REP(i,dx)ans+='R';
  REP(i,dy)ans+='D';
  REP(i,dx+1)ans+='L';
  REP(i,dy+1)ans+='U';
  REP(i,dx+1)ans+='R';
  ans+='D';
  ans+='R';
  REP(i,dy+1)ans+='D';
  REP(i,dx+1)ans+='L';
  ans+='U';
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){

    // input
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];

    ll ans = 0;
    rep(i, 1, n){
        ll tmp = a[i-1] + a[i];
        if(tmp <= x) continue;
        ans += tmp - x;
        a[i] -= min(a[i], tmp-x);
    }

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

Measured memory_bytes: 4032
import java.util.Scanner;

class Main {

	public static void main(String[] a) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int result[] = new int[10];
		for (int i = 0; i < 10; i++) {
			result[i] = sc.nextInt();
		}
		sc.close();

		// 出力
		for (int i = 0; i < 3; i++) {
			int maxIndex = i;
			for (int j = i + 1; j < result.length; j++) {
				if (result[maxIndex] < result[j]) {
					maxIndex = j;
				}
			}
			System.out.println(result[maxIndex]);
			result[maxIndex] = 0;/*
			if (i < 2) {
				System.out.println();
			}*/
		}
	}
}

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

ll gcd(ll a, ll b) { //最大公約数
	if (a == 0 || b == 0) return 0;
	if (a < b) swap(a, b);
	ll tmp = a % b;
	while (tmp != 0) {
		a = b;
		b = tmp;
		tmp = a % b;
	}
	return b;
}
ll gcd3(ll a, ll b, ll c) {
	ll d = gcd(gcd(a, b), c);
	return d;
}

int main()
{
    int n;
    cin >> n;
	ll sum = 0;
	rep(i, n) {
		rep(j, n) {
			rep(k, n) {
				sum += gcd3((ll)i+1, (ll)j+1, (ll)k+1);
			}
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[100010];
int main()
{
	int n,i=0,ans=0;
	cin>>n;
	for(int k=1;k<=n;k++)
	{
		cin>>a[k];	
	}
	while(i<n)//一旦==说明序列排完 
	{
		int j=i+1,low=-1,up=-1;
		if(a[j]>=a[j+1])//尝试降序 
		{
			for(;j<=n;j++)
				if(a[j]<a[j+1]||j==n)//伸到降序列末端 
					{low=j;break;}
			
			j=i+1;//特判等于 
		}
		if(a[j]<=a[j+1])//尝试升序 
		{
			for(;j<=n;j++)
				if(a[j]>a[j+1]||j==n)//伸到up末端 
					{up=j;break;}
		}
		i=max(up,low);//存下目前的最大延伸量 
		//i=min(n,i);//保险特判 
		ans++;
	//	cout<<1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    N = cin.int()
    T = cin.intListList(N)
    a,b = 1,1
    for t in T:
        n = max(Math.roundUp(a , t[0]),Math.roundUp(b , t[1]))
        a,b = n * t[0],n * t[1]
    print(a + b)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 40048
#include<bits/stdc++.h>
#include <algorithm>
 
using namespace std;
 
int main(){
  int N=0;
  cin>>N;
  int buf=0;
  if(N%2==0){
     buf=N/2;
  cout<<buf<<endl;
  }
  else if(N%2==1){
     buf=(N/2)+1;
  cout<<buf<<endl;
  }
}

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

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007

 
int32_t main(){

    //#ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
     IOS
    // // 
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
return 0;
}

Measured memory_bytes: 3612
import sys


def solve(inp):
    N = int(inp.readline())
    A = list(reversed(sorted(map(int, inp.readline().split(' ')))))

    a = b = 0
    for i in range(N):
        if i % 2 == 0:
            a += A[i]
        else:
            b += A[i]

    return str(a - b)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


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

int main(){
  int n, b, f, r, v, i, j, k;
  scanf("%d", &n);
  int count[4][3][10];
  for(i = 0; i < 4; i++){
    for(j = 0; j < 3;j++){
      for(k = 0; k < 10; k++) count[i][j][k] = 0;
    }
  }
  
  for(i = 0;i < n;i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    count[b - 1][f - 1][r - 1] += v;
  }

  for(i = 0; i < 3;i++){
    for(j = 0; j< 3;j++){
      for(k = 0; k < 10; k++)cout << " " << count[i][j][k];
      cout << endl;
    }
    cout << "####################" << endl;
  }
  for(j = 0; j < 3; j++){
    for(k = 0; k < 10; k++)cout << " " << count[3][j][k];
    cout << endl;
  }

}



Measured memory_bytes: 3148
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

int const N = 1000010;
int ans[N];

bool isprime(int x){
    for (int i = 2; i*i <= x; i++){
        if (x%i == 0) return false;
    }
    return true;
}

int main(int argc, char ** argv) {
    int n;
    while (~scanf("%d", &n)){
        int lo = n - 1, hi = n + 1;
        while (!isprime(lo)) lo--;
        while (!isprime(hi)) hi++;
        printf("%d %d\n", lo, hi);
    }
}

Measured memory_bytes: 1172
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 5000005;
int cnt[N];
int a[N], n;

int main() {
  n = read();
  long long ans = 0ll;
  for (rint i = 1; i <= n; i++) {
    a[i] = read(); 
    ans += cnt[a[i]]++;
  }  
  for (rint k = 1; k <= n; k++) {
    printf("%lld\n", ans - cnt[a[k]] + 1);
  }
  return 0;
}

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 405;
ll dp[MAXN][MAXN];
ll POWER[MAXN][MAXN];
int a[MAXN],b[MAXN];
int n;
ll go(int idx, int lft) {
	if(idx==n+1 and lft==0) return 1;
	else if(idx==n+1) return 0;
	if(dp[idx][lft]!=-1) return dp[idx][lft];
	ll ret=0;
	for(int i=0;i<=lft;i++) {
		ll temp=go(idx+1,lft-i);
		ll v;
		if(a[idx]==1) v = POWER[b[idx]][i];
		else v = POWER[b[idx]][i]-POWER[a[idx]-1][i];
		if(v<0) v+=MOD;
		temp*=v;
		if(temp>=MOD) temp%=MOD;
		ret+=temp;
		if(ret>=MOD) ret-=MOD;
	}
	return dp[idx][lft]=ret;
}
int main() {
//	freopen("TASK.in","r",stdin);freopen("TASK.out","w",stdout);
	int c;
	cin>>n>>c;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=400;i++) {
		for(int j=0;j<=400;j++) {
			if(j==0) POWER[i][j]=1;
			else POWER[i][j]=1LL*i*POWER[i][j-1];
			if(POWER[i][j]>=MOD) POWER[i][j]%=MOD;
		}
	}
	for(int i=2;i<=400;i++) {
		for(int j=0;j<=400;j++) {
			POWER[i][j]+=POWER[i-1][j];
			if(POWER[i][j]>=MOD) POWER[i][j]-=MOD;
		}
	}
	cout<<go(1,c)<<endl;
	return 0;
}

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

using namespace std;

const int MAXN = 110;
const int MAXW = 110000;
int N, W;
long long int A[MAXN], P[MAXN];
long long int dp[MAXW];

long long int calcDP(){
	for(int i = 0;i < N;i++){
		for(int j = W;j>=P[i];j--){
			if(dp[j-P[i]]+A[i]>dp[j])
				dp[j] = dp[j-P[i]]+A[i];
		}
		for(int i=1;i<=W;i++)
			dp[i]=max(dp[i],dp[i-1]);
	}
	return dp[W];
}

int main(){
	cin>>N>>W;
	for(int i=0;i<N;i++)
		cin>>P[i]>>A[i];
	cout<<calcDP();	
}

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

const int maxn = 1e5 + 5;
char str[maxn];

int main()
{
    while(scanf("%s",str) != EOF)
    {
        int n = strlen(str);
        if(str[0] == str[n - 1])
        {
            if(n % 2 == 0)
            {
                printf("First\n");
            }
            else
            {
                printf("Second\n");
            }
        }
        else
        {
            if(n % 2 == 0)
            {
                printf("Second\n");
            }
            else
            {
                printf("First\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL S;

mint ans = 0;

vector<mint> memo;
mint rec(LL x){
	if(memo[x].x!=0) return memo[x];
	mint ret = 1;
	for(int i=x-3;i>=3;i--){
		ret += rec(i);
	}
	memo[x] = ret;
	return ret;
}

void solve(){
	if(S==1 || S==2) return;
	memo = vector<mint>(S+1,0);
	ans = rec(S);
}
 
int main(){
	cin >> S;
 
    solve();

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

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
ll h,n;
cin >> h >> n; 
ll che = 0;
for(int i=0;i<n;i++){
    int z;
    cin >> z;
    che+=z;
}
if(che>=h){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}





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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> V(N, 0);
    vector<int> C(N, 0);
    for (auto & v : V) cin >> v;
    for (auto & c : C) cin >> c;
    int ans = 0;
    for (int i = 0; i < N; ++i){
        if (V[i] > C[i]) ans += V[i] - C[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;


int mod_power(int x, int y, int mod){
  int ans = 1;
  x %= mod;
  while(y){
    if (y & 1)
      ans *= x, ans %= mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}

int mod_inverse(int n, int mod){
  return mod_power(n, mod - 2, mod);
}

int mod_ncr(int n, int r, int mod){
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i, fact %= mod;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i, ans %= mod;
  ans *= mod_inverse(fact, mod), ans %= mod;
  return ans;
}

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}


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

  int n;
  cin >> n;
  int ans = 0;
  unordered_map<int, int> m;
  int sames = 0;
  for (int i = 1; i <= n; i++){
    if (m.find(10 * (i % 10) + i / (int)pow(10, (int)log10(i))) != m.end())
      ans += m[10 * (i % 10) + i / (int)pow(10, (int)log10(i))];
    
    if (m.find(10 * (i / (int)pow(10, (int)log10(i))) + i % 10) != m.end())
      m[10 * (i / (int)pow(10, (int)log10(i))) + i % 10] ++;
    else
      m[10 * (i / (int)pow(10, (int)log10(i))) + i % 10] = 1;
    sames += (10 * (i / (int)pow(10, (int)log10(i))) + i % 10 == 10 * (i % 10) + i / (int)pow(10, (int)log10(i)));
  }

  cout << 2 * ans + sames << endl;
}


Measured memory_bytes: 4116
#include <algorithm>
#include <iostream>
#include <set>
#include <tuple>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {

  int n, q;
  cin >> n >> q;
  vector<tuple<int, int, int>> a; // time, type, label
  // time: イベントが起こる時刻
  // type: 0->label削除, 1->label追加, 2->答え求める
  // label: type=0,1のときX[j], 2のとき人の番号
  rep(_, n) {
    int s, t, x;
    cin >> s >> t >> x;
    a.emplace_back(s - x, 1, x);
    a.emplace_back(t - x, 0, x);
  }
  rep(i, q) {
    int d;
    cin >> d;
    a.emplace_back(d, 2, i);
  }
  sort(a.begin(), a.end()); // time, type の昇順
  // 削除->追加->答え求めるの順
  set<int> setx; // X[j]を管理
  vector<int> ans(q, -1);
  for (auto it : a) {
    int type = get<1>(it), label = get<2>(it);
    if (type == 0) {
      setx.erase(label);
    } else if (type == 1) {
      setx.insert(label);
    } else {
      if (setx.size() > 0) ans[label] = *setx.begin();
    }
  }
  rep(i, q) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 18792
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int d,sum=0;
        sum=a+b;
        for(d=1;sum>=10;++d){
            sum/=10;
        }
        if(sum)cout<<d<<endl;
        else cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define N 44

int count = 0, s[N];

int main(){

  int x,sum;

  scanf("%d",&x);

  printf("%d\n",fibonacci(x));

  return 0;

}

int fibonacci(int n){

  if(n == 0 || n == 1){
    return s[n] = 1;
  }

  if(s[n] == 0){
    return s[n] = fibonacci(n-1) + fibonacci(n-2);
  } else {
    return s[n];
  }
  
}

Measured memory_bytes: 0