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

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] in = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        int bigH = Integer.parseInt(in[0]);
        int bigW = Integer.parseInt(in[1]);
        int h = Integer.parseInt(in2[0]);
        int w = Integer.parseInt(in2[1]);
        int r = bigH*bigW;
        r -= h*bigW+(w*bigH-h*w);
        System.out.println(r);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination() {}
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, x;
  cin >> n >> x;
  vi s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  sort(s.rbegin(), s.rend());
  Combination<MOD> comb(1000000);
  vvll dp(n+1, vll(x+1, 0));
  dp[0][x] = 1;
  for(int i=0;i<n;++i) {
    for(int j=0;j<=x;++j) {
      dp[i+1][j%s[i]] += dp[i][j];
      dp[i+1][j%s[i]] %= MOD;
      dp[i+1][j] += dp[i][j] * (n-i-1) % MOD;
      dp[i+1][j] %= MOD;
    }
  }
  ll ans = 0;
  for(int i=0;i<=x;++i) {
    ans += dp[n][i] * i % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 182144
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

A,B,C,D = map(int, input().split())

c = B//C - (A-1)//C
d = B//D - (A-1)//D

CD = C * D // gcd(C, D)
cd = B//CD - (A-1)//CD

ans = B - (A-1) - (c + d - cd)
print(ans)

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll n, m, x, y;
    cin >> n >> m;
    if(n == 1 && !m){
        cout << 0;
        return;
    }
    ll a[n+1], flag = 0;
    rep(i, n+1){
        a[i] = -1;
    }
    set < pll > s;
    rep(i, m){
        cin >> x >> y;
        s.ins({x, y});
        if(x == 1 && y == 0){
            flag = 1;
            break;
        }
        if(a[x] == y || a[x] == -1){
            a[x] = y;
        }
        else{
            flag = 1;
        }
    }
    rep(i, n+1){
        if(a[i] == -1){
            a[i] = 0;
        }
    }
    if(n == 1 && sz(s) == 1){
        for(auto it : s){
            if(it.ff == 1 && it.ss == 0){
                cout << 0 << endl;
                return;
            }
        }
    }
    if(flag){
        cout << -1 << endl;
    }
    else{
        if(a[1] == 0){
            a[1] = 1;
        }
        fo(i, 1, n){
            cout << a[i];
        }
    }
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

ll dp[100005][3];

int main() 
{
    fastio;
    int n;
    cin>>n;
    vi a[3];
    range(i,0,n)
     {
        int x,y,z;
        cin>>x>>y>>z;
        a[0].pb(x);a[1].pb(y);a[2].pb(z);
     }

    dp[0][0]=a[0][0];
    dp[0][1]=a[1][0];
    dp[0][2]=a[2][0];
    //cout<<dp[0][0]<<' '<<dp[0][1]<<' '<<dp[0][2]<<'\n';

    range(i,1,n)
    {
      dp[i][0]=a[0][i]+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=a[1][i]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=a[2][i]+max(dp[i-1][0],dp[i-1][1]);
      //cout<<dp[i][0]<<' '<<dp[i][1]<<' '<<dp[i][2]<<'\n';
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});


}

Measured memory_bytes: 4076
#include <cstdio>
#include <string.h>

int s[2000001];
int size = 0;

int Swap(int* S,int loc){
	if(loc > 0 && S[loc] > S[(loc-1)/2]){
		int tmp = S[loc];
		S[loc] = S[(loc-1)/2];
		S[(loc-1)/2] = tmp;
		return Swap(S,(loc-1)/2);
	}
	return loc;
}

int SwapRev(int* S,int loc){
	if(loc*2+2 < size){
		int mxi;
		if(S[loc*2+1] > S[loc*2+2]){
			mxi = loc*2+1;
		}
		else{
			mxi = loc*2+2;
		}
		if(S[mxi] > S[loc]){
			int tmp = S[mxi];
			S[mxi] = S[loc];
			S[loc] = tmp;
			return SwapRev(S,mxi);
		}
	}
	else if(loc*2+1 < size){
		if(S[loc*2+1] > S[loc]){
			int tmp = S[loc*2+1];
			S[loc*2+1] = S[loc];
			S[loc] = tmp;
		}
		return loc;
	}
	else{
		return loc;
	}
}

int Insert(int* S,int k){
	S[size] = k;
	Swap(S,size);
	size++;
	return k;
}

int ExtractMax(int* S){
	int ret = S[0];
	S[0] = S[size-1];
	size--;
	SwapRev(S,0);
	return ret;
}

int main(){
	char cmd[32];
	int v;
	while(scanf("%s",cmd) != EOF){
		if(strcmp(cmd,"insert") == 0){
			scanf("%d",&v);
			Insert(s,v);
		}
		else if(strcmp(cmd,"extract") == 0){
			printf("%d\n",ExtractMax(s));
		}
		else if(strcmp(cmd,"end") == 0){
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 6576
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}
using namespace std;
ll a[114514];
signed main() {
	ll n;
	cin >> n;
	rep(i, n)cin >> a[i];
	ll cnt[114514];
	cnt[0] = gcd(a[0], a[1]);
	for (int i = 1; i < n - 1; i++) {
		cnt[i] = gcd(cnt[i - 1], a[i + 1]);
	}
	cout << cnt[n - 2] << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 1792
#include<iostream>
            #include<stdio.h>
            //#include <bits/stdc++.h>
            #include<vector>
            #include<algorithm>
            #include<string>
            #include<math.h>
            #include<sstream>
            #include<set>
            #include<map>
            using namespace std;
            #define INF 10000000;
            #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
            #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
            #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
            #define vec(type,n) vector<type>(n)
            #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
         
          
          
            int main(){
              long a,b,k;
              cin >>a>>b>>k;
              long res1 = min(a,k);
              k -= res1;
              res1 = a-res1;
              
              long res2 = min(b,k);
              res2 = b-res2;
              
              cout <<res1<<" "<<res2;
            }

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var n = int.Parse(Console.ReadLine());

            var balls = new Position[n];
            for (var i = 0; i < n; i++)
            {
                var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
                balls[i] = new Position(inputs[0], inputs[1]);
            }

            // ボールの数が１の時はコスト１確定
            if (n == 1)
            {
                Console.WriteLine(1);
                return;
            }

            // 各ボール間の距離を計算
            var differences = new Position[n][];
            for (var i = 0; i < n; i++)
            {
                differences[i] = new Position[n];
                for (var j = 0; j < n; j++)
                {
                    differences[i][j] = balls[i].Difference(balls[j]);
                }
            }

            // 距離が同じものの数の最大値を取得
            var maxSameDiffs = differences.SelectMany(diffs => diffs)
                .GroupBy(diff => diff)
                .Where(kvp => kvp.Key.X != 0 || kvp.Key.Y != 0)
                .Max(kvp => kvp.Count());

            var cost = n - maxSameDiffs;

            // 解答の出力
            Console.WriteLine(cost);
        }

        struct Position
        {
            public int X, Y;
            public Position(int x, int y)
            {
                X = x;
                Y = y;
            }

            public Position Difference(Position other)
            {
                return new Position(X - other.X, Y - other.Y);
            }
        }
    }
}


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

int main() {
	int n;cin>>n;
	int F[50];
	F[0]=F[1]=1;
	for(int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];
	
	cout<<F[n]<<endl;
	
	return 0;
}

Measured memory_bytes: 3100
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt();
		List<String> A=new ArrayList<>();
		 
		for(int i=0;i<n;i++)A.add(in.next());
		List<String> B=new ArrayList<>(A),S=new ArrayList<>(A);
		
		in.close();
		
		bubble(B);
		for(int i=0;i<n-1;i++)System.out.print(B.get(i)+" ");
		System.out.println(B.get(n-1));
		System.out.println("Stable");
		
		selection(S);
		for(int i=0;i<n-1;i++)System.out.print(S.get(i)+" ");
		System.out.println(S.get(n-1));
		System.out.println((isStable(S,B))? "Stable": "Not stable");
	}
	
	static boolean isStable(List<String> A,List<String> B) {
		for(int i=0;i<A.size();i++) {
			if(!A.get(i).equals(B.get(i)))return false;
		}
		
		return true;
	}
	
	static void bubble(List<String> A) {
		boolean f=true;
		
		while(f) {
			f=false;
			for(int i=A.size()-1;i>0;i--) {
				if(A.get(i).charAt(1)<A.get(i-1).charAt(1)) {
					Collections.swap(A, i, i-1);
					f=true;
				}
			}
		}
	}
	
	static void selection(List<String> A) {
		
		for(int i=0;i<A.size();i++) {
			int min=i;
			for(int j=i;j<A.size();j++) {
				if(A.get(j).charAt(1)<A.get(min).charAt(1))min=j;
			}
			
			if(min>i) {
				Collections.swap(A, i, min);
			}
			
		}
		
	}

}



Measured memory_bytes: 26332
let last_i = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let extract (t : int array) =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !last_i && t.(l) > t.(i) then l else i in
    let m = if r <= !last_i && t.(r) > t.(m) then r else m in
    if i = m then ()
    else begin
      let tmp = t.(i) in
      t.(i) <- t.(m);
      t.(m) <- tmp;
      max_heapify m
    end in
  let ret = t.(1) in
  t.(1) <- t.(!last_i);
  decr last_i;
  max_heapify 1;
  ret

let insert x (t : int array) =
  let rec doit i =
    let p = parent i in
    if i <= 1 || t.(p) >= t.(i) then ()
    else begin
      let tmp = t.(i) in
      t.(i) <- t.(p);
      t.(p) <- tmp;
      doit p
    end in
  incr last_i;
  t.(!last_i) <- x;
  doit !last_i

let () =
  let t = Array.make 2000001 0 in
  let rec doit () =
    let op = Scanf.scanf "%s " (fun i -> i) in
    if op = "end" then ()
    else if op = "extract" then begin
      extract t |> Printf.printf "%d\n";
      doit ()
    end else begin
      insert (Scanf.scanf "%d " (fun i -> i)) t;
      doit ()
    end in
  doit ()

Measured memory_bytes: 20488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int disc_1(int x){
    if(x==1) return 14;
    else return x;
}

int main(){
    int n;
    cin >> n;
    int total = 800*n-n/15 * 200;
    out(total);
}


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

int main(){
  string temp;
  cin >> temp;
  if(temp == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(){
int n,ans=0;
scanf("%d",&n);
if(n>=105)
ans++;
if(n>=165)
ans++;
if(n>=195)
ans++;
if(n>=135)
ans++;
if(n>=189)
ans++;
printf("%d\n",ans);
return 0;
}

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

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k)  cout << s << endl;
    else cout << s.substr(0,k) <<  "..."  << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

int pos[21][21];

int main(){
  int n,m;
  while(cin>>n>>m && n+m){
    vector<int> veca(n);
    vector<int> vecb(m);
    int suma=0;
    int sumb=0;
    for(int i=0;i<n;i++){
      cin>>veca[i];
      suma+=veca[i];
    }
    for(int i=0;i<m;i++){
      cin>>vecb[i];
      sumb+=vecb[i];
    }

    int ta=1000;
    int tb=1000;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	int sa=suma-veca[i]+vecb[j];
	int sb=sumb-vecb[j]+veca[i];
	if(sa == sb && veca[i]+vecb[j] < ta+tb){
	  ta=veca[i];
	  tb=vecb[j];
	}
      }
    }
    if(ta ==1000){
      cout<<-1<<endl;
    }else{
      cout<<ta<<" "<<tb<<endl;
    }

  }
  return 0;
}

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

long long MOD = 1e9+7;

long long modPow(long long a, long long n, long long p){
  if (n==1LL) return a%p;
  if (n%2LL==0) {
    long long t = modPow(a, n/2LL, p);
    return (t*t)%p;
  }
  return (a * modPow(a, n-1LL, p)) % p;
}

long long combi(long long n, long long k){
  long long child = 1LL;
  long long parent = 1LL;
  for (long long i = 1LL; i <= k; i++) {
    child *= (n-i+1LL);
    child %= MOD;
    parent *= i;
    parent %= MOD;
  }
  return (child * modPow(parent,MOD-2LL, MOD)) % MOD;
}

int main(){
  long long n, a, b;
  cin >> n >> a >> b;

  long long ans = modPow(2LL, n, MOD)-1LL;
  ans -= combi(n,a);
  if (ans < 0) ans += MOD;
  ans -= combi(n,b);
  if (ans < 0) ans += MOD;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        Collections.sort(a);
        int m = a.get(0);
        for (int i = 1; i < n; i++) {
            m = gcd(m, a.get(i));
        }
        if (k % m == 0 && a.get(n - 1) >= k) {
            System.out.println("POSSIBLE");
            return;
        }
        System.out.println("IMPOSSIBLE");
    }
    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 53308
from collections import Counter

N = int(input())
V = list(map(int,input().split()))

E = list(Counter(V[0::2]).most_common())
O = list(Counter(V[1::2]).most_common())
E.append((10001,0))
O.append((10002,0))

if E[0][0] != O[0][0]:
    print(N - E[0][1] - O[0][1])
else:
    print(min([N - E[0][1] - O[1][1],N - E[1][1] - O[0][1]]))

Measured memory_bytes: 20700
<?php
$input = fgets(STDIN);
$arr = str_split(strval($input));
$str = "";
foreach($arr as $value) {
  if ($value === "B") {
    if (strlen($str) > 1) {
      $str = substr($str, 0, strlen($str) - 1);
    } else {
      $str = "";
    }
  } else {
    $str .= $value;
  }
}
echo $str;

Measured memory_bytes: 4984
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl '\n'
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	Think of a solution that gets TLE and optimize it
//	Use binary search
//	Solve on paper first

int main()
{
    cin.tie(nullptr); ios_base::sync_with_stdio(0);
    ll x, k, d;
    cin >> x >> k >> d;
    bool pos = x >= 0;
    ll m = min(k, llabs(x / d));
    if(pos)
    	x -= m * d;
    else
    	x += m * d;
    k -= m;
    if(k)
    {
    	if(k & 1)
    	{
    		if(pos)
    			x = d - x;
    		else
    			x += d;
    	}
    }
    cout << llabs(x);
}


Measured memory_bytes: 3632
/*
dp[i][j] = length of the longest common subsequence in s[i, i+1, .... s.size()-1] and t[j, j+1, ..... t.size()-1]
*/

#include <bits/stdc++.h>

using namespace std;

int main(){
	string s, t;
	int n, m;
	vector<vector<int> > dp;
	cin>>s;
	cin>>t;
	n = s.size();
	m = t.size();
	dp.assign(n+1, vector<int>(m+1, 0));

	for(int i=n-1;i>=0;i--){
		for(int j=m-1;j>=0;j--){
			if(s[i] == t[j])
				dp[i][j] = dp[i+1][j+1]+1;
			else
				dp[i][j] = max(dp[i][j+1], dp[i+1][j]);
		}
	}
	
	//cout<<dp[0][0]<<"\n";
	
	int curr_i = 0, curr_j = 0;
	while(curr_i < n && curr_j < m){
		if(s[curr_i] == t[curr_j]){
			cout<<s[curr_i];
			curr_i++; curr_j++;
		}
		else if(dp[curr_i+1][curr_j] > dp[curr_i][curr_j+1])
			curr_i++;
		else
			curr_j++;
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define inf 2e9
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define LL long long
using namespace std;
int n;
bool ok;
int main(){
	cin>>n;
	bool ok=false;
	for (int i=0;i*4<=n;i++)
	for (int j=0;j*7<=n;j++)
	if (i*4+j*7==n){
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
	return 0;
}

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if((0 <= (x - r) && (x + r) <= W) && (0 <= (y - r) && (y + r) <= H)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
//論理演算より(不)等価演算が先に計算される


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

typedef long long ll;
int main(){
  int n,k;
  cin >> n>>k;
  ll ans=1;
  n=max(0,n-k);
  k--;
  ans+=ceil(n*1.0/k);
  cout<<ans<<endl;
}
    
    


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

int main(){
char c;
cin >> c;
if(c == 'A') cout << "T" << endl;
else if(c == 'T') cout << "A" << endl;
else if(c == 'C') cout << "G" << endl; 
else if(c == 'G') cout << "C" << endl; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    long int n,a,b;
    cin >> n;
    cin >> a;
    cin >> b;

    long int syou,amari,res;

    if (a == 0)
    {
        cout << 0 << endl;
    } else if (b == 0)
    {
        cout << n << endl;
    } else
    {
        syou = n / (a+b);
        res = syou * a;

        amari = n % (a+b);
        if (amari <= a)
        {
            res = res + amari;
        } else
        {
            res = res + a;
        }
        cout << res << endl;
    }

    return 0;
}

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

int main() {
  int N;
  int num = 0;
  vector<int> a(N);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  for (int i = 0; i < (N+1)/2; i++) {
    if (a.at(2*i) % 2 == 1) {
      num++;
    }
  }
  
  cout << num << endl;
}

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

/* Defines begin */
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL) , cout.tie(NULL);
#define w1 solve();
#define pb push_back
#define mp make_pair
#define double long double
#define fi first 
#define se second
#define all(a) (a).begin(),(a).end()
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FOR2(I,A,B) for(ll I = (A); I <= (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define random (rand()<<16|rand())
#define sqr(x) (x)*(x)
#define base complex<double>
#define LOCAL
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
/* Defines end */

/* Constants begin */
const long long int inf = 2e18 + 7;
const long long int mod = 1e9 + 7;
const double eps = 1e-7;
const double PI = 2*acos(0.0);
const double E = 2.71828;
/* Constants end */

/* Typedef begin */
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
/* Typedef end */

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
}



void solve()
{
    string s;
    cin >> s;
    ll n = s.size();
    bool flag = false;
    for(int i = 0; i < n; ++i)
    {
	    if(s[i] >= 'A' && s[i] <= 'Z')
            s[i] = s[i] - 'A' + 'a';
		    
    }
	
	
	if(s[n - 1] == 's' )
		cout << s << "es" << "\n";
	else 
		cout << s << "s" << "\n";

}



 
 
auto main() -> int
{
	fastio
	w1
	return 0;
}


Measured memory_bytes: 3664
// 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
using namespace std;
using namespace std::chrono;

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;
}



Vi g[200100];
bool visited[200100];

int dfs(int v, int par = -1){
  visited[v] = true;
  int cnt = 1;
  for (auto item: g[v])
    if (item != par and not visited[item])
      cnt += dfs(item, v);
  return cnt;
}


bool red[200100];

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R')
      red[i] = true;
  int w = 0, r = n - 1;
  int cnt = 0;
  while (w < r){
    while (red[w])
      w++;
    while (not red[r])
      r--;
    if (w < r)
      cnt++, w++, r--;
  }
  cout << cnt << endl;

}


Measured memory_bytes: 8688
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k;
	ll x,y;
	cin>>x>>y;
	if(x%y==0)
		printf("-1\n");
	else
		printf("%lld\n",x );
	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<vector<Pll>>;
Graph g, rg;
ll N, M, P;
Vl dist;
Vi check1, check2;

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif

    cin >> N >> M >> P;
    g.resize(N);
    rg.resize(N);
    for (ll i = 0; i < M; i++) {
        ll ai, bi, ci;
        cin >> ai >> bi >> ci;
        --ai, --bi;
        g[ai].emplace_back(bi, P - ci);
        rg[bi].emplace_back(ai, P - ci);
    }

    check1.assign(N, 0);
    check2.assign(N, 0);

    queue<int> q;
    q.emplace(0);
    check1[0] = 1;
    while (!q.empty()) {
        int idx = q.front();
        q.pop();
        for (const auto& edge : g[idx]) {
            ll to = edge.first;
            if (check1[to]) continue;
            q.emplace(to);
            check1[to] = 1;
        }
    }

    q.emplace(N - 1);
    check2[N - 1] = 1;
    while (!q.empty()) {
        int idx = q.front();
        q.pop();
        for (const auto& edge : rg[idx]) {
            ll to = edge.first;
            if (check2[to]) continue;
            q.emplace(to);
            check2[to] = 1;
        }
    }

    dist.assign(N, L_INF);

    dist[0] = 0;
    bool update;
    for (ll _ = 0; _ < N; _++) {
        update = false;
        for (ll i = 0; i < N; i++) {
            if (!(check1[i] && check2[i])) continue;
            for (const auto& edge : g[i]) {
                ll to, c;
                tie(to, c) = edge;
                if (!(check1[to] && check2[to])) continue;
                if (dist[i] != L_INF && dist[to] > dist[i] + c) {
                    dist[to] = dist[i] + c;
                    update = true;
                }
            }
        }
    }

    if (update) {
        cout << -1 << endl;
    }
    else {
        cout << max(-dist[N - 1], 0LL) << endl;
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  int x;
  cin >> x;
  while(true) {
    bool prime = true;
    rep2(j, 2, sqrt(x) + 1) {
      if(x % j == 0) {
        prime = false;
        break;
      }
    }
    if(prime) {
      cout << x << endl;
      return 0;
    }
    x++;
  }
}

Measured memory_bytes: 256
/**
 *      ABC 101 C
 *      author  : kyomukyomupurin
 *      created : 2018/08/24
**/

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

int main(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while (n > 1){
        n -= k;
        ++n;
        ++cnt;
    }
    cout << cnt << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;	//x, y

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

int t, n;
int x[300], y[300];
int sx, sy;
bool isOk[150][150];
int cost[150][150];

void bfs() {
	queue<P> que;
	que.push(P(sx, sy));
	cost[sx][sy] = 0;
	
	while (!que.empty()) {
		P now = que.front(); que.pop();
		int x = now.first;
		int y = now.second;
		if (cost[x][y] == t) continue;
		
		for (int i = 0; i < 6; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (isOk[nx][ny] && cost[nx][ny] > cost[x][y] + 1) {
				cost[nx][ny] = cost[x][y] + 1;
				que.push(P(nx, ny));
			}
		}
	}
}

int main() {
	while (cin >> t >> n) {
		if (!t) break;
		for (int i = 0; i < 150; i++) {
			for (int j = 0; j < 150; j++) {
				cost[i][j] = 114514;
				isOk[i][j] = true;
			}
		}
		
		for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
		cin >> sx >> sy;
		
		//?????¢
		for (int i = 0; i < n; i++) { x[i] += 70; }
		for (int i = 0; i < n; i++) { y[i] += 70; }
		sx += 70;
		sy += 70;
		for (int i = 0; i < n; i++) { isOk[x[i]][y[i]] = false; }
		
		bfs();
		
		int ans = 0;
		for (int i = 0; i < 150; i++) {
			for (int j = 0; j < 150; j++) {
				if (cost[i][j] <= t) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 

int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}

int32_t main()
{
	fast;
	int m1, d1, m2, d2;
  	cin>>m1>>d1>>m2>>d2;
  	if(m1==m2)
      cout<<0<<endl;
  	else
      cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, W = sc.nextInt()
    val w, v = new Array[Int](N)
    for (i <- 0 until N) {
      w(i) = sc.nextInt()
      v(i) = sc.nextInt()
    }

    val INF = Int.MaxValue
    val VMAX = 100000
    val dp = Array.fill(N+1, VMAX+1)(INF)
    // dp[i][j] := i品目まで選んだ時の価値の総和がjの時の重さの総和
    dp(0)(0) = 0
    for {
      i <- 0 until N
      j <- 0 to (VMAX - v(i))
    } {
      if (dp(i)(j) != INF && dp(i)(j) + w(i) <= W)
        dp(i+1)(j+v(i)) = dp(i+1)(j+v(i)) min (dp(i)(j) + w(i))
      dp(i+1)(j) = dp(i+1)(j) min dp(i)(j)
    }

    println(dp(N).indices.filter(v => dp(N)(v) != INF).max)
  }

}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<pair<int, int>> vp;

const int INF = 1000000000;
const int MOD = 1000000007;

vector<vector<int>> edge;
vector<bool> flg;

void dfs(int node) {
    if (flg[node]) return;
    flg[node] = true;
    for (auto i : edge[node]) dfs(i);
}

int main () {
    int N, M;
    cin >> N >> M;

    edge.resize(N);
    rep(i, M) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X--, Y--;

        edge[X].push_back(Y);
        edge[Y].push_back(X);
    }

    int ans = 0;
    flg.resize(N, false);
    rep(i, edge.size()) {
        if (!flg[i]) ans++;
        dfs(i);
    }
    cout << ans << endl;
}


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

using namespace std;

int main(int argc, char* argv[])
{
  vector<int> cnt(3);
  for (int i = 0; i < 3; i++) {
    cin >> cnt[i];
  }

  int K; cin >> K;

  vector<unsigned long> cake[3];

  cin.exceptions(ios::failbit);

 for (int i = 0; i < 3; i++) {
    for (int j = 0; j < cnt[i]; j++) {
      unsigned long c;
      try {
	cin >> c;
      }
      catch (...) {
	cout << "exception" << endl;
	cin.clear();
      }
      cake[i].push_back(c);
    }
    sort(cake[i].begin(), cake[i].end(), greater<unsigned long>());
  }

 unsigned short isDone[3000] = {0};
  
  priority_queue<tuple<unsigned long, unsigned short, unsigned short, unsigned short> > que;
  que.push(make_tuple(cake[0][0] + cake[1][0] + cake[2][0], 0, 0, 0));
  
  set<tuple<unsigned short, unsigned short, unsigned short> > sDone;
  sDone.insert(make_tuple(0, 0, 0));
  
  for (int k = 0; k < K && !que.empty(); k++) {
    tuple<unsigned long, unsigned short, unsigned short, unsigned short> t = que.top(); que.pop();
    unsigned short cur_a = get<1>(t);     
    unsigned short cur_b = get<2>(t);
    unsigned short cur_c = get<3>(t);

    cout << get<unsigned long>(t) << endl;

    if (cur_a+1 < cnt[0] && sDone.find(make_tuple(cur_a+1,cur_b,cur_c)) == sDone.end()) {
      que.push(make_tuple(cake[0][cur_a+1] + cake[1][cur_b] + cake[2][cur_c], cur_a+1, cur_b, cur_c));
      sDone.insert(make_tuple(cur_a+1,cur_b,cur_c));
    }
    if (cur_b+1 < cnt[1] && sDone.find(make_tuple(cur_a,cur_b+1,cur_c)) == sDone.end()) {
      que.push(make_tuple(cake[0][cur_a] + cake[1][cur_b+1] + cake[2][cur_c], cur_a, cur_b+1, cur_c));
      sDone.insert(make_tuple(cur_a,cur_b+1,cur_c));
    }
    if (cur_c+1 < cnt[2] && sDone.find(make_tuple(cur_a,cur_b,cur_c+1)) == sDone.end()) {
      que.push(make_tuple(cake[0][cur_a] + cake[1][cur_b] + cake[2][cur_c+1], cur_a, cur_b, cur_c+1));
      sDone.insert(make_tuple(cur_a,cur_b,cur_c+1));
    }
  }

  return 0;
}


Measured memory_bytes: 768
#import<cstdio>
#import<map>
#define I(M,A)for(i=0;i<M;i++)scanf("%d",&x),A[i+1]=A[i]+x;
main(){for(int n[1501],m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){std::map<int,int>z;n[0]=m[0]=o=0;I(a,n)I(b,m)for(i=0;i<=a;i++)for(j=0;j<=b;j++)z[n[i]+m[j]]++;for(std::map<int,int>::iterator p=z.begin();p!=z.end();p++)o+=(p->second)*((p->second)-1)/2;}}

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

struct Seg {
    int l, r, type, query_idx;
    Seg() {}
    Seg(int a, int b, int c, int idx = -1) : l(a), r(b), type(c), query_idx(idx) {}
    bool operator<(const Seg &s) const {
        if(r != s.r) return r < s.r;

        // 質問が後に来るようにする
        return type < s.type;
    }
};

const int SIZE = 1 << 17;
struct SegmentTree {
    int node[SIZE*2];
    SegmentTree() { fill(node, node+SIZE*2, 0); }
    void update(int k, int val) {
        k += SIZE - 1;
        node[k] += val;
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    int count(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = count(a, b, l, mid, 2*k+1);
        int vr = count(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

SegmentTree treeone;
int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<Seg> segs;
    for(int i=0; i<M; i++) {
        int l, r; cin >> l >> r;
        segs.push_back(Seg(l, r, 0));
    }

    for(int i=0; i<Q; i++) {
        int l, r; cin >> l >> r;
        segs.push_back(Seg(l, r, 1, i));
    }

    sort(segs.begin(), segs.end());
    vector<int> ans(Q);
    for(int i=0; i<M+Q; i++) {
        if(segs[i].type == 0) {
            treeone.update(segs[i].l, 1);
            cerr << "# debug: " << segs[i].l << endl;
        }
        else {
            ans[ segs[i].query_idx ] = treeone.count(segs[i].l, segs[i].r + 1);
        }
    }

    for(int i=0; i<Q; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11628
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] A = new int[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        A[i][j]=sc.nextInt();
      }
    }
    int N = sc.nextInt();
    for(int n=0;n<N;n++){
      int p = sc.nextInt();
      for(int i=0;i<3;i++){
      	for(int j=0;j<3;j++){
        	if(p==A[i][j]){
              A[i][j]=0;
            }
      	}
      }
    }
    String ans = "No";
    for(int i=0;i<3;i++){
      if(A[i][0]==0 && A[i][1]==0 && A[i][2]==0){
        ans = "Yes";
      }
    }
    for(int j=0;j<3;j++){
      if(A[0][j]==0 && A[1][j]==0 && A[2][j]==0){
        ans = "Yes";
      }
    }
    if((A[0][0]==0 && A[1][1]==0 && A[2][2]==0) || (A[0][2]==0 && A[1][1]==0 && A[2][0]==0)){
       ans = "Yes";
    }
      System.out.println(ans);
  }
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define ll long long int
#define INF 1e9+7
using namespace std;
int main()
{ ll n,i,j,k;
cin>>n>>k;	
int a[n+1];
for(i=1;i<=n;i++) cin>>a[i];
int dp[n+1];
for(i=0;i<=n;i++) dp[i]=INF;
 dp[1]=0;
 for(i=1;i<=n;i++)
 { for(j=i+1;j<=i+k;j++)
 { if(j<=n) {
 	dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
 }
 }
 }	
	
cout<<dp[n];
	
}

Measured memory_bytes: 4400
n = int(input())
cnt = 0

for i in range(n):
    x = int(input())
    rt_x = int(pow(x,1/2)) +1
    flag = 1
    for j in range(2,rt_x):
        if x%j==0:
            flag = 0
            break
    cnt += flag
print(cnt)


Measured memory_bytes: 5688
#include <iostream>

using namespace std;

int main(){
  int a;
  cin >> a;
  int counter = 0;
  int ans = 0;

  for(int i = 1; i <= a; i++){
    counter = 0;
    if(i%2 == 0) continue;
    for(int j = 1; j <= i; j++){
      if(i%j == 0) {
        // cout << i << ' ' << j << endl;
        counter += 1;
      }
    }

    if(counter == 8) ans += 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(raw_input())
A = []
for i in xrange(N):
    A.append(int(raw_input()))
A = np.array(A)
num_pair = (A[A % 2 == 1] / 2).sum()
A[A % 2 == 1] = 1
num_pair += (A[A > 2] / 2).sum() - (A > 2).sum()
A[A > 2] = 2
for i in xrange(len(A) - 1):
    if A[i] == 2:
        num_pair += 1
        A[i] = 0
    elif A[i] == 1 and A[i + 1] >= 1:
        num_pair += 1
        A[i] = 0
        A[i + 1] -= 1
num_pair += A[-1] / 2
print num_pair


Measured memory_bytes: 16144
#include<stdio.h>

int main(void){
  
  int time[5],time_quo[5],time_TT[5]; //TT is Total Time
  int i,digit_one,min,TT_sum = 0;
  
  for(i = 0;i < 5;i++){
    scanf("%d",&time[i]);
    time_quo[i] = time[i] % 10;
    if(time[i] % 10 == 0){
      time_TT[i] = time[i];
    }else{
      time_TT[i] = ((time[i] / 10) + 1) * 10;
    }
  }
  
  for(i = 0;i < 5;i++){
    TT_sum += time_TT[i];
  }
  
  min = time_quo[0];
  for(i = 1;i < 5;i++){
    if(min > time_quo[i] && time_quo[i] != 0){
      min = time_quo[i];
    }
  }

  if(min == 0){
    digit_one = 0;
  }else{
    digit_one = 10 - min;
  }
  
  printf("%d",TT_sum - digit_one);
  return 0;
}

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

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
    string s;
    int k;
    cin>>k>>s;
    if(s.size()<=k){
        cout<<s<<'\n';
    }else{
        string ss=s.substr(0,k);
        ss+="...";
        cout<<ss<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void) {
  int b, r, g, c, s, t, medal;

  while (1) {
    scanf("%d %d %d %d %d %d", &b, &r, &g, &c, &s, &t);
    if (t == 0) break;

    medal = 100;
    medal -= (b * 5 + r * 3) * 2 + (t - (b * 5 + r * 3)) * 3;
    
    medal += b * 15;
    medal += b * 5 * 15;

    medal += r * 15;
    medal += r * 3 * 15;

    medal += g * 7;

    medal += c * 2;

    medal += s * 3;



    printf("%d\n", medal);
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> s = nextCharArray();
		int output = 700;
		for(int i = 0; i < s.size(); i++){
			output += (s.get(i).equals("o")) ? 100 : 0;
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33212
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    String[] S = new String[H];
    for(int i=0;i<H;i++){
      S[i] = sc.next();
    }
    char[][] array = new char[H+2][W+2];
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        array[i+1][j+1] = S[i].charAt(j);
      }
    }
    for(int i = 1; i <= H; i++){
      for(int j = 1; j <= W; j++){
        int count = 0;
        if(array[i][j] == '#'){
          System.out.print('#');
        }else if(array[i][j] != '#'){
          if(array[i-1][j-1] == '#'){
            count++;
          }
          if(array[i-1][j] == '#'){
            count++;
          }
          if(array[i-1][j+1] == '#'){
            count++;
          }
          if(array[i][j-1] == '#'){
            count++;
          }
          if(array[i][j+1] == '#'){
            count++;
          }
          if(array[i+1][j-1] == '#'){
            count++;
          }
          if(array[i+1][j] == '#'){
            count++;
          }
          if(array[i+1][j+1] == '#'){
            count++;
          }
          System.out.print(count);
        }
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 22356
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut ab: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            let a: usize = sc.read();
            let b: usize = sc.read();
            (a, b)
        })
        .collect();
    ab.sort();
    let mut heap = std::collections::BinaryHeap::new();
    let mut idx = 0;
    let mut result = 0;
    for i in 0..m {
        while idx < n && ab[idx].0 <= i + 1 {
            heap.push(ab[idx].1);
            idx += 1;
        }
        if let Some(res) = heap.pop() {
            result += res;
        }
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12668
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a)
{
    return (a*a*a*a*a);
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   map<ll,ll> ma;
   ma[arr[0]]++;
   ll ans = 0;
   for(ll i=1;i<n;i++)
   {
       ll curr = (-arr[i] + i);
       ans+=ma[curr];
       ma[arr[i]+i]++;
   }
   cout<<ans;
   
   return 0;        
}  
  
   

Measured memory_bytes: 27892
n,*z=`dd`.split.map &:to_i
t=(e=[*0...n]).dup
f=->a{a.size.times.map{|i|a[t[i]]}}
a=z.shift n+1
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(k%2>0&&e=f[e];t=f[t];k/=2)while k>0
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 73248