akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}






ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};

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




// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n) {
    if(n==0)return 1;
    mint x=f(2/n);
    x*=x;
    if(n%2==1)x*=2;
    return x;
}

mint choose(int n,int a){
    mint x =1,y=1;
    rep(i,a){
      x*=n-i;
      y*=a+i;
    }
    return x/y;
}

ll n,m,q;
vector<ll>a,b,c,d;
ll ans=0;
void dfs(vector<ll>v){
    if(v.size()==n+1){
      ll sum=0;
      rep(i,q){
          if(v[b[i]]-v[a[i]]==c[i])sum+=d[i];
      }
      ans=max(ans,sum);
      return;
    }
    v.push_back(v.back());
    dfs(v);
    while(v.back()<m){
        v.back()++;
        dfs(v);
    }
}

int main()
{
  cin>>n>>m>>q;
  a=b=c=d=vector<ll>(q);
  rep(i,q){
      cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  dfs(vector<ll>(1,1));
  cout<<ans<<endl;
}
 
 




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

using namespace std;

long attack_cul(long H){
  	long long attack_count = 0;
	if(H == 1) return 1;
  	long harf_H;
  	harf_H = floor(H/2);
    attack_count+=(attack_cul(harf_H))*2;
  	return attack_count+1;
}

int main(){
	long H;
  	cin >> H;
  	cout << attack_cul(H) << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n[5];
int b,c;
int main()
{   
for(int i=1;i<=4;i++)
{
	scanf("%1d",&n[i]);
}
	if(n[1]==n[2]&&n[2]==n[3])
   {
   	cout<<"Yes"<<endl;
   	return 0;
   }
   if(n[3]==n[2]&&n[4]==n[3])
   {
   	cout<<"Yes"<<endl;
   	return 0;
   }
	cout<<"No"<<endl;
	return 0;
	
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    X, Y = map(int, input().split())

    ans = 0
    if X == 3:
        ans += 100000
    if Y == 3:
        ans += 100000
    if X == 2:
        ans += 200000
    if Y == 2:
        ans += 200000
    if X == 1:
        ans += 300000
    if Y == 1:
        ans += 300000
    if X == 1 and Y == 1:
        ans += 400000

    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	set<int> R, G, B;
	rep(i,n){
		if(s[i] == 'R') R.insert(i);
		else if(s[i] == 'G') G.insert(i);
		else B.insert(i);
	}
	ll ans = 0;
	for(auto r : R){
		for(auto g : G){
			int i = min(r, g) - abs(r - g);
			int j = (r + g) / 2;
			if((r+g)%2 != 0) j = -1;
			int k = max(r, g) + abs(r - g);
			ans += B.size();
			if(i >= 0){
				if(s[i] == 'B') ans--;
			}
			if(0 <= j && j <= n-1){
				if(s[j] == 'B') ans--;
			}
			if(k <= n-1){
				if(s[k] == 'B') ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int length[100005] = {};
    int point[100005] = {};
    int N, R, L;

    set < pair < int , int > > st; //point -idx

    cin >> N >> R >> L;

    for ( int i = 0; i < N; i++ ) {
        st.insert(make_pair(0, -i));
    }
    int before = 0;
    while ( R > 0 ) {
        int d, t, x;
        cin >> d >> t >> x; --d;

        length[-(rbegin(st) -> second)] += (t - before);
        st.erase(make_pair(point[d], -d));
        point[d] += x;
        st.insert(make_pair(point[d], -d));


        R--, before = t;
    }

    length[-(rbegin(st) -> second)] += (L - before);

    int maxp = 0;
    for ( int i = 1; i < N; i++ ) {
        if ( length[i] > length[maxp] ) {
            maxp = i;
        }
    }
    cout << maxp + 1 << endl;

    return ( 0 );
}



Measured memory_bytes: 8564
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t;
int main()
{
    int i,j;
    scanf("%d%d%d",&n,&m,&k);
    if(n>m)swap(n,m);if(n>k)swap(n,k);if(m>k)swap(m,k);
    puts(n==5&&m==5&&k==7?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"

const ll mod = 1e9 + 7;
// const ll mod = 998244353;
const ll sz = 1e6 + 5;
vector<ll> fac(sz, 1);

ll powmod(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 nCr(ll n, ll r) { return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod ); }
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; }
ll extended_gcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) { x = 1; y = 0; return a; }
    ll xx, yy;
    ll res = extended_gcd(b, a%b, xx, yy); x = yy; y = xx - yy * (a / b);
    return res;
}

// * ALways PASS arrays, strings etc to functions BY REFERENCE

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // for (ll i = 2; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;

    while(t--) {
        ll n, res = 0;
        cin >> n;
        
        for (ll a = 1; a <= n; a++) {
            ll b = n / a;
            ll c = n % a;
            if (c == 0)
                b -= 1;
            res += b;
        }
        
        cout << res << endl;
    }
    
	return 0;
}


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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    x-=a;
    cout << x%b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define int long long

using namespace std;


class Solver {
};

signed main() {
	while (true) {
		int n, i, j;
		cin >> n >> i >> j;
		if (n == 0)break;

		int up = i - 1;
		int down = n - up - 1;
		vector<bool> ups(n, false);
		int val = pow(2, n - 1);
		for (int i = n - 1; i >= 0; i--) {
			if (val <= up) {
				up -= val;
				ups[i] = true;
			}
			else down -= val;

			val /= 2;
		}

		int now = j - 1;
		int len = pow(2, n);
		for (int i = 0; i < n; i++) {
			bool left = now < len / 2;
			bool toLeft = false;
			if (i + 1 < n) {
				if (ups[i] == ups[i + 1]) {
					if (left)toLeft = true;
					else toLeft = false;
				}
				else {
					if (left)toLeft = false;
					else toLeft = true;
				}
			}
			else {
				if (ups[i]) {
					if (left)toLeft = true;
					else toLeft = false;
				}
				else {
					if (left)toLeft = false;
					else toLeft = true;
				}
			}
			len /= 2;
			if (toLeft) {
				cout << 'R';
				if (!left) {
					now = len - now % len - 1;
				}
			}
			else {
				cout << 'L';
				if (left) {
					now = len - now - 1;
				}
				else {
					now %= len;
				}
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3268
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        String result = "No";
        if (4*x-y >= 0) {
            if ((4*x-y)%2 == 0) {
                if (y-2*x >= 0) {
                    if ((y-2*x)%2 == 0) {
                        result = "Yes";
                    }
                }
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 27072
n = int(input())
s = input()
ans = -1

for i in ['SS', 'SW', 'WW', 'WS']:
    narabi = ''
    narabi += i
    for k in range(n - 2):
        if narabi[-1] == 'S':
            if s[k + 1] == 'o':
                narabi += narabi[-2]
            else:
                if narabi[-2] == 'S':
                    narabi += 'W'
                else:
                    narabi += 'S'
        else:
            if s[k + 1] == 'o':
                if narabi[-2] == 'S':
                    narabi += 'W'
                else:
                    narabi += 'S'
            else:
                narabi += narabi[-2]
    kenshou = narabi[-2:]
    kenshou2 = kenshou + narabi[:2]
    kenshou_s = s[-1] + s[-0]
    for k in range(2):
        if kenshou[-1] == 'S':
            if kenshou_s[k] == 'o':
                kenshou += kenshou[-2]
            else:
                if kenshou[-2] == 'S':
                    kenshou += 'W'
                else:
                    kenshou += 'S'
        else:
            if kenshou_s[k] == 'o':
                if kenshou[-2] == 'S':
                    kenshou += 'W'
                else:
                    kenshou += 'S'
            else:
                kenshou += kenshou[-2]
    if kenshou == kenshou2:
        ans = narabi
        break
    # print(kenshou2)
    # print(kenshou)
    # print(narabi)
print(ans)


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

using ll=long long;
ll a,b;
ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main(){
    int N;cin>>N;
    ll ans=1;
    for(int i=0;i<N;i++){
        ll k;
        cin>>k;
        ans=lcm(ans,k);
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define ll long long
#define ar array



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

    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0;i < (int)n; i++){
      cin >> arr[i];
    }
    ll sum = 0;
    for(int i = 0;i < (int)n; i++){
     for(int j = i+1;j < (int)n; j++){
          sum += arr[i]*arr[j];
     }    
    }    
    cout << sum;
    
    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;

const long long int INF = pow(10, 16);

long long int N, A[100010][3];
long long int DP[100010][3];

void dp() {
	DP[0][0] = 0, DP[0][1] = 0, DP[0][2] = 0;
	for (int i = 1; i <= N; i++) {
		DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + A[i][0];
		DP[i][1] = max(DP[i - 1][2], DP[i - 1][0]) + A[i][1];
		DP[i][2] = max(DP[i - 1][0], DP[i - 1][1]) + A[i][2];
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i][0] >> A[i][1] >> A[i][2];
	}
	dp();
	sort(DP[N], DP[N] + 3);
	cout << DP[N][2];
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005

using namespace std;
 
typedef long long ll;

int n;

int main()
{
	cin >> n;

	cout << n*n*n;

    return 0;
}


Measured memory_bytes: 256
// Last Change: 06/20/2019 18:47:07.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  string ipt;
  while (cin >> ipt and ipt != "0") {
    ll ans = 0;
    int size = ipt.size();
    for (int i = 0; i < size; ++i) {
      ans += ipt[i] - '0';
    }
    cout << ans << endl;
  }

  //NS::LoopUntilZeroInpput();
}



Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll n_check(ll n) {
	for (ll i = sqrt(n);; ++i) {
		ll r = i * (i + 1) / 2;
		if (r == n) {
			return i + 1;
		} else if (r > n) {
			return -1;
		}
	}
}
signed main()
{
	ll n = in(), k;
	if ((k = n_check(n)) == -1) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		cout << k << endl;
		REP(i, k - 1) {
			cout << k - 1 << ' ';
			REP(j, k - 1) {
				cout << (i > j ? i * (i + 1) / 2 + j + 1 : j * (j + 1) / 2 + i + 1) << ' ';
			}
			cout << endl;
		}
		cout << k - 1 << ' ';
		REP(i, k - 1) {
			cout << (i + 1) * (i + 2) / 2 << ' ';
		}
		cout << endl;
	}
}

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

int main() {
	long long k,a,b;cin>>k>>a>>b;
	long long ans=1;
	if(b-a<=2){
		ans+=k;
//		cout<<'A';
	}else{
		if(a>=k+1){
			ans+=k;
//			cout<<'B';
		}else{
//			cout<<'C';
			ans=a;
			k-=a-1;
			ans+=(k/2)*(b-a)+k%2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N, P; 
cin >> N >> P; 
int A[60]; 
int sum; 
for (int i = 0; i < N; i++){
cin >> A[i]; 
sum += A[i] % 2; 
}
if(sum == 0 && P == 0){
long long int ans = 1; 
for(int i = 0; i < N; i++){ 
ans *= 2; 
}
cout << ans << endl; 
}
else if(sum == 0 && P == 1){
cout << 0 << endl; 
}
else if(sum > 0){
long long int ans = 1; 
for(int i = 0; i < N-1; i++){ 
ans *= 2; 
}
cout << ans << endl; 
}
}

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

using namespace std;
int main(void){
    int N;
    cin>>N;
    for(int n = 1;n<=N;n++){
        int cnt = 0;
        for(int x = 1;x* x<n;x++){
            for(int y = x;y*y<n;y++){
                for(int z = y; z*z<n;z++){
                    long long ans = x*x + y*y + z*z +x*y + y*z+z*x;
                    if(ans == n){
                        set<int> st{x,y,z};
                        if(st.size()==3)cnt += 6;
                        if(st.size()==2)cnt += 3;
                        if(st.size()==1)cnt ++;
                    }
                }
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    cin>>N;
    string s;
    cin>>s;
    long long ma=1;
    for(long long i=0;i<N-1;i++){
    if(s.at(i)!=s.at(i+1)){
    ma++;}}
    cout<<ma<<endl;}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[n];

        for(int i=0;i<n;i++){
            arr[i] = sc.nextInt();
        }

        int dp[] = new int[k+1];

        for(int i=1;i<=k;i++){
            int f = 0;
            for(int j=0;j<arr.length;j++){
                if(i-arr[j] >= 0 && dp[i-arr[j]] == 0){
                    f = 1;
                    break;
                }
            }
            if(f == 1) dp[i] = 1;
            else dp[i] = 0;
        }

        if(dp[k] == 1) System.out.println("First");
        else System.out.println("Second");

    }
}

Measured memory_bytes: 23760
import java.util.Scanner;

public class Main {

	static int H,W;
	static int[][] field;
	static int[][] dp;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			W=cin.nextInt();
			H=cin.nextInt();
			if(W+H==0)break;
			field=new int[H+2][W];
			dp=new int[H+2][W];
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					field[i][j]=cin.nextInt();
				}
			}
			for(int i=0;i<W;i++){
				if(field[0][i]==0)dp[0][i]=1;
			}
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(field[i][j]==0){
						if(i!=H-1){
							for(int k=-1;k<=1;k++){
								if(j+k<0||j+k>=W)continue;
								if(field[i+1][j+k]==1)continue;
								if(k!=0&&field[i+1][j+k]==2)continue;
								dp[i+1][j+k]+=dp[i][j];
							}							
						}
						else{
							dp[i+1][j]+=dp[i][j];
						}
					}
					else if(field[i][j]==2){
						dp[i+2][j]+=dp[i][j];
					}
				}
			}
			int ans=0;
			for(int i=H;i<H+2;i++){
				for(int j=0;j<W;j++){
					ans+=dp[i][j];
				}
			}
			System.out.println(ans);
			
		}
	}

}

Measured memory_bytes: 23468
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
int graph[51][51];
int subgraph[51][51];
int used[51];
void tansaku(int startx){
  for(int i=0;i<51;i++){
    if(subgraph[startx][i]==1){
      subgraph[startx][i]=0;
      subgraph[i][startx]=0;
      used[i]=0;
      tansaku(i);
    }
  }



}







int main() {
  int N,T;
  int c[N];
  int t[N];
  cin>>N>>T;
  for(int i=0;i<N;i++){
    cin>>c[i]>>t[i];
  }
  int min=10000;
  for(int i=0;i<N;i++){
    if(t[i]<=T){
      if(min>=c[i]){
        min=c[i];
      }
    }
  }
  if(min==10000){
    cout<<"TLE"<<endl;
  }else{
    cout<<min<<endl;
  }

  

  




  
  
}

  

  


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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=1000;

int a[MAXN][2],n;

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i][0],&a[i][1]);
		if(i>2){
			if(a[i-2][0]!=a[i-2][1]) continue;
			if(a[i-1][0]!=a[i-1][1]) continue;
			if(a[i][0]!=a[i][1]) continue;
			printf("Yes\n");return 0;
		}
	}
	printf("No\n");

	return 0;
}

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

//SUN, MON, TUE, WED, THU, FRI, or SAT
int main() {
    int a;
    a=getchar();
    if(a=='S'){
       a=getchar();
       if(a=='U'){
           printf("7");
       } else{
            printf("1");
       }
    }else if(a=='M'){
         printf("6");
    }else if(a=='T'){
        a=getchar();
       if(a=='U'){
            printf("5");
       } else{
            printf("3");
       }
    }else if(a=='W'){
         printf("4");
    }else if(a=='F'){
       printf("2");
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    string day;
    cin>>day;
    if (day=="SUN") {cout<<7;}
    if (day=="SAT") {cout<<1;}

    if (day=="MON") {cout<<6;}

    if (day=="TUE") {cout<<5;}

    if (day=="WED") {cout<<4;}

    if (day=="THU") {cout<<3;}

    if (day=="FRI") {cout<<2;}

    return 0;
}


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

int main() {
  int N,M,C,i,j,ct=0,x;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A(N, vector<int>(M));
  
  for(i=0; i<M; i++)
    cin >> B.at(i);
  for(i=0; i<N; i++) {
    int s=0;
    for(j=0; j<M; j++) {
      cin >> x;
      s+= x*B.at(j);
    }
    if(s+C>0)
      ct++;
  }
  cout << ct << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  
  vector<int> l(n);
  rep(i, 0, n) cin >> l.at(i);
  
  int ans = 1;
  int sum = 0;
  rep(i, 0, n) {
    sum += l.at(i);
    if(sum <= x)
    ans++;
  }
  
  cout << ans << "\n";

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n, m, x, a[101];

	cin >> n >> m >> x;

	for (i = 0; i < m; i++) {
		cin >> a[i];
	}

	int cnt1 = 0, cnt2 = 0;


	for (i = x; i <= n; i++) {
		for (j = 0; j < m; j++) {
			if (a[j] == i) cnt1++;
		}

	}


	for (i = x; i >= 0; i--) {
		for (j = 0; j < m; j++) {
			if (a[j] == i) cnt2++;
		}

	}


	int ans;

	ans = min(cnt1, cnt2);

	cout << ans << endl;







	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

solve i a b 1
    |(mod a i ==0)&&(mod b i ==0) = i
    |otherwise = solve (i-1) a b 1

solve i a b n
    |(mod a i ==0)&&(mod b i ==0) = solve (i-1) a b (n-1)
    |otherwise = solve (i-1) a b n



main = do
    [a,b,k] <- map read . words <$> getLine
    print $ solve a a b k

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

int main(){

        int n;
        cin>>n;

        int* a = new int[n];
        int* b = new int[n];
        int* c = new int[n-1];

        for(int i = 0;i<n;i++)cin>>a[i];
        for(int i = 0;i<n;i++)cin>>b[i];
        for(int i = 0;i<n-1;i++)cin>>c[i];

        int s = 0;//satisfy

        for(int i = 0;i<n;i++){
                s+=b[a[i]-1];
                if(i>0 and a[i] - a[i-1] == 1)s += c[a[i-1]-1];
        }

        cout<<s<<endl;
}

Measured memory_bytes: 256
s = gets.to_i

def f(n)
  if n % 2 == 0
    n / 2
  else
    3 * n + 1
  end
end

a = [s]
n = 1
until a.count(a[n-1]) == 2
  a << f(a[n-1])
  n += 1
end
puts n


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

int main() {
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];

    int ans = 0;
    sort(p, p+n);
    rep(i, n) {
        if (i == n-1) ans += p[i]/2;
        else ans += p[i];
    }

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


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

int main(){
  int W,A,B;
  cin>>W>>A>>B;
  int a=min(A,B);
  int b=max(A,B);
  if(a+W>=b){
    cout<<0<<endl;
  }
  else{
    cout<<b-a-W<<endl;
  }
  return 0;
}


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

int main() {
  int n, d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    if (d >= sqrt(x * x + y * y)) {
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3660
N = int(input())
S = input()

result = 10 ** 6
E = S.count('E')
W = S.count('W')
for i in range(N):
    temp = 0
    if 'E' == S[i]:
        temp = E-1
    else:
        temp = E
    if 'W' == S[i]:
        E += 1
    else:
        E -= 1
    result = min(temp, result)
print(result)


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

int main() {
    int N, flag=0;
    string S;
    cin >> N >> S;

    if(N <= 1) {
        cout << "No" << endl;
        return 0;
    }

    if(N%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    else 
        for(int i=0; i<N/2; i++){
            if(S[i] != S[N/2+i])
                flag++;
        }

    if(flag != 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

}

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

int main()
{
	int N, Z, W,i,j,k;
	cin >> N >> Z >> W;
	vector<int>a(N);
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}
	if (N == 1)
		cout << abs(a[0] - W) << endl;
	else if (abs(W - a[N - 1]) > abs(a[N - 1] - a[N - 2]))
		cout << abs(W - a[N - 1]) << endl;
	else
		cout << abs(a[N - 1] - a[N - 2]) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int main(){
    ll n , m;
    vector<pair<int, int> > v;
    ll a, b;
    cin >> n >> m;
    rep(i,n ){
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(all(v));
    ll ans = 0;
    ll cur = 0;
    rep(i, v.size()){
        if(cur + v[i].second < m){
            ans += v[i].first *v[i].second;
            cur += v[i].second;
        }else{
            cout << ans + v[i].first * (m - cur) << endl;
            return 0;
        }
    }

}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define in(x,y) 1<=x&&x<=n&&1<=y&&y<=m
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c[]={'R','Y','G','B'};
map<pair<int,int>,char> ch;
int main()
{	int n,m,d,t=0,X=0,Y=0; cin>>n>>m>>d;
	for(rint i=2;i<=n+m;i++,X++,Y=0)
	for(rint j=1-m;j<=n-1;j++,Y++)
	ch[mp(i,j)]=c[(X/d%2)*2+(Y/d%2)];
	for(rint i=1;i<=n;i++)
	for(rint j=1;j<=m;j++)
	{	int x=i+j,y=i-j;
		printf(j==m?"%c\n":"%c",ch[mp(x,y)]);
	}
	return 0;
}


Measured memory_bytes: 62848
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
int i,t=0;

long long int n;
long long int j;

cin>>n;
j=100;
while(j<n)
{
    j=j+j/100;
    t++;
}
cout<<t<<endl;
return 0;
}


Measured memory_bytes: 3636
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        if math.sqrt(tmp).is_integer():
            cnt += 1
        
print(cnt)

Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	static void inc(Map<Long, Integer> map, long value) {
		Integer nVal = map.get(value);
		nVal = nVal == null ? 1 : nVal + 1;
		map.put(value, nVal);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int N = sc.nextInt();
		Map<Long, Integer> acums = new HashMap<>();
		long acum = 0, tmp;
		inc(acums, acum);
		for (int i = 0; i < N; i++) {
			tmp = sc.nextInt();
			acum += tmp;
			inc(acums, acum);
		}
		long ans = 0;
		for (int cant : acums.values()) {
			ans += cant * (long) (cant - 1) / 2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 101872
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
   int a,b,c,z;
    cin >> a >> b >> c;
    z = a*100 + b*10 + c;
    if(z%4==0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

const int z = 1e9+7;

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

    int dp[n-2][64];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < 64; i++) {
        dp[0][i] = i == 6 || i == 9 || i == 33 ? 0 : 1;
    }
    for (int i = 1; i < n - 2; i++) {
        for (int j = 0; j < 256; j++) {
            if (j % 64 == 6 || j % 64 == 9 || j % 64 == 33
                    || (j & 207) == 9 || (j & 243) == 33) {
                continue;
            }
            dp[i][j%64] = (dp[i][j%64] + dp[i-1][j/4]) % z;
        }
    }

    int ans = 0;
    for (int i = 0; i < 64; i++) {
        ans = (ans + dp[n-3][i]) % z;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


const int limit = 10;

bool graph[limit][limit];
bool visited[limit];

int N,M;

int dfs(int now, int depth) {
  if(visited[now]) return 0;
  if(depth==N) return 1;

  visited[now] = true;
  int ans = 0;

  for (int i = 0; i < N; ++i) {
   if(graph[now][i]) ans += dfs(i,depth+1);
  }

  visited[now] = false;

  return ans;
}

int main(){
  scanf("%d%d", &N,&M);
  int a[M],b[M];
  for (int i = 0; i < M; ++i) {
    scanf("%d%d", &a[i],&b[i]);
    --a[i];--b[i];
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }

  cout << dfs(0,1) << endl;


}

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

using namespace std;

int main(){
  int a[5];
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  int k;
  cin>>k;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
       if(abs(a[i] - a[j])> k){
         cout<<":(";
         return 0;
       }
    }
  }
  cout<<"Yay!";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll a;
    cin>>a;
    string s;
    cin>>s;
    if(a >= 3200){
        print(s);
    }
    else print("red");
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}



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

#define ll long long
#define MOD 1000000007


int main(){
    int n;
    cin>>n;
    vector<int> h(n);

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

    vector<int> dp(n,0);

    dp.at(1)=abs(h.at(0)-h.at(1));

    for(int i=2;i<n;i++){
        dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)),
                dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
    }

    cout<<dp.at(n-1)<<endl;

}


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

int main() {
    int spending, haveCoins;
    cin >> spending >> haveCoins;

    int justSpending = spending % 500;

    if (justSpending == 0) {
        cout << "Yes" << endl;
    } else if ((justSpending - haveCoins) <= 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int dp[1100][1100];

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  for (int i = 0; i < 1100; i++) {
    dp[0][i] = i;
    dp[i][0] = i;
  }
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      int d = 0;
      if (s[i - 1] != t[j - 1]) {
        d = 1;
      }
      dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1), dp[i - 1][j - 1] + d);
    }
  }
  cout << dp[s.size()][t.size()] << endl;
  return 0;
}


Measured memory_bytes: 7864
n=int(input())
al=list(map(int,input().split()))

dic={}
flag=True
for i in range(n):
    v=al[i]
    dic[v]=dic.get(v,0)+1
    if dic[v]==2:
        flag=False
        break
if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 32944
import java.util.Scanner;

public class Main
{

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

        int N = scan.nextInt();

        for (int i = 0; i != N; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();
            int d;

            if (a < b) {
                d = a;
                a = b;
                b = d;

            }
            if (b < c) {
                d = b;
                b = c;
                c = d;

            }
            if (a < b) {
                d = a;
                a = b;
                b = d;

            }
            if (a * a == b * b + c * c) {
                System.out.println("YES");

            } else {
                System.out.println("NO");
            }
        }
    }
}



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

int main() {
	int a, b;
	int sum = 0;
	int count = 0;
	double ave = 0;
	string str, str_a, str_b;
	while(cin >> str) {
		count++;
		replace(str.begin(), str.end(), ',', ' ');
		istringstream iss(str);
		iss >> str_a >> str_b;
		a = stoi(str_a);
		b = stoi(str_b);
		sum += a * b;
		ave += b;
	}
	ave /= count;
	if (ave - (int)ave != 0) {
		if (ave - ((int)ave + 0.5) >= 0) ave = (int)(ave + 0.5);
		else ave = (int)ave;
	}
	cout << sum << endl << ave << endl;
	return 0;
}


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

using namespace std;

const int N = 2e5+7;
int n, k;
double a[N], e[N], sum[N], ans;

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

    sum[0] = 0;

    for (int i=1;i<=n;i++){
        scanf("%lf", &a[i]);
        e[i] = (1+a[i])/2;
        sum[i] = sum[i-1] + e[i];
    }

    for (int i=k;i<=n;i++){
        //cout << i << " " << i-k << endl;
        ans = max(ans, sum[i]-sum[i-k]);
    }

    printf("%.12lf\n", ans);

    return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 1000010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int f[maxn],sm[maxn];
	
void Work(){
	int ans=0;
	REP(i,0,n-2){
		ans=(ans+1ll*f[i]*(n-1)%mod*(n-2))%mod;
	}
	REP(i,0,n-1){
		ans=(ans+1ll*f[i]*(n-1))%mod;
	}
	REP(i,0,n-2){
		ans=(ans+1ll*f[i]*(n-1))%mod;
	}
	ans=(ans+1)%mod;
	iout(ans);
}

void Init(){
	read(n);
	f[0]=f[1]=1;sm[1]=2;
	REP(i,2,n){
		f[i]=sm[i-1];
		f[i]=(f[i]-f[i-2]+mod)%mod;
		sm[i]=(sm[i-1]+f[i])%mod;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

int main(){
    int r, c, i, j, s[128][128] = {};
    scanf("%d%d", &r, &c);
    for(i = 0;i < r;i++){
        for(j = 0;j < c;j++){
            scanf("%d", &s[i][j]);
            s[i][c] += s[i][j]; s[r][j] += s[i][j]; s[r][c] += s[i][j];
        }
    }
    
    for(i = 0;i <= r;i++){
        for(j = 0;j <= c;j++)
            printf(j != 0 ? " %d" : "%d", s[i][j]);
        puts("");
    }
    return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    while(cin>>n)
    {
        if(n&1)
            cout<<"0"<<endl;
        else
        {
            ll x=n/10;
            ll ret = 0;
            while(x)
            {
                ret += x/5;
                x /= 5;
            }
            cout<<n/10+ret<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include <algorithm>
#include <functional>
//#include <bits/stdc++.h>
#include<map>
using namespace std;
 
int main() {
int n,m;

cin>>n>>m;
string a,b;
a=to_string(n);
b=to_string(m);
string t,u;
t=a;
u=b;
for(int i=0;i<m-1;i++)t+=a;
for(int j=0;j<n-1;j++)u+=b;
/*
vector<char*> s;
s.push_back(a);
s.push_back(b);
sort(s.begin(), s.end());
*/
if(t<u)cout<<t<<endl;
else{
    cout<<u<<endl;
}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    li = LI()
    li.sort()
    ans = sum(li[:2])
    return ans

print(main())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    string s;
    cin>>s;
    int i,r=0,l=0;
    for(i=0;i<s.size();i++)if(s[i]=='A'){l=i;break;}
    i=s.size()-1;
    for(;i>=0;i--)
    if(s[i]=='Z'){r=i;break;}
    cout<<r-l+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3648
D,G = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(D)]
mincount = 1000
for i in range(2**D):
	Tcount = 0
	Tscore = 0
	for j in range(D):
		if((i>>j)&1):
			Tscore += l[j][0]*(j+1)*100 + l[j][1]
			Tcount += l[j][0]
	if Tscore >= G:
		if Tcount <= mincount:
			mincount = Tcount
	else:
		for j in range(D):
			AFcount = 0
			if(((~i)>>(D-j-1))&1):
				while Tscore < G and AFcount<=l[D-j-1][0]:
					Tscore += (D-j)*100
					Tcount += 1
					AFcount += 1
			if Tscore >= G:
				if Tcount <= mincount:
					mincount = Tcount
				break
print(mincount)

		

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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    int n;
    cin >> n;
    int num=0;
    while(1){
        num++;
        int cou=0;
        REAP(i,1,num+1){
            if(num%i==0)cou++;
        }
        if(cou==n){
            cout << num << endl;
            break;
        }
    }
}



Measured memory_bytes: 3112
N,M = map(int, input().split())

class UFT:
    def __init__(self, N):
        self.UFdata = [-1] * (N+1)
        self.rank   = [0]  * (N+1)
        self.connected_num = [1] * (N+1)

    def find(self,x):
        UFdata = self.UFdata
        while UFdata[x] != -1:
            x = UFdata[x]
        return x

    def unite(self,x,y):
        UFdata = self.UFdata
        rank = self.rank
        connected_num = self.connected_num
        find = self.find

        x = find(x)
        y = find(y)
        if x != y:
            if rank[x] < rank[y]:
                UFdata[x] = UFdata[y]
                x,y = y,x
            if rank[x] == rank[y]:
                rank[x] += 1
            UFdata[y] = x       
            connected_num[x] += connected_num[y]
            

UF = UFT(N)

import sys

input = sys.stdin.readline
AB = [ [int(j) for j in input().split()] for _ in range(M)]
AB = list(reversed(AB))

ans = [0] * (M+1)
ans[0] = N*(N-1)//2
for i in range(M):
    a,b = AB[i]
    if UF.find(a) != -1 and  UF.find(a) == UF.find(b):
        ans[i+1] = ans[i]
        continue
        
    cnt1 = UF.connected_num[ UF.find(a) ]   
    cnt2 = UF.connected_num[ UF.find(b) ]  
    UF.unite(a,b)
    # cnt = UF.connected_num[ UF.find(a) ]  -1 
    cnt = cnt1*cnt2

    last = ans[i]
    last -= cnt
    ans[i+1] = last

for i in range(M-1, -1, -1):
    # if ans[i] > 0:
    print(ans[i])
    # else:
    #     print(0)


Measured memory_bytes: 78300
import java.io.*;
public class Main {

    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());

        String[] temp = br.readLine().split(" ");
        int cnt = 0;
        for(int i=1;i<=n;i++){

            if(i % 2 == 0)continue;
            int a = Integer.parseInt(temp[i-1]);

            if(a % 2 == 0)continue;

            cnt++;

        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 32684
#include <stdio.h>
int main(void){
    int n,a[10],max=0,sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        if(max<a[i]) max=a[i];
        sum+=a[i];
    }
    printf("%d",sum-max/2);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int tansa(int [][101],int,int,int*);
int n;
int main(){
  int i,j,a[101][101],m,l,stack[100],stamp[101][2],now,time=1,depth[101];
  scanf("%d",&n);
  for(i=1;i<=n;i++) for(j=1;j<=n;j++){
      a[i][j]=0;
      depth[j]=-1;
    }
  for(i=1;i<=n;i++){
    scanf("%d %d",&j,&m);

    for(j=1;j<=m;j++){
      scanf("%d",&l);
      a[i][l]=1;
    }
  }
  tansa(a,1,0,depth);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i,depth[i]);
  }
}
int tansa(int a[][101],int now,int nowdep,int* depth){
  int i;
  if(depth[now] > nowdep || depth[now] == -1)
    depth[now]=nowdep;
  for(i=1;i<=n;i++){
    if(a[now][i] == 1 && (depth[i] > nowdep+1 || depth[i] == -1)) tansa(a,i,nowdep+1,depth);
  }
  return 1;
}



Measured memory_bytes: 2148