akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();
        if (S.length() - T.length() < 0) {
            System.out.println("UNRESTORABLE");
            return;
        }
        String ans = "";
        for (int i = S.length() - T.length(); i >= 0; i--) {
            boolean flag = true;
            for (int j = i; j < i + T.length(); j++) {
                flag &= S.charAt(j) == '?' || S.charAt(j) == T.charAt(j - i);
            }
            if (flag) {
                for (int k = 0; k < S.length(); k++) {
                    if (k == i) {
                        ans += T;
                        k += T.length() - 1;
                    } else {
                        ans += S.charAt(k) == '?' ? 'a' : S.charAt(k);
                    }
                }
                System.out.println(ans);
                return;
            }
        }
        System.out.println("UNRESTORABLE");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef pair <int, pii> piii;
#define fr first
#define sc second
#define pb push_back
#define ppb pop_back()
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define mpr make_pair
ll ans;
int cnt;
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	for(auto to : s){
		if(to == 'W')ans += cnt;
		else ++cnt;
	}
	cout << ans;
	return 0;
}

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

int main() {
    string T;
    cin >> T;
    int len = T.size();
    string n = "";
    for (int i=0; i < len; i++) {
        if (T[i] == '?') {
            if (i == (len -1)) {
                n += "D";
            } else if (i > 0 && n[i-1] == 'P') {
                n += "D";
            } else if (i < (len - 1) && T[i+1] == 'P') {
                n += "D";
            } else {
                n += "P";
            }
        } else {
            n += T[i];
        }
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
int main() {
    string S;
    cin >> S;
    int N = S.size();
    ll ans = 0;
    for (int i = 0, j = 0; j < N; j++) {
        if (S[j] == 'W') {
            ans += (ll)j - i;
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,k;
	int num[100000];
	while(1){
		cin >> n >> k;
		if(!n && !k) break;
		bool flag = false;
		for(int i = 0;i < k;i++) {
			cin >> num[i];
			if(num[i] == 0) flag = true;
		}
		sort(num,num + k);
		int ma = -1,prev,cnt = 1;
		if(!flag){
			prev = num[0];
			for(int i = 1;i < k;i++){
				if(num[i] - prev == 1) {
					cnt++;
					ma = max(ma,cnt);
				}
				else cnt = 1;
				prev = num[i];
			}
		}
		else{
			int pcnt = -1;
			prev = num[1];
			for(int i = 2;i < k;i++){
				if(num[i] - prev == 1){
					cnt++;
					ma = max(cnt + pcnt + 1,ma);
				}
				else if(num[i] - prev == 2){
					pcnt = cnt;
					cnt = 1;
					ma = max(ma,cnt + pcnt + 1);
				}
				else{
					pcnt = -1;
					cnt = 1;
				}
				prev = num[i];
			}
		}
		cout << ma << endl;
	}
	return 0;	
}

Measured memory_bytes: 3352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const inf = 1 << 60

func solve() {
	n, k := getInt(), getInt()
	hs := getIntSlice(n)

	dp := make([]int, n)
	for i := range dp {
		dp[i] = inf
	}
	dp[0] = 0

	for i := 0; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i-j < 0 {
				break
			}

			dp[i] = min(dp[i], dp[i-j]+abs(hs[i]-hs[i-j]))
		}
	}

	fmt.Fprintln(wr, dp[n-1])
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(){
	  ll a, b, c, d;
		cin>>a>>b>>c>>d;
		ll x = lcm(c, d);
    ll ans;

    ans=b-(b/c+b/d-b/x)-(a-1-((a-1)/c+(a-1)/d-(a-1)/x));

	  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double COS60 = cos(M_PI / 3.0), SIN60 = sin(M_PI / 3.0);

void print(double p[2]) {
  printf("%f %f\n", p[0], p[1]);
}

void add(double ret[2], double p1[2], double p2[2]) {
  ret[0] = p1[0] + p2[0];
  ret[1] = p1[1] + p2[1];
}

void subtract(double ret[2], double p1[2], double p2[2]) {
  ret[0] = p1[0] - p2[0];
  ret[1] = p1[1] - p2[1];
}

void multiply(double ret[2], double p[2], double a) {
  ret[0] = p[0] * a;
  ret[1] = p[1] * a;
}

void devide(double ret[2], double p[2], double a) {
  ret[0] = p[0] / a;
  ret[1] = p[1] / a;
}

double norm(double x[2]) {
  return sqrt(x[0] * x[0] + x[1] * x[1]);
}

void rot60(double ret[2], double x[2]) {
  double tmp[2] = {x[0], x[1]};
  ret[0] = COS60 * tmp[0] - SIN60 * tmp[1];
  ret[1] = SIN60 * tmp[0] + COS60 * tmp[1];
}

void koch(int n, double p1[2], double p2[2]) {
  if(n == 0) {
    return;
  }
  double s[2], t[2], u[2], d[2];

  // d = ( p2 - p1 ) / 3
  subtract(d, p2, p1);
  devide(d, d, 3.0);

  // calc s
  add(s, d, p1);
  // calc u
  multiply(u, d, 2);
  add(u, u, p1);
  // calc t
  rot60(t, d);
  add(t, t, s);

  koch(n - 1, p1, s);
  print(s);
  koch(n - 1, s, t);
  print(t);
  koch(n - 1, t, u);
  print(u);
  koch(n - 1, u, p2);
}

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

  double p1[2] = {0.0, 0.0};
  double p2[2] = {100.0, 0.0};
  print(p1);
  koch(n, p1, p2);
  print(p2);
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll n,k; cin>>n>>k;
    vll a(n); vll b(n);
    REP(i,n) cin>>a[i];
    ll a_sum = accumulate(ALL(a), 0LL); 

    vll cd;

    for(ll i=1;i*i<=a_sum;i++){
        if(i*i==a_sum) {
            cd.push_back(i);
            break;
        }
        if (a_sum%i==0) {
            cd.push_back(i); cd.push_back(a_sum/i);
        }
    }
    VSORTR(cd);
    ll mx;
    // cout << cd.top() << endl;
    for(ll p: cd){
        // cout<< p << endl;
        REP(i,n) b[i] = a[i] % p;
        VSORT(b);
        ll b_sum = accumulate(ALL(b), 0LL);
        ll nn = n - b_sum / p;
        ll am = accumulate(b.begin(), b.begin()+nn,0LL);
        
        if (am <= k) {
            cout << p <<endl;
            return 0;
        }
    }
    // cout << 121234 <<endl;
    return 0;
    
}



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

using namespace std;
using ll = long long;
const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    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 { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> A(a), B(b), C(c);
    for (int i = 0; i < a; ++i)cin >> A[i];
    for (int i = 0; i < b; ++i)cin >> B[i];
    for (int i = 0; i < c; ++i)cin >> C[i];
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end(), greater<int>());
    for (int i = 0; i < x; ++i)C.emplace_back(A[i]);
    for (int i = 0; i < y; ++i)C.emplace_back(B[i]);
    sort(C.begin(), C.end(), greater<int>());
    long long sum = 0;
    for (int i = 0; i < x + y; ++i)sum += C[i];
    cout << sum << endl;
    return 0;

}


Measured memory_bytes: 2552
N = int(input())
sum_ = 0
for i in range(N):
  tmp = input()
  tmp = tmp.split(" ")
  x = float(tmp[0])
  u = tmp[1]
  
  if(u=="JPY"):
    sum_ += x
  else:
    sum_ += x*380000
  
print(sum_)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  string s;
  cin >> s;
  if (s == "ABC") P("ARC");
  else P("ABC");

  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

bool isCyclic(string s) {
	int len = s.size();
	for (int i = 0; i < (len / 2); i++) {
		if (s[i] == s[len - 1 - i]) {
			continue;
		}
		else {
			return 0;
		}
	}
	return 1;
}
int main() {
	string s;
	cin >> s;
	int N = s.size();
	string former, latter;
	former = s.substr(0, (N - 1) / 2);
	latter = s.substr((N + 1) / 2);

	int ans;
	if (isCyclic(s) and isCyclic(former) and isCyclic(latter)) {
		ans = 1;
	}
	else {
		ans = 0;
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int N, M;
bool graph[55][55];

void dfs(vector<bool>& used, int now){
  used[now] = true;
  for(int i = 0; i < N; i++){
    if(!graph[now][i])continue;
    if(used[i])continue;
    dfs(used, i);
  }
}

int main(){
  cin >> N >> M;
  vector<int> a(M), b(M);
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  
  int ans = 0;
  for(int i = 0; i < M; i++){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

    vector<bool> used(N, false);
    dfs(used, 0);
    bool ok = false;
    for(int i = 0; i < N; i++) if(!used[i]) ok = true;
    ans += ok;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

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


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

bool f(int x,int y){if(x>=y)return true; return false;}

int main(){
	int W[10],K[10];
	for(int i=0;i<10;i++)scanf("%d",&W[i]);
	for(int i=0;i<10;i++)scanf("%d",&K[i]);
	sort(W,W+10,f); sort(K,K+10,f);
	printf("%d %d\n",W[0]+W[1]+W[2],K[0]+K[1]+K[2]);
}

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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

int solve(){
    int A, B, m;
    cin >> A >> B >> m;
    vector<int> a(A), b(B);
    int mia = INF, mib = INF; 
    for(int i=0;i<A;i++){
        cin >> a[i];
        mia = min(mia, a[i]);
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
        mib = min(mib, b[i]);
    }
    int ans = mia+mib;
    for(int i=0;i<m;i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x]+b[y]-c);
    }
    cout << ans << endl;
    return 0;
}

int main(){
    solve();
    // while(solve()==0);
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}

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

int main()
{
  int N,cp,fx=0;
  cin >> N;
  cp=N;
  while (cp>=10)
  {
    fx+=cp%10;
    cp/=10;
  }
  fx+=cp%10;
  if(N%fx==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
    

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

int main(void)
{
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	
	int n;
	cin >> n;
	
	unsigned long int amount = 0;
	for(unsigned int i = 1; i < (unsigned int)n; ++i){
		amount += i;
	}
	
	cout << amount << endl;
	
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    s = input()
    a = -1
    for i in range(len(s)):
        if s[i] == "A":
            a = i
            break
    z = -1
    for i in range(len(s)):
        if s[len(s) - i - 1] == "Z":
            z = len(s) - i - 1
            break
    print(z - a + 1)
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a=0,b=0,c=0;
	cin>>a>>b>>c;
	cout<<c-min(c,a-b)<<endl;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main { 
	public static int[][] list;
	public static boolean[][] map;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int w = stdIn.nextInt();
			int h = stdIn.nextInt();
			if(w == 0 && h == 0) break;
			list = new int[h][w];
			map = new boolean[2 * h -1][w];
			for(int i = 0; i < list.length; i++) {
				for(int j = 0; j < list[i].length; j++) {
					list[i][j] = 999999;
				}
			}
			for(int i = 0; i < 2 * h - 1; i++) {
				if(i % 2 == 1) {
					for(int j = 0; j < w; j++) {
						int a = stdIn.nextInt();
						if(a == 1) {
							map[i][j] = true;
						}
					}
				}
				else {
					for(int j = 0; j < w - 1; j++) {
						int a = stdIn.nextInt();
						if(a == 1) {
							map[i][j] = true;
						}
					}
				}
			}
			solv(0,0,1);
			int ans = list[list.length-1][list[0].length-1];
			if(ans == 999999) {
				System.out.println(0);
			}
			else {
				System.out.println(ans);
			}
			
		}
		
	}
	
	public static void solv(int x, int y, int c) {
		if(x < 0 || y < 0 || y >= list.length || x >= list[y].length) return;
		if(list[y][x] <= c) return;
		
		
		list[y][x] = c;
		if(x-1 >= 0 && !map[y*2][x-1]) {
			solv(x-1,y,c+1);
		}
		if(x < map[y*2].length && !map[y*2][x]) {
			solv(x+1,y,c+1);
		}
		if(y*2 + 1 < map.length && !map[y*2 + 1][x]) {
			solv(x,y+1,c+1);
		}
		if(y*2 - 1 >= 0 && y * 2 - 1 < map.length &&  !map[y*2-1][x] ) {
			solv(x,y-1,c+1);
		}
	}
	
}

Measured memory_bytes: 76616
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int S = scanner.nextInt();
        int h=S/3600;
		int m=(S%3600)/60;
		int s=S%60;
		System.out.println(h+":"+m+":"+s);
    }
}


Measured memory_bytes: 26380
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int  a = sc.nextInt();
		int  b = sc.nextInt();
		int  c = sc.nextInt();
		int  d = sc.nextInt();
		int  p = sc.nextInt();
		int x=a*p;
		int y;
		if(p<c) y=b;
		else y=b+(p-c)*d;
		if(x>y) x=y;
		System.out.println(x);
	}
}

Measured memory_bytes: 26012
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0;
        string c;
        string s;
       long long int n,m,o=0,l,d=1,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    cin>>n>>k>>f;
    if(n/(k+f)==0)
    {
        if(n%(k+f)==0)
        cout<<k;
        else
        cout<<min(k,n%(k+f));
    }
    else
    {    if(n%(k+f)==0)
        cout<<(k*(n/(k+f)));
        else
        cout<<min(k,n%(k+f))+(k*(n/(k+f)));
    
        
    }
 return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<stack>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define rrep(f,i,n) for(int (i)=0;(i) < (f); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define mset(a,x) memset(a,x,sizeof(a))

#define MAX 101
#define MAX_V 15

int main()
{
	string s;
	cin >> s;
	for (int i = s.length() - 2; i >= 0; i--) {
		if (i == 0) {
			cout << i + 1 << endl;
		}
		if (i % 2 == 0) continue;
		int h = i / 2+1;
		if (s.substr(0, h) == s.substr(h,h)) {
			cout << i + 1 << endl;
			return 0;

		}
	}
	return 0;
}



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

signed main() {
  int n;
  string s;
  cin >> n;
  vector<map<char, int>> cnt(n);
  map<char, int> mini;
  
  for (int i = 0; i < n; ++i) {
  	for (char alpha = 'a'; alpha <= 'z'; alpha++) {
      cnt[i][alpha] = 0;
  	}
  }
  
  for (char alpha = 'a'; alpha <= 'z'; alpha++) {
    mini[alpha] = 1000000;
  }
  
  for (int i = 0; i < n; ++i) {
    cin >> s;
    for (int j = 0; j < s.size(); ++j) {
      cnt[i][s[j]]++;
    }
  }
  
  for (char alpha = 'a'; alpha <= 'z'; alpha++) {
    for (int i = 0; i < n; ++i) {
      mini[alpha] = min(mini[alpha], cnt[i][alpha]);
    }
  }
  
  for (char alpha = 'a'; alpha <= 'z'; alpha++) {
    while (mini[alpha] > 0) {
      cout << alpha;
      mini[alpha]--;
    }
  }
  cout << endl;
}

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

using namespace std;

int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < o.size(); i++) {
    cout << o[i];
    if (i < e.size()) cout << e[i];
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_SheepandWolves_164
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long s = inputLongArray[0];
            long w = inputLongArray[1];

            string result = "";

            if (s <= w)
            {
                result = "unsafe";
            }
            else
            {
                result = "safe";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll ceil(ll n, ll d) {
	return n / d + (n % d != 0);
}

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

	int N; cin >> N;
	vll arr (N);
	F0R(i, N) cin >> arr[i];

	ll ans = 0;

	while (true) {
		bool didMove = false;
		F0R(j, N) if (arr[j] >= N) {
			ll done = arr[j] / N;
			ans += done;
			if (done) didMove = true;
			arr[j] -= done * (N + 1);
			F0R(k, N) {
				arr[k] += done;
			}
		}
		if (!didMove) break;
	}
	print(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll a,b,c, k;
  cin>>a>>b>>c >> k;
  while(k--){
    if(a < b && b < c){
      break;
    }
    if(a >= b){
      b *= 2;
    }else if(b >= c){
      c *= 2;
    }
  }
  if(a < b && b < c){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3592
while True:
    tmp=""
    a,b=map(int,input().split())
    if a==0 and b ==0:
        break
    
    for i in range(0,a):
        tmp="#"
        if i==0 or i==a-1:
            for j in range(1,b):
                tmp=tmp+"#"    
            print(tmp)
        else:
            for k in range(1,b-1):
                tmp=tmp+"."
            tmp=tmp+"#"
            print(tmp)
    print("")



Measured memory_bytes: 5612
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    long long a, b, k;
    cin >> a >> b >> k;
    if(k < a){
        a -= k;
    } else if(k >= a){
        b -= (k-a);
        if(b < 0) b = 0;
        a = 0;
    }
    cout << a << " " << b << endl;
}

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

using namespace std;

void solve4() {

}

void solve3() {

}

void solve2() {

}

void solve1() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	solve1();
	return 0;
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >>e >>k;

  bool ans=true;

  if(b-a>k) ans=false;
  if(c-a>k) ans=false;
  if(d-a>k) ans=false;
  if(e-a>k) ans=false;
  if(c-b>k) ans=false;
  if(d-b>k) ans=false;
  if(e-b>k) ans=false;
  if(d-c>k) ans=false;
  if(e-c>k) ans=false;
  if(e-d>k) ans=false;

  if(ans==true){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
return 0;  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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 n;
    cin >> n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0)continue;
        ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    string w;
    cin >> w;
    map<char, int> mp;
    rep(i, w.length()) mp[w[i]]++;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBrickBreak solver = new DBrickBreak();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBrickBreak {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = in.nextIntArray(N);
            boolean[] dp = new boolean[(int) 2e5 + 10];
            int max = 0;
            for (int i = 0; i < N; i++) {
                if (a[i] == 1) {
                    dp[1] = true;
                    max = Math.max(1, max);
                } else if (dp[a[i] - 1]) {
                    max = Math.max(a[i], max);
                    dp[a[i]] = true;
                }
            }
            if (dp[1]) out.println(N - max);
            else out.println(-1);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] nextIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = nextInt();
            return array;
        }

    }
}



Measured memory_bytes: 34472
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;
int main()
{
    int a[100005];
    int n,ans=0,t;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==i)
        {
            t=a[i];
            a[i]=a[i+1];
            a[i+1]=t;
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;

}


Measured memory_bytes: 640
#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++)
#define VL vector<ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;

int main(){
    ll N;    cin >> N;
    VL a(N); 
    ll sum = 0;
    rep(i,0,N){
        cin >> a[i];
        sum += a[i];
    }

    ll ans = 0;
    rep(i,0,N-1){
        sum = sum - a[i];
      	//cout << sum << endl;
        ans += (a[i]%MOD) * (sum%MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

int main() {
   ll K, A, B;
   ll ans = 0;
   cin >> K >> A >> B;
   if (B <= A + 1) {
      cout << K + 1 << endl;
      return 0;
   }
   if (A >= K) {
      cout << K + 1 << endl;
      return 0;
   }
   ans += A;
   K -= A - 1;
   ans += (B - A) * (K / 2);
   ans += K % 2;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    public static long MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] s = br.readLine().split(" ");

        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);

        String[] s2 = br.readLine().split(" ");
        Integer[] nums = new Integer[n];
        List<Long> positives = new ArrayList<>();
        List<Long> negatives = new ArrayList<>();

        int zeroCount = 0;

        for (int i = 0; i < n; i++) {
            nums[i] = Math.abs(Integer.parseInt(s2[i]));
            int temp = Integer.parseInt(s2[i]);
            if (temp<0)negatives.add((long) Math.abs(temp));
            else if (temp==0){
                ++zeroCount;
            }
            else  positives.add((long) temp);
        }

        boolean isPositive = positives.size() + ((int)(negatives.size()/2))*2 >= k && (k%2 == 0 || positives.size() > 0);


        if (isPositive){
            //positive sing = > select negatives or positives in groups of two (by whichever pair has higher product) and mul 1 more pos at the end if k nos not taken

            positives.sort(Collections.reverseOrder());
            negatives.sort(Collections.reverseOrder());

            int negIdx = 0;
            int posIdx = 0;
            int total = k;
            long ans  = 1L;
            if(k%2==1){
                ans = positives.get(posIdx);
                ++posIdx;
                --total;
            }
            while (total>0){

                long negProd = negatives.size()-negIdx>=2 ? (negatives.get(negIdx)*negatives.get(negIdx+1)) : 0;
                long posProd = positives.size()-posIdx>=2 ? (positives.get(posIdx)*positives.get(posIdx+1)) : 0;


                ans = (ans * (Math.max(negProd,posProd)%MOD))%MOD;
                if(negProd>posProd)
                    negIdx += 2;
                else
                    posIdx += 2;
                total -= 2;
            }
            System.out.println(ans);
        }else{
            // sign will be negative, hence choose smallest k numbers(by abs value).
            if(zeroCount>0){
                System.out.println(0);
                return;
            }
            Arrays.sort(nums);
            long ans = 1L;
            for(int i = 0 ; i<k; i++){
                ans = (ans*nums[i])%MOD;
            }
            System.out.println((MOD-ans)%MOD);
        }

    }
}


Measured memory_bytes: 78572
/*input
aaaaaaaaaa
bb bb bb aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
aaa aaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
aaaaaaaaaa xxx xxxxxxxxx aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa b b b b b b b aaaaaaaaaa aaaaaaaaaa
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaaa a a a a
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa a a a a
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa x
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa x x x x
aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa x x xaaaaaaaaaa
END_OF_TEXT

*/
use std::ascii::AsciiExt;

macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.trim().to_string()
    }};
}

fn main() {
    let pat = input!().to_ascii_lowercase();
    let mut inp;
    let mut tot = 0;
    loop {
        inp = input!();
        if &inp == "END_OF_TEXT" {
            break;
        }
        for i in inp.to_ascii_lowercase().split_whitespace() {
            if i == pat {
                tot += 1;
            }
        }
    }

    println!("{}", tot);
}



Measured memory_bytes: 5020
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

typedef long long ll;

int main() {
   int W,H,N; cin >> W >> H >> N;
  int x[101],y[101],a[101];
  for ( int i = 1; i <= N; i++ ) {
    cin >> x[i] >> y[i] >> a[i];
  }
  int X = 0,Y =0;
  for ( int i = 1; i <= N; i++ ) {
    if ( a[i] == 1 ) {
      if ( X < x[i] ) X = x[i];
    } else if ( a[i] == 2 ) {
      if ( W > x[i] ) W = x[i];
    } else if ( a[i] == 3 ) {
      if ( Y < y[i] ) Y = y[i];
    } else if ( a[i] == 4 ) {
      if ( H > y[i] )H = y[i];
    }
  }
  //cout << "X " << X << " " << "Y " << Y << endl;
  //cout << "W " << W << " " << "H " << H << endl;
  if( W <= X || H <= Y ) cout << 0 << endl;
  else cout << (W-X) * (H-Y) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a1,a2;
	cin>>a1>>a2;
    if((a1+a2)%3==0 || (a1%3==0)||(a2%3==0))
    	cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
const int maxN = 1e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;

struct vec {
	static const int maxE = maxN;
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxE << 1];
	inline void push(int x, int y) {e[++te] = (edge){y, g[x]}; g[x] = te;}
	inline void link(int x, int y) {push(x, y), push(y, x);}
	inline int& operator () (int x) {return g[x];}
	inline edge& operator [] (int x) {return e[x];}
}e;

int sg[maxN];

void dfs(int x, int fa) {
	fore (e, x, y) if (y != fa) {
		dfs(y, x);
		sg[x] ^= sg[y];
	}
	sg[x] += 1;
}

int main() {

	n = ri();
	For (i, 1, n) e.link(ri(), ri());
	dfs(1, 0);
	puts(sg[1] != 1 ? "Alice" : "Bob");

	return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define M1 (ll)1000000007
#define M2 (ll)998244353
#define Pi 3.141592653
#define exp 2.71828
#define ll long long
#define ull unsigned long long
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define di deque<int>
#define dl deque<ll>
#define dii deque<pi>
#define dll deque<pl>
#define vvi vector<vi>
#define vvl vector<vl>
#define vii vector<pi>
#define vll vector<pl>
#define pb push_back
#define pp pop_back
#define pf push_front
#define pt pop_front
#define mp make_pair
#define in insert
#define er erase
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rpt(i,a,b,t) for(int i=a;i<b&&t<1;i++)
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define rept(i,n,t) for(int i = 0 ; i<n&&t<1 ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define reprt(i,n,t) for(int i=n-1;i>=0&&t<1;i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
int main() {
    fast
    int n,k;
    cin>>n>>k;
    ll c[n+1];
    for(int i=1;i<n+1;++i) cin>>c[i];
    ll dp[n+1][k+1];
    for(int i=0;i<n+1 ;++i) for(int j=0;j<k+1;++j) dp[i][j]=0; 
    for(int i=0;i<n+1;++i) dp[i][0]=1;
    for(int i=1;i<n+1 ;++i){
        for(int j=1;j<k+1;++j){
            ll x = (j>c[i])?dp[i-1][j-c[i]-1]:0;
            dp[i][j] = (((dp[i][j-1]%M1)+dp[i-1][j]%M1)%M1-x%M1+M1)%M1;
        }
    }
    cout<<dp[n][k];
}

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

int main(){

    char S[1000], T[1000];

    scanf("%s", S);
    scanf("%s", T);

    int Slength = strlen(S);
    int Tlength = strlen(T);

    int num = 0;
    int matchMax = -1;

    int flag = 0;

    if(Slength == Tlength){
        flag = 1;
    }

    if(flag == 0){
        for(int i=0; i!=Slength - Tlength; i++){
        for(int j=0;j!=Tlength;j++){
            if(S[j+i] == T[j]){
                num++;
            }
        }
        if(matchMax<num){
            matchMax = num;
        }
        num=0;
    }
    }else{
        for(int i=0;i<Slength;i++){
            if(S[i] == T[i]){
                num++;
            }
        }
        matchMax = num;
    }

    printf("%d\n", Tlength - matchMax);

    return 0;
}

Measured memory_bytes: 2152
#include <iostream>

using namespace std;

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

    cin >> a >> b >> c;

    if(a==5 && b==5 && c==7) {
        cout << "YES" << endl;
    } else if(a==5 && b==7 && c==5) {
        cout << "YES" << endl;
    } else if(a==7 && b==5 && c==5) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
from collections import defaultdict

N, P = map(int, input().split())

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]


def prime_factorization_1(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = defaultdict(int)
        for prime in prime_list:
            while num % prime == 0:
                dict_counter[prime] += 1
                num //= prime
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        return dict_counter

ans_dict = prime_factorization_1(P)

ans = 1

if ans_dict:
    for soinsuu in ans_dict:
        while True:
            if ans_dict[soinsuu] >= N:
                ans_dict[soinsuu] -= N
                ans *= soinsuu
            else:
                break

print(ans)

Measured memory_bytes: 43640
#include<stdio.h>
#include<string.h>
int main(void){
    double a;
    while(scanf("%lf",&a)!=EOF){
        int i,j;
        double ten[10],work=0,x,y,z;
        ten[0]=a;
        for(i=1;i<10;i++){
            if(i%2==1)ten[i]=ten[i-1]*2.0;
            else ten[i]=ten[i-1]/3.0;
        }
        for(i=0;i<10;i++){
            work+=ten[i];
        }
        printf("%f\n",work);
    }
    return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
#include<math.h>

int main() {

	double x1, x2, y1, y2,d;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);

	
	printf("%f", sqrt(d));

	return 0;
}


Measured memory_bytes: 2044