akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int w,h;
    cin>>w>>h;
    vector<pair<int,int>> vec(w+h);
    rep(i,w){
        int p;
        cin>>p;
        vec[i]=make_pair(p,0);
    }
    rep(i,h){
        int q;
        cin>>q;
        vec[i+w]=make_pair(q,1);
    }
    sort(all(vec));
    
    ll ans=0;
    int a=w+1,b=h+1;
    for(auto x:vec){
        int cost,shu;
        tie(cost,shu)=x;
        if(shu==0){
            ans+=(ll)cost*b;
            a--;
        }
        else{
            ans+=(ll)cost*a;
            b--;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#include <cmath>
#define ff first
#define ss second
#define MAXN 300005
#define INF 1000000001000000001LL
//#define int long long

using namespace std;

const int mod = 998244353; //1000000007;
int n, i, j, k, dp[300000][4], res;
string s;

int f(int l1, int r1, int l2, int r2){
    if(l1 < 0 || r1 < 0)
        return 1;

    if(r1 - l1 + 1 != r2 - l2 + 1)
        return 1;

    for(int i = 0; i < r2 - l2 + 1; i++){
        if(s[l1 + i] != s[l2 + i])
            return 1;
    }

    return 0;
}

main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base :: sync_with_stdio(false);
    cin.tie();
    cin >> s; n = s.size();

    for(i = 0; i < n; i++){
        for(j = 1; j <= min(3, i + 1); j++){
            if(i - j == -1)
                dp[i][j] = 1;
            else{
                for(k = 1; k <= 3; k++){
                    if(k <= i - j + 1)
                        dp[i][j] = max(dp[i][j], 1 + dp[i - j][k] * f(i - j - k + 1, i - j, i - j + 1, i));
                }
            }

            //cout << i << " " dp[i][j] << endl;
        }
    }

    int ans = 0;
    for(i = 1; i <= min(n, 3); i++)
        ans = max(ans, dp[n - 1][i]);

    cout << ans;
    return 0;
}







Measured memory_bytes: 4628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		ArrayList<String> words = new ArrayList<String>();
		for(int i = 0 ; i < n ; i++){
			words.add(br.readLine());
		}
		
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < i ; j++){
				if(words.get(i).compareTo(words.get(j)) == 0){
					System.out.println("No");
					return;
				}
			}
			if(i > 0){
				int c = words.get(i-1).length() -1;
				if(words.get(i-1).charAt(c) != words.get(i).charAt(0)){
					System.out.println("No");
					return;
				}
			}
		}
		
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22484
// Coins
#include<iostream>
using namespace std;
int a,b,c,x;
int main(){
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>x;
    int count;
    count = 0;
    for(int i=0;i<a+1;++i){
        for(int j=0;j<b+1;++j){
            for(int k =0;k<c+1;++k){
                if(500*i+100*j+50*k==x) ++count;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import itertools
def resolve():
    N,=pin()
    D,X=pin()
    A=[int(input())for i in range(N)]
    cnt=0
    for d in range(D):
        for a in A:
            if d%a==0:cnt+=1
    print(cnt+X)            
        

#%%submit!    
resolve()


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

int main(){
    string s;
    cin >> s;
    int L = s.size();
    string ans = "AC";
    if(s[0] != 'A'){
        ans = "WA";
    }
    int cnt = 0;
    for(int i = 1; i < L; i++){
        if(isupper(s[i])){
            if(i == 1 || i == L - 1 || s[i] != 'C'){
                ans = "WA";
            }
            cnt++;
        }
    }
    if(cnt != 1){
        ans = "WA";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc172/tasks/abc172_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N + 1), B(M + 1);

    REP(i, N) { cin >> A[i + 1]; }
    REP(i, M) { cin >> B[i + 1]; }
    REP(i, N) { A[i + 1] += A[i]; }
    REP(i, M) { B[i + 1] += B[i]; }
    // 番兵
    B.emplace_back(1e15);
    int idx = 0, ans = 0;
    for (int i = N; i >= 0; i--) {
        if (A[i] + B[idx] > K) {
            continue;
        }
        while (A[i] + B[idx + 1] <= K) {
            idx++;
        }
        ans = max(ans, i + idx);
    }
    cout << ans << endl;

    return 0;
}


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

int n;

int cut(int n, int ans) {
  if (n % 2 == 0) cut(n / 2, ans + 1);
  else return ans;
}

int main(void){
    // Here your code !
    scanf("%d", &n);
    int max = -1; int ans = -1; int temp;
    for (int i = 1; i <= n; ++i) {
      temp = cut(i, 0);
      if (max < temp) {max = temp; ans = i;}
    }
    printf("%d\n", ans);
    return 0;
}


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


void solve(long long S, long long W){
if(S>W)cout<<"safe"<<endl;
else cout<< "unsafe" <<endl;
}

int main(){
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3760
#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;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int h, w;
string s[55];
int mem[55][55];

inline void solve(){
    int b = 0;

    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        cin >> s[i];
        for(int j = 0; j < w; j++) {
            b += (s[i][j]=='.');
        }
    }

    memset(mem,-1,sizeof(mem));

    queue<pii> que;
    que.push(pii(0,0));
    mem[0][0] = 0;
    while(!que.empty()) {
        int x = que.front().first;
        int y = que.front().second;
        que.pop();

        for(int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(inside(nx,ny,w,h) && s[ny][nx]=='.' && mem[ny][nx]==-1) {
                mem[ny][nx] = mem[y][x] + 1;
                que.push(pii(nx,ny));
            }
        }
        
    }

    if(~mem[h-1][w-1]) {
        cout <<  b - mem[h-1][w-1] - 1 << endl;
    }
    else
        cout << -1 << endl;
    
    

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


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

int* lower_bound(int key, int* l, int* r){
  int *mid = (int*)((long long)r+(long long)l/2);
  if (*mid == key)
    return mid;
  else if (*mid > key)
    return lower_bound(key, l, mid);
  else
    return lower_bound(key, mid+1, r);
}

int main(){
        int n,q,s[100000],t[50000];
        scanf("%d",&n);
        for (int i=0;i<n;i++)
                scanf("%d",s+i);
        scanf("%d",&q);
        for (int i=0;i<q;i++)
                scanf("%d",t+i);
        int count=0;
        for (int i=0;i<q;i++){
                if (*lower_bound(s,s+n,t[i])==t[i]){
                        count++;
                }
        }
        printf("%d\n",count);
}


Measured memory_bytes: 3812
#include<stdio.h>

int main(void){
	long long int sum=0;
	int n,min=1000000,max=-1000000,i,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		sum += a;
		if(min>a){
			min=a;
		}
		if(max<a){
			max=a;
		}
	}
	printf("%d %d %lld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 600
#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int a[12];

int main()
{
	int N, w, s;
	int i, lmin, rmin;

	N = in();
	s = 0; for (i = 0; i < N; i++) a[i] = in(), s += a[i];
	if (s == 0 || s == N) {
		puts("0");
		return 0;
	}
	lmin = rmin = 1001;
	for (i = 0; i < N; i++) {
		w = in();
		if (a[i]) {
			if (w < lmin) lmin = w;
		}
		else {
			if (w < rmin) rmin = w;
		}
	}
	printf("%d\n", lmin + rmin);
	return 0;
}



Measured memory_bytes: 2104
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			m = scanner.nextInt();
			n = scanner.nextInt();
			k = scanner.nextInt();
			d = scanner.nextInt();
			if ((m | n | k | d) == 0)
				break;
			int[] cake = new int[m];
			for (int i = 0; i < m; i++) {
				cake[i] = scanner.nextInt();
			}
			int N = m + n + 2;
			List<Pair>[] lists = new ArrayList[N];
			for (int i = 0; i < N; i++) {
				lists[i] = new ArrayList<Pair>();
			}
			while (d-- > 0) {
				int s = get(scanner.next());
				int t = get(scanner.next());
				int cost = scanner.nextInt() * k;
				lists[s].add(new Pair(t, cost));
				lists[t].add(new Pair(s, cost));
			}
			int[][] dist = new int[1 << m][N];
			for (int[] a : dist)
				Arrays.fill(a, 1 << 28);
			boolean[][] u = new boolean[1 << m][N];
			dist[0][n + m] = 0;
			u[0][n + m] = true;
			Deque<Pair> deque = new ArrayDeque<Main.Pair>();
			deque.add(new Pair(n + m, 0, 0));
			while (!deque.isEmpty()) {
				Pair pair = deque.poll();
				int s = pair.first;
				int cost = pair.second;
				int bit = pair.bit;
				for (Pair p : lists[s]) {
					if (m <= p.first) {
						int v = cost + p.second;
						if (v < dist[bit][p.first]) {
							dist[bit][p.first] = v;
							deque.offer(new Pair(p.first, v, bit));
						}
					} else {
						int aa = (bit >> p.first) & 1;
						if (aa == 1 )
							continue;
						int v = cost + p.second - cake[p.first];
						int newbit = bit | 1 << p.first;
						if (dist[newbit][p.first] > v) {
							dist[newbit][p.first] = v;
							deque.offer(new Pair(p.first, v, newbit));
						}
					}
				}
			}

			int min = 1 << 28;
			for (int j = 0; j < 1 << m; j++) {
				min = Math.min(min, dist[j][n + m + 1]);
			}
			System.out.println(min);
		}
	}

	private int get(String s) {
		if (s.charAt(0) == 'H')
			return n + m;
		if (s.charAt(0) == 'D')
			return n + m + 1;
		int x = Integer.parseInt(s.substring(1)) - 1;
		return s.charAt(0) == 'C' ? x : x + m;
	}

	int m, n, k, d;

	class Pair {
		int first;
		int second;
		int bit;

		public Pair(int first, int second) {
			super();
			this.first = first;
			this.second = second;
		}

		public Pair(int first, int second, int bit) {
			super();
			this.first = first;
			this.second = second;
			this.bit = bit;
		}

		@Override
		public String toString() {
			return "Pair [first=" + first + ", second=" + second + ", bit="
					+ bit + "]";
		}

	}
}

Measured memory_bytes: 67992
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
string str[3] = {"Sunny" , "Cloudy" , "Rainy"} , t;
int32_t main()
{
		cin >> t;
		if(t[0] == 'S')
				return cout << "Cloudy" << endl , 0;
		if(t[0] == 'C')
				return cout << "Rainy" << endl , 0;
		return cout << "Sunny" << endl , 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int A[1000];
int cnt=0;

int main(){
	int n,i,j,minj,w;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	
	
	for(i=0;i<n;i++){
		minj = i;
		for(j=i;j<n;j++){
			if(A[j] < A[minj])minj = j;
		}
		if(i==minj){;}
		else{
			w=A[i];
			A[i]=A[minj];
			A[minj]=w;
			cnt++;
		}
	}
	
	for(i=0;i<n-1;i++)printf("%d ",A[i]);
	printf("%d\n",A[n-1]);
	printf("%d\n",cnt);
	
	
	return 0;
}

Measured memory_bytes: 1852
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    rep(i, N) { cin >> H[i]; }
    vector<vector<int>> G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int res = 0;
    rep(i, N) {
        int ok = 1;
        for(auto x : G[i]) {
            if(H[i] <= H[x])
                ok = 0;
        }
        if(ok)
            res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8804
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/03 21:04:3 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define int long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;

// TOP
void Main()
{
	int n, k;
	cin >> n >> k;
	bitset<150> bs;
	rep(i, k)
	{
		int x;
		cin >> x;

		rep(i, x)
		{
			int a;
			cin >> a;
			bs.set(a);
		}
	}
	cout << n - bs.count() << endl;
}
// END

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> a(n);
    int mx = 0, mx2 = 0;
    rep(i,n) {
        cin >> a[i];
        if (mx < a[i]) {
            mx2 = mx;
            mx = a[i];
        } else if (mx2 < a[i]) {
            mx2 = a[i];
        }
    }
    rep(i,n) {
        if (mx == a[i]) {
            cout << mx2 << endl;
        } else {
            cout << mx << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back
#define sz(a) (int)a.size()

void solve();

signed main() {
#ifdef ONPC
    freopen("in.txt", "r", stdin);
#endif // ONPC
    //freopen("time.in", "r", stdin);
    //freopen("time.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}

const int N = 2e5 + 5;
int n, m, q, mn[N];
vector<int> v[N];

void solve() {
    cin >> n >> m >> q;
    int ans = n;
    int cur = 0;
    for (int i = 0; i < N; ++i) mn[i] = 1e9 + 7;
    set<pair<int, int>> Q;
    for (int i =1; i <= q; ++i) {
        int x, y;
        cin >> x >> y;
        v[y].pb(x);
        Q.insert({x, y});
    }
    for (int i= 0; i < N; ++i) {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
    }
    pair<int, int> p = {1, 1};
    bool f = 0;
    bool t = 0;
    while (1) {
        //cout << p.X << ' ' << p.Y << ' ' << cur << '\n';
        if (t == 0) {
            while (!v[p.Y].empty() && v[p.Y].back() < p.X) {
                v[p.Y].pop_back();
            }
            if (!v[p.Y].empty()) {
                ans = min(ans, v[p.Y].back() - p.X + cur);
            }
            if (p.X == n || Q.count({p.X + 1, p.Y})) {
                if (f) {
                    break;
                }
                f = 1;
            } else {
                ++p.X;
                f = 0;
            }
            ++cur;
        } else {
            if (p.Y == m || Q.count({p.X, p.Y + 1})) {

            } else {
                ++p.Y;
            }
        }
        t = 1 - t;
    }
    cout << min(cur, ans);
}


Measured memory_bytes: 18944
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int arr[] = new int[n];
		for(int i = 0; i<n; i++)
		{
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int sum = 0;
		for(int i = 0; i<k; i++)
		{
			sum = sum+arr[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 38404
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, A;
  cin >> N >> A;

  cout << N * N - A << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static PriorityQueue <State> pq=new PriorityQueue<>();
	
	static class State implements Comparable<State>{
		int a, cost;
		State(int a, int cost){
			this.a=a;
			this.cost=cost;
		}
		public int compareTo(State s) {
			return this.cost-s.cost;
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int m=sc.nextInt();
			int s, g, V, P;
			int[] v1=new int[n+1];
			int[] v2=new int[n+1];
			int[][] dist1=new int[n+1][n+1];
			int[][] dist2=new int[n+1][n+1];
			int INF=100000000;
			Arrays.fill(v1, INF);
			Arrays.fill(v2, INF);
			for(int i=1; i<=n; i++) {
				for(int j=1; j<=n; j++) {
					dist1[i][j]=INF;
					dist2[i][j]=INF;
				}
			}
			
			for(int i=0; i<m; i++) {
				String str=sc.next();
				String[] token=str.split(",");
				int a=Integer.parseInt(token[0]);
				int b=Integer.parseInt(token[1]);
				int c=Integer.parseInt(token[2]);
				int d=Integer.parseInt(token[3]);
				dist1[a][b]=dist2[a][b]=c;
				dist1[b][a]=dist2[b][a]=d;
			}
			String str=sc.next();
			String[] token=str.split(",");
			s=Integer.parseInt(token[0]);
			g=Integer.parseInt(token[1]);
			V=Integer.parseInt(token[2]);
			P=Integer.parseInt(token[3]);
			pq.add(new State(s, 0));
			while(! pq.isEmpty()) {
				State state=pq.poll();
				if(v1[state.a]!=INF) continue;
				v1[state.a]=state.cost;
				for(int i=1; i<=n; i++) {
					if(dist1[state.a][i]!=INF) {
						pq.add(new State(i, state.cost+dist1[state.a][i]));
					}
				}
			}
			pq.clear();
			pq.add(new State(g, 0));
			while(! pq.isEmpty()) {
				State state=pq.poll();
				if(v2[state.a]!=INF) continue;
				v2[state.a]=state.cost;
				for(int i=1; i<=n; i++) {
					if(dist2[state.a][i]!=INF) {
						pq.add(new State(i, state.cost+dist2[state.a][i]));
					}
				}
			}
			System.out.println(V-P-(v1[g]+v2[s]));
			
			
			

		}
	}
}


Measured memory_bytes: 26308
n = int(input())

list = [int(i) for i in input().split()]

def bubble(list):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(len(list)-1):
            if list[len(list)-1-i] < list[len(list)-1-i-1]:
                x = list[len(list)-i-1]
                list[len(list)-1-i] = list[len(list)-1-i-1]
                list[len(list)-1-i-1] = x
                flag = 1
                count += 1
    return [list,count]

answer = bubble(list)
for i in range(len(answer[0])):
    print(str(answer[0][i]) + ' ',end='') if i != len(answer[0])-1 else print(answer[0][i])
print(answer[1])

Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int n,m,f[maxn];
int fndfa(int x){return f[x] == x ? x : f[x] = fndfa(f[x]);}
bool meg(int u,int v){
    int fu = fndfa(u), fv = fndfa(v);
    if (fu == fv) return false;
    f[fu] = fv;
    return true;
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) f[i] = i;
    int ans = n;
    while (m--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if (meg(x,y)) ans--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  ll A;
  double B;
  cin >> A >> B;
  ll IB = B*100+0.5;
  A *= IB;
  A /= 100;

  printf("%lld\n", A);

  return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
int dir[4];
int dit[4];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int x,y;
    cin>>x>>y;
    cin>>s>>t;
    int f=0;
    int pos=x;
    for(int i=0;s[i];++i){
        if(s[i]=='U')
            pos--;
        if(pos<=0){
            f=1;
            break;
        }
        if(t[i]=='D'&&pos<n)
            pos++;
    }
    if(f){puts("NO");return 0;}
    pos=x;
    for(int i=0;s[i];++i){
        if(s[i]=='D')
            pos++;
        if(pos>n){
            f=1;
            break;
        }
        if(t[i]=='U'&&pos>1)
            pos--;
    }
    if(f){puts("NO");return 0;}
    pos=y;
    for(int i=0;s[i];++i){
        if(s[i]=='L')
            pos--;
        if(pos<=0){
            f=1;
            break;
        }
        if(t[i]=='R'&&pos<m)
            pos++;
    }
    if(f){puts("NO");return 0;}
    pos=y;
    for(int i=0;s[i];++i){
        if(s[i]=='R')
            pos++;
        if(pos>m){
            f=1;
            break;
        }
        if(t[i]=='L'&&pos>1)
            pos--;
    }
    if(f){puts("NO");return 0;}
    else puts("YES");
}


Measured memory_bytes: 920
N = int(input())
dic = {}
dic['AC'] = 0
dic['WA'] = 0
dic['TLE'] = 0
dic['RE'] = 0
for i in range(N):
  s = input().strip()
  dic[s] += 1
print("AC x ",end = '')
print(dic['AC'])
print("WA x ",end = '')
print(dic['WA'])
print("TLE x ",end = '')
print(dic['TLE'])
print("RE x ",end = '')
print(dic['RE'])


Measured memory_bytes: 9188
import itertools


def main():
    N = int(input())
    remarks = []
    for i in range(N):
        A = int(input())
        remark = []
        for j in range(A):
            x, y = [int(i) for i in input().split()]
            remark.append((x-1, y))
        remarks.append(remark)

    ans = 0
    for is_honest in itertools.product([1, 0], repeat=N):
        # 矛盾があればFalse
        ok = True
        for i, h in enumerate(is_honest):
            if not ok:
                break
            # 正直者でなければスルー
            if h == 0:
                continue
            # 正直者の場合
            # 正直者の発言と審議が一致しているか調べる
            for one_remark in remarks[i]:
                if is_honest[one_remark[0]] != one_remark[1]:
                    ok = False
                    break
        if ok:
            ans = max(ans, sum(is_honest))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42736
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
  int n;
  cin>>n;
  float x[n];
  rep(i,n){
    cin>>x[i];
  }
  float su=0;
  rep(i,n){
    su+=x[i]/n;
  }
  int mx=0;
  int my=0;
  rep(i,n){
    mx+=(x[i]-int(su))*(x[i]-int(su));
    my+=(x[i]-(int(su)+1))*(x[i]-(int(su)+1));
    
  }

  cout<<min(mx,my)<<endl;
}

Measured memory_bytes: 384
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
print(s[int(input())-1])


Measured memory_bytes: 2940
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
N = int(input())
#A = list(map(int,input().split()))
S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
R = []
G = []
B = []
for i in range(N):
    a = S[i]
    if a == "R":
        R.append(i)
    elif a == "G":
        G.append(i)
    else:
        B.append(i)
s = len(R) * len(G) * len(B)
def binary_search(S,key):  #昇順リストSからkeyを探す。
    n = len(S)             #存在したらindex,なかったら-1を返す
    left  = 0
    right = n
    while left < right:
        mid = (left+right) // 2
        if S[mid] == key:
            return mid
        elif S[mid] > key:
            right = mid
        else:
            left = mid + 1
    return -1
for r in R:
    for g in G:
        Min = min(r,g)
        Max = max(r,g)
        if 2 * Min - Max > 0:
            c1 = 2 * Min - Max
        else:
            c1 = -1
        if (Min + Max ) % 2 == 0:
            c2 = (Min + Max) / 2
        else:
            c2 = -1
        if 2 * Max - Min < N:
            c3 = 2 * Max - Min
        else:
            c3 = -1
        if c1 != -1:
            if binary_search(B,c1) != -1:
                s -= 1
        if c2 != -1:
            if binary_search(B,c2) != -1:
                s -= 1
        if c3 != -1:
            if binary_search(B,c3) != -1:
                s -= 1
print(s)


Measured memory_bytes: 82816
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define C(n,m) ((LL)fac[n]*ifac[m]%mo*ifac[(n)-(m)]%mo)

const int maxn=2e5+10;
const int maxm=1.2e6+10;
const int INF=1e9+10;
const int mo=1e9+7;

int n,X,Y,c[maxn],w[maxn],cpos[maxn],pos1,pos2,Ans=1;
int fac[maxn],ifac[maxn],cnt[maxn],q[maxn],cc[maxn];
int tote,FIR[maxn],TO[maxm],NEXT[maxm];
bool vis[maxn];

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

void search(int u)
{
	vis[u]=1;
	cnt[c[u]]++;
	q[++q[0]]=c[u];
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (!vis[v]) search(v);
	}
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d%d",&n,&X,&Y);
	fac[0]=1;
	for (i=1;i<=n;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	for (i=n;i>=1;i--)
		ifac[i-1]=(LL)ifac[i]*i%mo;
	w[0]=INF;
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&c[i],&w[i]);
		cpos[c[i]]=w[cpos[c[i]]]<w[i]?cpos[c[i]]:i;
		pos1=w[pos1]<w[i]?pos1:i;
	}
	for (i=1;i<=n;i++)
		if (c[i]!=c[pos1]) pos2=w[pos2]<w[i]?pos2:i;
	for (i=1;i<=n;i++)
	{
		if (i!=cpos[c[i]]&&w[i]+w[cpos[c[i]]]<=X)
			addedge(i,cpos[c[i]]),addedge(cpos[c[i]],i);
		if (c[i]!=c[pos1]&&w[i]+w[pos1]<=Y)
			addedge(i,pos1),addedge(pos1,i);
		if (c[i]!=c[pos2]&&w[i]+w[pos2]<=Y)
			addedge(i,pos2),addedge(pos2,i);
	}
	for (i=1;i<=n;i++)
		if (!vis[i])
		{
			int sum=0;
			q[0]=cc[0]=0;
			search(i);
			for (j=1;j<=q[0];j++)
			{
				if (cnt[q[j]])
				{
					cc[++cc[0]]=cnt[q[j]];
					sum+=cnt[q[j]];
				}
				cnt[q[j]]=0;
			}
			for (j=1;j<=cc[0];j++)
				Ans=(LL)Ans*C(sum,cc[j])%mo,sum-=cc[j];
		}
	printf("%d\n",Ans);
}


Measured memory_bytes: 16896
#include <stdio.h>


int main(void){
  int N, D;
  scanf("%d %d", &N, &D);
  int person_x = 0, person_n = 0;

  while(person_x < N){
    person_x += 2*D+1;
    person_n++;
  }

  if(person_x+D <= N)
    printf("%d\n", person_n++);
  else
    printf("%d\n", person_n);

  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum++;
            sum += (d - 1) / a[i];
        }
        System.out.println(sum + x);
    }
}

Measured memory_bytes: 21844
n=int(input())
A=list(map(int,input().split()))
q=int(input())
M=list(map(int,input().split()))

R=[]

for i in range(1<<n):
    r=0
    for j in range(n):
        if i&(1<<j):
            r+=A[j]
    R.append(r)

R=set(R)

for m in M:
	if m in R:
		print('yes')
	else:
		print('no')


Measured memory_bytes: 43084
import math

n = int(input())

for x in range(1, n + 1):
    if x % 3 == 0:
        print(f" {x}", end="")
    else:
        for y in range(int(math.log10(x)) + 1):
            if int(str(x)[y]) == 3:
                print(f" {x}", end="")
                break
print()



Measured memory_bytes: 5964
N, K = raw_input().split()
D = set(map(int,raw_input().split()))
L = sorted(set(range(10))-D)

pay=[]
for ind, d in enumerate(N):
    if ind == 0:
        w = len(N)
        ma, mi = max(L), min(L)
        tmp = ''.join([str(ma)]*w)
        tmp = int(tmp)
        if tmp < int(N):
            if L[0]==0:
                pay = [str(L[1])]+['0']*w
            else:
                pay = [str(L[0])] * (w+1)
            break

    if int(d) in D:
        for l in sorted(L):
            if l > int(d):
                pay+= [str(l)]+[str(L[0])]*(w-len(pay)-1)
                break
        else:
            for l in sorted(L):
                if l > int(N[ind - 1]):
                    pay = pay[:-1] + [str(l)] * (w - len(pay) + 1)
                    break
        break
    else:
        pay.append(d)

print ''.join(pay)

Measured memory_bytes: 2696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )


typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;


// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
PII,
null_type,
less<PII>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

/*end of header*/

LL n,k,a,g,mx;
int main()
{
    mx=g=0;
    scanf("%lld %lld",&n,&k);
    while(n--)
    {
        scanf("%lld",&a);
        g=gcd(g,a);
        mx=max(mx,a);
    }
    if(k%g==0 && mx>=k)
    {
        print("POSSIBLE");
    }
    else print("IMPOSSIBLE");
    return 0;
}



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

ll dp[100001], bit[100001];
int x[100000], n;
void update(int k, ll x) {
	while (k <= n) {
		bit[k] = max(bit[k], x);
		k += k&-k;
	}
}
ll query(int k) {
	ll ans = 0;
	while (k) {
		ans = max(ans, bit[k]);
		k -= k&-k;
	}
	return ans;
}
int main() {
	scanf("%d", &n);
	ll sum = 0;
	rep(i, n)scanf("%d", &x[i]), sum += x[i];
	rep(i, n){
		dp[i] = query(x[i]) + x[i];
		update(x[i], dp[i]);
	}
	printf("%lld\n", sum - query(n));
}

Measured memory_bytes: 5164
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

ll a[200001] = {};
int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, n) {
		cin >> a[i];
	}

	n--;
	k--;
	ll t = n / k;

	if (n % k != 0) {
		t++;
	}

	cout << t << endl;
	return 0;
}

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

int main(){
    int a, b;
    string str;
    cin >> a >> b >> str;

    if(str[a] != '-'){
        cout << "No" << endl;
        return 0;
    }

    int i = 0;
    while(str[i] != '\0'){
        if(i == a){
            i++;
        }
        else{
            if('0' <= str[i] && str[i] <= '9'){
                i++;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        } 
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
ARR = list(map(int,input().split()))
def calculate(n,arr):
    right = 0
    sum = arr[0]
    result = 0

    for left in range(0,n):
        while (right + 1 < n) and ( (sum + arr[right+1]) == (sum ^ arr[right+1]) ):
            right = right + 1
            sum = sum + arr[right]

        result = result + right - left + 1
        sum = sum - arr[left]

    print(result)

calculate(N,ARR)

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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int h1, m1, h2, m2, k;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    int first = h1*60+m1;
    int second = h2*60+m2;
    int d = second - first - k;
    cout << d << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>data;
  data.push_back(N/1000);
  N=N%1000;
  data.push_back(N/100);
  N=N%100;
  data.push_back(N/10);
  data.push_back(N%10);
  //for(int i=0;i<N;i++)cout<<data[i]<<endl;
    if(data[0]+data[1]+data[2]+data[3]==7){
      cout<<data[0]<<"+"<<data[1]<<"+"<<data[2]<<"+"<<data[3]<<"=7"<<endl;
      return 0;
    }
     if(data[0]+data[1]+data[2]-data[3]==7){
      cout<<data[0]<<"+"<<data[1]<<"+"<<data[2]<<"-"<<data[3]<<"=7"<<endl;
      return 0;
    }
    if(data[0]+data[1]-data[2]+data[3]==7){
      cout<<data[0]<<"+"<<data[1]<<"-"<<data[2]<<"+"<<data[3]<<"=7"<<endl;
      return 0;
    }
    if(data[0]-data[1]+data[2]+data[3]==7){
      cout<<data[0]<<"-"<<data[1]<<"+"<<data[2]<<"+"<<data[3]<<"=7"<<endl;
      return 0;
    } 
    if(data[0]+data[1]-data[2]-data[3]==7){
      cout<<data[0]<<"+"<<data[1]<<"-"<<data[2]<<"-"<<data[3]<<"=7"<<endl;
      return 0;
    }  
    if(data[0]-data[1]-data[2]+data[3]==7){
      cout<<data[0]<<"-"<<data[1]<<"-"<<data[2]<<"+"<<data[3]<<"=7"<<endl;
      return 0;
    }  
    if(data[0]-data[1]+data[2]-data[3]==7){
      cout<<data[0]<<"-"<<data[1]<<"+"<<data[2]<<"-"<<data[3]<<"=7"<<endl;
      return 0;
    }  
    if(data[0]-data[1]-data[2]-data[3]==7){
      cout<<data[0]<<"-"<<data[1]<<"-"<<data[2]<<"-"<<data[3]<<"=7"<<endl;
      return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << endl;

    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)
for i in range(0, N):
    if S[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]
inputList = []
for i in range(1, Q+1):
    inputList.append(input())

for i in range(Q):
    x, y = map(int, inputList[i].split())
    res = t[y-1] - t[x-1]
    print(res)


Measured memory_bytes: 13428
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;
 
int main(){
    int n;cin>>n;
    string s;cin>>s;
    int c=0;
    int sz = s.size();
    for(int i=0;i<sz-1;i++){
        if(s[i] != s[i+1])
            c++;
    }
    cout<<c+1;
    return 0;
}

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

int main(){
    
    int H, W;

    while(true){
    cin >> H >> W;
    if((H==0)&&(W==0)) break;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if((i==0)||(i==H-1)||(j==0)||(j==W-1)) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }
    cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n,t,a,b,c,d,e,cnt=0;
    map<string,ll>mp;
    vector<ll>vec;
    string s,s1,s2;
     cin>>t;
     while(t--){
     cin>>s;
    mp[s]++;
   }
    cnt=0;
   for(auto it:mp){
    if(it.second>0){
        cnt++;
    }
   }
   cout<<cnt<<endl;
   mp.clear();
   cnt=0;

}



Measured memory_bytes: 19256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define REP(i, n) for(int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for(int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001;  //もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
// cout << fixed << setprecision(10) << ans << endl;
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int extgcd(int a, int b, int &x, int &y) {
  int g = a;
  x = 1;
  y = 0;
  if(b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

int mod_fact(int n, int p, int &e) {
  e = 0;
  if(n == 0) return 1;
  int res = mod_fact(n / p, p, e);
  e += n / p;
  if(n / p % 2 != 0) {
    // n!(mod p)を求める
    int t = 1;
    for(int i = 1; i <= n; i++) {
      t *= i;
      t %= p;
    }
    //ここまで
    return res * (p - t) % p;
  }
  // n!(mod p)を求める
  int t2 = 1;
  for(int i = 1; i <= n; i++) {
    t2 *= i;
    t2 %= p;
  }
  //ここまで
  return res * t2 % p;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

int mod_comb(int n, int k, int p) {
  if(n < 0 || k < 0 || n < k) return 0;
  int e1, e2, e3;
  int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
  if(e1 > e2 + e3) return 0;
  return a1 * mod_inverse(a2 * a3 % p, p) % p;
}


int r1, c1, r2, c2;
signed main() {
  cin >> r1 >> c1 >> r2 >> c2;
  int ans;
  ans = mod_comb(c2+r2+2, c2+1, MOD) -  mod_comb(c2+r1+1, c2+1, MOD) - mod_comb(c1+r2+1, c1, MOD) + mod_comb(c1+r1, c1, MOD);
  ans += MOD;
  ans += MOD;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Map<String, Integer> map = new HashMap<>();
			int max = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				int val = map.containsKey(s) ? map.get(s) + 1 : 1;
				map.put(s, val);
				max = Math.max(max, val);
			}
			List<String> list = new ArrayList<>();
			for (String key : map.keySet()) if (map.get(key) == max) list.add(key);
			Collections.sort(list);
//			PrintWriter out = new PrintWriter(System.out);
			for (String s : list) System.out.println(s);
//			out.flush();
		}
	}
}

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

int main(void){
	double N;
	cin >> N;
	int M = ceil(N/1000);
	cout << 1000*M-N << endl;
return 0;
}


Measured memory_bytes: 3780
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

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

int main()
{
    int N,M;
    cin>>N>>M;
    if(N==0)
    {
        cout<<M*(M-1)/2<<endl;
        return 0;
    }
    if(M==0)
    {
        cout<<N*(N-1)/2<<endl;
        return 0;
    }
    cout<<(N*(N-1)/2)+(M*(M-1)/2)<<endl;
    return 0;

}

Measured memory_bytes: 256
use proconio::{input, fastout};

const MOD: i64 = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut p10n = 1i64;
    let mut p9n = 1i64;
    let mut p8n = 1i64;

    for _ in 0..n {
        p10n *= 10;
        p10n %= MOD;
        p9n *= 9;
        p9n %= MOD;
        p8n *= 8;
        p8n %= MOD;
    }

    let mut ans = p10n-2*p9n+p8n;
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    println!("{}", ans);
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    string a, b, c; cin >> a >> b;
    c = a + b;
    int d = stoi(c);
    int r = sqrt(d);
    //cout << r;
    if(r * r == d) cout << "Yes";
    else cout << "No";





    
    
    
    return 0;
}

Measured memory_bytes: 3628