akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    
    // どれかが残りの二つの合計になっていたらYes
    if(a == b + c || b == a + c || c == a + b) {
      System.out.println("Yes");
    // さもなくば、No
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=100000000000;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    multimap<int,int> mp;
    int N;
    LL K;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        mp.emplace(a,b);
    }
    LL count=0;
    for(auto p:mp){
        count+=p.second;
        if(K<=count){
            cout << p.first << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>

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

using namespace std;
int mod = 1000000007;

int N, K;


int main() {
  cin >> N >> K;
  vector<int> vec(N+1);
  rep(i, N) {
    int s; cin >> s;
    vec.at(s)++;
  }

  priority_queue<int, vector<int>, greater<>> que;
  for(int i=1; i<=N; i++) {
    if(vec.at(i) > 0) {
      que.push(vec.at(i));
    }
  }

  int ans = 0;
  while(que.size() > K) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}


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

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 vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#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; }

int main(){
    int n;
    ll d;
    cin >> n >> d;
    vll x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    int ans = 0;
    rep(i, n) if (x[i]*x[i]+y[i]*y[i]<=d*d) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6424
#include <iostream>

using namespace std;
typedef long long ll;
int main() {
    int n;
    ll a, cnt = 0;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a;
        while (!(a & 1)) {
            a >>= 1;
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


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

int a,b,c;
ll t;

void calc(int n, int m, ll st_time, int *v){
  ll cc = 0;
  
  int l = 0;
  
  for(int i=0;i<=m && i<=n-1;i++){
    ll sum = st_time + (ll)c*l;

    if(sum <= t){
      cc++;
    }else{
      break;
    }
    
    ll cc2 = (t - sum)/a;

    cc = min(cc + cc2, (ll)n);

    l = cc;
    
    v[i] = cc;
  }
  
}

int dp[SIZE];
int v[SIZE][SIZE] = {};

int main(){
  int n,m,k;
  int s[SIZE];
  
  scanf("%d%d%d",&n,&m,&k);
  
  scanf("%d%d%d%lld",&a,&b,&c,&t);

  for(int i=0;i<m;i++){
    scanf("%d",s+i);
    s[i]--;
  }

  for(int i=0;i<=k;i++){
    dp[i] = -INF-10;
  }
  
  dp[m] = 0;
  
  int ans = 0;

  priority_queue<pair<int,pair<int,int> > > pq;
  
  for(int i=0;i<m-1;i++){

    calc(s[i+1]-s[i], k-m, (ll)b*s[i], v[i]);
    
    pq.push({v[i][1]-v[i][0],{i,1}});
    ans += v[i][0];
  }
  
  for(int i=m;i<k;i++){
    if(pq.top().first < 0) break;
    
    ans += pq.top().first;

    int p = pq.top().second.first;
    int q = pq.top().second.second;

    pq.pop();
    
    pq.push({v[p][q+1]-v[p][q],{p,q+1}});
  }

  if((ll)(n-1)*b <= t) ans++;

  printf("%d\n",ans-1);
  
  return 0;
}

Measured memory_bytes: 14100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, int>;
using piii = pair<ll, pair<ll, int>>;

ll solve() {
    ll N, x, y;
    cin >> N;
    vector<ll> X(N), Y(N);
    set<piii> sx, sy;
    for ( int i = 0; i < N; i++ ) {
        cin >> x >> y;
        if ( x > y ) swap(x,y);
        X[i] = x;
        Y[i] = y;
        sx.insert(piii(x,pii(y,i)));
        sy.insert(piii(y,pii(x,i)));
    }
    ll m = 1e18;
    for(;;) {
        ll xmin = sx.begin()->first;
        ll xmax = sx.rbegin()->first;
        ll ymin = sy.begin()->first;
        ll ymax = sy.rbegin()->first;
        m = min(m, (ymax - ymin) * (xmax - xmin));
        piii v = *sx.begin();
        int i = v.second.second;
        if ( Y[i] == v.first ) break;
        piii u = piii(Y[i], pii(X[i], i));
        sx.erase(v);
        sx.insert(u);
        sy.erase(u);
        sy.insert(v);
    }
    return m;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 28416
// E - Picking Goods
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define chmax(x,y) x=max(x,(y))

int V[3000+1][3000+1];
ll dp[3000+1][3000+1][3+1];

int main(){
	int R, C, K; cin>>R>>C>>K;

	rep(i, K){
		int r, c, v; cin>>r>>c>>v;
		V[r][c] = v;
	}

	rep(i, R+1) rep(j, C+1) rep(k, 3+1){
		if(i-1 >= 0){
			chmax(dp[i][j][0], dp[i-1][j][k]);
			chmax(dp[i][j][1], dp[i-1][j][k] + V[i][j]);
		}
		if(j-1 >= 0){
			chmax(dp[i][j][k], dp[i][j-1][k]);
			if(k-1 >= 0) chmax(dp[i][j][k], dp[i][j-1][k-1] + V[i][j]);
		}
	}

	ll ans = 0;
	rep(k, 3+1) chmax(ans, dp[R][C][k]);
	cout<< ans <<endl;
}


Measured memory_bytes: 320132
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
double T,X;

int main()
{
    cin>>T>>X;
    if (X==0) cout<<0<<endl;else
    cout<<T/X<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
const int N=2e5+10;
const ll mod=1e9+7;
int n,m,a,b,maxx;
ll fac1[N]={1},inv[N]={0,1},fac2[N]={1},ans,x,y;
inline ll C(int nn,int mm){return fac1[nn]*fac2[mm]%mod*fac2[nn-mm]%mod;}
int main()
{
//	freopen("Iroha and a Grid .in","r",stdin);
	scanf("%d%d%d%d",&n,&m,&a,&b); maxx=n+m;
	for(RG int i=1;i<=maxx;i++) fac1[i]=fac1[i-1]*i%mod;
	for(RG int i=2;i<=maxx;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(RG int i=1;i<=maxx;i++) fac2[i]=fac2[i-1]*inv[i]%mod;
	for(RG int i=1;i<=n-a;i++)
	{
		x=C(b+i-2,b-1), y=C(n+m-i-b-1,m-b-1);
		(ans+=(x*y%mod))%=mod;
	}
	printf("%lld",ans);
	return 0;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}

int b[200];
int a[200];
int main(){
	int n, m, c; cin>> n >> m >> c;
	rep(i,1,m)
		cin>> b[i];
	int ans = 0;
	rep(i,1,n){
		rep(j,1,m)
			cin>> a[j];
		int sol = c;
		rep(j,1,m)
			sol += b[j]*a[j];
		if(sol > 0){
			ans += 1;
		}
	}
	cout<<ans;
	return 0;
}


//Problem A
/*
 int v[100010];
int x1[100010];
int x2[100010];

int main(){
	clr(x1,0);
	clr(x2,0);
	int n; cin>> n;
	rep(i,1,n)
		cin>> v[i];
	rep(i,1,n){
		if(v[i] == 2)
			x2[i] = x2[i-1] + 1;
	}
	per(i,n,1){
		if(v[i] == 1)
			x1[i] = x1[i+1] + 1;
	}
	int maxi = 0;
	rep(i,1,n-1){
		if(v[i] != v[i+1]){
			//~ cout<<i<<":"<<x2[i]<<" "<<i+1<<":"<<x1[i+1]<<endl;
			maxi = max(maxi, min(x2[i],x1[i+1]));
		}
	}
	//~ rep(i,1,n)
		//~ cout<<x2[i]<<" "; 
	//~ cout<< endl;
	//~ rep(i,1, n)
		//~ cout<<x1[i]<<" ";
	//~ cout<<endl;
	//~ cout<<endl;
	clr(x1,0);
	clr(x2,0);
	rep(i,1,n){
		if(v[i] == 1)
			x1[i] = x1[i-1] + 1;
	}
	per(i,n,1){
		if(v[i] == 2)
			x2[i] = x2[i+1] + 1;
	}
	
	rep(i,1,n-1){
		if(v[i] != v[i+1]){
			//~ cout<<i<<":"<<x2[i]<<" "<<i+1<<":"<<x1[i+1]<<endl;
			maxi = max(maxi, min(x1[i],x2[i+1]));
		}
	}
	
	//~ cout<< maxi<<endl;
	cout<<2*maxi<<endl;
	//~ rep(i,1,n)
		//~ cout<<x2[i]<<" "; 
	//~ cout<< endl;
	//~ rep(i,1, n)
		//~ cout<<x1[i]<<" ";
	//~ cout<<endl;
	return 0;
}

 */


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    
    if (abs(n - m) > 1) {
        cout << 0;
    } else {
        ll ans = 1 + (n == m);
        FOR(i,2,n) ans = (ans * i) % MOD;
        FOR(i,2,m) ans = (ans * i) % MOD;
        
        cout << ans;
    }

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005],a[100005];
int main()
{
    int i,n,m,x,y;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        x=abs(a[i]-a[i-2]);
        y=abs(a[i]-a[i-1]);
        dp[i]=min(x+dp[i-2],y+dp[i-1]);
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
#define ll long long
#define tt ll t;cin>>t;while(t--)
#define nl endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define so ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define a_size 100
int i,j,sum=0;

int main()
{
        so;

        int d,t,s;
        cin>>d>>t>>s;
        int x;
        x=(d+s-1)/s;
        if(x<=t)cout<<"Yes";
        else cout<<"No";





        return 0;
}



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

int main() 
{
    int A,B,C;
    cin >>A>>B>>C;
    if(A+B+C>21)
    {
        cout<< "bust" <<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }
    
}


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

int main()
{
    int n, cou = 0;

    cin >> n;

    for(int i = 1; i <= n; i++) {
        if(i % 2 != 0) {
            cou++;
        }
    }

    double r = ((double)cou) / n;

    cout << fixed << setprecision(10) << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long  dp[100004];
int main(){
	int n, K;
	cin >> n >> K;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
  	long long tmp;
  	dp[0] = 0;
  	dp[1] = abs(h[1] - h[0]);
  	for(int i = 1; i < n; i++) {
      tmp = 10000000000;
      for(int j = 1; j <= min(K, i); j++) {
        tmp = min(dp[i-j] + abs(h[i] - h[i-j]) , tmp);
      }
      dp[i] = tmp;
    }
	cout << dp[n-1] << endl;
	
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    intmax_t N;
    cin >> N;

    intmax_t res = 0;
    for (intmax_t i = 1; i * i <= N; ++i) {
        if (N / i - 1 != 0 && N / (N / i - 1) == N % (N / i - 1)) {
            res += (N / i - 1);
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
using System;

namespace Duplex_Printing
{
    class Program
    {
        static void Main(string[] args)
        {
            var numberPages = int.Parse(Console.ReadLine());

            double temp = (numberPages / 2);

            if(numberPages % 2 != 0)
            {
                temp = temp + 1;
            }

            int numberSheets = int.Parse(temp.ToString());

            
            Console.WriteLine(numberSheets);
        }
    }
}


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

int main(void){
	int n;
	cin >> n;
	int* a;
	a = new int[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = n-1;i >= 0;i--){
		cout << a[i];
		if(i != 0){
			cout << " ";
		}
	}
	cout << endl;
	delete [] a;
	return 0;
}

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

int main(){
	int n, max1, max2, a[5001];

	while( cin >> n , n ){
		for(int i=0 ; i<n ; i++){
			cin >> a[i] ;
		}
		max1 = a[0];

		for(int i=0 ; i<n ; i++){
			int sum = 0;
			for(int j=i ; j<n ; j++){
				sum += a[j];
				max1 = max( max1 , sum );
			}
		}
		cout << max1 << endl;
	}
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

LL mod = 1e9 + 7;

LL pow2(LL a, LL b) {
    LL ans = 1;
    while(b > 0) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

class Inverse{
    public:
        vector<LL> inv;
        int sz;
    Inverse(int _sz = 0){
        sz = max(1, _sz);
        inv = vector<LL>(sz + 1);
        inv[1] = 1;
        for(int i = 2; i <= sz; i++) {
            inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        }
    }
    LL get(LL x) {
        if(x <= sz) return inv[x];
        else return pow2(x, mod - 2);
    }
};


int n, k; 
vector<pair<LL, int>> a;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  Inverse inv;
  while (scanf("%d%d", &n, &k) != EOF) {
    a.clear();

    for (int i = 0; i < n; i++) {
      int w;
      scanf("%d", &w);
      if (w < 0) a.push_back({-w, 1});
      else a.push_back({w, 0});
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int t = 0;
    LL ans = 1;
    for (int i = 0; i < k; i++) {
      ans = (ans * a[i].first) % mod;
      t += a[i].second;
    }
    if (t % 2 == 0 || a[k - 1].first == 0) {
      cout << ans << endl;
    } else {
      LL pos = 0, neg = 0;
      for (int i = k - 1; i >= 0; i--) {
        if (a[i].second == 0 && pos == 0) {
          pos = a[i].first;
        }
        if (a[i].second == 1 && neg == 0) {
          neg = a[i].first;
        }
      }
      LL npos = 0, nneg = 0;
      for (int i = k; i < n; i++) {
        if (a[i].second == 0 && npos == 0) {
          npos = a[i].first;
        }
        if (a[i].second == 1 && nneg == 0) {
          nneg = a[i].first;
        }
      }

      if (pos > 0 && nneg > 0 && (nneg * neg >= npos * pos || npos == 0 || neg == 0)) {
        ans = ans * nneg % mod * inv.get(pos) % mod;
        t = 0;
      }
      if (neg > 0 && npos > 0 && (nneg * neg < npos * pos || nneg == 0 || pos == 0)) {
        ans = ans * npos % mod * inv.get(neg) % mod;
        t = 0;
      }

      if (t % 2 == 1) {
        ans = 1;
        for (int i = n - 1; i >= n - k; i--) {
          ans = (ans * a[i].first) % mod;
        }
        ans = (-ans + mod) % mod;
      } 
      cout << ans << endl;
    }
  }
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

int main()
{
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	for (int i = 0; i < A+B+1; i++)
	{
		if (i!=A)
		{
			if (S[i] == '-')
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			if (S[i] != '-')
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program{
    static int[] A;
    static List<int> G=new List<int>();
    static int InsertionSort(int g){
        var cnt=0;
        for(var i=g; i<A.Length; i++){
            var v=A[i];
            var j=i-g;
            while(j>=0 && A[j]>v){
                A[j+g]=A[j];
                j=j-g;
                cnt++;
            }
            A[j+g]=v;
        }
        return cnt;
    }

    static int ShellSort(){
        var cnt=0;
        for(var g=1; g<=A.Length;){
            G.Add(g);
            g=3*g+1;
        }
        G.Reverse();
        foreach(var g in G){
            cnt+=InsertionSort(g);
        }
        return cnt;
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        A=new int[n];
        for(var i=0; i<n; i++){
            A[i]=int.Parse(Console.ReadLine());
        }

        var cnt=ShellSort();
        var m=G.Count;

        Console.WriteLine(m);
        for(var i=0; i<m; i++){
            Console.Write(G[i]);
            if(i>=m-1){
                Console.WriteLine();
            } else{
                Console.Write(" ");
            }
        }
        Console.WriteLine(cnt);
        foreach(var a in A){
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 16616
KN=list(map(int,input().split()))
L=list(map(int,input().split()))
K=KN[0]
N=KN[1]
M=0
for i in range(N-1):
  if (L[i+1]-L[i])>M:
    M=L[i+1]-L[i]
if (K-L[N-1]+L[0])>M:
  M=K-L[N-1]+L[0]
print(K-M)

Measured memory_bytes: 26444
using System;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

		MInt f = MInt.MFactorial(n - 1);
		var dp = new MInt[n];
		for (int i = 1; i < n; i++)
			dp[i] = dp[i - 1] + f / i;

		MInt r = 0;
		for (int i = 1; i < n; i++)
			r += dp[i] * (x[i] - x[i - 1]);
		Console.WriteLine(r.V);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}

	public static long MFactorial(int n) { for (long x = 1, i = 1; ; x = x * ++i % M) if (i >= n) return x; }
}


Measured memory_bytes: 21344
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
int n,A,B,C;
int l[111111]={0};

int dfs(int i,int a,int b,int c){
    if(i==n){
        if(a==0||b==0||c==0)return INF;
        else return abs(A-a)+abs(B-b)+abs(C-c);
    }
    int d1,d2,d3,d4;
    d1=dfs(i+1,a,b,c);
    d2=dfs(i+1,a+l[i],b,c)+10;
    if(a==0)d2-=10;
    d3=dfs(i+1,a,b+l[i],c)+10;
    if(b==0)d3-=10;
    d4=dfs(i+1,a,b,c+l[i])+10;
    if(c==0)d4-=10;
    return std::min({d1,d2,d3,d4});
}

signed main(){
	
	
	cin>>n>>A>>B>>C;
	for(int i=0;i<n;i++)cin>>l[i];
	cout<<dfs(0,0,0,0)<<endl;
	
	
}

Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
    char s[4];
    scanf("%s", s);
    int c = 0;
    for (char *p = s; *p; p++) {
        if (*p == '1') c++;
    }
    printf("%d\n", c);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
def solve():
    length = [a,b,c,d,e]
    length.sort()
    if(length[-1]-length[0]>k):
        return print(':(')
    return print('Yay!')
solve()

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 998244353;

    constexpr unsigned long mx = 1000001;

    vector<unsigned long> coef(mx, 1), prime;
    iota(coef.begin(), coef.end(), 0UL);

    vector<unsigned long> sieve(mx, 1);
    for(unsigned long i = 2; i < mx; ++i)if(sieve[i]){
        prime.push_back(i);
        for(unsigned long j = i; j < mx; j += i){
            sieve[j] = 0;
            (coef[j] *= MOD + 1 - i) %= MOD;
        }
    }

    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);

    unsigned long ans{0};
    unsigned long max_size{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        max_size = max(i, max_size);
        ++hoge[i];
    }
    ++max_size;

    for(const auto& i : prime)for(unsigned long j = max_size / i; j; --j)hoge[j] += hoge[j * i] * i;
    for(auto& i : hoge)i %= MOD;

    ans = MOD - hoge[1];
    for(unsigned long i = 1; i < max_size; ++i)if(hoge[i])ans += hoge[i] * hoge[i] % MOD * coef[i] % MOD;
    (ans += (ans & 1) * MOD) >>= 1;
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 25972
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    speed_up;
    ll n, k;
    cin>>n>>k;
    ll ans;
    ans = k*pow((k-1), (n-1) );
    cout<<ans<<endl;



  return 0;
}



Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
ll power_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    const ll MAXX = 1000000000000001;
    ll N;
    cin >> N;
    vector<ll> v;
    v.push_back(26);
    while(v.back() <= MAXX){
        v.push_back(v.back() * 26);
    }
    rep(i,v.size()-1){
        v[i+1] += v[i];
    }
    ll len = 0;
    rep(i,v.size()){
        if(N<=v[i]){
            len = i+1;
            if(i >= 1)N -= v[i-1];
            break;
        }
    }
    vector<ll> beki(1,1);
    while(beki.back() <= MAXX){
        beki.push_back(beki.back() * 26);
    }
    /*
    dump(N);
    print(beki);
    print(v);
    dump(len);
    */
    string ans = "";
    N--;
    for(int i = 1; i <= len; i++){
        //dump(N);
        //dump(N%26);
            ans.push_back(char('a' + N%26));
            N /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;
}

Measured memory_bytes: 3660
from math import factorial
x, y = map(int, input().split())

if (x + y) % 3 or min(x, y) < (x + y) // 3:
    print(0)
    exit()

n = (x + y) // 3
m = x - n

tn = 10**6
mod = 10 ** 9 + 7
fact = [1, 1] + [0] * tn
finv = [1, 1] + [0] * tn
inv = [0, 1] + [0] * tn

for i in range(2, tn):
    fact[i] = fact[i - 1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod//i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod

def com(n, m):
    if n < m: return 0
    if n < 0 or m < 0: return 0
    return fact[n] * (finv[m] * finv[n - m] % mod) % mod

print(com(n, m))

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

int main(){
    int D,N; cin >> D >> N;
    if(D==0){
        if(N==100) cout << 100+1 << endl;
        else cout << 1*N << endl;
    }else if(D==1){
        if(N==100) cout << 100*100+100 << endl;
        else cout << 100*N << endl;
    }else{
        if(N==100) cout << 10000*100+10000 << endl;
        else cout << 10000*N << endl;
    }
}

Measured memory_bytes: 256
import math
A,B = map(int,input().split())
x_A= int(math.ceil(25/2*A))
x_B= int(math.ceil(10*B))
large_num = x_A if x_A > x_B else x_B
result = 0
if int(large_num*0.08) == A and int(large_num*0.1) == B:
  result = large_num
else:
  result = -1
print(result)

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input! {
        a: isize,
        b: isize,
    }
    println!("{}", max(max(a + b, a * b), a - b));
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
LL n;
int main()
{
	bool tf=true;
	LL ans=0,lalal=(1<<30);
	scanf("%lld",&n);
	for (LL u=1;u<=n;u++)
	{
		LL a,b;
		scanf("%lld%lld",&a,&b);
		if (a!=b) tf=false;
		ans=ans+a;
		if (a>b) lalal=min(lalal,b);
	}
	if (tf) printf("0");
	else printf("%lld\n",ans-lalal);
	return 0;
}

Measured memory_bytes: 256
/*
 * Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$
**/

#include <bits/stdc++.h>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <cmath>

using namespace std;

//typedef
typedef string STR;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef priority_queue<int> PQI;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<STR> VS;
typedef vector<char> VC;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<STR,int> PSI;
typedef pair<int,STR> PIS;
typedef vector<PII> VII;
typedef map<int,int> MII;
typedef map<LL,LL> MLL;
typedef map<STR,int> MSI;
typedef map<char,int> MCI;
typedef map<int,STR> MIS;
typedef set<STR> SS;
typedef set<int> SI;
typedef set<LL> SLL;

//symbolic const
#define MOD 1000000007
#define MAXN 1e9
#define SIZE 10000


//STL keywords
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
#define all(v) v.begin(), v.end()

//functions
#define dec(n) cout<<fixed<<setprecision(n);
#define f(i, n)   for(LL i=0; i<n; i++)
#define fa(i,a,n) for(LL i=a; i<n; i++)

//IO
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test int t;cin>>t;while(t--){solve();}

const LL INF=1e9+5;

LL maxLL(LL a, LL b){return (a>b?a:b);}
LL minLL(LL a, LL b){return (a<b?a:b);}

void solve() {
  int n;
  cin>>n;
  LL knap_w, sum_value=0;
  cin>>knap_w;
  VLL weight(n), value(n);
  f(i, n){
      cin>>weight[i]>>value[i];
      sum_value+=value[i];
  }
  VLL dp(sum_value+1, INF);
  dp[0]=0;
  for(int i=0; i<n; i++){
      for(LL value_already=sum_value-value[i]; value_already>=0; value_already--){
          dp[value_already+value[i]]=minLL(dp[value_already+value[i]], dp[value_already]+weight[i]);
      }
  }
  LL ans=0;
  for( LL i=0; i<=sum_value; i++){
      if(dp[i]<=knap_w)
       ans=maxLL(ans, i);
  }
  cout<<ans;
}

int main() {
    sync;
    //test;
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int i = 1;
	int ans = 1;

	while (i <= 100) {
		i *= 2;
		if (i > n) {
			cout << ans << endl;
			return 0;
		}
		ans = i;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define Num 20000

int main(void){

   int s[Num], t[Num];
   int n, q, i, j, count = 0;

   scanf("%d", &n);
   for (i=0; i < n; i++) {
      scanf(" %d", &s[i]);
   }

   scanf("%d", &q);
   for (i=0; i < q; i++) {
      scanf(" %d", &t[i]);
      for (j=0; j < n; j++) {
         if(s[j] == t[i]){
            count++;
            s[j] = 0;
            break;
         }
      }
   }

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

   return 0;
}



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

int main() {
  int n;
  long long ans = 0;
  cin >> n;
  vector<int> a(100005);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
    ans += x;
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    ans += a[b] * (c - b);
    a[c] += a[b];
    a[b] = 0;
    cout << ans << endl;
  }
  return 0;
}

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

void solve(){
    int n; cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    auto maxit = max_element(A.begin(), A.end());
    int maxind = distance(A.begin(), maxit);
    int max = A[maxind];
    A[maxind] = -1;
    auto maxit2 = max_element(A.begin(), A.end());
    int maxind2 = distance(A.begin(), maxit2);
    int max2 = A[maxind2];
    
    REP(i, n){
        if(i!=maxind) cout << max << endl;
        else cout << max2 << endl;
    }


}

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

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

using namespace std;

int main()
{
  int N[4];
  for (int i = 0; i < 4; i++)
    cin >> N[i];
  sort(N, N + 4);
  if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    if(min(n, m) == 1) {
        cout << (max(n, m) == 1 ? 1 : max(n, m) - 2) << endl;
    } else {
        cout << (n - 2) * (m - 2) << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
# チャンネルの情報は不要ではない, その情報を適切に使う必要がある
from itertools import accumulate
from collections import defaultdict
N, V = map(int, input().split())  # N個の録画したい番組, V個のチャンネル
programs = defaultdict(list)
for _ in range(N):
    s, t, c = map(int, input().split())
    programs[c].append((s, t))

imos = [0] * (100002)
for c, p in programs.items():  # cはチャンネルの番号, pは番組の開始と終了のペアのリスト
    p.sort()  # 開始時間が早い順にソート
    ps, pt = p[0]  # そのチャンネルで一番早い時間に始まる番組の開始と終了の時刻
    for s, t in p[1:]:
        if pt == s:  # もし直前の番組の終了時刻と今から始まる番組の開始時間が一緒なら繋げることができる
            pt = t
        else:
            # 繋げることができない場合、imos法を適用してpsとptを最新のものに変更する
            imos[ps-1] += 1  # ps-0.5を含むからps-1をインクリメントする？
            imos[pt] -= 1  # ptは含まないからptをデクリメントする
            ps, pt = s, t

    # forループでは最後の番組の録画を行っていないのでその処理
    imos[ps-1] += 1
    imos[pt] -= 1

print(max(accumulate(imos)))


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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n, m;
int arr[N];
char mat[1001][1001];
int dp[1050][1050];

int ways(int i, int j)
{     
      int &ans = dp[i][j];
      if( ans != -1 ) return ans;
      if( i >= n or j >=m ) return ans = 0;
      if( mat[i][j] == '#' ) return ans = 0;
      if( i == n-1 and j == m-1 ) return ans = 1;

      return dp[i][j] = (ways(i+1,j) + ways(i,j+1))%M;
}
void solve()
{     

     cin >> n >> m;
     loop(i,0,n)loop(j,0,m) cin >> mat[i][j];
     mset(dp,-1);
     cout << ways(0,0); 
}

int32_t main() {
    fastio;

  
  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 10624
#include <bits/stdc++.h>
#include <time.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
using vi = vector<ll>;
using vv = vector<vi>;
const ll INF = 1001001001;
const ll NUM = 1<<10;

//(開始, 今)を管理
//例:
//(0,0), (1,1), (2,2), (3,3), (4,4), (5,5)
//壁(1,2)   .      .(該当領域)
//(0,0), (1,3), (2,3), (3,3), (4,4), (5,5) ->(1,3),(2,3)は消す
//(0,0),               (3,3), (4,4), (5,5)
//壁(2,3)                 .(該当領域)
//(0,0),               (3,4), (4,4), (5,5) ->(3,4)は消す
//(0,0),                      (4,4), (5,5)
//
//・順序集合(map)を使う: map[今]=開始の最大値
//・ans = min(今-開始), multisetで管理
//・該当領域+1の範囲で開始が一番右のものだけ残す
//・それ以外はansからもmapからも消す

//

int main(){
    int h,w;
    cin >> h >> w;
    map<int,int> s;
    multiset<int> m;
    rep(i,w)s[i] = i;
    rep(i,w)m.insert(0);
    
    rep(i,h){
        int l,r;
        cin>>l>>r;
        --l;
        
        if(m.empty()){
            cout<<-1<<endl;
            continue;
        }
        
        auto itr = s.lower_bound(l);
        int mincost = INF;
        int maxstart= 0;
        bool rewrite = false;
        while(itr!=s.end() && itr->first<=r){
            rewrite = true;
            mincost = min(mincost,  r-itr->second);
            maxstart= max(maxstart, itr->second);
            int c = itr->first - itr->second;
            m.erase(m.find(c));
            itr = s.erase(itr);
            //s.erase(*itr);//これやっちゃだめ
            //itr++;
        }
        if(r!=w && rewrite){
            s[r] = maxstart;
            m.insert(mincost);
        }
        
        if(m.empty()){
            cout<<-1<<endl;
        }else{
            cout<<*m.begin()+i+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 22348
N = int(input())
A = [int(_) for _ in input().split()]
ans = 0

for i in range(N):
    A[i] = A[i] - (i+1)

A = sorted(A)

if N % 2 == 1:
    b = A[N//2]
    for i in A:
        ans += abs(i - b)
    print(ans)
else:
    ans = -sum(A[:N//2])+sum(A[N//2:])
    print(ans)

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

int main() {
  //N = 展望台の数
  //M = 道の数
  int N, M;
  cin >> N >> M;
  
  //H = 各展望台の高さ
  int H[N] = {0};
  //HQ = 各展望台の品質 0:良い、1:悪い
  int HQ[N] = {0};
  
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  for(int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    if(H[A-1] > H[B-1]){
      HQ[B-1] = 1;
    }else if(H[A-1] < H[B-1]){
      HQ[A-1] = 1;  
    }else if(H[A-1] == H[B-1]){
      HQ[A-1] = 1;  
      HQ[B-1] = 1;
    }
  }
    
    
  int count = 0;
  
  for(int i = 0; i < N; i++){
    if(HQ[i] == 0){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 4372
package main
 
import (
  "fmt"
  "os"
  "bufio"
  "strconv"
  "strings"
)

func main() {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Scan()
  stdInput := scanner.Text()
  valueList := strings.Split(stdInput, " ")
  a, _ := strconv.Atoi(valueList[0])
  b, _ := strconv.Atoi(valueList[1])
  
  if 0 < a && a < 10 && 0 < b && b < 10 {
    fmt.Println(a * b)
  } else {
    fmt.Println("-1")
  }
}

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

using namespace std;

typedef long long ll;
const int mx=1e5+10;
ll ans;

int main()
{
	int n;
	scanf("%d",&n);
	int t=1e7,c=0,x;
	
	for (int i=1;i<=n;++i){
		scanf("%d",&x);
		if(x<0){
			++c;
			x=abs(x);
		}
		t=min(t,x);
		ans+=x;
	}
	printf("%lld\n",c&1?ans-(t<<1):ans);
	
}

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

int main(){
    char ch;
    int counter[26];
    for(int i=0; i<26; i++) counter[i] = 0;
    while(cin >> ch){
        int num = tolower(ch) - 'a';
        counter[num]++;
    }
    for(int i=0; i<26; i++){
        ch = i + 'a';
        cout << ch << " : " << counter[i] << endl;
    }
    return 0;
} 

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a*b %2==0){
  	cout << "Even" << endl;
  }
  else if(a*b %2==1){
  	cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
n,k=list(map(int,input().split()))
li=list(map(int,input().split()))

sum_=0
for i in range(k):
  sum_+=li[i]
max_=sum_

for i in range(k,len(li)):
  sum_-=li[i-k]
  sum_+=li[i]
  if max_<sum_:
    max_=sum_
max_+=k
max_/=2
print(max_)

Measured memory_bytes: 25060
program abc159d
  use iso_fortran_env
  implicit none
  integer(int64) :: n, i
  integer(int64),dimension(:),allocatable :: a, freq, cmb, ans
  read *, n
  allocate(a(n), freq(n))
  read *, a
  freq = 0
  do i = 1,n
     freq(a(i)) = freq(a(i)) + 1
  end do
  cmb = freq * (freq - 1) / 2
  ans = sum(cmb) - (freq(a) - 1)
  print *, ans
end program abc159d


Measured memory_bytes: 11648
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;
  
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
  
#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
  
const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
  
  
int main(){
	int i,j,n,m,flag,unre;
	string s,t;
	cin>>s>>t;
	unre=0;
	int x=0;
	FOR(i,0,s.length()-t.length()+1){
		flag=0;
		FOR(j,0,t.length()){
			if(s[i+j]!=t[j]&&s[j+i]!='?')flag=1;
		}
		if(flag==0){//一致可能なら
			unre=1;
			x=i;
		}
	}
	if(unre==0){
		cout<<"UNRESTORABLE"<<endl;
	}else{
		FOR(j,0,t.length()){
			s[x+j]=t[j];
		}
		FOR(i,0,s.length()){
			if(s[i]=='?')s[i]='a';
		}
		cout<<s<<endl;
	}
	
    return 0;
}

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

int main(){
    long N, A, B;
    cin >> N >> A >> B;

    long P = 1 << N - 1;
    auto k = __builtin_popcountl(A ^ P ^ B);

    if(k & 1){
        puts("NO");
    }else{
        puts("YES");
        vector<long> ans((1 << N) - 1);
        for(long i = 0, j = 2; i < N; ++i){
            for(long l = j / 2 - 1; l < (1 << N) - 1; l += j)ans[l] = i;
            j *= 2;
        }

        vector<long> t;
        for(long i = 0; i < N; ++i)if(((A ^ P ^ B) >> i) & 1)t.push_back(i);

        auto s = t.size(), n = ans.size();
        for(long i = 0; i < s; i += 2){
            auto a = t[i], b = t[i + 1];
            for(long j = 0; j < n; ++j){
                if(ans[j] > b)break;
                if(ans[j] == a)ans[j] = b;
                else if(ans[j] == b)ans[j] = a;
            }
        }

        long a = A;
        cout << a << " ";
        for(const auto& i : ans){
            a ^= 1 << i;
            cout << a << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int calc(Int N, vector<deque<Int> > A){

  Int res = 0;

  vector<Int> I(N); iota(I.begin(), I.end(), 0);

  while(1){
    Int update = 0;
    res++;
    vector<Int> used(N);
    vector<Int> nI;
    for(Int i:I){
      if(used[i] ||  A[i].empty()) continue;
      Int target = A[i][0];
      if(A[target].empty() || used[target]) continue;

      if(A[target][0] == i){
        used[i] = 1;
        used[target] = 1;
        A[i].pop_front();
        A[target].pop_front();
        update = 1;
        nI.push_back(i);
        nI.push_back(target);
      }
    }
    I = nI;
    if(!update) break;
  }

  for(Int i=0;i<N;i++) if(!A[i].empty()) return -1;

  return res-1;
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<deque<Int> > A(N, deque<Int>(N-1, 0));
  for(Int i=0;i<N;i++){
    for(Int j=0;j<N-1;j++){
      Int a;
      cin>>a; a--;
      A[i][j] = a;
    }
  }

  Int ans = calc(N, A);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 17280