akhauriyash/Code-Regression huggingface dataset:
<?php
$fl=array();
for($i=0;$i<4;$i++){
  $fl[$i]=array();
  for($j=0;$j<3;$j++){
    $fl[$i][$j]=array();
    for($k=0;$k<10;$k++)$fl[$i][$j][$k]=0;
  }
}

$n=trim(fgets(STDIN));

for($i=0;$i<$n;$i++){
  list($b,$f,$r,$v)=explode(' ',trim(fgets(STDIN)));
  $fl[$b-1][$f-1][$r-1]+=$v;
}

$o='';
$sp='';for($i=0;$i<20;$i++){$sp.='#';}
for($i=0;$i<4;$i++){
  for($j=0;$j<3;$j++){
    $o.=' '.implode(' ',$fl[$i][$j]).PHP_EOL;
  }
  if($i<3){$o.=$sp.PHP_EOL;}
}
print $o;

Measured memory_bytes: 15432
# ABC129D - Lamp
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                L[i][j] == 0
                U[i][j] == 0
            else:
                if j == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i][j - 1] + 1
                if i == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i - 1][j] + 1
    for i in range(H - 1, -1, -1):
        for j in range(W - 1, -1, -1):
            if S[i][j] == "#":
                R[i][j] == 0
                D[i][j] == 0
            else:
                if j == W - 1:
                    R[i][j] = 1
                else:
                    R[i][j] = R[i][j + 1] + 1

                if i == H - 1:
                    D[i][j] = 1
                else:
                    D[i][j] = D[i + 1][j] + 1
    ans = max(
        L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(H) for j in range(W)
    )
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
    string s;
    cin >> s;
    int p2 = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'p') p2++;
    }
    int n = s.size()/2;
    cout << n-p2 << endl;
}

Measured memory_bytes: 512
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let S = scan.word::<String>();
    let t = S
        .chars()
        .map(|c| if c == '?' { 'D' } else { c })
        .collect::<String>();

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


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

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int a, b, c;

int main(){
	cin.tie(0);
	
    cin>>a>>b>>c;
    
    int d = 0;
    for_(i, a, b+1) {
        if(c%i==0)d++;
    }
    cout<<d<<endl;
	return 0;
}



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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    vector<vector<int> >a(N, vector<int>(3));
    rep(i,N) cin >> a[i][0] >> a[i][1] >> a[i][2];

    vector<vector<ll> > dp(N+1, vector<ll>(3,0));

    rep(i,N)
    {
        rep(j,3)
        {
            rep(k,3)
            {
                if(j==k)continue;
                else chmax(dp[i+1][j], dp[i][k] + a[i][k]);
            }
        }
    }
    /*
    rep(i,dp.size())
    {
        rep(j,3) cout << dp[i][j] << " ";
        cout << endl;
    }
    */
    
    cout << max(dp[N][0], max(dp[N][1], dp[N][2]) ) << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
using namespace std;
int n;
const int maxn = 205;
int a[maxn];
int b[maxn];
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)
     {
         cin>>a[i];
         if(a[i]%2==1)b[i]=0;
         else
         {
             int k = 0;
             while(a[i]%2==0)
             {
                 a[i]/=2;
                 k++;
             }
             b[i]=k;
         }
     }
     sort(b+1,b+1+n);
     cout<<b[1]<<endl;
     return 0;
}


Measured memory_bytes: 256
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

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

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	string str;
	cin>>str;

	if(str[2]==str[3] and str[4]==str[5]){
		cout<<"Yes"<<endl;
		return;
	}

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

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
#define ll signed long long

int main() {
  ll N;
  ll A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  ans += (N / (A + B)) * A;
  ans += min(A, N % (A + B));

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 2010

using namespace std;

struct Data{
  string word;
  int value;
  Data(string word="X",int value=IINF):word(word),value(value){}
};

int dp[2][MAX];
Data input[MAX];
string line;

int main(){
  int N,CNT = 1;
  while(cin >> N,N){
    rep(i,N) cin >> input[i].word >> input[i].value;
    cin >> line;
    rep(i,2)rep(j,MAX)dp[i][j] = (i?IINF:-IINF);
    dp[0][0] = 0, dp[1][0] = 0;
    rep(i,(int)line.size())rep(j,N)
      if(dp[0][i] != -IINF && i+(int)input[j].word.size()<=(int)line.size() && input[j].word == line.substr(i,input[j].word.size()) ){
	dp[0][i+(int)input[j].word.size()] = max(dp[0][i+(int)input[j].word.size()],
						 dp[0][i]+input[j].value);
      }

    int max_cost = dp[0][line.size()];

    rep(i,max_cost+1)rep(j,N)if(dp[1][i] != IINF && i+input[j].value <= max_cost ){
      dp[1][i+input[j].value] = min(dp[1][i+input[j].value],
				    dp[1][i]+(int)input[j].word.size());
    }
    cout << "Case " << CNT++ << ": " << dp[1][max_cost] << endl;

  }
  return 0;
}

Measured memory_bytes: 1384
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
t = 0
a = 0
b = 0

while True:
    if not t + A[a] > K:
        t += A[a]
        a += 1
        # print(a, t, A[a-1])
        if a >= N:
            break
    else:
        break

flug = True     #全探索を行うか
while True:
    if not t + B[b] > K:
        t += B[b]
        b += 1
        # print(b, t, B[b-1])
        if b >= M:
            flug = False
            break
    else:
        break

# print(a, b, flug)
ans = a + b
flug2 = True    #処理を続けるか
if flug:
    while True:
        a -= 1
        if a < 0:
            break
        t -= A[a]
        while True:
            if not t + B[b] > K:
                t += B[b]
                b += 1
                if b >= M:
                    flug2 = False
                    break
            else:
                break
        ans = max(ans, a + b)
        if not flug2:
            break
print(ans)

Measured memory_bytes: 111188
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
int main() {
	ll a, b;
	cin >> a >> b;
	for (ll i = 1; i <= 3; i++) {
		if (i == a || i == b) {

		}
		else {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    c = []
    ok = 1
    for i in range(3):
        c.append([int(x) for x in input().split()])
        if i:
            if c[i] != c[i-1]:
                d = c[i][0] - c[i-1][0]
                c[i] = [x - d for x in c[i]]
            if c[i] != c[i-1]:
                ok = 0
    if ok:
        print("Yes")
    else:
        print("No")
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""


Measured memory_bytes: 9444
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),s(n+1);
    map<ll,ll> m;
    m[0]++;
    rep(i,n){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
        m[s[i+1]]++;
    }
    ll ans=0;
    for(auto [x,y]:m){
        if(y>=2){
            ans+=y*(y-1)/2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18708
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
long long a[200005],s[200005];
map<long long,long long> mod;
int main()
{
	long long n,k,sum=0;
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
	s[0]=0;a[0]=0;
	for(int i=1;i<=n;i++)
	{
		mod[(s[i-1]-i+1)%k]++;
		if(i>=k)mod[(s[i-k]-(i-k))%k]--;
		sum+=mod[(s[i]-i)%k];
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 15872
n, a, b, c, d = map(int, input().split())
s = ['S'] + list(input())

for i in range(a, max(c, d)):
    if s[i] == '#' and s[i-1] == '#':
        print('No')
        exit()

if c < d:
    print('Yes')
else:
    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            print('Yes')
            exit()
    print('No')


Measured memory_bytes: 6260
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    int a[N];
    int b[N];
    rep(i, N){
        cin >> a[i];
        b[i] = a[i];
    }
    int max = 0, next_max = 0;
    sort(b, b + N, greater<int>());
    max = b[0];
    next_max = b[1];
    
    rep(i, N){
        if(a[i] == max){
            cout << next_max << endl;
        }else{
            cout << max << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		if(N%K==0){
			System.out.println("0");
		}
		else{
			System.out.println("1");
		}
	}
}


Measured memory_bytes: 22612
#include<stdio.h>

int main(){
	int a,b,k;
	scanf("%d%d%d", &a,&b,&k);
	int count=0, answer, i;
	if(a>b) i=b;
	else i=a;
	while(1){
		if((a%i == 0) && (b%i == 0)){
			answer = i;
			count++;
			if(count == k) break;
		}
		i--;
	}
	
	printf("%d", answer);
	
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	// Code for A - Pair
	var K int
	fmt.Scanf("%d", &K)

	if K%2 == 0 {
		fmt.Println((K / 2) * (K / 2))
	} else {
		fmt.Println(((K + 1) / 2) * ((K - 1) / 2))
	}
}


Measured memory_bytes: 1832
"use strict";
function Main(input) {
  const args = input.split('\n');
  const N = parseInt(args.shift());
  const SP = args
  .filter((f, i) => i < N)
  .map((m1, i) => {
    const ms = m1.split(' ');
    return {
      S: ms[0],
      P: parseInt(ms[1]),
      i: i + 1
    };
  })
  .sort((a ,b) => {
    const cS = b.S.localeCompare(a.S);
    if (b.S !== a.S) {
      return b.S < a.S ? 1 : -1;
    }
    return b.P - a.P;
  }).forEach((f) => {
    console.log(f.i);
  });
}

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


Measured memory_bytes: 22472
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j) % 2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
    print()


Measured memory_bytes: 7004
N = int(input())
T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()] + [0]

MOD = 10**9 + 7

fixed = [False] * N
fixed[0] = True

for i in range(1, N):
    if T[i] > T[i-1]:
        fixed[i] = True

ans = 1
for i in range(N-1, -1, -1):
    if A[i] > A[i+1] and A[i] > T[i]:
        print(0)
        exit()
    if fixed[i] is True and A[i] < T[i]:
        print(0)
        exit()
    if fixed[i] is False and A[i] == A[i+1]:
        ans *= min(A[i], T[i])
        ans %= MOD
print(ans)


Measured memory_bytes: 19136
#! /usr/bin/env python3
n,m = map(int,input().split())

A = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
  data = input().split()
  for j in range(m):
    A[i][j] = int(data[j])

b = [0 for i in range(m)]
for i in range(m):
  b[i] = int(input())

c = [0 for i in range(n)]
for i in range(n):
  for j in range(m):
    c[i] += A[i][j]*b[j]

for i in range(n):
  print(c[i])


Measured memory_bytes: 5964
#include <iostream>

using namespace std;

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

    int arr[n];

    //input

    for(int i=0; i<n; i++){
        cin>>arr[i];

    }

    //bubble sort in a different array
    int arr1[n];

    for(int i=0; i<n; i++){
        arr1[i]=arr[i];

    }

    //bubble sort
    for(int k=0;k<n-1; k++){
            for(int l=0; l<n-k-1; l++){
                if(arr1[l]>arr1[l+1]){
                    int temp = arr1[l];
                    arr1[l] = arr1[l+1];
                    arr1[l+1]= temp;
                }
            }
        }

        //compare and check if there is more than 2 differences between the two arrays

        int diff=0;

        for(int i=0; i<n; i++){
        if(arr1[i]!=arr[i]){
            diff++;
        }
        }

    if(diff==2||diff==0){
        cout<<"YES"<<endl;
    }
    else if(diff>2){
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
  int main() {
    int n;
    int64_t ans = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
      cin >> a[i];
    sort(a, a + n, greater<int>());
    for (int i = 1; i<n; i++)
      ans += a[i/2];
    cout << ans;
    return 0;
  }


Measured memory_bytes: 4420
<?php
fscanf(STDIN, "%d %d", $a, $b);

$moji = null;

If($a > $b) {
  for($i = 1; $i <= $a; $i++) {
  	$moji = $moji.$b;
  }
} else {
  for($i = 1; $i <= $b; $i++) {
  	$moji = $moji.$a;
  }
}

echo $moji;

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

#define MOD 1000000007

using namespace std;

typedef long long ll;
#define rep(i, n) for(auto i = 0*(n); i < (n); ++i)

ll mod(ll a, ll b) {
  if(b == 1) return 1;
  int cur = 1, prev = 0;
  ll table[2][3] = {{a, 1, 0}, {b, 0, 1}};
  while(true) {
    ll q = table[prev][0] / table[cur][0];
    table[prev][0] = table[prev][0] - table[cur][0]*q;
    table[prev][1] = table[prev][1] - table[cur][1]*q;
    table[prev][2] = table[prev][2] - table[cur][2]*q;
    if (table[prev][0] == 1) {return table[prev][2];}
    cur = (cur + 1) & 1;
    prev = (prev + 1) & 1;
  }
}

vector<ll> fact(200001);
ll comb(ll n, ll m) {
  if (n == 0 || m == 0) return 1;
  ll a1 = fact[n], a2 = (mod(MOD, fact[m]) + MOD)%MOD, a3 = (mod(MOD, fact[n - m]) + MOD) % MOD;
  return ((a1 * a2) % MOD * a3 % MOD);
}

int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  ll sum = 0;

  ll a = 1;
  fact[0] = 1;
  for(ll i = 1; i <= 200000; ++i){
    a = (a * i) % MOD;
    fact[i] = a;
  }

  rep(i, H - A) {
    ll a = comb(i + B - 1, i) % MOD;
    ll b = comb(H - i + W - B - 2, W - B - 1) % MOD;
    // cout << a << " " << b << endl;
    sum = (sum + (a*b) % MOD) % MOD;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1792
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    int A;
    int B;
    int K;

    cin >> A;
    cin >> B;
    cin >> K;

    int count;
    count = 0;
    for(int i=101;i>0;i--){
        if(A % i==0){
            if(B % i==0){
                count = count + 1;
            }
        }
        if(count==K){
            cout << i;
            break;
        }
    }

    

}

Measured memory_bytes: 256
# coding:utf-8

N = int(input())
A = list(map(int, input().split(' ')))
ans = 0

if 0 in set(A):
    print(0)
    exit(0)

for i, a in enumerate(A):
    if i == 0:
        ans = a
    else:
        ans *= a
        if ans > 10 ** 18:
            print(-1)
            exit(0)
print(ans)


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

using namespace std;

typedef long long int ll;

vector<vector<int> > dp;
string s1, s2;

void solve() {
    int l1 = s1.length();
    int l2 = s2.length();
    string ans = "";
    dp.resize(l1+1, vector<int>(l2+1));

    for(int i = 0; i <= l1; i++) {
        for(int j = 0; j <= l2; j++) {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(s1[i-1] == s2[j-1]) {
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int i = l1, j = l2;

    while(i > 0 && j > 0) {
        if(s1[i-1] == s2[j-1]) {
            ans = s1[i-1] + ans;
            i--, j--;
        }
        else if(dp[i][j] == dp[i-1][j])
            i--;
        else if(dp[i][j] == dp[i][j-1])
            j--;
        
    }
    cout << ans << "\n";
}

int main() {
    cin >> s1 >> s2;
    solve();
}

Measured memory_bytes: 35584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N); for(auto& in:a) cin >> in;
    vector<ll> cusum(N+1);
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + a[i];
    ll ans = LINF;
    for(int i = 1; i < N;i++){
        ans = min(ans,abs(cusum[i]-(cusum[N]-cusum[i])));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;
                    public class Main{
                    public static void main(String[] args){
                    	Scanner scan  = new Scanner(System.in);
                      int k = scan.nextInt();
                    	String s= scan.next();
                      if(s.length()<=k){
                    		System.out.println(s);
                    }
                      else if(s.length()>=k){
                        System.out.println(s.substring(0,k) +"...");
                      }
                    }
                    }

Measured memory_bytes: 38640
while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0:
        break
    S = map(int, raw_input().split())
    left = 0; right = sum(S)+2
    def check(mid):
        if 1+mid <= S[0]:
            return 10**9
        cnt = 0; l = 1
        target = S[n-1] - mid
        for i in xrange(n-1):
            while l <= S[i] and cnt<=m and l<=target:
                l += mid-(S[i]-l)
                cnt += 1
            if (l+mid <= S[i+1] or abs(l-S[i]) < abs(l-S[i+1])) and cnt<=m and l<=target:
                l += max(1, mid-(l-S[i]))
                cnt += 1
                if l+mid <= S[i+1]:
                    cnt += S[i+1]-mid+1-l
                    l = S[i+1]-mid+1
        return cnt
    while left+1 < right:
        mid = (left + right) / 2
        if m-1 <= check(mid):
            left = mid
        else:
            right = mid
    if 10**8 < check(left):
        print -1
    else:
        print left

Measured memory_bytes: 17292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
//文字をbitで処理する
struct segtree {
    int n;
    vector<ll> par;
    segtree (int k) {
        int x = 1;
        while (x < k) {
            x *= 2;
        }
        n = x;
        par.resize (2 * n - 1);
        rep (i, k) {
            char c;
            cin >> c;
            ll bit = 1 << (c - 'a');
            par[n + i - 1] = bit;
        }
        for (int i = k; i < n; i++) par[n + i - 1] = par[n + k - 2];
        for (int i = n - 2; i >= 0; i--)
            par[i] = par[2 * i + 1] | par[2 * i + 2];
    }
    void update (int key, char c) {
        key += n - 1;
        ll bit = 1 << (c - 'a');
        par[key] = bit;
        while (key) {
            key = (key - 1) / 2;
            par[key] = par[2 * key + 1] | par[2 * key + 2];
        }
    }
    ll get (int s, int g, int l = 0, int r = -1, int k = 0) {
        if (r < 0) r = n;
        if (l >= g || r <= s) return 0;
        if (s <= l && r <= g) return par[k];
        ll vecl = get (s, g, l, (l + r) / 2, 2 * k + 1);
        ll vecr = get (s, g, (l + r) / 2, r, 2 * k + 2);

        return vecl | vecr;
    }
};

int main() {
    int n;
    cin >> n;
    segtree tree (n);
    int q;
    cin >> q;
    rep (i, q) {
        int a;
        cin >> a;
        if (a == 1) {
            int key;
            char c;
            cin >> key >> c;
            tree.update (key - 1, c);
        } else {
            int l, r;
            cin >> l >> r;
            ll ans = __builtin_popcount (tree.get (l - 1, r));
            cout << ans << "\n";
        }
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int cnt[9][9]={};
    for(int i = 0; i < n; i++) {
        int tn=i+1;
        int r=tn%10;
        if(r==0) continue;
        int l=r;
        while(tn>0){
            l=tn%10;
            tn/=10;
        }
        cnt[l-1][r-1]++;
//        cout << l << " " << r << "\n";
    }
//    for(int i = 0; i < 9; i++) {
//        for(int j = 0; j < 9; j++) {
//            cout << cnt[i][j];
//        }
//        cout << "\n";
//    }

    int ans=0;
    for(int i = 0; i < 9; i++) {
        for(int j = i; j < 9; j++) {
            int tmp=cnt[i][j]*cnt[j][i];
            if(i!=j) tmp*=2;
            ans+=tmp;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
const int N = 5e5;
lli fac[N];


lli pow1(lli x, lli y) {
  lli ans = 1;
  while(y>0) {
    if(y&1LL) ans = (ans * x) % MOD;
    x = (x * 1LL * x) % MOD;
    y = y>>1;
  }
  return ans;
}
lli inv(lli x) {
  return pow1(x, MOD-2);
}

lli C(lli x, lli y) {
  if(y>x) return 0;
  if(y == 0) return 1;
  lli ans = 1;
  ans *= fac[x];
  ans %= MOD;
  ans *= inv(fac[y]);
  ans %= MOD;
  ans *= inv(fac[x-y]);
  ans %= MOD;
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, k; cin>>n>>k;
  //ans = (n+k)Ck;
  if(k>=n) k = n;
  fac[0] = 1;
  rep(i,1,n+k+1) fac[i] = fac[i-1] * i % MOD;
  //debug(C(5,2));
  lli ans = 0;
  rep(i,0,k+1) {
    //if(k%2 == 1 && i == 0) continue;
    ans += (C(n,i) * C(n-1,i))%MOD;
    //debug(ans);
    ans %= MOD;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3328
# https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
rr = range


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


K, T = read_ints()
A = read_ints()
if T == 1:
    # コーナーケース
    print(K - 1)
    exit()

# 差が最も少なくなるように二分割すれば良い
# 二分探索でもいいが線形探索で愚直に合計値を計算しても十分間に合う
A.sort()
ans = 2**31
for i in rr(1, T):
    r = sum(A[:i])
    l = sum(A[i:])
    ans = min(ans, abs(r - l))
print(max(ans - 1, 0))


Measured memory_bytes: 38704
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = float('inf')
for i in range(1,2*10**6):
    if (n/i).is_integer():
        res = min(res, i + n/i)
print(int(res-2))


Measured memory_bytes: 43632
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;

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

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n,k;
  cin>>n>>k;
  set<int> s;
  map<int,int> m;
  vector<int> a;
  rep(i,n){
    int j;
    cin>>j;
    s.insert(j);
    m[j]++;
  }

  auto itr=s.begin();
  int co=0;
  for(int i=0;i<m.size();i++){
    int num=*itr;
    a.pb(m[num]);
    itr++;
  }
  sort(all(a));
  int all=a.size();
  for(int i=0;i<all-k;i++){
    co+=a[i];
  }
  cout<<co;
}

Measured memory_bytes: 20092
#include <bits/stdc++.h>
using namespace std;
#define int long long
    

int findoya(int oya[],int p){
    if(oya[p]<0){
        return p;
    }else{
        int t=oya[p];
        oya[p]=findoya(oya,t);
        return oya[p];
    }
}

signed main(){
    int n,m;
    cin >>n>>m;
    int a[m],b[m],a0,b0,oya[n],ans[m]={};
    for(int i=0;i<n;i++)oya[i]=-1;
    for(int i=0;i<m;i++){
        cin >> a0>>b0;
        a[i]=a0-1;b[i]=b0-1;
    }
    ans[m-1]=n*(n-1)/2;
    for(int i=m-2;i>=0;i--){
        a0=findoya(oya,a[i+1]);b0=findoya(oya,b[i+1]);
        if(a0!=b0){
            ans[i]=ans[i+1]-oya[a0]*oya[b0];
            oya[b0]+=oya[a0];
            oya[a0]=b0;
        }else{
            ans[i]=ans[i+1];
        }
    }
    for(int i=0;i<m;i++)cout << ans[i]<<endl;
    return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, M, L, Q, ans=0, tmp=0;
vector<vector<ll>> D, G;

signed main(){
    cin >> N >> M >> L;
    D.resize(N);
    G.resize(N);
    for(int i=0;i<N;i++) {
        D[i].resize(N, INF);
        D[i][i] = 0;
        G[i].resize(N, INF);
        G[i][i] = 0;
    }
    for(int i=0;i<M;i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        if(c<=L) {
            D[a][b] = min(D[a][b],c);
            D[b][a] = D[a][b];
        }
    }
    for(int k=0;k<N;k++) {
        for(int i=0;i<N-1;i++) {
            for(int j=i+1;j<N;j++) {
                D[i][j] = min(D[i][j], D[i][k]+D[k][j]);
                D[j][i] = D[i][j];
            }
        }
    }
    for(int i=0;i<N-1;i++) {
        for(int j=i+1;j<N;j++) {
            if(D[i][j]<=L) {
                G[i][j]=1;
                G[j][i]=1;
            }
        }
    }
    for(int k=0;k<N;k++) {
        for(int i=0;i<N-1;i++) {
            for(int j=i+1;j<N;j++) {
                G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
                G[j][i] = G[i][j];
            }
        }
    }
    cin >> Q;
    for(int i=0;i<Q;i++) {
        ll s, t;
        cin >> s >> t;
        s--;
        t--;
        if(G[s][t]==INF) cout << -1 << endl;
        else cout << G[s][t]-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N-1),B(N-1);
  rep(i,N-1) cin>>A[i]>>B[i];
  VVI X(N,VI());
  rep(i,N-1){
    X[A[i]-1].pb(B[i]-1);
    X[B[i]-1].pb(A[i]-1);
  }
  VI D(N,-1);
  D[0]=0;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int tmp=Q.front();
    Q.pop();
    rep(i,X[tmp].size()){
      if(D[X[tmp][i]]==-1){
        D[X[tmp][i]]=D[tmp]+1;
        Q.push(X[tmp][i]);
      }
    }
  }
  int Y=0;
  rep(i,N) if(D[Y]<D[i]) Y=i;
  rep(i,N) D[i]=-1;
  D[Y]=0;
  Q.push(Y);
  while(!Q.empty()){
    int tmp=Q.front();
    Q.pop();
    rep(i,X[tmp].size()){
      if(D[X[tmp][i]]==-1){
        D[X[tmp][i]]=D[tmp]+1;
        Q.push(X[tmp][i]);
      }
    }
  }
  int L=0;
  rep(i,N) if(L<D[i]) L=D[i];
  if(L%3!=1) cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}


Measured memory_bytes: 15220
using System;
using System.Linq;
using System.Collections.Generic;
namespace mytest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine();            
            var D = input.Split(' ');
            var T = 0;
            for(int i = 0; i < N - 1;i++)
            {
                var I = int.Parse(D[i]);
                for(int k = i+1; k < N; k++)
                {
                    T+= I * int.Parse(D[k]);
                }

            }
            Console.WriteLine(T.ToString());
        }
    }
}


Measured memory_bytes: 13140
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	ll op=powe(10,n);
	ll ok=2*(powe(9,n));
	ok%=mod;
	op-=ok;
	op+=mod;
	op%=mod;
	op+=powe(8,n);
	op%=mod;
	cout<<op;
	return 0;
}

Measured memory_bytes: 3652
s = list(input())
t = list(input())
ans = len(t)

for i in range(0, len(s) - len(t) + 1):
    tmp = len(t)
    tmp1 = s[i:i + len(t)]
    for j in range(len(t)):
        if tmp1[j] == t[j]:
            tmp -= 1

    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 8948
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

bool is_composite[100001];
vector<int> primes;

int main() {
  for (int i=2; i<=100000; i++) {
    if (!is_composite[i]) {
      primes.push_back(i);
      for (int j=i+i; j<=100000; j+=i) is_composite[j] = true;
    }
  }

  while (1) {
    int n;
    if (scanf("%d", &n) != 1) return 0;
    auto itr1 = lower_bound(primes.begin(), primes.end(), n)-1;
    auto itr2 = upper_bound(primes.begin(), primes.end(), n);
    printf("%d %d\n", *itr1, *itr2);
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 10;

int N;

int sub(int x) {
    int count = 0;
    vi v(N);
    REP (i, N) {
        v[i] = i+1;
    }
    do {
        int num = 0;
        REP (i, N) num = num * 10 + v[i];
        if (x > num) count++;
    } while (next_permutation(v.begin(), v.end()));
    return count;

}

int solve(int p, int q) {
    return abs(sub(p) - sub(q));
}

int main() {
    cin >> N;
    int p = 0, q = 0;
    int x;
    REP (i, N) {
        cin >> x;
        p = p * 10 + x;
    }
    REP (i, N) {
        cin >> x;
        q = q * 10 + x;
    }
    cout << solve(p, q) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100005
struct edge{
	int to,next;
}e[N*2];
int n,m,tot,head[N];
int a[N],b[N],id[N],fa[N];
long long qd[N],S[N];
bool cmp(int x,int y){
	return a[x]<a[y];
}
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
int get(int x){
	return fa[x]==x?x:fa[x]=get(fa[x]);
}
int vis[N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]=max(a[i]-b[i],0);
	}
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	for (int i=1;i<=n;i++)
		id[i]=i,fa[i]=i,qd[i]=a[i],S[i]=b[i]; 
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<=n;i++){
		int x=id[i]; vis[x]=1;
		for (int j=head[x];j;j=e[j].next)
			if (vis[e[j].to]){
				int X=get(x),Y=get(e[j].to);
				if (X==Y) continue;
				fa[Y]=X; S[X]+=S[Y];
				qd[X]=min(qd[X],qd[Y]+max(0ll,a[x]-S[Y]-qd[Y]));
			}
	}
	int x=get(1);
	printf("%lld",qd[x]+S[x]);
}

Measured memory_bytes: 9264
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    int m, n; cin>>m>>n;
    vi v(n), delta(n-1);
    for(int i = 0; i < n; i++) cin>>v[i];
    sort(all(v));
    for(int i = 0; i < n-1; i++){
        delta[i] = v[i+1] - v[i];
    }
    sort(all(delta));
    /*for(auto i: v) cout<<i<<" ";
    cout<<endl;
    for(auto i: delta) cout<<i<<" ";
    */
    int ans = 0;
    for(int i = 0; i < n-m; i++) ans+=delta[i];
    cout<<ans;
    
}

Measured memory_bytes: 1024
import re
n,q=map(int,input().split())
s=input()

a=[0]*(n+1)
for i in range(1,n+1):
    # print(s[i-1:i+1])
    if s[i-1:i+1]=="AC":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]

for i in range(q):
    l,r=[int(i) for i in input().split()]
    print(a[r-1]-a[l-1])

Measured memory_bytes: 6268
#include<bits/stdc++.h>
using namespace std;
int w[200],v[200];
long long f[100005];

int tt=0;
main()
{
    fill(f,f+100003,1e15);
    int n,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        tt=tt+v[i];
    }
    f[0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=tt;j>=0;j--)
        {
            if(j<v[i])
                break;
            f[j]=min(f[j],f[j-v[i]]+w[i]);
        }
    }
    for(int i=tt;i>=0;i--)
    {
        if(f[i]<=W)
        {
            cout<<i;
            break;
        }
    }

}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

ll dp[55][3][3];
string board1, board2;

ll solve(int i, int prev1, int prev2) 
{
    ll ret = 0;
    if (board1[i] == board2[i]) {
        //pr("case 1") nl
        for (int c=0; c<3; c++) {
            if (c != prev1 && c != prev2) {
                ret = (ret + dp[i+1][c][c]) % MOD;
            }
        }
    }
    else {
        //2 different colours
        //pr("case 2") nl
        for (int c1=0; c1<3; c1++) {
            for (int c2=0; c2<3; c2++) {
                if (c1 != prev1 && c2 != prev2 && c1 != c2) {
                    ret = (ret + dp[i+1][c1][c2]) % MOD;
                }
            }
        }
    }
    return ret;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n;
    cin >> n;
    cin >> board1;
    cin >> board2;
    
    ms(dp,0);
    for0(i,3)
        for0(j,3)
            dp[n][i][j] = 1;
            
    ll ans = 0;
    for (int i=n-1; i>=0; i--) {
        //prl(i)
        if (i == 0 or (i == 1 and board1[i] == board1[i-1])) {
            ans = solve(i,-1,-1);
            break;
        }
        
        for0(prev1,3) {
            for0(prev2,3) {
                dp[i][prev1][prev2] = solve(i,prev1,prev2);
            }
        }
        //print2D(dp[i],3,3)
        if (board1[i] == board1[i-1]) {
            for0(prev1,3) {
                for0(prev2,3) {
                    dp[i-1][prev1][prev2] = dp[i][prev1][prev2];
                }
            }
            i--;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [a,d,n] <- getl $ wrds toInt
  unless (a == 0 && d == 0 && n == 0) $ do
    print $ solve a d n
    main

solve :: Int -> Int -> Int -> Int
solve a d n = filter isPn (toDList a d) !! (n-1)

toDList :: Int -> Int -> [Int]
toDList a d = iterate (+d) a

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

pns :: Integral a => [a]
pns = 2 : 3 : f [] (tail pns) 5
  where
    f ys (x:xs) n = ps ++ f (ys++[x]) xs (x^2+2)
      where
        ip m = all ((/= 0) . (mod m)) ys
        ps = filter ip [n, n+2 .. x^2-2]

isPn :: Integral a => a -> Bool
isPn 1 = False
isPn x = all ((/= 0) . mod x) $ takeWhile ((<= x) . (^2)) pns

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

using namespace std;

typedef long long ll;

const int N = 1e5+20;
const int oo = 1e9;

ll n, m, l, k, a[N], dp[N];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL

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

    dp[1] = 0;
    dp[2] = abs(a[1]-a[2]);

    for(int i=3; i<=n; ++i){
        dp[i]=oo;
        for(int j=1; j<=k; ++j){
            if(j<i)
                dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define repr(i,x,n) for(int i=x; i<(int)n; i++)

int main() {
    long double A, B; cin >> A >> B;
    long long res = floor(A*B);
    cout << res << endl;
}

Measured memory_bytes: 3720