akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()

using namespace std;

long a, b, c, d, i, j, k, n;


int main(){
//////////////////////////////////////////////////////


    //cout << "Hello, World!" << endl;

    cin >> n;

    // cout << "n:" << n << endl;

    long cnta = 0, cntb = 0, cntab = 0;

    long answer = 0,includeab = 0;


    vector<string> input(n);
    for (int i = 0 ; i < n ; i ++ )
    {
        cin >> input[i];
        //cout << "input[" << i << "]=" << input[i] << endl;

        bool bflag = false, aflag = false;

        //集計作業
        long len = input[i].length();
        if ( input[i][0] == 'B' )bflag = true;
        if ( input[i][len - 1] == 'A')aflag = true;
        
        if ( aflag && bflag)cntab ++;
        if ( aflag && !bflag)cnta ++;
        if ( !aflag && bflag)cntb ++;

        //文内AB検出作業
        long cntabstr = 0;
        for ( int j = 0 ; j < len - 1 ; j ++ )
        {
            if (input [i][j] == 'A' && input[i][j+1] == 'B')
            {
                cntabstr ++ ;
            }
        }

        //cout << input[i] << ":" << cntabstr << endl;
        answer += cntabstr;
        includeab += cntabstr;
    }

    // cout << "includeab num:" << includeab << endl;
    // cout << "cntab num:" << cntab << endl;
    // cout << "cnta num:" << cnta << endl;
    // cout << "cntb num:" << cntb << endl;

    //BxxxAの数が複数ならば足す
    if( cntab >= 2){
        answer += cntab - 1;
        //cout << "Adds by BxxxA: " << cntab - 1 << endl;
    }

    //Aで終わるやつとBxxxAの組み合わせ
    if( cnta > 0 && cntab > 0){
        answer ++;
        //cout << "Add by xxxxA + BxxxA: " << 1 << endl;
        cnta--;
    }

    //BxxxAとBで始まるやつの組み合わせ
    if( cntb > 0 && cntab > 0){
        answer ++;
        //cout << "Add by BxxxA + Bxxxx: " << 1 << endl;
        cntb--;
    }

    //Aで終わるやつとBで始まるやつの組み合わせ
    if ( cnta > 0 && cntb > 0)
    {
        answer += min(cnta,cntb);
        //cout << "Add by xxxxA + Bxxxx: " << max(cnta,cntb) << endl;
    }
    

    

    // sort(input.begin() , input.end());

    // uint64_t max = numeric_limits<uint64_t>::max();



    // long sum = 0;
    // for ( int i = 0 ; i < n ; i ++ )
    // {
    //     sum += i;
    // }





    cout << answer << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
bool comp(const string& a, const string& b)
{
  if(a[0] == 'i') return(false);
  if(b[0] == 'i') return(true);
  if(a.size() != b.size()) return(a.size() > b.size());
  return(a > b);
}

string S;
string dp[50][51];

string tonum(int left, int right)
{
  string ss;
  if(S[left] == '0' && left + 1 < right) return("invalid");
  while(left < right) {
    if(!isdigit(S[left]) && S[left] != '?') return("invalid");
    if(!isdigit(S[left])) ss += "9";
    else ss += S[left];
    ++left;
  }
  return(ss);
}
string rec(int left, int right)
{
  
  if(dp[left][right] != "*") return(dp[left][right]);
  string ret = tonum(left, right);
  if(right - left >= 6) {
    if((S[left + 1] == '?' || S[left + 1] == '(') && (S[right - 1] == '?' || S[right - 1] == ')')) {
      for(int i = left + 3; i + 3 <= right; i++) {
        if(S[i] == '?' || S[i] == ',') {
          string L = rec(left + 2, i), R = rec(i + 1, right - 1);
          if(L[0] == 'i' || R[0] == 'i') continue;
          if(S[left] == 'L' || S[left] == '?') ret = min(ret, L, comp);
          if(S[left] == 'R' || S[left] == '?') ret = min(ret, R, comp);
        }
      }
    }
  }
  return(dp[left][right] = ret);
}

int main()
{
  fill_n(*dp, 50 * 51, "*");
  cin >> S;
  cout << rec(0, S.size()) << endl;
}

Measured memory_bytes: 1368
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, M, L;
    cin >> N >> M >> L;

    vll A, B, C;
    REP(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        A.pb(a); B.pb(b); C.pb(c);
    }

    vector<vll> D(N, vll(N, INF));
    REP(i, N) D[i][i] = 0;
    vector<vll> F(N, vll(N, INF));
    REP(i, N) F[i][i] = 0;

    REP(i, M) {
        D[A[i]][B[i]] = min(D[A[i]][B[i]], C[i]);
        D[B[i]][A[i]] = min(D[A[i]][B[i]], C[i]);
    }

    REP(i, N) {
        REP(j, N) {
            REP(k, N) {
                D[j][k] = min(D[j][k], D[j][i] + D[i][k]);
            }
        }
    }

    REP(i, N) {
        REP(j, N) {
            if (i == j) continue;
            if (D[i][j] <= L) F[i][j] = 1LL;
        }
    }

    REP(i, N) {
        REP(j, N) {
            REP(k, N) {
                F[j][k] = min(F[j][k], F[j][i] + F[i][k]);
            }
        }
    }

    int Q; cin >> Q;
    REP(i, Q) {
        int s, t;
        cin >> s >> t;
        --s; --t;

        print(F[s][t] < INF ? F[s][t] - 1 : -1);
    }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n, k;
    cin >> n >> k;

    if((n-1)*(n-2)/2<k){
        cout << -1 << endl;
        return 0;
    }

    ll lim = (n-1)*(n-2)/2 - k;
    cout << n-1 + lim << endl;
    for(int i = 2; i <= n; i++){
        cout << "1 " << i << endl;
    }
    for(int i = 2; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            if(lim>0){
                cout << i << " " << j << endl;
                lim--;
            }else{
                i = j = n+1;
            }
        }
    }
    return 0;

}


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

long long int a,b,c;

void solve(){
	cin >> a >> b >> c;
	long long int ans;
	ans = b/c - a/c;
	if(a%c == 0){
		ans++;
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    
    int n, m;
    int a[3];
    cin >> n >> m;
    rep(i, 3) cin >> a[i];
    
    vector<int> g[n];
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        g[s].eb(t);
    }
    
    set<int> to[n][107];
    // iからj stepで行けるとこ
    // bfsだけどqueueでやると無限ループもあるし...
    // rep(cnt, 106) {
        rep(v, n) { // vからiで行けるとこ
            // if (cnt == 0) {
                for (int nxt : g[v]) {
                    to[v][1].insert(nxt);
                }
            // }
            rep3(i, 2, 105) {
                // vからi-1で行けるとこから行けるとこ
                for (int now : to[v][i - 1]) {
                    for (int nxt : g[now]) {
                        to[v][i].insert(nxt);
                    }
                }
            }
        }
    // }
    /*
    rep(v, n) rep(i, 5) {
        cout << v << " " << i << endl;
        for (int tmp : to[v][i]) cout << tmp << " "; cout << endl;
    }
    */
    vector<int> d(n, inf);
    d[n - 1] = 0;
    int cnt = 0;
    while (1) {
        cnt++;
        if (cnt == 2 * n) {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
        
        int update = 0;
        rep(v, n) {
            int tD = 0;
            rep(i, 3) {
                int D = inf;
                for (int va : to[v][a[i]]) {
                    chmin(D, d[va]);
                }
                // cout << v << " " << a[i] << " " << D << endl;
                chmax(tD, D);
            }
            tD++;
            if (tD < d[v]) {
                update = 1;
                d[v] = tD;
            }
        }
        if (update == 0) break;
    }
    if (d[0] != inf) cout << d[0] << endl;
    else cout << "IMPOSSIBLE" << endl;
}






Measured memory_bytes: 15424
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	long long h, w;
	cin >> h >> w;

	if (h == 1 || w == 1) {
		cout << 1 << endl;
		return 0;
	}

	long long ans = ceil(w / 2.0) * ceil(h / 2.0) + (w / 2) * (h / 2) ;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

string toString(int x)
{
	stringstream ss; ss << x;
	return ss.str();
}

string rootString(int f, int t)
{
	int b = f < t ? 1 : -1;
	
	string res;
	
	for(int i = f; i != t; i += b)
		res += toString(i);
	
	return res + toString(t);
}

void print(string s)
{
	rep(i, s.size())
		cout << s[i] << (i == s.size() - 1 ? "\n" : " ");
}

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		int f, t;
		cin >> f >> t;
		
		if(f < t)	print(rootString(f, t));
		else
		{
			if(f <= 5)	print(rootString(f, t));
			else if(t < 5) print(rootString(f, 9) + toString(5) + rootString(4, t));
			else if(t == 5) print(rootString(f, 9) + toString(5));
			else print(rootString(f, 9) + rootString(5, 0) + rootString(1, t));
		}
	}
}

Measured memory_bytes: 0
def calc(answer, S, L_or_R, rev):
    stock = 0
    for i, s_i in enumerate(S):
        if s_i == L_or_R:
            answer[[i-1, -i][rev]] += stock // 2 + [0, 1][stock % 2 == 1]
            answer[[i, -i-1][rev]] += stock // 2
            stock = 0
        else:
            stock += 1
    return answer

def main():
    s1 = input()
    s2 = s1[::-1]
    answer = [0 for i in range(len(s1))]
    answer = calc(answer, s1, "L", 0)
    answer = calc(answer, s2, "R", 1)
    print(*answer)


main()

Measured memory_bytes: 6504
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#define LL long long
using namespace std;
const int M =1e5+5;
int A[M];
int main() {
    int n;
    scanf("%d",&n);
    for(int j=1;j<=n;j++){
        int a;
        scanf("%d",&a);
        A[a]++;
    }
    int cnt=0;
    for(int j=0;j<=M-5;j++){
        if(A[j]) cnt+=A[j]-1;
    }
    if(cnt&1) printf("%d\n",n-cnt-1);
    else printf("%d\n",n-cnt);
    return 0;
}


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

int n;
string s;

bool can_make(string a, string b)
{
    for (int i = 0; i < b.size(); i++)
    {
        if (a[0] == b[i])
        {
            for (int j = i + 1; j < b.size(); j++)
            {
                if (a[1] == b[j])
                {
                    int p = 2;
                    for (int k = j + (j - i); k < b.size(); k += j - i)
                    {
                        if (p == a.size())
                            return true;
                        if (a[p] == b[k])
                            p++;
                        else
                            break;
                    }
                    if (p == a.size())
                        return true;
                }
            }
        }
    }
    return false;
}

int main()
{
    int ans = 0;
    cin >> n >> s;
    for (int i = 0; i < n; i++)
    {
        string t;
        cin >> t;
        ans += can_make(s, t);
    }
    cout << ans << endl;
}



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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int xmin = 0, xmax = w, ymin = 0, ymax = h;

  for (int i = 0; i < n; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      xmin = max(xmin, x);
    } else if (a == 2) {
      xmax = min(xmax, x);
    } else if (a == 3) {
      ymin = max(ymin, y);
    } else {
      ymax = min(ymax, y);
    }
  }
  int ans = 0;
  if (xmin < xmax && ymin < ymax) ans = (xmax - xmin) * (ymax - ymin);
  printf("%d", ans);
  
}

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





void solve()
{


ll a,b;
cin>>a>>b;
cout<<a*b;


}


int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);


		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3592
#include <stdio.h>

int Prime_numbers(int);

int main(){
  int N,n,i,j=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&n);
    if(Prime_numbers(n)==1)j++;
  }

  printf("%d\n",j);

  return 0;
}

int Prime_numbers(int n)
{
  int i,flag=0;
  
  if(n==2)return 1;
  if(n==3)return 1;

    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)return 0;
    }

    return 1;
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;
    } else if (k <= a + b) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s,a[25],b[100],n,k,i; 
int main()
{

  int j,m,t;	 
  char x,y;
cin>>m;  
if (m%10==m/100) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 return 0;     
} 

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <cstdint>


using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	if(n>=2*k-1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;

}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main  implements Runnable {
	Random rnd = new Random();
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[][] a = new int[m][2];
		for (int i = 0; i < m; i++) {
			a[i][0] = Integer.parseInt(sc.next());
			a[i][1] = Integer.parseInt(sc.next());
		}
		Arrays.parallelSort(a, (aa, ab) -> Integer.compare(ab[1], aa[1]));
		Arrays.parallelSort(a, (aa, ab) -> Integer.compare(aa[0], ab[0]));
		int ans = 0;
		int ca = 0;
		int cut = 0;
		for (int i = 0; i < m; i++) {
			if(cut < a[i][0])
			{
				ca = a[i][0];
				ans++;
				cut = a[i][1]-1;
			}
			else if(cut > a[i][1]-1){
				cut = a[i][1]-1;
			}
		}
		out.println(ans);
		out.flush();
	}
}

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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    string l;
    cin >> l;
    int n1=0,n2;
    if (l[0]==l[1] && l[2]==l[3] && l[1]!=l[3]) cout << "Yes" << endl; 
    else if (l[0]==l[2] && l[1]==l[3] && l[2]!=l[3]) cout << "Yes" << endl;
    else if (l[0]==l[3] && l[1]==l[2] && l[2]!=l[3]) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,x[107],y[107],h[107],H,T;
  cin >> N;
  rep(i,N){
    cin >> x[i] >> y[i] >> h[i];
  }
  rep(i,101){
    rep(j,101){
      T=0;
      rep(k,N){
        if(h[k]>0){
          H=abs(i-x[k])+abs(j-y[k])+h[k];
       }
      }
      rep(k,N){
        if(max(0LL,H-(abs(i-x[k])+abs(j-y[k])))!=h[k]){
          T=1;
        }
      }
      if(T==0){
        cout << i << " " << j << " " << H << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long D, A;

struct teki {
    long long x;
    long long h;
    long long atk;
};

vector<teki> enemy;

bool cmp(const teki &a, const teki &b) {
    return a.x < b.x;
}

bool isOK(int index, long long key) {
    if(enemy.at(index).x <= key) return true;
    else return false;
}

int Binary_search(long long key, int ok, int ng) {

    while(abs(ok-ng) > 1) {
        int mid = (ok+ng) / 2;
        if(isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ng;
}

int main() {
    cin >> n >> D >> A;
    enemy = vector<teki>(n);
    for(int i = 0; i < n; ++i) {
        cin >> enemy.at(i).x >> enemy.at(i).h;
        enemy.at(i).atk = 0;
    }

    sort(enemy.begin(), enemy.end(), cmp);

    long long cnt = 0;
    for(int i = 0; i < n; ++i) {
        long long rest = enemy.at(i).h - enemy.at(i).atk;
        if(rest > 0) {
            long long nowcnt = (rest+A-1)/A;
            cnt += nowcnt;
            long long hitp = nowcnt*A;
            long long dist = enemy.at(i).x + 2*D;
            int limit = Binary_search(dist, i, n);
            enemy.at(i).atk += hitp;
            if(limit != n) enemy.at(limit).atk -= hitp;
        }
        if(i != n-1) enemy.at(i+1).atk += enemy.at(i).atk;
    }

    cout << cnt << endl;
}


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

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(q);
  vector<int>b(n,k-q);
  //最初にkポイント持っているが、一律、問題数マイナス
  
  rep(i,q){
    cin>>a[i];//入力
    --a[i];//正解者の番号は1始まりなので調整
    b[a[i]]++;//正解者にはプラス1
  }
  
  rep(j,n){//条件分岐して出力
    if(b[j]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
N, M, C=[int(i) for i in input().split()]
B      =[int(i) for i in input().split()]
count=0

for _ in range(N):
    A = [int(i) for i in input().split()]
    s = C
    for i in range(M):
        s += A[i]*B[i]

    if s>0:
        count += 1

print(count)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		int k = Integer.parseInt(tmpArray[2]);

		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] friends = new ArrayList[n];
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] block = new ArrayList[n];

		DisjointSet unionFind = new DisjointSet(n);

		for(int i = 0; i < n; i++){
			friends[i] = new ArrayList<Integer>();
			block[i] = new ArrayList<Integer>();
		}

		for(int i = 0; i < m; i++){
			tmpArray = br.readLine().split(" ");
			int a = Integer.parseInt(tmpArray[0]) - 1;
			int b = Integer.parseInt(tmpArray[1]) - 1;

			friends[a].add(b);
			friends[b].add(a);

			unionFind.union(a, b);
		}

		for(int i = 0; i < k; i++){
			tmpArray = br.readLine().split(" ");
			int c = Integer.parseInt(tmpArray[0]) - 1;
			int d = Integer.parseInt(tmpArray[1]) - 1;

			block[c].add(d);
			block[d].add(c);
		}

		int[] groupMember = new int[n];
		for(int i = 0; i < n; i++){
//			System.out.print(unionFind.findSet(i) + " ");
			groupMember[unionFind.findSet(i)]++;
		}
//		System.out.println();

		for(int i = 0; i < n; i++){
			int count = groupMember[unionFind.findSet(i)] - friends[i].size() - 1;

			int innerBlock = 0;

			Iterator<Integer> it = block[i].iterator();

			while(it.hasNext()){
				if(unionFind.isSameSet(i, it.next())){
					innerBlock++;
				}
			}

			count -= innerBlock;
//			for(int j = 0; j < n; j++){
//				if(i == j){
//					continue;
//				}
////				System.out.println("i = "+i+" j = "+j);
//				if(block[i].contains(j) || friends[i].contains(j)){
////					System.out.println("friend or block");
//					continue;
//				}
//
//				if(unionFind.isSameSet(i, j)){
//					count++;
//				}
//			}
			System.out.print(count);
			if(i != n - 1){
				System.out.print(" ");
			}
		}
		System.out.println();
	}

}

class DisjointSet {
	private int n;
	private int[] p;
	private int[] rank;

	public DisjointSet(int n){
		this.n = n;

		p = new int[n + 1];
		rank = new int[n + 1];

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

	private void makeSet(int x){
		p[x] = x;
		rank[x] = 0;
	}

	public void union(int x, int y){
		link (findSet(x), findSet(y));
	}

	//今回の問題では特別にpublic
	public int findSet(int x){
		if(x != p[x]){
			p[x] = findSet( p[x]);
		}
		return p[x];
	}

	public boolean isSameSet(int x, int y){
		return findSet(x) == findSet(y);
	}

	private void link(int x, int y){
		if(rank[x] > rank[y]){
			p[y] = x;
		}
		else {
			p[x] = y;
			if(rank[x] == rank[y]){
				rank[y]++;
			}
		}
	}
}

Measured memory_bytes: 96608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
bool judge_bc(string const& s,int k,int len){
  if(k==len)return false;
  return s[k]=='B'&&s[k+1]=='C';
}
int main(){
  string s;cin>>s;
  int n=(int)s.length();
  ll ans=0;
  int sum_a=0;
  rep(i,n){
    if(s[i]=='A')sum_a++;
    else if(judge_bc(s,i,n-1)){
      ans+=sum_a;
      i++;
    }
    else{
      sum_a=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main()
{
	ifstream fin("bcs.in");
	ofstream fout("bcs.out");
	int k;
	cin>>k;
	int seq=0;
	int i=1;
	while(i<=1e7) {		
		seq=((10*seq)+7)%k;
		if (seq==0) {
			cout<<i<<endl;
			return 0;
		}

		i++;
		
	}
	cout<<-1<<endl;
	
	
}



Measured memory_bytes: 3572
import math
X = int(input())
if X == 2:
    print(2)
else:
    is_end = False
    while not is_end:
        is_end = True
        for i in range(1, X // 2):
            if math.gcd(X, i) != 1:
                is_end = False
                X += 1
                break
    print(X)

Measured memory_bytes: 9180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 5010

vector<int> tree[SIZE];

int n, x[SIZE];
ll dp[SIZE][SIZE][2];
ll ave, num_plus;

pair<int, ll> dfs(int now = 0, int back = -1, int cost = INF){ //{numOfChilds, sumOfChildsX} 
  ll numOfChilds = 0, sum = 0;

  dp[now][0][0] = 0;
  
  for(int to : tree[now]){
    if(back == to) continue;
    auto res = dfs(to, now, 1);

    for(int i=0;i<=numOfChilds;i++){
      for(int j=0;j<=res.first;j++){
        dp[now][i+j][1] = min(dp[now][i+j][1], dp[now][i][0] + dp[to][j][0]);
      }
    }

    for(int i=0;i<=numOfChilds+res.first;i++){
      dp[now][i][0] = dp[now][i][1];
      dp[now][i][1] = LLINF;
    }
    
    numOfChilds += res.first;
    sum += res.second;
  }

  sum += x[now];
  numOfChilds += 1;
  
  for(int i=numOfChilds;i>=0;i--){
    ll add_cost = abs(sum - (ave*numOfChilds + (i+1))) * cost;
    dp[now][i+1][0] = min(dp[now][i+1][0], dp[now][i][0] + add_cost);
    ll add_cost2 = abs(sum - (ave*numOfChilds + i)) * cost;
    dp[now][i][0] = dp[now][i][0] + add_cost2; 
  }
  
  return {numOfChilds, sum};
}

int main(){
  ll sumx = 0;
  
  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d", x+i);
    sumx += x[i];
  }

  ave = sumx / n;
  num_plus = sumx % n;
  
  for(int i=0;i<n-1;i++){
    int u, v;
    scanf("%d%d", &u, &v);
    u--; v--;

    tree[u].push_back(v);
    tree[v].push_back(u);
  }

  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
      dp[i][j][0] = dp[i][j][1] = LLINF;

  dfs();

  cout << dp[0][num_plus][0] << endl;
  
  return 0;
}



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

#define INF 100000000
int dp[1005][10005] ={{INF}};
// i番目までの魔法を使ったときにモンスターの体力をj減らすのに消耗する魔力の最小値

int main() {
  int H, N;
  vector<int> as, bs;
  cin >> H >> N;
  int a, b;
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    as.push_back(a);
    bs.push_back(b);
  }

  for (int i = 0; i < N+1; i++)
  {
    for (int j = 0; j < H+1; j++)
    {
      dp[i][j] = INF;
    }
  }  

  for (int i = 0; i < N+1; i++)
  {
    dp[i][0] = 0;
  }
  
  for (int i = 0; i < N; i++)
  {
    a = as[i];
    b = bs[i];
    for (int j = 0; j < H+1; j++)
    {
      if (j-a <= 0)   
      {
        dp[i+1][j] = min(dp[i][j], dp[i][0]+b);
      }   
      else {
        dp[i+1][j] = min(dp[i][j], dp[i+1][j-a]+b);
      }
    }
  }

  cout << dp[N][H] << endl;
  
}

Measured memory_bytes: 39552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int a, b, t;
    cin >> a >> b >> t;

    int ans = 0;
    for(int i = a; i < t+0.5; i += a){
        ans += b;
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	string s;
	string ret = "";

	cin >> s;

	rep(i, s.length())
	{
		if ( (i + 1) % 2 == 1)
		{
			ret += s.at(i);
		}
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 512
import itertools
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for i in range(n):
    s = input()
    for e in ["M", "A", "R", "C", "H"]:
        if s[0] == e:
            d[e] += 1

sum_num = 0
l = ["M", "A", "R", "C", "H"]
for a, b, c in itertools.combinations(l, 3):
    sum_num += d[a] * d[b] * d[c]
print(sum_num)

Measured memory_bytes: 9480
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){
  std::queue<int> quet;
  std::queue<string> quen;

  int n, q, i, time, sum_times=0;
  string name;

  cin >> n >> q;

  for(i=0;i<n;i++){
    cin >> name >> time ;
    quen.push(name);
    quet.push(time);
  }
  
  while(quen.size()!=0){

    if(quet.front()<=q){
      cout << quen.front() << " " << quet.front()+sum_times << "\n";
      sum_times += quet.front();
      quen.pop();
      quet.pop();
    }
    
    else{
      name = quen.front();
      time = quet.front() - q;
      quen.pop();
      quet.pop();
      quen.push(name);
      quet.push(time);
      sum_times += q;
    }
      
  
  }
  return 0;
}

Measured memory_bytes: 5768
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;
//typedef __int64 ll;

int const Max_N = 1e6+5;
int main()
{
 	int N,K;
	cin >> N;
	int a[500];
	cin >> K;
	rep(i,0,N) cin >> a[i];
	sort(a,a+N);
	int sum = 0;
	int p = 0;
	for(int i = N-1; i > -1; --i)
	{
		++p;
		if(p>K) break;
		sum += a[i];
	 } 
	 cout << sum << endl;

	return 0;
}
	//freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);



Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())
total = 0
if A+B <= 2*C:
    total =A*X + B*Y
else:
    if X>Y:
        total += 2*C *Y
        if A > 2*C:
            total += 2*C * (X-Y)
        else:
            total += A * (X-Y)
    elif X<Y:
        total += 2*C *X
        if B > 2*C:
            total += 2*C * (Y-X)
        else:
            total += B * (Y-X)
    elif X==Y:
        total += 2*C * X
print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <list>
#include <queue>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> jobs(M);
    for(int i = 0; i < N; ++i){
        int a, b;
        cin >> a >> b;
        if(a > M) continue;
        jobs[M-a].push_back(b);
    }

    long long ans = 0;
    priority_queue<int> q;

    for(int i = M-1; i >= 0; --i){
        for(auto& b : jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 5504
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	string s, t;cin >> s >> t;
	if(s.size() != t.size()){
		puts("No");
		return 0;
	}
	else{
		map<char, char> m;
		map<char, set<char> > cnt;
		for(int i = 0; i <(int)s.size(); i++){
			m[s[i]] = t[i];
			cnt[t[i]].insert(s[i]);
		}
		string fin;
		for(auto i:s){
			if(cnt[m[i]].size() > 1){
				puts("No");
				return 0;
			}
			fin += m[i];
		}
		if(fin == t){
			puts("Yes");
		}else{
			puts("No");
		}
		//deb(fin, t);
	}
	return 0;
}


Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std; 
int t[103];
int main(){
	fastIO;         
	int n,m;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>t[i];
		ans+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int p,x;	
		cin>>p>>x;
		cout<<ans-t[p]+x<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s = "CODEFESTIVAL2016", t;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> t;
	int cnt = 0;
	FOR(i, t.size()) {
		if (t[i] != s[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=count(s.begin(),s.end(),'R');
    int b=count(s.begin(),s.end(),'B');
    if(r>b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
return 0;
}


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

#define Ff(i,a,b) for(i=a;i<b;i++)
#define Fb(i,a,b) for(i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define mp make_pair
#define PI 2*asin(1)
#define all(x) x.begin(),x.end()
#define trav(x) for(auto& i:x)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #define in(a,x) scanf("%a",&x)
// #define out(a,x) printf("%a",x)

// #define int long long

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<long long> vll;
typedef map<int, int> mi;
typedef map<long long, long long> mll;
typedef unordered_map<int, int> umi;
typedef unordered_map<long long, long long> umll;
typedef set<int> si;
typedef set<long long> sll;
typedef unordered_set<int> usi;
typedef unordered_set<long long> usll;

const ll N = 1e9 + 7;

// #define int long long

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

bool comp(pair<int, int>a, pair<int, int>b) {
	return (a.ss > b.ss);
}

void solve() {
	int n, m;
	cin >> n >> m;
	unordered_map<int, int> x, y;
	int k, i;
	cin >> k;
	int g, h;
	// int p[n + 1][m + 1] = {0};
	set<pair<int, int>>s;
	Ff(i, 0, k) {
		cin >> g >> h;
		// p[g][h] = 1;
		s.insert(mp(g, h));
		x[g]++;
		y[h]++;
	}
	int ma = -1, mb = -1;
	trav(x) {
		if (i.ss > ma)
			ma = i.ss;
	}
	trav(y) {
		if (i.ss > mb)
			mb = i.ss;
	}
	vector<int>a, b;
	for (auto it = x.begin(); it != x.end(); it++)
		if (it->ss == ma)a.pb(it->ff);
	x.clear();
	for (auto it = y.begin(); it != y.end(); it++)
		if (it->ss == mb)b.pb(it->ff);
	y.clear();
	// sort(all(a), comp);
	// sort(all(b), comp);
	auto ia = a.begin();
	auto ib = b.begin();
	// cout << ma << ' ' << mb << ' ';
	int mx = ma + mb;
	// ia++;ib++;
	while (ia != a.end()) {
		ib = b.begin();
		while (ib != b.end()) {
			if (s.find(mp(*ia, *ib)) == s.end()) {cout << mx << endl; return;}
			ib++;
		}
		ia++;
	}

	cout << mx - 1 << endl;


}

int32_t main() {
	FIO
	sub();
	int t = 1;
	// cin >> t;
	while (t--)
		solve();
	return 0;
}




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

int main() {

    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> pairs(M);
    //vector<int> vec(N-1, 0);

    for(int i = 0; i < M; i++) {
        cin >> pairs.at(i).second >> pairs.at(i).first;
    }

    sort(pairs.begin(), pairs.end());
/*
    for(int i=0; i < M; i++) {
        cout << pairs.at(i).first << " : " << pairs.at(i).second << endl;
    }
*/

    int count = 0;
    int before_bridge = -1;

    for(int i = 0; i < M; i++) {
        if(before_bridge == -1) {
            //vec.at(pairs.at(i).second - 1) = 1;
            before_bridge = pairs.at(i).first - 1;
            count ++;    
        }
        else {
            if(pairs.at(i).second <= before_bridge) {
                continue;
            }
            else {
                //vec.at(pairs.at(i).second - 1) = 1;
                before_bridge = pairs.at(i).first - 1;
                count++;
            }
        } 
    }

    cout << count << endl;
}


Measured memory_bytes: 1024
#include <cstdio>

using namespace std;

int main()
{
    long long n, m, d;
    double ans;
    scanf("%lld%lld%lld", &n, &m, &d);
    if (d==0) ans=1.0/n*(m-1);
    else ans=2.0*(n-d)/(n*n)*(m-1);
    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
	double x0, y0, x1, y1, x, y, xt, yt;
	int i,q;

	cin >> x0 >> y0 >> x1 >> y1;

	for (cin >> q, i = 0; cin >> x >> y, i < q; ++i){
		double ang = atan2(y-y0,x-x0) - atan2(y1-y0,x1-x0);

		xt = (x-x0)*cos(ang * 2) + (y-y0)*sin(ang * 2) + x0;
		yt = -(x-x0)*sin(ang * 2) + (y-y0)*cos(ang * 2) + y0;

		cout << fixed << setprecision(10) << xt << " " << yt << endl;
	}
}

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

void solve() {
    int H, W, N;
    cin >> H >> W >> N;
    queue<int> que;
    rep(i, N) {
        int a; cin >> a;
        rep(j, a) que.push(i + 1);
    }
    vector<vector<int>> ans(H, vector<int>(W));
    auto paint = [&](int i, int j) -> void {
        int c = que.front(); que.pop();
        ans[i][j] = c;
    };
    rep(i, H) {
        if(i % 2 == 0) {
            rep(j, W) paint(i, j);
        } else {
            for(int j = W - 1; j >= 0; --j) paint(i, j);
        }
    }
    rep(i, H) {
        rep(j, W) cout << ans[i][j] << " ";
        cout << '\n';
    }
}

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


Measured memory_bytes: 3716
#include<iostream>
#include<set>
#include<vector>
using namespace std;
typedef long long li;
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n;li c; cin >>n >>c;
  vector<li> x(n),v(n);
  rep(i,n){
    cin >>x[i] >>v[i];
  }
  
  li ans=0,tmp=0;
  rep(i,n){
    tmp+=v[i];
    maximize(ans,tmp-x[i]);
  }
  if(df)print(ans);
  li s=tmp;
  tmp=0;
  rep(i,n){
    tmp+=v[n-1-i];
    maximize(ans,tmp-(c-x[n-1-i]));
  }
  if(df)print(ans);
  tmp=s;
  li tmp2=0;
  li rem=0;
  rep(i,n-1){
    tmp-=v[i];                     // 121
    tmp2+=v[i];                    // 80
    maximize(rem,tmp2-x[i]);              // 78
    maximize(ans,tmp+rem-2*(c-x[i+1]));     // 
    if(df)print(i,tmp+rem-2*(c-x[i+1]));
  }
  if(df)print(ans);
  tmp=s;
  tmp2=0;
  rem=0;
  rep(i,n-1){
    tmp-=v[n-1-i];                     // 200
    tmp2+=v[n-1-i];                    // 1
    maximize(rem,tmp2-(c-x[n-1-i]));       // 0
    maximize(ans,tmp+rem-2*x[n-1-i-1]);      // 
    if(df)print(n-1-i,tmp+rem-2*x[n-1-i-1]);
  }
  if(df)print(ans);
  print(ans);
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 105
#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll d[SIZE][SIZE];
int V;

void warshall_floyd_init(){
  fill(d[0],d[SIZE],INF);
  rep(i,0,SIZE) d[i][i] = 0;
}

//trueなら負の閉路が存在
bool warshall_floyd(){
  rep(k,0,V) rep(i,0,V){
    if(d[i][k]==INF)continue;
    rep(j,0,V){
      if(d[k][j]==INF)continue;
      d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
  }
  rep(i,0,V) if(d[i][i] < 0) return true;
  return false;
}

void add_edge(int a,int b,ll cost){
  d[a][b] = cost;
}

int E;

int main(){
  cin >> V >> E;
  warshall_floyd_init();
  rep(i,0,E){
    int s,t;
    ll D;
    cin >> s >> t >> D;
    add_edge(s,t,D);
  }
  if(warshall_floyd()){
      cout << "NEGATIVE CYCLE" << endl;
  }else{
    rep(k,0,V){
      rep(i,0,V){
        if(i!=0) cout << " ";
        if(d[k][i]==INF)cout << "INF";
        else cout << d[k][i];
      }
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3204
N = int(input())
lst = [0]
for i in range(N):
	lst += [int(input())]

lst.sort()

lst += [0]
ans = 0
count = 0
for i in range(1,N+2):
	if lst[i] != lst[i-1]:
		ans += count%2
		count = 1
	else:
		count += 1	
print (ans)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int a[100010];

void _main() {
    cin >> N;
    map<int, int> mp;
    REP(i, N) {
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for (auto p : mp) {
        if (p.second < p.first) ans += p.second;
        else ans += max(0LL, p.second - p.first);
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 7040
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string a, b;
    cin >> a >> b;
    int n = atoi((a + b).c_str());
    if (sqrt(n) - int(sqrt(n)) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256