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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
vector<int> g[200010];
int d[200010];

void dfs(int v,int pre,int dep){
  d[v]=dep;
  for(int nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v,dep+1);
  }
}

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

  cin>>N;
  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0,-1,0);
  int mx=0;
  rep(v,N)if(d[v]>d[mx])mx=v;
  dfs(mx,-1,0);
  int dia=0;
  rep(v,N)maxch(dia,d[v]);
  if((dia-1)%3==0)cout<<"Second"<<endl;
  else cout<<"First"<<endl;

  return 0;
}


Measured memory_bytes: 21376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
using namespace std;
using ll =long long;

int main (void) {
  int N,M,X;
  cin >> N >> M >> X;
  int A[M+1];
  int v;
  for (int i=1; i<=M; i++) {
    cin >> v;
    A[i]=v;
    if(A[i]>X){
      cout << min(i-1,M+1-i);
      return 0;
    }
  }
  cout << 0;
}


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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rs(s);
  int l=0;
  int r = s.size()-1;
  ll ans = 0;
  while(l<=r){
  	if(s[l]!=s[r]){
  		ans++;
  	}
  	l++;
  	r--;
  }

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define double long double
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[334334];int n,ans=0;
signed main() {
	cin>>n;
	rep(i,3*n)cin>>a[i];
	sort(a,a+3*n);
	for(int i=1;i<=n;i++)ans+=a[3*n-2*i];
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <cstdio>

using namespace std;

char mp[15][15] = {0};
int dx[5] = {0, 0, 1, -1};
int dy[5] = {1, -1, 0, 0};

void def(int y, int x){
	mp[y][x] = 0;
	for (int i = 0; i < 4; i++){
		int ty = y + dy[i];
		int tx = x + dx[i];
		if (mp[ty][tx] == '1') def(ty, tx);
	}
}

int main()
{
	int pi, pj;
	int cnt;
	while (scanf("%s", mp[0]) != EOF){
		cnt = 0;
		
		for (int i = 1; i < 12; i++) scanf("%s", mp[i]);
		
		for (int i = 0; i < 12; i++){
			for (int j = 0; j < 12; j++){
				if (mp[i][j] == '1'){
					def(i, j);
					cnt++;
				}
			}
		}
		
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 972
#include <iostream>
#include <string>
 
using namespace std;
 
long long addition(const string& numbers, const int& positionOfPlus);
 
int main() {
    string numbers;
    cin >> numbers;
    
    //longでいい
    long long answer = 0;
    //bitじゃなくてbits
    for (int bit = 0; bit < (1 << (numbers.size() - 1)); ++bit) {
        answer += addition(numbers, bit);
    }
    cout << answer << endl;       
}

//関数名が名詞になっているadd?
//positionOfPlusは使い方と名前が乖離している
//+の位置はboolの配列でもできそう
long long addition(const string& numbers, const int& positionOfPlus) {
    long long sum = 0;
    long long term = 0;
    //0Uで表記
    for (size_t i = 0; i < numbers.size(); ++i) {
        //10がマジックナンバーっぽい
        term *= 10;
        term += numbers.at(i) - '0';
        if (positionOfPlus & (1 << i) || i == numbers.size() - 1) {
            sum += term;
            term = 0;
        }
    }
    return sum;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (String.valueOf(i).length() % 2 == 1) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 41100
from itertools import accumulate


def main():
    cells, can_jump = [int(x) for x in input().split()]
    jumps_from = [int(x) - 1 for x in input().split()]
    score_on = [int(x) for x in input().split()]

    ans = - 10**10
    for start in range(cells):
        route = []
        position = start
        while True:
            route.append(score_on[position])
            position = jumps_from[position]
            if position == start:  # Looped
                break

        length = len(route)
        total = sum(route)
        for jumping, accum_candidate in enumerate(accumulate(route)):
            jumping += 1
            if jumping > can_jump:
                break
            if total > 0:
                accum_candidate += total * ((can_jump - jumping) // length)
            ans = max(ans, accum_candidate)
    return ans


if __name__ == '__main__':
    ans = main()
    print(ans)


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

int main() {
    long long N;
    cin >> N;
    long long res = 0;
    for (long long A = 1; A * A < N; ++A) ++res;
    for (long long A = 1; A * A < N; ++A) {
        long long num = max((N - 1) / A - A, 0LL);
        res += num * 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    N,M,K = map(int, stdin.readline().rstrip().split())
    A = list(map(int, stdin.readline().rstrip().split()))
    B = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    a = [0]
    for i in range(N):
        a.append(a[i] + A[i])
    b = [0]
    for i in range(M):
        b.append(b[i] + B[i])
    ans, j = 0, M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 48596
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<string.h>
typedef long long int ll;
using namespace std;
int  d[100][100];
int mod=1e9+7;
int h(int x)
{
	return x%10;
}
int r(int x)
{   int s;
	while(x)
	{
		s=x%10;
		x/=10;
	}
   return s;
}
int main()
{
	int n,m,i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		d[h(i)][r(i)]++;
	}
	ll s=0;
	for(i=1;i<=9;i++)
	for(j=1;j<=9;j++)
	{
		s+=d[i][j]*d[j][i];
	}
	printf("%lld\n",s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc scanf
typedef long long ll;
using namespace std;
ll brr[1010],arr[1010];
int main()
{
	ll n;
	while(cin>>n)
	{
		int cnt=0;
		while(n)
		{
			arr[cnt++]=n%10;
			n/=10;
		}
		ll ans=0;
		reverse(arr,arr+cnt);
		ll len=1<<(cnt-1);
		for(int i=0;i<len;i++)
		{	
			ll t=arr[0];
			for(int j=0;j<cnt;j++)
			{
				if((i&(1<<j))||j==cnt-1)
				{
					ans+=t;
					t=0;
					if(j==cnt-1)break;
				}
				t=t*10+arr[j+1];
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

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

typedef struct dice_struct{
    int num[6], temp;
}dice_struct;

void throw_dice(dice_struct *dice, char order) {
    switch (order) {
        case 'R':
            dice->temp = dice->num[1];
            dice->num[1] = dice->num[3];
            dice->num[3] = dice->num[4];
            dice->num[4] = dice->num[2];
            dice->num[2] = dice->temp;
            break;
        case 'E':
            dice->temp = dice->num[0];
            dice->num[0] = dice->num[3];
            dice->num[3] = dice->num[5];
            dice->num[5] = dice->num[2];
            dice->num[2] = dice->temp;
            break;
        case 'S':
            dice->temp = dice->num[0];
            dice->num[0] = dice->num[4];
            dice->num[4] = dice->num[5];
            dice->num[5] = dice->num[1];
            dice->num[1] = dice->temp;
            break;
        case 'W':
            dice->temp = dice->num[0];
            dice->num[0] = dice->num[2];
            dice->num[2] = dice->num[5];
            dice->num[5] = dice->num[3];
            dice->num[3] = dice->temp;
            break;
        case 'N':
            dice->temp = dice->num[0];
            dice->num[0] = dice->num[1];
            dice->num[1] = dice->num[5];
            dice->num[5] = dice->num[4];
            dice->num[4] = dice->temp;
            break;            
    }

}


int isSame(dice_struct dice1, dice_struct dice2) {
    static const char order[] = "NNNESSSWNNNESSSWNNNESSSW";
    int i, j;
    for (i = 0; i < 24; i++) {
        j = 0;
        while(j < 6 && dice1.num[j] == dice2.num[j]) {
            j++;
        }
        if (j == 6) {
            return 1;
        }
        throw_dice(&dice2, order[i]);
    }
    return 0;
}


int main(int argc, char const *argv[]) {
    int i, j, n;
    dice_struct d[100];
    cin >> n;

    for (i = 0; i < n; i++) {
        for (j = 0; j < 6; j++) {
            cin >> d[i].num[j];
        }
        for (int j = 0; j < i; j++) {
            if (isSame(d[i], d[j])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



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

int main()
{

    long double a, b, c, X, Y;

    cin >> a >> b >> c;

    if(c-a-b<0){
        cout << "No";
        return 0;
    }

    X = a + b - c;

    X *= X;
    Y = 4 * a * b;


    if (Y<X)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}


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

using namespace std;


int main() {

    int a,b;
    string res1, res2;
    res1 = "Yay!";
    res2 = ":(";
    cin >> a;
    cin >> b;

    if(a+b<=16 && a<=8 && b<=8) {
        cout << res1 << '\n';
    }
    else if(a+b<=16 && a>8 || b>8) {
        cout << res2 << '\n';
    }
   
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120


int main(){
  int n,k;
  cin>>n>>k;
  int ans=k;
  for(int i=0;i<n-1;i++){
    ans*=(k-1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        String S = in.next();

        long ans = 0;
        int R = 0;
        int G = 0;
        int B = 0;
        for (int i = 0; i < N; i++) {
            switch (S.charAt(i)) {
                case 'R':
                    R++;
                    ans += G * B;
                    break;
                case 'G':
                    G++;
                    ans += R * B;
                    break;
                case 'B':
                    B++;
                    ans += R * G;
                    break;
            }
        }
        for (int i = 0; i < N; i++) {
            char Si = S.charAt(i);
            for (int j = i+1, k = i+2; k < N; j++, k+=2) {
                char Sj = S.charAt(j);
                char Sk = S.charAt(k);
                if (Si != Sj && Si != Sk && Sj != Sk) {
                    ans--;
                }
            }
        }
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 33072
package main

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

var matchNum = []int{0, 2, 5, 5, 4, 5, 6, 3, 7, 6}

func main() {
	N := nextInt()
	M := nextInt()
	var As []int
	for i := 0; M > i; i++ {
		As = append(As, nextInt())
	}

	sort.Sort(sort.Reverse(sort.IntSlice(As)))

	dp := make([]int, N+1)
	dp[0] = 0
	for i := 1; N >= i; i++ {
		maxDigit := int(math.Inf(-1))
		for _, A := range As {
			index := i - matchNum[A]
			if index < 0 || dp[index] < 0 {
				continue
			}

			maxDigit = max(maxDigit, dp[index]+1)
		}

		dp[i] = maxDigit
	}

	remain := dp[N]
	match := N
	for match > 0 {
		for _, A := range As {
			if match-matchNum[A] < 0 {
				continue
			}

			if dp[match-matchNum[A]] == remain-1 {
				fmt.Print(A)
				match -= matchNum[A]
				remain--
				break
			}
		}
	}

	fmt.Println()
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        int[] b = new int[3];

        boolean ans = false;
        
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        
        int[] count = new int[4];
        Arrays.fill(count, 0);
        for (int j = 0; j < 3; j++) {
            count[a[j] - 1]++;
            count[b[j] - 1]++;
        }
        
        int one = 0;
        for (int i = 0; i <= 3; i++) {
            if (count[i] == 1) {
                one++;
            }
        }
        
        if (one <= 2) {
            ans = true;
        }
        System.out.println(ans?"YES":"NO");
    }

}

Measured memory_bytes: 21332
#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
using namespace std;
#define N 4
#define N2 16


static const int dx[4]={0,-1,0,1};
static const int dy[4]={1,0,-1,0};
static const char dir[4]={'r','u','l','d'};
int MDT[N2][N2];

struct Puzzle{
  int f[N2],space,MD;
  int cost;
  bool operator<(const Puzzle &p)const{
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i])continue;
      return f[i]<p.f[i];
    }return false;
  }
};
struct State{
  Puzzle puzzle;
  int estimated;
  bool operator<(const State &s)const{
    return estimated>s.estimated;
  }
};
int getAllMD(Puzzle pz){
  int sum=0;
  for(int i=0;i<N2;i++){
    if(pz.f[i]==N2)continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}
int astar(Puzzle s){
  priority_queue<State> PQ;
  s.MD=getAllMD(s);
  s.cost=0;
  map<Puzzle,bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle=s;
  initial.estimated=getAllMD(s);
  PQ.push(initial);
  while(!PQ.empty()){
    State st=PQ.top(); PQ.pop();
    u=st.puzzle;
    if(u.MD==0)return u.cost;
    V[u]=true;
    int sx=u.space/N;
    int sy=u.space%N;
    for(int r=0;r<4;r++){
      int tx=sx+dx[r];
      int ty=sy+dy[r];
      if(tx<0||ty<0||tx>=N||ty>=N)continue;
      v=u;
      v.MD-=MDT[tx*N+ty][v.f[tx*N+ty]-1];
      v.MD+=MDT[sx*N+sy][v.f[tx*N+ty]-1];
      swap(v.f[sx*N+sy],v.f[tx*N+ty]);
      v.space=tx*N+ty;
      if(!V[v]){
	v.cost++;
	State news;
	news.puzzle=v;
	news.estimated=v.cost+v.MD;
	PQ.push(news);
      }
    }
  }
  return -1;
}
int main(){
  for(int i=0;i<N2;i++){
    for(int j=0;j<N2;j++){
      MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
    }
  }
  Puzzle in;
  for(int i=0;i<N2;i++){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  cout<<astar(in)<<endl;
  return 0;
}

Measured memory_bytes: 257664
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; string S; cin >> N >> S;
    int ans = 0;
    REP(i, 0, N - 2) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n=Integer.parseInt(sc.next());       
int ans = 0;    
for (int i = 0; i < n; i++) {
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
    ans+=r-l+1;
    }
    out.println(ans);
}
}

Measured memory_bytes: 24660
S = input()[::-1]
T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
Ans = "YES"
while len(S) > 0:
    if S[0:5] in T:
        S = S[5:]
        continue
    elif S[0:6] in T:
        S = S[6:]
        continue
    elif S[0:7] in T:
        S = S[7:]
        continue
    else:
        Ans = "NO"
        break
print(Ans)

Measured memory_bytes: 3188
//#define TEST

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int mod = (int)1e9 + 7;

map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

struct Combination
{
	vector< int64_t > mfact, rfact;

	Combination(int sz) : mfact(sz + 1), rfact(sz + 1)
	{
		mfact[0] = 1;
		for (int i = 1; i < mfact.size(); i++) {
			mfact[i] = mfact[i - 1] * i % mod;
		}
		rfact[sz] = inv(mfact[sz]);
		for (int i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % mod;
		}
	}

	int64_t fact(int k) const
	{
		return (mfact[k]);
	}

	int64_t pow(int64_t x, int64_t n) const
	{
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= mod;
			(x *= x) %= mod;
			n >>= 1;
		}
		return (ret);
	}

	int64_t inv(int64_t x) const
	{
		return (pow(x, mod - 2));
	}

	int64_t P(int n, int r) const
	{
		if (r < 0 || n < r) return (0);
		return (mfact[n] * rfact[n - r] % mod);
	}

	int64_t C(int p, int q) const
	{
		if (q < 0 || p < q) return (0);
		return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
	}

	int64_t H(int n, int r) const
	{
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	if (M == 1) {
		cout << 1 << endl;
		return 0;
	}
	auto pf = prime_factor(M);
	vector<int> index(0);
	for (auto p : pf)
		index.push_back(p.second);
#ifdef TEST
	for (int i : index) cout << i << " ";
	cout << endl;
#endif
	Combination c(*max_element(index.begin(), index.end()) + N);
	ll ans = 1;
	for (auto k : index) {
		ans *= c.C(k + N - 1, k);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int a,b;cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	a.push_back(0LL);
	
	ll ans = 1000, money = 1000, stock = 0;
	for(int i = 0; i < n + 1; ++i) {
		if( i > 0 ) {
			if( a[i - 1] < a[i] && stock > 0 ) {
				money += a[i] * stock;
				stock = 0;
				
				ans = max(ans, money);	
			}
		}
		
		if( i < n && money > a[i] && a[i] < a[i + 1] ) {
			stock = money / a[i];
			money = money % a[i];
		
		}	
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
 int n,c=0,d=0,i;
 cin >> n;
 char m[n];
 cin >> m;
 for(i=0;i<n;i++){
     if(m[i]=='('){
         c++;
     }
     else if(c>0){
         c--;
     }
     else {
         d++;
     }
 }
 for(i=0;i<d;i++)cout << '(';
 cout << m;
 for(i=0;i<c;i++)cout << ')';
 cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int N = 200000;
int a[N + 5], cnt[N + 5];

int main()
{
    int n;
    long long ans = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    for(int i = 1; i <= N; i++)
        ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;

    for (int i = 0; i < n; i++)
        printf("%lld\n", ans - cnt[a[i]] + 1);    

    return 0;
}

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

using namespace std;

const int N=3009;

int n,a[N],siz[N];
int to[N<<1],nxt[N<<1],beg[N],tot;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

inline void add(int u,int v)
{
	siz[u]++;
	to[++tot]=v;
	nxt[tot]=beg[u];
	beg[u]=tot;
}

inline bool dfs(int u,int fa)
{
	for(int i=beg[u],v;i;i=nxt[i])
		if((v=to[i])!=fa && a[u]>a[v] && !dfs(v,u))
			return true;
	return false;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1,u,v;i<n;i++)
	{
		u=read();v=read();
		add(u,v);add(v,u);
	}

	for(int i=1;i<=n;i++)
		if(dfs(i,0))
			printf("%d ",i);

	puts("");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n;
	cin>>n;
	ll x=-1,y=-1,z,zz;
	for(ll a=0;a<=10000;a++)
	{
		for(ll b=-10000;b<=10000;b++)
		{
			z=pow(a,(ll)5);
			zz=pow(b,(ll)5);
			if(z-zz==n)
			{
				x=a;
				y=b;
				break;
			}	
		}
		if(x!=-1)
		break;
	}
	cout<<x<<" "<<y;
	return 0;
}

Measured memory_bytes: 4244
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int num1 = scanner.nextInt();
    int sum = 0;
    for(int i = 1; i <= num1; i++) {
    	if(String.valueOf(i).length() % 2 == 1) {
    		sum++;
    	}
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 28244
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, t = M()
print((t//a)*b)

Measured memory_bytes: 40476
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

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

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;


int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
    ll n, i ,j , k, x;

    cin>>x;

    ll c1, c2;

    c1 = x/500;

    x = x%500;

    c2 = x/5;

    cout<<c1*1000+c2*5<<"\n";
  

}




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


int main() {
	int N, M;
	cin >> N >> M;
 
	vector<vector<int>> g(N);
	while (M--) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
	}
	
	vector<int> cycle;
    for (int s = 0; s < N; s++) {  // Loop for all vertices; s as the starting vertex.
		vector<int> par(N, -1);
		queue<int> q;
		q.push(s);
 
		while (q.size()) {
			int i = q.front();
			q.pop();
			for (int j: g[i]) {
				if (j == s) {
					vector<int> cur = {i};
					while (i != s) i = par[i], cur.push_back(i);
					if (cycle.size() == 0 || cur.size() < cycle.size()) cycle = cur;
					while (q.size()) q.pop();
					break;
				}
				if (par[j] != -1) continue;
				par[j] = i;
				q.push(j);
			}
		}
	}
 
	if (cycle.size()) {
		cout << cycle.size() << endl;
		for (int x: cycle) cout << x + 1 << endl;
	} else {
		cout << -1 << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

const int N = 2e5 + 10;
int a, d, cnt[N];
int n, k;

int main()
{
	int t;
	sdd(n, k);
	rep(i, 1, k)
	{
		sd(d);
		rep(j, 1, d)
		{
			sd(a);
			cnt[a]++;
		}
	}
	int ans = n;
	rep(i, 1, n) if (cnt[i])
		ans--;
	pd(ans);
	return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int pow(int n){
	if(n==1) return 2;
	if(n==0) return 1;
	return pow(n/2)*pow(n-n/2);
}
long long int cal(vector<int> a,int n){
	vector<long long int> val(1);
	val[0]=a[0];
	for(int i=1;i<a.size();i++){
		if (n%2==0) {val[val.size()-1]*=10;val[val.size()-1]+=a[i];}
		else val.push_back(a[i]);
		n/=2;
	}
	long long int sum=0;
	for(int i=0;i<val.size();i++) sum+=val[i];
	return sum;
}
int main(){
	long long int s;
	cin>>s;
	vector<int> a;
	int i=0;
	while(s>0){
		a.push_back(s%10);
		s=s/10;
		i++;
	}
	vector<int> aa(a.size());
	for(int i=0;i<a.size();i++){
		aa[i]=a[a.size()-1-i];
	}
	/*
	for(int i=0;i<aa.size();i++){
		cout<<aa[i]<<endl;
	}
	*/
	long long int e=pow(aa.size()-1);
	
	long long int sum=0;
	for(int i=0;i<e;i++){
		//cout<<"i="<<i<<"cal="<<cal(aa,i)<<endl;
		sum+=cal(aa,i);
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
Q = int(input())
mod = 10 ** 6 + 3
class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(mod - 1, mod)

for _ in range(Q):
  x, d, n = map(int, input().split())
  if d == 0:
    print(pow(x, n, mod))
    continue
  z = -x * pow(d, mod - 2, mod) % mod
  v = -z % mod
  #print(z, v, (x + z * d) % mod)
  if z < n:
    print(0)
    continue
  res = f.factorial(v + n - 1) * pow(d, v + n - 1, mod) % mod
  #print(res, f.ifactorial(v - 1), pow(f.factorial(v - 1), mod - 2, mod), pow(d, v - 1, mod))
  res *= f.ifactorial(v - 1) * pow(pow(d, v - 1, mod), mod - 2, mod) % mod
  res %= mod
  print(res)

Measured memory_bytes: 117276
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    int N;
    cin>>N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin>>A[i];
    }
    ll ans=0;
    int higest=A[0];
    for (int i = 1; i < N; i++){
        if(higest-A[i]>0){
            ans+=higest-A[i];
        }
        higest=max(higest,A[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3992
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		if(b/a > c){
			System.out.println(c);
		} else {
			System.out.println(b/a);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ld r;cin>>r;
    cout<<r*2*pi<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {

	int a = 1, b = 2, c = 3;
	scanf("%d%d%d", &a, &b, &c);

	int temp = a;
	a = b;
	b = temp;
	temp = c;
	c = a;
	a = temp;

	printf("%d %d %d", a, b, c);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    u64 X;
    cin >> X;

    if(X) {
        cout << 0 << endl;
    } else {
        cout << 1  << endl;
    }
    return 0;
}

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

int H,W;
vector<string> fi;
int Left[2100][2100],Right[2100][2100],Up[2100][2100],Down[2100][2100];

int main(){
    cin >> H >> W;
    fi.resize(H);
    for(int i = 0; i < H ;++i) cin >> fi[i];
    
    for(int i = 0; i < H;i++){
        int cur = 0;
        for(int j = 0; j <W;++j){
            if(fi[i][j]=='#')cur = 0;
            else ++cur;
            Left[i][j]=cur;
        }
    }
    
    for(int i = 0; i < H;i++){
        int cur = 0;
        for(int j = W-1; j >=0;--j){
            if(fi[i][j]=='#')cur = 0;
            else ++cur;
            Right[i][j]=cur;
        }
    }
    
    for(int j = 0; j < W;j++){
        int cur = 0;
        for(int i = 0; i <H;++i){
            if(fi[i][j]=='#')cur = 0;
            else ++cur;
            Up[i][j]=cur;
        }
    }
    
    for(int j = 0; j < W;j++){
        int cur = 0;
        for(int i = H-1; i >=0;--i){
            if(fi[i][j]=='#')cur = 0;
            else ++cur;
            Down[i][j]=cur;
        }
    }
    
    int res = 0;
    
    for(int i = 0; i < H ; i++){
        for(int j = 0; j < W; j++){
            if(fi[i][j]=='#')continue;
            res = max(res,Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-3);
        }
    }
    
    cout << res <<endl;
    
    
}

Measured memory_bytes: 72448
tc = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for t in range(tc):
  r = input()
  if r == "AC":
    ac += 1
  elif r == "WA":
    wa += 1
  elif r == "TLE":
    tle += 1
  else:
    re += 1
    
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
template <class T>
void co_vec(vector<T> v) {
    for (T i : v) cout << i << ' ';
    co();
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

template <typename Type>
struct KMP{
    Type S;
    Vec A;

    KMP(Type S) : S(S){
        A.resize(S.size() + 1);
        A[0] = -1, A[1] = 0;
        ll j = 0;
        for(int i = 1; i < S.size(); ++i){
            while(j >= 0 && S[i] != S[j]) j = A[j];
            ++j;
            // ce(i, j);
            // if(S[i + 1] == S[j]) A[i + 1] = A[j];
            A[i + 1] = j;
        }
    }

    vector<ll> search(Type T, ll pos = 0){
        vector<ll> res;
        ll i = 0, j = pos;
        while(i < S.size() && j < T.size()){
            if(S[i] == T[j]) ++i, ++j;
            else if(!i) ++j;
            else i = A[i];
            if(i == S.size()){
                res.push_back(j - i);
                i = A[i];
                // ce(i, j);
            }
        }
        return res;
    }
};

int main(void){
    ll n;
    cin >> n;
    Vec a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    Vec c(n), d(n);
    rep(i, n) c[i] = a[i] ^ a[(i + 1) % n];
    rep(i, n) d[i] = b[i] ^ b[(i + 1) % n];
    c.insert(c.end(), all(c));
    // co_vec(c);

    KMP<Vec> kmp(d);
    auto v = kmp.search(c);
    for(ll i : v){
        if (i >= n) break;
        co(i, a[i] ^ b[0]);
    }

    return 0;
}


Measured memory_bytes: 21520
n, a, b=map(int, input().split())
def s(x):
  out=0
  sx=list(str(x))
  for i in range(len(sx)):
    out+=int(sx[i])
  return out

ans=0
for i in range(1, n+1):
  if a<=s(i)<=b:
    ans+=i
print(ans)

Measured memory_bytes: 3060
using System;

class Program
{
    const int TYPE_NUM = 26;

    static void Main(string[] args)
    {
        int i, j, k;

        int d = int.Parse(Console.ReadLine());
        int[] c = new int[TYPE_NUM + 1];
        int[,] s = new int[d + 1, TYPE_NUM + 1];

        string[] strInput = Console.ReadLine().Split(' ');
        for (i = 1; i <= TYPE_NUM; i++)
        {
            c[i] = int.Parse(strInput[i - 1]);
        }

        for (i = 1; i <= d; i++)
        {
            strInput = Console.ReadLine().Split(' ');
            for (j = 1; j <= TYPE_NUM; j++)
            {
                s[i, j] = int.Parse(strInput[j - 1]);
            }
        }

        int[] t = new int[d + 1];

        int[] choiceCandidate = new int[TYPE_NUM + 1];




        int result = 0;
        int[] last = new int[TYPE_NUM + 1];
        int resultDiff;
        int maxNo = 0;
        int maxDiff;

        for (i = 1; i <= d; i++)
        {
            maxNo = 0;
            maxDiff = int.MinValue;
            for (j = 1; j <= TYPE_NUM; j++)
            {
                choiceCandidate[j] = s[i, j];
                resultDiff = 0;
                for (k = 1; k <= TYPE_NUM; k++)
                {
                    if(k != j)
                    {
                        resultDiff += c[k] * (i - last[k]);
                    }
                }
                choiceCandidate[j] -= resultDiff;
                if(maxDiff < choiceCandidate[j])
                {
                    maxDiff = choiceCandidate[j];
                    maxNo = j;
                }
            }



            result += choiceCandidate[maxNo];
            last[maxNo] = i;
            //Console.WriteLine("result:" + result);
            Console.WriteLine(maxNo);
        }

        return;
    }
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    string s; cin >> s;
    if(s.size() == 2)out(s);
    else {
        reverse(all(s));
        out(s);
    }
}

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main { 

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] numberAandB = sc.nextLine().split(" ");
    	int numberCount  = Integer.parseInt(numberAandB[0]);
    	int startPoint = Integer.parseInt(numberAandB[1]);
    	
    	List<Integer> result = new ArrayList();
    	result.add(startPoint);
    	for(int i = 1;i<numberCount;i++) {
    		result.add(startPoint+i);
    		result.add(startPoint-i);
    	}
    	Collections.sort(result);
    	
    	String resultString = "";
    	for(int i = 0;i<result.size();i++) {
    		resultString+=result.get(i) + " ";
    	}
    	
    	
    	System.out.println(resultString.trim());
    	
    	
	}
}

Measured memory_bytes: 21844