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

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		int X = sc.nextInt();
		int N = sc.nextInt();
		boolean[] able = new boolean[201];
		Arrays.fill(able, true);
		for(int i = 0; i < N; i++) {
			int p = sc.nextInt();
			able[p] = false;
		}
		for(int i = 0; i <= 100; i++) {
			if(able[X-i]) {
				System.out.println(X-i);
				return;
			}
			if(able[X+i]) {
				System.out.println(X+i);
				return;
			}
		}
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 35768
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
  int id;
  struct node *pre;
  struct node *next;
} *nodePointer;
nodePointer START;
nodePointer END;
nodePointer cursol;
void init();
void insert(int);
void move(int);
void erase(void);
void printNode(void);
nodePointer make1node(void);
int main(void)
{
  int i,q,x1,x2;
  init();
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&x1);
      switch(x1)
        {
        case 0:
          scanf("%d",&x2);
          insert(x2);
          break;
        case 1:
          scanf("%d",&x2);
          move(x2);
          break;
        case 2:
          erase();
          break;
        }
    }
  printNode();
  return 0;
}
void init(void)
{
  START=make1node();
  END=make1node();
  START->pre=NULL;
  START->next=END;
  END->pre=START;
  END->next=NULL;
  cursol=END;
}
void insert(int x)
{
  nodePointer p=make1node();
  p->id=x;
  p->pre=cursol->pre;
  p->next=p->pre->next;
  p->pre->next=p;
  p->next->pre=p;
  cursol=p;
}
void move(int p)
{
  int i;
  if(p>0)
    {
      for(i=0;i<p;i++) cursol=cursol->next;
    }
  else if(p<0)
    {
      p*=-1;
      for(i=0;i<p;i++) cursol=cursol->pre;
    }
}
void erase(void)
{
  cursol->pre->next=cursol->next;
  cursol->next->pre=cursol->pre;
  cursol=cursol->next;
}
void printNode(void)
{
  nodePointer p;
  for(p=START->next;p->next!=NULL;p=p->next) printf("%d\n",p->id);
}
nodePointer make1node(void)
{
  nodePointer p=(nodePointer)malloc(sizeof(struct node));
  return p;
}


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

n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
C = [list(map(int, input().split())) for _ in range(m)]
for a in A:
    dis = 10**100
    ans = None
    for i in range(len(C)):
        c = C[i]
        if abs(a[0]-c[0])+abs(a[1]-c[1]) < dis:
            dis = abs(a[0]-c[0])+abs(a[1]-c[1])
            ans = i + 1
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;

int main()
{
    int n; cin >> n;
    pii a[n];
    FOR(i, n, 0)
    {
        int x; cin >> x;
        a[i] = {x, i};
    }
    sort(a, a + n);
    FOR(i, n, 0)cout << a[i].s + 1 << ' ';
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e9 + 7;
ll h,n;
ll a[10001],b[10001];
ll dp[10001];
int main()
{
    cin >> h >> n;
    for(int i = 1;i <= n;i ++)
        cin >> a[i] >> b[i];
    memset(dp,N,sizeof dp);
    dp[0] = 0;
    for(int i = 0;i <= n;i ++)
    {
        for(int j = 0;j <= h;j ++)
        {
            if(j + a[i] >= h) dp[h] = min(dp[h],dp[j] + b[i]);
            else dp[j + a[i]] = min(dp[j + a[i]],dp[j] + b[i]);
        }
    }
    cout << dp[h] ;
    return 0;
}


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

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<long long> a(x), b(y), c(z);
    for(int i = 0; i < x; i++)
    {
        cin >> a.at(i);
    }
    for(int i = 0; i < y; i++)
    {
        cin >> b.at(i);
    }
    for(int i = 0; i < z; i++)
    {
        cin >> c.at(i);
    }
    
    vector<long long> ab;
    for(int i = 0; i < x; i++)
    {
        for(int j = 0; j < y; j++)
        {
            ab.push_back(a.at(i) + b.at(j));
            
        }
        
    }

    sort(ab.begin(), ab.end());
    vector<long long> abc;
    for(int i = 0; i < min((int)ab.size(), k); i++)
    {
        for(int j = 0; j < z; j++)
        {
            abc.push_back(ab.at((int)ab.size() - 1 - i) + c.at(j));
        }
        
    }
    
    sort(abc.begin(), abc.end());
    
    for(int i = 0; i < k; i++) {
        cout << abc.at((int)abc.size() - i - 1) << endl;    
    }
    
}

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

using namespace std;

int K, X;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> K >> X;
    
    int minVal = max(-100000, X-K+1);
    int maxVal = min(100000, X+K-1);
    
    for (int i = minVal; i <= maxVal; i++) {
        cout << i << ' ';
    }
    cout << endl;
    
    return 0;
}



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

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int n = scanner.nextInt();
        double[] array = new double[n];

        for(int i=0;i<n;i++) {
        	array[i] = scanner.nextDouble();
        }
        Arrays.sort(array);

        double tmp = 0;
        for(int i=0;i<n;i++) {
        	if(i==0) {
        		tmp = array[i];
        	}else {
        		tmp = (tmp + array[i])/2;
        	}
        }
        System.out.println(tmp);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int a[55], i;
	memset(a, 0, sizeof(a));
	int n, m, t1, t2;
	cin >>n>>m;
	n;
	for(i = 0; i < m; i++)
	{
		cin >> t1 >> t2;
		a[t1]++;
		a[t2]++;
	}
	for(i = 1; i <= n; i++)
		cout<<a[i]<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  if(s == "Sunny")  cout << "Cloudy" << endl;
  if(s == "Cloudy")  cout << "Rainy" << endl;
  if(s == "Rainy")  cout << "Sunny" << endl;
  return 0;
}


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

int main(){

        string s;
        cin >> s;


        if(s=="Sunny"){
                cout << "Cloudy";
        }
        if(s=="Cloudy"){
                cout << "Rainy";
        }
        if(s=="Rainy"){
                cout << "Sunny";
        }



        return 0;
}


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

#define int long long

int32_t main(){
	string s ;
	cin >> s ;
	int cnt = 0 ;
	for(auto i : s){
		cnt += i - '0' ;
	}
	cout << ( cnt % 9 ? "No" : "Yes") ;
	return 0 ;
}



Measured memory_bytes: 3748
#include <iostream>
#include <map>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::map<int, i64> cnt;
    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        ret += cnt[i - a];
        cnt[a + i]++;
    }

    std::cout << ret << std::endl;

    return 0;
}


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

typedef long long int ll;

int main()
{
    int n;
    cin>>n;
    map<int, int> mmap;

    for(int i=0;i<n-1;i++)
    {
        int var;
        cin>>var;

        mmap[var]++;
    }

    for(int i=1;i<n+1;i++)
    {
        cout<<mmap[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 13004
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        char[] ch = sc.next().toCharArray();
        final int N = ch.length;
        String ans = "No";
        
        for (int i = 0; i < N - 2; i++) {
            if (ch[i] == ch[i + 1] && ch[i + 1] == ch[i + 2]) {
                ans = "Yes";
            }
        }
        
        out.println(ans);

        out.flush();
    }
}
// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	l := []byte(s)
	var cindex, findex int
	cindex = 101
	var cin, fin bool
	for i, p := range l {
		if p == 'C' {
			cin = true
			cindex = min(cindex, i)
		}
		if p == 'F' {
			fin = true
			findex = max(findex, i)
		}
	}
	//fmt.Println(cin, fin, cindex, findex)
	if cin && fin && (cindex < findex) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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


Measured memory_bytes: 512
import numpy as np
N, M = list(map(int, input().split()))
Modulo = 2019
MAP = np.dot(np.arange(Modulo).reshape(Modulo, 1), np.arange(Modulo).reshape(1, Modulo))
MAP %= Modulo
iu2 = np.tril_indices(Modulo, k=0)
MAP[iu2] = Modulo
if M - N >= 2019:
  print(0)
else:
  fir = N % Modulo
  sec = M % Modulo
  if sec > fir:
    print(np.min(MAP[fir:sec+1, fir:sec+1]))
  elif fir > sec:
    print(min([np.min(MAP[:sec+1, :sec+1]),
               np.min(MAP[fir:Modulo, fir:Modulo]),
               np.min(MAP[:sec+1, fir:Modulo])]))
  

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

int main()
{
  int n, x, m, w_sum=0, w_min=1<<30;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> m;
    w_sum += m;
    if (m < w_min) w_min = m;
  }
  int res = n + (x - w_sum) / w_min;
  cout << res << endl;
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  string s;cin>>s;
  int ans = 0;
  for(int i = 0; s.size()/2 > i; i++){
    if(s[i]!=s[s.size()-1-i])ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np 

I = np.array(sys.stdin.read().split(), dtype=np.int64)
a = I[1:]

def main():
    res = np.bincount(a)
    ans = np.count_nonzero(res)
    res = np.maximum(0, res - 1)
    ans -= (np.sum(res) & 1)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 21544
str = input()
cnt = 700
if str[0]=="o" and str[1]=="o" and str[2]=="o":
  cnt = 1000
elif (str[0]=="o" and str[1]=="o") or (str[1]=="o" and str[2]=="o") or(str[0]=="o" and str[2]=="o"):
  cnt = 900
elif str[0]=="o" or str[1]=="o" or str[2]=="o":
  cnt = 800
print(cnt)

Measured memory_bytes: 9048
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int num = sc.nextInt();

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(num * a >= b) System.out.println(b);
        else System.out.println(num * a);
    }
}

Measured memory_bytes: 23636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
bool flg[60000];

int main() {
	memset(flg, 1, sizeof(flg));
	flg[1] = 0;
	for(int i = 2; i <= 55555; i++) {
		for(int j = 2; j <= sqrt(i); j++) {
			if(i % j == 0) {
				flg[i] = 0;
				break;
			}
		}
	}
	flg[2] = 0;
	//for(int i = 1; i <= 100; i++) if(flg[i]) printf("%d ", i);
	scanf("%d", &n);
	for(int i = 1; i <= 55555; i++) {
		if(n == 0) break;
		if(flg[i] && i % 10 == 1) {
			printf("%d ", i);
			n--;
		}
	}
	printf("\n");
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

class Combination{
public:
    int N;
    ll mod;
    vector<ll> fact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1){
        fact[0] = 1;
        for(ll i=1; i<=N; i++){
            fact[i] = i * fact[i-1] % mod;
        }
    }

    ll POW(ll a, ll b){
        ll res = 1;
        while(b > 0){
            if(b & 1){
                res = res * a % mod;
            }
            a = a * a % mod;
            b >>= 1;
        }
        return res;
    }

    ll combin(int n, int k){
        if(n < 0 || k < 0 || n < k){
            return 1;
        }
        return fact[n] * POW(fact[k] * fact[n-k] % mod, mod - 2) % mod;
    }

    ll moddiv(ll a, ll b){
        return a % mod * POW(b % mod, mod - 2) % mod;
    }
};

signed main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    vector<ll> dist(n);
    REP(i, n-1){
        dist[i+1] = v[i+1] - v[i];
    }

    vector<ll> dp(n, 0LL);
    Combination C(n, MOD);

    for(ll i = 1; i < n; i++){
        dp[i] = dp[i-1] + C.moddiv(C.fact[n-1], i);
        dp[i] %= MOD;
    }


    ll ans = 0;
    FOR(i, 1, n){
        ans += dp[i] * dist[i] % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
S = gets.chomp.chars.map(&:to_i).reverse
P10 = Array.new(S.size, 1)
dp = Array.new(2020, 0)
ans = 0

dp[0] = 1
dp[S[0]] = 1

(1 ... S.size).inject(S[0]) do |mod, i|
  P10[i] = (P10[i - 1] * 10) % 2019
  m = ((S[i] * P10[i] + mod) % 2019)
  ans += dp[m]
  dp[m] += 1
  m
end
puts ans

Measured memory_bytes: 29704
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll A, B, C, K;
	std::cin >> A >> B >> C >> K;

	ll ans = 0;
	ans += min(A, K);
	K -= min(A, K);
	K -= min(B, K);
	ans -= min(C, K);
	K -= min(C, K);

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3584
// ???#include <bits/stdc++.h>
#include <iostream>

// #define MP make_pair
// #define PB push_back
// #define ALL(x)  (x).begin(),(x).end()
// #define RALL(x) (x).rbegin(),(x).rend()
// #define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
// #define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
// #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, init, N)  for (int i = (init); i < (int)(N); i++)
// #define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
// #define PB push_back

using namespace std;

// typedef long long LL;
// typedef unsigned long long ULL;
// typedef vector<int> VI;
// typedef vector<VI > VVi;
// typedef vector<string> VS;
// typedef vector<LL> VLL;
// typedef pair<int,int> PII;

// const int    INF  = 0x3f3f3f3f;
// const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
// const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int sum=0;
    int x;
    int cnt=0;
    while(1){
        cin>>x;
        if(!x)
            return 0;
        sum=1000-x;
        while(sum>0){
            if(sum>=500){
                cnt++;
                sum-=500;
            }
            else if(sum>=100){
                cnt++;
                sum-=100;
            }
            else if(sum>=50){
                cnt++;
                sum-=50;
            }
            else if(sum>=10){
                cnt++;
                sum-=10;
            }
            else if(sum>=5){
                cnt++;
                sum-=5;
            }
            else{
                cnt++;
                sum-=1;
            }
        }
        cout<<cnt<<endl;
        cnt=0;
    }


    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

string L;

const int MAX_N = 100005;

int dp[MAX_N][2][2];

signed main()
{
  cin >> L;

  dp[0][0][0] = 1;

  REP(n,L.size()) {
    if(L[n] == '0') {
      dp[n+1][0][0] = (dp[n][0][0]*1 + dp[n][0][1]*0) % MOD;
      dp[n+1][0][1] = (dp[n][0][0]*0 + dp[n][0][1]*2) % MOD;

      dp[n+1][1][0] = (dp[n][0][0]*0 + dp[n][0][1]*0 + dp[n][1][0]*3 + dp[n][1][1]*0) % MOD;
      dp[n+1][1][1] = (dp[n][0][0]*0 + dp[n][0][1]*0 + dp[n][1][0]*1 + dp[n][1][1]*2) % MOD;
    } else { // 1
      dp[n+1][0][0] = (dp[n][0][0]*2 + dp[n][0][1]*0) % MOD;
      dp[n+1][0][1] = (dp[n][0][0]*1 + dp[n][0][1]*0) % MOD;

      dp[n+1][1][0] = (dp[n][0][0]*1 + dp[n][0][1]*0 + dp[n][1][0]*3 + dp[n][1][1]*0) % MOD;
      dp[n+1][1][1] = (dp[n][0][0]*0 + dp[n][0][1]*2 + dp[n][1][0]*1 + dp[n][1][1]*2) % MOD;
    }
  }

  cout << (dp[L.size()][0][0] + dp[L.size()][1][0]) % MOD << endl;

  return 0;
}

Measured memory_bytes: 3584
import sys
fin = sys.stdin.readline


N, W = [int(elem) for elem in fin().split()]
weight_value_pairs = tuple(tuple(int(elem) for elem in fin().split()) for _ in range(N))

dp = [0] * (W + 1)
for i in range(N):
    w, v = weight_value_pairs[i]
    for j in reversed(range(W + 1)):
        if j - w >= 0:
            dp[j] = max(dp[j], dp[j - w] + v)

print(max(dp))


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

using namespace std;
int l;
bool judge( string & s){
	string temp = s;
	reverse(temp.begin(),temp.end());
	return temp == s;
}

int main(){
	string ss;
	cin>>ss;
	string a="";
	string b="";
	l = ss.length();
	for(int i=0;i<(l-1)/2;i++){
		a+=ss[i];
	}
	for(int i=(l+3)/2-1;i<l;i++){
		b+=ss[i];
	}
	if(judge(ss)){
	   if(judge(a)&&judge(b)){
	   	cout<<"Yes"<<endl;
	   }
	   else{
	   	cout<<"No"<<endl;
	   }
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int main() {
  int d,n;
  cin >> d >> n;
  
  int cnt = 0, num = 1, ans;
  while(cnt != n) {
    ans = num;
    int cnt2 = 0;
    while(num % 100 == 0) {
      num /= 100;
      cnt2++;
    }
    if(cnt2 == d) cnt++;
    
    num = ans + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
while gets
  w=$_.to_f
  case
  when w<=48
    puts "light fly"
  when (48<w and w<=51)
    puts "fly"
  when (51<w and w<=54)
    puts "bantam"
  when (54<w and w<=57)
    puts "feather"
  when (57<w and w<=60)
    puts "light"
  when (60<w and w<=64)
    puts "light welter"
  when (64<w and w<=69)
    puts "welter"
  when (69<w and w<=75)
    puts "light middle"
  when (75<w and w<=81)
    puts "middle"
  when (81<w and w<=91)
    puts "light heavy"
  when 91<w
    puts "heavy"
  end
end

Measured memory_bytes: 8664
package main

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

const (
	MAX      = 100000
	SENTINEL = 20000000000
)

type Card struct {
	Suit  string
	Value int
}

var L = make([]Card, MAX/2+2)
var R = make([]Card, MAX/2+2)

func merge(a []Card, n, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	for i := 0; i < n1; i++ {
		L[i] = a[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = a[mid+i]
	}
	i, j := 0, 0
	L[n1].Value = SENTINEL
	R[n2].Value = SENTINEL
	for k := left; k < right; k++ {
		if L[i].Value <= R[j].Value {
			a[k] = L[i]
			i++
		} else {
			a[k] = R[j]
			j++
		}
	}
}

func mergeSort(a []Card, n, left, right int) {
	var mid int
	if left+1 < right {
		mid = (left + right) / 2
		mergeSort(a, n, left, mid)
		mergeSort(a, n, mid, right)
		merge(a, n, left, mid, right)
	}

}

func partition(a []Card, n, p, r int) int {
	x := a[r]
	i := p - 1

	for j := p; j < r; j++ {
		if a[j].Value <= x.Value {
			i++
			a[i], a[j] = a[j], a[i]
		}
	}
	a[i+1], a[r] = a[r], a[i+1]
	return i + 1
}

func quickSort(a []Card, n, p, r int) {
	if p < r {
		q := partition(a, n, p, r)
		quickSort(a, n, p, q-1)
		quickSort(a, n, q+1, r)
	}
}

func main() {
	a := make([]Card, MAX)
	b := make([]Card, MAX)
	isStable := true

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	for i := 0; i < n; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), " ")
		a[i].Suit = s[0]
		b[i].Suit = s[0]
		a[i].Value, _ = strconv.Atoi(s[1])
		b[i].Value, _ = strconv.Atoi(s[1])
	}

	mergeSort(a, n, 0, n)
	quickSort(b, n, 0, n-1)

	for i := 0; i < n; i++ {
		if a[i].Suit != b[i].Suit {
			isStable = false
		}
	}

	if isStable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
	for i := 0; i < n; i++ {
		fmt.Println(b[i].Suit, b[i].Value)
	}
}



Measured memory_bytes: 14572
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

int main() {

	int N;
	ll l[100];
	l[0] = 2;
	l[1] = 1;

	cin >> N;

	if (N == 1)cout << l[1] << endl;
	else {

		for (int i = 2; i <= N; i++)l[i] = l[i - 1] + l[i - 2];
		cout << l[N] << endl;

	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putkotae(int X, int Y) {
	char C[12];
	rep(i, 6) {
		*(C + i) = '0' + Y % 10;
		Y /= 10;
	}
	rep(i, 6) {
		*(C + i + 6) = '0' + X % 10;
		X /= 10;
	}
	for (int i = 11; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint();
	int P[100000], PK[100001] = {};
	ll S[100000];
	rep(i, M) {
		P[i] = getint();
		S[i] = ((ll)getint() << 20) + i;
	}
	sort(S, S + M);

	int kotae[100000];
	rep(i, M) {
		int j = S[i] & 131071;
		kotae[j] = ++PK[P[j]];
	}
	rep(i, M) putkotae(P[i], kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define make0(a) memset(a,0,sizeof(a))
#define make1(a) memset(a,-1,sizeof(a))
#define all(v) begin(v),end(v)
#define allr(v) v.rbegin(),v.rend()
#define pi pair <int,int>
#define pll pair <ll,ll>
#define fast_cin() ios_base::sync_with_stdio(0) 

const int mod = 1e9+7;

void print(int *A, int N)
{
	for(int i=0;i<N;i++)
		cerr << A[i] << " ";
	cerr << endl;
}
const int maxn = 2e5+10;

ll fact[maxn];

ll mypow(ll A, ll M)
{
	ll res = 1;
	while(M)
	{
		if(M&1)
			res = (res*A) % mod;
		M /= 2;
		A = (A*A) % mod;
	}
	return res;
}

ll inv[maxn];

void pre()
{
	fact[0] = 1;
	for(int i=1;i<maxn;i++)
		fact[i] = (fact[i-1] * i) % mod;
	for(int i=0;i<maxn;i++)
		inv[i] = mypow(fact[i], mod-2);

}

ll C(ll N, ll R)
{
	if(N < R)
		return 0;
	return (fact[N]*((inv[N-R]*inv[R])%mod)) % mod;
}

int main()
{
	// #ifdef ONLINE_JUDGE 
	// 	freopen("input.txt", "r", stdin); 
	// 	freopen("output.txt", "w", stdout); 
	// #endif
	fast_cin();
	int N;
	pre();
	cin >> N;
	N++;
	int A[N+1];
	for(int i=1;i<=N;i++)
		cin >> A[i];

	int idx1, idx2;
	map <int,int> mp;
	for(int i=1;i<N+1;i++)
	{
		if(mp.find(A[i]) != mp.end())
		{
			idx1 = mp[A[i]];
			idx2 = i;
		} 
		mp[A[i]] = i;
	}
	int left = idx1 - 1;
	int right = N - idx2;
	cout << N - 1 << endl;
	for(int i=2;i<=N;i++)
	{
		ll ans = C(N,i) - C(left + right, i-1);
		ans %= mod;
		if(ans < 0)
			ans += mod;
		cout << ans << endl;
	}

	return 0;
}

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

string vector_finder(vector<char> vec, char element) {
  auto itr = find(vec.begin(), vec.end(), element);
  if (itr != vec.end()) {
    return "vowel";
  } else {
    return "consonant";
  }
}

int main() {
  vector<char> vec = {'a','e','i','o','u'};
  char c;

  cin >> c;

  cout << vector_finder(vec, c) << endl;
}

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

int main(void){

    string s;
    cin >> s;
    int n = s.size();
    vector<int> num(n + 1, 0);

    for (int i = 0; i < n;i++){
        if(s[i]=='<'){
            num[i + 1] = max(num[i + 1], num[i] + 1);
        }
    }
    
    for (int i = n - 1; i >= 0;i--){
        if(s[i]=='>'){
            num[i] = max(num[i], num[i+1] + 1);
        }
    }
    long long sum = 0;
    for (int i = 0; i < n+1; i++)
        sum += num[i];

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  string t = "CODEFESTIVAL2016";
  string s;
  cin >> s;
  
  ll ans = 0;
  for (int i = 0; i < t.size(); i++){
    ans += (t[i] != s[i]);
  }

  cout << ans << endl;
  

  return 0;
}


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

int main() {
    long long n;
    long long p;
    long long minimum = 1000000000000000;
    
    cin >> n;
    for(int i = 0; i < 5; i++)
    {
        cin >> p;
        minimum = min(minimum, p);
    }
    
    long long ans;
    if (n == minimum) {
        ans = 5;
    }
    else if (n % minimum == 0) {
        ans = (n - 1) / minimum + 5;    
    }
    else ans = n / minimum + 5;
    
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;
const LL mod=1000000007;

int main()
{
//    ifstream cin("input.txt");
    LL n;
    cin>>n;
    if (n==1)
    {
        cout<<0;
        return 0;
    }
    LL p1=1,p2=1,p3=1;
    for (int i=0;i<n;++i)
        p1=(p1*10)%mod,
        p2=(p2*9)%mod,
        p3=(p3*8)%mod;
    LL total=(mod+p1-p3)%mod;
    LL nr1=(mod+p1-p2)%mod;
    LL nr=(2*mod+2*nr1-total)%mod;
    cout<<nr;
}



Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------



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

    int ans = 0;
    REP(i,3){char a; cin >> a; if(a=='1')ans++;}
    out(ans);

    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int k; cin >> k;
  cout << (k / 2) * ((k+1) / 2) << endl;

  return 0;
}


Measured memory_bytes: 3568
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let v: Vec<i32> = buf.trim().chars().map(|c| c.to_digit(10).unwrap() as i32).collect();

    let mut v2: Vec<char> = Vec::new();
    for bit in 0..(1<<3) {
        let mut res = v[0];
        v2.clear();
        for i in 0..3 {
            if bit & (1<<i) == 0 {
                res += v[i + 1];
                v2.push('+');
            } else {
                res -= v[i + 1];
                v2.push('-');
            }
        }
        if res == 7 {
            break;
        }
    }

    println!("{}{}{}{}{}{}{}=7", v[0], v2[0], v[1], v2[1], v[2], v2[2], v[3]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m;
    cin >> n >> m;
    VI x(n), y(n);
    REP(i,n) cin >> x[i] >> y[i];
    VI xs(x), ys(y);
    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    xs.erase(unique(xs.begin(),xs.end()), xs.end());
    ys.erase(unique(ys.begin(),ys.end()), ys.end());
    REP(i,n){
        x[i] = find(xs.begin(),xs.end(),x[i]) - xs.begin();
        y[i] = find(ys.begin(),ys.end(),y[i]) - ys.begin();
    }
    int w = xs.size(), h = ys.size();
    VVI s(w+1, VI(h+1));
    REP(i,n) s[x[i]+1][y[i]+1]++;
    REP(i,w) REP(j,h+1) s[i+1][j] += s[i][j];
    REP(j,h) REP(i,w+1) s[i][j+1] += s[i][j];

    while (m--){
        int x1, x2, y1, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        x1 = lower_bound(xs.begin(),xs.end(),x1) - xs.begin();
        x2 = upper_bound(xs.begin(),xs.end(),x2) - xs.begin();
        y1 = lower_bound(ys.begin(),ys.end(),y1) - ys.begin();
        y2 = upper_bound(ys.begin(),ys.end(),y2) - ys.begin();
        int ans = s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 100864
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin >> n;
  string s;
  cin >> s;
  int sum = 0;
  for(int i=0 ; i<n ;){
    int j = i;
    while(s[i]==s[j]&&j<n){
      j++;
    }
    sum++;
    i = j;
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int n, t, count = 0;
  cin >> n;

  for (int k = 0; k < n; k++) {
    cin >> t;
    while (t % 2 == 0 && t > 0) {
      count++;
      t /= 2;
    } 
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
struct node
{
    string city;
    int id;
    int score;
};
node a[105];
bool cmp(node a, node b)
{
    if(a.city == b.city)
    {
        return a.score > b.score;
    }
    return a.city < b.city;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].city >> a[i].score;
        a[i].id = i;
    }
    sort(a, a+n, cmp);
    for(int i = 0; i < n; i++)
    {
        cout << a[i].id + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3180
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

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

	int i;
	VInt v(n);
	FOR(i, 0, n) scanf("%d", &v[i]);

	VInt w;
	FOR(i, 0, n)
		if (i == 0 || v[i] != v[i - 1])
			w.push_back(v[i]);

	v = w;
	n = SIZE(v);

	vector<Int> r(n + 1, 0);
	vector<Int> s(1 << 18, 0);

	Int mod = 1e9 + 7;

	r[0] = 1;
	FOR(i, 0, n)
	{
		r[i + 1] = (r[i] + s[v[i]]) % mod;
		s[v[i]] += r[i];
	}

	printf("%lld\n", r[n]);
	return 0;
};


Measured memory_bytes: 5492
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
ll f[200004];
ll even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<ll> v){
    ll i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve(){
    ll n,m,i,j,k;
    ll a[200005],b[200005];
    ll ans=0,res=0;
    bool flag=true;
    string s1,s2;
    set<ll> s;
   // cin>>n;
    vector<ll> v;
   // for0(i,n)cin>>v[i];
    ll x,t;
    cin>>n>>x>>t;
    if(n%x==0)cout<<(n/x)*t;
    else cout<<((n/x)+1)*t;

}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

    

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

vector<int> G[10000];
int match[10000];
bool used[10000];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v] = true;
	for(int i = 0;i < G[v].size();i++){
		int u = G[v][i],w = match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bi_match(int V){
	int res = 0;
	memset(match,-1,sizeof(match));
	for(int v = 0;v < V;v++){
		if(match[v] < 0){
			memset(used,0,sizeof(used));
			if(dfs(v)) res++;
		}
	}
	return res;
}

int gcd(int a,int b){
	if(a < b) swap(a,b);
	if(!b) return a;
	return gcd(b,a % b);
}

int main(){
	int m,n,b[500],r[500];
	while(cin >> m >> n,m){
		for(int i = 0;i < m;i++) cin >> b[i];
		for(int i = 0;i < n;i++) cin >> r[i];
		for(int i = 0;i < m;i++){
			for(int j = 0;j < n;j++){
				if(gcd(b[i],r[j]) != 1) add_edge(i,m + j);
			}
		}
		cout << bi_match(n + m) << endl;
		for(int i = 0;i < n + m;i++) G[i].clear();
	}
	return 0;
}

Measured memory_bytes: 5164
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	string s,t;	cin >> s >> t;
	ll ans = 0;
	Rep(i,0,s.size()){
		if(s[i] != t[i]){
			ans++;
		}
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for(int i = 1; i <= b; i++) {
    if((i*a) %b == c) {
      cout << "YES" << "\n";
      return 0;
    }
  }
  cout << "NO" << "\n";
}

Measured memory_bytes: 256