akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static long mod;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		final int mod = (int)Math.pow(10,9)+7;
		final int N = 13;
		int r[] = new int[N];
		r[0]=1;
		int mul=1;
		for(int i=S.length()-1;i>=0;i--) {
			int nextr[]=new int[N];
			char tmp = S.charAt(i);
			if(tmp =='?') {
				for(int k=0;k<=9;k++) {
					int tmpnmod = k*mul%N;

					for(int j=0;j<N;j++) {
						int next = (j + tmpnmod)%N;
						nextr[next]+=r[j];
						nextr[next]%=mod;
					}
				}
			}else {
				int tmpn = tmp - '0'; 
				int tmpnmod = tmpn*mul%N;
				for(int j=0;j<N;j++) {
					int next = (j+tmpnmod)%N;
					nextr[next]=r[j];
				}
			}
			r = nextr;
			mul *= 10;
			mul %= mod;
			mul %= N;
		}
		System.out.println(r[5]);
	}
}


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

int main() {
  int x, y, z;
  scanf("%d %d %d", &x, &y, &z);
  printf("%d", std::min(std::abs(x - y) + std::abs(y - z),
                        std::min(std::abs(y - z) + std::abs(z - x),
                                 std::min(std::abs(y - x) + std::abs(x - z),
                                          std::abs(x - z) + std::abs(z - y)))));
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int b = sc.nextInt(), r = sc.nextInt(), g = sc.nextInt();
                                int c = sc.nextInt(), s = sc.nextInt(), t = sc.nextInt();
                                if (b + r + g + c + s + t == 0) {
                                        break;
                                }
                                System.out.println(100 -(t - s - b * 5 - r * 3) * 3 - b * 5 * 2 - r * 3 * 2 + b * 15 + r * 15 + (b * 5 + r * 3) * 15 + g * 7 + c * 2);
                        }
                }
        }
}

Measured memory_bytes: 28544
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int X;
	cin >> X;

	if (X >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	d := make(map[int]struct{})
	for _, v := range a {
		d[v] = struct{}{}
	}
	if len(d) == len(a) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 10320
#include<iostream>
#include<vector>
typedef unsigned long long ull;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF

int main()
{
  ull i,j,N,W,w,v;
  cin >> N >> W;
  vector<vector<ull>> dp;
  dp.resize(N);
  for(i=0;i<N;++i)
  {
    dp[i].resize(W+1,0);
  }
  cin >> w >> v;
  for(j=0;j<w;++j)
  {
    dp[0][j]=0;
  }
  for(j=w;j<=W;++j)
  {
    dp[0][j]=v;
  }
  for(i=1;i<N;++i)
  {
    cin >> w >> v;
    for(j=0;j<w;++j)
    {
      dp[i][j]=dp[i-1][j];
    }
    for(j=w;j<=W;++j)
    {
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v);
    }
  }
  cout << dp[N-1][W];
  return 0;
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;cin >> n >> x;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i]>x){
            ll u=a[i-1],v=a[i];
            ans+=u+v-x;
            if(a[i-1]>=x){
                a[i]=0;
                a[i-1]=x;
            }
            else{
                a[i]=x-u;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#define ll long long
using namespace std;

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

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

// 1-indexed
template <class T>
struct BIT {
  vector<T> lst;
  int treesize;
  // constructor
  BIT(int newn = 0) {
    treesize = newn;
    lst.resize(treesize + 1);
    for(int i = 0; i <= treesize; ++i) lst[i] = 0;
  }
  // a_place += num
  bool add(int place, T num) {
    while(place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
    return 1;
  }
  // add wide ver.(add num between l and r)
  bool addw(int left, int right, T num) {
    while(left <= right && left >= 1 && right <= treesize)
      add(left++, num);
    return 1;
  }
  // sum between [1,place]
  T calcsum(int place) {
    T answer = 0;
    while(place > 0) {
      answer += lst[place];
      place -= place & -place;
    }
    return answer;
  }
  // sum [l,r]
  T calcsumw(int left, int right) {
    return calcsum(right) - calcsum(left - 1);
  }
};

long long n, k;
vector<long long> a, sum;
map<long long, long long> mp;
BIT<long long> bit;

long long solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < n; ++i) a[i] -= k;
  sum.resize(n + 1);
  for(int i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i];
  sort(sum.begin(), sum.end());
  sum.erase(unique(sum.begin(), sum.end()), sum.end());
  for(int i = 0; i < sum.size(); ++i) mp[sum[i]] = i + 1;
  bit = BIT<long long>(n + 1);
  long long nsum = 0;
  bit.add(mp[0], 1);

  for(int i = 0; i < n; ++i) {
    nsum += a[i];
    auto it = upper_bound(sum.begin(), sum.end(), nsum);
    if(it != sum.begin()) ans += bit.calcsum(mp[*(--it)]);
    bit.add(mp[nsum], 1);
  }
  return ans;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
typedef pair<pair<ll, ll>,int> PP;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};

int use[55]={0};
int N,V,Pr;
ll M;
ll A[114514];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>N;
	cin>>M;
	cin>>V>>Pr;
	rep(i,N){
		cin>>A[i];
	}
	sort(A,A+N);
	reverse(A,A+N);
	/*rep(i,N)cout<<A[i]<<" ";
	cout<<endl;*/
	int ok=Pr-1,ng=N+1;//1-index
	while(ng-ok>1){
		int mid=(ng+ok)/2;
		//midで行けるかどうか
		int cnt=V-(Pr+N-mid);
		if(A[Pr-1]>A[mid-1]+M){
			ng=mid;
		}else if(cnt<=0){
			ok=mid;
		}else{
			//cnt問に+1　をM回繰り返してすべてA[mid-1]+M以下にできるかどうかチェック
			//A[mid-1]+M-A[i-1]<=Mに注意すると和だけ見ればよい。
			ll line=A[mid-1]+M;
			ll sum=0;
			bool flag=true;
			for(int i=Pr;i<=mid-1;i++){
				sum+=line-A[i-1];
				if(line-A[i-1]<0)flag=false;
			}
			//cout<<sum<<" "<<cnt<<" "<<M<<endl;
			if(flag){
				if(sum>=cnt*M)ok=mid;
				else ng=mid;
			}else{
				ng=mid;
			}
		}
	}
	
	cout<<ok<<endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String word = sc.next();
		int start = 0, end = 0;
		for(int i = 0; i < word.length(); i++) {
			if(word.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int i = word.length() - 1; i >= 0; i--) {
			if(word.charAt(i) == 'Z') {
				end = i;
				break;
			}
		}
		System.out.println((end - start + 1));
	}
}

Measured memory_bytes: 26032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int K;
    cin>>K;
    ll now=0,keta=0,ten=1;
    if(K%2==0 || K%5==0){
        cout<<-1<<endl;
        return 0;
    }
    while(true){
        keta++;
        now+=ten*7;
        now%=K;
        ten*=10;
        ten%=K;
        if(now==0){cout<<keta<<endl;return 0;}
        if(keta>K+10){
            cout<<-1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;
import java.io.*;



public class Main {
   public static void main(String[] args) throws IOException{
	   final   Scanner scan = new Scanner(System.in);
	   int n=scan.nextInt();
	   System.out.println("0.000000 0.000000");
	   koch(new double[]{0,0}, new double[]{100,0},n);
	   System.out.println("100.000000 0.000000");
   }
   
   public static void koch(double[] p,double[] q,int n){
	   double pi=Math.PI/3;
	if(n==0) return;
	double[] S={(2*p[0]+q[0])/3,(2*p[1]+q[1])/3};
	double[] T={(p[0]+2*q[0])/3,(p[1]+2*q[1])/3};
	double[] U={(T[0]-S[0])*Math.cos(pi)-(T[1]-S[1])*Math.sin(pi)+S[0],(T[0]-S[0])*Math.sin(pi)+(T[1]-S[1])*Math.cos(pi)+S[1]};

	koch(p.clone(),S.clone(),n-1);
    System.out.println(S[0]+" "+S[1]);
	koch(S.clone(),U.clone(),n-1);
	System.out.println(U[0]+" "+U[1]);
	koch(U.clone(),T.clone(),n-1);
	System.out.println(T[0]+" "+T[1]);
	koch(T.clone(),q.clone(),n-1);   
   }
}

Measured memory_bytes: 27432
########関数部分##############
def Base_10_to_n(X, n):
    X -= 1
    if (int(X/n)):
            return Base_10_to_n((X)//n, n) + str(X%n) + " "
    return str(X%n) + " "
############################

def nanketa(X):
    n = 1
    a = 0
    while X > (26 ** n) + a:
        a += 26 ** n
        n += 1
    return n


#####関数をつかってみる．#####
######今回は二進数に変換######
x10 = int(input())
x2 = Base_10_to_n(x10, 26)
##print(x2)
ans = ""
a = ""
cnt = 0
x2 = list(x2.split(" "))[:-1]
x2 = list(map(int, x2))
#if x2[-1] == 25:
    #x2[-1] = -1
#x2[-1] += 1
##print(x2)
for x in x2:
    ans += chr(x + 97)

print(ans)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define input_from_file  freopen("input.txt", "r", stdin);
#define inf 1000000000000000
using namespace std;

int main()
{
FASTIO
//input_from_file

int n, m;
cin >> n >> m;

int mod = 1e9 + 7;

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

int dp[n][m];
memset(dp, 0, sizeof(dp));

dp[0][0] = 1;

for(int i = 1; i < m; i++){
  if(a[0][i] != '#'){
    dp[0][i] = dp[0][i-1];
  }
}

for(int i = 1; i < n; i++){
  if(a[i][0] != '#'){
    dp[i][0] = dp[i-1][0];
  }
}

for(int i = 1; i < n; i++){
  for(int j = 1; j < m; j++){
    if(a[i][j] != '#'){
      dp[i][j] = dp[i-1][j] + dp[i][j-1];
      dp[i][j] = dp[i][j] % mod;
    }
  }
}

int ans = dp[n-1][m-1] % mod;
cout << ans;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,m; cin>>n>>m;
    long long x[n],y[m];
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    long long xx=0,yy=0;
    for(long long i=0;i<n;i++){
        if(x[i]<0) x[i]=(x[i]+MOD)%MOD;
        xx+=x[i]*i%MOD+MOD;
        xx-=x[i]*(n-1-i)%MOD;
        xx%=MOD;
    }
    for(long long i=0;i<m;i++){
        if(y[i]<0) y[i]=(y[i]+MOD)%MOD;
        yy+=y[i]*i%MOD+MOD;
        yy-=y[i]*(m-1-i)%MOD;
        yy%=MOD;
    }
    cout<<xx*yy%MOD<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}


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

int main() {
 long long n,M=0,A=0,R=0,C=0,H=0; cin >> n;
 vector<string> s(n);
 for(int i=0;i<n;i++){
   cin >> s[i];
   if(s[i][0]=='M'){
     M++;
   }
   if(s[i][0]=='A'){
     A++;
   }
   if(s[i][0]=='R'){
     R++;
   }
   if(s[i][0]=='C'){
     C++;
   }
   if(s[i][0]=='H'){
     H++;
   }
 }
 long long ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H;
 cout << ans << endl;

}


Measured memory_bytes: 6144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		List<String> list = new ArrayList<>();
		String W = scan.next();
		list.add(W);
		String preW;
		for (int i = 1; i < N; i++) {
			W = scan.next();
			if (list.contains(W)) {
				System.out.println("No");
				return;
			}
			preW = list.get(i - 1);
			if (preW.charAt(preW.length() - 1) != W.charAt(0)) {
				System.out.println("No");
				return;
			}
			list.add(W);
		}
		System.out.println("Yes");

	}
}


Measured memory_bytes: 23764
#include<iostream>

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

long long dp[100100][3];
long long a[100100][3];

int main(void){
    int n;
    std::cin >> n;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            chmax(dp[i+1][0], dp[i][1] + a[i][1]);
            chmax(dp[i+1][0], dp[i][2] + a[i][2]);

            chmax(dp[i+1][1], dp[i][0] + a[i][0]);
            chmax(dp[i+1][1], dp[i][2] + a[i][2]);

            chmax(dp[i+1][2], dp[i][0] + a[i][0]);
            chmax(dp[i+1][2], dp[i][1] + a[i][1]);
        }
    }

    long long ans = 0;
    chmax(ans, dp[n][0]);
    chmax(ans, dp[n][1]);
    chmax(ans, dp[n][2]);
    
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	string s; cin >> s;
	int len = (s.length() - 1) / 2;
	while (len > 0) {
		string l = s.substr(0, len);
		string r = s.substr(len, len);
		if (r == l)break;
		else len--;
	}
	cout << 2 * len << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

ll calc(ll A)
{
	if (A <= 0)
		return 0;
	// 10^3 <= 2^10
	// 1000 <= 1024
	// 10^12 <= 2^40
	// 10^12 <= 2進数 40桁くらい

	ll ans = 0;
	for (int i = 0; i < 50; i++)
	{
		// 0桁目　→　周期2
		// 1				4
		// 2				8
		// 3				16
		ll loop = (1LL << (i+1));
		ll cnt = (A / loop) * (loop / 2);
		cnt += max(0LL, (A % loop) - (loop / 2) + 1);

		// その桁の1の数が奇数だったら足し算
		if (cnt % 2 == 1)
			ans += 1LL << i;
	}
	return ans;
}

int		main(void)
{
	ll A, B;
	cin >> A >> B;
	ll ans = calc(B) ^ calc(A - 1);
	cout << ans << endl;
}



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

const long long MAX = 10000000;  // TLEならば小さくする
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (long long i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

// 重複組み合わせ計算
long long H(long long n, long long r) {
	return COM(n + r - 1, r);
}

int main() {
	
	ll s; cin >> s;
	COMinit(); // 前処理
	ll n = s / 3;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll x = s - 3 * i;
		ans += H(i, x);
		ans %= MOD;
	}
	cout << ans << endl;	
    return 0;
}

Measured memory_bytes: 238008
'use strict';
function Main(stdin){
  const input = stdin.trim().split(' ').map(str => Number(str));
  const X = input[0], Y = input[1];
  const tsuru = 2;
  const kame = 4;
  let result = 'No';

for(let i = 0; i <= X; i++){
    if(tsuru * i + kame * (X-i) === Y){
        result = 'Yes';
        break;
    }
}
  console.log(result);
}


// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=100 +117;
const int MM=100000 +117;
const int mod=1e9+7;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL dp[NN][2*NN]={};
LL fact[NN]={};
LL rev[NN]={};
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
void prefact(int n){
	fact[0]=1;
	for(int i=1;i<=n;++i){
		fact[i]=fact[i-1]*i%mod;
	}
	rev[n]=ksm(fact[n],mod-2);
	for(int i=n;i>=1;--i){
		rev[i-1]=rev[i]*i%mod;
	}
}
int main(){
	//open();
	n=read();
	int std=n;
	dp[1][std-1]=1;
	dp[1][std]=1;
	prefact(n);
	for(int i=1;i<n;++i){
		for(int j=0;j<=2*n;++j){
			int more=abs(j-std);
			int tp=j-std;
			for(int k=(more==0?2:more);k+i<=n;k+=2){
				for(int c=0;c<=k;++c){
					int xt=(tp+k-2*c)/2;
					if(xt>=-n&&xt<=n){
						dp[i+k][std+xt]+=dp[i][j]*rev[k-c]%mod*rev[c];
						dp[i+k][std+xt]%=mod;
					}
				}
			}
		}
	}
	printf("%lld\n",dp[n][std]*fact[n]%mod);
	close();
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

char S[50];

int main()
{
  int cnt;
  int N, K;
  int i;
  int result = 0;
  int offset = (int)('a' - 'A');

  cnt = scanf("%d %d", &N, &K);
  cnt = scanf("%s", S);

  S[K-1] += offset;

  printf("%s", S);

  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

//計算の高速化を図るためにあらかじめ値を格納した配列を用意しておくパターン。

int max(int a, int b){
  if(a>=b){
    return a;
  }
  else{
    return b;
  }
}

int gcd(int a, int b){
  if(a<b){
    int temp=a;
    a=b;
    b=temp;
  }
  int c;
  while(a%b!=0){
    c=a%b;
    a=b;
    b=c;
  }
  return b;
}


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&A[i]);
  }

  int *L=(int *)malloc(sizeof(int)*N);
  int *R=(int *)malloc(sizeof(int)*N);
  L[0]=A[0];
  R[N-1]=A[N-1];

  srep(i,1,N){
    L[i]=gcd(L[i-1], A[i]);
    R[N-1-i]=gcd(R[N-i],A[N-1-i]);
  }

  int ans=R[1];
  srep(i,1,N-1){
    int temp=gcd(L[i-1], R[i+1]);
    ans=max(temp, ans);
  }
  ans=max(ans, L[N-2]);

  printf("%d\n", ans);

  return 0;


}


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

template<typename T> struct Edge {
    int to;
    T cost;
    Edge(int t, T c) : to(t), cost(c) {}
};

template<typename T> vector<T> dijkstra(const vector<vector<Edge<T>>> g, int s) {
    T EPS = (T)1e-10;
    T INF = (T)1e18;
    vector<T> d(g.size(), INF);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<>> q;
    d.at(s) = 0;
    q.emplace(d.at(s), s);
    while ( !q.empty() ) {
        auto p = q.top();
        q.pop();
        int v = p.second;
        if ( d.at(v) + EPS < p.first ) continue;
        for ( auto e : g[v]) {
            if ( d.at(e.to) > d.at(v) + e.cost ) {
                d.at(e.to) = d.at(v) + e.cost;
                q.emplace(d.at(e.to), e.to);
            }
        }
    }
    return d;
}

using Eg = Edge<double>;

double solve() {
    double e = 1e-12;
    double xs, ys, xt, yt;
    ll N;
    cin >> xs >> ys >> xt >> yt;
    cin >> N;
    vector<double> X(N+2), Y(N+2), R(N+2), dst(N+2, 1e14);
    for ( int i = 1; i <= N; i++ ) {
        cin >> X[i] >> Y[i] >> R[i];
    }
    X[0] = xs, Y[0] = ys, R[0] = 0;
    X[N+1] = xt, Y[N+1] = yt, R[N+1] = 0;

    auto f_dist = [&](int a, int b) {
        double dx = X[a] - X[b], dy = Y[a] - Y[b];
        return max(0.0, sqrt(dx*dx+dy*dy) - R[a] - R[b]);
    };
    
    vector<vector<Eg>> G(N+2);
    for ( int i = 0; i < N+2; i++ ) {
        for ( int j = i; j < N+2; j++ ) {
            if ( i != j ) {
                double w = f_dist(i,j);
                G[i].emplace_back(j, w);
                G[j].emplace_back(i, w);
            }
        }
    }

    auto ans = dijkstra(G, 0);
    return ans[N+1];
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 38148
# https://atcoder.jp/contests/abc162/submissions/11837869
# tamazooさんを参考に書いた
n = int(input())
s = input()
x = [0] * n
num_r, num_g, num_b = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        x[i] = 1
        num_r += 1
    elif s[i] == 'G':
        x[i] = 2
        num_g += 1
    elif s[i] == 'B':
        x[i] = 4
        num_b += 1

num = num_r * num_g * num_b

for i in range(n):
    for j in range(1, n):
        if i - j < 0 or n <= i + j:
            break
        else:
            if (x[i - j] + x[i] + x[i + j]) == 7:
                num -= 1
print(num)


Measured memory_bytes: 68204
from bisect import bisect_left
import sys
input = sys.stdin.readline

class SegmentTree():
    def __init__(self,size,func,default):
        self.leaf=2**(size-1).bit_length()
        self.data=[default]*(2*self.leaf-1)
        self.f=func; self.d=default
    def rangeupdate(self,l,r,x):
        l+=self.leaf-1; r+=self.leaf-1
        while l<r:
            if not l&1:
                self.data[l]=self.f(self.data[l],x)
                l+=1
            if not r&1:
                r-=1
                self.data[r]=self.f(self.data[r],x)
            l>>=1; r>>=1
    def getvalue(self,i):
        k=i+self.leaf-1
        ret=self.d
        while k>=0:
            ret=self.f(ret,self.data[k])
            k=(k-1)>>1
        return ret

#最大値            
def segfunc(x,y):
    return max(x,y)

#最小値
def segfunc2(x,y):
    return min(x,y)
#和
def segfunc3(x,y):
    return x | y


def main():
    N, Q = map(int, input().split())
    construction = []
    for _ in range(N):
        S, T, X = map(int, input().split())
        construction.append([S,T,X])

    D = [int(input()) for _ in range(Q)]
    seg = SegmentTree(Q,segfunc2,float('inf'))

    for i in range(N):
        S, T, X = construction[i]
        l = bisect_left(D, S - X)
        r = bisect_left(D, T - X)
        seg.rangeupdate(l, r, X)
    
    for q in range(Q):
        ans = seg.getvalue(q)
        if ans == float('inf'):
            print(-1)
        else:
            print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 125020
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, x;

int32_t main(){_
   
   cin >> x;

   for (int a = -5000; a <= 5000; ++a)
   {
      for (int b = -5000; b <= 5000; ++b)
      {
         int pro1 = a * a * a * a * a;   
         int pro2 = b * b * b * b * b;
         if (pro1 - pro2 == x){
               cout<<a<<" "<<b;
               exit(0);
            }   
      }
   }
   

   return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,k,g[100001],qmin=INT_MAX;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>g[i];
	}
	sort(g,g+n);
	for(int i=k-1;i<n;i++)
	{
		qmin=min(qmin,g[i]-g[i-k+1]);
	}
	cout<<qmin;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>

using namespace std;

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

const long long inf = (1ll<<31) - 1;

struct SegTree { // ??????min,max
	int n;
	vector<int> Min;
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		Min.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; ++i) {
			Min[i] = inf;
		}
	}
	void update(int idx, int val) {
		idx += n - 1;
		Min[idx] = val;
		while (idx > 0) {
			idx = (idx - 1) / 2;
			Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
		}
	}
	int get_min(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)???min
		if (r == -1) r = n;
		if (r <= a || b <= l) return inf;
		if (a <= l && r <= b) return Min[k];
		int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

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

	SegTree seg;

	seg.init(n);

	rep(i, q) {
		int type, x, y;
		scanf("%d%d%d", &type, &x, &y);

		if (type % 2 == 0) {
			seg.update(x, y);
		} else {
			printf("%d\n", seg.get_min(x, y + 1));
		}
	}
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

int n, Q;
int arr[N + 2];


void solve()
{
	string str; cin >> str;
	int n = str.length();


	int ans = 0, rem = 0;
	int p = 1;
	unordered_map<int, int> mp2;
	mp2[0]++;
	rlop(i, n - 1, 0)
	{
		int d = str[i] - '0';
		rem = ( rem + p * (d) ) % 2019;
		if ( mp2.count(rem) ) ans += mp2[rem], mp2[rem]++;
		else mp2[rem] = 1;
		p = (10 * p) % 2019;
	}

	cout << ans;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 3788
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		set<int> s;
		repi(i,1,n)
			s.insert(i*i%n);
		vi a(allof(s));
		vi res(n/2+1);
		rep(i,a.size()) rep(j,a.size()){
			if(i==j) continue;
			int temp=a[i]-a[j];
			if(temp<0) temp+=n;
			if(temp>n/2) temp=n-temp;
			res[temp]++;
		}
		repi(i,1,res.size())
			cout<<res[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const int N = 1e6+11;
int n,a[N];char s[N];
int main() {
	read(n);scanf("%s",s+1);
	rep(i,1,n)a[i-1]=s[i]-'0'-1;
	int res=0;rep(i,0,n-1)if(a[i]&1)res^=((n-1)&i)==i;
	if(res&1)puts("1");
	else{
		bool fd=0;rep(i,0,n-1)fd|=a[i]==1;
		if(fd)puts("0");
		else{
			res=0;rep(i,0,n-1)if(a[i]==2)res^=((n-1)&i)==i;printf("%d",2*(res%2));
		}
	}
	return 0;
}
//2311312312

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n+2), b(n+2);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    a[0] = a[n+1] = 0;
    for(int i = 1; i <= n+1; i++){
        b[i]      = abs(a[i] - a[i-1]);
        b[i] += b[i-1];
    }
    for(int i = 1; i <= n; i++){
        printf("%d\n", b[i-1] + abs(a[i-1] - a[i+1]) + b[n+1] - b[i+1]);
    }
    return 0;
}

Measured memory_bytes: 2048
a,b=map(int,input().split())
res = 0
if a == 0:
  if b == 100:
    res = 101
  else:
    res = b
elif a == 1:
  if b == 100:
    res = 10100
  else:
    res =100*b
else:
  if b == 100:
    res = 1010000
  else:
    res =10000*b
print(res)

Measured memory_bytes: 9184
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func main() {
	n := nextInt()
	fmt.Println(n * (n - 1) / 2)
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n > 0) {
        n /= k;
        ans++;
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (ll i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec)is>>x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i, vec.size()) {
        if(i) os << " ";
        os << vec[i];
    }
    return os;
}

struct Edge {
    ll to, cap, rev;
};
vector< vector<Edge> > G;

void add_edge(ll from, ll to, ll cap) {
    G[from].pb({to, cap, (ll)G[to].size()});
    G[to].pb({from, 0, (ll)G[from].size()-1});
}
ll dfs(ll v, ll t, ll f, const vector<ll>& dist) {
    if (v == t) return f;
    EACH(e, G[v]) {
        if (e.cap > 0 && dist[e.to] == dist[v]+1) {
            ll d = dfs(e.to, t, min(f, e.cap), dist);
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
vector<ll> bfs(ll s) {
    vector<ll> res(G.size(), linf);
    res[s] = 0;
    queue<ll> Q; Q.push(s);
    while ( !Q.empty() ) {
        ll v = Q.front(); Q.pop();
        EACH(e, G[v]) {
            if (e.cap > 0 && res[e.to] == linf) {
                res[e.to] = res[v]+1;
                Q.push(e.to);
            }
        }
    }
    return res;
}
ll max_flow(ll s, ll t) {
    ll res = 0;
    while (1) {
        vector<ll> dist = bfs(s);
        if (dist[t] == linf) break;
        while (1) {
            ll f = dfs(s, t, linf, dist);
            if (f == 0) break;
            res += f;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    int v1 = m / n;
    int v2 = v1 + (m % n == 0 ? 0 : 1);
    cout << v2-v1 << endl;
    vector< vector<ll> > H(n, vector<ll>(m)); cin >> H;
    ll ss = n + m, s = ss+1, t = s+1;
    G.resize(t+1);
    REP(i, m) {
        add_edge(n+i, t, 1);
    }
    REP(i, n) {
        add_edge(s, i, v1);
        add_edge(ss, i, 1);
    }
    add_edge(s, ss, m-n*v1);
    map<ll, vector<P>> ev;
    REP(i, n) REP(j, m) {
        ev[H[i][j]].pb({i, j});
    }
    ll f = 0;
    ll ans = linf;
    EACH(dt, ev) {
        EACH(p, dt.second) {
            assert(dt.first == H[p.first][p.second]);
            add_edge(p.first, n+p.second, 1);
        }
        f += max_flow(s, t);
        if (f == m) {
            ans = dt.first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import java.util.Scanner;

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

        int N = scanner.nextInt();

        if (N % 2 == 0) {
            double answer = 0.5;
            System.out.println(answer);
        } else {
            double answer = (N + 1.0) / (2.0 * N);
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 35840
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
using namespace std;

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

  int32_t H, N;
  cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    cin >> tmp;
    sum += tmp;
  }
  if (sum >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 400005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

/*long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}*/


int main(){
    ll N, X;
    cin>>N>>X;
    vector<ll> A(N);
    rep(i, N){
        cin>>A[i];
        
    }
    ll Sum=0;
    if(A[0]-X>0){
        Sum+=A[0]-X;
        A[0]=X;
    }
    rep(i, N-1){
        if(A[i]+A[i+1]>X){
            Sum+=A[i]+A[i+1]-X;
            if(X-A[i]>0){
              A[i+1]=X-A[i];
            }else{
              	A[i+1]=0;
            }
        }
        
    }
  	cout<<Sum<<endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    ss = [S[i:(i+3)] for i in range(N-2)]
    ans = sum([1 for i, x in enumerate(ss) if x == 'ABC'])
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(M);
	for (int i = 0; i < M; i++) {
		cin >> a.at(i);
	}

	vector<long long> dp(N+1, 0);
	dp.at(0) = 1;

	// 速くなるのかわかんないけど、壊れている床をメモ化してみる
	map<int, bool> alive;
	for (int i = 0; i <= N; i++) {
		alive[i] = true;
	}
	for (int i : a) {
		alive[i] = false;
	}

	for (int i = 0; i < N; i++) {
		if (!alive.at(i)) {
			continue;
		}
		if (alive.at(i+1)) {
			dp.at(i+1) += dp.at(i);
			dp.at(i+1) %= 1000000007;
		}
		if (i+2 <= N && alive.at(i+2)) {
			dp.at(i+2) += dp.at(i);
			dp.at(i+2) %= 1000000007;
		}
	}

	cout << dp.at(N) << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

//境界値に注意！！！

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(min(b,d)-max(a,c),0) << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BColorfulHats solver = new BColorfulHats();
        solver.solve(1, in, out);
        out.close();
    }

    static class BColorfulHats {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] hat = new int[n];
            for (int i = 0; i < n; i++) {
                hat[i] = in.nextInt();
            }
            Arrays.sort(hat);
            if (hat[n - 1] - hat[0] > 1) {
                out.println("No");
                return;
            }
            if (hat[n - 1] == hat[0]) {
                out.println((hat[n - 1] <= n / 2) || hat[n - 1] == n - 1
                        ? "Yes"
                        : "No");
                return;
            }

            int unique = 0;
            for (int i = 1; i < n; i++) {
                if (hat[i] != hat[i - 1]) unique = i;
            }

            out.println(unique + 1 <= hat[n - 1]
                    && hat[n - 1] <= unique + (n - unique) / 2
                    ? "Yes"
                    : "No");
        }

    }
}



Measured memory_bytes: 61000
A, B, C = tuple(map(int, input().split(" ")))
k = sorted([A, B, C])
if k[0] == k[1]:
    if k[1] == k[2]:
        print("No")
    else:
        print("Yes")
elif k[1] == k[2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import sys
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a-=1
    b-=1
    graph[a].append((b, c))
    graph[b].append((a, c))
q, k = map(int, input().split())
k -= 1
xy = []
for _ in range(q):
    x, y = map(int, input().split())
    x-=1
    y-=1
    xy.append((x, y))

def DFS(node, p_node, length):
    l[node] = length
    for i, j in graph[node]:
        if i==p_node:
            continue
        DFS(i, node, length+j)
sys.setrecursionlimit(2 * n)
l = [0]*n
DFS(k, -1, 0)
for x, y in xy:
    print(l[x]+l[y])


Measured memory_bytes: 145140
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n; cin >> n;
  vector <ll> a(n);
  for(auto &x : a) cin >> x;
  sort(a.begin(), a.end());
  int ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      for(int k = j + 1; k < n; k++) {
        if(a[i] != a[j] and a[j] != a[k] and a[i] != a[k]) {
          if(a[i] + a[j] > a[k]) ans++;
        }
      }
    }
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

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

int main()
{
    int N, K, x, sum = 0;
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; ++i)
    {
        scanf("%d", &x);
        sum += std::min(x, K-x) * 2;
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128