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

int n, x, ans;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    while(n-- && cin >> x)
        a.push_back(x-1);
    for(int i = 0 ; i < a.size() ; i++)
        if(a[i] == i){
            swap(a[i], a[i+1]);
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
fun main(args: Array<String>){
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    var draw = IntArray(0)
    for (i in 0 until n){
        draw += IntArray(a[i]){i+1}
    }

    val list = mutableListOf<IntArray>()
    for (i in 0 until h){
        if(i % 2 == 0){
            list.add(draw.slice(i*w until (i+1)*w).toIntArray())
        }else{
            list.add(draw.slice(i*w until (i+1)*w).reversed().toIntArray())
        }
    }

    list.forEach {
        println(it.joinToString(separator = " "))
    }
}

Measured memory_bytes: 94932
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s = sc.next();
        boolean[] isO = new boolean[N];
        for (int i = 0; i < N; i++) {
            isO[i] = s.charAt(i) == 'o';
        }
        boolean[] first = {true, true, false, false};
        boolean[] second = {true, false, true, false};
        for (int i = 0; i < 4; i++) {
            boolean[] isS = new boolean[N];
            isS[0] = first[i];
            isS[1] = second[i];
            for (int j = 2; j < N; j++) {
                boolean tmp = isS[j - 1] ^ isO[j - 1];
                if (isS[j - 2]) {
                    tmp = !tmp;
                }
                isS[j] = tmp;
            }
            boolean tmp1 = isS[N - 1] ^ isO[N - 1];
            if (isS[N - 2]) {
                tmp1 = !tmp1;
            }
            boolean tmp2 = isS[0] ^ isO[0];
            if (isS[N - 1]) {
                tmp2 = !tmp2;
            }
            if (isS[0] == tmp1 && isS[1] == tmp2) {
                for (int j = 0; j < N; j++) {
                    System.out.print(isS[j] ? 'S' : 'W');
                }
                System.out.println();
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 36352
// C++ program to construct array from
// XOR of elements of given array
#include <bits/stdc++.h>
using namespace std;

// function to construct new array
void constructXOR(int A[], int n)
{
	// calculate xor of array
	int XOR = 0;
	for (int i = 0; i < n; i++)
		XOR ^= A[i];

	// update array
	for (int i = 0; i < n; i++)
		A[i] = XOR ^ A[i];
}

// Driver code
int main()
{
	long long int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }

	constructXOR(A, n);

	// print result
	for (int i = 0; i < n; i++)
		cout << A[i] << " ";
	return 0;
}


Measured memory_bytes: 4344
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> v(n, 0);
    for (ll i = 0; i < q; i++)
    {
        ll temp;
        cin >> temp;
        v[temp - 1] += 1;
    }

    for (ll i = 0; i < n; i++)
    {
        if (v[i] + k - q > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    
}

Measured memory_bytes: 1408
#coding utf-8
from operator import itemgetter
N=int(input())
AB=[[int(i) for i in input().split()+[0]] for i in range(N)]
C=[0 for i in range(N)]


AB.sort(key=itemgetter(1))
time=0
ans=0
for i in range(N):
  time+=AB[i][0]
  if time>AB[i][1]:
    ans=1
    break

if ans==0:
  print("Yes")
else:
  print("No")

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

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;

int n,m;

ll x[100001];
ll y[100001];
ll sumx[100001];
ll sumy[100001];

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

  for(int i = 0; i < n; i++) cin >> x[i];
  for(int j = 0; j < m; j++) cin >> y[j];
  
  sumx[0] = x[0];
  sumy[0] = y[0];

  for(int i = 1; i < n; i++) sumx[i] = sumx[i-1] + x[i];
 
  for(int i = 1; i < m; i++) sumy[i] = sumy[i-1] + y[i];
  

  ll tmp1 = 0;
  ll tmp2 = 0;

  for(int i = 1; i < n; i++) tmp1 += (sumx[n-1] - sumx[i-1]) - (n - i) * x[i-1];
  for(int i = 1; i < m; i++) tmp2 += (sumy[m-1] - sumy[i-1]) - (m - i) * y[i-1];
   

  cout << (tmp1 % mod) * (tmp2 % mod) % mod  << endl;
}


Measured memory_bytes: 3328
#include<iostream>
//#include<CastingInterop.h>
#include<string>
using namespace std;

int main()
{
    char arr[3];
    int arr1[3];
    string y;
    for (int i = 0; i < 3; i++)
    {
        cin >> arr[i];
    }
    string s[1000];
    for (int i = 0; i < 3; i++)
    {
        s[i] = arr[i];
        
    }
    string w;

    for (int i = 0; i < 3; i++)
    {
        w += s[i]; 
    }

    //cout << s[0];
    //cout << w;
    int num = stoi(w);
    //cout << num<<endl ; 
    if (num % 4 == 0)
        cout << "YES";
    else
        cout << "NO";
}

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

typedef long long ll;
const int N = 3e3;
const int mod = 998244353;
int dp[N+100][N+100],S,A[N+100],n;

int solve(int pos,int total)
{
	if(total==S){
		return n+2-pos;
	}
	if(pos==n+1){
		return 0;
	}
	if(total>S){
		return 0;
	}
	if(dp[pos][total]!=-1){
		return dp[pos][total];
	}
	int sum = 0;
	sum = (sum+solve(pos+1,total+A[pos]))%mod;
	sum = (sum+solve(pos+1,total))%mod;
	return dp[pos][total] = sum;
}
int main()
{
	memset(dp,-1,sizeof dp);
	scanf("%d%d",&n,&S);
	for(int i=1;i<=n;i++){
		scanf("%d",A+i);
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ll cur = (1ll*solve(i+1,A[i])*i)%mod;
		ans = (ans+cur)%mod;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 41400
#include <iostream>
#include <time.h>
#include <string>

using namespace std;

int main(){
  int y,m,d;
  char ch1,ch2;
  cin >> y>>ch1>>m>>ch2>>d;
  cout << (m<=4 ? "Heisei" : "TBD") << endl;
  return 0;
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    lli n, k, x, ans=INF ;
    vlli left, right ;
    cin>> n >> k ;
    for(int i=0 ; i<n ; i++)
      {
        cin>> x ;
        if(x>0) right.pb(x) ;
        else if(x<0) left.pb(-x) ;
        else k-- ;
      }
    if(k<=0) return cout<< 0, 0 ;
    reverse(all(left)) ;
    if(left.size()>=k) ans=min(ans, left[k-1]) ;
    if(right.size()>=k) ans=min(ans, right[k-1]) ;
    for(int i=0 ; i<right.size() ; i++) if(k-i-2>=0 && k-i-2<left.size()) ans=min({ans, 2*right[i]+left[k-i-2], right[i]+2*left[k-i-2]}) ;
    cout<< ans ;
  }


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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;

string s[1000];
struct Matrix{
	vector< vector< int > > v;
	int n, m;
	Matrix(int _n, int _m, int x = 0){
		n = _n;
		m = _m;
    	v.resize(n, vector< int > (m, 0) );
    	if(x){
    		cerr << n << " " << m << endl;
    		assert(n == m);
    		for(int i = 0; i < n; i++)
    			v[i][i] = 1;
    	}
    }

	Matrix operator *(Matrix a){
		if(m != a.n)
			assert(0);
		Matrix res(n, a.m);
		for(int i = 0; i < res.n; i++)
			for(int j = 0; j < res.m; j++)
				for(int q = 0; q < m; q++)
					res.v[i][j] = (res.v[i][j] + 1ll * v[i][q] * a.v[q][j]) % mod;
		return res;
	}
	void print(){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++)
				cerr << v[i][j] << " ";
			cerr << endl;
		}
	}
};
ll n, m, k, gn, gm, cnt;   
ll binpow(ll x, ll p){
	ll res = 1;
	while(p){
		if(p & 1)
			res = res * x % mod;
		x = x *  x % mod;
		p >>= 1;
	}
	return res;
}

Matrix binpow(Matrix x, ll p){
	Matrix res(x.n, x.m, 1);
	while(p){
		if(p & 1)
			res = res * x;
		x = x *  x;
		p >>= 1;
	}
	return res;
}
int main(){    
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
    	cin >> s[i];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(s[i][j] == '#')
				cnt++; 
	for(int i = 0; i < n; i++)
		if(s[i][0] == '#' &&  s[i][m - 1] == '#')
			gn++;
	for(int i = 0; i < m; i++)
		if(s[0][i] == '#' &&  s[n - 1][i] == '#')
			gm++;
	if(gn && gm)
		cout << 1, exit(0);
	if(!gn && !gm)
		cout << binpow(cnt, k - 1), exit(0);
	ll a, b, c;
	if(gn){
		a = cnt;
		c = gn;
		for(int i = 0; i < n; i++)
			for(int j = 1; j < m; j++)
				if(s[i][j - 1] == '#' && s[i][j] == '#')
					b++;
	}else{
		a = cnt;
		c = gm;
		for(int i = 1; i < n; i++)
			for(int j = 0; j < m; j++)
				if(s[i - 1][j] == '#' && s[i][j] == '#')
					b++;
	}
	Matrix mt(2, 2);
    Matrix t(2, 1);

    mt.v[0][0] = a;
	mt.v[0][1] = mod - 1;
	mt.v[1][1] = c;
	//mt.print();
	mt = binpow(mt, k - 1);
	
	//mt.print();
	
	cout << (mt.v[0][0] + 1ll * mt.v[0][1] * b) % mod;
	return 0;
}


Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func checkRune(r rune) bool {
	d := []rune{'A', 'T', 'C', 'G'}
	for _, x := range d {
		if x == r {
			return true
		}
	}
	return false
}

func getMaxLen(s string) (l int) {
	l = 0
	tmp := 0
	for _, r := range s {
		if checkRune(r) {
			tmp++
			if tmp > l {
				l = tmp
			}
		} else {
			tmp = 0
		}
	}
	return
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(getMaxLen(s))
}


Measured memory_bytes: 512
y,x=map(int,input().split())
a=["."+input()+"." for i in range(y)]
a=["."*(x+2)]+a+["."*(x+2)]
ans=[]
anss=""
ansss=0
for j in range(1,y+1):
    for i in range(1,x+1):
        if a[j][i]=="#":
            anss+="#"
        else:
            if a[j+1][i]=="#":
                ansss+=1
            if a[j-1][i]=="#":
                ansss+=1
            if a[j][i+1]=="#":
                ansss+=1
            if a[j][i-1]=="#":
                ansss+=1
            if a[j-1][i-1]=="#":
                ansss+=1
            if a[j+1][i-1]=="#":
                ansss+=1
            if a[j+1][i+1]=="#":
                ansss+=1
            if a[j-1][i+1]=="#":
                ansss+=1
            
            anss+=str(ansss)
            ansss=0
    print(anss)
    anss=""

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//最大公約数
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  ll r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

//セグメント木
//全て添字で扱うこと
template<typename T>
struct segment_tree {
  ll n; //vのサイズ
  ll m = 1; //葉の数
  vector<T> v;
  T id_e; //単位元

  //二項演算
  T seg_func(T a, T b) {
    if (a == -1) return b;
    if (b == -1) return a;
    return gcd(a, b);
  }

  //初期化関数
  void init(vector<T> a, T b) {
    id_e = b;
    while (m < a.size()) m *= 2;
    n = 2 * m - 1;
    vector<T> w(n);
    v = w;
    for (ll i = 0; i < a.size(); i++) v[m - 1 + i] = a[i];
    for (ll i = a.size(); i < m; i++) v[m - 1 + i] = id_e;
    for (ll i = m - 2; i >= 0; i--) {
      v[i] = seg_func(v[2 * i + 1], v[2 * i + 2]);
    }
  }

  //値の更新
  void change(ll a, T b) {
    a += m - 1;
    v[a] = b;
    while ((a - 1) / 2 != a) {
      a = (a - 1) / 2;
      v[a] = seg_func(v[2 * a + 1], v[2 * a + 2]);
    }
  }

  //区間和用の補助関数
  T subsub(ll a, ll b, ll cur, ll l, ll r) {
    if (v[cur] == id_e) return v[cur];
    if (a <= l && r <= b) return v[cur];
    if (r < a || b < l) return id_e;
    if (l < r) {
      return seg_func(
        subsub(a, b, 2 * cur + 1, l, (l + r) / 2),
        subsub(a, b, 2 * cur + 2, (l + r) / 2 + 1, r)
      );
    }
  }

  //区間[a, b]の和
  T subsum(ll a, ll b) {
    if (a == b) return v[m - 1 + a];
    T ans = id_e;
    ll cur = 0, l = 0, r = m - 1;
    ans = seg_func(ans, subsub(a, b, cur, l, r));
    return ans;
  }

  //自然数の場合，O(logN)でpush/pop及びランダムアクセスが可能な，常にソートされた配列として扱える
  /*ll submin(ll x, ll cur, ll l, ll r, ll flag) {
    if (l == r) return l;
    if (v[cur] == x) flag = 1;
    if (flag == 1) {
      if (v[2 * cur + 2] > 0) {
        return submin(x, 2 * cur + 2, (l + r) / 2 + 1, r, flag);
      }
      else {
        return submin(x, 2 * cur + 1, l, (l + r) / 2, flag);
      }
    }
    else {
      if (v[2 * cur + 1] == 0) {
        return submin(x, 2 * cur + 2, (l + r) / 2 + 1, r, flag);
      }
      if (v[2 * cur + 2] == 0) {
        return submin(x, 2 * cur + 1, l, (l + r) / 2, flag);
      }
      if (v[2 * cur + 1] >= x) {
        return submin(x, 2 * cur + 1, l, (l + r) / 2, flag);
      }
      else {
        return submin(x - v[2 * cur + 1], 2 * cur + 2, (l + r) / 2 + 1, r, flag);
      }
    }
  }*/

  //x番目に小さい要素を求める
  /*ll x_th_min(ll x) {
    ll cur = 0, l = 0, r = m - 1, flag = 0;
    return submin(x, cur, l, r, flag);
  }*/
};

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

  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];

  segment_tree<ll> seg;
  seg.init(a, -1);

  priority_queue<ll> ans;
  for (ll i = 0; i < n; i++) {
    seg.change(i, -1);
    ans.push(seg.subsum(0, n - 1));
    seg.change(i, a[i]);
  }
  cout << ans.top() << endl;
}

Measured memory_bytes: 5888
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <ll> v(n);
    for (ll &x : v) cin >> x;
    sort(v.begin(), v.end());
    vector <ll> sum(n, 0);
    sum[0] = v[0]%MOD; 
    for (int i = 1; i < n; i++) {
        sum[i] = (sum[i-1] + v[i])%MOD;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += ((v[i]%MOD) * ((sum[n-1]-sum[i]+MOD)%MOD))%MOD;
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;
    return 0;
}




Measured memory_bytes: 6300
n_max = int(input())

num_ans = 0
for n in list(range(1,n_max+1,2)):
    n_ori = n
    yaku = []
    for k in range(3,100):
        if n%k == 0:
            n = n/k
            yaku.append(k)

    ans = 2**len(yaku)
    waru = [yaku.count(y) for y in yaku]
    for w in waru:
        ans/=w
    if ans == 8:
        num_ans += 1
#     print(n_ori,ans)
print(num_ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[5000000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 5000000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int x, y;
	cin >> x >> y;
	if (x > y)  swap(x, y);
	int a = x * 2;
	if (a < y || (x + y) % 3) {
		cout << 0 << endl;
		return 0;
	}
	a = ((x + y) / 3 - (a - y) / 3);
	int b = (x + y) / 3 - a;
	cout << comb((b + a), a) << endl;
}

Measured memory_bytes: 39296
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int main() {

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

  ll A, B, V, W, T;
  cin>>A>>V>>B>>W>>T;

  if(B < A) B = A + (A-B);

  A += V*T;
  B += W*T;
  if(A >= B) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;



  return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

struct State {
  int prev;
  int now;
  int vel; // 到着時
  double e_time;
  
  bool operator < (const State &s) const {
    return e_time > s.e_time;
  }
  
  State() {}
  State(int p, int n, int v, double t) :
    prev(p), now(n), vel(v), e_time(t) {}
};

struct Edge {
  int to;
  int cost;
  int lim;
  
  Edge() {}
  Edge(int t, int c, int l) : to(t), cost(c), lim(l) {}
};

const double Inf = 1<<23;
int N, M;
vector<Edge> edges[30];
double G_time[31][30][31]; // u, v, vel -> e_time

double dijkstra(int s, int g) {
  
  fill(G_time[0][0], G_time[30][30], Inf);
  priority_queue<State> pq;
  
  pq.push(State(s, s, 0, 0.0));
  G_time[s][s][0] = 0.0;
  
  while(!pq.empty()) {
    const State st = pq.top(); pq.pop();
    
    if(G_time[st.prev][st.now][st.vel] < st.e_time) {
      continue;
    }
    
    if(st.now == g && st.vel == 1) {
      return st.e_time;
    }
    
    for(int i=0; i<edges[st.now].size(); i++) {
      const Edge &e = edges[st.now][i];
      
      if(e.to == st.prev) continue;
      
      for(int dvel = -1; dvel <= 1; dvel ++) {
	int nvel = st.vel + dvel;
	// 速度制限
	if(1 <= nvel && nvel <= e.lim) {
	  double ntime = st.e_time + (double)e.cost / nvel;
	  if(G_time[st.now][e.to][nvel] > ntime) {
	    G_time[st.now][e.to][nvel] = ntime;
	    pq.push(State(st.now, e.to, nvel, ntime));
	  }
	}
	
      }
    }
  }
  
  return 42;
}

int main() {
  int s, g;
  
  while(cin >> N >> M && (N|M)) {
    cin >> s >> g;
    s --, g --;
    
    for(int i=0; i<N; i++)
      edges[i].clear();
    
    for(int i=0; i<M; i++) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      x --, y --;
      edges[x].push_back(Edge(y, d, c));
      edges[y].push_back(Edge(x, d, c));
    }
    
    double ans = dijkstra(s, g);
    if(ans == 42) {
      cout << "unreachable" << endl;
    } else {
      printf("%.5lf\n", ans);
    }
  }
  
  return 0;
}

Measured memory_bytes: 1980
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    ll i;
    cin >> N;
    ll a;
    for(i=0;i<N;i++){
      cin >> a;
      if(a%2==1){
        cout << "first";
        return 0;
      }
    }
    cout << "second";
    return 0;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;
using Graph = vector<vector<int>>;

int main()
{
    int n, q;
    cin >> n >> q;
    Graph g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> x(n, 0);
    for (int i = 0; i < q; i++)
    {
        int p, _x;
        cin >> p >> _x;
        p--;
        x[p] += _x;
    }

    vector<i64> dist(n, -1);
    queue<int> que;
    dist[0] = x[0];
    que.push(0);
    while (!que.empty())
    {
        int v = que.front();
        que.pop();

        for (auto &&nv : g[v])
        {
            if (dist[nv] != -1)
                continue;
            dist[nv] = dist[v] + x[nv];
            que.push(nv);
        }
    }

    for (auto &&d : dist)
    {
        cout << d << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 17140
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
l = 0
 
def pattern(a, b, c, x):
	if x == 0:
		return 1
	else:
		if (500 * a + 100 * b + 50 * c < x):
			return 0
		elif (x >= 500) and (a >= 1):
			return pattern(a - 1, b, c, x - 500) + pattern(0, b, c, x)
		elif (x >= 100) and (b >= 1):
			return pattern(a, b - 1, c, x - 100) + pattern(a, 0, c, x)
		elif (x >= 50) and (c >= 1):
			return pattern(a, b, c - 1, x - 50) + pattern(a, b, 0, x)
		else:
			return 0
 
ans = pattern(a, b, c, x)
 
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
struct UnionFind {
    public:
    vector<int> par;
    UnionFind(int n){
        par=vector<int>(n,-1);
    }
    int root(int x){
        if(par[x]<0)return x;
    return par[x]=root(par[x]);
    }
    bool issame(int x,int y){
        return root(x)==root(y);
    }
    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

signed main(){
    int N,M;cin>>N>>M;
    int p[N];
    REP(i,N)cin>>p[i];
    UnionFind uf(N);
    REP(i,M){
        int a,b;cin>>a>>b;a--;b--;
        uf.merge(a,b);
    }
    int ans=0;
    REP(i,N){
        if(uf.issame(i,p[i]-1))ans++;
    }
    cout<<ans<<endl; 
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
 
int main(int argc, char** argv) {
    int n;
    while(cin >> n) {
        int count = 0;
        for(int a=0; a<=9; a++) {
            for(int b=0; b<=9; b++) {
                for(int c=0; c<=9; c++) {
                    for(int d=0; d<=9; d++) {
                        if(a+b+c+d == n) {
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int table[8][8] = {
    {0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 300, 500, 600, 700, 1350, 1650},
    {0, 6, 0, 350, 450, 600, 1150, 1500},
    {0, 13, 7, 0, 250, 400, 1000, 1350},
    {0, 18, 12, 5, 0, 250, 850, 1300},
    {0, 23, 17, 10, 5, 0, 600, 1150},
    {0, 43, 37, 30, 25, 20, 0, 500},
    {0, 58, 52, 45, 40, 35, 15, 0},
};

int check(int h, int m)
{
    if (17 < h && h < 19) return 0;
    if (h == 17 && m >= 30) return 0;
    if (h == 19 && m <= 30) return 0;
    return -1;
}

int main(void)
{
    int s;

    while (scanf("%d", &s), s != 0){
        int h[2], m[2];
        int e;

        scanf("%d %d", h, m);
        scanf("%d", &e);
        scanf("%d %d", h + 1, m + 1);
        if (s > e){
            int t = s;
            s = e;
            e = t;
        }
        if ((check(h[0], m[0]) == 0 || check(h[1], m[1]) == 0) && table[e][s] <= 40){
            int pay = table[s][e] / 2;
            if (pay % 50 != 0) pay += 25;
            printf("%d\n", pay);
        }
        else {
            printf("%d\n", table[s][e]);
        }
    }

    return 0;
}

Measured memory_bytes: 600
import sys
input=sys.stdin.readline


def solve():
    N = int(input())
    l = [tuple(map(int, input().split())) for i in range(N)]
    l.sort(key=lambda x:(x[0], -x[1]))

    #1 [lmax, rmin] [*, *]
    #2 [lmax, *] [*, rmin]

    lmax = 0
    rmin = 10**12
    a, b = 0, 0

    for i in range(N):
        if lmax < l[i][0]:
            lmax = l[i][0]
            a = i
        if rmin > l[i][1]:
            rmin = l[i][1]
            b = i

    #1
    ans1 = 0
    for i in range(N):
        ans1 = max(ans1, max(l[b][1]-l[a][0]+1, 0)+max(l[i][1]-l[i][0]+1, 0))

    #2
    ans2 = 0
    p = 10**18
    for i in range(1, N)[::-1]:
        p = min(p, l[i][1])
        ans2 = max(ans2, max(l[b][1]-l[i-1][0]+1, 0)+max(p-l[a][0]+1, 0))

    ans = max(ans1, ans2)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 90620
//The new goal: to learn  GRAPHS  & DYNAMIC PROGRAMMNING during the summer, on God`s will
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;

string s,t;
int c;

int main() {
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3824
# -*- coding: utf-8 -*-
# @Author: WA_King
# @Date:   2019-04-03 19:35:31
# @Last Modified by:   lcw
# @Last Modified time: 2019-09-02 13:50:55
a=''.join(input().split())
b=''.join(input().split())
ans=0
for i in range(len(a)):
	if a[i]==b[i]:
		ans+=1
print(ans)

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

using namespace std;

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

    int h = S / 3600;
    int m = S % 3600 / 60;
    int s = S % 60;

    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> v(n, 0);
    for(int i=0; i<n; i++) {
        scanf("%d", &v[i]);
        v[i] -= i + 1;
    }
    sort(v.begin(), v.end());
    int mid = v[v.size() / 2];
    long long res = 0;
    for(int i=0; i<v.size(); i++){
        res += abs(v[i] - mid);
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 1024
import numpy as np
N, H = map(int, input().split())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
max_A = max(A)
B = np.array(B)
B.sort()
# print('B', B, max_A)
idx = np.searchsorted(B, max_A)
# print('idx', idx)
subset = B[idx:][::-1]
# print('subset', subset)

cumsum = subset.cumsum()
# print('cumsum', cumsum)
if cumsum[-1] < H:
    ans = ((H - cumsum[-1]) + max_A - 1) // max_A + len(subset)
    print(ans)
else:
    idx = np.searchsorted(cumsum, H)
    ans = idx + 1
    print(ans)


Measured memory_bytes: 20836
#include <stdio.h>

int main(void)
{
  int N, Y;
  scanf("%d %d", &N, &Y);
  for(int ten = 0; ten <= N; ten++){
    for(int five = 0; five <= N-ten; five++){
      int one = N-ten-five;
      if(ten*10+five*5+one == Y/1000){
        printf("%d %d %d\n", ten, five, one);
        return 0;
      }
    }
  }
  printf("%d %d %d\n", -1, -1, -1);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
class segtree
{
public:
	int ko[1000000][2];
	int pt;
	ll ans;
	void init()
	{
		ko[0][0] = ko[0][1] = -1;
		pt = 1;
		ans = 0;
	}
	void add(string s)
	{
		int now = 0;
		for (int i = 0; i < s.size(); i++)
		{
			if (ko[now][s[i] - '0'] == -1)
			{
				ko[now][s[i] - '0'] = pt;
				ko[pt][0] = ko[pt][1] = -1;
				pt++;
			}
			now = ko[now][s[i] - '0'];
		}
	}
	void dfs(int node, ll len)
	{
		for (int i = 0; i < 2; i++)
		{
			if (ko[node][i] == -1)ans ^= len&-len;
			else dfs(ko[node][i], len - 1);
		}
	}
};
segtree tree;
int main()
{
	tree.init();
	int num;
	ll len;
	scanf("%d%lld", &num, &len);
	for (int i = 0; i < num; i++)
	{
		string s;
		cin >> s;
		tree.add(s);
	}
	tree.dfs(0, len);
	if (tree.ans == 0)printf("Bob\n");
	else printf("Alice\n");
}

Measured memory_bytes: 3868
#include <iostream>

using namespace std;

int main()
{
  long long N, M;
  cin >> N >> M;

  if (N == 1 && M == 1) cout << 1 << endl;
  else if (N == 1) cout << (M - 2) << endl;
  else if (M == 1) cout << (N - 2) << endl;
  else cout << (N - 2)*(M - 2) << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
x = list(map(int, input().split()))
if N > M:
    print(0)
    exit()
x.sort()
y = [x[i] - x[i - 1] for i in range(1, len(x))]
y_sort = sorted(y, reverse=True)
z = [y_sort[i] for i in range(N - 1)]
print(sum(y) - sum(z))


Measured memory_bytes: 13968
from collections import Counter

n, k, l = map(int, input().split())
ps = [tuple(map(int, input().split())) for _ in range(k)]
rs = [tuple(map(int, input().split())) for _ in range(l)]

def root(n, u):
    if u[n] == n:
        return n
    u[n] = root(u[n], u)
    return u[n]

union1 = {x:x for x in range(1, n+1)}
for p, q in ps:
    union1[root(p, union1)] = root(q, union1)

union2 = {x:x for x in range(1, n+1)}
for r, s in rs:
    union2[root(r, union2)] = root(s, union2)

gs = {x:(root(x, union1), root(x, union2)) for x in range(1, n+1)}
c = Counter(gs.values())
print(' '.join(str(c[gs[x]]) for x in range(1, n+1)))

Measured memory_bytes: 119600
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

static const D = false;

char isDigit(char c) {
    return '0' <= c && c <= '9';
}

string rmSpace(string s) {
    string ret;
    foreach (c; s) {
        if (c == ' ') continue;
        ret ~= c;
    }
    return ret;
}

void main() {
    string _;
    while (_ = readln.chomp, _ != "#") {
        struct Parser {
            int index;
            string s;
            static const ulong C = 1000000007;
            this(string s) {
                this.s = s;
                this.index = cast(int)s.length - 1;
            }
            ulong expr() {
                ulong x = term();
                if (index == -1 || s[index] == '<') return x % C;
                assert(s[index] == '>'); index--;
                assert(s[index] == '>'); index--;
                ulong y = expr();
                //writeln("expr(): ", y, " ", x);
                if (x > 63) return 0;
                return y >> x;
            }
            ulong term() {
                static if (D) "term".writeln(index);
                if (s[index] == '>') {
                    index--;
                    ulong x = expr();
                    assert(s[index] == '<'); index--;
                    assert(s[index] == 'S'); index--;
                    return x * x % C;
                } else {
                    assert(s[index].isDigit);
                    return number();
                }
            }
            ulong number() {
                assert(s[index].isDigit);
                int i = index - 1;
                while (i >= 0 && s[i].isDigit) i--;
                //s[i + 1 .. index + 1].writeln;
                ulong ret = to!ulong(s[i + 1 .. index + 1]);
                index = i;
                return ret % C;
            }
        }
        auto parser = Parser(rmSpace(_));
        parser.expr().writeln;
    }
}

Measured memory_bytes: 7352
import sys
from collections import Counter

tmp = sys.stdin.readline().strip()
directions = ""
pre = ""
for c in tmp:
    if c == pre:
        continue
    directions += c
    pre = c
    
counter = Counter(directions)
# print(counter)

d = {"S": 0, "E": 0, "N": 0, "W": 0}
for t, count in counter.items():
    d[t] = count

sn = False
if 0 < d["S"] and 0 < d["N"] and abs(d["S"] - d["N"]) < 2:
    sn = True
if d["S"] == d["N"]:
    sn = True

ew = False
if 0 < d["E"] and 0 < d["W"] and abs(d["E"] - d["W"]) < 2:
    ew = True
if d["E"] == d["W"]:
    ew = True

if sn and ew:
    print("Yes")
else:
    print("No")

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

int main(){
  int prev=10,n,c=0;
  string str;
  char s,buf='\0';
  char keymap[9][5]={ {'.',',','!','?',' '},
		      {'a','b','c','\0','\0'},
		      {'d','e','f','\0','\0'},
		      {'g','h','i','\0','\0'},
		      {'j','k','l','\0','\0'},
		      {'m','n','o','\0','\0'},
		      {'p','q','r','s','\0'},
		      {'t','u','v','\0','\0'},
		      {'w','x','y','z','\0'}};
  cin>>n;

  while(n--){
    cin>>str;
    for(int i=0;i<str.length();i++){
      s=str.at(i);
      if(c!=0&&s=='0')cout<<buf,c=0,buf=0;
      switch (s){
      case '1':
	buf=keymap[0][(c++)%5];
	break;
      case '2':
	buf=keymap[1][(c++)%3];
	break;
      case '3':
	buf=keymap[2][(c++)%3];
	break;
      case '4':
	buf=keymap[3][(c++)%3];
	break;
      case '5':
	buf=keymap[4][(c++)%3];
	break;
      case '6':
	buf=keymap[5][(c++)%3];
	break;
      case '7':
	buf=keymap[6][(c++)%4];
	break;
      case '8':
	buf=keymap[7][(c++)%3];
	break;
      case '9':
	buf=keymap[8][(c++)%4];
	break;
      }
    }
    buf=0;
    cout<<endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cctype>
#include<stdio.h>
#include<string>
using namespace std;

int main(){
    int len;
    string number;

    while(true){
        cin >> number;
        if(number == "0"){
            break;
        }

        int ans = 0;
        len = number.length();
        for(int i=0;i<len;i++){
            ans += number[i] - '0';
        }

        cout << ans << endl;
    }


    
    return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ( (a == b && a != c) || (b == c && a != b ) || ( a == c && a != b )) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  double l;
  std::cin >> l;

  cout << fixed << setprecision(10) << pow(l/3,3)<< endl;
  return 0;
}


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

using namespace std;

int main()
{
    long long N,K;
    cin >> N >> K;
    long long result = 0;
    for(long long i = K;i <= N + 1;i++){
        result += (N - i + 1) * i  + 1;
        result %= 1000000007;
    }
    cout << result <<endl;
    return 0;
}

Measured memory_bytes: 3652
import math

a,b,x= map(int, input().split())

if x<a*a*b/2:
    a2= x/(a*b/2)
    print(math.degrees(math.atan(b/a2)))
else:
    a3=(a*a*b-x)/(a*a/2)
    print(math.degrees(math.atan(a3/a)))


Measured memory_bytes: 9316
n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
score1 = []

def cal_score(num):
    return 1 + 0.5 * (num - 1)

score.append(cal_score(List[0]))

for i in range(1, n):
    score.append(score[i - 1] + cal_score(List[i]))
    
score1.append(score[k - 1])
m = 0
for i in range(k, n):
    score1.append(score[i] - score[m])
    m += 1

#print(score)    
#print(score1)
print(max(score1))

Measured memory_bytes: 25172
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int i,a,N,S,ans,v[3001],mod=998244353;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N>>S;
  while(N--){
    cin>>a;
    ++v[0];
    for(i=S;i>=a;--i){
      v[i]+=v[i-a];
      v[i]-=(v[i]>=mod)*mod;
    }
    ans+=v[S];
    ans-=(ans>=mod)*mod;
  }
  cout<<ans;
}

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

using namespace std;

const int maxN = 2e5;
int a[maxN];

int main(void) {

    int n;
    ios_base::sync_with_stdio(0);
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int cur = 1;
    vector <int> cnt;
    int prev = -1;
    int c = 0;
    for (int i = 0; i < n; i++) {
        a[i] = min(cur, a[i]);
        cur = a[i] + 2;
        if (a[i] - 1 == prev) {
            c++;
        } else {
            if (c) {
                cnt.push_back(c);
            }
            c = 1;
        }
        prev = a[i];
    }
    cnt.push_back(c);
    long long ans = 1;
    int mod = 1e9 + 7;
    int sum = 0;
    int nxt = 0;
    for (int i = 0; i < cnt.size(); i++) {
        if (cnt[i] == 1) {
            sum += cnt[i];
            continue;
        } else {
            if (nxt) {
                cnt[i] -= nxt;
                sum++;
                nxt = 0;
            }
            while (cnt[i] > 2) {
                ans *= sum + 2;
                ans %= mod;
                sum++;
                cnt[i] -= 2;
            }
            if (cnt[i] == 2) {
                ans *= sum + 2;
                ans %= mod;
                nxt = 1;
            }
            sum++;
        }
    }

    while (sum) {
        ans *= sum;
        ans %= mod;
        sum--;
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<string>
using namespace std;
string s,t;
int main(void){
	cin>>s>>t;
	s+=s;
	int a=t.size();
	for(int i=0;i<a;i++)if(s.substr(i,a)==t){cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] x1 = new int[n];
        int[] y1 = new int[n];
        int[] x2 = new int[m];
        int[] y2 = new int[m];
        
        for(int i=0;i<x1.length;i++)
        {
            x1[i] = scan.nextInt();
            y1[i] = scan.nextInt();
        }
        for(int i=0;i<x2.length;i++)
        {
            x2[i] = scan.nextInt();
            y2[i] = scan.nextInt();
        }
        
        int min,tmp;
        for(int i=0;i<x1.length;i++)
        {
            min = 2147483647;tmp=0;
            for(int j=0;j<x2.length;j++)
            {
                int dist = manhattan(x1[i],y1[i],x2[j],y2[j]);
                if(dist < min)
                {
                    min = dist;
                    tmp = j+1;
                }
            }
            System.out.println(tmp);
        }
    }
    
    static int manhattan(int a,int b,int c,int d){
        return (Math.abs(a-c) + Math.abs(b-d));
    }
}

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

int main() {
    map<string, int> mp;
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    mp[s] = a;
    mp[t] = b;
    mp[u]--;
    cout << mp[s] << " " << mp[t] << endl;
    return 0;
}

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

//DEBUGGER
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{
    cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';
}

template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{
    return cout<<'('<<P.first<<','<< P.second<<')';
}

const int N = 2e5 + 2;
int ar[N];
int seg_tree[4*N];
int mod = 998244353;

void build(int ar[], int v, int tl, int tr)
{
    if (tl==tr)
        seg_tree[v] = ar[tr];
    else
    {
        int tm = (tl+tr)/2;
        build(ar,v*2,tl,tm);
        build(ar,v*2+1,tm+1,tr);

        seg_tree[v] = seg_tree[(v*2)] + seg_tree[(v*2+1)];
    }
}

int query(int ar[], int v, int tl, int tr, int l, int r)
{
    if (l>r)
        return 0;

    if ( l==tl && r==tr )
        return seg_tree[v];

    int tm = (tl+tr)/2;

    return query(ar,2*v,tl,tm,l,min(tm,r)) + query(ar,2*v+1,tm+1,tr,max(tm+1,l),r);
}

void update(int ar[], int v, int tl, int tr, int posn, int value)
{
    if ( tl==tr )
    {
        seg_tree[v] = value;
        return; 
    }
    int tm = (tl+tr)/2;

    if ( posn<=tm )
        update(ar,2*v,tl,tm,posn,value);
    else
        update(ar,2*v+1,tm+1,tr,posn,value);
    seg_tree[v] = seg_tree[(2*v)] + seg_tree[(2*v+1)];
    seg_tree[v]%=mod; 
}



signed main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    pair<int,int>ivs[k+1];

    for (int i=1; i<=k; ++i)
        cin>>ivs[i].first>>ivs[i].second;

    for (int i=0; i<=n; ++i)
        ar[i] = 0;

    ar[1] = 1;

    build(ar,1,1,n);

    for (int i=2; i<=n; ++i)
    {
        for ( int j=1; j<=k; ++j )
        {
            int to = i - ivs[j].first;
            int from = i - ivs[j].second;

            if ( to<1 )
                continue;

            to = min(to,i-1);
            from = max(1LL,from);

            if ( from>to )
                continue;

            int val =  query(ar,1,1,n,i,i) + query(ar,1,1,n,from,to);
            val%=mod;
            update(ar,1,1,n,i,val);
        }
    }

    cout<< query(ar,1,1,n,n,n) <<"\n";
}


Measured memory_bytes: 9248
N = int(input())

first = (0, 0)
second = 0
for i in range(N):
    A = int(input())
    if first[1] < A:
        first = (i, A)
    elif second < A:
        second = A

for i in range(N):
    if i != first[0]:
        print(first[1])
    else:
        print(second)

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

char C;
// *********************************************************
int main(){

    cin >>  C;

    if(isupper(C)){
        cout << 'A'<<endl;
    }else{
        cout << 'a' <<endl;
    }





    return 0;
}

Measured memory_bytes: 3588
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;
double cache[3001][3001] = {0};
int main(){
    gibe_de_fast_io_b0ss;
    int n;
    cin>>n;
    vector<double> probs(n + 1);
    for(int i = 1; i <= n; i++) {
    	cin>>probs[i];
    }
    cache[0][0] = 1.0;
    double answer = 0;
    
    
     
    for(int i = 0; i <= n; i++) {
    	for(int j = 0; (i + j) <= n; j++) {
    	    if(i == 0 && j == 0) continue;
			cache[i][j] = 0;
			if(i > 0) cache[i][j] += cache[i - 1][j] * (probs[i + j]);
			if(j > 0) cache[i][j] += cache[i][j - 1] * (1.0 - probs[i + j]);
			
			if((i + j) == n && i > j) answer += cache[i][j];
    	}
    }
    
    cout<<fixed<<setprecision(10)<<answer;
    return 0;
}

	/*
	for(int i = 0; i < n; i++) {
    	for(int j = 0; j <= i; j++) {
    		cache[i + 1][j] += cache[i][j] * (1.0 - probs[i + 1]);
    		cache[i + 1][j + 1] += cache[i][j] * probs[i + 1];
    	}
    }
    
    for(int j = (n + 1) / 2; j <= n; j++) answer += cache[n][j];
    */


Measured memory_bytes: 70016