akhauriyash/Code-Regression huggingface dataset:
/*
                   _ooOoo_
                  o8888888o
                  88" . "88　AC!AC!
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
int main(){
    int n;cin>>n;
    string s;
    cin>>s;
    char prev=s[0];
    int res=1;
    rep3(i,1,s.size()){
        if(s[i]!=prev){
            res++;
            prev=s[i];
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string a, b; cin >> a >> b;
    bool judge = 1;
    REP(i, 3) if(a[i] != b[2 - i]) judge = 0;
    cout << (judge ? "YES" : "NO") << endl;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  int K = -1;
  for(int i = 0;i < 1000000000;i++){
    if(A - i == B - i || A - i == i - B){
      K = i;
      cout << K << endl;
      break;
    }
  }
  if(K == -1){
    cout << "IMPOSSIBLE" << endl;}
}


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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Stack<Integer>	s = new Stack<Integer>();

		boolean	map[] = new boolean[3001];

		for (int n = 0; n <= map.length; n += 4) {
			map[n] = (n % 400 == 0 || n % 4 == 0 && n % 100 != 0);
		}

		while(true) {
			int[]	r = parseRange();
			int		n = 0;
			boolean	f = false;

			if (r[0] == 0 && r[1] == 0) {
				break;
			}

			n = r[0] / 4;
			n = (r[0] % 4 != 0) ? n + 1 : n;
			n = n * 4;

			if (s.size() > 0) {
				s.push(-2);
			}

			for (; n <= r[1]; n += 4) {
				if (map[n]) {
					s.push(n);
					f = true;
				}
			}

			if (!f) {
				s.push(-1);
			}
		}

		for (int l = 0; l < s.size(); l++) {
			int	n = s.get(l);
			if (n == -2) {
				System.out.println("");
			} else if (n == -1) {
				System.out.println("NA");
			} else {
				System.out.println(n);
			}
		}
	}

	private static int[] parseRange() {
		int[]	params = new int[2];
		String	strin  = null;

		if ((strin = parseStdin()) != null) {
			String[]	lines = strin.split(" ");
			params[0] = Integer.parseInt(lines[0]);
			params[1] = Integer.parseInt(lines[1]);
		}
 
		return params;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (!tmp.isEmpty()) stdin = tmp;
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 20052
fun main(args: Array<String>) {
    val l = readLine()!!.map(Char::toString).map(String::toInt)
    for (bit in 0 until (1 shl 3)) {
        var tmp = l[0]
        val list = mutableListOf<String>()
        list += l[0].toString()
        for (i in 0 until 3) {
            if (1 and (bit shr i) == 0) {
                list += "+"
                list += l[i + 1].toString()
                tmp += l[i + 1]
            } else {
                list += "-"
                list += l[i + 1].toString()
                tmp -= l[i + 1]
            }
        }
        if (tmp == 7) {
            list.joinToString(separator = "", postfix = "=$tmp").let(::println)
            return
        }
    }
}

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

int main() {
	int n; cin >> n;
	rep(i, n) {
		int k, p; cin >> k >> p;
		cout << (k%p ? k%p : p) << endl;
	}
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 200005

int n;
ll a[MAXN];
map<ll,ll> mp;
ll ans=0;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n){
		cin>>a[i];
		
		ans+=mp[a[i]-i];
		
		mp[-a[i]-i]++;
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 27924
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    int[] a = new int[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }

    sc.close();

    int cost = Integer.MAX_VALUE;

    for (int i = -100; i <= 100; i++) {
      int cost_ = 0;
      for (int j = 0; j < N; j++) {
        cost_ += (a[j] - i) * (a[j] - i);
      }
      cost = Math.min(cost, cost_);
    }
    
    System.out.println(cost);

  }

}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

ll f(ll i){return i*i*i*i*i;}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll x;cin>>x;
    vector<ll> v;
    v.push_back(0);
    map<ll,int> m;
    for(int i=1;i<=4000;i++){
        v.push_back(f(i));
        v.push_back(-1ll*f(i));
        m[f(i)]=i;
        m[f(i)*-1]=-i;
    }
    bool ok=0;
    for(int i=0;i<v.size();i++){
        ll need=x+v[i];
        if(m[need]){cout<<m[need]<<' '<<m[v[i]];return 0;}
    }
}

Measured memory_bytes: 4216
K=int(input())
N=50

def solve(A,cnt):
  res=len(A)
  for i in range(cnt):
    A[i]+=(res+1)
    for j in range(res):
      A[j]-=1
  return A

Ans=[0 for x in range(N)]
Ans[0]=25+(K//50)
for i in range(1,N):
  if i % 2 ==0:
    Ans[i]=Ans[i-1]+1
  else:
    Ans[i]=Ans[i-1]

Ans=solve(Ans,K%50)

print(N)
for i in range(N):
  if i == N-1:
    print(Ans[i])
  else:
    print(Ans[i],end=" ")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#define ll                    long long int
#define ll_MAX                LLONG_MAX
#define ll_MIN                LLONG_MIN
#define pi                    3.14159265358979323846
#define count_1(n)            __builtin_popcountll(n)
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define mid(s,e)              (s+(e-s)/2)
const int MX=10010896;
const int lmt=3164;
const int N=10000001;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define print(a)        for (auto x : a) cout << x << " "; cout << endl

inline void solve(){
	string s;cin>>s;
	ll sm=0;
	//int n=s.length();
	for(char ch:s){
		int d=ch-'0';
		sm+=d;
	}
	if(sm%9)
		cout<<"No"<<"\n";
	else
		cout<<"Yes"<<"\n";
}

int main()
{
	cout<<fixed<<setprecision(12);
	fastio;ll  t=1,tc=1;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);
	#endif
	//cin>>t;
	while(t--){solve();}return 0;
}

Measured memory_bytes: 3804
#ika　tako
'''
A.ダメなケースを除外できるか、B.組合せの数を問題に応じて求められるか
階乗や逆元はfor文で求める。
ダメなケースを除外した上で、最終X,Y に行くには、二つの選択肢
(i+1,j+2),(i+2,j+1)の組合せの数を求める。
組合せの数を求める時は、階乗と逆元を使う。
逆元は一通り、全て求めておいて、配列invsに格納して、後で使う。
'''
def prepare(n, MOD):
    f = 1
    for m in range(1, n + 1):
        f = f * m % MOD
    fn = f#n!を求める

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)#[1, 1, 1]のイメージ、逆元？格納テーブル
    invs[n] = inv#配列の一番最後のデータ
    for m in range(n, 1, -1):#n*(n-1)*(n-2)*...と上から掛けている
        inv = inv * m % MOD#逆元を一通り、求めて、配列invsに格納する
        invs[m - 1] = inv
        
    return fn, invs

def solve(x, y):#ダメなケースの除外
    d, m = divmod(x + y, 3)#商と余り
    if m != 0 or x < d or y < d:
    #Xとyの合計は3の倍数、x、yがd移動回数以下はあり得ない（1回1個は進む）
        return 0
    #c = d - x　　これだと範囲外参照でエラー
    c = abs(d - x)#nCr=nC(n-r)、Cの後ろのrと(n-r)を入れ替えても同じ
 
    MOD = 10 ** 9 + 7
    f, invs = prepare(d, MOD)
    return f * invs[c] * invs[d - c] % MOD
  #fはn!、invs[c],invs[d - c] はc!,(d-c)!の逆元？
  #nCr=n!/(r!*(n-r)!)
  
x, y = map(int, input().split())
print(solve(x, y))

Measured memory_bytes: 29428
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	if (M<=1){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	vector<int> a(M),b(M);
	multimap<int,int> A;
	int i;
	for (i=0;i<M;i++){
		cin>>a[i]>>b[i];
		A.insert(multimap<int,int>::value_type(a[i],b[i]));
	}
	multimap<int,int>::iterator mit;
	for (i=0;i<M;i++){
		if (a[i]==1){
			mit=A.find(b[i]);
			if (mit==A.end()){
				continue;
			}
			while ((*mit).first == b[i]){
				if ((*mit).second==N){
					cout<<"POSSIBLE"<<endl;
					return 0;
				}
				mit++;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 11136
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

ll fun(ll n)
{
	ll odd_sum=0,even_sum=0;
	while(n)
	{
		ll temp=n%10;
		n/=10;
		if(temp%2)
			odd_sum+=temp;
		else
			even_sum+=temp;
	}
	return abs(odd_sum-even_sum);
}
int main()
{
	fast();
	ll n,i;
	stack<char> stk;
	string s;
	cin>>n>>s;
	rep(i,n)
	{
		if(i==0)
			stk.push(s[i]);
		else
		{
			if(stk.top()!=s[i])
				stk.push(s[i]);
		}
	}
	cout<<stk.size();
}

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

bool pointsIsOnSide(int x, int y, int R, int C) {
	return x == 0 || x == R || y == 0 || y == C;
}

bool insertPoint(int x, int y, int i, int R, int C, vector<pair<int, pair<int, int> > > &sortedPoints) {
	if (y == 0) {
    sortedPoints.emplace_back(0, make_pair(-x, i));
  } else if (x == 0) {
   	sortedPoints.emplace_back(1, make_pair(y, i));
  } else if (y == C) {
    sortedPoints.emplace_back(2, make_pair(x, i));
  } else {
   	sortedPoints.emplace_back(3, make_pair(-y, i));
  }
  return true;
}

bool canConnect(vector<int> &x1, vector<int> &y1, vector<int> &x2, vector<int> &y2, int R, int C) {
	int valueCnt = (int) x1.size();
	vector<pair<int, pair<int, int> > > sortedPoints;
  for (int i = 0; i < valueCnt; i++) {
		if (!pointsIsOnSide(x1[i], y1[i], R, C) || !pointsIsOnSide(x2[i], y2[i], R, C)) {
			continue;
    }
    insertPoint(x1[i], y1[i], i, R, C, sortedPoints);
    insertPoint(x2[i], y2[i], i, R, C, sortedPoints);
  }

  sort(sortedPoints.begin(), sortedPoints.end());
  stack<int> valuesStack;
  vector<int> valuesVisited(valueCnt);
  for (auto point: sortedPoints) {
  	int value = point.second.second;
  	if (valuesStack.empty() || !valuesVisited[value]) {
    	valuesStack.push(value);
      valuesVisited[value] = 1;
    } else if (valuesStack.top() == value) {
      valuesStack.pop();
      valuesVisited[value] = 0;
    } else {
      return false;
    }
  }
  return true;
}

void solve() {
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> x1(N), x2(N), y1(N), y2(N);
	for (int i = 0; i < N; i++) {
		cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	}
	if (canConnect(x1, y1, x2, y2, R, C)) {
		cout << "YES";
	} else {
		cout << "NO";
	}
}

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


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

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    if(n%max(h,w)!=0)cout<<n/max(h,w)+1<<endl;
    else cout<<n/max(h,w)<<endl;
    return 0;
}

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

int main(){
    
    int a,b;
    cin>> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }
    else if(a < b){
        cout << "a < b" << endl;
    }
    else if(a == b){
        cout << "a == b" << endl;
    }
    else{
        cout << "!?" << endl;
    }
        return 0;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

int main(){
	int data, r, t, i,tate, yoko, kouho[4] = {0};
	int first[7] = {1,6,11,16,21,26,31}; 
	cin >> data;
	for(i = 0; i < data; i++){
		cin >> r >> t;
		tate = r / 100;
		yoko = t / 30;
		if(r % 100 == 0){
			if(t % 30 == 0) cout << first[yoko] + tate - 1 << endl;
			else cout << first[yoko] + tate - 1 << " " << first[yoko + 1] + tate - 1 << endl;
		}
		else{
			if(t % 30 == 0) cout << first[yoko] + tate - 1 << " " << first[yoko] + tate << endl;
			else cout << first[yoko] + tate - 1 << " " << first[yoko] + tate << " " << first[yoko + 1] + tate - 1 << " " << first[yoko + 1] + tate << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    int ret = 0;
    rep(j,n)rep(i,j){
        // i  j   k
        // a[k]  < a[i] + a[j];
        int top = n,bot = j;
        while(top - bot > 1){
            int mid = (top + bot)/2;
            if(a[mid] < a[i] + a[j])bot = mid;
            else top = mid;
        }
        ret += bot - j;
    }
    cout <<ret << endl;
    return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,q;
    cin >> n >> q;
    queue<int> Qi;
    queue<string> Qs;
    
    for(int i = 0; i < n; i++){
        int time;
        string name;
        cin >> name >> time;
        Qs.push(name);
        Qi.push(time);
    }
    
    int times = 0;
    
    while(!Qi.empty()){
        times += min(q,Qi.front());
        Qi.front() -= q;
        if(Qi.front() <= 0){
            int a = times;
            string s = Qs.front();
            Qi.pop();
            Qs.pop();
            cout << s << " " << a << endl; 
        }else{
            int b = Qi.front();
            string t = Qs.front();
            Qi.pop(); Qs.pop();
            Qi.push(b); Qs.push(t);
        }
    }
    return 0;
}


Measured memory_bytes: 5788
n,h=map(int,input().split())
num=[]
for i in range(n):
    a,b=map(int,input().split())
    num.append([a,0])
    num.append([b,1])
num.sort(reverse=True,key=lambda x: x[0])
ans=0
for i in range(n*2):
    if num[i][1]==1:
        ans+=1
        h-=num[i][0]
        if h<=0:
            break
    else:
        ans+=-(h//-num[i][0])
        break
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p[i];
  int min = p[0];
  int ans = 1;
  for(int i=1; i<n; i++) {
    if(p[i] <= min) {
      min = p[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
def resolve():
    from collections import deque

    n, m = map(int, input().split())
    d = {}
    par = [[] for i in range(n)]
    que = deque()
    for i in range(m):
        a, b = map(int, input().split())
        par[a - 1].append(b)
        par[b - 1].append(a)

    que.append(1)
    while(len(que) > 0):
        label = que.popleft()
        for i in par[label - 1]:
            if i not in d.keys():
                que.append(i)
                d[i] = label

    if len(d) < n:
        print("No")
        return

    print("Yes")
    for i in range(2, n + 1):
        print(d[i])

resolve()

Measured memory_bytes: 40760
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;

int main()
{
	in >> N;
	std::vector<LL>P(N), pos(N + 1);
	rep(i, N)
	{
		in >> P[i];
		pos[P[i]] = i;
	}
	LL res = 0, cou = 1;
	for (LL i = 1; i < N; ++i)
	{
		if (pos[i] < pos[i + 1]) ++cou;
		else
		{
			res = std::max(res, cou);
			cou = 1;
		}
	}
	res = std::max(res, cou);
	out << N - res << std::endl;
	return 0;
}


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

int main(){
    int n,m;
    int sum = 0;
    
    cin >> n >> m;
    //a = new int[n];
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(),a.end());
    if((double)a[n-m] >= (double)sum/(4*m)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    /*
    for(int i= 0; i < n; i++){
        cout << a[i] << " ";
    }
    */
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> A(3, 0);
    for (int i = 0; i < 3; i++) cin >> A[i];
    sort(A.begin(), A.end());
    printf("%d\n", A[0] + A[1]);
}

Measured memory_bytes: 3704
import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            int n = Integer.parseInt(sc.next());
            Map<String, Integer> mapG = new HashMap<String, Integer>();

            for(int i = 0; i < n; i++){
                String keihin = sc.next();
                if(mapG.containsKey(keihin)){
                    mapG.put(keihin, mapG.get(keihin) + 1);
                }else{
                    mapG.put(keihin, 1);
                }
            }

            System.out.println(mapG.size());

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  int m = 1000;
  for (int i = 0; i < N-2; i++) {
    string r = s.substr(i,3);
    int k = stoi(r);
    m = min(m, abs(k-753));
  }
  cout << m << endl;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    S = input()
    alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alp = list(alp)
    ans = ''
    for s in S:
        i = (alp.index(s) + N) % 26
        ans += alp[i]
    print(ans)


if __name__ == '__main__':
    solve()


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

const int INF = 1 << 30;
int h[100000];
int dp[100000];

// i番目の足場に行くまでの最小コストを返す関数
int rec(int i) {
	// メモされていたらメモされた値を返す
	if (dp[i] < INF) return dp[i];

	// i = 0 なら明示的に値を返す
	if (i == 0) return 0;

	// 再帰的にrecを呼び出す
	int ret = min(
		rec(i-1) + abs(h[i] - h[i-1]),
		i != 1 ? rec(i-2) + abs(h[i] - h[i-2]) : INF
	);

	// 結果をメモする
	dp[i] = ret;
	return ret;
}

int main() {
	// 入力を受け取る
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		// メモを初期化する
		dp[i] = INF;
	}

	cout << rec(n-1) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A; 
  int B;
  
  cin >> A >> B;
  
  int X;
  
  if (A <= 9 && B <= 9){
    X = A * B;
    cout << X;
  }
  
  else {
    cout << -1;
  }
}

Measured memory_bytes: 256
N=int(input())
takahashi=1
aoki=1
for i in range(N):
  T,A=map(int,input().split())
  n=max((takahashi+T-1)//T,(aoki+A-1)//A)
  takahashi=n*T
  aoki=n*A
print(takahashi+aoki)


Measured memory_bytes: 9132
#include<stdio.h>
int main(viud) {
    int n, x, y, N[300][3], i, j, count1, count2, count3, sum[300] = { 0 };
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d %d %d", &N[i][1], &N[i][2], &N[i][3]);
    }
    for ( i = 0; i < n; i++ ) {
        count1 = count2= count3 = 0;
        for ( j = 0; j < n; j++ ) {
            if ( i != j ) {
                if ( N[i][1] == N[j][1] ) count1++;
                if ( N[i][2] == N[j][2] ) count2++;
                if ( N[i][3] == N[j][3] ) count3++;
            }
            if ( count1 != 0 && count2 != 0 && count3 != 0 ) break;
        }
        if ( count1 == 0 ) sum[i] += N[i][1];
        if ( count2 == 0 ) sum[i] += N[i][2];
        if ( count3 == 0 ) sum[i] += N[i][3];
    }
    for ( i = 0; i < n; i++ ) printf("%d\n", sum[i]);
    return 0;
}

Measured memory_bytes: 1860
def g;gets.split.map &:to_i;end
while(x,y,z=g;x>0)
v=g
e=[]
r=(0..y).map{Hash.new{0}}
r[0][0]=1
z.times{n,*a=g;e[n]=a}
y.times{|i|o=d=0
t,u=e[i]
t&&(t<2?(o=u):(d=t<3?u:-u))
r[i].map{|k,w|k+=d;v.map{|j|r[[y,i+j+o].min][k<0?0:k]+=w.quo x}}
}
p r[y].map{|k,w|k*w}.inject(:+).to_i
end

Measured memory_bytes: 11168
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.next();
			int[] a = new int[4];
			int p;
			for(int i=0;i<s.length();i++){
				p = s.codePointAt(i);
				if(p==75) a[0]++;
				else if(p==85) a[1]++;
				else if(p==80) a[2]++;
				else if(p==67) a[3]++;
			}
			Arrays.sort(a);
			System.out.println(a[0]);
		}
	}	
}

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

struct point{ int x, y, id; };

point init(int pos_x, int pos_y, int index)
{
	point p; 
	p.x = pos_x, p.y = pos_y, p.id = index; 
	return p; 
}

bool cmp_x(const point &P1, const point &P2){ if(P1.x != P2.x){ return P1.x < P2.x; } return P1.y < P2.y; }
bool cmp_y(const point &P1, const point &P2){ if(P1.y != P2.y){ return P1.y < P2.y; } return P1.x < P2.x; }

void kd_tree(point *S, point *T, point *U, int left, int right, int d)
{
	if(right - left < 2) return;

	int mid = ((left + right) >> 1);
	int a = left, b = mid + 1;

	if((d & 1) == 0){
		for(int i = left; i < right; i++){
			if(cmp_x(T[i], S[mid])){
				U[a++] = T[i];
			}else if(S[mid].id == T[i].id){
				U[mid] = T[i];
			}else{
				U[b++] = T[i];
			}
		}
		for(int i = left; i < right; i++){ T[i] = U[i]; }

	}else{
		for(int i = left; i < right; i++){
			if(cmp_y(S[i], T[mid])){
				U[a++] = S[i];
			}else if(T[mid].id == S[i].id){
				U[mid] = S[i];
			}else{
				U[b++] = S[i];
			}
		}
		for(int i = left; i < right; i++){ S[i] = U[i]; }
	}
	kd_tree(S, T, U, left, mid, d + 1);
	kd_tree(S, T, U, mid + 1, right, d + 1);
}

int cnt;

void find_pt(int *Q, point *S, int sx, int tx, int sy, int ty, int left, int right, int d)
{
	if(left >= right) return;

	int mid = ((left + right) >> 1);
	point p = S[mid];
	int a = p.x, b = p.y;

	if(sx <= a && a <= tx && sy <= b && b <= ty){
		Q[cnt++] = p.id;
	}

	if((d & 1) == 0){
		if((left < mid) && (sx < a || (sx == a && sy <= b))){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
		if((mid + 1 < right) && (a < tx || (a == tx && b <= ty))){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
	}else{
		if((left < mid) && (sy < b || (sy == b && sx <= a))){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
		if((mid + 1 < right) && (b < ty || (b == ty && a <= tx))){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
	}
	return;
}

int main()
{
	point *S, *T, *U;
	int Q[100];
	int i, pos_x, pos_y, n;
	scanf("%d", &n);

	S = new point [n], T = new point [n], U = new point [n];

	for(i = 0; i < n; i++){
		scanf("%d %d", &pos_x, &pos_y);
		S[i] = init(pos_x, pos_y, i);
		T[i] = S[i];
	}
	sort(S, S + n, cmp_x);
	sort(T, T + n, cmp_y);

	kd_tree(S, T, U, 0, n, 0);

	int sx, tx, sy, ty, q;
	scanf("%d", &q);
	while(q){
		cnt = 0;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		find_pt(Q, S, sx, tx, sy, ty, 0, n, 0);
		sort(Q, Q + cnt);
		for(int i = 0; i < cnt; i++){ printf("%d\n", Q[i]); }
		printf("\n");
		q--;
	}

	return 0;
}

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

using namespace std;

int main()
{
	int n, d, cnt = 0;
	bool check[100] = { false };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d;
		check[d - 1] = true;
	}
	for (int i = 0; i < 100; i++) {
		if (check[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int h,w,a,b; cin>>h>>w>>a>>b;
    rep(i, h){
        rep(j, w){
            if((i<b && j<a) || (i>=b && j>=a)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int main(){
	double x1,x2;
	double y1,y2;
	
	cin>>x1>>y1>>x2>>y2;

	printf("%.8f\n",(double)sqrt(pow((x1-x2),2) + pow((y1-y2),2)));
	
	return 0;
}

Measured memory_bytes: 1240
from itertools import combinations


def solve():
    N = int(input())
    x = [[] for _ in range(N)]
    y = [[] for _ in range(N)]
    for i in range(N):
        A = int(input())
        xi = [0 for _ in range(A)]
        yi = [0 for _ in range(A)]
        for j in range(A):
            xi[j], yi[j] = map(int, input().split())
            xi[j] -= 1
        x[i] = xi
        y[i] = yi

    ans = 0
    for i in range(1, N+1):
        for honest_peoples in combinations(range(N), i):
            flag = True
            for honest_people in honest_peoples:
                for xij, yij in zip(x[honest_people], y[honest_people]):
                    if xij in honest_peoples and yij == 0 or xij not in honest_peoples and yij == 1:
                        flag = False
                        break
                if not flag:
                    break
            if flag:
                ans = max(ans, i)

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
x, n = map(int, input().split())
pli = [int(i) for i in input().split()]
ans = 0
for s in range(1, 51):
    if not x in pli:
        ans = x
    elif x in pli and not x - s in pli and not x + s in pli:
        ans = x - s
        break
    elif x in pli and x - s in pli and not x + s in pli:
        ans = x + s
        break
    elif x in pli and not x - s in pli and x + s in pli:
        ans = x - s
        break
    
print(ans)

Measured memory_bytes: 9204
using System;

class CF2016QAB
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] vals = Console.ReadLine().Split(' ');
		int[] a = new int[N+1];
		for(int i=1; i <= N; i++)
		{
			a[i] = int.Parse(vals[i-1]);
		}

		int ans = 0;
		bool[] check = new bool[N+1];
		for(int i=1; i<=N; i++)
		{
			if(check[i] == false && a[a[i]] == i)
			{
				ans++;
				check[a[i]] = true;
			}
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 18784
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h> 
using namespace std;   
int main()
{
	string s;
	cin>>s;
	if (s=="abc") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="acb") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="bca") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="bac") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="cba") 
	{
		cout<<"Yes";
		return 0;
	}
		if (s=="cab") 
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
    return 0;  
}

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

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

	vector<int>a(3 * n);
	for (int i = 0; i < 3 * n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	long long ans = 0;
	for (int i = a.size() - 2; i >= n;i-=2) {
		ans += a[i];
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int x, a, b, c;
  cin >> a >> b >> c >> x ;
  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      if ((x - 500 * i - 100 * j) % 50 == 0 && (x - 500 * i - 100 * j) / 50 <= c && x - 500 * i - 100 * j >= 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string s, t;
    cin >> s >> t;
    sort(ALL(s)); sort(ALL(t));
    reverse(ALL(t));
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,zrq;
int main() {
	cin>>a>>b>>c;
	if(b>=a) {
		cout<<1<<endl;
		exit(0);
} 
	if(c>=b) {     
		cout<<-1<<endl;
		return 0;
	}
	if((a-b)%(b-c)>=1)
		zrq=1;
	cout<<((a-b)/(b-c)+zrq)*2+1<<endl;
	return 0;
}

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll a,b,n; cin >> a >> b >> n;
	ll ans = -1e18;
	n = min(n,b);
	ans = max(ans,(a * n) / b - a * (n / b));
	n--;
	ans = max(ans,(a * n) / b);
	cout << ans << endl;
}

Measured memory_bytes: 3652
def main():
    buf = input()
    buflist = list(buf.split())
    M = int(buflist[0])
    K = int(buflist[1])
    numbers = []
    if K == 0:
        for i in range(2 ** M):
            numbers.append(i)
            numbers.append(i)
        print(' '.join(map(str, numbers)))
        return
    if K > 2 ** M - 1:
        print(-1) # impossible
        return
    xor_result = 0
    for i in range(2 ** M):
        if i == K:
            continue
        xor_result = xor_result ^ i
    if xor_result != K:
        print(-1) # impossible
        return
    for i in range(2 ** M):
        if i != K:
            numbers.append(i)
    numbers.append(K)
    for i in range(2 ** M - 1, -1, -1):
        if i != K:
            numbers.append(i)
    numbers.append(K)
    print(' '.join(map(str, numbers)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 31640
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200006;
const int INF = (int)1e9;
int e_num = 1, S, T;
int hed[maxn], dep[maxn];
struct Edge {
  int from, to, nxt, c;
} edge[maxn * 4];
void addedge(int from, int to, int c) {
  edge[++e_num] = (Edge){from, to, hed[from], c};
  hed[from] = e_num;
}
void adde(int from, int to, int c) {
  addedge(from, to, c);
  addedge(to, from, 0);
}
int que[maxn + 5], head = 0, tail = 0;
bool bfs() {
  head = tail = 0;
  que[tail++] = S;
  memset(dep, 0, sizeof dep);
  dep[S] = 1;
  while (head != tail) {
    int cur = que[head++]; head %= maxn;
    for (int i = hed[cur]; i; i = edge[i].nxt) {
      int to = edge[i].to;
      if (!dep[to] && edge[i].c) {
        dep[to] = dep[cur] + 1;
        que[tail++] = to; tail %= maxn;
      }
    }
  }
  return dep[T];
}
int hed2[maxn];
int dfs(int x, int flow) {
  if (x == T) return flow;
  int ret = 0;
  for (int &i = hed2[x]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (dep[to] == dep[x] + 1 && edge[i].c) {
      int tmp = dfs(to, min(flow, edge[i].c));
      edge[i].c -= tmp;
      edge[i ^ 1].c += tmp;
      flow -= tmp;
      ret += tmp;
      if (!flow) {
        break;
      }
    }
  }
  if (!ret) dep[x] = 0;
  return ret;
}
int dinic() {
  int ret = 0;
  while (bfs()) {
    memcpy(hed2, hed, sizeof hed);
    ret += dfs(S, INF);
  }
  return ret;
}

int n, p[maxn], q[maxn], bp[maxn], bq[maxn], cnt;
void solve(int *p, int *bel) {
  for (int i = 1; i <= n; i++) if (!bel[i]) {
    int x = i;
    ++cnt;
    do {
      bel[x] = cnt;
      x = p[x];
    } while (x != i);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    ++p[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &q[i]);
    ++q[i];
  }
  solve(p, bp);
  solve(q, bq);
  S = 0, T = ++cnt;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i] == i && q[i] == i) {
      ans++;
    } else if (q[i] == i) {
      adde(S, bp[i], 1);
    } else if (p[i] == i) {
      adde(bq[i], T, 1);
    } else {
      addedge(bq[i], bp[i], 1);
      addedge(bp[i], bq[i], p[i] == q[i]);
    }
  }
  ans += dinic();
  printf("%d\n", n - ans);
  return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int k, s;
int ans = 0;
/**********************************************/

int main(){
    cin >> k >> s;
    
    FOR(i, 0, k+1){
        FOR(j, i, k+1){
            if(i+j+(s-i-j) == s && (s-i-j) <= k && (s-i-j) >= j){
                if(i == j && i == (s-i-j)) ans++;
                else if(i == j || j == (s-i-j) || (s-i-j) == i) ans += 3;
                else ans += 6;
                //cout << i << " " << j << " " << (s-i-j) << endl;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> t(n);
    int sum = 0;
    rep(i, 0, n)
    {
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    rep(i, 0, m)
    {
        int p, x;
        cin >> p >> x;
        cout << sum - t[p-1] + x << endl;
    }
    return 0;
}

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

int main() {
    int N, count = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i < N - 1; i++) {
        if (S.at(i) == S.at(i + 1)) {
            count++;
        }
    }
    cout << N - count << endl;
}


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

int bukket[10001];

int main(){
	ios_base::sync_with_stdio(false);

	int num;
	cin >> num;
	while(cin >> num){
		bukket[num] ++;
	}

	for(int i = 0; i < 10001; i++){
		if(bukket[i] > 0){
			cout << i;
			bukket[i] --;
			break;
		}
	}


	for(int i = 0; i < 10001; i++){
		while(bukket[i] > 0){
			cout << " " << i;
			bukket[i] --;
		}
	}

	cout << endl;
	

	return 0;
}

Measured memory_bytes: 1244
#053 b-a to z string
s=input()
a=0
z=0
flag=True
for i in range(len(s)):
    if flag:
        if s[i]=="A":
            a=i
            flag=False
    if s[i]=="Z":
        z=i
ans=len(s[a:z+1])
print(ans)

Measured memory_bytes: 3516
using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
     
    namespace AtCoder
    {
        class Program
        {
            static void Main(string[] args)
            {
                var r = long.Parse(Console.ReadLine());
                Console.WriteLine(r * r);
            }
        }
    }

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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
 fastIO();
 string s , t ; long long cnt=0;
 bool ok = true;
 
 cin>>s>>t;
 for(int i=0; i<s.size(); i++)
 {
 	if(s[i] != t[i])
 	{
 		cnt++;
	 }
 }
 cout<<cnt<<endl;

return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, cnt = 0; string S;

int main() {
	cin >> N >> S;
	for (int i = 0; i < N - 2; i++) {
		if (S.substr(i, 3) == "ABC") cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a = 0;
  int b = 0;
  scanf("%d%d",&a,&b);
  if(a<b) printf("a < b\n");
  else if(a>b) printf("a > b\n");
  else printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vll m(n,0);
   for(int i=0;i<=x;i++)
   {
           //cout<<i<<" hh ";
        for(int j=i+1;j<n;j++)
        {
              ll dis = 0;
              if(j>x && j<y)
              {
                      ll z = (x-i) + (y-j) + 1;
                      dis = min(ll(j-i),z);
              }
              else if(j<=x)
              {
                   dis = (j-i);      
              }
              else
              {
                      dis = (x-i) + (j-y) + 1;
              }
              m[dis]++;
        }

   }
   
   for(int i = y;i<n;i++)
   {
        //cout<<i<<" po "<<y<<endl;   
        for(int j=i+1;j<n;j++)
        {
                 ll dis = 0;
                 dis = (j-i);
                 m[dis]++;
        }
        for(int j=x+1;j<y;j++)
        {
                ll dis = 0;
                ll z = (j-x) + (i-y) + 1;
                dis = min(ll(i-j),z);
                m[dis]++;
        }
   }
   
   for(int i=x+1;i<y;i++)
   {
        for(int j=i+1;j<y;j++)
        {
                ll dis = 0;
                ll z = (i-x) + (y-j) + 1;
                dis = min(ll(j-i),z);
                m[dis]++;
        }
   }
   
   for(int i=1;i<n;i++)
   {
           cout<<m[i]<<endl;
   }
   
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, 0, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
}


Measured memory_bytes: 19280
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    string s;
    cin>>n>>s;
    lli ans=n;
    rep(i,n-1){
        if(s[i]==s[i+1]){ 
            ans--;
        }
    }
    out(ans);
}

Measured memory_bytes: 3744
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Set<Integer> s = new HashSet<>();

			for (int i = 1; i < 10; i++) {
				for (int j = i; j < 10; j++) {
					s.add(i * j);
				}
			}
			if (s.contains(n)) {
				System.out.print("Yes");
			} else {
				System.out.print("No");
			}
		}
	}
}


Measured memory_bytes: 23764