akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

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

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
    // cout << fixed << setprecision(10) << ans << endl;
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

ll sum(vll &v) {return accumulate(all(v), 0LL);}

int main(){
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vll p(a), q(b), r(c), s(x), t(y);
    cin >> p >> q >> r;
    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    sort(all(r), greater<ll>());

    REP(i,x) s[i] = p[i];
    REP(i,y) t[i] = q[i];
    s.emplace_back(0);
    t.emplace_back(0);

    // dump(s);
    // dump(t);

    ll ri=0, si=0, ti=0, ans=0;
    REP(i,x+y){
        if(t[ti]>=s[si] && t[ti]>=r[ri]){
            ans += t[ti];
            ti++;
        }
        else if(s[si]>=t[ti] && s[si]>=r[ri]){
            ans += s[si];
            si++;
        }
        else{
            ans += r[ri];
            ri++;
        }
    }

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


Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  string str;
  cin >> str;
  rep(i,str.size()-8){
    cout << str[i];
  }

  cout << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll z = x/d;
    ll ans = 0;
    if (k<=z) {
        ans = x - d*k;
    }
    else {
        k -=z;
        k %= 2;
        if (k==0) {
            ans = x%d;
        }
        else {
            ans = d-x%d;
        }
    }
    
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
string s, t, B = "~";
bool isOK(string ss,string t)
{//sをi文字目からtと同じ文字数で切り取ったものがssとして届く
 //cout << ss<<":"<<t<<endl;
 rep(i,ss.size())
 { 
   if(ss[i]!='?'&&ss[i]!=t[i])
   {return false;}
 }
 //cout<<"true!"<<endl;
 return true;

}
int main() {
	cin >> s >> t;
	for (int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
		/*string U = s.substr(i, t.size());
		if (isOK(U, t) == true) {*/
		if(isOK(s.substr(i,t.size()),t)){
			string v = s;
			//for (int j = i; j < i + t.size(); j++)v[j] = t[j - i];
			for(int j=0; j<t.size(); j++)
	    	{v[j+i]=t[j];}
	 		rep(j,i)//i(挿入開始地点)まで見る
	 		{if(v[j]=='?')v[j]='a';}
	 		for(int j=i+t.size(); j <s.size();j++)
	 		{if(v[j]=='?')v[j]='a';}
			B = min(B, v);

	  		/*string v=s;
	    	for(int j=0; j<t.size(); j++)
	    	{v[j+i]=t[j];}
	    	//?を置き換え
	 		rep(j,i)//i(挿入開始地点)まで見る
	 		{if(v[j]=='?')v[j]='a';}
	 		for(int j=i+t.size(); j <s.size();j++)
	 		{if(v[j]=='?')v[j]='a';}*/
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/


signed main(){
	
	
	vector<PP> ans_vec;
	
	ll x,y;
	cin >> y >> x;
	
	ll cell[y][x] = {};
	
	rep(i,0,y){
		rep(j,0,x){
			cin >> cell[i][j];
		}
	}
	
	
	rep(i,0,y){
		rep(j,0,x-1){
			if(cell[i][j] % 2 != 0){
				cell[i][j]--;
				cell[i][j+1]++;
				PP p;
				p.fs.fs = i+1;
				p.fs.sc = j+1;
				p.sc.fs = i+1;
				p.sc.sc = j+2;
				ans_vec.push_back(p);
			}
		}
	}
	
	
	rep(i,0,y-1){
		if(cell[i][x-1] % 2 != 0){
			cell[i][x-1]--;
			cell[i+1][x-1]++;
			PP p;
			p.fs.fs = i+1;
			p.fs.sc = x;
			p.sc.fs = i+2;
			p.sc.sc = x;
			ans_vec.push_back(p);
		}
	}
	
	cout << (ll)ans_vec.size() << endl;
	
	rep(i,0,ans_vec.size()){
		cout << ans_vec[i].fs.fs << " " << ans_vec[i].fs.sc << " ";
		cout << ans_vec[i].sc.fs << " " << ans_vec[i].sc.sc << endl;
	}
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 8304
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			ArrayDeque<String> deque = new ArrayDeque<>();
			for(int i = 0 ; i < s.length() ; i++) {
				deque.addLast(s.substring(i, i + 1));
			}
			int q = sc.nextInt();
			boolean asc = true;
			for(int i = 0 ; i < q ; i++) {
				int t = sc.nextInt();
				if(t == 1) {
					asc = !asc;
				} else {
					int f = sc.nextInt();
					String c = sc.next();
					if(f == 1) {
						if(asc) {
							deque.addFirst(c);
						} else {
							deque.addLast(c);
						}
					} else {
						if(asc) {
							deque.addLast(c);
						} else {
							deque.addFirst(c);
						}
					}
				}
			}
			int size = deque.size();
			if(asc) {
				for(int i = 0 ; i < size ; i++) {
					System.out.print(deque.pollFirst());
				}
			} else {
				for(int i = 0 ; i < size ; i++) {
					System.out.print(deque.pollLast());
				}
			}
		}

	}

}


Measured memory_bytes: 172316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

//typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int X, P, Q;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> X >> P;
  Q = 100-P;
  double np = 1+(double)Q/(double)P;
  double ans = 0;
  if (X%2) {
    ans += (P/100.0)*(1+((X-1)/2)*np);
    ans += (1-(P/100.0))*(1+((X+1)/2)*np);
  }
  else {
    ans += (X/2)*np;
  }
  cout << fixed << setprecision(20) << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int flag[50][26];
int getMin(int j,int n)
{
	int minV=50;
	for (int i=0;i<n;i++){
		if (minV>flag[i][j]){
			minV =flag[i][j];
		}
	}
	return minV;
}

int main(int argc, char* argv[])
{
	int n;
	cin>>n;
	string S;

	int i,j;
	for (i=0;i<50;i++){
		for (j=0;j<26;j++){
			flag[i][j]=0;
		}
	}
	int minSLen=50;
	for (i=0;i<n;i++){
		cin>>S;
		size_t sLen=S.length();
		if (minSLen>sLen){
			minSLen=(int)sLen;
		}
		for (j=0;j<sLen;j++){
			flag[i][S[j]-'a']++;
		}
	}
	int MinJ[26];
	minSLen=26;
	for (j=0;j<minSLen;j++){
		MinJ[j] = getMin(j,n);
		for (i=0;i<n;i++){
			flag[i][j]=MinJ[j];
		}
	}
	bool match=false;
	for (j=0;j<minSLen;j++){
		if (MinJ[j]>0){
			for (i=0;i<MinJ[j];i++){
				cout<<char('a'+j);
			}
			match=true;
		}
	}
	if (!match){
		cout<<"";
	}
	cout<<endl;
	return 0;
}

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

int main(){
	int H,N;
	cin >> H >> N;
	vector<pair<int,int>> AB;
	for(int i=0;i<N;i++){
		int a,b;
		cin >> a >> b;
		AB.push_back(make_pair(a,b));
	}
	
	vector<int> dp(H+1,999999999);
	dp[0]=0;
	
	for(int h=0;h<H;h++){
		for(int i=0;i<N;i++){
			int A=AB[i].first,B=AB[i].second;
			if(h+A>=H)dp[H]=min(dp[H],dp[h]+B);
			else dp[h+A]=min(dp[h+A],dp[h]+B);
		}
	}
	cout << dp[H] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int N,m;
    cin >> N;
    m = N;
    vector<int> l,r;
    while(N--){
        int x,y;
        cin >> x;
        cin >> y;
        l.push_back(x);
        r.push_back(y);
        
    }
    
        cout << (accumulate(r.begin(), r.end(), 0) - accumulate(l.begin(), l.end(), 0) + m) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(list(sys.stdin.readline())[:-1])

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def main():
    N,A,B,C,D = LI()
    s = S()

    for i in range(B-1,D-1):
        if s[i] == "#" and s[i+1] == "#":
            return "No"

    if C<D:
        for i in range(A-1,C-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
        return "Yes"

    flag = False
    for i in range(B-2,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            flag = True
    if flag:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 62064
from collections import defaultdict, deque
N, M = map(int, input().split())
used = [True]*N
dic = defaultdict(list)
for i in range(M):
  l, r, d = map(int,input().split())
  l -= 1
  r -= 1
  used[r] = False
  dic[l] += [(r,d)]

dist = [-1]*N
q = deque([])
for i in range(N):
  if used[i]:
    q += [i]
    dist[i] = 0

ans = True
while q:
  e = q.popleft()
  flag = False
  for p, d in dic[e]:
    if dist[p]==-1:
      dist[p] = d+dist[e]
      q += [p]
    elif dist[p]!=dist[e]+d:
      ans = False
      flag = True
      break
  if flag:
    break
if ans:
  if -1 not in dist:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 82008
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((ll)2e7+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

ll X,Y;
ll fact[MAXN];

ll modInverse(ll a)
{
	ll m = MOD;
	ll y = 0, x = 1;
	if (m == 1)
		return 0;
	while (a > 1)
	{
		ll q = a / m;
		ll t = m;
		m = a % m, a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	if (x < 0)
		x += MOD;
	return x;
}

void setup()
{
	fact[0] = 1;
	for (ll i = 1; i < MAXN; ++i)
		fact[i] = (fact[i-1] * i) % MOD;

}


ll C(ll n, ll m)
{
	if (n < m) return 0;
    if (n < 0 || m < 0) return 0;
	
	ll ans = fact[n];
	ll denom = fact[m] * fact[n-m];
	denom %= MOD;

	ans = (ans * modInverse(denom)) % MOD;

	return ans;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	setup();
	cin >> X >> Y;

	if((2*Y - X)%3 or (2*X - Y)%3)
	{
		cout << 0 << endl;
		return 0; 
	}

	ll a = (2*Y - X) / 3;
	ll b = (2*X - Y) / 3;

	ll ans = C(a+b,b);

	cout << fixed << ans << endl;
}

Measured memory_bytes: 156544
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 505
using namespace std;

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
			 tree_order_statistics_node_update> ordered_set;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ ll c = a + b; if(c >= p) c -= p; return c;}
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c;}
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p;}

int a[N][N];

main()
{	
	#ifndef ONLINE_JUDGE
		//freopen("/home/tarun/Desktop/input.txt", "r", stdin);
//		freopen("/home/tarun/Desktop/output.txt", "w", stdout);
	#endif
	sync;
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int n, m, q; cin >> n >> m >> q;
	rep(i, 0, m) {
		int l, r; cin >> l >> r;
		l--, r--;
		a[l][r]++;
	}

	rep(i, 0, n) {
		rep(j, i+1, n) {
			a[i][j] += a[i][j-1];
		}
	}

	rep(i, 0, q) {
		int l, r; cin >> l >> r;
		l--, r--;
		ll ans = 0;
		rep(i, l, r+1) {
			ans += a[i][r];
		}
		cout << ans << '\n';
	}

	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment







Measured memory_bytes: 1920
a, b, c, d = gets.split(" ").map(&:to_i)
n = b - a + 1
cd = c.lcm(d)

a1 = a - 1
nc = (b / c) - (a1 / c)
nd = (b / d) - (a1 / d)
ncd = (b / cd) - (a1 / cd)

puts n - nc - nd + ncd


Measured memory_bytes: 14332
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ha = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var h = ha[0];
        var a = ha[1];

        Console.WriteLine((h + a - 1) / a);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string X, Y;
    map<string, int> map;
    map["A"] = 10;
    map["B"] = 11;
    map["C"] = 12;
    map["D"] = 13;
    map["E"] = 14;
    map["F"] = 15;
    cin >> X >> Y;
    if (map[X] > map[Y]) {
        cout << ">" << endl;
    } else if (map[X] < map[Y]) {
        cout << "<" << endl;
    } else {
        cout << "=" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var W = Number(inputs[0]);
    var H = Number(inputs[1]);
    var x = Number(inputs[2]);
    var y = Number(inputs[3]);
    var r = Number(inputs[4]);


    var x0 = W - x - r;
    var x1 = W - x + r;
    var y0 = H - y - r;
    var y1 = H - y + r;

    if (x0 >= 0 && x1 <= W && y0 >= 0 && y1 <= H) {
        console.log('Yes');
    } else {
        console.log('No');
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15556
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
s.append(1)
a1=1
a2 = a[a1-1]
l=[0]*n
l[0]=1

while l[a2-1] != 1:
    s.append(a2)
    a1 = a2
    a2 = a[a1-1]
    l[a1-1] = 1

loop_num=s.index(a2)
loop=s[loop_num:]
cnt=len(loop)

if k<len(s):
    print(s[k])
else:
    ans = (k-loop_num)%cnt
    print(loop[ans])

Measured memory_bytes: 32092
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int N = 1005;
int dp[N][N];
int32_t main()
{
	fio();
	int n,m;
	cin>>n>>m;
	string s[n];
	for(int i=0;i<n;i++)
		cin>>s[i];
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(i==1 && j==1)
				continue;
			if(s[i-1][j-1]=='#')
				dp[i][j]=0;
			else
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[n][m];
}



Measured memory_bytes: 9216
// D - Derangement
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int in(){int x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	int L = in();
	int ans = 0;
	rp(i, 1, N){
		int R = in();
		if(L == i) ans++;
		else L = R;
	}
	if(L == N) ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	int x=accumulate(all(a),0,[](int p,int q){return p^q;});
	rep(i,n)a[i]=__builtin_ctz(a[i]);
	sort(all(a),greater<int>());
	int ans=0;
	rep(i,n){
	    if((1<<a[i])&x){
	        ans++;
	        x^=(1<<(a[i]+1))-1;
	    }
	}
	if(x){
	    cout<<-1<<endl;
	}else{
	    cout<<ans<<endl;
	}
	return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 2e5+1;
long fact[N], ifact[N], n, k;

long POW(long x, long n){
  if (n == 0) return 1;
  long y = POW(x, n / 2);
  y = y * y % MOD;
  if (n % 2) return x * y % MOD;
  else return y;
}

int main()
{
  fastio;
  cin >> n >> k;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MOD;
  ifact[n] = POW(fact[n], MOD - 2); ifact[0] = 1;
  for (int i = n - 1; i > 0; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
  auto C = [&](int k, int n){
    long res = fact[n] * ifact[k] % MOD;
    res = res * ifact[n - k] % MOD;
    return res;
  };
  long res = 0;
  for (int i = 0; i <= min(n - 1, k); i++){
    res = res + C(i, n) * C(i, n - 1);
    res %= MOD;  
  }
  cout << res;
  return 0;
}

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

const int mod = 1000*1000*1000+7;
int N, K;
int po[102];

int cc[102][10010];
int dp(int idx, int cnt) {
    int &ret = cc[idx][cnt];
    if(ret != -1) return ret;
    if(idx == 0) return ret = 0;

    ret = 0;
    for(int i = 0; idx * i - cnt <= K; i++) {
        int st = max(0, idx * i - cnt);
        int ed = min(idx, min(K + 1, idx * (i + 1) - cnt) - 1);

        if(st > ed) continue;

        ret += 1LL * dp(idx - 1, cnt + i) * (ed - st + 1) % mod;
        ret %= mod;
        ret += 1LL * (mod - i) * (ed - st + 1) % mod * po[idx - 1] % mod;
        ret %= mod;
        ret += 1LL * (st + ed) * (ed - st + 1) / 2 % mod * po[idx - 1] % mod;
        ret %= mod;
    }
    //*
    if(idx + 1 <= K) {
        ret += 1LL * dp(idx - 1, cnt) * (K - idx) % mod;
        ret %= mod;
        ret += 1LL * (idx + 1 + K) * (K - idx) / 2 % mod * po[idx - 1] % mod;
        ret %= mod;
    }
    //*/
    return ret;
}

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

    po[0] = 1;
    for(int i = 1; i < 102; i++) {
        po[i] = 1LL * po[i - 1] * (K + 1) % mod;
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(N, 0));
}


Measured memory_bytes: 4224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int K; cin >> K;
    vector<int> A(K);

    int val = 0;
    rep(i,2*K) {
        val = (val*10+7)%K;
        if (val==0) {
            cout << i+1 << ln;
            return 0;
        }
        if (A[val]) {
            cout << -1 << ln;
            return 0;
        }
        A[val] = 1;
    }
}


Measured memory_bytes: 7140
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 = "";
		if (2*x<=y&&y<=4*x&&y%2==0) {
			result = "Yes";
		} else {
			result = "No";
		}
		System.out.print(result);
		sc.close();
	}
}

Measured memory_bytes: 27088
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;

int mox[] = {0, 0, -1, 1}, moy[] = {-1, 1, 0, 0};
int jar[1003][1003];
char pet[1003][1003];

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
			cin >> pet[i][j];
	}
	queue<ii> q;
	memset(jar, -1, sizeof jar);

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(pet[i][j] == '#')
			{
				jar[i][j] = 0;
				q.push({i,j});
			}
		}
	}
	int mx = 0;
	while(q.size())
	{
		ii u = q.front(); q.pop();
		int x = u.fi, y = u.se;
		mx = max(jar[x][y], mx);
		for(int i = 0; i < 4; i++)
		{
			int _x = x+mox[i];
			int _y = y+moy[i];
			if(jar[_x][_y] == -1 && _x >= 1 && _x <= n && _y >= 1 && _y <= m)
			{
				jar[_x][_y] = jar[x][y]+1;
				q.push({_x,_y});
			}
		}
	}
	cout << mx << "\n";
}










Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  ll N, K;
  cin >> N >> K;
  ll d = N % K;
  ll m = min(d, abs(d-K));
  ll ans = min(m, N);
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 201010;

// 組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] / (fac[k] * fac[n - k]);
}


ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(5);
	ll tmin = INF;
	rep(i, 5) {
		cin >> a[i];
		tmin = min(tmin, a[i]);
	}
	ll res = 4 + (n + tmin - 1) / tmin;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3636
// Devarshi

/*
We will not return to the countless mistakes of the past
I will not relive the failures of the man I once was

Only through dedication will I destroy all preconception

No longer will I let myself be truly satisfied with the standard
We will not return to the countless mistakes of the past

Only through dedication will I destroy all preconception

Let this be
Be the day
Day of my
My declaration
Let this be the day of my declaration

Join me,
Walk with me

Shatter the bonds that tie us
To what we strive to never be

Join me,
Walk with me
*/
#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

int r;
cin>>r;
if(r>=2800) cout<<"AGC";
else if(r>=1200) cout<<"ARC";
else cout<<"ABC";

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N = in(), T = in(), cost = 10000, c, t;

  rep(i, N){
    c = in();
    t = in();
    if(t <= T) cost = min(cost, c);
  }
  if(cost == 10000) cout << "TLE" << endl;
  else cout << cost << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r, g, b;
	cin >> r >> g >> b;
	int sum = r * 100 + g * 10 + b;
	if (sum % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    string s;
    cin>>s;
    if(s[1]=='R')
    {
        s[1]='B';
    }
    else
    {
        s[1]='R';
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3600
#!/usr/bin/ruby
unless Enumerable.method_defined? :tally
	module Enumerable
		def tally
			group_by(&:itself).map{|k,v|[k,v.size]}.to_h
		end
	end
end

gets;p gets.chomp.each_char.tally.map{|k,v|v+1}.reduce(:*)%(10**9+7)-1

Measured memory_bytes: 7548
#define PI 3.14159265359
#define INF 2000000000
#define MAX 500000
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;


int main() {
	string S;
	cin >> S;
	for (int i = 0;i < S.length() - 8;i++)
		cout << S[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl "\n"
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
ll n;
bool check(ll x){
    ll p = n;
    while(p%x==0) p/=x;
    if(p%x==1)
        return 1;
    return 0;
}
int main(){
    cin>>n;
    if(n<10000){
        int i = n;
        int x=i;
        int num = 0;
        for(int j=2;j<=i;j++){
            x = i;
            while(x>=j){
                if(x%j == 0)
                    x/=j;
                else x-=j;
            }
            if(x==1)
                num++;
        }
        cout<<num;
    }else{
        int ans = 0;
        for(int i=2;i<=sqrt(n);i++){
            if(n%i==0){
                if(check(i)) ans ++;
                if(n/i!=i){
                    if(check(n/i)) ans ++;
                }
            }
        }
        n--;
        for(int i=2;i<=sqrt(n);i++){
            if(n%i==0){
                ans++;
                if(n/i!=i) ans++;
            }
        }
        cout<<ans+2<<endl;
    }
}


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

using namespace std;

#define INF 1000000000

using ll = long long;

int main()
{
	int q, h, s, d;
	ll m = 0, c;
	double n;

	scanf("%d %d %d %d", &q, &h, &s, &d);
	scanf("%lf", &n);

	if (s * 2 < d) {
		d = INF;
	}
	if (h * 4 < d) {
		d = INF;
	}
	if (q * 8 < d) {
		d = INF;
	}
	if (h * 2 < s) {
		s = INF;
	}
	if (q * 4 < s) {
		s = INF;
	}
	if (q * 2 < h) {
		h = INF;
	}

	if(d != INF){
		c = ll(n / 2.0);
		m += d * c;
		n -= 2.0 * c;
	}
	if(s != INF){
		c = ll(n / 1.0);
		m += s * c;
		n -= c;
	}
	if (h != INF) {
		c = ll(n / 0.5);
		m += h * c;
		n -= 0.5 * c;
	}
	c = ll(n / 0.25);
	m += q * c;

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,P;
    cin >> N >> P;
    ll cnt0 = 0, cnt1 = 0;

    rep(i,N){
        ll a;
        cin >> a;
        if (a % 2) cnt1++;
        else
            cnt0++;
    }
    if(cnt0==N){
        cout << (P == 1 ? 0 : (1ll << N)) << endl;
        return 0;
    }
    else{
        cout << (1ll << N - 1) << endl;
        return 0;
    }
    

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left

def solve():
    n, m = [int(x) for x in input().split()]
    x = 1900 * m
    y = 100 * (n - m)
    print(2 ** m * (x + y))

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


Measured memory_bytes: 9976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int mmin(int &a, int b) {
	a = min(a, b);
	return a;
}
long long mmin1(long long &a,long long b) {
	a = min(a, b);
	return a;
}
int mmax(int &a, int b) {
	a = max(a, b);
	return a;
}
long long mmax1(long long &a,long long b) {
	a = max(a, b);
	return a;
}
long long po(long long  a, int n,long long p) {
	if (n == 0) {
		return 1 % p;
	}
	long long x = po(a, n / 2, p);
	if (n % 2 == 0) {
		return (x*x) % p;
	}
	return (((x*x) % p)*a) % p;
}
long long inve(long long a, long long p) {
	return po(a, p - 2, p);
}
int main() {
	long long p = (1000 * 1000 * 1000) + 7;
	long long n;
	cin >> n;
	long long kai = 1;
	for (long long i = 1; i <= n; i++) {
		kai *= i;
		kai = kai % p;
	}
	vector<long long> ka(n);
	ka[0] = kai;
	long long sum = kai;
	for (long long i = 1; i < n; i++) {
		ka[i] = (kai*inve(i + 1, p)) % p;
		sum += ka[i];
		sum = sum % p;
	}
	long long ans = 0;
	for (long long i = 1; i <= n; i++) {
		long long a;
		cin >> a;
		ans += (a*sum) % p;
		ans = ans % p;
		if (i != n) {
			sum += ka[i];
			sum -= ka[n - i];
		}
		sum = (sum + p) % p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {

	var s string
	fmt.Scan(&s)

	slice := []string{"a", "i", "u", "e", "o"}

	ans := "consonant"

	for i := 0; i < 5; i++ {
		if s == slice[i] {
			ans = "vowel"
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include<iostream>
#include<array>

using namespace std;

int main(){
    int n,sum = 0,p;
    array<int,100>x;

    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>x.at(i);
        sum = sum + x.at(i);
    }
    p = sum / n;
    if((sum % n)*2 > n){p++;}
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = ans + (x.at(i) - p)*(x.at(i) - p);
    }
    cout<<ans<<endl;
}

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

int main()
{
  string s;cin>>s;
  ll ans=7;
  if(s=="MON")ans=6;
  if(s=="TUE")ans=5;
  if(s=="WED")ans=4;
  if(s=="THU")ans=3;
  if(s=="FRI")ans=2;
  if(s=="SAT")ans=1;
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;

int main() {
    ll a, b, k;
    std::cin >> a >> b >> k;
    for(int i = 1; i <= k; ++i) {
        if(i & 1) {
            b += a / 2;
            a /= 2;
        } else {
            a += b / 2;
            b /= 2;
        }
    }
    std::cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct edge{ int to; ll w; };
using graph = vector<vector<edge>>;

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  vector<ll> c(n);
  graph g(n);

  REP(i, n-1){
    cin >> a[i] >> b[i] >> c[i];
    --a[i]; --b[i];
    g[a[i]].push_back({b[i], c[i]});
    g[b[i]].push_back({a[i], c[i]});
  }

  int q, k; cin >> q >> k;
  k--;

  vector<ll> dis(n, -1);

  dis[k] = 0LL;
  function<void(int)> rec = [&](int v){
    for(const auto& e: g[v]){
      if(dis[e.to] == -1){
        dis[e.to] = dis[v] + e.w;
        rec(e.to);
      }
    }
  };

  rec(k);
  
  REP(i, q){
    int x, y; cin >> x >> y;
    --x; --y;
    cout << dis[x] + dis[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 17408
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

A, B, C, D = ISI()
ans = 0
for i in range(1, 101):
    if A < i <= B and C < i <= D:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import numpy as np

N = int(input())
lh = list(map(int, input().split()))
lz = list()

for i in range(1, N):
    if lh[i-1] >= lh[i]:
        lz.append(1)
    else:
        lz.append(0)

#print(lz)

lz1 = list()

cnt = 0
for i in range(N-1):
    if lz[i] == 1:
        if cnt == 0:
            cnt = 1
        else:
            cnt += 1
    else:
        lz1.append(cnt)
        cnt = 0
lz1.append(cnt)
#print(lz1)
print(max(lz1))

Measured memory_bytes: 23372
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    Int n;
    cin >> n;

    Int ans = 0;
    for (Int k = 1; k <= n; k++) {
        ans += k * Floor(n, k) * Floor(k + n, k) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k - 1] = (s[k - 1] - 'A' + 'a');
  cout << s << en;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

int main() {
	int n, x, y = 0;
	std::cin >> n;
	while (n != 0 && std::cin >> x) {
		n--; x == 2 ? y++ : 0;
		if (x % 2 != 0) {
			int  _ = 0;
			for (int num = 3, k = sqrt(x) + 1; num < k && _ == 0; num++)
				x % num == 0 ? _++ : 0; 
			_ == 0 ? y++ : 0;
		}
	}
	std::cout << y << "\n";
	return 0;
}


Measured memory_bytes: 3088
from itertools import groupby
n = int(input())
P = list(map(int, input().split()))

j = [False] * (n+1)
for i, p in enumerate(P):
    if i+1 == p:
        j[i] = True

cnt = 0
gr = groupby(j)
for key, group in gr:
    l = len(list(group))
    if key and l != 1:
        cnt += l//2 if l % 2 == 0 else l//2+1
    elif key:
        cnt += 1

print(cnt)

Measured memory_bytes: 91140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int ans=0;
  string s, t;
  cin >> s >> t;
  rep(i, 0, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
n,y=map(int,raw_input().split())
for i in range(2001):
	for j in range(2001):
		foo=y-10000*i-5000*j
		z=1000
		if foo%z==0 and i+j+foo/z==n and foo/z>=0:
			print i,j,foo/z
			exit(0)
print -1,-1,-1

Measured memory_bytes: 2692
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

count=0
if(a[0]>x):
    count=a[0]-x
    a[0]=x
    
for ind,i in enumerate(a):
    if(ind==len(a)-1):
      break
    s=i+a[ind+1]
    if(s>x):
        count+=s-x
        a[ind+1]-=s-x
        #s=i+a[ind+1]
print(count)
    


Measured memory_bytes: 14252
import java.util.Scanner;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {

	private static final Integer SEVEN = 7;

	public static void main(String[] args) throws ScriptException {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] abcd = scanner.next().toCharArray();
			for (int i = 0; i < (1 << abcd.length); i++) {
				if (ok(abcd, i)) {
					System.out.println(toFormula(abcd, i) + "=" + SEVEN);
					return;
				}
			}
		}
	}

	/**
	 * abcdと'+'か'-'を表す二進数で数式を組み立てて、結果が7かどうかを判定
	 * 
	 * @param abcd
	 * @param n    '+'か'-'を表す二進数
	 * @return 結果が7かどうか
	 */
	private static boolean ok(char[] abcd, int n) throws ScriptException {
		ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
		return SEVEN.equals(engine.eval(toFormula(abcd, n)));
	}

	/**
	 * abcdと'+'か'-'を表す二進数で数式を組み立てる
	 * 
	 * @param abcd
	 * @param n    '+'か'-'を表す二進数
	 * @return a?b?c?d の数式
	 */
	private static String toFormula(char[] abcd, int n) {
		StringBuilder result = new StringBuilder();
		for (char c : abcd) {
			result.append(c);
			result.append((1 == (n & 1)) ? '+' : '-');
			n >>= 1;
		}
		// 最後の文字を削除
		result.deleteCharAt(result.length() - 1);
		return result.toString();
	}
}


Measured memory_bytes: 62060