akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, x, min = 1e18, sum = 0;
  cin >> n >> x;
  REP(i, n) {
    int m = read();
    chmin(min, m);
    sum += m;
  }
  print(((x - sum) / min) + n);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll L, R;
  std::cin >> L >> R;

  ll ans = INF;
  for (ll i = L; i <= std::min(R, L + 2019); i++) {
    for (ll j = i+1; j <= std::min(R, L + 2019); j++) {
      ans = std::min(ans, (i * j) % 2019);
    }
  }

  print(ans);
  return 0;
}


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

vector<vector<int>> G;
int d[200010], l[200010], r[200010], x[200010];
bool det[200010];

bool dfs(int key){
	det[key]=true;
	bool res=true;
	for(int i=0; i<G[key].size(); ++i){
		int antic=x[key], nx=l[G[key][i]]+r[G[key][i]]-key;
		if(l[G[key][i]]==key) antic += d[G[key][i]];
		else antic -= d[G[key][i]];
		if(det[nx]){
			res=res&&(x[nx]==antic);
		}else{
			x[nx]=antic;
			res=res&&dfs(nx);
		}
	}
	return res;
}

int main() {
	int N, M;
	cin >> N >> M;
	G.resize(N+1);
	for(int i=0; i<M; ++i){
		cin >> l[i] >> r[i] >> d[i];
		G[l[i]].emplace_back(i);
		G[r[i]].emplace_back(i);
	}
	bool flag=true;
	for(int i=1; i<=N; ++i){
		if(!det[i]){
			x[i]=0;
			flag=flag&&dfs(i);
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define fo(i,n) for(int i=1;i<=n;i++)
#define fo1(i,n) for(int i=0;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

int main()
{
	//fast;
    int t=1;
    //cin>>t;
    while(t--)
	{
		int n;
		cin>>n;
		int a[n+1]={0};
		for(int x=1;x<=100;x++)
		{
			for(int y=1;y<=100;y++)
			{
				for(int z=1;z<=100;z++)
				{
					int ans = x*x + y*y + z*z + x*y + y*z + z*x;
					if(ans <= n) 
						a[ans]++;
					else
						break;
				}
			}
		}
		for(int i=1;i<=n;i++)
			cout<<a[i]<<"\n";
	}
} 

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

#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,a[10],b,c;
	cin >> n;
	rep(kk, n){
		rep(i, 10)
			cin >> a[i];
			b = c = 0;
		rep(i, 10){
			if (a[i] > b && b >= c){ b = a[i];}
			else if (a[i] > c){ c = a[i]; }
			else { cout << "NO" << endl; break; }
			if (i == 9){ cout << "YES" << endl; break; }
		}
	}
}


Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
ll count(ll x){
    if(x<10)return x;
    return x%10 + count(x/10);
}
int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(abs(a-b)>1e18){
        cout << "Unfair\n";
        return 0;
    }
    if(k&1)cout << b-a;
    else cout << a-b;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		int n = Integer.parseInt(reader.readLine());
		long sum = 0;
		input = reader.readLine().split(" ");
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		long[] arr = new long[100001];
		for(int i = 0; i < n; i++) {
			int a = Integer.parseInt(input[i]);
			arr[a]++;
			sum += a;
		}
		int q = Integer.parseInt(reader.readLine());
		while(q-->0) {
			input = reader.readLine().split(" ");
			int b = Integer.parseInt(input[0]), c = Integer.parseInt(input[1]);
			long temp = arr[b];
			arr[b] = 0;
			sum -= temp * b;
			arr[c] += temp;
			sum += temp * (long)c;
			out.println(sum);
		}
		out.flush();
		out.close();
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

int colors[100005];

void dfs(vector<vector<P>> &graph, int v, int c) {
    colors[v] = c;
    for (P p: graph[v]) {
        if (colors[p.first] != 0) continue;
        if (p.second % 2 == 0) {
            dfs(graph, p.first, c);
        } else {
            dfs(graph, p.first, -c);
        }
    }
}

void Main() {
    int N;
    cin >> N;
    vector<vector<P>> graph(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back({v, w});
        graph[v].push_back({u, w});
    }
    dfs(graph, 0, 1);
    rep(i, N) {
        int a = colors[i];
        if (a == -1) a++;
        cout << a << '\n';
    }
}

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


Measured memory_bytes: 9728
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

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

    ll now = 1;
    rep(i, n) {
        if (a[i] > M / now) {
            cout << -1 << endl;
            return 0;
        }
        now *= a[i];
    }
    cout << now << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int gcd(int x, int y){
    int r;
    
    // 引数チェック
    if(x == 0 || y == 0){
        return 0;
    }
    
    // ユーグリッドの互除法
    // yで割り切れるまでループ
    while((r = x % y) != 0){
        x = y;
        y = r;
    }
    return y;
}

int main(int argc, const char *argv[]){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int ans = v[0];
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, v[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5,inf=1e9+10;
int n,tot,rt,flag,k;
int head[maxn],des[maxn<<1],nxt[maxn<<1];
int dep[maxn],p[maxn],cnt[maxn];
int mini[maxn],vis[maxn];
void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
}
void dfs1(int x,int fa){
	Rep(p,x)if(des[p]!=fa)dep[des[p]]=dep[x]+1,dfs1(des[p],x);
}
void dfs2(int x,int fa){
	if(vis[x])mini[x]=cnt[x];
	else mini[x]=inf;
	Rep(p,x)if(des[p]!=fa)dfs2(des[p],x),mini[x]=min(mini[x],mini[des[p]]);
}
void calc(int x,int fa,int now){
	if(vis[x]&&(cnt[x]!=now))flag=1;
	Rep(u,x)if(des[u]!=fa){
		if(mini[des[u]]>now){
			p[des[u]]=p[x]+1;
			calc(des[u],x,now+1);
		}else{
			p[des[u]]=p[x]-1;
			calc(des[u],x,now);
		}
	}
}
int main(){
	memset(p,-1,sizeof p);
	read(n);
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		adde(x,y);adde(y,x);
	}
	read(k);
	rep(i,1,k)read(rt),vis[rt]=1,read(p[rt]);
	dfs1(rt,0);
	rep(i,1,n)if(vis[i]){
		cnt[i]=p[i]-p[rt]+dep[i];
		if(cnt[i]&1)return puts("No"),0;
		cnt[i]>>=1;
	}
	dfs2(rt,0);
	calc(rt,0,0);
	if(flag)return puts("No"),0;
	puts("Yes");
	rep(i,1,n)printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		char[] c = s.toCharArray();

		for(int i = 0; i < c.length; i++){
			if(Character.isUpperCase(c[i])){
				c[i] = Character.toLowerCase(c[i]);
			}else if(Character.isLowerCase(c[i])){
				c[i] = Character.toUpperCase(c[i]);
			}else{
				c[i] = c[i];
			}
		}

		System.out.println(c);
		
	}
}

Measured memory_bytes: 26284
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long A,B,C,D;
  cin >> A >> B >> C >> D;
  long P=C,Q=D;
  if(P<Q) swap(P,Q);
  while(P%Q!=0){
    P=P%Q;
    swap(P,Q);
  }
  long lcm = C*D/Q;
  
  long  x = B-B/C-B/D+B/lcm;
  long  y = (A-1)-(A-1)/C-(A-1)/D+(A-1)/lcm;
    
  cout << x - y  << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;
int main(void){
  string s,str;
  int b=0,min=754,c=0,d=0;
  
  cin>>s;
  int a = s.size();
  for(int i=0;i<a-2;i++){
      str=s.substr(i,3);
      b=stoi(str);
      c=b-753;
      d=abs(c);
      if(min>d) min=d;
     
  }
  
  cout<<min<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

bool isPrime(long long n){
    if(n<=1)return false;
    if(n==2)return true;
    for(long long i=2;i*i<=n;i++){
        if((n%i)==0)return false;
    }
    return true;
}

int main(){
    
    while(true){
        ll a,d,n; cin>>a>>d>>n;
        if(a==0&&d==0&&n==0)break;
        a-=d;
        while(n>0){
            a+=d;
            if(isPrime(a))n--;
        }
        cout<<a<<endl;
    }
    
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a.at(i+1);
    vector<int> b(n+1);
    for(int i=n;i>=1;i--){
        int x = 0;
        for(int j=2;i*j<=n;j++){
            x = (x + b.at(i*j)) % 2;
            // if(i==1) cout << i*j << " " << b.at(i*j) << endl;
        }
        // cout << i << " " << x << endl;
        b.at(i) = (x + a.at(i)) % 2;
    }
    vector<int> c;
    rep(i,n+1){
        if(b.at(i) == 1) c.push_back(i);
    }

    cout << c.size() << endl;
    rep(i,c.size()){
        if(i>0) cout << " ";
        cout << c.at(i);
    }
    if(c.size()) cout << endl;
    return 0;
}

Measured memory_bytes: 3064
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    T = sum(A)
    count = 0
    for a in A:
        if a*4*M >= T:
            count += 1
    if count >= M:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
int t[110][110][4];
char str[110][110];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int R[110000];
int C[110000];
char D[110000];
char name[6]="ESWN";
int main(){
	int a,b;
	long long c;
	while(scanf("%d%d%lld",&a,&b,&c),a){
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<4;k++)t[i][j][k]=-1;
		int dir=0;
		int row=0;
		int col=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]!='#'&&str[i][j]!='.'){
				row=i;col=j;
				if(str[i][j]=='E')dir=0;
				if(str[i][j]=='S')dir=1;
				if(str[i][j]=='W')dir=2;
				if(str[i][j]=='N')dir=3;
			}
		}
		int now=0;
		int last=-1;
		long long c2;
		while(1){
			t[row][col][dir]=now;
			if(last!=now){
				R[now]=row;
				C[now]=col;
				D[now]=name[dir];
				last=now;
			}
			//now++;
			int nr=row+dx[dir];
			int nc=col+dy[dir];
			if(nr<0||nc<0||nr>=a||nc>=b||str[nr][nc]=='#'){
				dir=(dir+1)%4;
				
			}else{
				row=nr;
				col=nc;
				now++;
			}
			if(~t[row][col][dir]){
				if((long long)now<=c){
					c=t[row][col][dir]+(c-t[row][col][dir])%(now-t[row][col][dir]);
					c2=t[row][col][dir]+(c-t[row][col][dir]-1+(now-t[row][col][dir]))%(now-t[row][col][dir]);
				}else c2=c-1;
				break;
			}
		}
		printf("%d %d ",R[c]+1,C[c]+1);
		for(int i=0;i<4;i++)if(R[c2]+dx[i]==R[c]&&C[c2]+dy[i]==C[c])printf("%c\n",name[i]);
	}
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std; 
const int MOD=1e9+7; 
int main(){

int n; cin>>n; long long  pow=1; 

for(int i=1;i<=n;i++) 
	pow=(pow*i)%MOD; 

cout<<pow<<endl;
	return 0; 
}

Measured memory_bytes: 256
num_count = gets.chomp.to_i

nums = gets.chomp.split(" ").map{|i| i.to_i}.sort

if nums.first == 0
  puts "0"
else
  answer = 1
  nums.each do |i|
    answer *= i
    if answer > (10 ** 18)
      answer = -1
      break
    end
  end
  
  puts answer
end


Measured memory_bytes: 25008
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, H;
    cin >> N >> H;
    vector<pair<int, bool> > AB(N*2);
    for (int i = 0; i < N*2; i++) {
        cin >> AB[i].first;
        AB[i].second = i%2 == 0;
    }
    sort(AB.rbegin(), AB.rend());
    int count = 0;
    for (auto &ab : AB) {
        if (ab.second) {
            count += (H+ab.first-1)/ab.first;
            printf("%d\n", count);
            return 0;
        } else {
            H -= ab.first;
            count++;
            if (H <= 0) {
                printf("%d\n", count);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=100009;
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
 

	char s[6];
	int ch[6];
	cin>>s;
	for(int i=0;i<4;i++) ch[i]=s[i]-'0';
	if(ch[0]+ch[1]+ch[2]+ch[3]==7){
		cout<<ch[0]<<"+"<<ch[1]<<"+"<<ch[2]<<"+"<<ch[3]<<"=7\n";
	}else if(ch[0]+ch[1]+ch[2]-ch[3]==7){
		cout<<ch[0]<<"+"<<ch[1]<<"+"<<ch[2]<<"-"<<ch[3]<<"=7\n";
	}else if(ch[0]+ch[1]-ch[2]+ch[3]==7){
		cout<<ch[0]<<"+"<<ch[1]<<"-"<<ch[2]<<"+"<<ch[3]<<"=7\n";
	}else if(ch[0]-ch[1]+ch[2]+ch[3]==7){
		cout<<ch[0]<<"-"<<ch[1]<<"+"<<ch[2]<<"+"<<ch[3]<<"=7\n";
	}
	else if(ch[0]+ch[1]-ch[2]-ch[3]==7){
		cout<<ch[0]<<"+"<<ch[1]<<"-"<<ch[2]<<"-"<<ch[3]<<"=7\n";
	}else if(ch[0]-ch[1]-ch[2]+ch[3]==7){
		cout<<ch[0]<<"-"<<ch[1]<<"-"<<ch[2]<<"+"<<ch[3]<<"=7\n";
	}else if(ch[0]-ch[1]+ch[2]-ch[3]==7){
		cout<<ch[0]<<"-"<<ch[1]<<"+"<<ch[2]<<"-"<<ch[3]<<"=7\n";
	}
	else if(ch[0]-ch[1]-ch[2]-ch[3]==7){
		cout<<ch[0]<<"-"<<ch[1]<<"-"<<ch[2]<<"-"<<ch[3]<<"=7\n";
	}
	return 0;
}


Measured memory_bytes: 256
<?php

$input = trim(fgets(STDIN));
$input = explode(" ", $input);
$n_max = (int) $input[0];

$count = 0;
while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	$args[$count] = [
		'x' => (int) $input[0],
		'y' => (int) $input[1],
		'h' => (int) $input[2],
	];
	if((int)$input[2] > 0){
		$sample_n = $count;
	}
	++$count;
	if ($count >= $n_max) {
		break;
	}
}

for ($x=0; $x <= 100 ; $x++) { 
	for ($y=0; $y <= 100 ; $y++) { 
		$ok = true;
		$test_helght = abs($x - $args[$sample_n]['x']) + abs($y - $args[$sample_n]['y']) + $args[$sample_n]['h'];
		for ($n=0; $n < $n_max; $n++) { 
			$tmp = $args[$n];
			$check = max([$test_helght - abs($x - $tmp['x']) - abs($y - $tmp['y']), 0]);
			if ($tmp['h'] !== $check) {
				$ok = false;
				break;
			}
		}
		if ($ok) {
			echo $x . ' ' . $y . ' ' . $test_helght;
			exit(0);
		}
	}
}


Measured memory_bytes: 4604
#include<stdio.h>
 
int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i!=n;
}
 
int main(){
  int i,n,A[10000+1],q,key,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1064
#!/usr/bin/env python
# coding: utf-8

# In[22]:


S = input()


# In[24]:


keyence = "keyence"
length = len(keyence)
flag = True
for i in range(len(keyence)):
#     print(S[:i+1], keyence[:i+1], S[-length+i+1:], keyence[-length+i+1:])
    if S[:i+1] == keyence[:i+1]:
        if S[-length+i+1:] == keyence[-length+i+1:]:
            print("YES")
            flag = False
            break
if flag:
    print("NO")


# In[ ]:






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

int main() {
  
  int n;
  cin >> n;
  vector<int> a(n);

  for(int i = 0; i < n; i++) { cin >> a.at(i); }

  vector<int> ans(n);

  for(int i = 0; i < n; i++) {
    int tmp = a.at(i) - 1;
    ans.at(tmp) = i+1;
  }
  for(int i = 0; i < n; i++) {
    cout << ans.at(i) << " ";
  }
}

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

int main(void){
    int n, d;
    cin >> n >> d;
    if ( n % (2*d+1) == 0){
        cout << n / (2*d+1) << endl;
    }else{
        cout << n / (2*d+1) + 1 << endl;
    }
    
    return 0;
}
    

Measured memory_bytes: 256
#include<iostream> 
#include<string> 
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[200005];
	int f=1;
	int flag=0;
	for(int i=0;i<n;i++) {
		cin >> a[i] ;
		if(a[i]==f) {
			f++;
		}else {
			flag++;
		}
	}
	if(flag == n) cout <<"-1" <<endl;
	else
	cout <<flag;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

  int n;
  cin >> n;
  vector<int> p(n);
  REP(i, n) cin >> p[i];

  int ans = 0;
  REP(i, n - 2){
    if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ans++;
    else if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

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

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int n; cin >> n;
    VI cnt(60, 0); //2^i が1の数の数
    REP(i, n){
        ll a; cin >> a;
        REP(j, 60){
            if(a & 1) ++cnt[j];
            a /= 2;
        }
    }
    ll ans = 0, weight = 1;
    REP(i, 60){
        (ans += (cnt[i] * ll(n-cnt[i])) % MOD * weight) %= MOD;
        (weight *= 2) %= MOD;
    }
    cout << (ans >= 0 ? ans : ans+MOD) << "\n";
    return 0;
}


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

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    string ea(a.substr(a.size()-1,1));
    string sb(b.substr(0,1));
    string eb(b.substr(b.size()-1,1));
    string sc(c.substr(0,1));
    if(ea==sb&&eb==sc){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

class minCostFlow {

	struct edge { ll to, cap, cost, rev; };

	ll V;
	vector<vector<edge>> G;
	vector<ll> dist;
	vector<ll> prevv;
	vector<ll> preve;

public:

	minCostFlow(ll n): G(n), dist(n), prevv(n), preve(n), V(n){
	}

	void addEdge(ll from, ll to, ll cap, ll cost) {
		G[from].push_back((edge){to, cap, cost, (ll)G[to].size()});
		G[to].push_back((edge){from, 0, -cost, (ll)G[from].size() - 1});
	}

	ll solve(ll s, ll t, ll f) {
		ll ret = 0;
		while(f > 0) {
			fill(dist.begin(), dist.end(), LLINF);
			dist[s] = 0;
			bool update = true;
			while(update) {
				update = false;
				for(ll v = 0;v < V;v++) {
					if(dist[v] == LLINF)continue;
					for(ll i = 0;i < G[v].size();i++) {
						edge &e = G[v][i];
						if(e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			}
			if(dist[t] == LLINF) {
				return LLINF;//流せない
			}

			ll d = f;
			for(ll v = t;v != s;v = prevv[v]) {
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			ret += d * dist[t];
			for(ll v = t;v != s;v = prevv[v]) {
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return ret;
	}

};

int main(){
	ll n, sum = 0;cin >> n;
	ll v = 2 * n + 6;
	const int start = 2 * n;
	const int end = 2 * n + 1;
	const int pXpYmxmy = 2 * n + 2;
	const int pXmYmxpy = 2 * n + 3;
	const int mXpYpxmy = 2 * n + 4;
	const int mXmYpxpy = 2 * n + 5;
	minCostFlow mcf(v);

	REP(i, n){
		ll x, y, c;cin >> x >> y >> c;
		sum += c;
		mcf.addEdge(start, i, c, 0);
		mcf.addEdge(i, pXpYmxmy, c, 2 * INF - (x + y));
		mcf.addEdge(i, pXmYmxpy, c, 2 * INF - (x - y));
		mcf.addEdge(i, mXpYpxmy, c, 2 * INF - (- x + y));
		mcf.addEdge(i, mXmYpxpy, c, 2 * INF - (- x - y));
	}

	REP(i, n){
		ll x, y, c;cin >> x >> y >> c;
		mcf.addEdge(n + i, end, c, 0);
		mcf.addEdge(pXpYmxmy, n + i, c, 2 * INF - (- x - y));
		mcf.addEdge(pXmYmxpy, n + i, c, 2 * INF - (- x + y));
		mcf.addEdge(mXpYpxmy, n + i, c, 2 * INF - (x - y));
		mcf.addEdge(mXmYpxpy, n + i, c, 2 * INF - (x + y));
	}

	cout << 4 * sum * INF - mcf.solve(start, end, sum) << endl;;

	return 0;
}


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


int main(){
  string S;
  cin >> S;
  int K=0;
  string pre = "";
  int s=0;
  for(int e=1; e<S.size()+1; e++){
    if(pre==S.substr(s, e-s)) continue;
    K++;
    pre=S.substr(s, e-s);
    s=e;
  }
  cout << K << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
bool checker(int n,int A[],int k){
int noOfdigits = floor(log10(n)+1);
for(int i=0;i<noOfdigits;i++){
   int digit = n%10;
   for(int j=0;j<k;j++){
      if(digit==A[j]) return false;
   }
   n/=10;
}
return true;
}
int main(){
   // We have to Find the Closest digit to N that does not contain any of those K digits
   // Brute Force
   int n,k,res;
   cin>>n>>k;
   int A[k];
   for(int i=0;i<k;i++) cin>>A[i];
   res=n;
   while(checker(res,A,k) != true){
     res++;
   }
   cout<<res;
   return 0;
}



Measured memory_bytes: 4004
S = input()
first = int(S[0:2])
second = int(S[2:4])
if (1<=first<=12):
    if (1<=second<=12):
        print("AMBIGUOUS")
    elif (second==0 or second>12):
        print("MMYY")
elif (first==0):
    if (1<=second<=12):
        print("YYMM")
    elif(second==0 or second>12):
        print("NA")
elif (first>12):
    if (1<=second<=12):
        print("YYMM")
    elif (second==0 or second>12):
        print("NA")

Measured memory_bytes: 3064
<?php
define("MAX", 2e5 + 1);

// sieve
for ($i = 0; $i < MAX; $i++) {
  $isPrime[] = 1;
}
$isPrime[0] = $isPrime[1] = 0;
for ($i = 2; $i < MAX; $i++) {
  if (!$isPrime[$i]) continue;
  $prime[] = $i;
  for ($j = 2 * $i; $j < MAX; $j += $i) {
    $isPrime[$j] = 0;
  }
}

while (fscanf(STDIN, "%d %d", $n, $p)) {
  if ($n == -1 && $p == -1) break;

  $idx = 0;
  foreach ($prime as $key => $value) {
    $idx = $key;
    if ($n < $value) break;
  }

  $sum = array();
  for ($i = 0; $i < $p; $i++) {
    for ($j = $i; $j < $i + $p; $j++) {
      $sum[] = $prime[$idx + $i] + $prime[$idx + $j];
    }
  }
  
  sort($sum);

  print $sum[$p - 1] . "\n";
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  vi v(4);

  rep(i, 4) v[i] = in();
  sort(all(v));
  print(v[1] + v[2] + v[3] + max(in(), in()));

  return (0);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; 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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    cout << 180*(N-2) << endl;
    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    string hitachi = "";
    string result = "No";
    for(int i = 0; i < 5; i++){
        hitachi += "hi";
        if(hitachi == s){
            result = "Yes";
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second


void solve()
{
	ll n;
	cin >> n;
	char char1;
	string out = "";
	for (; n > 0;)
	{
		//handling z separately
		ll remainder = n % 26;
		if (remainder != 0)
		{
			n /= 26;
			char1 = 'a' + (remainder - 1);
			//cout << char1 << "\n";
			out =  char1 + out;
		}
		else
		{
			n /= 26;
			out = 'z' + out;
			n--;
		}
	}
	cout << out << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }

	return 0;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

inline int num(int mask){
	return __builtin_popcount(mask);
}


#define vi vector<int>


inline int getSmall(int mask, int i){
	return ((mask >> (i + 1)) << i) | (mask & ((1 << i) - 1));
}

inline int getLarge(int mask, int i, int v){
	return ((mask >> i) << (i + 1)) + (v << i) + (mask & ((1 << i) - 1));
}

vi get(int mask, int i){
	if(i == 0) return {0};
	if(i == 1){
		assert(mask == 1);
		return {0, 1};
	}
	int pos1 = -1, pos2 = -1, absent = 0;
	int cnt = 0;
	for(int j = 0; j < i; j++){
		if(mask >> j & 1){
			if(pos1 == -1){
				pos1 = j;
			} else if(pos2 == -1){
				pos2 = j;
			}
			cnt++;
		} else absent = j;
	}
	assert(cnt & 1);
	if(pos2 == -1){
		int toGet = getSmall(mask ^ (1 << pos1) ^ (1 << absent), pos1);
		vi rgt = get(toGet, i - 1);
		vi ret = rgt;
		int k = ret.size();
		ret.resize(2 * k);
		for(int i = k; i < 2 * k; i++) ret[i] = ret[k - 1] ^ ret[i - k];

		for(int i = 0; i < 2 * k; i++) ret[i] = getLarge(ret[i], pos1, i / k);
		return ret;
	}

	else{
		vi v1 = get(getSmall(mask ^ (1 << pos1) ^ (1 << pos2), pos1), i - 1);
		vi v2 = get(getSmall(1 << pos2, pos1), i - 1);
		int f1 = getSmall(mask ^ (1 << pos1) ^ (1 << pos2), pos1);
		int f2 = getSmall(1 << pos2, pos1);
		int k = v1.size();
		for(int i = 0; i< k; i++) v2[i] = v2[i] ^ v1[k - 1];
		vi ret(2 * k);
		for(int i = 0; i < 2 * k; i++) ret[i] = getLarge(i < k ? v1[i] : v2[i - k], pos1, i / k);
		return ret;
	}
}

int main(){
	int a, b, n;
	sd(n); sd(a); sd(b);	
	if(!(num(a ^ b) & 1)){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	vi v = get(a ^ b, n);
	for(int i = 0; i < (1 << n); i++) printf("%d ", v[i] ^ a);
}

Measured memory_bytes: 1716
#include<map>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int T;
    cin >> T;
    multimap<string, int> mp;
    while (T--) {
        int t;
        cin >> t;
        if (t==0) {
            string s;int a;
            cin >> s >> a;
            mp.insert(pair<string ,int >(s, a));
        } else if (t==1) {
            string s;
            cin >> s;
            auto it1 = mp.lower_bound(s);
            auto it2 = mp.upper_bound(s);
            while (it1 != it2) {
                cout << it1->second << endl;
                it1++;
            }
        } else if (t==2) {
            string s;
            cin >> s;
            mp.erase(s);
        } else {
            string l, r;
            cin >> l >> r;
            auto it = mp.lower_bound(l);
            auto it1 = mp.upper_bound(r);
            for (; it !=it1; it++) cout << it->first << " " << it->second <<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24708
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] c = s.toCharArray();
        char tmp = '#';
        int count = 0;
        for (char slime : c) {
            if (tmp != slime) {
                count++;
                tmp = slime;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 25684
#include <iostream>

using namespace std;

int N;
int a[10005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> a[i];
	
	int ans = 0;
	for(int i = 0; i < N; i++){
		while(a[i] % 2 == 0){
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, j, h, w, ch, cw, dh, dw, ans;
int maze[1000][1000];
int mark[1000][1000];
deque<pair<int, pair<int, int>>> q;

bool isRoad(int ci, int cj) {
    return ci >= 0 && cj >= 0 && ci < h && cj < w && maze[ci][cj] == 1;
}

void markAround(int ci, int cj, int dist) {
    rep(ci-2,ci+3) {
        repj(cj-2, cj+3) {
            if (isRoad(i, j) && mark[i][j] > dist + 1) {
                mark[i][j] = dist + 1;
                q.push_back(make_pair(dist+1, make_pair(i, j)));
            }
        }
    }
}

int main() {
    scanf(" %d %d", &h, &w);
    scanf(" %d %d", &ch, &cw);
    scanf(" %d %d", &dh, &dw);

    string s;
    rep (0, h) {
        cin >> s;
        repj(0, w) {
            maze[i][j] = (s[j] == '.');
            mark[i][j] = inf;
        }
    }
    int dist = 0;
    ch--; cw--; dh--; dw--;
    mark[ch][cw] = dist;
    q.push_front(make_pair(dist, make_pair(ch, cw)));
    while (q.size() > 0) {
        pair<int, pair<int, int>> chw = q.front(); q.pop_front();
        dist = chw.first;
        ch = chw.second.first; cw = chw.second.second;
        if (mark[ch][cw] > dist) mark[ch][cw] = dist;
        markAround(ch, cw, dist);
        if (isRoad(ch-1, cw) && mark[ch-1][cw] > dist) q.push_front(make_pair(dist, make_pair(ch-1, cw)));
        if (isRoad(ch, cw-1) && mark[ch][cw-1] > dist) q.push_front(make_pair(dist, make_pair(ch, cw-1)));
        if (isRoad(ch, cw+1) && mark[ch][cw+1] > dist) q.push_front(make_pair(dist, make_pair(ch, cw+1)));
        if (isRoad(ch+1, cw) && mark[ch+1][cw] > dist) q.push_front(make_pair(dist, make_pair(ch+1, cw)));
    }
    if (mark[dh][dw] == inf) printf("%d\n", -1);
    else printf("%d\n", mark[dh][dw]);
}

Measured memory_bytes: 11676
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#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 RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	long long  a, b, x;
	cin >> a >> b >> x;
	long long c = b / x - a / x;
	if (a%x == 0) c++;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	set<int> c;
	int i;
	for(i=0;i<n;i++){
		c.insert(a[i]);
	}
	if(c.size()==n)cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, char const *argv[])
{
    int a,b,k;
    cin >> a>>b>>k;
    vector<int> v{};
    for(int d=1;d<=100;++d){
        if(a%d==0 && b%d==0){
            v.push_back(d);
        }
    }
    reverse(v.begin(),v.end());
    cout << v[k-1] << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; ++i) cin >> T[i];
  int M; cin >> M;
  vector<int> P(M), X(M);
  for (int i = 0; i < M; ++i) cin >> P[i] >> X[i];

  int t_sum = 0;
  for (int i = 0; i < N; ++i) t_sum += T[i];

  for (int i = 0; i < M; ++i) {
    cout << t_sum - T[P[i]-1] + X[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> L(N); for(int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end());
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i+1; j < N; ++j){
            if(L[i] == L[j]) continue;
            for(int k = j+1; k < N; ++k){
                if(L[k] == L[j]) continue;
                if(L[i] + L[j] > L[k]) cnt++;
            }
        }
    }
    cout << cnt <<'\n';
    return 0;
}

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

int main(){
  int n; cin >> n;
  int h[n];
  rep(i,n)cin >> h[i];

  int max=0;
  int a=0;
  if(n == 1){
     cout << 0 << endl;
     return 0;

  }

  for(int i=0;i<=n-2;i++){
     if(h[i] >= h[i+1]){
        a++;
     }else{
        if(max < a){
           max = a;
        }
        a=0;
     }
  }
  if(max < a){
           max = a;
        }


  cout << max << endl;
}



Measured memory_bytes: 640
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N, R;
    cin >> N >> R;
    if (N >= 10)
    {
        cout << R << endl;
    }
    else
    {
        cout << R + (100 * (10 - N)) << endl;
    }

    return;
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, i;
    int card[2];
    int result[2];
    scanf("%d",&n);
    while(n){
        result[0] = result[1] = 0;
        for(i=0;i < n;i++){
            card[0] = card[1] = 0;
            scanf("%d %d", &card[0], &card[1]);
            if(card[0] < card[1]) result[1] += card[0] + card[1];
            else if(card[0] > card[1]) result[0] += card[0] + card[1];
            else{
                result[0] += card[0];
                result[1] += card[1];
            }
        }
        printf("%d %d\n", result[0], result[1]);
        scanf("%d",&n);
    }
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>  
 char s1[4],s2[4];
 int main()
{
	while(~scanf("%s%*c%s",&s1,&s2))
	{
                  if(s1[0]==s2[2] && s1[1]==s2[1] && s1[2]==s2[0])
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			       	}
		}
		return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = int(1e9) + 7

tf = [True for _ in range(N)]
for i in a:
    tf[i-1] = False

if N <= 2:
    if N == 1:
        if tf[0]:
            print(1)
        else:
            print(0)
    else:
        if tf[0] and tf[1]:
            print(2)
        elif tf[0] or tf[1]:
            print(1)
        else:
            print(0)
    exit()


# DP
dp = []
if tf[0]:
    dp.append(1)
else:
    dp.append(0)
if tf[1]:
    dp.append(dp[0] + 1)
else:
    dp.append(0)
for i in range(N):
    if i == 0 or i == 1:
        continue
    else:
        if tf[i]:
            dp.append((dp[i-1] + dp[i-2])%MOD)
        else:
            dp.append(0)
print(dp[N-1])


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

int main() {
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  int red[a];
  int green[b];
  int white[c];
  for(int i=0; i<a; i++) cin>>red[i];
  for(int i=0; i<b; i++) cin>>green[i];
  for(int i=0; i<c; i++) cin>>white[i];

  sort(red, red+a, greater<int>());
  sort(green, green+b, greater<int>());
  sort(white, white+c, greater<int>());

  int apple[a+b+c];
  for(int i=0; i<x; i++) apple[i]=red[i];
  for(int i=0; i<y; i++) apple[x+i]=green[i];
  for(int i=0; i<c; i++) apple[x+y+i]=white[i];

  sort(apple, apple+x+y+c, greater<int>());

  int64_t ans = 0;
  for(int i=0; i<x+y; i++) ans += apple[i];

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 2560
x,y=map(int,input().split())

kame=0
turu=0

asi=0
flag=0

for kame in range(0,x+1):
    asi=kame*4 +(x-kame)*2
    
    if asi==y:
        print("Yes")
        flag=1
        break

if flag==0:
    print("No")

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}

//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}

//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int main(){
  int n;
  cin >> n;

  pair<int, int> p[MAX_N];
  rep(i, n){
    int x, y;
    cin >> x >>y;
    p[i] = make_pair(x+y, x-y);
  }

  sort(p, p + n);

  int ans = 0;
  int q = -MAX_V;

  rep(i,n){
    if(q <= p[i].second){
      ans++;
      q = p[i].first;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
        char str[100000];
	scanf("%s",str);
        printf("%d",(int)(ceil((double)(n-k)/(double)(k-1)))+1);
        return 0;
       
}


Measured memory_bytes: 128