akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <numeric>

int f(int, int, int);
int N;
int yotei[100];
int dp[111][4][4];

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

    int k, date;
    std::cin >> N >> k;
    for (int i = 0; i < k; i++) {
        std::cin >> date;
        std::cin >> yotei[date - 1];
    }

    for (int i = 0; i < 111; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                dp[i][j][k] = -1;

    std::cout << f(0, 0, 0) << "\n";
    return 0;
}

int f(int day, int kinou, int ototui) {
    if (day == N) return 1;
    if (dp[day][kinou][ototui] >= 0) return dp[day][kinou][ototui];
    int ans = 0;

    for (int i = 1; i <= 3; i++) {
        if ((i == kinou && i == ototui) || (yotei[day] != 0 && i != yotei[day])) continue;

        ans += f(day + 1, i, kinou);
    }

    dp[day][kinou][ototui] = ans % 10000;
    return ans % 10000;
}

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

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

int main(){
	string a;
	cin>>a;
	if(a == "Sunny"){
		cout<<"Cloudy"<<endl;
	}
	else if(a == "Cloudy"){
		cout<<"Rainy"<<endl;
	}
	else{
		cout<<"Sunny"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char status = s.charAt(0);

        int count = 0;
        for (int i = 1; i < s.length(); i++) {
            if (status != s.charAt(i)) {
                count++;
                status = s.charAt(i);
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 24216
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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;
}

int n, q;
vector<int> S, T;

bool isOK(int index, int key) {
    if(S[index] >= key)
        return true;
    else
        return false;
}

int binary_search(int key) {
    int ng = -1;
    int ok = (int)S.size();

    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if(isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

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

    cin >> n;
    S.assign(n, 0);
    rep(i, n) cin >> S[i];
    cin >> q;
    T.assign(q, 0);
    rep(i, q) cin >> T[i];

    int ans = 0;
    rep(i, q) {
        int left = binary_search(T[i]);
        if(S[left] == T[i]) ans++;
    }
    COUT(ans);
}



Measured memory_bytes: 3396
#include <iostream>
typedef long long ll;
using namespace std;
inline ll min(ll a,ll b){
	return a<b ? a : b;
}
inline ll ab(ll a){
	return a>0 ? a : -a;
}
int main(int argc, char *argv[]) {
	ll n,k,t;
	cin>>n>>k;
	t=n;
	if(n%k==0) {cout<<0<<endl; return 0;}
	if(n>k) t=n%k;
	cout<<min(t,ab(t-k));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#define MAX_T 50
#define MAX_P 10
using namespace std;

typedef pair<int,int> S;
typedef vector<S> V;
typedef map<int,set<S>> MM;

bool pairCompare(const S& firstElof, const S& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(void)
{
    int M, T, P, R;
    while (cin >> M >> T >> P >> R) {
        if (M == 0 && T == 0 && P == 0 && R == 0) break;
        int m, t, p, j, data[T + 1][P + 1][2];
        memset(data, 0, sizeof(data));
        for (int i = 0; i < R; i++) {
            cin >> m >> t >> p >> j;
            if (j == 0) {
                data[t][0][0] += (m + data[t][p][1]);
                data[t][0][1]++;
            } else
                data[t][p][1] += 20;
        }
        V v;
        MM mm;
        queue<int> ans;
        for (int i = 1; i <= T; i++) {
            if (data[i][0][1] == 0) data[i][0][0] = -2;
            mm[data[i][0][1]].insert(S(data[i][0][0],i));
        }
        for (int i = P; i >= 0; i--) {
            stack<int> tmp;
            auto f = mm[i].begin();
            for (auto it = mm[i].begin(); it != mm[i].end(); it++) {
                if ((*f).first == (*it).first) tmp.push((*it).second); 
                else {
                    if (ans.size()) ans.push(-1);
                    while (tmp.size()) {
                        advance( f, 1);
                        auto ss = tmp.top(); tmp.pop();
                        ans.push(ss);
                        if (tmp.size()) ans.push(-3);
                    }
                    tmp.push((*it).second);
                }
            }
            if (tmp.size()) {
                if (ans.size())ans.push(-1);
                while (tmp.size()) {
                    auto ss = tmp.top(); tmp.pop();
                    ans.push(ss);
                    if (tmp.size()) ans.push(-3);
                }
            }
        }
        while (ans.size()) {
            int tmp = ans.front(); ans.pop();
            if (tmp == -1) cout << ",";
            else if (tmp == -3) cout << "=";
            else cout << tmp;
        }
        cout << endl;
        
    }
    
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力の取得
s = input()

# 結果出力
result = str()
for s_i in s:
    if s_i == "0":
        result += "0"
    elif s_i == "1":
        result += "1"
    elif s_i == "B":
        result = result[:-1]

# 結果出力
print(result)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cmath>
#include<typeinfo>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin>>n;
    if(n%2==0)cout << n << endl;
    else cout << 2 * n << endl; 
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdlib>
#include<list>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<stack>
#define MAX 1001
using namespace std;
int main() {
	int n; cin >> n;
	string x, y; int data[MAX][MAX] = {0,0};
	for (int d = 0; d <n; d++)
	{
		cin >> x >> y;
		for (int i = 0; i < y.size(); i++)
		{
			for (int j = 0; j < x.size(); j++)
			{
				if (y[i] == x[j]) {
					data[j + 1][i + 1] = data[j][i] + 1;
				}
				else {
					data[j + 1][i + 1] = max(data[j + 1][i], data[j][i + 1]);
				}
			}
		}
		cout << data[x.size()][y.size()]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  int ans = 0;
  int b,c,d;
  if(a[0] == a[1] && a[1] == a[2]){
    if(a[0] % 2 == 0){
      cout << -1 << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
    while(a[0] % 2 == 0 && a[1] % 2 == 0 && a[2] % 2 == 0){
      b = a[1];
      c = a[2];
      d = a[0];
      a[0] = (b+c)/2;
      a[1] = (d+c)/2;
      a[2] = (d+b)/2;
      ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

#define L 100000
#define M 2000001

int a[M],b[M],c[M];
int n,i,j;

int main(){
  scanf("%d",&n);

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

  for(j=0;j<L;j++){
    c[j]=0;
    b[j]=0;
  }

  for(i=1;i<=n;i++){
    c[a[i]]++;
  }

  for(i=1;i<10001;i++){
    c[i] += c[i-1];
  }

  for(i=n;i>0;i--){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }

  for(i=1;i<n;i++){
    printf("%d ",b[i]);
  }
  printf("%d\n",b[n]);

  return 0;
}

  

Measured memory_bytes: 19940
#include <bits/stdc++.h>
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define P pair<int, int>
#define F first
#define S second
#define prique priority_queue<P, vector<P>, greater<P>>
using namespace std;

int n,z,w,a[2000];

signed main() {
	cin>>n>>z>>w;
	rep(i,n)cin>>a[i];
	if(n==1)cout<<abs(w-a[0])<<endl;
	else cout<<max(abs(w-a[n-1]),abs(a[n-1]-a[n-2]))<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    public static int MAXN = 1600;
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int a=cin.nextInt(),b=cin.nextInt(),c=cin.nextInt(),d=cin.nextInt();
        int ans=0;
        for(int i=a;i<b;i++){
        	if(i>=c&&i<d){
        		ans++;
        	}
        }
        out.println(ans);
        out.flush();
        out.close();
        cin.close();
    }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main(){
  char s[1010];
  scanf("%s",s);
  
  printf("%s",s);
  
  for(int i=0;i<=1010;i++){
    if(s[i]>'z' || s[i]<'a'){
      if(s[i-1]=='s'){
        printf("es");
        return 0;
      }else{
        printf("s");
        return 0;
      }
    }
  }
}

Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 100005
#define inf 100000000000000000LL
ll a[mx], b[mx], c[mx];
/// 1     2       3
int n;
ll dp[mx][4];
ll fun(int pos, int prev)
{
    if(pos>n) return 0;
    ll& ret = dp[pos][prev];
    if(ret!=-1) return ret;
    if(prev!=1) ret = max(ret, a[pos] + fun(pos+1, 1));
    if(prev!=2) ret = max(ret, b[pos] + fun(pos+1, 2));
    if(prev!=3) ret = max(ret, c[pos] + fun(pos+1, 3));
    return ret;
}
int main()
{
    while(scanf("%d",&n)){
        for(int i=1; i<=n; i++)
            scanf("%lld%lld%lld",&a[i], &b[i], &c[i]);
        memset(dp, -1, sizeof dp);
        printf("%lld\n",fun(1,0));
        return 0;
    }
}



Measured memory_bytes: 11904
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int N = int.Parse (str[0]);
            int M = int.Parse (str[1]);

            char[] ans = new char[N];
            for (int i = 0; i < ans.Length; i++)
            {
                ans[i] = '0';
            }

            for (int i = 0; i < M; i++)
            {
                str = Console.ReadLine ().Split (' ');
                int s = int.Parse (str[0]) - 1;
                char c = str[1][0];

                if (s == 0 && c == '0')
                {
                    if (N == 1) break;
                    Console.Write (-1);
                    return;
                }
                if (ans[s] != '0')
                {
                    if (ans[s] == c)
                    {
                        break;
                    }
                    else
                    {
                        Console.Write (-1);
                        return;
                    }
                }
                else
                {
                    ans[s] = c;
                }
            }

            if (ans[0] == '0' && N != 1) ans[0] = '1';

            Console.Write (ans);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27188
#include <iostream>
#include <climits>
using namespace std;
using lld=long long ;


const int temp =100010;
const int lef =110;
lld dp[lef][temp];

bool chmin(lld& a,lld b){//a>b=T
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    lld N,W;
    cin >> N>>W;
    lld v[N],w[N];
    for(int i=0;i<N;i++){
        cin >> w[i] >>v[i];
    }
    for(int j=0;j<lef;j++){
        for(int i=0;i<temp;i++){
            dp[j][i]=INT_MAX;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<temp;j++){
            if(j-v[i]>=0){
                chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
            }
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    for(int i=temp-1;i>=0;i--){
        if(dp[N][i]<=W){
            cout << i<<"\n";
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 86144
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2000+10;
const int p=1e9+7;
int n,k,f[maxn][maxn],farc[maxn*maxn],inv[maxn*maxn];

int C(int n,int m){
	return (ll)farc[n]*inv[m]%p*(ll)inv[n-m]%p;
}

int main()
{
	scanf("%d%d",&n,&k);k--;
	if(!k){printf("1\n");return 0;}
	farc[0]=farc[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=n*k+n+k;i++){
		farc[i]=(ll)farc[i-1]*i%p;
		inv[i]=(ll)(p-p/i)*inv[p%i]%p;
	}
	for(int i=2;i<=n*k+n+k;i++) inv[i]=(ll)inv[i]*inv[i-1]%p;
	f[0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=i;j<=n;j++){
			if(i>0) f[i][j]=(f[i][j]+f[i-1][j])%p;
			if(j>0) f[i][j]=(f[i][j]+(ll)f[i][j-1]*C(i+(j-1)*k+k-1,k-1)%p)%p;
		}
	printf("%d\n",(ll)f[n][n]*farc[n]%p);
	return 0;
}

Measured memory_bytes: 47488
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

constexpr int INF{1001001001};
constexpr lint LINF{1001001001001001001ll};
constexpr int MOD{(int)1e9 + 7};
constexpr double EPS{1e-9};
const double PI{acos(-1)};
constexpr int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)(v.size() - 1) ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  string s;
  cin >> s;
  string t = s;
  reverse(all(t));
  if (t == s) {
    print("Yes");
  } else {
    print("No");
  }
}


Measured memory_bytes: 256
M=2019;L,R=map(int,input().split())
l=L%M;r=R%M;a=M
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int h, n ;
    cin >> h >> n ;
    vint a(n) ;
    vint b(n) ;
    REP(i,n){
        cin >> a[i] >> b[i] ;
    }
    vint cost(h+1,INF) ;
    cost[h] = 0 ;
    for(int i=h;i>=1;i--){
        if(cost[i]==INF){
            continue ;
        }
        for(int j=0;j<n;j++){
            int next = max(0,i-a[j]) ;
            cost[next] = min(cost[next],cost[i]+b[j]) ;
        }
    }
    cout << cost[0] <<endl;


    


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	int[] a;
	public void solve() {
		N = nextInt();
		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}

		int ans = Integer.MAX_VALUE;
		for(int i = -100;i <= 100;i++){
			int costSum = 0;
			for(int j = 0;j < N;j++){
				if(a[j] != i){
					costSum += (a[j] - i) * (a[j] - i);
				}
			}

			ans = Math.min(ans,costSum);
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8020
#include <stdio.h>

int main(void)
{
    long long int transport[5];
    long long int n;

    int i;
    long long int min, min_time;
    int min_id;

    scanf("%lld", &n);
    for(i=0;i<5;i++){
        scanf("%lld", &transport[i]);
    }

    min = 1000000000000001;
    min_id = -1;
    for(i=0;i<5;i++){
        if(transport[i] < min){
            min = transport[i];
            min_id = i;
        }
    }

    min_time = (n + min - 1) / min;

    printf("%lld", min_time + 4);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  int a,b;cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) :d(n, -1) {}
    int find(int x){
        if (d[x] < 0) return x;
        else return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    vector<int> ans;
    rep(i, q){
        int com, x, y;
        cin >> com >> x >> y;
        if (com){
            ans.push_back(uf.same(x, y));
        }else{
            uf.unite(x, y);
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3280
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,a[N];

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	int ans=0;
	for (int i=1;i<=n;++i)
		if (i==a[i]) swap(a[i],a[i+1]),++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4148
//caddi2018_d.cpp
//Sat Dec 22 20:47:35 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	int flag = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		if (a[i]%2==1){
			flag = 1;
		}
	}

	if (flag == 1){
		cout << "first" << endl;
	}else {
		cout << "second" << endl;
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        REP(i, n) par[i] = i;
    }

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

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

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

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

    int n, k, l;
    cin >> n >> k >> l;

    UnionFind D(n), R(n);

    REP(i, k) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        D.unite(p, q);
    }

    REP(i, l) {
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        R.unite(r, s);
    }

    map<pair<int, int>, int> mp;

    REP(i, n) {
        mp[make_pair(D.root(i), R.root(i))]++;
    }

    REP(i, n) {
        if (i)cout << " ";
        cout << mp[make_pair(D.root(i), R.root(i))];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int CONTEST_NUM=26;

int score_function(const vector<int> &t,const vector<vector<int>> &s,const vector<int> &c,const int &d){
    vector<int> last(27);
    int manzoku=0;
    for(int i=1;i<=d;i++){
        manzoku+=s[i][t[i]];
        last[t[i]]=i;
        int sum=0;
        for(int j=1;j<=CONTEST_NUM;j++){
            sum+=c[j]*(i-last[j]);
        }
        manzoku-=sum;
    }
    return manzoku;
}

void set_ans(const vector<int> &t,vector<int> &ans,const int &d){
    for(int i=1;i<=d;i++){
        ans[i]=t[i];
    }
}

int main() {
    int d;cin>>d;
    vector<int> c(27);
    for(int i=1;i<=CONTEST_NUM;i++){
        cin>>c[i];
    }
    vector<vector<int>> s(d+1,vector<int>(27));
    for(int i=1;i<=d;i++){
        for(int j=1;j<=CONTEST_NUM;j++){
            cin>>s[i][j];
        }
    }
    vector<int> t(d+1);
    vector<int> ans(d+1);
    int old_ans=-1000000000;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand26(1,26);
   int k=0;
    while(k<100000){
        for(int i=1;i<=d;i++){
            t[i]=rand26(mt);
        }
        int tmp=score_function(t,s,c,d);
        if(tmp>old_ans){
            set_ans(t,ans,d);
            old_ans=tmp;
        }
        k++;
    }
    for(int i=1;i<=d;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


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

int main(){
    int min, max, N, temp;
    min = 1000000000;
    max = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> temp;
        if(min > temp){
            min = temp;
        }
        if(max < temp){
            max = temp;
        }
    }

    cout << max-min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

string S, T;

int main() {
    cin >> S >> T;
    int n = S.size();
    if (T.size()== n+1 && T.substr(0,n) == S) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


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

int main() {
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*N]

c = [0]*N
d = [0]*N
for i,ab in enumerate(AB):
    a,b = ab
    c[i] = a
    d[i] = b
c.sort()
d.sort(reverse=True)

if N%2:
    L = c[N//2]
    R = d[N//2]
    print(R-L+1)
else:
    L1 = c[N//2-1]
    R1 = d[N//2]
    L2 = c[N//2]
    R2 = d[N//2-1]
    print((R1+R2)-(L1+L2)+1)

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

using int64 = long long;
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W;
int a[555][555];
using pii = pair<int, int>;
using pp = pair<pii, pii>;
vec<pp> ans;

int main() {
   cin >> H >> W;
   rep (i, H) {
      rep (j, W) {
         cin >> a[i][j];
      }
   }

   int cnt = 0;

   rep (i, H-1) {
      rep (j, W) {
         if (a[i][j]&1) {
            ans.push_back({{i+1, j+1}, {i+2, j+1}});
            // printf("%d %d %d %d\n", i+1, j+1, i+2, j+1);
            a[i][j]--;
            a[i+1][j]++;
         }
      }
   }

   int h = H-1;
   rep (j, W-1) {
      if (a[h][j]&1) {
         ans.push_back({{h+1, j+1}, {h+1, j+2}});
         // printf("%d %d %d %d\n", h+1, j+1, h+1, j+2);
         a[h][j]--;
         a[h][j+1]++;
      }
   }

   cout << ans.size() << endl;
   rep (i, ans.size()) {
      printf("%d %d %d %d\n", ans[i].first.first, ans[i].first.second, ans[i].second.first, ans[i].second.second);
   }

   return 0;
}

Measured memory_bytes: 5232
from collections import Counter

n,k,q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()))

cnt = Counter(a)

#print(cnt[3])

for i in range(1,n+1):
    if (k-q+cnt[i]>0):
        print('Yes')
    elif(k-q+cnt[i]<0):
        print('No')
    else:
        print('No')

Measured memory_bytes: 60504
// WeirdBugsButOkay

# include <bits/stdc++.h>

# define ll long long
# define ld long double
# define pii pair <int,int>
# define pll pair <ll,ll>
# define mp make_pair
# define pb push_back
# define ff first
# define ss second
# define endl '\n'

using namespace std;

ll pow3(ll a, ll b, ll m = 1000000007)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    ll r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q = 1;
    //cin >> q;
    for(ll i = 0; i < q; i++)
    {
        solve();
    }
    return 0;
}


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

#define infi            2e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define loop1(i,n)      for(register int i=1;i<=n;i++)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//

int N,M;
string A[55],B[55];

bool func(int r,int c){
    int x,y;
    for(int i=0;i<M;i++){
        x=r+i;
        for(int j=0;j<M;j++){
            y=c+j;
            if(x==N || y==N || A[x][y]!=B[i][j])return 0;
        }
    }
    return 1;
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    cin >> N >> M;
    loop(i,N)cin >> A[i];
    loop(i,M)cin >> B[i];

    loop(i,N){
        loop(j,N){
            if(A[i][j]==B[0][0]){
                if(func(i,j)){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, N;
  cin >> N;
  if(N == 1) {
    cout << "Hello World" << endl;
  }
  else {
    cin >> A >> B;
    cout << A+B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a = input("").split(" ")
a = [int(b) for b in a]
N = a[0]
A = a[1]
B = a[2]
S = input("")
n = 0
nb = 1
for c in range(len(S)):
    if S[c] == "a":
        if n < (A + B):
            n += 1
            print("Yes")
        else:
            print("No")
    elif S[c] == "b":
        if n < (A + B) and nb <= B:
            n += 1
            nb += 1
            print("Yes")
        else:
            print("No")
    elif S[c] == "c":
        print("No")

Measured memory_bytes: 9052
import java.util.Scanner;

class Main{

    public static void main(String[] args){

	Scanner scan = new Scanner(System.in);

	while(true){

	    int n = scan.nextInt();

	    if(n == 0){
		break;
	    }

	    int[] prime = new int[n+1];

	    for(int i = 0; i < n; i++){
		prime[i] = 1;
	    }

	    prime[0] = 0;
	    prime[1] = 0;

	    for(int i = 2; i < Math.sqrt(n+1); i++){
		if(prime[i] == 1){

		    for(int j = i * 2; j < n + 1; j+=i){
			prime[j] = 0;
		    }

		}
	    }


	    int pass = 0;

	    for(int i = 2; i <= n / 2; i++){

		if(prime[i] == 1){
		    int another = n - i;
		    if(prime[another] == 1){
			pass++;
		    }
		}
	    }

	    System.out.println(pass);

	}
    }
}

		

		
		

Measured memory_bytes: 0
from collections import defaultdict

N=int(input())
A=list(map(int,input().split()))
d=defaultdict(int)

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

MIN=min(A)
MAX=max(A)

ans=0
for i in range(MIN,MAX+1):
    ans=max(ans,d[i-1]+d[i]+d[i+1])
print(ans)

Measured memory_bytes: 19424
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll A, B, C, k;
  cin >> A >> B >> C >> k;
  if(k % 2 == 0) {
    cout << A - B << endl;
    return 0;
  }
  cout << B - A << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N, count = 0;
    cin >> N;
    for (int i = 1; i <= N; i += 2) {
        int yakusu = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                yakusu++;
            }
        }
        if (yakusu == 8) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int  a, b, c;
	cin >> a >> b >> c;
	if ((a + b) == c) {
		cout << "Yes" << endl;
	}
	else if ((a + c) == b) {
		cout << "Yes" << endl;
	}
	else if ((b + c) == a) {
		cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}
}

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

typedef struct {
	int key, id;
} data;

typedef struct {
	data *obj;
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key < h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key < h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

typedef struct {
	int t, h, cost;
} edge;

typedef struct List {
	struct List *next;
	edge *e;
} list;

typedef struct {
	int n, m;
	edge *e;
	list **inc;
} graph;

void input_graph(graph *G, int n, int m)
{
	int i;
	list *data = (list*)malloc(sizeof(list) * m * 2);
	G->n = n;
	G->m = m;
	G->e = (edge*)malloc(sizeof(edge) * m);
	G->inc = (list**)malloc(sizeof(list*) * (n + 1));
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &(G->e[i].t), &(G->e[i].h), &(G->e[i].cost));
		data[i*2].e = &(G->e[i]);
		data[i*2+1].e = &(G->e[i]);
		data[i*2].next = G->inc[G->e[i].t];
		data[i*2+1].next = G->inc[G->e[i].h];
		G->inc[G->e[i].t] = &(data[i*2]);
		G->inc[G->e[i].h] = &(data[i*2+1]);
	}
}

void redundant_edge_dijkstra(graph *G, int s, int red[])
{
	static int i, *dist = NULL, *prev = NULL;
	if (dist == NULL) {
		dist = (int*)malloc(sizeof(int) * (G->n + 1));
		prev = (int*)malloc(sizeof(int) * (G->n + 1));
	}
	for (i = 1; i <= G->n; i++) {
		dist[i] = 1 << 30;
		prev[i] = 0;
	}
	dist[s] = 0;
	prev[s] = -s;
	
	int u, w;
	list *p;
	data d;
	min_heap h;
	h.obj = (data*)malloc(sizeof(data) * (G->m * 2 + 1));
	h.size = 0;
	d.key = 0;
	d.id = s;
	push(d, &h);
	while (h.size > 0) {
		u = pop(&h).id;
		if (prev[u] > 0) continue;
		prev[u] *= -1;
		for (p = G->inc[u]; p != NULL; p = p->next) {
			w = (p->e->t == u)? p->e->h: p->e->t;
			if (dist[u] + p->e->cost < dist[w]) {
				dist[w] = dist[u] + p->e->cost;
				prev[w] = -u;
				d.key = dist[w];
				d.id = w;
				push(d, &h);
			}
		}
	}
	
	for (i = 0; i < G->m; i++) {
		u = G->e[i].t;
		w = G->e[i].h;
		if (G->e[i].cost == abs(dist[u] - dist[w])) red[i] = 0;
	}
}

int main()
{
	int N, M;
	graph G;
	scanf("%d %d", &N, &M);
	input_graph(&G, N, M);
	
	int i, red[1000], sum = 0;
	for (i = 0; i < M; i++) red[i] = 1;
	for (i = 1; i <= N; i++) redundant_edge_dijkstra(&G, i, red);
	for (i = 0; i < M; i++) sum += red[i];
	printf("%d\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>


#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));

int main(){
    int n, a, b, ret = 0;
    scanf("%d%d%d", &n, &a, &b);
    for(int i = 1; i <= n; ++i){
        int tmp = i, count = 0;
        while(tmp > 0){
            count += tmp % 10;
            tmp /= 10;
        }
        if(a <= count && count <= b){
            ret += i;
        }
    }
    printf("%d\n", ret);
    return 0;
}



Measured memory_bytes: 128
def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs
        

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
modFacts, invs = prepare(max(N, M))

ans = 0
for i in range(N + 1):
    cnt = (modFacts[N] * invs[i] * invs[N - i]) % MOD
    cnt *= (modFacts[M] * invs[M - i]) % MOD
    cnt %= MOD
    cnt *= pow(modFacts[M - i] * invs[(M - i) - (N - i)], 2, MOD)
    cnt %= MOD
    ans += pow(-1, i) * cnt
    ans %= MOD

print(ans)


Measured memory_bytes: 95644
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll A,B,C,D,E,F;
  cin>>A>>B;
  C=(A+0.08-0.001)/0.08;
  D=(B+1+0.1-0.001)/0.1;
  E=(A+1+0.08-0.001)/0.08;
  F=(B+0.1-0.001)/0.1;
  
  
  if(max(C,F)<min(E,D)) {
    cout<<max(C,F)<<endl;
    
  }
  else
    cout<<"-1"<<endl;
}
  
    

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct xy{
    ll x;
    ll y;
};

bool asc( const xy& left, const xy& right ) {
     return left.x < right.x;
 }

int main() {
    ll n;
    xy xys[200001];
    std::cin >> n;
    ll f_r_max,f_r_min,f_b_max,f_b_min;
    f_r_max = 0;
    f_r_min = 1000000000+10;
    f_b_max = 0;
    f_b_min = 1000000000+10;
    
    ll result = 0;
    
    for (int i = 0; i < n; i++) {
        ll tmp_x,tmp_y;
        std::cin >> tmp_x >>tmp_y;
        
        xys[i].x = min(tmp_x,tmp_y);
        xys[i].y = max(tmp_x,tmp_y);
         
        f_r_max = max(f_r_max, xys[i].y );
        f_r_min = min(f_r_min, xys[i].y );
        f_b_max = max(f_b_max, xys[i].x );
        f_b_min = min(f_b_min, xys[i].x );
    }
    
    result = (f_r_max - f_r_min) * (f_b_max - f_b_min);
    
    sort(xys,xys+n,asc);
    
    ll now_min = 1000000000+10;
    ll now_max = f_b_max;
    
    // if(xys[0].y > now_max){
    //     if(xys[0].y - xys[1].x < now_max - now_min){
    //         now_max = xys[0].y;
    //         now_min = 
    //     }
    // }else{
    //     now_min = xys[0].y;
    // }
    
    // チェンジできなくなったらそこで試合終了
    
    for (int i = 0; i < n; i++) {
        if( xys[i].y >now_max ){
            if(now_min == 1000000000+10){
                result = min(result, ( f_r_max - f_b_min) * (now_max-xys[i].x));
                
                now_max = xys[i].y;
            }else{
                // 交換　の利益が上回る
                if(xys[i].y - now_min < now_max - min(now_min,xys[i].x)){
                    now_max = xys[i].y;
                }else{
                    // 交換不可能！試合終了
                    now_min = min(now_min,xys[i].x);
                    break;
                }
            }
        // 無条件でチェンジ可能
        }else {
            now_min = min(now_min,xys[i].y);
            
        }
    }
    
    // std::cout << now_max << std::endl;
    // std::cout << now_min << std::endl;
    
    if(now_min ==1000000010 ){
        std::cout << result << std::endl;
        return 0;
    }
    
    
    std::cout << min(result, ( f_r_max - f_b_min) * ( now_max - now_min) ) << std::endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int T;
    cin >> T;
    for(int i=0; i<T; i++){
        int N, D;
        cin >> N >> D;
        int ans = 0;
        for(int j=0; j<7; j++){
            int fac;
            if(D & (1<<j))
                if(N % 2 == 0) fac = N - 1;
                else fac = N;
            else
                if(N % 2 == 0) fac = N;
                else fac = N - 1;
            ans += fac * (1<<j);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let x = read::<usize>();
    let y = read::<usize>();
    let z = read::<usize>();
    let k = read::<usize>();

    let mut a = (0..x).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut b = (0..y).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut c = (0..z).map(|_| read::<usize>()).collect::<Vec<_>>();
    a.sort();
    b.sort();
    c.sort();
    a.reverse();
    b.reverse();
    c.reverse();

    use std::collections::{BinaryHeap, HashSet};

    let mut q = BinaryHeap::new();
    q.push((a[0] + b[0] + c[0], (0, 0, 0)));

    let mut s = HashSet::new();
    s.insert((0, 0, 0));

    for _ in 0..k {
        let (v, (xi, yi, zi)) = q.pop().unwrap();
        println!("{}", v);

        let ix = vec![
            if xi + 1 < x {
                Some((xi + 1, yi, zi))
            } else {
                None
            },
            if yi + 1 < y {
                Some((xi, yi + 1, zi))
            } else {
                None
            },
            if zi + 1 < z {
                Some((xi, yi, zi + 1))
            } else {
                None
            },
        ];

        for index in ix {
            if let Some(k) = index {
                if !s.contains(&k) {
                    s.insert(k);
                    let (xi, yi, zi) = k;
                    q.push((a[xi] + b[yi] + c[zi], k))
                }
            }
        }
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    long long n,ans,s,i;
    scanf("%lld",&n); 
    for(i=sqrt(n);i>0;i--)
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){ 
        ++s;
        ans/=10;
    }
    printf("%d\n",s); 
    return 0;
}

Measured memory_bytes: 128