akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main{

    static Node firstNode;
    static Node lastNode;

    static class Node {
        int data;
        Node prev;
        Node next;

        public Node(int data) {
            this.data = data;
        }
    }

    static void insertNode(int data) {
        Node xNode = new Node(data);
        if (firstNode == null) {
            firstNode = xNode;
            lastNode = xNode;
        } else {
            xNode.next = firstNode;
            firstNode.prev = xNode;
            firstNode = xNode;
        }
    }

    static void delete(int data) {
        Node cur = firstNode;
        while (cur != null) {
            if (cur.data == data) {
                if (cur == lastNode) {
                    deleteLast();
                    return;
                }
                if (cur == firstNode) {
                    deleteFirst();
                    return;
                }
                cur.next.prev = cur.prev;
                cur.prev.next = cur.next;
                return;
            }
            cur = cur.next;
        }
    }

    static void deleteFirst() {
        firstNode = firstNode.next;
        if (firstNode != null) {
            firstNode.prev = null;
        } else {
            lastNode = null;
        }
    }

    static void deleteLast() {
        lastNode = lastNode.prev;
        if (lastNode != null) {
            lastNode.next = null;
        } else {
            firstNode = null;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String[] st = br.readLine().split(" ");
            String command = st[0];
            int data;
            switch (command) {
                case "insert":
                    data = Integer.parseInt(st[1]);
                    insertNode(data);
                    break;
                case "delete":
                    data = Integer.parseInt(st[1]);
                    delete(data);
                    break;
                case "deleteFirst":
                    deleteFirst();
                    break;
                case "deleteLast":
                    deleteLast();
                    break;
            }
        }

        Node cur = firstNode;
        boolean printed = false;
        while (cur != null) {
            if (printed) {
                bw.append(" ");
            } else {
                printed = true;
            }
            bw.append(cur.data + "");
            cur = cur.next;
        }
        bw.newLine();
        bw.flush();
    }
}


Measured memory_bytes: 188804
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int H,W,count=0;
    cin>>H>>W;
    string S[52];
    for(int i=0;i<H;i++)cin>>S[i];
    bool ans=false;
    for(int i=1;i<H;i++){
        for(int j=1;j<W;j++){
            if(S[i][j]=='#'&&S[i][j-1]!='#'&&S[i][j+1]!='#'&&S[i-1][j]!='#'&&S[i+1][j]!='#')count++;
        }
    }
    if(count==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string S,weather;
  cin >> S;
  if(S=="Sunny"){
    weather="Cloudy";
  }
  if(S=="Cloudy"){
    weather="Rainy";
  }
  if(S=="Rainy"){
    weather="Sunny";
  }
  cout << weather << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] = s[k - 1] == 'A'? 'a': s[k - 1] == 'B'? 'b': 'c';
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
#define ALL(obj) (obj).begin(),(obj).end()
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>

int main(){
	CIN(N);
	COUT((N+1)/2);
}

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

const int mod = 1e9 + 7;

int modpow(long long a, long long b){
    if(b == 0) return 1;
    if(b & 1) return a * modpow(a, b-1) % mod;
    return modpow(a*a % mod, b/2);
}

long long modcomb(long long a, long long b){
    if(a == 0 || b == 0) return 1;
    if(a < b || b < 0) return 0;

    long long faca = 1, facb = 1;
    for(int i=1; i<=a; ++i){
        if(i > a-b) faca = faca * i % mod;
        if(i <= b) facb = facb * i % mod;
    }

    return faca * modpow(facb, mod - 2) % mod;
}

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

    for(int i=1; i<= k; ++i){
        cout << modcomb(n-k + 1, i) * modcomb(k-1, i-1) % mod << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define int long long
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
class Union_Find{
private:
    vector<int> t,s;
public:
    Union_Find(int max_length){
        rep(i,max_length+1){
            t.push_back(i);
            s.push_back(1);
        }
    }
    void Union(int x,int y){
        if(same(x,y))return;
        int tx=Find(x),ty=Find(y);
        if(s[tx]<s[ty]){
            s[ty]+=s[tx];
            t[tx]=ty;
        }
        else if(s[tx]>s[ty]){
            s[tx]+=s[ty];
            t[ty]=tx;
        }
        else if(tx>ty){
            t[tx]=ty;
            s[ty]+=s[tx];
        }
        else{
            t[ty]=tx;
            s[tx]+=s[ty];
        }
    }
    int Find(int n){
        if(t[n]==n)return n;
        else return t[n]=Find(t[n]);
    }
    bool same(int x,int y){
        return Find(x)==Find(y);
    }
    int get_Size(int a){
        return s[a];
    }
};
signed main(){
    int n,a[100000],cnt=0;
    bool b=false;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0){
            cnt++;
            a[i]*=-1;
        }
        if(a[i]==0)b=true;
    }
    int ans=0;
    sort(a,a+n);
    if(cnt%2==0||b){
        ans=a[0];
    }
    else ans-=a[0];
    rep(i,n-1){
        ans+=a[i+1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000
#define VMAX 10000

int main() {
    int *A, *B;
    int C[VMAX+1];
    int n,i,j;
    
    scanf("%d",&n);
    
    A = malloc(sizeof(int)*n+1);
    B = malloc(sizeof(int)*n+1);
    
    for(i=0; i<=VMAX; i++) C[i]=0;
    
    for(i=0; i<n; i++) {
        scanf("%d",&A[i+1]);
        C[A[i+1]]++;
    }
    
    for(i=1; i<=VMAX; i++) C[i] = C[i]+C[i-1];
    
    for(j=1; j<=n; j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for(i=1; i<=n; i++){
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 16276
#include <iostream>
#include <map>
using namespace std;
map<int,int>Num;
map<int,int>::iterator It;
int N;
int Ans;
int main()
{
	int I,J,K;
	for(cin>>N,I=1;I<=N;I++)
	{
		cin>>J;
		Num[J]++;
	}
	int Length=Num.size();
	for(I=1;I<=Length;I++)
	{
		It=Num.begin();
		if(Num[It->first]>It->first)
			Ans+=Num[It->first]-It->first;
		else if(Num[It->first]<It->first)
			Ans+=Num[It->first];
		Num.erase(It->first);
	}
	cout<<Ans;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h> 
#define ll long long int 
using namespace std; 
  
int main() 
{  
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL);  
    int a,b; 
    cin>>a>>b; 
    cout<<(2*b)-a<<endl;
    return 0; 
} 


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

#define ll long long
#define endl "\n"
#define int ll

signed main ()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int x;
	cin >> x;

	if (x < 600) cout << 8 << endl;
	else if (x < 800) cout << 7 << endl;
	else if (x < 1000) cout << 6 << endl;
	else if (x < 1200) cout << 5 << endl;
	else if (x < 1400) cout << 4 << endl;
	else if (x < 1600) cout << 3 << endl;
	else if (x < 1800) cout << 2 << endl;
	else cout << 1 << endl;

	return 0;

}


Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x, (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll a;
	cin >> a;
	string b;
	cin >> b;
	a*=100*(b[0]-'0')+10*(b[2]-'0')+(b[3]-'0');
	cout << a/100 << endl;
}


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

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int n = s.size();
    int m = t.size();
    int dp[n+1][m+1];
    for(int i = 0;i<=n ;i++){
        for(int j = 0;j<=m;j++){
            if(i==0 || j==0)dp[i][j] = 0;
            else if(s[i-1]==t[j-1])dp[i][j] = 1 + dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int length = dp[n][m];
    string res;
    int a,b;
    a = n;
    b = m;
    while(a>0 && b>0){
        if(s[a-1]==t[b-1]){
            res = s[a-1]+res;
            a = a - 1;
            b = b - 1;
        }
        else if(dp[a-1][b]>dp[a][b-1]){
            a = a - 1;
        }
        else{
            b = b - 1;
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
typedef long double LD;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define REP(i,n) for (ll i = 0; i < n; i++)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REPD(i,n) for (ll i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (ll i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type,vector<type>,greater<type> >
#define ITR :: iterator it
#define WL(t) while(t--)
#define SZ(x) ((int)(x).size())
#define TR(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))
#define i1(x) cin>>x
#define i2(x,n) cin>>x>>n
#define o1(x) cout<<x
#define o2(x,n) cout<<x<<n
int main(){
    ll x;
    i1(x);
    ll temp=x/500;
    x-=(temp*500);
    o1(temp*1000+((x/5)*5));
}

Measured memory_bytes: 256
interface Main{
	static void main(String[]$){
		var a=new java.util.Scanner(System.in).next().toCharArray();
		long l=a.length;
		var x=new long[26];
		for(char c:a)x[c-'a']++;
		System.out.println(2+l*l-java.util.stream.LongStream.of(x).map(e->e*e).sum()>>1);
	}
}

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

int main(void){
    string S; cin >> S;
    map<string, int> toHoliday;
    toHoliday["SUN"] = 7;
    toHoliday["MON"] = 6;
    toHoliday["TUE"] = 5;
    toHoliday["WED"] = 4;
    toHoliday["THU"] = 3;
    toHoliday["FRI"] = 2;
    toHoliday["SAT"] = 1;

    cout << toHoliday[S] << endl;
  	
  	return 0;
}

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

string divide[4] = { "dream", "dreamer", "erase", "eraser" };

int main() {
	string S;
	cin >> S;
	
	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
	
	bool can = true;
	for (int i = 0; i < S.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; ++j) {
			string d = divide[j];
			if (S.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
              	break;
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}
	
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


int f(char c1, char c2){
	if(c1=='(' && c2==')') return 1;
	if(c1==')' && c2=='(') return 1;
	if(c1=='[' && c2==']') return 1;
	if(c1==']' && c2=='[') return 1;
	if(c1=='{' && c2=='}') return 1;
	if(c1=='}' && c2=='{') return 1;
	return 0;
}

bool solve(){
	string str;
	cin>> str;
	
	string str1, str2;
	for(int i=0;i<str.size();i++){
		if(str[i] == 'i'){
			str1 = str.substr(0,i);
			str2 = str.substr(i+3);
			break;
		}
	}
//	cout<< str<< endl;
//	cout<< str1<< endl;
//	cout<< str2<< endl;
	reverse(str2.begin(), str2.end());
//	cout<< str2<< endl;
	
	int n = str1.size();
	int m = str2.size();
	vector<vector<int> > ans(n+1, vector<int>(m+1, 0));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ans[i+1][j+1] = max(ans[i+1][j], ans[i][j+1]);
			if(f(str1[i],str2[j])) ans[i+1][j+1] = max(ans[i+1][j+1], ans[i][j] + 1);
//			cout<< ans[i+1][j+1]<< " ";
		}
//		cout<<endl;
	}
	
	cout<< 2 * ans[n][m] + 3<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e9;

int main(){
    long long int n, a, b;
    cin >> n >> a >> b;

    vector<long long int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }

    long long int upper = INF, lower = -1, mid;
    while(upper - lower > 1){
        mid = (upper + lower) / 2;
        long long int count = 0;
        for(int i=0; i<n; i++){
            if(h[i] > b * mid){
                count += ((h[i] - b * mid) + (a-b-1)) / (a-b);
            }
        }
        if(count <= mid) upper = mid;
        if(count >  mid) lower = mid;
    }
    cout << upper << endl;
    return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k < a) {
        cout << k << endl;
    }else if(k <= a + b){
        cout << a << endl;
    }else if(a + b < k){
        cout << a - (k - (a + b)) << endl;
    }
}


Measured memory_bytes: 3632
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
using ll = int64_t; using ull = uint64_t; using ld = long double;

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

const int N = 3e5 + 5;
int n, a[N];

int main() {
    cin >> n; n *= 3;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += a[n - 2];
        n -= 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int n = in.nextInt();
    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[n - i - 1] = in.nextInt();
    }
    System.out.print(a[0]);
    for (int i = 1; i < n; i++) {
      System.out.print(" " + a[i]);
    }
    System.out.println();
  }
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;

    int n, ans = 0;
    cin >> n;

    vector<P> r(n), b(n);
    vector<int> used(n, false);
    rep(i, n) cin >> r[i].first >> r[i].second;
    rep(i, n) cin >> b[i].first >> b[i].second;
    sort(r.begin(), r.end());
    sort(b.begin(), b.end());

    rep(i, n) {
        int m1 = -1, m2 = -1;
        rep(j, n) {
            if (b[i].first < r[j].first) break;
            if (b[i].second >= r[j].second && m2 < r[j].second && !used[j]) {
                m1 = j;
                m2 = r[j].second;
            }
        }
        if (m1 != -1) {
            ans++;
            used[m1] = true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
string s;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>s;
    s[0]='2';
    s[1]='0';s[2]='1';s[3]='8';

    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 256
#single source shotest path 2

from heapq import heappush, heappop

n = int(input())
a = [None]*n
for i in range(n):
    u, k, *V = map(int, input().split())
    a[i] = [(p, q) for p, q in zip(V[::2], V[1::2])]

dist = [10**6]*n
dist[0] = 0
que = []
heappush(que,(0,0))

while que:
    cost, v = heappop(que)
    for w, c in a[v]:
        if cost + c < dist[w]:
            dist[w] = r = cost + c
            heappush(que, (r,w))
            
for i in range(n):
    print(f"{i} {dist[i]}")


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  ll k;
  cin >> s >> k;
  rep(i,sz(s)) {
    if(s[i] != '1') {
      if(k < i+1) continue;
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

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

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

    vector<int> vecNum(n);
    for(int i=0; i<n; i++) cin >> vecNum.at(i);

    int ans = 0;
    for(int i=1; i<n-1; i++){
        if(((vecNum[i-1] < vecNum[i]) && (vecNum[i] < vecNum[i+1])) || ((vecNum[i-1] > vecNum[i]) && (vecNum[i] > vecNum[i+1])))
            ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define SIZE 200010

typedef struct _Edge {
    int to, next;
} Edge;

Edge edge[SIZE << 1];
int head[SIZE], edgePt, vertexNum;
int deg[SIZE];

pair<int, int> dp[SIZE];
int maxLen, num;

void addEdge(int from, int to) {
    edge[edgePt] = {to, head[from]};
    head[from] = edgePt++;
}

void dfs(int cntPt, int fatherPt) {
    dp[cntPt].first = 0;
    dp[cntPt].second = 1;

    for (int i = head[cntPt]; i != -1; i = edge[i].next) {
        int nextPt = edge[i].to;
        if (nextPt == fatherPt)
            continue;
        dfs(nextPt, cntPt);

        int cntLen = dp[nextPt].first + 1;
        if (cntLen + dp[cntPt].first > maxLen) {
            maxLen = cntLen + dp[cntPt].first;
            num = dp[cntPt].second * dp[nextPt].second;
        } else if (cntLen + dp[cntPt].first == maxLen) {
            num += dp[cntPt].second * dp[nextPt].second;
        }

        if (cntLen > dp[cntPt].first) {
            dp[cntPt].first = cntLen;
            dp[cntPt].second = dp[nextPt].second;
        } else if (cntLen == dp[cntPt].first) {
            dp[cntPt].second += dp[nextPt].second;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    memset(head, -1, sizeof(head));
    memset(deg, 0, sizeof(deg));
    edgePt = 0;
    cin >> vertexNum; int maxDeg = 0;
    for (int i = 1; i < vertexNum; i++) {
        int from, to;
        cin >> from >> to;
        from--; to--;
        addEdge(from, to);
        addEdge(to, from);
        deg[from]++; deg[to]++;
        maxDeg = max(maxDeg, max(deg[from], deg[to]));
    }

    maxLen = 0, num = 0;
    dfs(0, -1); maxLen++;
    int ans = (maxLen % 3 != 2);
    cout << (ans ? "First\n" : "Second\n");
    return 0;
}


Measured memory_bytes: 15488
/*BY-ADITYA OJHA
  LEARN DSA SINCERELY*/
#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define fas1  ios_base::sync_with_stdio(false)
#define fas2   cin.tie(NULL)
using namespace std;


int main()
{
     fas1;
     fas2;
     ll n;
     cin>>n;
     if(n%2==0)cout<<n/2<<endl;
     else
        cout<<n/2 + 1<<endl;
     return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <map>


using namespace std;


int main()
{
  long n , b;
  cin >> n ;//１万から99999
  vector<long> a(n);
  priority_queue <long> p;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p.push(a[i]);
  }

  long al=0,bl=0;
  for (int i = 0; i < n; i++) {
    if (i%2==0)al+=p.top();
    if (i%2==1)bl+=p.top();
    p.pop();
  }


  cout << al-bl << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[105][4][2];

int main(){
  string n;
  int K;
  cin >> n >> K;
  int digit = n.size();
  dp[0][0][0] = 1;
  for(int i=0;i<digit;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<2;k++){
        int nd=n[i]-'0';
        for(int d=0;d<10;d++){
          int ni=i+1,nj=j,nk=k;
          if(d!=0) nj++;
          if(nj>K) continue;
          if(k==0){
            if(d>nd) continue;
            if(d<nd) nk=1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[digit][K][1]+dp[digit][K][0] << endl;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print("APPROVED")
else:
    print("DENIED")
            
    



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
using namespace std;
int mx=3234566667;
set<int> s;
vector<int> ans;
void Onigiri()
{
  int k;
  cin>>k;
  rep(i,1,10)
  s.insert(i);
  while(true)
  {
    int x=*s.begin();
    ans.push_back(x);
    if(x==mx)break;
    s.erase(s.begin());
    if(x%10!=9)s.insert(x*10+x%10+1);
    s.insert(x*10+x%10);
    if(x%10!=0)s.insert(x*10+x%10-1);
  }
  cout<<ans[k-1];
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
  
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 9972
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>


#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define prd(t) printf("%d",t)
#define prld(t) printf("%ld",t)
#define prlld(t) printf("%lld",t)
#define prc(t) printf("%c",t)
#define prs(t) printf("%s",t)
#define prf(t) printf("%f",t)
#define prsp() printf(" ")
#define prnl() printf("\n")
#define MOD 1000000007
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define fo(i,a,b) for(int i=a;i<b;i++)


void solve(){
	int k;
	scd(k);
	int a,b;
	scd(a); scd(b);
	int flag=1;
	/*for(int i=a;i<=b;i++){
		if(i%k==0){
			printf("OK");
			flag=0;
			break;
		}
	}*/
	int x=a/k;
	int y=(x+1)*k;
	if((y>a&&y<=b)||(x*k==a)) printf("OK");
	else  printf("NG");
}


int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	//int t; scd(t);
	//while(t--){
		solve();
		//prnl();
	//}
	return 0;
}

Measured memory_bytes: 1696
x = int(input())
if x == 1:
    print(1)
    exit()
l = []
l.append(1)
for i in range(2, x+1):
    j = 2
    while i**j <= x:
        l.append(i**j)
        j += 1
#print(l)
l.sort()
print(l[-1])

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

int n, ans = 0;
pair<int, int> r[100], b[100];
vector<int> q;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		r[i] = make_pair(x, y);
	}
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		b[i] = make_pair(x, y);
	}
	sort(r, r + n);
	sort(b, b + n);
	int k = 0;
	for (int i = 0; i < n; i++) {
		while (k < n && r[k].first < b[i].first) {
			q.push_back(r[k].second);
			k++;
		}
		sort(q.begin(), q.end(), greater<int>());
		if (!q.size() || *(q.end() - 1) >= b[i].second)
			continue;
		ans++;
		for (auto it = q.begin(); it != q.end(); it++)
			if (*it < b[i].second) {
				q.erase(it);
				break;
			}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*; 
import java.io.*; 


public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(), m = scan.nextInt();
        int[] num = new int[n];
        boolean[] found = new boolean[n];
   
        for (int i = 0; i < m; i ++){
            int a = scan.nextInt(), b = scan.nextInt();
            if (found[a - 1]){
                if (num[a - 1] != b){
                    System.out.println("-1");
                    return;
                }
            }
            else{
                found[a - 1] = true;
                num[a - 1] = b;
            }
        }
        if (num[0] == 0 && n != 1 && found[0]){
            System.out.println("-1");
            return;
        }
        if (num[0] == 0 && n != 1){
            num[0] = 1;
        }
        for (int i : num)
            System.out.print(i);
        

    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

struct mintcomb{
    vector<mint> fact;
    vector<mint> ifact;
    mintcomb(ll n) : fact(n + 1, 1), ifact(n + 1, 1) {
        for(ll i = 2; i <= n; ++i){
            fact.at(i) = fact.at(i - 1) * i;
            ifact.at(i) = fact.at(i).inv();
        }
    }

    mint factorial(ll k) const { return fact.at(k); }
    mint combination(ll k, ll l) const {
        return fact.at(k) * ifact.at(l) * ifact.at(k - l);
    }
};


int main(){
    ll k;
    cin >> k;
    string s;
    cin >> s;
    const ll n = s.size();
    mint total = 0;
    mintcomb mc(k + n);
    REP(i, k + 1){
        total += mc.combination(i + n - 1, n - 1) * mint(25).pow(i) * mint(26).pow(k - i);
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 35556
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans=0
    integer(int64), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    do i=2,n
        ans=ans+max(a(i-1)-a(i),0_8)
        a(i)=max(a(i-1), a(i))
    end do

    print'(i0)', ans
end program main

Measured memory_bytes: 4800
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
B=[[A[i][1],A[i][0]] for i in range(n)]
A.sort()
B.sort(reverse=True)
if n%2==1:
  print(B[(n-1)//2][0]-A[(n-1)//2][0]+1)
else:
  print((B[n//2][0]+B[n//2-1][0])-(A[n//2][0]+A[n//2-1][0])+1)

Measured memory_bytes: 128672
import math

def resolve():
    import sys
    input = sys.stdin.readline
    
    H, N = map(int, input().split())
    v = []
    w = []
    for i in range(N):
        a, b = map(int, input().split())
        v.append(a)
        w.append(b)

    dp = [[0]*H for _ in range(N)]

    # initiate
    for i in range(H):
        dp[0][i] = w[0] * (math.ceil((i + 1) / v[0])) # 魔法1だけでHまで削るのに必要なコスト(MP)

    for i in range(1, N):
        for j in range(H):
            if j+1 < v[i]: 
                # 敵のHPが魔法iで与えるダメージより小さい場合、そのままの組み合わせか新しい魔法1回とで、コストの少ない方を選ぶ
                dp[i][j] = min(dp[i-1][j], w[i])
            else:
                # 大きい場合、そのままの組み合わせと、魔法iを取り込んだ組み合わせで、コストの少ない方を選ぶ
                dp[i][j] = min(dp[i-1][j], dp[i][j - v[i]] + w[i])

    print(dp[N-1][H-1])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 277000
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    int ac = 0, wa = 0;
    map<int, int> f, f1;
    while(m--)
    {
        int p;
        string s;
        cin >> p >> s;
        if(!f[p])
        {
            if(s=="AC") f[p] = 1;
            else f1[p]++;
        }
    }
    for(auto i:f){
        if(i.second){
            ac++;
            wa += f1[i.first];
        }
    }
    cout << ac << ' ' << wa;
    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

struct edge {ll from,to,cost;};

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

    ll ans = 1;

    for(ll i = 1; i * i <= m; i++){
        ll div = i;
        if(m % i == 0){
            if(m >= div * n && ans < div){
                ans = div;
            }
            div = m/i;
            if(m >= div * n && ans < div){
                ans = div;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
d,g = gets.split.map(&:to_i)
ps = []
d.times do
  ps << gets.split.map(&:to_i)
end

h = {}
ps.each.with_index(1) do |p,i|
  h[i] ||= []
  (1..p[0]).each do |j|
    if j == p[0]
      h[i] << i * j * 100 + p[1]
    else
      h[i] << i * j * 100
    end
  end
end

total = ps.reduce(0) do |a,e|
  a += e[0]
end

dp = {}

(1..d).each do |i|
  dp[i] ||= {}
  (0...total).each do |j|
    size = h[i].size - 1
    if i == 1
      if size < j
        dp[i][j] = dp[i][j-1]
      else
        dp[i][j] = h[i][j]
      end
    else
      if size < j
        dp[i][j] = [h[i][size] + dp[i-1][j - size -1], dp[i][j-1], dp[i-1][j]].max
      else
        dp[i][j] = [h[i][j], dp[i-1][j]].max
      end
    end
  end
end

(0..total).each do |i|
  if dp[d][i] >= g
    puts i+1
    exit
  end
end


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

int main(){
    int A, B;
    cin >> A >> B;
    char space[100][99];
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 99; j++){
            space[i][j] = '#';
        }
    }
    for(int i = 50; i < 100; i++){
        for(int j = 0; j < 99; j++){
            space[i][j] = '.';
        }
    }
    A--;
    B--;
    for(int i = 0; A; i += 2){
        for(int j = 0; A && j < 99; j += 2, A--){
            space[i][j] = '.';
        }
    }
    for(int i = 99; B; i -= 2){
        for(int j = 0; B && j < 99; j += 2, B--){
            space[i][j] = '#';
        }
    }
    cout << "100 99" << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 99; j++){
            cout << space[i][j];
        }
        cout << endl;
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int K, S; cin >> K >> S;

    ll ans = 0;
    F0R(X, K+1) {
        F0R(Y, K+1) {
            if (X+Y > S) break;
            if (S-X-Y > K) continue;
            ans++;
        }
    }

    cout << ans << "\n";

}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define int long long
#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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


bool dfs(string s){
    if(s == "ABC") return true;
    else if(s.find("ABC") == string::npos) return false;
    vector<bool> valid(3, true);
    
    string t;
    int i = 0;
    while(i < s.size()){
        if(i <= (int)s.size() - 3 && s.substr(i, 3) == "ABC"){
            i += 3;
        }else{
            t += s[i];
            i++;
        }
    }
    REP(i, t.size()) valid[t[i] - 'A'] = false;
    
    bool ret = false;
    REP(k, 3){
        if(!valid[k]) continue;
        string t;
        int i = 0;
        while(i < s.size()){
            if(i <= (int)s.size() - 3 && s.substr(i, 3) == "ABC"){
                t += 'A' + k;
                i += 3;
            }else{
                t += s[i];
                i++;
            }
        }
        ret |= dfs(t);
    }
     
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; 
    cin >> s;
    cout << (dfs(s) ? "Yes":"No") << endl; 
}



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

int main(){
	int n,a[200010],i,j,flag=0,cnt=0,t;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	for(i=1;i<n;i++){
	scanf("%d",&a[i]);
	if(a[i]<=a[i-1])cnt++;
	else{
		t=a[i];
		a[i]=a[i-1];
		a[i-1]=t;
	}
	} 

	printf("%d",cnt+1);
	
}

Measured memory_bytes: 1024
N = int(input())
A = sorted(list(map(int,input().split())))
S = [0]*(N+1)
for k in range(1,N+1):
    S[k] = A[k-1] + S[k-1]
S.append(0)
ans = 0
for k in range(1,N+1):
    if S[k]*2 >= S[k+1]-S[k]:
        ans += 1
    else:
        ans = 0
print(ans)


Measured memory_bytes: 14636
#include <stdio.h>

int main(void){
    int N,i,X,m[1000],S=0,min=1000;
    scanf("%d %d",&N,&X);
    for(i=0;i<N;i++){
        scanf("%d",&m[i]);
        S+=m[i];
    }

    for(i=0;i<N;i++){
        if(min>m[i]){
            min=m[i];
        }
    }
    
    X-=S;
    X/=min;
    X+=N;

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

    return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL A, B;
	cin >> A >> B;

	if (B % A == 0) {
		cout << A + B << endl;
	}
	else {
		cout << B - A << endl;
	}


	return 0;
}


Measured memory_bytes: 256
def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j] = min(edges[i][j],edges[i][k]+edges[k][j])
  return edges

N,M=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(M)]
A=[[float("inf") for j in range(N)] for i in range(N)]#最短距離map
for i in range(N):
  A[i][i]=0
for i in range(M):
  A[abc[i][0]-1][abc[i][1]-1]=abc[i][2]
  A[abc[i][1]-1][abc[i][0]-1]=abc[i][2]
dist = Warshall_Floyd(A,N)
ans = 0
for j in range(M):
  u = abc[j][0] - 1
  v = abc[j][1] - 1
  for s in range(N):
    if dist[s][u] + abc[j][2] == dist[s][v]:
      ans += 1
      break
print(M - ans)

Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=105;
const int mod=998244353;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
map<string,int> f,g;
char getand(int u,int v){return (u&v)+'0';}
int getf(string now);
int getg(string now)
{
	if(g.find(now)!=g.end())return g[now];
	int len=now.length();int ret=0;
	if(len==1)return now[0]-'0'+1;
	string temp;
	for(int i=1;i<len;i++)if(!(len%i))
	{
		temp.clear();for(int j=0;j<i;j++)temp+=now[j];
		for(int begin=i;begin<len;begin+=i)for(int x=0;x<i;x++)temp[x]=getand(temp[x]-'0',now[begin+x]-'0');
		ad(ret,getf(temp));
	}return g[now]=ret;
}
int bin[MAXN];
int geto(string now)
{
	int ret=0;int len=now.length();
	for(int i=0;i<len;i++)ret+=now[i]-'0';
	return ret;
}
int getf(string now)
{
	if(f.find(now)!=f.end())return f[now];
	int len=now.length();if(len==1)return now[0]-'0'+1;
	int ret=0;
//	for(int i=0,sum=0;i<len;i++)
//	{
//		for(int j=i+1;j<len;j++)
//		{
//			if(j+1<len)ad(ret,1LL*getg(now.substr(i,j-i+1))*getf(now.substr(j+1))%mod*bin[sum]%mod);
//			else ad(ret,1LL*getg(now.substr(i,j-i+1))*bin[sum]%mod);
//		}sum+=now[i]-'0';
//	}return f[now]=ret;
	for(int i=0,sum=0;i<len-1;i++)
	{
		if(i)ad(ret,1LL*getg(now.substr(i))*getf(now.substr(0,i))%mod);
		else ad(ret,getg(now.substr(i)));
	}
	if(len!=1)ad(ret,getf(now.substr(0,len-1))*(now[len-1]-'0'+1)%mod);
	return f[now]=ret;
}
string ans;
int main()
{
	bin[0]=1;for(int i=1;i<MAXN;i++)bin[i]=(bin[i-1]<<1)%mod;
	cin>>ans;
	pr2(getf(ans));
	return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define ll long
// #define LOCAL

vector<ll> v;

void getDivisor(ll n) {

	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			v.push_back(i);
			if (i != n / i) {
				v.push_back(n / i);
			}
		}
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
}

int main() {
	ll n, m; scanf("%ld %ld", &n, &m);

	getDivisor(m);

#ifdef LOCAL
	auto tt = v.begin();
	while (true) {
		printf("%ld\n", *tt);
		tt++;
		if (tt == v.end()) break;
	}
#endif

	vector<ll>::iterator it = v.begin();
	while (!v.empty()) {
		if (m / *it >= n) {
			break;
		}
		it++;
	}

	printf("%ld", *it);
	return 0;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 200010
using namespace std;

int a[N],n;

int main()
{
	scanf("%d",&n); ll ans=0; int i;
	for(i=1;i<=n;i++)	scanf("%d",&a[i]); a[0]=-1;
	for(i=1;i<=n;i++)
	{
		if(a[i]>a[i-1]+1)	break;
		if(a[i]>=a[i+1])	ans+=a[i];	
	}
	if(i<=n)	return printf("-1\n"),0;
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=c-a,y=d-b;
  for(int i=0;i<x;i++)cout<<'R';
  for(int i=0;i<y;i++)cout<<'U';
  for(int i=0;i<x;i++)cout<<'L';
  for(int i=0;i<y;i++)cout<<'D';
  cout<<'D';
  for(int i=0;i<x+1;i++)cout<<'R';
  for(int i=0;i<y+1;i++)cout<<'U';
  cout<<"LU";
  for(int i=0;i<x+1;i++)cout<<'L';
  for(int i=0;i<y+1;i++)cout<<'D';
  cout<<"R\n";
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n;
  vector<ll> cnt(100010, 0);
  ll ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
    ans += a;
  }
  cin >> q;
  rep(_, q) {
    int b, c;
    cin >> b >> c;
    ans -= b * cnt[b];
    ans += c * cnt[b];
    cout << ans << '\n';
    cnt[c] += cnt[b];
    cnt[b] = 0;
  }
  return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a,b;
    cin>>a;
    char  k;
    cin>>k;
    cin>>b;
    if(k == '+')
    {
        cout<< a + b;
    }
    else
    {
        cout<< a - b;
    }
    return 0;
}


Measured memory_bytes: 256
//B - Training Camp: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll fat(int n) {
    if(n == 1) return 1;
    ll a = ((n % MOD) * (fat(n-1) % MOD)) % MOD;
    return a;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll ans;
    cin >> n;
    ans = fat(n);
    cout << ans << "\n";
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec_a(M);
  vector<int> vec_b(M);
  //道路の取得
  for (int i = 0; i < M; i++) {
    cin >> vec_a.at(i) >> vec_b.at(i);
  }

  //都市ごとの計算
  for (int j = 0; j < N; j++) {
    int count = 0;
    for (int k = 0; k < M; k++) {
      if (vec_a.at(k) == j + 1) {
        count++;
      }
      if (vec_b.at(k) == j + 1) {
        count++;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256