akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 998244353LL
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;

void solve() 
{
    ll k;
    cin>>k;

    ll a[55];

    for(ll i=0;i<50;i++)
        a[i]=i;
 
    ll d=k/50;
    if(k%50==0)
    {
        for(ll i=0;i<50;i++)
            a[i]+=d;
    }
    else
    {
        for(ll i=0;i<50;i++)
            a[i]+=d;
        k%=50;
        ll p=0;
        while(k)
        {
            k--;
            a[p]+=50;
            for(ll i=0;i<50;i++)
                if(i!=p)
                    a[i]--;
            p++;
        }
    }
 
    cout<<50<<endl;
    for(ll i=0;i<50;i++)
        cout<<a[i]<<" ";
    cout<<endl;


}

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3776
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

void dfs(char c,ll N,string S){
    if(N==0){cout<<S<<endl;return;}
    else for(char i='a';i<=c;i++){
        if(i==c)dfs(c+1,N-1,S+i);
        else dfs(c,N-1,S+i);
    }
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    dfs('a',N,"");fl

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 3e3 + 5;
int dp[MAX][MAX];
int main()
{
	boost;
	int n, m;
	string s, t;
	cin >> s;
	cin >> t;
	n = s.length();
	m = t.length();
	
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {
			if(i * j == 0) dp[i][j] = 0;
			else if(s[i - 1] == t[j - 1])
			dp[i][j] = dp[i - 1][j - 1] + 1;
			else
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	string ans = "";
	int i = n, j = m;
	while(i > 0 && j > 0) {
		if(s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			--i, --j;
		}
		else if(dp[i - 1][j] > dp[i][j - 1])
		--i;
		else
		--j;
	}
	reverse(all(ans));
	cout << ans;
}

Measured memory_bytes: 35456
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a == 5){
      if(b == 5){
        if(c == 7){
          System.out.println("YES");
        }
        else{
          System.out.println("NO");
        }
      }
      else if(b == 7){
        if(c == 5){
          System.out.println("YES");
        }
        else{
          System.out.println("NO");
        }
      }
      else{
        System.out.println("NO");
      }
    }
    else if(a == 7){
      if(b == 5){
        if(c == 5){
          System.out.println("YES");
        }
        else{
          System.out.println("NO");
        }
      }
      else{
        System.out.println("NO");
      }
    }
    else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23252
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        
        int total = 0;
        if( A + B > C * 2 ) {
            int Z = Math.min( X, Y );
            X -= Z;
            Y -= Z;
            total += Z * 2 * C;
        }
        
        if( X > 0 ) {
            int AA = Math.min( A, 2*C );
            total += AA * X;
        }
        
        if( Y > 0 ) {
            int BB = Math.min( B, 2*C );
            total += BB * Y;
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 35812
#include <cstdio> 
#include <cstring>
const int N = 200007;
char str[N];
int main()
{
	while(~scanf("%s", str)) {
		int len = strlen(str), cnt[128] = { 0};
		for (int i = 0; i < len; ++i) {
			cnt[str[i]]++;
		} 
		long long res = 1 + (long long)len * (len - 1) / 2;
		for (char i = 'a'; i <= 'z'; ++i) {
			res -= cnt[i] * (long long)(cnt[i] - 1) / 2; 
		}
		printf("%lld\n", res);
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  clock_t start = clock();

  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N - 1));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N - 1; j++)
    {
      int a;
      scanf("%d", &a);
      A.at(i).at(j) = a - 1;
    }
  }

  vector<int> B(N, 0);
  for (int ans = 1;; ans++)
  {
    if (clock() / 1000 >= 1900)
      FINALANS(N * (N - 1) / 2);
    
    vector<bool> visited(N, false);
    bool ng = true;
    for (int i = 0; i < N; i++)
    {
      if (visited.at(i))
        continue;
      if (B.at(i) == N - 1)
        continue;
      
      int x = A.at(i).at(B.at(i));

      if (visited.at(x))
        continue;
      if (B.at(x) == N - 1)
        continue;
      
      int y = A.at(x).at(B.at(x));

      if (i == y)
      {
        B.at(i)++;
        B.at(x)++;
        visited.at(i) = true;
        visited.at(x) = true;
        ng = false;
      }
    }

    if (ng)
      FINALANS(-1);

    bool ok = true;
    for (int i = 0; i < N; i++)
    {
      if (B.at(i) < N - 1)
      {
        ok = false;
        break;
      }
    }
    if (ok)
      FINALANS(ans);
  }
}

Measured memory_bytes: 4224
n,m,l=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
b=[]
for i in range(m):
    b.append(list(map(int,input().split())))
c=[[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j]+=a[i][k]*b[k][j]
    print(*c[i])


Measured memory_bytes: 7052
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


A,B,C,D = map(int,input().rstrip().split(' '))
x = (B // C) - ((A-1) // C)
y =  (B // D) - ((A-1) // D)
E = (C * D) // gcd(C,D)
z = (B // E) - ((A-1) // E)
print((B-A+1)-(x+y-z))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   make_pair 
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
vll v(100000,0);

ll sum = 0;
int md(int n){
	if(n>0)return n;
	else return -n;
}

string str,str2;
void solve(){
	cin>>str;
	ll ans=0;
	if(str[0]=='R')ans++;
	if(str[1]=='R')ans++;
	if(str[2]=='R')ans++;
	if(ans==0||ans==1||ans==3){
	    cout<<ans;return;
	}
	if(str[1]=='R')cout<<2;
	else cout<<1;
}


int main(){

 
    	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
		
	}
	
	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int ans = 0,l = 0;
	string pre = "";
	rep(i,s.size()){
		if(s.substr(l,i - l + 1) != pre){
			pre = s.substr(l,i - l + 1);
			ans++;
			l = i + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}


int main(void) {
	int N,i,j;
	scanf("%d", &N);
	int n, k,distance;
	int house[100000];
	for (i = 0; i < N; i++) {
		scanf("%d %d", &n, &k);
		for (j = 0; j < n; j++) {
			scanf("%d", &house[j]);
		}
		distance = house[n - 1] - house[0];
		for (j = 0; j < n - 1; j++) {
			house[j] = house[j + 1] - house[j];
			
		}
		qsort(house, n - 1, sizeof(int), compare_int);
		for (j = 0; j < k-1; j++) {
			distance -= house[n - 2 - j];
		}
		if (n <= k)distance = 0;
		printf("%d\n", distance);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

const ll INF = 100000000000000;

typedef pair<ll, pair<ll, ll>> P;

ll n;
ll a[300][300];
ll d[300][300];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) REP(j, n) cin >> a[i][j];
	REP(i, n) REP(j, n) d[i][j] = (i == j ? 0 : INF);
	priority_queue<P, vector<P>, greater<P>> q;
	REP(i, n) FOR(j, i + 1, n) q.push(MP(a[i][j], MP(i, j)));
	ll res = 0;
	while (!q.empty()) {
		auto t = q.top(); q.pop();
		ll c = t.first, x = t.second.first, y = t.second.second;
		if (d[x][y] < c) {
			cout << -1 << endl;
			return 0;
		}
		if (d[x][y] == c) {
			continue;
		}
		d[x][y] = d[y][x] = c;
		res += c;
		REP(i, n) REP(j, n) d[i][j] = min(d[i][j], min(d[i][x] + d[x][y] + d[y][j], d[i][y] + d[y][x] + d[x][j]));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3320
n,d = map(int,input().split())

x = []

ans = 0

for i in range(n):
    x.append(list(map(int,input().split())))
    
def dis(a,b):
    t = 0
    for i in range(len(a)):
        t += (a[i]-b[i])**2
        
    if int(t**0.5)==t**0.5:
        return 1
    else:
        return 0
        
for i in range(len(x)):
    for s in range(i+1,len(x)):
        ans += dis(x[i],x[s])
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    vector<vector<int>> dis(110,vector<int>(110,inf));
    map<pair<int,int>,int> mpi;
    int n,m; 
    cin >> n >> m;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        dis[a][b]=c;
        dis[b][a]=c;
        mpi[{a,b}] = c;
        mpi[{b,a}] = c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dis[i][j] = min(dis[i][k]+dis[k][j],dis[i][j]);
                if(i==j) dis[i][j]=0;
            }
        }
    }
    set<pair<int,int>> spi;
    rep(i,n){
        rep(j,n){
            for(auto u : mpi){
                if(dis[i][j] == dis[i][u.first.first]+dis[u.first.second][j] + u.second){
                    if(u.second!=0) spi.insert({u.first.first,u.first.second});
                }
            }
        }
    }
    cout << m - (int)spi.size()/2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;
 


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        a[tmp]++;
        if(i==0 && tmp!=0) {
            printf("0\n"); return 0;
        }
    }

    if(a[0]!=1) {
        printf("0\n"); return 0;
    }
    ll ans=1;
    for(i=1; i<n; i++) {
        int k;
        for(k=0; k<a[i]; k++) {
            if(a[i-1]==0) {
                printf("0\n"); return 0;
            }
            ans=ans*a[i-1]%MOD;
        }    
    }
    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 640
N = int(input())
h_list = list(map(int, input().split(' ')))

DP = {}
DP[1] = 0
DP[2] = abs(h_list[1] - h_list[0])

for k in range(3, N + 1):
    a1 = DP[k - 1] + abs(h_list[k - 2] - h_list[k - 1])
    a2 = DP[k - 2] + abs(h_list[k - 3] - h_list[k - 1])
    DP[k] = min(a1, a2)

print(DP[N])

Measured memory_bytes: 23188
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  char c;
  cin >> c;
  cout << (char)(c+1) << endl;
  return 0;
}

Measured memory_bytes: 256
N, K  = [int(n) for n in input().split()]
pn = [int(n) for n in input().split()]

cumsum = [0]
for n in range(1, N+1):
  cumsum.append(cumsum[n-1] + (pn[n-1] + 1)/2)

max_exp = 0
for n in range(K, N + 1):
  max_exp = max(max_exp, cumsum[n] - cumsum[n-K])
print(max_exp)


Measured memory_bytes: 25188
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.substring(0, s.length() - 1);
        int max = 0;
        for (int i = 1; i <= s.length() / 2; i++) {
            if (s.substring(0, i).equals(s.substring(i, 2 * i))) {
                max = i * 2;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  ll i;
  for(i=0;i<N;i++){
    cin >> A[i];
    B[i] = i;
  }
  sort(B.begin(), B.end(), [&](size_t i1, size_t i2){return A[i1] < A[i2];});
  for(i=0;i<N;i++){
    cout << B[i]+1 << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 2432
let bubble_sort ?(comparator=compare) a n =
  let rec loop () =
    let rec bubble c = function
      | 0 -> c
      | i ->
        bubble
          (match comparator a.(i) a.(i-1) with
           -1 -> (let aj = a.(i-1) in a.(i-1) <- a.(i); a.(i) <- aj; c+1)
           | _ -> c)
          (i-1)
    in
    match bubble 0 (n-1) with
      0 -> a
    | _ -> loop ()
  in loop ()

let selection_sort ?(comparator=compare) a n =
  let rec selection j acc =
    match j < n with
      true ->
      selection (j+1) (match comparator a.(j) a.(acc) with -1 -> j | _ -> acc)
    | false -> acc
  in
  let rec loop = function
      i when i = n -> a
    | i ->
      (match selection (i+1) i with
       | j when i != j -> let ai = a.(i) in a.(i) <- a.(j); a.(j) <- ai
       | _ -> ());
      loop (i+1)
  in
  loop 0

let () =
  let n = read_int () in
  let l = read_line () |> Str.split (Str.regexp " ")
          |> List.mapi (fun i x -> i,x) in
  let comp (_,a) (_,b) = compare a.[1] b.[1] in
  let is_stable = ref true in
  let print_array_b a =
    Array.iteri (fun i x ->
        Printf.printf
          (match i with i when i=n-1 -> "%s\nStable\n" | _ -> "%s ")
          (snd x))
      a in
  let print_array_s a =
    Array.iteri (fun i x ->
        Printf.printf
          (match i with
             i when i=n-1 ->
             (if !is_stable then "%s\nStable\n" else  "%s\nNot stable\n")
           | i ->
             (if (snd a.(i)).[1] = (snd a.(i+1)).[1] && fst a.(i) > fst a.(i+1)
              then is_stable := false);
             "%s ")
          (snd x))
      a in  
  print_array_b (bubble_sort ~comparator:comp (Array.of_list l) n);
  print_array_s (selection_sort ~comparator:comp (Array.of_list l) n)

Measured memory_bytes: 2164
def cmb(n, r, p):
    r = min(r, n - r)
    upper = 1
    for i in range(n, n - r, -1):
        upper = (upper * i) % p

    lower = 1
    for i in range(1, r + 1):
        lower = (lower * i) % p

    # フェルマーの小定理よりp素数ならupper**(p-2)は逆元
    return (upper * pow(lower, p - 2, p)) % p

mod = pow(10, 9) + 7
n, a, b = map(int, input().split())
ans = (pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod))%mod
print(ans)

Measured memory_bytes: 9008
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
    cin>>s;
    FOR(i,0,3){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy";
	}
	if (s == "Cloudy") {
		cout << "Rainy";
	}
	if (s == "Rainy") {
		cout << "Sunny";
	}

	//system("pause");
	return 0;
}

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

int main()
{
  int a;
  cin >> a;
  float sum = 0;
  for (int i = 0; i < a; i++)
  {
      float b;
      cin >> b;
      sum += 1/b;
  }
  cout << 1/sum;
  return 0;
}

Measured memory_bytes: 256
# 大混乱したので乱択

from random import randint
def main():
    import sys
    sys.setrecursionlimit(500000)
    N = int(input())
    if N==2:
        print(1)
        exit()
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        E[a].append(b)
        E[b].append(a)

    def dfs(v=0, p=-1, root=0):
        cnt_child = 0
        cnt_false = 0
        res = 0
        for u in E[v]:
            if u!=p:
                cnt_child += 1
                d = dfs(u, v, root)
                res += d
                cnt_false += d == 0
        return res + max(0, cnt_false - 1)

    #for i in range(N):
    #    print(dfs(i, -1, i))

    print(max(dfs(i, -1, i) for i in sorted(range(N), key=lambda x: -len(E[x]))[:5]))

main()


Measured memory_bytes: 131648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<ll> a(n);
  ll sum=0;
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
    sum^=a[i];
  }
  for (int i = 0; i < n; ++i)
  {
    cout<<(a[i] ^ sum)<<" ";
  }

}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll n;
    cin >> n;

    vector<ll> nums(n);
    rep(i, n) cin >> nums[i];

    ll avg = accumulate(all(nums), 0) / n;
    ll ans = INFL;
    repi(plus_val, -1, 2){
        ll mini_ans = 0;
        ll avg_cp = avg + plus_val;
        rep(i, n){
            mini_ans += (nums[i] - avg_cp) * (nums[i] - avg_cp);
        }

        ans = min(mini_ans, ans);
    }

    cout << ans << endl;
}

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

int main(void) {
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<bool>> RECT(H, vector<bool>(W, true));
  for (int i = 0; i < N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    for (int j = 0; j < H; ++j) {
      for (int k = 0; k < W; ++k) {
        bool cond = ((a == 1) && (k < x)) || ((a == 2) && (k >= x)) ||
                    ((a == 3) && (j < y)) || ((a == 4) && (j >= y));
        if (cond) RECT[j][k] = false;
      }
    }
  }

  int answer = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (RECT[i][j]) ++answer;
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main(){
  int n, m, b[100], a[100][100], c[100] = {};
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++){
    cout << c[i] << endl;
  }
}



Measured memory_bytes: 3112
#include <iostream>

using namespace std;
int n,t[200005],naj=0,naj2=0,szukane,wynik=0,wyniki[200005];
int main()
{
cin>>n;
for(int i=0;n>i;i++)
{
cin>>t[i];
}
 szukane=1;
for(int i=0;n>i;i++)
{
    wyniki[t[i]]=wyniki[t[i]-1]+1;
}
for(int i=1;n>=i;i++)
{
      wynik=max(wynik,wyniki[i]);
      wyniki[i]=0;
}
szukane =n;
for(int i=n-1;i>=0;i--)
{
    wyniki[t[i]]=wyniki[t[i]+1]+1;
}
for(int i=1;n>=i;i++)
{
      wynik=max(wynik,wyniki[i]);
}
cout<<n-wynik;
    return 0;
}


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

using namespace std; 

const int maxn = 1e5; 

int n; 
int r1, r2; 
int f1[maxn + 5], f2[maxn + 5], vis[maxn + 5]; 
vector <int> G1[maxn + 5], G2[maxn + 5]; 
int vis1[maxn + 5], vis2[maxn + 5]; 
int ans[maxn + 5], sta[maxn + 5], top; 

struct Edge {
    int v, nxt; 
} E[maxn * 4 + 5];

int h[maxn + 5], ecnt; 

void add(int u, int v) {
   // cout << u << ' ' << v << '\n'; 
    E[++ecnt].v = v; E[ecnt].nxt = h[u], h[u] = ecnt; 
    E[++ecnt].v = u; E[ecnt].nxt = h[v], h[v] = ecnt; 
}

void dfs1(int u) {
    int x = 0; 
    for (auto v : G1[u]) {
        dfs1(v); x++;  
    }
    if (!(x & 1)) {
        sta[++top] = u; 
        vis1[u] = 1; 
    }
    while (top >= 2) {
        add(sta[top], sta[top - 1]); 
        top -= 2; 
    }
}

void dfs2(int u) {
    int x = 0; 
    for (auto v : G2[u]) {
        dfs2(v); x++; 
    }
    if (!(x & 1)) {
        sta[++top] = u; 
        vis2[u] = 1; 
    }
    while (top >= 2) {
        add(sta[top], sta[top - 1]); 
        top -= 2; 
    }
}

int ppp = 0; 

void dfs(int u, int col) {
    if (ans[u] != -1) return ; 
    ppp ^= 1; 
    ans[u] = col; 
    for (int i = h[u]; i; i = E[i].nxt) {
        if (ans[E[i].v] == -1) {
            dfs(E[i].v, col ^ 1); 
        }
    }
}

int main() {
    memset(ans, -1, sizeof(ans)); 
    ecnt = 1; 
    scanf("%d", &n); 
    for (int i = 1; i <= n; i++) {
        scanf("%d", &f1[i]); 
        if (f1[i] == -1) {
            r1 = i; 
        }
        else {
            G1[f1[i]].push_back(i); 
        }
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &f2[i]); 
        if (f2[i] == -1) {
            r2 = i; 
        }
        else {
            G2[f2[i]].push_back(i); 
        }
    }
    dfs1(r1); top = 0; 
    dfs2(r2); 
    for (int i = 1; i <= n; i++) {
        if (vis1[i] != vis2[i]) {
            puts("IMPOSSIBLE"); 
            return 0; 
        }
    }
    puts("POSSIBLE"); 
    for (int i = 1; i <= n; i++) {
        if (vis1[i]) dfs(i, 0); 
    }
    for (int i = 1; i <= n; i++) {
        if (vis1[i]) {
            if (ans[i]) printf("1 "); 
            else printf("-1 "); 
        }
        else printf("0 "); 
    }
    cout << endl; 
    return 0; 
}



Measured memory_bytes: 19456
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    int x, y;
    cin >> x >> y;

    for (int i = 0; i < n; i++)
    {
        int xi;
        cin >> xi;
        x = max(x, xi);
    }

    for (int i = 0; i < m; i++)
    {
        int yi;
        cin >> yi;
        y = min(y, yi);
    }

    cout << (x < y ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int s_h,s_m,s_s,f_h,f_m,f_s,i,h,m,s;
  for(i=0;i<3;i++)
  {
    scanf("%d%d%d%d%d%d",&s_h,&s_m,&s_s,&f_h,&f_m,&f_s);
    h=f_h-s_h;
    m=f_m-s_m;
    if(m<0)
    {
      h--;
      m=60+m;
    }
    s=f_s-s_s;
    if(s<0)
    {
      m--;
      if(m<0){m=59;}
      s=60+s;
    }
    printf("%d %d %d\n",h,m,s);
  }
  return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int,int> 
#define int long long 


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
	int t=1;
//	cin>>t;
	while(t--){
		string n,w;
		cin>>n>>w;
		int **dp=new int*[n.size()+1];
		rep(i,n.size()+1){
			dp[i]=new int[w.size()+1];
		}
		rep(i,n.size()+1){
			rep(j,w.size()+1){
				dp[i][j]=0;
			}
		}
		REP(i,1,n.size()+1){
			REP(j,1,w.size()+1){
				if(n[i-1]==w[j-1]){
					dp[i][j]=1+dp[i-1][j-1];
				}
				else{
					if(dp[i-1][j]>dp[i][j-1]){
						dp[i][j]=dp[i-1][j];
					}
					else{
						dp[i][j]=dp[i][j-1];
					}
				}
			}
		}
		
		int i=n.size(),j=w.size();
		string out="";
			
		while(i>0&&j>0){
			if(n[i-1]==w[j-1]){
				out+=n[i-1];
				i--;
				j--;
			//	cout<<i<<" "<<j<<endl;
			//	cout<<out<<endl;
			}
			else{
				if(dp[i-1][j]>dp[i][j-1]){
					i--;
				}
				else{
					j--;
				}
			}
		}
		reverse(out.begin(),out.end());
		cout<<out<<endl;
	}
	//exit();
	return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    int a,b;
    cin>>a>>b;
    if(a<=8&&b<=8){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }


    return 0;
}


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

const string weather[3] = {"Sunny", "Cloudy", "Rainy"};

int main(){
    string s;
    int count = 0;
    cin >> s;
    for(int i = 0; i < 3; i++){
        if(s == weather[i]){
            count++;
            if(count > 2){
                count = 0;
            }
            break;
        }
        count++;
    }
    cout << weather[count];
    return 0;
}

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

// 插入此處

LL a[3005];

const LL M = 998244353;

LL dp[3005];

int main() {
    LL n, s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = s; j >= a[i]; j--) {
            dp[j] = dp[j] * 2 + dp[j - a[i]];
            dp[j] %= M;
        }
        for (int j = a[i] - 1; j >= 0; j--) {
            dp[j] = dp[j] * 2 % M;
        }
        // for (int j = 0; j <= s; j++) {
        //     printf("dp[%d] = %lld\n", j, dp[j]);
        // }
        // puts("");
    }
    cout << dp[s] << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
int MOD;
#define INF 0x3f3f3f3f
#define MAXN (int)(1e5+1)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
vi adj[MAXN],children[MAXN],prefix[MAXN],suffix[MAXN];
ll down[MAXN],up[MAXN];
void dfs_one(int v,int parent)
{
	ll res=1;
	for(auto u:adj[v])
	{
		if(u!=parent)
		{
			children[v].pb(u);
			dfs_one(u,v);
			res=mult(res,addmod(1,down[u]));
			prefix[v].pb(res);

		}
	}
	down[v]=res;
}
void dfs_two(int v,int parent)
{
	ll res=1;
	if(v==1)up[v]=1;
	for(int i=0;i<children[v].size();i++)
	{
		res=1;
		if(i!=0)
			res=mult(res,prefix[v][i-1]);
		if(i!=children[v].size()-1)
			res=mult(res,suffix[v][i+1]);
		res=mult(res,up[v]);
		up[children[v][i]]=addmod(res,1);
		dfs_two(children[v][i],v);

	}
}
int main()
{
	fastio;
	int n;
	cin>>n>>MOD;
	for(int i=1;i<n;i++)
	{
		int x,y;cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs_one(1,-1);
	for(int i=1;i<=n;i++)
	{
		int sz=children[i].size();
		suffix[i].resize(sz);
		ll res=1;
		for(int j=sz-1;j>=0;j--)
		{
			res=mult(res,addmod(1,down[children[i][j]]));
			suffix[i][j]=res;
		}
	}
	dfs_two(1,-1);
	ll res;

	for(int i=1;i<=n;i++)
	{
		res=mult(up[i],down[i]);
		cout<<res<<endl;
	}

}


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
  	int pointer = 0;
  	int N;
	for(int i =100 ; i >= 0; i--){
    
      if(A%i==0){

      	if(B%i==0){
          pointer++;
          	if(pointer == K){
              	N = i;
          		break;
            }
          
   
        }
        
      }
      
    }
	
  	cout << N << endl;
}

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

using namespace std;

vector<string> x;

void gen(string a,string b)
{
    int n=a.size();
    int m=b.size();
    for(int i=0;i<=n;i++)
    {
        bool ok=1;
        for(int j=0;j<m;j++)
        {
            if(i+j>=n||a[i+j]=='?'||b[j]=='?') continue;
            if(a[i+j]!=b[j])
            {
                ok=0;
                break;
            }
        }
        if(ok)
        {
            string t=a;
            for(int j=0;j<m;j++)
            {
                if(i+j>=(int)t.size()) t+='?';
                if(t[i+j]=='?') t[i+j]=b[j];
            }
            x.push_back(t);
        }
    }
}

string match(string a,string b)
{
    int n=a.size();
    int m=b.size();
    for(int i=0;i<=n;i++)
    {
        bool ok=1;
        for(int j=0;j<m;j++)
        {
            if(i+j>=n||a[i+j]=='?'||b[j]=='?') continue;
            if(a[i+j]!=b[j])
            {
                ok=0;
                break;
            }
        }
        if(ok)
        {
            for(int j=0;j<m;j++)
            {
                if(i+j>=(int)a.size()) a+='?';
                if(a[i+j]=='?') a[i+j]=b[j];
            }
            break;
        }
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(false);
    vector<string> v(3);
    for(int i=0;i<3;i++) cin >> v[i];
    sort(v.begin(),v.end());
    int res=v[0].size()+v[1].size()+v[2].size();
    do
    {
        vector<string> t=v;
        gen(t[0],t[1]);
        for(auto a:x) if((int)a.size()<res) res=min(res,(int)match(a,t[2]).size());
        x.clear();
    }while(next_permutation(v.begin(),v.end()));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6596
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
	int oper;
	cin >> oper;
	set<int> p;
	while (oper--)
	{
		int n;
		cin >> n;
		switch (n)
		{
			int num;
		case 0:
			cin >> num;
			p.insert(num);
			cout << p.size() << endl;
			break;
		case 1:
			cin >> num;
			cout << p.count(num) << endl;
			break;
		case 2:
			cin >> num;
			p.erase(num);
			break;
		}
	}
}


Measured memory_bytes: 12376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
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;}

int main(){
  int N; cin >> N;
  cout << N/2+N%2 << endl;
  return 0;
}


Measured memory_bytes: 256
//b.c B-Maximum Differnce
#include<stdio.h>

int abs(int x){
    if(x<0){
        return -x;
    }else{
        return x;
    }
}

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;++i){
        scanf("%d",a+i);
    }
    int min=a[0],max=a[0];
    for(int i=0;i<n;++i){
        if(a[i]<min){
            min = a[i];
        }
        if(a[i]>max){
            max = a[i];
        }
    }
    printf("%d\n",max - min);
    return 0;
}

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

using namespace std;


int main(){
    int n;
    cin >> n;
    
    vector<long long> a(n+1,0);
    for (int i = 1; i <= n; i++) {
        int b;
        cin >> b;
        a[i] = b;
    }
    
    long long cumulativeSum = 0;
    
    for (int i = 1; i <= n; i++){
       
        cumulativeSum += abs(a[i]-a[i-1]);
        
    }
    cumulativeSum += abs(a[n]);
   
    
    // i番目を抜く
    for (int i = 1; i <= n; i++){
        long long temp = cumulativeSum;
        if (i == n){
            temp += abs(a[n-1]);
            temp -= abs(a[n-1] - a[n]);
            temp -= abs(a[n]);
            cout << temp << endl;
        }
        else{
            temp += abs(a[i-1] - a[i+1]);
            temp -= abs(a[i-1] - a[i]);
            temp -= abs(a[i] - a[i+1]);
            cout << temp << endl;
        }
    }
    
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<double >    vecd;
typedef vector<vector<int> >  vec2int;
typedef vector<vector<double> >  vec2d;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<vector< bool > > vec2bool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int n;
vector<vector< pair<int, int>>> u; // u[i].first = node from u[i], u[i].second = cost
//output
vecbool seen;
vecint ans;
////////////////////////////////////////////////
void dfs(int pos, int color)
{
  seen[pos] = true;
  ans[pos] = color%2;
  REPvec(itr, u[pos]){
    if(seen[itr->first])continue;
    dfs(itr->first, (color + (itr->second))%2);
  }
}
////////////////////////////////////////////////
int main()
{
  cin >> n;
  u.resize(n);
  seen.resize(n);
  ans.resize(n);
  ll a, b, c;
  REP(i,n - 1){
    cin >> a >> b >> c;
    a --; b --;
    u[a].push_back(make_pair(b, c));
    u[b].push_back(make_pair(a, c));
  }
  REP(i,n){
    seen[i] = false;
    ans[i] = -1;
  }
  dfs(0,0);
  REP(i,n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 8192
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    
    let [a,b,c,d] = input[0].split(" ").map(BigInt);
    
    let ac = a * c;
    let ad = a * d;
    let bc = b * c;
    let bd = b * d;
    
    let max = [ac,ad,bc,bd].sort((a, b) => (a < b) ? -1 : ((a > b) ? 1 : 0))[3];
    
    console.log(max.toString());
    
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

vector<vector<int>> g;
vector<int> dp;

void solve(int u) {
  if (dp[u] != -1)
    return;
  dp[u] = 0;
  for (auto v : g[u]) {
    solve(v);
    dp[u] = max(dp[u], 1 + dp[v]);
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  g.resize(n + 1);
  dp.resize(n + 1, -1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
  }
  g[0].resize(n);
  iota(g[0].begin(), g[0].end(), 1);
  solve(0);
  cout << dp[0] - 1 << '\n';
  return 0;
}

Measured memory_bytes: 8576
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define tc(t) while (t--)
// https://atcoder.jp/contests/abl/tasks/abl_c
vector<ll> v[101010];
bool isVisited[101010] ={0,};
ll cnt = 0;
void dfs(ll x){
    isVisited[x] = 1;
    for(auto k : v[x]){
        if(isVisited[k] == 0){
            dfs(k);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,m;
    cin >> n >> m;
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    repn(i,n){
        if(isVisited[i] == 0){
            dfs(i);
            cnt++;
        }
    }
    cout << cnt-1;

    return 0;
}


Measured memory_bytes: 10448
#include <bits/stdc++.h> 
#define ll long long
#define MOD 1000000007
using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	char a[H][W];
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			cin >> a[i][j];

	ll dp[H][W];
	memset(dp, 0, sizeof(dp));
	dp[H-1][W-1] = 1;
	for(int j = W-1; j >= 0; j--)
	{
		for(int i = H-1; i >= 0; i--)
		{
			if(a[i][j] == '.')
			{
				if(i+1 < H and a[i+1][j] == '.')
					dp[i][j] = (dp[i][j] + dp[i+1][j]) % MOD;
				
				if(j+1 < W and a[i][j+1] == '.')
					dp[i][j] = (dp[i][j] + dp[i][j+1]) % MOD;
			}
		}
	}
	cout << dp[0][0] % MOD;

}

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

int c (vector<int> v) {
    int n[11][11];
    for (int i = 0; i < 10; i++) {
        n[0][i] = v[i];
    }
    for (int i = 1; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            n[i][j] = (n[i-1][j-1] + n[i-1][j]) % 10;
        }
    }

    return n[9][9];
}

int main ()
{
    long long n;
    while (cin >> n) {
        vector<int> v;
        for (int i = 0; i < 10; i++) {
            v.push_back(n % 10);
            n /= 10;
        }
        cout << c(v) << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
i = input()
if i == "SUN":
  print(7)
elif i == "MON":
  print(6)
elif i == "TUE":
  print(5)
elif i == "WED":
  print(4)
elif i == "THU":
  print(3)
elif i == "FRI":
  print(2)
else:
  print(1)

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

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
/**
 * For every prime factor p, perform result[p] += e. (where n = \prod p^e)
 * Verified by: Codeforces #400 E
 *              (http://codeforces.com/contest/776/submission/24956471)
 */
void factorize(long long v, std::map<long long, int> &result) {
  long long p = 2;
  while (v > 1 && p * p <= v) {
    int cnt = 0;
    while (v % p == 0) {
      cnt++;
      v /= p;
    }
    if (cnt > 0) {
      if (result.count(p) == 0) {
	result[p] = 0;
      }
      result[p] += cnt;
    }
    p += p == 2 ? 1 : 2;
  }
  if (v > 1) {
    if (result.count(v) == 0) {
      result[v] = 0;
    }
    result[v] += 1;
  }
}

ll gcd(ll x,ll y){
  while(y!=0){
    ll r=x%y;
    x=y;y=r;
  }
  return x;
}

// Find x s.t. n^x mod mod = 1, or -1 if there's no such x
ll calc(ll n, ll mod) {
  n %= mod;
  ll v = 1;
  REP(i, 0, mod) {
    v = v * n % mod;
    if (v == 1 % mod) {
      return i + 1;
    }
  }
  return -1;
}

int main(void){
  ll n;
  cin >> n;
  map<ll, int> factor;
  factorize(n, factor);
  ll res = 1;
  for (map<ll, int>::iterator it = factor.begin(); it != factor.end(); ++it) {
    ll p = it->first;
    int e = it->second;
    ll v = p - 1;
    REP(i, 0, e - 1) {
      v *= p;
    }
    ll c = calc(n, v);
    if (c == -1) {
      res = -1;
      break;
    }
    res = c / gcd(c, res) * res;
  }
  cout << res << endl;
}

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

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

	vector<int> a( N );
	vector<int> b( N );
	for( int i = 0; i < N; i++ ) {
		if( i == 0 ) {
			a[ p[i] ] = 1000000000 / 2;
			b[ p[i] ] = 1000000000 / 2;
		}
		else {
			int d = (p[i] - p[i - 1]) * N;
			a[ p[i] ] = a[ p[i - 1] ] + d;
			b[ p[i] ] = b[ p[i - 1] ] - d;
		}
	}
	for( int i = 0; i < N; i++ ) {
		a[ p[i] ] += i;
	}

	for( int i = 0; i < N; i++ ) {
		if( i ) cout << " ";
		cout << a[i];
	}
	cout << endl;
	for( int i = 0; i < N; i++ ) {
		if( i ) cout << " ";
		cout << b[i];
	}
	cout << endl;
}


Measured memory_bytes: 896