akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

const ll pr= 1000000007ll;
#define pb push_back
#define mp make_pair
#define err(x) cout<<#x<<"= "<<x<<endl;
#define rep(i,n) for(int i =0; i< n; i++)
#define ff first
#define ss second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 100010
#define eps 1e-13

ll exp(ll b, ll e){
	ll ans =1;
	while(e){
		if(e&1)ans = (ans*b)%pr;
		e >>=1;
		b = (b*b)%pr;
	}
	return ans;
}
ll inv(ll a){
	return exp(a,pr-2);
}

ll fact[SIZE],invfact[SIZE],prec[SIZE],A[SIZE],n,ans;

void init(){
	fact[0] = 1;invfact[0] = 1;
	for(int i =1; i<SIZE-1; i++){
		fact[i] = (fact[i-1]*i)%pr;
	//	invfact[i] = inv(fact[i]);
	}
	prec[0] = inv(2);//invfact[2];
	for(int i = 1; i<SIZE-5; i++){
		prec[i] = inv(i+2);//(invfact[i+2]*fact[i])%pr;
		prec[i] += prec[i-1];
		prec[i] %=pr;
	//	cout<<i<<' '<<prec[i]<<endl;
	}
}


int main(){
//	#ifdef ONLINE_JUDGE
//	freopen("little.in", "r" , stdin);
//	freopen("little.out", "w", stdout);
// cin.tie(false); cout.tie(false);	
//	#endif
	ios::sync_with_stdio(false);
	init();
	cin>>n;
	rep(i,n)cin>>A[i];
	rep(i,n) A[i] = (A[i]*fact[n])%pr;
	ans = 0;

	rep(i,n){
		ans+= A[i];
		if(n-i-2>=0)
			ans += (A[i]*prec[n-i-2])%pr;
		ans%=pr;
		if(i-1>=0)
			ans += (A[i]*prec[i-1])%pr;
		ans%=pr;
	//	cout<<ans<<endl;
	}
	cout<<ans<<endl;


	

	return 0;
};


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L i){for(c=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=c;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
    d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),n=Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(0);Z[a=H[P[++n]]-n?n:0];)for(;!O[a];a=H[a],S(*Z=O[c]=++b))X[c=a]=n;
//     for(cin>>a;cin>>s>>a>>b;S(H[a],b=O[a]),S(a,b-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
//     for(cin>>a;cin>>s>>a>>b;S(a,O[a]-1),S(H[a],O[a]))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}
       for(cin>>a;cin>>s>>a>>b;S(b=O[a]-1),a=H[a],S(b+1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

int main() {
  string S;
  cin >> S;
  int ans =1;
  int a = S.size();
  vector<char> c(a);
  for(int i=0;i<a;i++){
  c.at(i)=S.at(i);
  }
  for(int i=0;i<a;i++){
    if(c.at(i)!=c.at(a-i-1)){
    ans =0;
    }
  }
  for(int i=0;i<(a-1)/2;i++){
    if(c.at(i)!=c.at((a-1)/2-i-1)){
      ans=0;
    }
  }
  for(int i=((a+3)/2)-1;i<a;i++){
    if(c.at(i)!=c.at(a-i-1)){
      ans=0;
    }
  }
       if(ans==1){
         cout << "Yes" << endl;
       }
       else{
         cout << "No" << endl;
       }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

int a[5];

int main()
{
    ///freopen("INA.txt","r",stdin);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    cin>> a[1] >> a[2] >> a[3];
    int f=0,s=0;

    if(a[1]==5){ f++; }
    if(a[2]==5){ f++; }
    if(a[3]==5){ f++; }

    if(a[1]==7){ s++; }
    if(a[2]==7){ s++; }
    if(a[3]==7){ s++; }

    if(f==2 && s==1){ cout<< "YES" << endl;}
    else{ cout<< "NO" << endl; }

    return 0;
}



Measured memory_bytes: 3544
import java.util.*;

class Main{
  public static Scanner cin;
  public static HashSet<String> m;

  public static String reverse(String s){
    return new StringBuffer(s).reverse().toString();
  }

  public static void arrange(){
    String s=cin.nextLine();
    m=new HashSet<String>();
    int i=1;
    for(;i<s.length();i++){
      String s1=s.substring(0,i),s2=s.substring(i);
      m.add(s1+s2);
      m.add(reverse(s1)+s2);
      m.add(s1+reverse(s2));
      m.add(reverse(s1)+reverse(s2));
      m.add(s2+s1);
      m.add(reverse(s2)+s1);
      m.add(s2+reverse(s1));
      m.add(reverse(s2)+reverse(s1));
    }
    System.out.println(m.size());
  }

  public static void main(String []args){
    cin=new Scanner(System.in);
    int i=0,n=cin.nextInt();
    cin.nextLine();
    for(;i<n;i++)arrange();
  }
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
using ll = long long;

int main () {
	ll A, B, C;
	cin >> A >> B >> C;
	// A: 解毒剤only
	// B: 解毒剤 + 美味しい
	// C: 毒 + 美味しい
	
	// 美味しい を最大化
	// Cを連続して食べることはできない。間にA, Bのいずれかを挟む。
	//
	// C = 3のとき、A+Bが3-1 = 2以上であれば、Cを全て食べることができる。
	// i.e. A+B >= (C-1)
	if (A + B >= (C-1)) {
		cout << B + C << endl;
	} else {
		// A+BがC-1より小さい場合はCを全て食べられない。
		// A+B = 3で, C=10の場合、Cは3+1 = 4, つまり、A+B+1個まで食べられる。
		// 今 A+B < C-1であるから、A+B+1 < C という条件で考えているから、Cを食べられる数はCより小さい。
		cout << B + (A+B+1) << endl;
	}	

	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	s := oneStr()

	size := len(s)

	cntO := 0
	cntX := 0
	for _, r := range s {
		if r == 'o' {
			cntO++
		} else {
			cntX++
		}
	}

	if 15-size+cntO >= 8 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


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

int main() {
  string s;
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "Yes" << endl;
  }
  else if (s[1] == s[2] && s[2] == s[3]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int cnt[3] = {};
  char S[4];
  scanf("%s", S);
  for (int i = 0; i < 3; i++) {
    cnt[S[i] - 'a']++;
  }

  if (cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 1) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main




int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll i,j;
	ll n;

	cin>>n;
	ll arr[n];
	ll suf[n]={0};
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	suf[0] = arr[n-1];
	j = 1;

	for(i=n-2;i>=0;i--)
	{

		suf[j] = (suf[j-1] + arr[i])%INF;
		j++;
		//cout<<suf[j]<<" "<<suf[j-1]<<" "<<arr[i]<<endl;
	}
	
	ll ans= 0;
	j = n-2;
	for(i=0;i<n;i++)
	{
		if(i!=n-1)
		{
			ans += (arr[i]*suf[j])%INF;
			//cout<<arr[i]<<" "<<suf[j]<<endl;
		}
		j--;
		ans = ans%INF;
		//cout<<ans<<endl;
	}

ans = ans%INF;
cout<<ans<<endl;
	
	


	
	return 0;
}

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

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

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

void calc_primefactorization(long long in, vector<vector<long long> >& out){
	
	long long N = in, Ntmp;
	long long p,e,p_init = 2;
	vector<long long> out_tmp(2);
	
	while( 1 ){

		Ntmp = N;
			
		p = N;
		e = 1;

		for(long long i = p_init;i * i <= N;i++){
					
			if( Ntmp % i == 0 ){
				e = 0;
				while( 1 ){
					if( Ntmp % i != 0 ){
						break;
					}
					else{
						Ntmp = Ntmp / i;
						e++;
					}
				}
				p = i;
				break;
			}
			
		}
		
		out_tmp[0] = p;
		out_tmp[1] = e;
		out.push_back(out_tmp);
		
		for(int i = 0;i < e;i++){
			N = N / p;
		}
		
		if( N == 1 ){
			break;
		}
		
	}
	
}

int main(){
	
	long long N;
	int ans = 0;
	
	cin >> N;
	
	vector<vector<long long> > out;
	calc_primefactorization(N,out);
	
	for(int i = 0;i < out.size();i++){
		
		//cout << out[i][0] << " " << out[i][1] << endl;
		for(int j = 1;j <= out[i][1];j++){
			ans++;
			out[i][1] = out[i][1] - j;
		}
		
	}
	
	if( N <= 1 ){
		cout << 0;
	}
	else{
		cout << ans;
	}
	/*
	if( N > 1 ){
		
		while( 1 ){
			Ntmp = N;
			
			p = N;
			e = 1;
			
			for(long long i = p_init;i * i <= N;i++){
				
				if( Ntmp % i == 0 ){
					e = 0;
					while( 1 ){
						if( Ntmp % i != 0 ){
							break;
						}
						else{
							Ntmp = Ntmp / i;
							e++;
						}
					}
					p = i;
					break;
				}
				
			}
			//cout << N << " " << p << " ";
			
			N = N / p;
			
			//cout << N << endl;
			
			if( p != p_1 ){
				ans++;
			}
			
			if( N == 1 ){	
				break;
			}
			
			p_init = p + 1;
			p_1 = p;
			
		}
		
	}
	*/
	//cout << ans;
	
	return 0;
	
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
// グローバルに木を持つ
vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) { // -1は親を持たないって
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u,v);
	}
}
int main()
{
	int n, q;
	cin >> n >> q;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		--a, --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	rep(i,q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i,n) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 23424
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll N, K, Q;
	ll A[100005];
	ll p[100005];
	cin >> N >> K >> Q;

	for (int i = 1; i <= Q; i++) {
		cin >> A[i];
	}

	for (int i = 1; i <= N; i++) {
		p[i] = K;
	}	

	for (int i = 1; i <= Q; i++) {
		p[A[i]]++;
	}

	for (int i = 1; i <= N; i++) {
		if (K - Q + (p[i] - K) > 0) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}

	return 0;
}

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

string solve(string input) {
    string ans = "";
    for(int r = 0; r < input.length(); r++) {
        if(input[r] == '@') {
            char target = input[r + 2];
            int rep = input[r + 1] - '0';
            
            for(int c = 0; c < rep; c++) ans += target;
            r+=2;
        } else {
            ans += input[r];
        }
    }
    return(ans);
}

int main(void) {
    string input;
    while(cin >> input) {
        cout << solve(input) << endl;
    }
    return(0);
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){

  int a[3];
  a[0] = 1;
  a[1] = a[2] = 0;
  string str;
  while(cin >> str){
    swap(a[str[0]-'A'],a[str[2]-'A']);
  }
  
  for(int i=0;i<=2;i++){
    if(a[i] == 1) printf("%c\n",('A'+i));
  }
  
  return (0);
}

Measured memory_bytes: 3308
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
int main()
{
    ll a,b,c,d,i,j;
    string s;
    cin>>s;
       //ll t=a+b+c+d;

    a=s[0]-48;
    b=s[1]-48;
    c=s[2]-48;
    d=s[3]-48;

    if((a+b+c+d)==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if((a-b-c-d)==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }

    else if((a+b+c-d)==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if((a+b-c+d)==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if((a-b+c+d)==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }


    else if((a-b+c-d)==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if((a-b-c+d)==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if((a+b-c-d)==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, *a, *b, *c;
    cin >> n;
    a = new int[n+1];
    b = new int[n+1];
    c = new int[n+1];
    int ans = 0;

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

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

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

    for (int i = 1; i <= n; i++) {
        ans += b[a[i]];
        if (i < n && a[i]+1 == a[i+1])
            ans += c[a[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#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;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=305;
int a[N][N],val[N*N];
ii rev[N*N];
int n,m,q,d;
bool vis[N*N];
void dfs(int u)
{
  if(u+d>n*m) return;
  vis[u]=true;
  int x=rev[u+d].fi,y=rev[u+d].se;
  int x1=rev[u].fi,y1=rev[u].se;
  dfs(u+d);
  val[u]=abs(x-x1)+abs(y-y1)+val[u+d];
  return;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  cin>>n>>m>>d;
  rep(i,1,n+1)
    rep(j,1,m+1)
    cin>>a[i][j],rev[a[i][j]]=mp(i,j);
  rep(i,1,n*m+1)
    if(!vis[i])
      dfs(i);
  cin>>q;
  while(q--)
    {
      int l,r;
      cin>>l>>r;
      cout<<val[l]-val[r]<<endl;
    }
  return 0 ;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	cout<<(x+1)/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

const int Nmax = 2e5 + 5;
typedef long long ll;

int i, n;
ll D, ans = 0, go[Nmax], val[Nmax], X[Nmax], sum[Nmax], sum2[Nmax];

int main()
{
//    freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> D;
    for(i=1; i<=n; ++i) cin >> X[i] >> val[i];

    for(i=1; i<=n; ++i) sum[i] = sum[i-1] + val[i];
    for(i=n; i; --i) sum2[i] = sum2[i+1] + val[i];

    for(i=n; i; --i) go[i] = max(go[i+1], sum2[i] - (D - X[i]));

    for(i=1; i<=n; ++i)
        ans = max(ans, sum[i] - X[i] + max(0LL, go[i+1] - X[i]));

    ///
    for(i=1; i<=n; ++i) X[i] = D - X[i];
    reverse(X+1, X+n+1);
    reverse(val+1, val+n+1);


    for(i=1; i<=n; ++i) sum[i] = sum[i-1] + val[i];
    for(i=n; i; --i) sum2[i] = sum2[i+1] + val[i];

    for(i=n; i; --i) go[i] = max(go[i+1], sum2[i] - (D - X[i]));

    for(i=1; i<=n; ++i)
        ans = max(ans, sum[i] - X[i] + max(0LL, go[i+1] - X[i]));
    ///

    cout << ans << '\n';
    return 0;
}


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

using namespace std;

int main()
{
  int N, L;
  cin >> N >> L;
  string S[101];
  for(int i = 0; i < N; i++) cin >> S[i];
  sort(S, S + N);
  for(int i = 0; i < N; i++) cout << S[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD = 1000000007;
ll INF = 90000000001000;

int N,k;
ll a[200005];
int h[200005];
ll bit[200005];
void update(int a,ll k){
    for(;a <=N;a+=a&-a) bit[a] = max(bit[a],k);
}

ll query(int a){
    ll res = 0;
    for(; a > 0;a -= a & -a) res = max(res,bit[a]);
    return res;
}

int main() {

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

for (int i = 0; i < N; ++i)
{
    update(h[i],query(h[i] )+ a[i]);
}

cout << query(N);
return 0;
}




Measured memory_bytes: 4096
//Problem ID: AtCoder - abc112_c (Pyramid)
//Programmer: IQBAL HOSSAIN     Description: Brute Force/MATH
//Date: 06/07/19
//Problem Link: https://atcoder.jp/contests/abc112/tasks/abc112_c
#include <bits/stdc++.h>
#define MAX 105
using namespace std;

int x[MAX], y[MAX], h[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;

    cin>>n;

    for(int i = 1; i <= n; i++){
        cin>>x[i]>>y[i]>>h[i];
    }

    int X, Y, H;

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            H = abs(i - x[1]) + abs(j - y[1]) + h[1]; 
            for(int k = 1; k <= n; k++){
                if(h[k] > 0){
                    H = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    break;
                }
            }
            bool flag = true;
            for(int k = 1; k <= n; k++){
                int temp = max(0, H - abs(x[k] - i) - abs(y[k] - j));
                if(temp != h[k]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout<<i<<" "<<j<<" "<<H<<endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	cin>>N;
	int s[100];
	rep(i,N)cin>>s[i];
	sort(s,s+N);
	int ans;
	int sum=0;
	rep(i,N)sum+=s[i];
	if(sum%10!=0)ans=sum;
	else{
		bool f=true;
		rep(i,N)if(s[i]%10!=0)f=false;
		if(f)ans=0;
		else{
			int x=0;
			rep(i,N){
				if(s[i]%10!=0){
					x=s[i];
					break;
				}
			}
			ans=sum-x;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : December 04 2019 01:03:01 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 100005;

int N, M, A[MN], B[MN];
int K, p[MN], x[MN], y[MN], cx, cy;

inline void Compress(int *a, int &c) {
	static int d[MN];
	for (int i = 1; i <= K; ++i) d[++c] = a[i];
	std::sort(d + 1, d + c + 1), c = std::unique(d + 1, d + c + 1) - d - 1;
	for (int i = 1; i <= K; ++i) a[i] = std::lower_bound(d + 1, d + c + 1, a[i]) - d;
}
inline void Init() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int i = 1; i <= M; ++i) scanf("%d", &B[i]);
	int j = 0;
	for (int i = 1; i <= N; ++i) {
		while (j < M && B[j + 1] < A[i]) ++j;
		if (j >= 1 && j < M) {
			++K, p[K] = K;
			x[K] = A[i] - B[j];
			y[K] = B[j + 1] - A[i];
		}
	}
	Compress(x, cx), Compress(y, cy);
	std::sort(p + 1, p + K + 1, [](int a, int b) {
		return x[a] == x[b] ? y[a] > y[b] : x[a] < x[b];
	});
	K = std::unique(p + 1, p + K + 1, [](int a, int b) {
		return x[a] == x[b] && y[a] == y[b];
	}) - p - 1;
}

int bit[MN];
inline void Add(int i, int v) { for (; i <= cy + 1; i += i & -i) bit[i] -= (bit[i] += v) >= Mod ? Mod : 0; }
inline int Qur(int i) { int s = 0; for (; i; i -= i & -i) s -= (s += bit[i]) >= Mod ? Mod : 0; return s; }

int main() {
	Init();
	Add(1, 1);
	for (int i = 1; i <= K; ++i) {
		int pos = y[p[i]];
		Add(pos + 1, Qur(pos));
	}
	printf("%d\n", Qur(cy + 1));
	return 0;
}

Measured memory_bytes: 2560
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    for x in A:
        if x % 2 == 1:
            cnt += 1

    if cnt % 2 == 0:
        print("YES")
    else:
        print("NO")


resolve()

Measured memory_bytes: 62448
#include <cstdio>
#include <algorithm>

int main()
{
  long long t1, t2;
  long long a1, a2;
  long long b1, b2;
  scanf("%lld%lld%lld%lld%lld%lld", &t1, &t2, &a1, &a2, &b1, &b2);
  if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2)
  {
    puts("infinity");
  }
  else
  {
    long long dif = (t1 * a1 + t2 * a2) - (t1 * b1 + t2 * b2);
    if (dif < 0)
    {
      std::swap(a1, b1);
      std::swap(a2, b2);
      dif = -dif;
    }
    if (a1 > b1)
    {
      puts("0");
    }
    else
    {
      printf("%lld\n", 2 * ((t1 * (b1 - a1) + dif - 1) / dif) - 1 + (t1 * (b1 - a1) % dif == 0 ? 1 : 0));
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll n,a,b,c,q,k,x,y,p[100010],d[100010];
vector<P> v[100010];
void init(ll i,ll pe=0,ll D=0){
  p[i]=pe;d[i]=D;
  fr(j,v[i].size()) if(v[i][j].first!=p[i]) init(v[i][j].first,i,D+v[i][j].second);
}

int main(){
  cin>>n;
  Fr(i,n-1){
    cin>>a>>b>>c;
    v[a].pb(mp(b,c));
    v[b].pb(mp(a,c));
  }
  cin>>q>>k;
  init(k);
  fr(i,q){
    cin>>x>>y;
    cout<<d[x]+d[y]<<endl;
  }
}

Measured memory_bytes: 15104
n = int(input())
s = input()
s = list(s)
# print(s)
result = []

for char in s:
    # print(char)
    i = ord(char)
    i += n
    if i > 90:
        i -= 26
    afterchar = chr(i)
    result.append(afterchar)

print("".join(result))

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    string t;
    cin >> t;
    vector<int> a(t.length(), 0);
    int max = 0;
    for (int i = 0; i < (int)t.length(); i++){
        if (t[i] == 'A' || t[i] == 'T' || t[i] == 'G' || t[i] == 'C'){
            if (i != 0){
                a[i] = a[i - 1] + 1;
                if (a[i] > max) max = a[i];
            }else{
                a[i] = 1;
              max = 1;
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll big = 1e16;
const int p = 37;

int pref[N];
int main() 
{
	data();      
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		pref[i] += s[i] == 'R';
		if (i)
		{
			pref[i] += pref[i - 1];
		}
	}	
	for (int i = 0; i < s.size(); i++)
	{
		int len = i + 1;
		int kol = len - pref[i];
		//cout << i << " " << pref[i] << '\n';
		if (kol == pref[n - 1] - pref[i])
		{
			cout << pref[n - 1] - pref[i] << '\n';
			return 0;
		}
	}
	cout << 0;
}


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

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

	string a, b;
	cin >> a >> b;
	int br = 0;
	for(int i=0; i<b.size(); i++){
		if(a[i] != b[i]) br++;
	}
	if(br == 1) cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 3608
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])

x_quo = Y//10000

flag = False
for x in range(min([x_quo,N]),-1,-1):
  Y_x = Y - 10000*x
  N_x = N - x
  y_quo = Y_x // 5000
  for y in range(min([y_quo,N_x]),-1,-1):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
      flag = True;
      break;
  else:
    continue
  break

if flag == True:
  print(str(x) + " " + str(y) + " " + str(z))
else:
  print("-1 -1 -1")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F(i, s, n, k) for(int i=s;i<n;i+=k)
#define all_(a) a.begin(),a.end()
#define mp make_pair
#define INF INT_MAX
#define pb push_back


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);    

    int n;
    cin >> n;
    vector<double> dp(n+1);
    dp[0] = 1;
    for(int coin = 0;coin < n; ++coin)
    {
        double prob_of_heads;
        cin >> prob_of_heads;
        for(int i=coin+1;i>=0;i--)
        {
            dp[i] = (i == 0 ? 0 : dp[i-1] * prob_of_heads) + dp[i] * (1 - prob_of_heads);
        }
    }
    double ans = 0;

    for(int heads = 0; heads <= n; ++heads)
    {
        int tails = n - heads;
        if(heads > tails)
        {
            ans += dp[heads];
        }
    }
    cout << fixed << setprecision(10) << ans << endl;


    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,m;
    cin>>n>>m;
    vector<VL> adj(n+1,VL());
    VL h(n+1,0);
    fr(i,1,n+1)
    {
        cin>>h[i];
    }
    fr(i,0,m)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    ll ct=0;
    fr(i,1,n+1)
    {
        ll fg=1;
        for(auto j: adj[i])
        {
            if(h[j]>=h[i])
            {
                fg=0;
            }
        }
        if(fg==1)
            ct++;
    }
    cout<<ct<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9800
n = int(input())
plan = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]

for i in range(n):
    if plan[i + 1][0] - plan[i][0] < abs(plan[i + 1][1] - plan[i][1]) + abs(plan[i + 1][2] - plan[i][2]):
        print("No")
        exit()
    if (plan[i + 1][0] - plan[i][0]) % 2 != (abs(plan[i + 1][1] - plan[i][1]) + abs(plan[i + 1][2] - plan[i][2])) % 2:
        print("No")
        exit()
print("Yes")

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

long long combi(long long n) {
    return n*(n - 1) /2;
}

int main(){
  map<int,int> mball;
  int N,a;
  long long sum=0,bcombi,acombi;
  vector<int> vball;
  cin >> N;
  for(int i = 0;i < N;i++){
  	cin >> a;
    vball.push_back(a);
    mball[a] += 1;
  }
  for(auto itr = mball.begin(); itr != mball.end(); ++itr) {
        if(itr->second ==  1){
        }else{
        	sum += combi(itr->second);
        }
    }
  for(int i = 0;i < N;i++){
    bcombi=0,acombi=0;
	auto itr = mball.find(vball.at(i));
    if( itr != mball.end()) {
        bcombi = combi((itr->second));
      	acombi = combi((itr->second - 1));
      }
    cout << sum + acombi - bcombi<< endl;
  }
  
}


Measured memory_bytes: 8308
#include <stdio.h>

int main(void){
	char c[4];
  	int n;
  	scanf("%s",c);
  	if(c[0]=='M'){
    	n=6;
    }else if(c[0]=='T'){
      	if(c[1]=='U'){n=5;}
    	else{n=3;}
    }else if(c[0]=='W'){
    	n=4;
    }else if(c[0]=='F'){
    	n=2;
    }else if(c[0]=='S'){
    	if(c[1]=='U'){n=7;}
    	else{n=1;}
    }
  	printf("%d\n",n);
}


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

using namespace std;

char next_c(char c){
  if(c < 'z'){
    return c + 1;
  }else{
    return 'a';
  }
}

int main(){
  string s;
  int k;
  cin >> s >> k;
  for(int i = 0;i < s.size();i++){
    int gap = 'z' - s[i] + 1;
    if(gap <= k && s[i] != 'a'){
      s[i] = 'a';
      k -= gap;
    }else{
      continue;
    }
  }

  for(int i = 0;i < k % 26;i++){
      s.back() = next_c(s.back());
  }

  cout << s << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

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

	if (n%2) cout << "No" << endl;
	else {
		bool vf = 1;
		for(int i=0; i<n/2; i++) {
			if (s[i] != s[n/2 + i]) vf = 0; 
		}
		if (vf) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  int a,b;
  cin >> a >> b;
  
  int c = a + b;
  int d = a - b;
  int e = a * b;
  
  cout << max(max(c,d),e) << endl;
  
  return 0;
}



Measured memory_bytes: 256
// package c;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long a = stdin.nextLong();
        long b = stdin.nextLong();
        long c = stdin.nextLong();
        long d = stdin.nextLong();

        // e: cとdの最小公倍数
        long e = (c * d) / gcd(c, d);

        // x: cで割り切れるもの
        // y: dで割り切れるもの
        // z: cでもdでも割り切れるもの
        long x = ((b / c * c) - (div(a, c) * c)) / c + 1;
        long y = ((b / d * d) - (div(a, d) * d)) / d + 1;
        long z = ((b / e * e) - (div(a, e) * e)) / e + 1;
        System.out.println((b - a + 1) - x - y + z);
    }

    public static long gcd(long x, long y) {
        if (x < y) {
            return gcd(y, x);
        }

        return x % y == 0 ? y : gcd(y, x % y);
    }

    public static long div(long x, long y) {
        return x % y == 0 ? x / y : x / y + 1;
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
#include <map>
using namespace std;
#define ll long long

ll add(ll x,ll y,ll mod) {
  x%=mod;
  y%=mod;
  return ((x+y)%mod+mod)%mod;
}

ll mul(ll x,ll y,ll mod) {
  x%=mod;
  y%=mod;
  return x*y%mod;
}

ll mypow(ll x,ll c,ll mod) {
  ll ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x,mod);
    }
    c/=2;
    x = mul(x,x,mod);
  }
  return ret;
}

int getLen(ll x) {
  int ret = 0;
  while(x>0) {
    x/=10;
    ++ret;
  }
  return ret;
}

#define mat vector<vector<ll> >

mat mul(mat x,mat y,ll mod) {
  mat R = mat(x.size(),vector<ll>(x.size(),0LL));
  for(int i=0;i<x.size();++i) {
    for(int j=0;j<x.size();++j) {
      for(int k=0;k<x.size();++k) {
        R[i][j] = add(R[i][j], mul(x[i][k],y[k][j],mod),mod);
      }
    }
  }
  return R;
}
mat matPow(mat x,ll cc,ll mod) {
  int n = x.size();
  mat R = mat(n,vector<ll>(n,0LL));
  for(int i=0;i<n;++i) {
    R[i][i] = 1;
  }
  while(cc>0) {
    if(cc&1) {
      R = mul(R, x,mod);
    }
    x = mul(x,x,mod);
    cc/=2;
  }

  return R;
}

void solve() {
  ll L,A,B,mod;
  scanf("%lld %lld %lld %lld ",&L,&A,&B,&mod);
  ll firstInd = 1;
  ll ret = 0;
  while(firstInd<=L) {
    ll l = firstInd,r = L,mid;
    int len = getLen(A + (firstInd-1)*B);
    while(l<r) {
      mid = (l+r+1)/2;
      ll tmp = A + (mid-1)*B;
      if(getLen(tmp)!=len) {
        r = mid-1;
      } else {
        l = mid;
      }
    }
    mat R = mat(3,vector<ll>(3,0LL));
    R[0][0] = mypow(10,len,mod);
    R[1][0] = 1;
    R[1][1] = 1;
    R[2][1] = 1;
    R[2][2] = 1;
    ll X = A + (firstInd-1)*B;
    R = matPow(R,l-firstInd+1,mod);
    ll tmp = add(add(mul(ret,R[0][0],mod),mul(X,R[1][0],mod),mod),mul(B,R[2][0],mod) ,mod);
    ret = tmp;
    firstInd = l+1;
  }
  printf("%lld\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    int sum=0;
    cin >> a>> b>>c;
    for(int i=1; i<b+1;i++){
        if((a*i)%b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
def ABC073C(d,i):
    if i in d:
        d[i]= not(d[i])
    else:
        d[i]=True
    return d

n,*a=map(int,open(0).read().split())
d=dict()
for i in a:
    d = ABC073C(d,i)
print(sum(d.values()))

Measured memory_bytes: 18144
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        //
		// 1行目個数、2行目の複数の数字を配列に格納
		//   3
		//   1 2 3
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int N = Integer.parseInt(ss0[0]);
		int K = Integer.parseInt(ss0[1]);

		ss0 = br.readLine().trim().split(" ", 0);
		Integer[] ii0 = new Integer[N];
		for(int i = 0; i < N; i++){
			ii0[i] = Integer.parseInt(ss0[i]);
		}
//				for(int i: ii0) {
//					System.out.println(i);
//				}

		//配列のソート
		Arrays.sort(ii0, Collections.reverseOrder());
//				for(int i: ii0) {
//					System.out.println(i);
//				}

		//全部足しても届かないなら、全部不要
		long sum = 0;
		for(int i: ii0) { sum += i; }
		if (sum < K) { System.out.println(N); return;}

		//
		int[] fuyou = new int[N];
		for(int i=0; i<N; i++) { fuyou[i] = 1;}
		
		int j2 = 0;
		for(int j=0; j<N; j++) {
			sum = 0;
			j2 = j;
			for(int i=j; i<N; i++) {
				if(sum+ii0[i] >= K) {
					setNeed(fuyou, j2, i);
					j2 = i;
					//break;
				} else {
					sum += ii0[i];
				}
			}
		}

		int ans = 0;
		for(int i: fuyou) { ans += i; }

//				for(int i: fuyou) {
//					System.out.println(i);
//				}

        System.out.println(ans);
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	//
	static void setNeed(int[] i1, int I, int N) {
		for(int i=I; i<=N; i++) {
			i1[i] = 0;
		}
	}
	
	//-----------------------------------------------------------------
	// 入力値確認
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int arr [4000];
	int ar[3][4000];
	int cu0,cu1,cu2;
	cu0=cu1=cu2=0;
	long long cnt=0;
	for(int i=0;i<n;i++)ar[0][i]=ar[1][i]=ar[2][i]=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){arr[i]=0;ar[0][i]=++cu0;}
		if(s[i]=='G'){arr[i]=1;ar[1][i]=++cu1;}
		if(s[i]=='B'){arr[i]=2;ar[2][i]=++cu2;}
	}
	for(int i=1;i<n;i++){
		if(ar[0][i]==0)ar[0][i]=ar[0][i-1];
		if(ar[1][i]==0)ar[1][i]=ar[1][i-1];
		if(ar[2][i]==0)ar[2][i]=ar[2][i-1];
	}
	for(int i=0;i<n-3;i++)
		for(int j=n-1;j>i+2;j--){
			if(arr[i]!=arr[j]){
				cnt+=ar[3-arr[i]-arr[j]][j]-ar[3-arr[i]-arr[j]][i];
				if((j-i)%2==0&&arr[(j+i)/2]==3-arr[i]-arr[j])cnt--;
			}
		}
	cout<<cnt<<endl;
	return 0;
}
	
	



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,k;
    cin>>n>>k;
    cout<<((n>=k)?n-k+1:0)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<j; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
//	freopen("t.in","r",stdin);
//	freopen("t.out","w",stdout);
	IOS;
	int n;
	cin >> n;
	int ans = 0;
	for(int i=1; i<=n; i++)
	{
		if((int)log10(i)%2 == 0)
			ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int price = 700;
string s;

int main() {
  cin >> s;
  for (int i=0; i<3; i++) {
    if (s[i]=='o') {
       price += 100;
     }
  }
  cout << price;
  return 0;
}


Measured memory_bytes: 256
let (+@) a b = (a + b) mod 1000000007
let rec f xs v =
  if v = 0 then xs else f (v mod 2 :: xs) (v / 2)

let solve n =
  let d = f [] n in
  let x, y, z = List.fold_left (fun (x,y,z) b ->
    if b = 0 then
      (x +@ y, y, y +@ 3 * z)
    else
      (x, x +@ y, 2 * y +@ 3 * z)
    ) (1,0,0) d
  in x +@ y +@ z

let () = Scanf.scanf "%d" solve |> Printf.printf "%d\n"

Measured memory_bytes: 384
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let fixed_cnt = A.iter()
        .map(|&a| a / 400)
        .filter(|&a| a < 8)
        .collect::<std::collections::HashSet<_>>()
        .len();
    let free_cnt = A.iter()
        .filter(|&&a| a >= 3200)
        .count();
    let ans = format!(
        "{} {}",
        std::cmp::max(1, fixed_cnt),
        fixed_cnt + free_cnt
    );

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    int k;
    cin >> n >> k;
    map<int, int> mp; // times, value
    FOR(i, 0, n) {
        int temp;
        cin >> temp;
        if (mp[temp] == 0) {
            mp[temp] = 1;
        } else {
            mp[temp]++;
        }
    }
    int mp_size = mp.size();
    int res = 0;
    if (mp_size <= k) {
        res = 0;
    } else {
        Vec<int> array;
        for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
            array.push_back(itr->second);
        }
        VSORT(array);
        FOR(j, 0, mp_size - k) {
            res += array[j];
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 10748