akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long N;
        N = sc.nextLong();
        String[] s = new String[(int)(N)];
        long[] t = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                s[i] = sc.next();
                t[i] = sc.nextLong();
        }
        String X;
        X = sc.next();
        solve(N, s, t, X);
    }

    static void solve(long N, String[] s, long[] t, String X){
        HashMap<String, Long> timeSum = new HashMap<>();

        long time = 0;
        for (int i = 0; i < N; i++) {
            time += t[i];
            timeSum.put(s[i], time);
        }

        System.out.println(time - timeSum.get(X));
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 20820
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
typedef long long int ll;
using namespace std;
int Z[300000];int V[300000]; 
int main()
{
	int N;cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>Z[i];
	}
	memcpy(V,Z,sizeof(V));
	sort(Z,Z+N);
	int l=Z[N/2-1];int r=Z[N/2];
	for(int i=0;i<N;i++)
	{
		if(V[i]>l)
		cout<<l;
		else
		cout<<r;
		cout<<endl;
	}
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
MOD = 1000000007

dp = [0]*(n+2)
dp[0] = 1
for i in range(n):
    if i+1 not in a:
        dp[i+1] += dp[i]
        dp[i+1] %= MOD
    if i+2 not in a:
        dp[i+2] += dp[i]
        dp[i+2] %= MOD

print(dp[-2])


Measured memory_bytes: 13216
N = gets.to_i
A = [0]
N.times {
  A << gets.chomp.to_i
}

i = 1
judge = false
ans = 0

while ans <= N do
i = A[i] #ボタンを押す 
ans += 1
if i == 2 then
  judge = true
  break
end
end
  
if judge
  p ans
else
  p -1
end
  

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int N = 100000;

vector<int> a[N];

int dfs(int i) {
	vector<int> v;
	for (int j : a[i]) {
		v.push_back(dfs(j));
	}
	sort(v.rbegin(), v.rend());
	int ret = 0;
	for (int i = 0; i < v.size(); i++) {
		ret = max(ret, v[i] + i + 1);
	}
	return ret;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int t;
		cin >> t;
		a[t - 1].push_back(i);
	}
	cout << dfs(0) << endl;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
ll w[100],v[100];

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	ll n,weight,totalval=0;
	cin>>n>>weight;
	f(n){
		cin>>w[i]>>v[i];
		totalval+=v[i];
	}
	ll ans=0,dp[totalval+1];
	f(totalval+1)	dp[i]=INT_MAX;
	// dp[i] = min weight to get value exactly i
	dp[0]=0;
	for(int i=0;i<n;i++)
		for(int j = totalval;j>=v[i];j--){
			dp[j] = min(dp[j],w[i]+dp[j-v[i]]);
			//cout<<dp[j]<<" "<<j<<"\n";
			if(dp[j]<=weight)
				ans = max(ans,(ll)j);
		}
	cout<<ans<<"\n";
return 0;	
}

Measured memory_bytes: 4400
n=int(input())
a=[0]
r=list(map(int,input().split()))
for i in range(n):
  a.append(r[i])
b=[0 for i in range(n+1)]


for i in range((n//2+1),n+1):
  b[i]=a[i]
for i in range(n//2,0,-1):
  j=2
  b[i]=a[i]
  while(j*i<=n):
    b[i]^=b[j*i]
    j+=1

m=0
for i in range(n+1):
  m+=b[i]
print(m)
for i in range(1,n+1):
  if b[i]==1:
    print(i)



Measured memory_bytes: 9788
#include <cstdio>
#include <set>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::set<int> x;
  for (size_t i=0; i<N; ++i) {
    int a;
    scanf("%d", &a);
    x.insert(a);
  }
  if (x.size() & 1) {
    printf("%jd\n", x.size());
  } else {
    printf("%jd\n", x.size()-1);
  }
}


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

int main(void) {
    int n;
    cin >> n;
    int ans = 0;
    string s;
    for (int i = 1; i <= n; ++i) {
        s = to_string(i);
        if (s.length() % 2 == 1) {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int ab = 0;
  int bc = 0;
  int ca = 0;
  
  // 三角形の3辺の長さを取得
  scanf( "%d %d %d", &ab, &bc, &ca );
  
  // 面積を出力
  printf( "%d\n", ( ab * bc ) / 2 );
  
  return 0;
}

Measured memory_bytes: 128
n,x,m = map(int, input().split())

lm = [x]
a = x

zero = 0
for i in range(m):
    a = a ** 2 % m
    if a == 0:
        zero = 1
        break
    lm.append(a)

if zero == 1:
    if n < len(lm):
        print(sum(lm[:n]))
    else:
        print(sum(lm))
        

else:
    last = lm[m]
    for i in range(1, m+1):
        if lm[m-i] == last:
            syuki = i
            break

    for i in range(2, m//syuki + 2):
        if m - i*syuki < 0:
            amari = (m+1) % syuki
        if lm[m - i*syuki] != last:
            amari = m - (i-1) * syuki + 1
            break

    l1 = lm[:amari]
    l2 = lm[amari:amari + syuki]


    if n <= amari:
        print(sum(l1[:n]))

    else:
        n -= amari
        print(sum(l1) + sum(l2) * (n//syuki) + sum(l2[:(n%syuki)]))

Measured memory_bytes: 73108
object Main extends App {

  import scala.io.StdIn._
  val numbers = readLine.trim.split(' ').map(_.toInt)
  println(
    if (List(1, 9, 7, 4).forall(i ⇒ numbers.contains(i))) "YES"
    else "NO"
  )
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}

Measured memory_bytes: 25544
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int stack[1000];
int n;
void push(int);
int pop(void);


int main(){
  int x,a,b,c;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      b=pop();
      a=pop();
      push(a+b);
    
    }
    else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    
      
    }
    else if ( s[0] == '*' ){
      b=pop();
      a=pop();
      push(a*b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[n]);

  return 0;
}
 
int pop(void)
{
  if(n == 0) fprintf(stderr,"stack underflow\n");
  --n;
  return (stack[n+1]);
}
  
void push(int f)
{
  if(n >= 100){
    fprintf(stderr,"stack overflow\n");
   
  }
  n++;
  stack[n]=f;

}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>
#include <cstring>

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
	int n=nxi(),m=nxi(),x=nxi(),y=nxi();
	if(n%x==0&&m%y==0){
		puts("No");
		return 0;
	}
	puts("Yes");
	if(m%y){
		const int w=(y-1)*1000+1;
		for(int i=1; i<=n; ++i){
			for(int j=1; j<=m; ++j){
				printf("%d ",j%y?1000:-w);
			}
			puts("");
		}
	}
	else if(n%x){
		const int w=(x-1)*1000+1;
		for(int i=1; i<=n; ++i){
			for(int j=1; j<=m; ++j){
				printf("%d ",i%x?1000:-w);
			}
			puts("");
		}
	}
	return 0;
}


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

typedef long long ll;

int n,a;
vector<int> G[100001];
int d[100001];
int p[100001][30];

int lca(int a,int b){
  if(d[a]<d[b])swap(a,b);
  for(int i=29;i>=0;i--)
    if((d[a]-d[b])>>i&1)
      a=p[a][i];
  if(a==b)return a;
  for(int i=29;i>=0;i--){
    if(p[a][i]!=p[b][i]){
      a=p[a][i];
      b=p[b][i];
    }
  }
  return p[a][0];
}

int main(){
  scanf("%d",&n);
  for(int i=2;i<=n;i++){
    scanf("%d",&a);
    G[a].push_back(i);
    p[i][0]=a;
  }
  p[1][0]=1;
  for(int k=1;k<30;k++){
    for(int i=1;i<=n;i++){
      p[i][k]=p[p[i][k-1]][k-1];
    }
  }
  for(int i=1;i<=n;i++){
    sort(G[i].begin(),G[i].end());
  }
  queue<int> Q;
  Q.push(1);
  int prev=1;
  ll ans=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    ans+=(d[prev]+d[pos]-d[lca(prev,pos)]*2);
    for(int to:G[pos]){
      d[to]=d[pos]+1;
      Q.push(to);
    }
    prev=pos;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 20764
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
INF = 10**9

dp = [[0]*2 for _ in range(n+1)] # dp[i][0]がiを選んで反転させない場合の最大値, dp[i][1]がiを選んで反転させた場合の最大値

dp[0][0] = 0 
dp[0][1] = -INF

for i in range(1,n+1):
    dp[i][0] = max(dp[i-1][0]+A[i-1], dp[i-1][1]-A[i-1]) # iを選んで反転させない時、 i-1を選んで反転させていなかったらiはそのままで、i-1を反転させていたらiは反転する
    dp[i][1] = max(dp[i-1][0]-A[i-1], dp[i-1][1]+A[i-1]) # iを選んで反転させる時、i-1を選んで反転させていなかったらiは反転していて、i-1を反転させていたらiはそのまま

print(dp[n][0]) # nを選ぶことはできない（n+1が存在しない）ため、答えはdp[n][0]

Measured memory_bytes: 31312
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int abs(int x){
    if(x<0)return -x;
    return x;
}


int main(void){
    long long N,H;
    int x[110];
    int y[110];
    long long h[110];
    int flag =true;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i]>>h[i];
    }
    for(int Cx=0;Cx<101;Cx++){
        for(int Cy=0;Cy<101;Cy++){
            flag=true;
            H=-1;
            for(int n=0;n<N;n++){
                if(h[n]==0)continue;
                H = (-1)*(-h[n]-llabs(x[n]-Cx)-llabs(y[n]-Cy));
                break;
            }
            for(int n=0;n<N;n++){
                if(flag==false)break;
                if(h[n]==0){
                    if(h[n]<(H-abs(x[n]-Cx)-abs(y[n]-Cy))){
                        flag = false;
                    }
                }else{
                    if(h[n]!=(H-abs(x[n]-Cx)-abs(y[n]-Cy))){
                        flag=false;
                    }
                }
            }
            if(flag==true){
                cout<<Cx<<" "<<Cy<<" "<<H<<endl;
                return 0;
            }
        }
    }



    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int F[50];
  F[0] = F[1] = 1;
  for(int i = 2; i <= n;i++) F[i] = F[i-1] + F[i-2];
  cout << F[n] << endl;
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++)cin>>x[i];
    int ans=1e9;
    for(int i=0;i<n-k+1;i++){
        int l=x[i],r=x[i+k-1];
        int sum;
        if(r==0||l==0)sum=max(abs(r),abs(l));
        else if(r/abs(r)!=l/abs(l)){
            if(abs(r)<abs(l))sum=abs(r)*2+abs(l);
            else sum=abs(l)*2+abs(r);
        }else{
            if(abs(r)<abs(l))sum=abs(l);
            else sum=abs(r);
        }
        if(ans>sum)ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
double prob[3000][3005];
void solve(long long N, std::vector<long double> p)
{
  prob[0][0] = 1;
  rep(i, N) rep(j, i + 1)
  {
    prob[i + 1][j + 1] += prob[i][j] * p[i];
    prob[i + 1][j] += prob[i][j] * (1 - p[i]);
  }
  double ans = 0;
  rep(j, N + 1)
  {
    if (j > N - j)
    {
      ans += prob[N][j];
    }
  }
  printf("%.10f\n", ans);
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long double> p(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%Lf", &p[i]);
  }
  solve(N, std::move(p));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 69120
n, x, m = gets.split.map(&:to_i)
a = [0]
a[1] = x
h = Hash.new(0)
h[x] = 1
1.upto(n.pred) do |i|
  a[i + 1] = a[i] * a[i] % m
  if h[a[i + 1]].zero?
    h[a[i + 1]] = i + 1
  else
    break
  end
end
a = a[1..a[1..-1].find_index{ _1 == a[-1] }]
b = h.sort_by{ |k, v| v}.map { |k, v| k } - a
ans = a.sum
c = n - a.size
ans += (c / b.size) * b.sum
ans += b[0, c % b.size].sum if c % b.size > 0
puts ans

Measured memory_bytes: 19812
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[3],b[3];
gets(a);
gets(b);
char c=a[2];
a[2]=a[0],a[0]=c;
for(int i=0;i<3;i++)
if(a[i]!=b[i]){
cout<<"NO";
return 0;}
cout<<"YES";}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c;
    ll ans=0;
    cin>>a>>b>>c;
    if (a%c==0){
        ans++;
    }
    ans+=b/c-a/c;
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = 1, x;
		while ((x = sc.nextInt()) != 0) {
			System.out.println("Case " + i + ": " + x);
			i++;
		}
	}
}



Measured memory_bytes: 41820
package main

import (
	"fmt"
)

func cntDivisors(a, b, c int) int {
	cnt := 0
		for i := a; i <= b; i++ {
			if i > c {
				break
			} else if c % i == 0{
				cnt++
			}
		} 
	return cnt
}

func main(){
	var a, b, c int
			fmt.Scan(&a)
			fmt.Scan(&b)
			fmt.Scan(&c)
	fmt.Println(cntDivisors(a, b, c))
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = (int)pow(2, 31) - 1;
int pow_mod(int a, int b) {
    if(b == 0) {
        return 1;
    }
    int mid = pow(a, b / 2);
    if(b % 2 == 0) {
        return (mid * mid ) % mod;
    }else {
        return (((a * mid) % mod) * mid) % mod; 
    }
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int ans = k;
    ans *= pow_mod(k - 1, n - 1);
    ans %= mod;
    cout << ans << "\n";
}


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

int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int N = 3 * n;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<int> L(n + 1), R(n + 1);

    int sum = 0;
    priority_queue<int, vector<int>, greater<int>> que1;
    rep(i, n)
    {
        sum += a[i];
        que1.push(a[i]);
    }
    L[0] = sum;
    rep(i, n)
    {
        int x = a[i + n], y = que1.top();
        if (x > y)
        {
            sum = sum - y + x;
            que1.pop();
            que1.push(x);
        }
        L[i + 1] = sum;
    }

    sum = 0;
    priority_queue<int> que2;
    rep(i, n)
    {
        sum += a[N - i - 1];
        que2.push(a[N - i - 1]);
    }
    R[n] = sum;
    rep(i, n)
    {
        int x = a[2 * n - i - 1], y = que2.top();
        if (x < y)
        {
            sum = sum - y + x;
            que2.pop();
            que2.push(x);
        }
        R[n - i - 1] = sum;
    }

    int ans = -INF;
    rep(i, n + 1) ans = max(ans, L[i] - R[i]);
    cout << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  
  long long ans=0;
  
  for(int i=1;i<=N;i++){
    if(!(i%3==0 ||i%5==0)){
      ans+=i;
    }
  }
  cout<<ans<<endl;



}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define NAME "E"
#define vt vector
#define ll long long
#define fi first
#define se second
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

void init()
{
    freopen(NAME".inp","r",stdin);
    freopen(NAME".out","w",stdout);
    time
}

const int N=3005;
string a,b;

void inp()
{
    cin>>a>>b;
}

string c;
int f[N][N] {0};

void solve()
{
    for(int i=0;i<a.size();i++)
    {
        for(int j=0;j<b.size();j++)
        {
            if(a[i]==b[j]) f[i+1][j+1]=f[i][j]+1;
            else f[i+1][j+1]=max(f[i+1][j],f[i][j+1]);
        }
    }
    int i=a.size(),j=b.size();
    while(i>=0 && j>=0)
    {
        if(f[i][j-1]==f[i][j]) j--;
        else if(f[i-1][j]==f[i][j]) i--;
        else
        {
            if(a[i-1]==b[j-1]) c.pb(a[i-1]);
            i--,j--;
        }
    }
    for(int i=c.size()-1;i>=0;i--) cout<<c[i];
}

void out()
{
    solve();
}

int main()
{
   // init();
    inp();
    out();
}



Measured memory_bytes: 35456
import numpy as np
import sys
input = sys.stdin.readline

def main(args):
    N,C = map(int,input().split())
    
    time = [[0]*(10**5+1) for _ in range(C)]
    
    for _ in range(N):
        s, t, c = map(lambda x:int(x)-1,input().split())
        time[c-1][s] += 1
        time[c-1][t+1] -= 1
        
    recorder = np.where(np.cumsum(time[0]) > 0, 1, 0)
    
    for i in range(1,C):
        recorder += np.where(np.cumsum(time[i]) > 0, 1, 0)
    
    print(max(recorder))
    
if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 40516
s =input()
l, i  = len(s) + 1, 1
while i < l:
    if i % 2:
        if  s[i - 1] == 'L':
            break
    else:
        if s[i - 1] == 'R':
            break
    i += 1
if i == l:
    print('Yes')
else:
    print('No')


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

int main() {
  int n;
  cin >> n;
  
  //入力値をsetに格納(重複を除いてくれる)
  set<string> st;

  //景品の種類を判別する
  rep(i,n) {
    string s;
    cin >> s;
    st.insert(s); //setに登録している
  }

  cout << st.size() << endl;
}


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

int main(void)
{
    long int N;
    cin >> N;
    long int num[5];
    for(int i = 0; i < 5; i++)
    {
        cin >> num[i];
    }
    sort(num, num+5);
    cout << (N + num[0] - 1) / num[0] + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{
	int a, b, answer = 0;
	cin >> a >> b;

	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) {
			answer++;
		}
	}
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int x;
  cin >> x;
  int ans = 0;
  for(int i = 1; i < 1000; i++) {
    for(int j = 2; j < 1000; j++) {
      int a = pow(i,j);
      if(a > x) {
        break;
      } else {
        ans = max(ans,a);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int is_prime[1000010];
vector<int> prime;

int a,d,n;
void prime_check(){
	prime.push_back(2);
	is_prime[2]=1;
	for(int i=3;i<=1000000;i++){
		int flag=0;
		for(int j=0;j<prime.size()&&sqrt(i)>=prime[j];j++){
			if(i%prime[j]==0){
				flag=1;
				break;
			}
		}
		if(!flag){
			is_prime[i]=1;
			prime.push_back(i);
		}
	}
	return;
}

int main(){
	prime_check();
	while(1){
		cin>>a>>d>>n;
		if(a==0&&d==0&&n==0)break;
		int st;
		for(st=a;1;st+=d){
			if(is_prime[st])n--;
			if(n==0)break;
			
		}
		cout<<st<<endl;
	}
	return 0;
}
		
			


Measured memory_bytes: 7120
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+1;

int n, sz[MAX];
vector<pair<int,int>> g[MAX];
vector<int> centroids;
long long sum;

void dfs(int u, int par) {
	sz[u] = 1;
	bool valid = true;
	for(auto p: g[u]) if(p.first != par) {
		dfs(p.first, u);
		sz[u] += sz[p.first];
		valid &= sz[p.first] <= n/2;
		sum += 2ll * min(n - sz[p.first], sz[p.first]) * p.second;
	}
	if(n - sz[u] <= n/2 && valid) centroids.push_back(u);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 0, u, v, w; i < n-1; i++) {
		cin >> u >> v >> w; --u; --v;
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
	}
	dfs(0, -1);
	assert(centroids.size() <= 2);
	if(centroids.size() == 2) for(auto p: g[centroids[0]]) {
		if(p.first == centroids[1]) sum -= p.second;
	} else {
		int mn = INT_MAX;
		for(auto p: g[centroids[0]]) mn = min(p.second, mn);
		sum -= mn;
	}
	cout << sum;
}


Measured memory_bytes: 12800
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	private static class Process{
		public String n;
		public int t;
		
		public Process(String name, int time) {
			n = name;
			t = time;
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String first = in.nextLine();
		String[] components = first.split(" ");
		int inputs = Integer.parseInt(components[0]);
		int quantum = Integer.parseInt(components[1]);
		int time = 0;
		
		//Creating the Queue of processes
		LinkedList<Process> q = new LinkedList<>();
		while (in.hasNextLine()) {
			String i = in.nextLine();
			String[] c = i.split(" ");
			q.add(new Process(c[0], Integer.parseInt(c[1])));
		}
		
		//Running
		while (!q.isEmpty()) {
			Process curr = q.poll();
			if (curr.t <= quantum) {
				time += curr.t;
				System.out.println(curr.n + " " + time);
			} else {
				curr.t -= quantum;
				time += quantum;
				q.add(curr);
			}
		}
	}
}


Measured memory_bytes: 108468
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>

#define m(a,b) memset(a,b,sizeof(a));
#define cpy(a,b) memcpy(a,b,sizeof(b));

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int maxn = 1e5 + 5;
const int inf = 1 << 30;

int main(){
	int n, m, ans = 1;
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		ans *= 100;
	if(m % 100 == 0) m++;
	ans *= m;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def include3(i, x)
  if x % 10 == 3
    print " #{i}"
  elsif x / 10 != 0
    include3(i, x / 10)
  end
end

n = STDIN.gets.chomp.to_i
(1..n).each do |i|
  if i % 3 == 0
    print " #{i}"
  else
    include3(i, i)
  end
end
print "\n"

Measured memory_bytes: 8776
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  rep(i,n){
    ans+=(lower_bound(ALL(a),b[i])-a.begin())*(c.end()-upper_bound(ALL(c),b[i]));
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 2560
n = int(input())
s = input()
t = input()

res = 0
s_ = s[::-1]
for i in range(n+1):
    tmp = s_[:i]
    tmp = tmp[::-1]
    
    cnt = 0
    for j in range(len(tmp)):
        if tmp[j] == t[j]:
            cnt += 1
    res = max(res, cnt)
print(2*n - res)

Measured memory_bytes: 3064
import collections
n,p=map(int,input().split())
def factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n /= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n /= f
    else:
      f += 2
  if n != 1: a.append(n)
  return a
factor=factorize(p)
c = collections.Counter(factor)
ans=1
for k, v in c.items():
  if v >= n:
    ans *= (k ** (v//n))
print(int(ans))

Measured memory_bytes: 3316
package main

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

// BIT stands for binary indexed tree.
type BIT []int

func newBIT(n int) BIT {
	return make([]int, n)
}

func (bit BIT) add(i, v int) {
	for i++; i <= len(bit); i += i & -i {
		bit[i-1] += v
	}
}

func (bit BIT) sum(i int) int {
	result := 0
	for i++; i > 0; i -= i & -i {
		result += bit[i-1]
	}
	return result
}

func (bit BIT) query(start int, stop int) int {
	return bit.sum(stop-1) - bit.sum(start-1)
}

func main() {
	defer flush()

	N := readInt()
	Q := readInt()

	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = readInt()
	}

	bit := newBIT(N)
	for i := 0; i < N; i++ {
		bit.add(i, a[i])
	}

	for i := 0; i < Q; i++ {
		t := readInt()
		if t == 0 {
			p := readInt()
			x := readInt()
			bit.add(p, x)
		} else if t == 1 {
			l := readInt()
			r := readInt()
			println(bit.query(l, r))
		}
	}
}

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

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

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 18644
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
	vector<ll> a(n);
	ll cnt = 0;
	rep(i, n) {
		cin >> a[i];
	}
	while(true) {
		int ma = 0, j = -1;
		rep(i, n) {
			if(chmax(ma, a[i])) j = i;
		}
		if(ma >= n) {
			rep(i, n) {
				if(i == j) {
					a[j] -= (ma / n) * n;
					cnt += ma / n;
				} else {
					a[i] += (ma / n);
				}
			}
		} else {
			break;
		}
	}
	cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 1001000
#define llg long long 
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,tot,a[maxn],c[maxn],cs;
int main()
{
	//yyj("B");
	cin>>n;
	if (n==1){cout<<"YES"; return 0;}
	for (llg i=1;i<=n;i++) scanf("%lld",&c[i]),tot+=c[i];
	llg w=n;
	w*=n; w+=n; w/=2;
	if (tot%(w)!=0)
	{
		cout<<"NO";
		return 0;
	}
	else
	{
		tot/=(w);
	}
	for (llg i=1;i<=n;i++)
		if (c[i]>tot*n || c[i]<tot)
		{
			cout<<"NO";
			return 0;
		}
	for (llg i=2;i<=n;i++) a[i]=c[i]-c[i-1];
	a[1]=c[1]-c[n];
	for (llg i=1;i<=n;i++)
	{
		llg x=tot-a[i];
		if (x%(n)!=0)
		{
			cout<<"NO";
			return 0;
		}
		cs+=x/(n);
	}
	if (cs==tot)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;

int main()
{
    int test;

    ll l, r;
    ll ans1 = 0, ans2 = 0;

    cin>>l>>r;

    if(r % 4 == 0){
        ans1 = ans1 ^ r;
    }
    else if(r % 4 == 1)
        ans1 ^= 1;
    else if(r % 4 == 2)
        ans1 ^= (r + 1);
    else if(r % 4 == 3)
        ans1 = 0;

    l--;

    if(l % 4 == 0){
        ans2 = ans2 ^ l;
    }
    else if(l % 4 == 1)
        ans2 ^= 1;
    else if(l % 4 == 2)
        ans2 ^= (l + 1);
    else if(l % 4 == 3)
        ans2 = 0;

    cout<<(ans1 ^ ans2)<<endl;

    return 0;
}


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

int main() {
  string S, T ;
  int N = 0 ;
  cin >> S ;
  cin >> T ;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i))
    {
      N++ ;
    }
  }
  cout << N << endl;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 
ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}
 
int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<ll> dp(k+1);
    ll ans=0;
    invrepr(i,1,k+1) {
        dp[i]=binary_power(k/i,n);
        ll j=i+i;
        while (j<=k) {
            dp[i]=(dp[i]+MOD-dp[j])%MOD;
            j+=i;
        }
        ans=(ans+(dp[i]*i)%MOD)%MOD;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a=0, b=0, x=0;
		a=scanner.nextInt();
		b=scanner.nextInt();
		x=scanner.nextInt();
		
		String anser = "NO";
		if (b>=x-a && x>=a) {
			anser = "YES";
		}
		System.out.println(anser);
		scanner.close();
	}
}


Measured memory_bytes: 21844
#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))

int		main(void)
{
	int n, m, x;
	cin >> n >> m >> x;
	
	int C[n][m+1];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m+1; j++)
			cin >> C[i][j];
	}

	ll ans = 1e18;
	for (int i = 1; i < (1 << n); i++)
	{
		bitset<12> bs(i);
		vector<int> S(m);
		ll sum = 0;
		for (int j = 0; j < n; j++)
		{
			if (bs[j])
			{
				sum += C[j][0];
				for (int k = 0; k < m; k++)
					S[k] += C[j][k+1];
			}
		}
		bool ok = true;
		for (int j = 0; j < m; j++)
		{
			if (S[j] < x)
				ok = false;
		}
		if (ok)
			ans = min(ans, sum);
	}
	if (ans == 1e18)
		cout << -1 << endl;
	else
		cout << ans << endl;
}



Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int n;
	scanf("%d", &n);
	int ans = 0;
	int cnt;
	int i;
	REPS(i, n) {
		if (i % 2 == 0)continue;
		cnt = 0;
		REPS(j, i) {
			if (i%j == 0)cnt++;
		}
		if (cnt == 8)ans++;
	}
	PRINTD(ans);
}

Measured memory_bytes: 128
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

c = input()
if c == "a" or c == "e" or c == "i" or c == "o" or c == "u":
    print("vowel")
else:
    print("consonant")

Measured memory_bytes: 3316
#include"stdio.h"
#include"string.h"
#include"stack"
#include"map"
#include"math.h"
#include"iostream"
#include"vector"
#include"queue"
#include"algorithm"
using namespace std;
#define OK printf("\n");
#define Debug printf("this_ok\n");
#define INF 1e18
typedef long long ll;
#define scanll(a,b) scanf("%lld%lld",&a,&b);
#define scanl(a) scanf("%lld",&a);
#define printl(a,b) if(b == 0) printf("%lld ",a); else printf("%lld\n",a);
#define print_int(a,b) if(b == 0) printf("%d ",a); else printf("%d\n",a);
typedef pair<int,int> PII;

inline int read(){
    int s = 0, w = 1; char ch = getchar();
    while(ch < '0' || ch > '9')   { if(ch == '-') w = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') { s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar(); }
    return s * w;
}
const ll mod = 1e9+7;
const int N = 500010,M = 300010;
const  double pi = acos(-1);
const int inf = 1 << 29;
const int dirx[4] = {-1,0,1,0};

char str[N],t[N];
int a[N];
ll sum[N];
int main(){
  int n = read();
  for(int i = 1; i <= n; i++) a[i] = read();
  for(int i = n; i >= 1; i --){
     sum[i] = sum[i + 1] + a[i];
     sum[i] %= mod;
  }
  ll ans = 0;
  for(int i = 2; i <= n; i ++){
     ans = ans + a[i - 1] * sum[i] % mod;
     ans %= mod;
  }
  printf("%lld\n",ans);
}
/*
3
1 2 3
2
2 6
*/



Measured memory_bytes: 6108
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
from collections import deque
def bfs(v, p):
    q = deque()
    q.append((v, p))
    rec[v - 1] = c.pop()
    while c:
        V, P = q.popleft()
        for nv in G[V - 1]:
            if nv == P:continue
            rec[nv - 1] = c.pop()
            q.append((nv, V))

n = int(input())
ab = [list(map(int, input().split())) for i in range(n - 1)]
c = list(map(int, input().split()))
c.sort()
G = Graph(ab)
print(sum(c[:-1]))
rec = [0] * n
bfs(1, -1)
print(*rec)

Measured memory_bytes: 7568
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<LL> a(n), b(n);
  VEC<pair<LL, int>> c(n);
  REP(i, 0, n) {
    cin >> a[i] >> b[i];
    c[i].first = a[i] + b[i];
    c[i].second = i;
  }
  set<int>A;
  sort(ALL(c));
  reverse(ALL(c));
  for(int i=0;i<n;i+=2){
    A.insert(c[i].second);
  }
  LL asum=0,bsum=0;
  REP(i,0,n){
    if(A.count(i)>0){
      asum+=a[i];
    }else{
      bsum+=b[i];
    }
  }
  cout<<(asum-bsum)<<endl;

  return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int time = 1;
            int dist = 0;

            while(dist < N)
            {
                dist += time;
                time++;
            }

            Console.WriteLine(time - 1);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n, 0), imos(n + 1, 0);

  for(int i = 0; i < n; i++) {
    imos[max(i - a[i], 0)]++;
    imos[min(i + a[i] + 1, n)]--;
  }
  for(int i = 1; i < n; i++) {
    imos[i] += imos[i - 1];
  }

  for(int i = 0; i < k; i++) {
    for(int j = 0; j < n; j++) {
      b[j] = imos[j];
      b[j] = min(n, b[j]);
      imos[j] = 0;
    }
    bool ok = true;
    for(int j = 0; j < n; j++) {
      if(b[j] < n) {
        ok = false;
        break;
      }
    }
    if(ok) {
      break;
    }
    for(int j = 0; j < n; j++) {
      imos[max(j - b[j], 0)]++;
      imos[min(j + b[j] + 1, n)]--;
    }
    for(int j = 1; j < n; j++) {
      imos[j] += imos[j - 1];
    }
  }
  for(int i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}

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

int main(){
   string s;
   cin >> s;
    int a[255]={0};
    for(char c : s){
        a[c]++;
    }
    string ans = "Yes";
    for(char c: s){
        if(a[c] % 2 == 1)
            ans = "No";
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
N=int(input())
li=list(map(int,input().split()))
kekka=[0]*N
#print(li)
#print(kekka)
for i in range(1,N):
    if i==1:
        kekka[i]=abs(li[i]-li[i-1])
    else:
        a=abs(li[i]-li[i-1])+kekka[i-1]
        b=abs(li[i]-li[i-2])+kekka[i-2]
        kekka[i]=min(a,b)
print(kekka[-1])

Measured memory_bytes: 13928
import Control.Applicative

solve c sa sb sc
  | c == 'a' = if null sa then "A" else solve (head sa) (tail sa) sb sc
  | c == 'b' = if null sb then "B" else solve (head sb) sa (tail sb) sc
  | c == 'c' = if null sc then "C" else solve (head sc) sa sb (tail sc)
  | otherwise = undefined

main = do
  sa <- getLine :: IO String
  sb <- getLine :: IO String
  sc <- getLine :: IO String
  putStrLn $ solve 'a' sa sb sc


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

// a*i+b=(xをiにしたときのスイッチの減少)
ll a[202020], b[202020];

int main(){
  int N,M; cin>>N>>M;
  ll A[N]; rep(i,N) cin>>A[i];
  ll sum=0;
  rep(i,N-1){
    bool flag=0;
    if(A[i+1]<A[i]){
      flag=1;
      A[i+1]+=M;
    }
    sum+=A[i+1]-A[i];
    if(A[i+1]-A[i]==1){
      if(flag) A[i+1]-=M;
      continue;
    }
    int s=min(A[i]+2,A[i+1]),t=A[i+1]+1;
    ll bb=-1+s;
    b[s]+=bb; b[t]-=bb;
    a[s]-=1; a[t]+=1;
    if(flag) A[i+1]-=M;
  }
  vector<ll> heru(M+1);
  for(ll i=1;i<=2*M;i++){
    a[i]+=a[i-1];
    b[i]+=b[i-1];
    heru[i%M]+=a[i]*i+b[i];
  }
  sort(heru.begin(),heru.end());
  cout<<sum+heru[0]<<endl;
  return 0;
}


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

int n;
ll ans;

ll f(int x){
	int re = 0;
	for(int i=1;i*i<=x;i++){
		if(x % i == 0) re += 1 + (i != x / i);
	}
	return re;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for(int i=1;i<n;i++) ans += f(n - i);
	cout << ans;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.EmptyStackException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Stack;

/**
 * @author kumar1
 * 
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		try {
			solve();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	/**
	 * @throws IOException
	 * 
	 */
	private static void solve() throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		LinkedList<Boolean> ans = new LinkedList<Boolean>();
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while (!(s = in.readLine()).equals(".")) {
			ans.add(isBalanced(s));
		}

		Iterator<Boolean> it = ans.iterator();
		while (it.hasNext()) {
			if (it.next()) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}

	/**
	 * @param s
	 * @return
	 */
	private static boolean isBalanced(String s) {
		// TODO 自動生成されたメソッド・スタブ]
		Stack<Character> st = new Stack<Character>();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '(' || s.charAt(i) == '[') {
				st.push(s.charAt(i));
			} else if (s.charAt(i) == ')' || s.charAt(i) == ']') {
				try {
					char u = st.pop();
					if (u != ((s.charAt(i) == ')') ? '(' : '[')) {
						return false;
					}
				} catch (EmptyStackException e) {
					return false;
				}
			}
		}
		if (st.size() == 0)
			return true;

		return false;
	}

}

Measured memory_bytes: 25624