akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         String S=gs();
         long[] a=new long[S.length()+1];

         long tmp=0;
    	 for(int i=0; i<S.length();i++) {
    		 char c=S.charAt(i);
    		 if(c=='<') {
    			 a[i]=tmp;
    			 a[i+1]=tmp+1;
    			 tmp++;
    		 } else {
    			 tmp=0;
    		 }
    	 }

    	 tmp=0;
    	 for(int i=S.length()-1; i>=0;i--) {
    		 char c=S.charAt(i);
    		 if(c=='>') {
    			 a[i+1]=Math.max(a[i+1], tmp);
    			 a[i]=Math.max(a[i], tmp+1);
    			 tmp++;
    		 } else {
    			 tmp=0;
    		 }
    	 }
    	 long ans=0;
    	 for(int i=0; i<S.length()+1;i++) {
    		 ans+=a[i];
    	 }
         System.out.println(ans);
     }


     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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



int main(){
    int n,countNo=0;
    string a,b,c;
    cin>>n;
    cin>>a>>b>>c;
    for(int i=0;i<n;i++){
        if(a[i]==b[i] && c[i]==a[i]){
            continue;
        }else if(a[i]==b[i] && c[i]!=a[i]){
            countNo++;
        }else if(a[i]!=b[i] && c[i]==a[i]){
            countNo++;
        }else if(a[i]!=b[i] && c[i]==b[i]){
            countNo++;
        }else{
            countNo+=2;
        }
    }
    cout<<countNo;
}


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

struct edge { int from, to, cost; };

typedef pair<long long, int> plli;
int main() {
  int n, m, r;
  cin>>n>>m>>r;
  vector<edge> graph(m);
  for (int i=0; i<m; i++) {
    int s, t, d;
    cin>>s>>t>>d;
    graph[i] = {s, t, d};
  }
  long long inf = 1e5 * 1e4 + 1;

  long long d[n];
  for (int i=0; i<n; i++) {
    d[i] = inf;
  }

  d[r] = 0;
  for (int i=0; i<2*n; i++) {
    for (edge e: graph) {
      if (d[e.from] != inf && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if (i >= n) {
          cout<<"NEGATIVE CYCLE"<<endl;
          return 0;
        }
      }
    }
  }
  for (auto di: d) {
    if (di == inf) {
      cout<<"INF"<<endl;
    } else {
      cout<<di<<endl;
    }

  }
}


Measured memory_bytes: 3124
#include <stdio.h>
int main(void){
    int i,x;
    for(i=0;i<10000;i++){
        scanf("%d",&x);
        if(x==0){
            break;
        }else{
            printf("Case %d: %d\n",i+1,x);
        }
    
    }
    return(0);
}



Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int cnt(vector<int>A){
  
  int memo[100010] = {0}; int i = 1; int count = 0;
  bool flag = false;
  
  while(memo[i] <= 1){
    memo[i]++; count++;
       if(A[i] == 2){ flag = true; break;}
       else{ i = A[i]; continue;}}
      
 
 if(flag){return count;}
 else{return -1;}}
  

int main(){
  int N; cin >> N; vector<int> A(N + 1); 
  for(int i = 1; i <= N ; i++){cin >> A[i];}
  //switchの番号は1-indexで扱う
  cout << cnt(A) << endl;
  
  return 0;}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <vector> 
using namespace std;

int main()
{
	int w,b,a,t;
	scanf("%d%d%d",&w,&a,&b);
	if(a>b) 
	{
		if(b+w>=a) printf("0\n");
		else printf("%d\n",a-b-w);
	}
	else
	{
		if(a+w>=b) printf("0\n");
		else printf("%d\n",b-a-w);
	}
}

Measured memory_bytes: 256
n, p = map(int, input().split())
def decomp(a):
    sqrt = round(a ** 0.5 + 0.5)
    factors = []
    for i in range(2, sqrt + 1):
        if not a % i:
            count = 0
            while a % i == 0:
                count += 1
                a //= i
            factors.append((i, count))
    if a != 1:
        factors.append((a, 1))
    return factors

f = decomp(p)
t = 1
for i, j in f:
    if j >= n:
        t *= i ** (j // n)
print(t)

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

int main() {
  int n;
  cin>>n;
  vector<int> v(100005,0);
  for(int i=0;i<n;++i){
    int a,b;
    cin>>a>>b;
    ++v[a];
    --v[b+1];
  }
  int mx=0;
  for(int i=0;i<n+2;++i){
    v[i+1]+=v[i];
    if(v[i+1]>=i)mx=i;
  }
  cout<<mx<<endl;
  return 0;
}

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

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;

    int ans = 0;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        if(pow(x, 2) + pow(y, 2) <= pow(D, 2)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3552
import sys
readline = sys.stdin.readline
from fractions import gcd

def main():
    N, X = map(int, readline().rstrip().split())
    x = list(map(int, readline().rstrip().split()))
    x = [abs(e-X) for e in x]
    
    if N == 1:
        print(x[0])
        return
    
    g = gcd(x[0], x[1])
    if N == 2:
        print(g)
        return

    for e in x[2:]:
        g = gcd(g, e)
    
    print(g)  


if __name__ == '__main__':
    main()

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

int main() {
  ll a, b;
  cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if (a == 1) cout << "Alice" << endl;
  else if (b == 1) cout << "Bob" << endl;
  else if (a > b) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  string s;
  cin >> s;
    if(s == "SUN"){
      cout << 7;
    } 
  	else if(s == "MON") {cout << 6;}
  	else if(s == "TUE") {cout << 5;}
  	else if(s == "WED") {cout << 4;}
  	else if(s == "THU") {cout << 3;}
  	else if(s == "FRI") {cout << 2;}
  	else if(s == "SAT") {cout << 1;}
  else {cout << "!?";}
  return 0;
  
  

}

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

using namespace std;

int main() {
    int N,Q; cin>>N>>Q;
    string S; cin>>S;

    int dp[N];
    memset(dp,0,sizeof(dp));

    for (int i=1;i<N;i++) {
        if (S[i-1]=='A' && S[i]=='C') {
            dp[i] = dp[i-1] + 1;
        } else {
            dp[i] = dp[i-1];
        }
        //cout << i << ":" << dp[i] << endl;
    }

    vector< pair<int,int> > p;
    for (int i=0;i<Q;i++) {
        int l, r; cin>>l>>r;
        p.push_back(make_pair(l,r));
    }

    for (int i=0;i<p.size();i++){
        int l = p[i].first;
        int r = p[i].second;
        cout << dp[r-1] - dp[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2292
#include <iostream>

int main (){
    std::string rightName = "Hoshina";
    std::string wrongName = "Hoshino";

    //num of data n
    int n = 0;
    std::cin >> n;
    //skip "\n"
    std::cin.ignore();
    for(int i = 0; i < n; ++i){
        std::string line;
        //input string
        getline(std::cin, line);
        //find exist of wrongName 
        std::string::size_type pos = line.find(wrongName);
        while(pos != std::string::npos){
            //rename to rightName
            line.replace(pos, wrongName.size(), rightName);
            pos = line.find(wrongName, pos + rightName.size());
        }

        std::cout << line << std::endl;
    }
}

Measured memory_bytes: 2984
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)

    if i != len(a) and a[i] == x:
        return i
    raise ValueError

# ポイント
# 文字列update
# 文字種の高速取得

# 文字種の高速取得について考えてみる
# 文字のidxを取得しておいて二分探索することで高速に取得することが可能


N = read_a_int()
S = list(read()[:-1])

from collections import defaultdict
from bisect import bisect_left, bisect_right, insort_left
char_idxs = defaultdict(lambda: [])
for i, s in enumerate(S):
    char_idxs[s].append(i)


def get_syurui(char_idxs, l, r):
    ret = 0
    for v in char_idxs.values():
        l_idx = bisect_left(v, l)
        r_idx = bisect_right(v, r)
        # print(v,l_idx,r_idx)
        if r_idx - l_idx > 0:
            ret += 1
    return ret


Q = read_a_int()
for q in range(Q):
    com, a, b = read().split()
    if int(com) == 2:
        a, b = int(a) - 1, int(b) - 1
        print(get_syurui(char_idxs, a, b))
    else:
        i = int(a) - 1
        if S[i] == b:
            continue
        # i文字目を消す
        tmp = char_idxs[S[i]]  # S[i]を更新しなきゃ
        del char_idxs[S[i]][index(tmp, i)]
        # cのidxに挿入し直す
        insort_left(char_idxs[b], i)
        # S[i]を更新しなきゃ
        S[i] = b


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

int main()
{
  int n,k;
  cin>>k>>n;
  int a[n]={0}, dif[n]={0};
  for (int i=0; i<n; i++)
  {
      cin>>a[i];
  }
  
  for (int i=0; i<n; i++)
  {
      dif[i]=a[i+1]-a[i];
  }

  dif[n-1]=(k-a[n-1])+a[0];

  //for (int i=0; i<n; i++)
    //cout<<dif[i]<<endl;

  int* i1; 
  i1 = std::max_element(dif, dif + n);

  cout<<k-int(*i1)<<endl;
    
	
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int x,y;cin >>x>>y;
    vector<int>a={4,6,9,11};
    char ansx='c',ansy='c';
    for (auto e:a){
//        cout <<e<<endl;
        if(x==e) {
            ansx='a';
        }
        if(y==e){
            ansy='a';
        }
    }
    if(x==2)ansx='b';
    if(y==2)ansy='b';
    if(ansx==ansy)puts("Yes");
    else puts("No");
    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;

    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p, p+n);

    int sum=0;
    for(int i = 0; i < k; i++){
        sum += p[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 3628
use std::io::{self, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: i64 = read();
    let mut v: Vec<i32> = Vec::new();
    for _ in 0..n {
        v.push(read::<i32>());
    }
    let d: i64 = 1000000007;
    let tri0 = k * (k - 1) / 2 % d;
    let tri1 = (k + 1) * k / 2 % d;
    let mut p = 0i64;
    let mut q = 0i64;
    for i in 0..n {
        for j in (i + 1)..n {
            if v[i] < v[j] {
                p += 1;
            }
            if v[i] > v[j] {
                q += 1;
            }
        }
    }
    let result = (p * tri0 + q * tri1) % d;
    println!("{}", result);
}


Measured memory_bytes: 4352
#include "cstdio"
#include "algorithm"

int stick[100004];

int main()
{
    int n;
    while (scanf ("%d",&n) != EOF)
    {
        for (int i=0;i<n;i++)
        {
            scanf ("%d",&stick[i]);
        }
        std::sort(stick,stick+n);
        int w=0,h=0;
        bool tag=true;
        for (int i=0;i<n-1;i++)
        {
            if (stick[i] == stick[i+1])
            {
                if (tag)
                {
                    w = stick[i++];
                    tag = false;
                }
                else
                {
                    h = stick[i++];
                    tag = true;
                }
            }
        }
        long long ans = (long long) w * (long long) h;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;
#define MX 1000000000

long long GCD(long long a, long long b)
{
    if (b > a)
        swap(a, b);
    if (a % b == 0)
        return b;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, lcm = 1;
    cin >> N;
    vector<ll> vec(N);
    double cpp = 0;
    for (int i = 0; i < N; ++i)
    {
        long long tmp;
        cin >> tmp;
        cpp += double(1) / tmp;
    }

    // for (int i = 0; i < N; ++i)
    //     cin >> vec[i];
    // ll bunshi = 1;
    // ll bunbo = vec[0];
    // for (ll i = 1; i < N; ++i)
    // {
    //     bunshi = vec[i] * bunshi + bunbo;
    //     bunbo *= vec[i];
    //     if (bunbo % bunshi == 0)
    //     {
    //         bunshi = 1;
    //         bunbo /= bunshi;
    //     }
    // }
    cout << fixed << setprecision(15);
    cout << 1 / cpp << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        String a="";
        String b="";
        a=sc.nextLine();
        b=sc.nextLine();

        if(a.equals(b.substring(0,a.length()))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }

}

Measured memory_bytes: 35768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  LL X, Y;
  cin >> X >> Y;
  int ans=0;
  while(X<=Y) X*=2, ans++;
  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

  vector<ll> as = {};
  map<ll, ll> r{};

  for (auto i = 0; i < n; i++)
  {
    ll a;
    cin >> a;
    as.push_back(a);
    r[i + a]++;
  }

  ll cnt = 0;
  for (auto i = 0; i < as.size(); i++)
  {
    auto a = as[i];
    cnt += r[i - a];
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 27224
# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
l=n//2
if n%2==0:
    for i in range(n):
        if i%2==0:
            B[l+i]=str(A[i])
            l=l+i
        else:
            B[l-i]=str(A[i])
            l=l-i
else:
    for i in range(n):
        if i%2==0:
            B[l-i]=str(A[i])
            l=l-i
        else:
            B[l+i]=str(A[i])
            l=l+i
print(' '.join(B))

Measured memory_bytes: 120760
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    q <- getInt
    bc <- replicateM q $ do
        [b,c] <- getIntList
        return (b,c,c-b)
    vec <- VUM.replicate 100001 (0 :: Int)
    forM_ as $ \a -> VUM.modify vec (+1) a
    VUM.write vec 0 (sum as)
    forM_ bc $ \(b,c,d) -> do
        nb <- VUM.read vec b
        VUM.modify vec (+ nb) c
        VUM.write vec b 0
        s <- VUM.read vec 0
        print (s + d * nb)
        VUM.write vec 0 (s+d*nb)

Measured memory_bytes: 59704
#include<stdio.h>
#include<string.h>
int main()
{
     char s[100],t[101];
     scanf("%s",&s);
      scanf("%s",&t);
     int l1=strlen(s),l2=strlen(t),c=0;
        for(int i=0;i<l1;i++){
             if(s[i]==t[i])
        c++;}

     if(c==l1)
          printf("Yes\n");
     else
          printf("No\n");
}


Measured memory_bytes: 1612
#include <iostream>

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int a[n+1];
    long long int b[n];
    long long sum1=0;
    for(long long int i=0; i<(n+1); i++)
    {
        cin>>a[i];
        sum1=sum1+a[i];
    }
    for(long long int i=0; i<n; i++)
    {
        cin>>b[i];
    }
    if(a[0]<=b[0])
    {
        b[0]=b[0]-a[0];
        a[0]=0;
        if(a[1]<=b[0])
        {
            a[1]=0;
            b[0]=b[0]-a[1];
        }
        else
        {
            a[1]=a[1]-b[0];
            b[0]=0;
        }
    }
    else
    {
        a[0]=a[0]-b[0];
        b[0]=0;
    }
    //cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    //cout<<b[0]<<" "<<b[1]<<endl;
    for(long long int i=1; i<=(n-1); i++)
    {
        //cout<<a[i]<<" "<<b[i]<<endl;
        if(a[i]<=b[i])
        {
            //cout<<"tuka"<<" "<<a[i]<<" "<<a[i+1]<<" "<<b[i]<<endl;
            b[i]=b[i]-a[i];
            a[i]=0;
            //cout<<"tuka3"<<" "<<a[i]<<" "<<a[i+1]<<" "<<b[i]<<endl;
            if(a[i+1]<=b[i])
            {
                a[i+1]=0;
                b[i]=b[i]-a[i+1];
            }
            else
            {
                a[i+1]=a[i+1]-b[i];
                b[i]=0;
            }
            //cout<<"tuka2"<<" "<<a[i]<<" "<<a[i+1]<<" "<<b[i]<<endl;
        }
        else
        {
            a[i]=a[i]-b[i];
            b[i]=0;
        }
    }
    long long int sum2=0;
    for(long long int i=0; i<(n+1); i++)
    {
        sum2=sum2+a[i];
    }
    cout<<sum1-sum2<<endl;
}


Measured memory_bytes: 1792
#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;
//const ll MOD=998244353;

int main(){
  int A,B; cin>>A>>B;
  for(int i=1;i<=101010;i++){
    int x=i*0.08,y=i*0.10;
    if(x==A&&y==B){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

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

char t[1 << 18], d[1 << 18];
int n, q; string s;

int sta(int x) {
	for(int i = 0; i < q; i++) {
		if (s[x] == t[i]) {
			if (d[i] == 'L')x--;
			else x++;
		}
		if (x < 0)return 1;
		else if (x >= n)return 2;
	}
	return 0;
}
void solve() {
	cin >> n >> q >> s;
	for(int i = 0; i < q; i++) {
		cin >> t[i] >> d[i];
	}
	int le = 0, ri = n;
	while (ri - le > 1) {
		int mid = (le + ri) / 2;
		if (sta(mid) == 1)le = mid;
		else ri = mid;
	}
	int cle = 0, cri = n;
	while (cri - cle > 1) {
		int mid = (cle + cri) / 2;
		if (sta(mid) == 2)cri = mid;
		else cle = mid;
	}
	int ans = cle - ri + 1;
	if (ans < 0)ans = 0;
	cout << ans << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int input;
		long ans = 0;
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			input = scanner.nextInt();
			for(int i=0; i<((600/input)-1); i++){
				ans = (ans + (long)(input * (Math.pow((input*(i+1)), 2))));
			}
			System.out.println(ans);
			ans=0;
		}
	}
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll dp[3001][3001][2];
int N, M;

int main() {
	cin >> N >> M;
	
	FOR(i, 1, N + 1) dp[0][i][0] = 1;
	dp[0][0][1] = 1;
	
	REP(i, M) {
		REP(j, N + 1) {
			REP(k, 2) {
				if (j != 0) {
					if (j == 1) {
						(dp[i + 1][j - 1][1] += dp[i][j][k]) %= MOD;
						(dp[i + 1][j][1] += dp[i][j][k]) %= MOD;
					}
					else {
						(dp[i + 1][j - 1][k] += dp[i][j][k]) %= MOD;
						(dp[i + 1][j][k] += dp[i][j][k]) %= MOD;
					}
				}
				
				if (j != N) {
					(dp[i + 1][j + 1][k] += dp[i][j][k]) %= MOD;
					(dp[i + 1][j][k] += dp[i][j][k]) %= MOD;
				}
			}
		}
	}
	
	ll ans = 0;
	REP(i, N + 1) ans += dp[M][i][1];
	ans %= MOD;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 140928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public void execute(CustomReader in) throws IOException {

        final int N = in.readLineAsInt();

        int[] cx = new int[N];
        int[] cy = new int[N];
        int[] ch = new int[N];

        for (int i = 0; i < N; i++) {
            int[] clue = in.readLineAsIntArray();
            cx[i] = clue[0];
            cy[i] = clue[1];
            ch[i] = clue[2];
        }

        for (int x = 0; x <= 100; x++) {
            for (int y = 0; y <= 100; y++) {
                int h = 0;
                for (int i = 0; i < N; i++) {
                    if (ch[i] > 0) {
                        h = ch[i] + Math.abs(x - cx[i]) + Math.abs(y - cy[i]);
                        break;
                    }
                }
                boolean solved = true;
                for (int i = 0; i < N; i++) {
                    if ((ch[i] == 0 && (Math.abs(x - cx[i]) + Math.abs(y - cy[i]) < h))
                            || (ch[i] > 0 && h != ch[i] + Math.abs(x - cx[i]) + Math.abs(y - cy[i]))) {
                        solved = false;
                        break;
                    }
                }
                if (!solved) {
                    continue;
                }
                System.out.printf("%d %d %d\n", x, y, h);
                return;
            }
        }
        throw new RuntimeException("reaching this line is impossible");
    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

Measured memory_bytes: 21972
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
	
	int S,T;
	int s[100002]={};
	
	cin>>S;
	for(int i=0;i<S;i++)
		cin>>s[i];
	sort(s,s+S);
	
	cin>>T;
	int c=0;
	for(int i=0;i<T;i++)
	{int D;
		cin>>D;
		int L=0,R=S;
		while(L<R){
			int mid=(L+R)/2;

			if(s[mid]==D){c++;break;}
			if(D<s[mid]){R=mid;}
			else{L=mid+1;}
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1572
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N;
    cin >> N;
    vll A(N);
    rep(i,N) cin >> A[i];
    ll sum = 0;
    rep(i,N) sum = sum ^ A[i];

    rep(i,N){
        cout << ll(sum ^ A[i]) << " ";
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 4708
import sys
input = sys.stdin.readline
s=input().strip()
flg=True

s=s[:-2]
while len(s)>=2:
    for i in range(len(s)//2):
        if s[i]!=s[len(s)//2+i]:
            flg=False
    if flg:
        print(len(s))
        exit()
    s=s[:-2]
    flg=True


Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

template<typename T>
T gcd(T a, T b){
	if (a%b == 0)		return(b);
   else	return(gcd(b, a%b));
}

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll A, B;
	cin >> A >> B;
	ll upper = gcd<ll>(A, B);
	vector<ll>	D = divisor(upper);
	vector<ll>	J;
 
	FOR(i, 0, D.size() - 1)
	{
		if (binary_search(range(J), D.at(i)))
			continue;
		FOR(j, i + 1, D.size())
		{
			if (binary_search(range(J), D.at(j)))
				continue;
			if (gcd<ll>(D.at(i), D.at(j)) != 1)
			{
				J.push_back(D.at(j));
				sort(range(J));
			}
		}
	}
 
	cout << D.size() - J.size() << endl;
 
	return 0;
}



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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  for (int i = 1; i <= 3; i++) {
    if (a * b * i % 2 != 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using Int = int64_t;
Int solve() {
    Int A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C) return A % 2 ? 0 : -1;
    Int ans = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        Int a = (B + C) / 2, b = (A + C) / 2, c = (A + B) / 2;
        A = a;
        B = b;
        C = c;
        ans++;
    }
    return ans;
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX_WH 50
#define BLACK 1
#define WHITE 2

char map[MAX_WH][MAX_WH + 1];
char flag[MAX_WH][MAX_WH + 1];

int w, h;

void printFlag() {
  int i, j;
  for (i = 0; i < w; i++) {
    for (j = 0; j < h; j++) printf("%d", flag[j][i]);
    puts("");
  }
  puts("****************");
}

int count(int n) {
  int i, j, cnt = 0;
  for (i = 0; i < w; i++) {
    for (j = 0; j < h; j++) {
      if (flag[j][i] == n) cnt++;
    }
  }
  return cnt;
}

void reset_flag() {
  int i, j;
  for (i = 0; i < w; i++) {
    for (j = 0; j < h; j++) {
      flag[j][i] = 0;
    }
  }
}

int rinsetsu(int mask, int x, int y) {
  char c = mask == BLACK ? 'B' : 'W';
  if (0 <= x + 1 && x + 1 < w && map[y][x + 1] == c) return 1;
  if (0 <= x - 1 && x - 1 < w && map[y][x - 1] == c) return 1;
  if (0 <= y + 1 && y + 1 < h && map[y + 1][x] == c) return 1;
  if (0 <= y - 1 && y - 1 < h && map[y - 1][x] == c) return 1;
  return 0;
}

int kakudai_rinsetsu(int mask, int x, int y) {
  if (0 <= x + 1 && x + 1 < w && flag[y][x + 1] & mask) return 1;
  if (0 <= x - 1 && x - 1 < w && flag[y][x - 1] & mask) return 1;
  if (0 <= y + 1 && y + 1 < h && flag[y + 1][x] & mask) return 1;
  if (0 <= y - 1 && y - 1 < h && flag[y - 1][x] & mask) return 1;
  return 0;
}

void fill(int mask, int x, int y) {
  if (0 <= x && x < w && 0 <= y && y < h) {
    int c = map[y][x];
    if (c == 'B' || c == 'W') return;
    if (flag[y][x] & mask) return;
    
    if (rinsetsu(mask, x, y) || kakudai_rinsetsu(mask, x, y)) {
      flag[y][x] |= mask;
      fill(mask, x + 1, y);
      fill(mask, x, y + 1);
      fill(mask, x - 1, y);
      fill(mask, x, y - 1);
    }
  }
}

void solve() {
  int i, j;
  
  for (i = 0; i < w; i++) {
    for (j = 0; j < h; j++) {
      if (map[j][i] == 'B' || map[j][i] == 'W') {
        int mask = map[j][i] == 'B' ? BLACK : WHITE;
        fill(mask, i + 1, j);
        fill(mask, i, j + 1);
        fill(mask, i - 1, j);
        fill(mask, i, j - 1);
      }
    }
  }
  
  printf("%d %d\n", count(BLACK), count(WHITE));
}

int main() {
  int i;
  while (1) {
    scanf("%d %d\n", &w, &h);
    if (!(w | h)) break;
    
    for (i = 0; i < h; i++) {
      scanf("%s\n", map[i]);
    }
    reset_flag();
    
    solve();
  }
  return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    rep(i, T) cin >> a[i];
    sort(all(a));
    if (T == 1) {
        cout << K - 1 << endl;
    } else {
        cout << max(0, 2 * a.back() - (K + 1)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//template<typename T>
#define o_set(T) tree<T, null_type,greater<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//use it like o_set(ll) x;  --> x.order.....
//-->for pair<ll,ll> : second element as index and for search use INT_MAX...
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


#define fast ios::sync_with_stdio(false);cin.tie(0);cout<<setprecision(25)
#define pb push_back
#define I insert
#define F first
#define S second
#define digit(x) floor(log10(x))+1
const long long M1=1000000007;
const long long  M2=998244353;
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
template<typename T>
void showArr(T a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
bool isValid(ll x,ll y,ll n,ll m){
    return (x>=0 and y>=0 and x<n and y<m);
}
ll power(ll a,ll n,ll m){
    ll ans=1;
    while(n>0){
        if(n&1){
            ans=(ans%m * a%m)%m;
        }
        n=n>>1;
        a=(a%m*a%m)%m;
    }
    return ans;
}
ll MMI(ll a,ll m){
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1){
        ll q=a/m,t=m;
        m=a%m,a=t,t=y,y=x-q*y,x=t;
    }
    if(x<0) x+=m0;
    return x;
}

ll dx[]={-1,1,0,0},dy[]={0,0,-1,1};
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    ld n,x,t;
    cin>>n>>x>>t;
    n=ceil(n/x);
    cout<<(n*t)<<endl;
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0) continue;
        else{
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;




signed main() {
        ll n;
        cin >> n;
        string s;
        map<string , int> mm ;
        vector <pair <int , string>> vec;
        vector<string>sr;
    for (int i = 0; i <n ; ++i) {
        cin >>s;
        sr.pb(s);
        if(mm[s] > 0)
            vec.pb({mm[s]+1, s});


        mm[s]++;
    }
    sort(BEND2(vec));
   ll t;
   if(vec.size())
         t = vec[0].fi;
    else{
        sort(BEND(sr));
        for(auto el : sr) cout << el <<endl;
       return 0;
    }


    vector <string> res;
    ll count =0;
    while( count < vec.size() and t == vec[count].fi ){
        res.pb(vec[count].se);
        count++;

    }
    sort(BEND(res));
    for(auto el : res)cout << el <<endl;



        return 0;
}

Measured memory_bytes: 26736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class B81
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if (81 < n)
            {
                Console.WriteLine("No");
                Console.ReadLine();
                return;
            }
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == n)
                    {
                        Console.WriteLine("Yes");
                        Console.ReadLine();
                        return;
                    }
                }
            }

            Console.WriteLine("No");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
def main():
    IN1 = [int(_) for _ in input().split()]
    N = IN1[0]
    T = IN1[1]
    times = [int(_) for _ in input().split()]

    result = 0
    before = 0
    base = 0 
    for i in range(1, len(times)):
        time = times[i]
        if time - before > T:
            result = result + before + T - base
            base = time
        before = time
    result = result + times[len(times)-1] + T - base
    print(result)

if __name__ == "__main__":
    main()

Measured memory_bytes: 25200
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] b = new long[m];
        long[] c = new long[m];
        for (int i = 0; i < m; i++)
        {
            long[] t = Console.ReadLine().Split().Select(long.Parse).ToArray();
            b[i] = t[0];
            c[i] = t[1];
        }

        long ans = 0;
        Array.Sort(a);
        Array.Reverse(a);
        Array.Sort(c, b);
        Array.Reverse(b);
        Array.Reverse(c);

        var x = 0;
        var y = 0;
        for (int i = 0; i < n; i++)
        {
            if (y >= c.Length || a[x] >= c[y])
            {
                ans += a[x];
                x++;
            }
            else if (y < c.Length)
            {
                ans += c[y];
                b[y]--;
                if (b[y] == 0) y++;
            }
        }
        // 出力
        Console.WriteLine(ans);
    }
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;

int main() {
	int N; cin >> N;
	V<int> A(N);
	V<int> pf(N + 1);
	rep(i, N) {
		cin >> A[i];
		pf[i+1] = (pf[i] ^ A[i]);
	}

	if (pf[N] != 0) {
		int X = pf[N];

		V<int> dp(N + 1);
		map<int, int> sum;
		dp[0] = sum[0] = 1;
		for (int i = 1; i <= N; ++i) {
			if (pf[i] == X) {
				dp[i] = sum[0];
				sum[X] = (sum[X] + dp[i]) % MOD;
			} else if (pf[i] == 0) {
				dp[i] = sum[X];
				sum[0] = (sum[0] + dp[i]) % MOD;
			}
		}
		cout << dp[N] << endl;
		return 0;
	}

	V<pii> vec;
	rep(i, N + 1) if (pf[i] != 0) {
		vec.eb(pf[i], i);
	}
	sort(ALL(vec));

	V<int> p0;
	for (int i = 0; i <= N; ++i) {
		if (pf[i] == 0) {
			p0.pb(i);
		}
	}

	ll ans = 0;
	{
		int zero = p0.size() - 2;
		ll k = 1;
		rep(i, zero) k = k * 2 % MOD;
		ans = k;
	}

	rep(i, vec.size()) {
		if (i == 0 || vec[i].fi != vec[i-1].fi) {
			int X = vec[i].fi;

			V<int> ids;
			for (int j = i; j < vec.size(); ++j) {
				if (vec[j].fi == X) {
					ids.pb(vec[j].se);
				} else {
					break;
				}
			}

			map<int, int> sum;
			sum[0] = 1;
			int sz = ids.size();

			rep(j, sz) {
				int c0;
				if (j == 0) {
					c0 = lower_bound(ALL(p0), ids[j]) - p0.begin() - 1;
				} else {
					c0 = lower_bound(ALL(p0), ids[j]) - lower_bound(ALL(p0), ids[j-1]);
				}
				int v = (ll)sum[X] * c0 % MOD;
				sum[0] += v;
				sum[0] %= MOD;
				
				(sum[X] += sum[0]) %= MOD;
			}
			ll v = sum[X];
			ans = (ans + v) % MOD;
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10224
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N;
int H[Max];

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(H, N);

    int count = 0;
    int ans = 0;
    rep(i, N-1) {
        if (H[i] >= H[i+1]) {
            count++;
        } else {
            chmax(ans, count);
            count = 0;
        }
        // printf("%d, %d\n", i, count);
    }

    chmax(ans, count);

    output(ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>

main()
{
	char s1[10], s2[10], s3[10];
	char ans[4] = {'\0'};
	
	int i;
	
	scanf("%s %s %s", s1, s2, s3);
	
	ans[0] = s1[0];
	ans[1] = s2[0];
	ans[2] = s3[0];
	
	for(i = 0; ans[i] != '\0'; i++)
	{ ans[i] = (char)toupper(ans[i]);}
	
	printf("%s\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace Atcoder {
    class Program {
        static void Main(string[] args) {
            //var N = int.Parse(Console.ReadLine());
            //var inputList = new List<int>();
            //foreach (var i in Enumerable.Range(0, N))
            //    inputList.Add(int.Parse(Console.ReadLine()));


            //var NK = Console.ReadLine().Split(' ');
            //var N = int.Parse(NK.First());
            //var K = int.Parse(NK.Last());

            //var A = long.Parse(Console.ReadLine());
            //var B = long.Parse(Console.ReadLine());
            //var C = long.Parse(Console.ReadLine());
            //var D = long.Parse(Console.ReadLine());
            //var N = int.Parse(Console.ReadLine());
            //var DX = Console.ReadLine().Split(' ');
            //var D = long.Parse(DX.First());
            //var X = long.Parse(DX.Last());
            //var Ate = new List<long>();
            //foreach (var i in Enumerable.Range(0, N))
            //    Ate.Add(chocos(long.Parse(Console.ReadLine()), D));
            //var sum = X + Ate.Aggregate((n, next) => n + next);
            //Console.WriteLine(sum);

            var N = long.Parse(Console.ReadLine());

            var A = new List<long>();
            A.Add(0);
            A.AddRange(Console.ReadLine().Split(' ').Select(a => long.Parse(a)));
            A.Add(0);

            long total = 0;
            for (int inner = 0; inner < A.Count() - 1; inner++) {
                total += Math.Abs(A[inner] - A[inner + 1]);
            }

            var result = new List<long>();

            for (int outer = 1; outer < A.Count() - 1; outer++) {
                long money = total;

                var olg_cost = Math.Abs(A[outer - 1] - A[outer]) + Math.Abs(A[outer] - A[outer + 1]);
                var new_cost = Math.Abs(A[outer + 1] - A[outer - 1]);

                result.Add(money - olg_cost + new_cost);
            }
            result.ForEach(r => Console.WriteLine(r));
            return;
        }

        //      for (int outer = 0; outer<N; outer++) {
        //            long money = 0;
        //    var tmp = new List<long>(A);
        //    tmp.RemoveAt(outer+ 1);
        //            for (int inner = 0; inner<tmp.Count() - 1; inner++) {
        //                money += Math.Abs(tmp[inner] - tmp[inner + 1]);
        //            }
        //result.Add(money);
        //        }

        static long chocos(long a, long d) {
            long counter = 0;
            while (counter * a + 1 <= d) {
                counter++;
            }
            return counter;
        }

        static long max(long left, long right) {
            if (left >= right)
                return left;
            return right;
        }

        static long min(long left, long right) {
            if (left >= right)
                return right;
            return left;
        }
    }
}


Measured memory_bytes: 30300
#include <cmath>
#include <iostream>

using namespace std;

double BMI(double height, double weight)
{
	return weight / pow(height / 100.0, 2);
}

int main()
{
	const int DATASETS = 1000;

	int Number[DATASETS], C = 0; double H[DATASETS], W[DATASETS]; char ch;

	while (cin >> Number[C] >> ch >> W[C] >> ch >> H[C])
	{
		C++;
	}

	for (int i = 0; i < C; i++)
	{
		if (BMI(H[i] * 100.0, W[i]) >= 25.0)
		{
			cout << Number[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1244