akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)
#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)
#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

struct edge { ll x, y, h; };
bool comp(const edge& e1, const edge& e2){
    return e1.h > e2.h;
}

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

    vector<edge> nums;
    rep(i,N){
        ll a,b,c; cin>>a>>b>>c;
        nums.push_back({a,b,c});
    }
    
    sort(nums.begin(),nums.end(),comp);
    
    int len=nums.size();
    rep(i,101){
        rep(j,101){
            bool f=true;
            ll H = nums[0].h + abs(i-nums[0].x) + abs(j-nums[0].y);
            rep(k,len){
                ll hei = H - abs(i-nums[k].x) - abs(j-nums[k].y);
                if( (hei==nums[k].h) || (hei<=0 && nums[k].h==0)) continue;
                f=false;
                break;
            }
            if(f){
                cout3(i,j,H);
                return 0;
            }
        }
    }
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head, tail, n;
 
void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == LEN + 1)
   tail = 0;
  else 
   tail++;
}
 
P dequeue(){
  P a;
  a = Q[head];
  if(head + 1 == LEN + 1) 
   head = 0;
  else 
   head++;
  return a;
}
 
int isEmpty(){
  if(head == tail) 
     return 1;
  else 
     return 0;
}
 
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
 
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
 
  head = 1;
  tail = n + 1;
   
  for(;;){
    u = dequeue();
    c = u.t - q;
     
    if(c > 0){
      elaps += q;
      u.t = c;
      enqueue(u);
    }
     
    else if(c <= 0){
      elaps += u.t;
      printf("%s %d\n", u.name, elaps);
    }
 
    if(isEmpty() == 1)
      break;
    else 
      continue;
  }
  return 0;
}

Measured memory_bytes: 10756
S = input()[::-1]
L = len(S)
ans = 0
now = 0
A = [0] * 2019
A[0] = 1
d = 0
for i in range(L):
    now = now + int(S[i]) * pow(10, d, 2019)
    now %= 2019
    d += 1
    A[now] += 1

for i in A:
    ans += i * (i-1) // 2

print(ans)

Measured memory_bytes: 9280
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
typedef pair<long long int, int> P;
int main() {
    int n, m, b, k=0;
    vector<P> v;
    long long int a[100000], c, sum=0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b >> c;
        P p;
        p.first = c;
        p.second = b;
        v.push_back(p);
    }
    sort(a, a+n);
    sort(v.begin(), v.end(),[](const P& x, const P& y) { return x.first > y.first;});
    if(v.at(0).first>a[0]) {
        for (P p : v) {
            long long int s = p.second;
            for (int i = k; i < n; ++i) {
                if (a[i] < p.first) {
                    a[i] = p.first;
                    p.second--;
                    k=i;
                }
                if (p.second == 0) {
                    break;
                }
            }
            if (s == p.second) {
                break;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3188
N = int(input())
import heapq as h
A = list(map(int, input().split()))


# use 0 based index
sum_red, sum_blue = [], []

head = A[:N]
tail = [-x for x in A[-N:]]
h.heapify(head)
h.heapify(tail)
sum_red.append(sum(head))
sum_blue.append(-sum(tail))
# keypoint: いちいちsumすると線形時間かかるのでsum_hoge[-1]でアクセスする
for k in range(N, 2*N):
    num_sub = h.heappushpop(head, A[k])
    sum_red.append(sum_red[-1]-num_sub+A[k])
    num_sub = -h.heappushpop(tail, -A[-k-1])
    sum_blue.append(sum_blue[-1]-num_sub+A[-k-1])


print(max([r-b for r, b in zip(sum_red, sum_blue[::-1])]))


Measured memory_bytes: 37212
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    int b[SIZE];
    for( int i = 0; i < n - 1; ++i ) cin >> b[i];
    LL res = 0;
    for( int i = n - 1; i > 0; --i ) {
        if( i == n - 1 ) {
            res += b[i - 1];

        } else {
            if( b[i - 1] < b[i] ) {
                res += b[i - 1];

            } else {
                res += b[i];

            }
        }
    }

    cout << res + b[0] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
	int n,m;
	cin>>n>>m;
	vi x(m),y(m);
	REP(i,m){
		cin>>x[i]>>y[i];
	}
	vector<map<int,int>> ma(n+100);
	REP(i,m){
		ma[x[i]][y[i]]++;
	}
	REP(i,n+1){
		int cnt=1;
		for(auto itr:ma[i]){
			ma[i][itr.fi]=cnt;
			cnt++;
		}
	}
	REP(i,m){
		printf("%06d%06d\n",x[i],ma[x[i]][y[i]]);
	}
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep2(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i,0,n)
#define rep1(i, n) rep1(i,1,n+1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(long long N, long long A, long long B){
    ll a = A + B;
    cout << N / a * A + min(A, N % a) << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
 //   cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;
    long long A;
    std::cin >> A;
    long long B;
    std::cin >> B;
    func(N, A, B);
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

path = []
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            x = (i, j)
            path.append(x)
    else:
        for j in range(W - 1, -1, -1):
            x = (i, j)
            path.append(x)

ans = []
for i in range(len(path) - 1):
    p = path[i]
    p2 = path[i + 1]
    if A[p[0]][p[1]] % 2 != 0:
        A[p2[0]][p2[1]] += 1
        ans.append((p[0] + 1, p[1] + 1, p2[0] + 1, p2[1] + 1))
print(len(ans))
for a in ans:
    print(*a)



Measured memory_bytes: 109824
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		double sum=0;
		for(int i=0;i<N;i++) {
			double x=sc.nextDouble(); 
			String u=sc.next();
			if(u.equals("JPY")) {
				sum=sum+x;
			}
			else if(u.equals("BTC")) {
				sum=sum+x*380000;
			}

		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
int A[100000 + 100];
int N, M;
int main()
{
	scanf("%d%d", &N, &M);
	while (M --)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		A[x] ++, A[y] ++;
	}
	for (int i = 1; i <= N; ++i)
		if (A[i] & 1)
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	return 0;
}

Measured memory_bytes: 640
using System;

class Program{
    static void Main(){
        int a = 2;
        int r, x, temp;
        int N = int.Parse(Console.ReadLine());
    
        x = a * N;

        if(a < N){
            temp = a;
            a = N;
            N = temp;
        }

        r = a % N;
        while(r != 0){
            a = N;
            N = r;
            r = a % N;
        }

        Console.WriteLine("{0}", x/N);
    }
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int len(int n)
{
    int c = 0;
    for ( ; n > 0; n /= 10) {
        c++;
    }
    return c;
}

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

    int count = 0;
    for (int i = 1; i <= N; i++) {
        if ((len(i) & 1) == 1) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
 
int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> x;

    rep(i,m){
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    sort(x.begin(), x.end());
    vector<ll> d(m);

    rep(i,m-1) { 
        d[i] = x[i+1] - x[i];
    }

    ll ans = x.back() - x.front();
    sort(d.rbegin(), d.rend());

    if(n>=m) { 
        ans = 0;
    } else { 
        rep(i,n-1) {
            ans -= d[i];
        }
    }

    cout << ans << endl;
}



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

int main(){
	char a[4], b[4];
	while(cin >>a[0] >>a[1] >>a[2] >>a[3] >>b[0] >>b[1] >>b[2] >>b[3]){
		int hit = 0, blow = 0;
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				if(a[i] == b[j] && i == j) hit++;
				else if(a[i] == b[j]) blow++;
			}
		}
		cout <<hit <<" " <<blow <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(N),B(N);
  REP(i,N)cin>>A[i];
  REP(i,N)cin>>B[i];
  priority_queue<pair<ll,int>> q;
  REP(i,N){
    ll left,right,centor;
    centor=B[i];
    if(i==0)left=B[N-1];
    else left=B[i-1];
    if(i==N-1)right=B[0];
    else right=B[i+1];
    if(centor>right+left && centor>A[i])q.push(make_pair(centor,i));
  }
  ll ans=0;
  while(!q.empty()){
    auto tmp=q.top();q.pop();
    int i=tmp.second;
    ll left,right,centor;
    centor=B[i];
    if(i==0)left=B[N-1];
    else left=B[i-1];
    if(i==N-1)right=B[0];
    else right=B[i+1];
    ll cnt=(centor-A[i])/(right+left);
    ans+=cnt;
    B[i]-=(right+left)*cnt;

    i=(i+N-1)%N;
    centor=B[i];
    if(i==0)left=B[N-1];
    else left=B[i-1];
    if(i==N-1)right=B[0];
    else right=B[i+1];
    if(centor>right+left && centor>A[i])q.push(make_pair(centor,i));

    i=(i+2)%N;
    centor=B[i];
    if(i==0)left=B[N-1];
    else left=B[i-1];
    if(i==N-1)right=B[0];
    else right=B[i+1];
    if(centor>right+left && centor>A[i])q.push(make_pair(centor,i));
  }
  bool flag=true;
  REP(i,N)if(A[i]!=B[i])flag=false;
  if(flag)
    cout<<ans<<endl;
  else
    cout<<-1<<endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector< vector<int> > a;
  a.resize(n);
  for( int i=0; i<n; i++ ){
    a[i].resize(m);
  }
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++)
		cin>>a[i][j];
  }
  bool *flag = new bool[m];
  for(int i=0;i<m&&a[0][i]!=0;i++){
    flag[a[0][i]-1]=true;
  }
  for(int i=1;i<n;i++){
  	bool *temp = new bool[m];
    for(int j=0;j<m&&a[i][j]!=0;j++){
      temp[a[i][j]-1]=true;
    }
    for(int j=0;j<m;j++){
      flag[j]=flag[j]&&temp[j];
    }
  }
  
  int ans=0;
  for(int i=0;i<m;i++)
    if(flag[i])
      ans++;
  
  cout << ans<<"\n";
}

Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n;
	
	cin>>n;
	cout<<pow(n,2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 15
using namespace std;
int main() {
  string n;
  cin >> n;
  for(int i=0;i<n.size();i++) {
    if(n[i]=='1') n[i]='9';
    else n[i]='1';
  }
  cout << n << endl;

  return 0;
}

Measured memory_bytes: 256
n = list(input())
for i in range(len(n)):
        n[i] = int(n[i])
ans = n[0]
if n[0] < n[1] or (n[0] == n[1] and n[1]<n[2]):
        ans += 1
for i in range(3):
        print(ans,end="")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

struct UF {
    static const int N = 100100;//書き換え!
    int par[N];
    int rank[N];

    UF() {
        rep(i, N) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    void init() {
        rep(i, N) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x) {
        if (par[x] == x)return x;
        return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y])++rank[x];
        }
    }
};

int N, M;
vector<int> L[100100];
bool exist[100100];
UF uf;

signed main() {
    cin >> N >> M;
    rep(i, N) {
        int k;
        cin >> k;
        rep(j, k) {
            int l;
            cin >> l;
            L[i].push_back(l);
            exist[l] = true;
        }
        rep(j, k - 1) {
            uf.unite(L[i][j], L[i][j + 1]);
        }
    }
    vector<int> e;
    rep(i, M) {
        if (exist[i + 1])e.push_back(i + 1);
    }
    rep(i, e.size() - 1) {
        if (!uf.same(e[i], e[i + 1])) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> p;
int main() {
  cin >> n;
  read_n(p, n, 1);
  i64 ans = 0;
  for (i64 i = 1; i <= n; ++i) {
    if (p[i] == i) {
      ++ans;
      ++i;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int x,y,z,room=0,mod=0;
	while(scanf("%d%d%d",&x,&y,&z)!=EOF)
	{
		room=(x-z)/(y+z);
		mod=x%(y+z);
		if(z<mod&&mod<(y+z))
		{
			room--;
		}
		printf("%d",room);
	}
	return 0;
}

Measured memory_bytes: 128
while True:
    items = input().split()
    if items[1] == '?':
        break
    if items[1] == '+':
        sum = int(items[0]) + int(items[2])
        print(sum)
    elif items[1] == '-':
        dif = int(items[0]) - int(items[2])
        print(dif)
    elif items[1] == '*':
        prod = int(items[0]) * int(items[2])
        print(prod)
    elif items[1] == '/':
        quot = int(items[0]) // int(items[2])
        print(quot)



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

typedef long long ll;

int main()
{

	int n;cin >> n;
	string s; cin >> s;

	int x=0,ans=0;
	for (int i = 0; i < s.length(); ++i)
	{
		x = s[i] == 'I' ? x+1:x-1;
		ans=max(x,ans);
	}
	cout<<ans<<endl;


	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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


	int k,x;cin>>k>>x;

	k--;

	for(int i=x-k; i<=x+k; i++){
		cout<<i<<" ";
	}
	cout<<endl;

}




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

int main(){
  long long N;
  cin >> N;
  long long c;
  long long f=4;
  for (long long i=1;i<=3500;i++){
    for (long long j=1;j<=3500;j++){
      if ((f*i*j-N*i-N*j)>0){
        if( (N*i*j) % (f*i*j-N*i-N*j)==0 ){
          c =(N*i*j) / (i*j*f-N*i-N*j);
          cout << i << " " << j << " " << c << endl;
          return 0;
        }
      }
    }
  }
}


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

int main() {
	char c;
	int ans;
	while (cin >> c) {
		if (c >= '0' && c <= '9') {
			ans += c - '0';
		}
	}
	if (ans % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

#define SIZE_OF_ARRAY(p) (sizeof(p)/sizeof(p[0]))

int main()
{
    // input
    int N, K;
    cin >> N >> K;
    int p[N];
    int result = 0;

    for(int i = 0; i < N; i++){
        cin >> p[i];
    }

    sort(p, p + SIZE_OF_ARRAY(p));

    // output
    for(int i = 0; i < K; i++) {
        result += p[i];
    }
    cout << result << endl;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int a[3];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    qsort(a,3,sizeof(int),cmp);
    printf("%d\n",abs(a[0]-a[1])+abs(a[1]-a[2]));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  multiset<int> colors;
  drep(i,N){
    int x = A[i];
    auto itr = colors.upper_bound(x);
    if(itr == colors.end()) {
      colors.insert(x);
    } else {
      colors.erase(itr);
      colors.insert(x);
    }
  }
  int ans = 0;
  for(auto x: colors) {
    ans++;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<cstring>
bool da[110][12];
int n,p[110][11],tin,ans=0;
int main()
{
    long long ans=0;
    memset(p,0,sizeof p);
    std::cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            std::cin>>da[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=10;j++){
            std::cin>>p[i][j];
        }
    }
    ans=-(1<<31);
    for(int i=1;i<(1<<10);i++){
        int curr=0,tc;
        for(int j=0;j<n;j++){
            int c=0;
            for(int k=0;k<10;k++){
                if((i>>k&1)&&da[j][k]) c++;
            }
            curr+=p[j][c];
            tc=c;
        }
        if(curr>ans) {ans=curr;}
    }
    std::cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

struct list{
	char name[15];
	int time;
};
struct list node[100005];

int main()
{
	int n,q,T=0;
	int i=0;
	scanf("%d%d",&n,&q);
	int count=n;
	while(count--)
	{
		scanf("%s %d",&node[i].name,&node[i].time);
		i++;
	}
	for(int head=0,tail=n;head!=tail;head=(head+1)%(n+1))
	{
		i=head;
		if(node[i].time<=q)
		{
			T+=node[i].time;
			printf("%s %d\n",node[i].name,T);
			node[i].time=0;
		}
		else
		{
			T+=q;
			node[tail].time=node[i].time-q;
			strcpy(node[tail].name,node[i].name);
			tail=(tail+1)%(n+1);
		}
	}
	return 0;
}



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

int main() {
  string a[3]; rep(i,0,3) cin >> a[i];
  char A[3]; rep(i,0,3) A[i] = a[i][0] + 'A' - 'a';
  rep(i,0,3) cout << A[i];
  cout << endl;
}

Measured memory_bytes: 3628
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int D; cin >> D;
	vector<int> c(26, 0);
	rep(i, 26)cin >> c[i];
	vector<vector<int>> s(D, vector<int>(26, 0));
	rep(i, D)rep(j, 26)cin >> s[i][j];
	
	rep(i, D) {
		int t = 0;
		rep(j, 26) {
			if (s[i][t] <= s[i][j])t = j;
		}
		cout << t+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;
  return 0;
}

Measured memory_bytes: 3600
from collections import deque
N = int(input())
taka = []
ao = []
A = []
B = []
for i in range(N):
    Ain,Bin = map(int,input().split())
    A.append(Ain)
    B.append(Bin)
    taka.append((Bin+Ain,i))
    ao.append((Ain+Bin,i))
taka.sort()
taka.reverse()
ao.sort()
ao.reverse()
taka = deque(taka)
ao = deque(ao)
takacnt = 0
aocnt = 0
st = set()

# print(taka)
# print(ao)

for i in range(N):
    if i % 2 == 0:
        while True:
            val = taka.popleft()
            if not val[1] in st:
                break
        st.add(val[1])
        takacnt += A[val[1]]
    else:
        while True:
            val = ao.popleft()
            if not val[1] in st:
                break
        st.add(val[1])
        aocnt += B[val[1]]
print(takacnt-aocnt)


Measured memory_bytes: 113360
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n,m;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    if (n==m) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 764
import java.util.*;
class Main{
    public static void main(String[] args){
    	//final int MAX =200000;
    	
    
    	Scanner sc = new Scanner(System.in);
    	int n = Integer.parseInt(sc.next());
    	int[] R=new int[n];
    	
    	for(int i=0;i<n;i++){
    		 R[i]=Integer.parseInt(sc.next());
    	}
    	long maxv=-2000000000;
    			 
    	long minv=R[0];
    	for(int i=1;i<n;i++){
    		maxv=Math.max(maxv,R[i]-minv);
    		minv=Math.min(minv,R[i]);
    	}
    	System.out.println(maxv);
    	
    }
}

Measured memory_bytes: 70852
//BISMILLAHIR RAHMANIR RAHIM
                                               //BY THE NAME OF ALLAH
                                               //FAISAL AHAMMED SHAWON
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<set>
#include<map>
#include<iterator>
#include<numeric>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define SQ(a) (a)*(a)
#define pi acos(-1.0)
const int MAX=100001;
const int MOD=1e9+7;
int ara[MAX];
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

bool f(ll a,ll b)
{
    return a>b;
}
ll max_sum_subarrays(ll ara[],ll n)
{
    ll ans=0,sum=0;
    for(ll k=0;k<n;k++){
        sum=max(ara[k],sum+ara[k]);
        ans=max(ans,sum);
    }
    return ans;
}
ll num_divisors(ll n)
{
    long long cnt=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0 && i*i==n)
            cnt+=1;
        if(n%i==0 && i*i!=n)
                cnt+=2;
    }
    return cnt;
}
ll comb(ll m, ll n)
{
    ll x = max(m-n,n),ans = 1,i=1;
    for(ll k=m;k>=x+1;k--){
        ans*=k;
        ans/=i;
        i++;
    }
    return ans;
}
ll binsearch(ll low,ll high,ll target)
{
    while(low<=high)
    {
        ll mid=(low+high)/2;
        if(ara[mid]>target)
            high=mid-1;
        else if(ara[mid]<target)
            low=mid+1;
        else return mid;
    }
    return -1;
}
void solve()
{
    int a,b;
    cin>>a>>b;
    vector<string>v(a);
    string ans="";
    for(int i=0;i<a;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<a;i++)
    {
        ans+=v[i];
    }
    cout<<ans<<endl;
}
int main()
{
    fast();
    solve();
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 55
using namespace std;

typedef long long ll;
ll n, mx, ans, a[N], b[N];
bool c[N], v[N];

bool f() {
	ll i, j, k;
	for (i = 0; i < n; i++) {
		memset(v, 0, sizeof(v));
		v[a[i]] = 1;
		for (j = a[i]; j > 0; j--) {
			if (!v[j]) continue;
			for (k = 1; k <= j; k++) if (c[k]) v[j % k] = 1;
		}
		if (!v[b[i]]) return 0;
	}
	return 1;
}

int main()
{
	ll i;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]), mx = max(mx, a[i]);
	for (i = 0; i < n; i++) scanf("%lld", &b[i]);
	for (i = 1; i <= mx; i++) c[i] = 1;
	for (i = mx; i > 0; i--) {
		c[i] = 0;
		if (!f()) c[i] = 1, ans |= 1LL << i;
	}
	if (c[mx]) {cout << "-1"; return 0;}
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N, A[200010];
    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int B[200010];
    for(int i = 0; i < N; i++){
        B[i] = A[i];
    }
    sort(B, B+N, greater<int>());
    int k = 0;

    for(int i = 0; i < N; i++){
        if(A[i] == B[0]){
            k = i;
        }
    }

    for(int i = 0; i < N; i++){
        if(i == k){
            cout << B[1] << endl;
        }
        else{
            cout << B[0] << endl;
        }
    }
    
}

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

int main(void) {
	int X;
	cin >> X;

	int ans = 0;
	if (X >= 100) {
		int maxcnt = X / 100;
		int cnt = X % 100;
		while (cnt > 0) {
			if (cnt >= 5) {cnt -= 5; maxcnt--;}
			else if (cnt >= 4) {cnt -= 4; maxcnt--;}
			else if (cnt >= 3) {cnt -= 3; maxcnt--;}
			else if (cnt >= 2) {cnt -= 2; maxcnt--;}
			else if (cnt >= 1) {cnt -= 1; maxcnt--;}
		}
		if (maxcnt >= 0) ans = 1;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
D = list(map(int, input().split()))
Dam = [0]*n
t = D[0]
for i in range(n-1):
    if i%2 == 0:
        t-=D[i+1]
    else:
        t+=D[i+1]
Dam[0] = t
#print(t)

for i in range(n-1):
    Dam[i+1] = (D[i] - Dam[i]//2)*2
for i in Dam:
    print(i, end=' ')

Measured memory_bytes: 14032
# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
import sys
input = sys.stdin.readline
OFS = ord('a')
_ = input()
S = list(input()[:-1])

D = [[] for _ in [0]*26]
for i, s in enumerate(S):
    D[ord(s)-OFS].append(i)

for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt)


Measured memory_bytes: 30856
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n);
  for (auto &v : a) cin >> v;
  int cnt = 0;
  if (n == 1) cnt++;
  for (int i = 0; i < n-1; i++) {
    if (a[i] == a[i+1]) continue;
    else if (a[i] < a[i+1]) {
      cnt++;
      while (i < n-1 && a[i] <= a[i+1]) i++;
      if (i == n-2 && a[i] > a[i+1]) cnt++; 
    }
    else if (a[i] > a[i+1]) {
      cnt++;
      while (i < n-1 && a[i] >= a[i+1]) i++;
      if (i == n-2 && a[i] < a[i+1]) cnt++; 
    }
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if (
        b - a <= k and
        c - a <= k and
        d - a <= k and
        e - a <= k and
        c - b <= k and
        d - b <= k and
        e - b <= k and
        d - c <= k and
        e - c <= k and
        d - e <= k
):
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,x,a[100],i,j,ans = 0;
    scanf("%d %d",&n,&x);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),asc);
    for (i = 0; i < n; i++)
    {
        if(x >= a[i])
        {
            x -= a[i];
        }
        else
        {
            break;
        }
    }
    if(i == n && x > 0)i--;
    printf("%d",i);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AInfiniteCoins {
public:
	void solve(istream& in, ostream& out) {
        int n, a; in >> n >> a;
        n %= 500;
        if(n <= a) out << "Yes" << endl;
        else out << "No" << endl;
	}
};

int main() {
	AInfiniteCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

type Array with
    static member private _BinarySearch<'T when 'T: comparison>
        (comp, array: 'T [], first: Int32, last: Int32, value: 'T) =
        let rec loop left right =
            if left > right then
                left
            else
                let mid = left + ((right - left) >>> 1)
                if comp array.[mid] value then
                    loop (mid + 1) right
                else
                    loop left (mid - 1)
        loop first (last - 1)

    static member LowerBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<), array, first, last, value)

    static member UpperBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<=), array, first, last, value)

let toInt32 (s: string) = Convert.ToInt32(s)

[<EntryPoint>]
let main _ =
    let N = read int
    let LS = reada toInt32 |> Array.sort

    let mutable ans = 0
    for i in [N-1 .. -1 .. 2] do
        for j in [i-1 .. -1 .. 1] do
            let high = LS.[i]
            let mid = LS.[j]
            let bound = Array.UpperBound(LS, 0, LS.Length, (high - mid))
            let lows = max 0 (j - bound)
            ans <- ans + lows

    printfn "%i" ans
    0

Measured memory_bytes: 37048
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        A[i] = A[i][:j] + '.' + A[i][j + 1:]
        break
visited = [[False] * W for _ in range(H)]
ans = min([i, H - 1 - i, j, W - 1 - j])
Q = collections.deque([[i, j, K]])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and not visited[h][w] and A[h][w] == '.':
        visited[h][w] = True
        ans = min([ans, h, H - 1 - h, w, W - 1 - w])
        if res:
            res -= 1
            Q += [[h - 1, w, res]]
            Q += [[h + 1, w, res]]
            Q += [[h, w - 1, res]]
            Q += [[h, w + 1, res]]
print(1 + math.ceil(ans / K))


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

int main()
{
    int N, answer = 1;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    
    sort(S.begin(), S.end());
    string hikaku = S.at(0);

    for (int i = 0; i < N; i++)
    {
        if (hikaku != S.at(i))
        {
            answer ++;
            hikaku = S.at(i);
        }
        
    }

    cout << answer;
    
}

Measured memory_bytes: 9600
from collections import deque
import math

N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort(key=lambda x: x[0])

# 爆発範囲がとても広く、全ての爆発が右端まで及ぶとひとまず考える
# 各xを見る際に、影響の及ばない爆発分のダメージは引く

# 合計の爆発回数
ans = 0
# 爆発ダメージの合計
total_damage = 0
# 各爆発の情報
dq = deque()

# 左端から順にモンスターを見る
for x, h in XH:
    # 爆発が及ばない場合
    while dq and dq[0][1] < x:
        dmg, rng = dq.popleft()
        total_damage -= dmg

    # 爆発させる必要がある場合
    if total_damage < h:
        # 残っているHPに更新
        h -= total_damage
        # 必要な爆発回数
        cnt = math.ceil(h / A)
        ans += cnt
        # 爆発回数 * 単発のダメージ
        dmg = cnt * A
        total_damage += dmg
        # [爆発で与えるダメージ、及ぶ範囲の右端]
        dq.append((dmg, x + D * 2))

print(ans)


Measured memory_bytes: 118252
object Main extends App {

  def safeDivide(l: Double, r: Double) = if (l == 0.0) 0.0 else l / r
  def format(x: Double) = {
    val s = (x * 1000).round formatted "%04d"
    s.dropRight(3) + "." + s.takeRight(3)
  }

  val sc = new java.util.Scanner(Console.in)

  while (sc.hasNextLine()) {
    val line = sc.nextLine()
    val Array(a, b, c, d, e, f) = line.split(' ').map(_.toDouble)
    val x = safeDivide(c*e - b*f, a*e - b*d)
    val y = safeDivide(c - a*x, b)

    println(format(x) + " " + format(y))
  }
}



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

int main()
{
	int n;
	cin >> n;
	auto ans = set<string>();
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		ans.insert(s);
	}
	cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 19200
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string s, t;
  std::cin >> s >> t;
  std::sort(s.begin(), s.end());
  std::sort(t.begin(), t.end(), std::greater<char>());
  std::cout << (s < t ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))


int sumofdigit(int n){
    int ans = 0,a;
    while(n!=0){
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    string res;
    if(a+b >= c) res = "Yes";
    else res = "No";
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int H = Integer.parseInt(sl[0]);
            int W = Integer.parseInt(sl[1]);

            String[] ar = new String[H];

            for (int i = 0; i < H; i++) {
                ar[i] = reader.readLine();
            }

            ArrayList<Integer> wa = new ArrayList<Integer>();

            // 縦すべてが空白
            for (int i = 0; i < W; i++) {
                boolean flg = true;
                for (int j = 0; j < H; j++) {
                    if (ar[j].charAt(i) != '.') {
                        flg = false;
                        break;
                    }
                }
                if (flg) wa.add(i);
            }

            ArrayList<Integer> ha = new ArrayList<Integer>();

            // 横すべてが空白
            for (int i = 0; i < H; i++) {
                boolean flg = true;
                for (int j = 0; j < W; j++) {
                    if (ar[i].charAt(j) != '.') {
                        flg = false;
                        break;
                    }
                }
                if (flg) ha.add(i);
            }

            for (int i = 0; i < H; i++) {
                if (ha.contains(i)) continue;
                for (int j = 0; j < W; j++) {
                    if (wa.contains(j)) continue;
                    System.out.print(ar[i].charAt(j));
                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 22564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 100002;
ll n,m,ans=0;
vector<ll> p;
vector<pair<ll,ll> > xy;
ll par[N];
void init(ll n){
	FOR(i,1,n+1)par[i]=i;
}

ll root(ll x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=root(par[x]);
	}
}

void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	init(n);
	FOR(i,0,n){
		ll k;cin>>k;
		p.pb(k);
	}
	FOR(i,0,m){
		ll x,y;
		cin>>x>>y;
		xy.pb(make_pair(x,y));
		unite(x,y);
	}
	FOR(i,1,n+1){
		if(root(i)==root(p[i-1]))ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3956
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int A = reader.nextInt();
        int B = reader.nextInt();
        if (A*B==2) System.out.println(3);
        else if (A*B==3) System.out.println(2);
        else System.out.println(1);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21076
package main

import "fmt"

func main() {
    var a, b int

    fmt.Scanf("%d %d", &a, &b)

    if a < b {
        fmt.Println("a < b")
    } else if a > b {
        fmt.Println("a > b")
    } else {
        fmt.Println("a == b")
    }
}


Measured memory_bytes: 1116