akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int n;
  double money = 100000, rate = 0.05, interest;

  cin >> n;

  REP(i, n) {
    interest = money * rate;
    money += interest;
    money = (int)money / 1000;
    money *= 1000;
    if((int)interest % 1000 > 0) money += 1000;
  }
  cout << (int)money << endl;
}

Measured memory_bytes: 1160
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
tmp_sum = 0
sum_val = 0
for i in range(N):
    A2_sum = sum(A2[i : ])
    A1_sum = sum(A1[: i + 1])
    tmp_sum = A2_sum + A1_sum
    if tmp_sum > sum_val:
        sum_val = tmp_sum
print(sum_val)

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>

using namespace std;
int main(void) {
    while(1) {
        int d,e;
        scanf("%d%d",&d,&e);
        if(!d) break;
        double res=10000.;
        for(int i=0; i<d; i++)
            if(abs(sqrt(i*i + (d-i)*(d-i)) - e) < res)
                res = abs(sqrt(i*i + (d-i)*(d-i)) - e);
        printf("%f\n",res);
    }
}

Measured memory_bytes: 2664
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b)
		for (int i = 0; i < a; i++)
			printf("%d", b);
	else
		for (int i = 0; i < b; i++)
			printf("%d", a);


	//printf("%d", r);
	return 0;
}


Measured memory_bytes: 888
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const pair<int, int> NIL(-1, -1);

double orig[110][110], mat[110][110], tmp[110][110];
 
signed main() {
    int N, M;
    while(cin >> N >> M, N) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                cin >> mat[i][j];
                orig[i][j] = mat[i][j];
            }
        }

        cout << fixed << setprecision(2);
        if(M == 1) cout << 1.0 << endl;
        else {
            for(int k=0; k<M-2; k++) {
                fill(tmp[0], tmp[N], 0);
                for(int j=0; j<N; j++) {
                    double ma = -1;
                    for(int i=0; i<N; i++) {
                        chmax(ma, mat[i][j]);
                    }
                    for(int i=0; i<N; i++) {
                        chmax(tmp[j][i], orig[j][i] * ma);
                    }
                }
                swap(mat, tmp);
            }

            double ans = -1;
            for(int i=0; i<N; i++) {
                for(int j=0; j<N; j++) {
                    chmax(ans, mat[i][j]);
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

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

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

//map<pair<string, string>, int> mpi;
//
//ll n, f;
//
//int main(){
//	cin >> n >> f;
//	REP(i, n){
//		ll m;
//		cin >> m;
//		REP(i, m){
//		cin>>
//		}
//	}
//}

ll n;
string s;

int main(){
	ll ans = 0;
	ll x = 0;
	cin >> n >> s;
	REP(i, n){
		if (s[i] == 'I')x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	N := nextInt64()
	height := make([]int64, N)
	heightsr := make([]int64, N)
	heightsl := make([]int64, N)
	for i := int64(0); i < N; i++ {
		height[i] = nextInt64()
		if i+height[i] < N {
			heightsr[i+height[i]]++
		}
		if i-height[i] >= 0 {
			heightsl[i-height[i]]++
		}
	}
	matches := int64(0)
	for i := int64(0); i < N; i++ {
		matches += heightsr[i] * heightsl[i]
	}

	fmt.Println(matches)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 8536
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	static final Scanner	s	=new Scanner(System.in);

	public static void main(String args[]){
		input();
		solve();
	}

	private static void input(){
	}

	private static void solve(){
		int n=s.nextInt(),t[]=new int[n],m,p,x,sum;
		for(int i=0;i<n;i++)
			t[i]=s.nextInt();
		sum=Arrays.stream(t).sum();
		m=s.nextInt();
		for(int i=0;i<m;i++) {
			System.out.println(sum-t[s.nextInt()-1]+s.nextInt());
		}
	}
}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  int ans=-1,a;
  for(int i=1;i<=n;i++){
    int cnt=0,j=i;
    while(j){
      if(j%2==0)cnt++;
      j/=2;
    }
    if(cnt>ans){
      ans=cnt;
      a=i;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::cmp::min;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(dead_code)]

fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

fn main(){

    let input = get_vec_input();
    let n: usize = input[0];
    let m: usize = input[1];
    let lists = (0..m).map(|_| get_vec_input()).collect::<Vec<Vec<usize>>>();
    let ps: Vec<usize> = get_vec_input();
    
    let mut ans = 0;

    //list up the pattern of switches
    for i in 0..((2 as u32).pow(n as u32)) {
        let mut ok: bool = true;
        for j in 0..m {
            let mut cnt = 0;
            let mut _loop = 0;
            for &l in &lists[j] {
                if _loop == 0 {
                    _loop += 1;
                    //continue;
                } else {
                    if ((i >> (l-1)) & 1) == 1 {
                        cnt += 1;
                        // print!("i={}, ",i);
                        // print!("j={}, ",j);
                        // println!("l-1={}",l-1);
                    }
                }
            }
            _loop = 0;
            // print!("cnt={}, ", cnt);
            // println!("ps[j]={}", ps[j]);
            if cnt%2 != ps[j] {
                ok = false;
            }
        }
        if ok {
            ans += 1;
            //println!("{}", i);
        }
    }

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

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int n;
vector<int> vec(20);
bool solve(int i,int x){
    if(x==0)return true;
    if(i>=n)return false;
    return solve(i+1,x)||solve(i+1,x-vec[i]);
}

int main(void){
    cin>>n;
    rep(i,n){
        scanf("%d",&vec[i]);
    }
    int q,x;
    scanf("%d",&q);
    rep(i,q){
        scanf("%d",&x);
        cout<<(solve(0,x)?"yes":"no")<<endl;
    }
}


Measured memory_bytes: 3228
import math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    maxv = n*(n-1)//2
    a = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
    v = 0
    Id = [[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(n):
            if i < j:
                Id[i][j] = v
                v += 1

    def toId(i, j):
        if i > j:
            i, j = j, i
        return Id[i][j]

    to = [[] for i in range(maxv)]
    for i in range(n):
        for j in range(n - 1):
            a[i][j] = toId(i, a[i][j])
        for j in range(n - 2):
            to[a[i][j+1]].append(a[i][j])

    visited = [False for i in range(maxv)]
    calculated = [False for i in range(maxv)]
    dp = [-1 for i in range(maxv)]

    def dfs(v):
        if dp[v] != -1:
            if not calculated[v]:
                return -1
            return dp[v]
        visited[v] = True
        dp[v] = 1
        for u in to[v]:
            ret = dfs(u)
            if ret == -1:
                return -1
            dp[v] = max(dp[v], ret + 1)
        calculated[v] = True
        return dp[v]

    ans = 0
    for i in range(v):
        ret = dfs(i)
        if ret == -1:  # detected cycle
            print(-1)
            exit()
        ans = max(ans, ret)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 168936
#include <stdio.h>
#include <string.h>

int main(void)
{
    int Q;
    unsigned int s;
    double out;
    int i, j;
    double a;
    char outs[100];
    
    scanf("%d", &Q);
    for (i = 0; i < Q; i++){
        scanf("%x", &s);
        
        out = (s & 0x7fffffff) >> 7;
        if ((s & 0x80000000) != 0){
            printf("-");
        }
        
        a = 0.5;
        for (j = 0; j < 7; j++){
            if ((s & (0x40 >> j)) != 0){
                out += a;
            }
            a /= 2;
        }
        
        sprintf(outs, "%.8lf", out);
        for (j = strlen(outs) - 1; outs[j] == '0'; j--){
            outs[j] = '\0';
        }
        if (outs[j] == '.'){
            outs[j + 1] = '0';
        }
        printf("%s\n", outs);
    }
    
    return (0);
}

Measured memory_bytes: 660
/*problem A*/
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int a,b,t;
  int count=0;
  scanf("%d %d %d",&a,&b,&t);

  for(int i=a;i<t+0.5;i = i+a){
    count+=b;
  }

  printf("%d",count);
  return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct UnionFind{
	int size;
	vector<int> parent;
	vector<int> Vnum, Enum;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		Vnum.resize(size+1), Enum.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i, Vnum[i] = 1, Enum[i] = 0;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		Enum[root_i]++;
		if(root_i == root_j) return;
		parent[root_i] = root_j;
		Vnum[root_j] += Vnum[root_i];
		Enum[root_j] += Enum[root_i];
	}
};

llint n, h, w;
vector<E> vec;
UnionFind uf(200005);

int main(void)
{
	cin >> n >> h >> w;
	llint r, c, a;
	for(int i = 1; i <= n; i++){
		cin >> r >> c >> a;
		vec.push_back(make_pair(a, make_pair(r, c)));
	}
	sort(vec.rbegin(), vec.rend());
	
	llint ans = 0;
	for(int i = 0; i < vec.size(); i++){
		llint u = vec[i].second.first, v = vec[i].second.second + 100000, w = vec[i].first;
		if(uf.same(u, v) && uf.Enum[uf.root(u)] >= uf.Vnum[uf.root(u)]) continue;
		if(!uf.same(u, v) && uf.Enum[uf.root(u)]+uf.Enum[uf.root(v)]+1 > uf.Vnum[uf.root(u)]+uf.Vnum[uf.root(v)]) continue;
		uf.unite(u, v);
		ans += w;
	}
	cout << ans << endl;
	
	return 0;
}

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int odd = 0;
  int n; cin >> n;
  for(int i=0;i<n;i++){
    int x; cin >> x;
    if(x % 2) odd++;
  }
  cout << (odd % 2 ? "NO" : "YES") << endl;
  
  return 0;
}


Measured memory_bytes: 256
t=int(input())
z=[]
for _ in range(t):
    inp=list(map(int,input().split()))
    if inp[0]==inp[1]:
        z.append(1)
    else:
        z.append(0)
flag=0
a=0
for i in range(len(z)):
    if z[i]==1:
        a+=1
    else:
        a=0
    if a>=3:
        flag=1
        break
if flag==1:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    map<int,int> d;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        d[a]++;
    }
    int res = 0;
    for(auto v:d){
        if(v.first<v.second){
            res+=v.second-v.first;
        }
        else if(v.first>v.second){
            res+=v.second;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MAXN = 3333;
ll dp[MAXN], v[MAXN];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i<=n; ++i) {
        scanf("%lld", v+i);
    }

    for (int l = 1; l<=n; ++l) {
        for (int m = (n-l&1), i = n-l+1, j = n; j>=l; --i, --j) {
            if (m) {
                dp[j] = min(dp[j] - v[i], dp[j-1] - v[j]);
            } else {
                dp[j] = max(dp[j] + v[i], dp[j-1] + v[j]);
            }
        }
    }
    printf("%lld\n", dp[n]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll mod = 1e9 + 7;
ll dp[102][100005];

int fun(vector<ll>& a, ll n, ll k)
{
    //Base case
    for(ll j=0;j<=k;j++)
    dp[1][j] = (j > a[1]) ? 0 : 1;

    //BU
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=k;j++)
        {
            if(j == 0)
            {
                dp[i][j] = dp[i-1][j];
                dp[i][j] = (mod + dp[i][j])%mod;
            }
            else
            {
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - ( (j-1-a[i] >= 0) ? dp[i-1][j-1-a[i]] : 0);
                dp[i][j] = (mod + dp[i][j])%mod;
            }
        }
    }
    return dp[n][k];
}

int main()
{
    fast_io;

    ll n,k;
    cin>>n>>k;

    vector<ll> a(n+1);
    for(ll i=1;i<=n;i++)
    cin>>a[i];

    cout<<fun(a,n,k)<<endl;

    return 0;
}

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

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int main()
{
    FASTIO;
    int n; cin >> n;
    vll cnts(1e5+1);
    int tmp;

    rep(i, 1, n) {
        cin >> tmp;
        cnts[tmp]++;
    }

    ll sum = 0;
    rep(i, 1, 1e5) sum += cnts[i]*i;

    int q; cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;

        sum -= cnts[b]*b;
        sum += cnts[b]*c;
        cnts[c] += cnts[b];
        cnts[b] = 0;

        cout << sum << nl;
    }
    return 0;
}


Measured memory_bytes: 3984
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdint>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100001];
int b[100001];
int main()
{
	int n;
	scanf("%d",&n);
	int i,j;
	long long s1=0,s2=0;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(j=1;j<=n;j++)
		scanf("%d",&b[j]);
	for(i=1;i<=n;i++)
	{
		if(a[i]>b[i])
			s1+=(a[i]-b[i]);
		else
			s2+=(b[i]-a[i])/2;
	}
	if(s1<=s2)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 200000000000000

using namespace std;

int main(void) {
	int num, i = 0;
	long long ans = INF, dif = 0;
	cin >> num;
	vector<int> d(num);
	for (; i < num; i++) {
		scanf("%d", &d[i]);
		dif += d[i];
	}
	for (i = 0; i < num - 1; i++) {
		dif -= 2 * d[i];
		ans = min(ans, abs(dif));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.io.*;
 
class Main {
    public static long modpow(long a, long b, long m) {
        long ret = 1;
        while(b > 0) {
            if((b & 1) == 1) ret = ret * a % m;
            a = a * a % m;
            b >>= 1;
        }
        return ret;
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        System.out.println(modpow(a, b, 1000000007));
    }
}


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

int main(){
	ll n;
	cin >> n;
	
	vector<ll> d;
	for(ll i = 1; i * i <= n; ++i){
		if(n % i == 0){
			d.push_back(i);
			if(i * i != n){
				d.push_back(n / i);
			}
		}
	}
	
	sort(d.rbegin(), d.rend());
	
	ll ans = 0;
	for(int i = 0; i < d.size(); ++i){
		if(d[i] != 1 && n % (d[i] - 1) == n / (d[i] - 1)){
			ans += d[i] - 1;
		}
	}
	
	cout << ans << endl;
	return 0;
}



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

	#define ll long long
	#define pii pair<int, int>
	#define pll pair<ll, ll>
	#define vi vector<int>
	#define vll vector<ll>
	#define vpii vector<pair<int,int>>
	#define vpll vector<pair<ll,ll>>
	#define fr(i,k,n) for (int i = k; i < n; ++i)
	#define fri(i,k,n) for (int i = k; i >= n; --i)
	#define INF (int)1e9
	#define MOD 1000000007
	#define pb push_back
	#define mp make_pair
	#define all(arr) arr.begin(),arr.end()

	void boost(){
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	}

	void solve(){
		ll d,t,s;
		cin>>d>>t>>s;
		if(d<=t*s){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
		return;
	}

	int main()
	{
		boost();
		
		int tc=1;
		//cin>>tc;
		while(tc--)
			solve();
		return 0;
	}

Measured memory_bytes: 3684
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int h = scan.nextInt();
        int n = scan.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
            sum += a[i];
        }
        System.out.println(h <= sum ? "Yes" : "No");
        scan.close();
    }
}

Measured memory_bytes: 49576
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};


int main(){
  double a,b,h,m;cin>>a>>b>>h>>m;
  double min=m/60*2*PI;
  double hour=(h+m/60)/12*2*PI;
  double d=abs(min-hour);
  double x=sqrt(a*a+b*b-2*a*b*cos(d));
  cout<<fixed<<setprecision(12)<<x<<endl;
}

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt = 0, arr[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j= 0; j <3; ++j){
            cin >> arr[i][j];
        }
    }
    cin >> n;
    int temp;
    for(int i = 0;i <n ; ++i ){
        cin >> temp;
        for(int k = 0; k < 3; ++k){
            for(int j= 0; j <3; ++j){
                if(arr[k][j]==temp){
                    arr[k][j] =-1;
                }
            }
        }
    }
    for(int i = 0; i < 3; ++i){
        if(arr[i][0]==-1&&arr[i][1]==-1&&arr[i][2]==-1){
            ++cnt;
        }
        if(arr[0][i]==-1&&arr[1][i]==-1&&arr[2][i]==-1){
            ++cnt;
        }
                
    }
    if(arr[0][2]==-1&&arr[1][1]==-1&&arr[2][0]==-1){
        ++cnt;
    }
    if(arr[0][0]==-1&&arr[1][1]==-1&&arr[2][2]==-1){
        ++cnt;
    }
        
    
    if(cnt>=1){
        cout<< "Yes";
    }
    else{
        cout<< "No";
    }
}

Measured memory_bytes: 256
local mfl, mce, mmi = math.floor, math.ceil, math.min
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = false
    end
  end
end
SegTree.create = function(self, n)
  local stagenum, mul = 1, 1
  self.cnt, self.stage = {1}, {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = false end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = false
  while true do
    local stage = 1
    local sz = bls(1, stagenum - stage)
    local len = right + 1 - left
    while (left - 1) % sz ~= 0 or len < sz do
      stage = stage + 1
      sz = brs(sz, 1)
    end
    ret = ret or self.stage[stage][1 + brs(left - 1, stagenum - stage)]
    left = left + sz
    if right < left then break end
  end
  return ret
end
SegTree.setValue = function(self, idx, value)
  self.stage[self.stagenum][idx] = value
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.stage[i + 1][idx] or self.stage[i + 1][rem]
    idx = dst
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n", "*l")
local s = io.read()
local q = io.read("*n", "*l")
local sts = {}
local t = {}
for i = 1, 26 do
  sts[i] = SegTree.new(n, function(a, b) return a or b end, false)
end
for i = 1, n do
  t[i] = s:sub(i, i):byte() - 96
  sts[t[i]]:setValue(i, true)
end

for iq = 1, q do
  local iqstr = io.read()
  local ic = iqstr:sub(1, 1)
  if ic == "1" then
    local i, cs = iqstr:match("%d (%d+) (%w)")
    i = tonumber(i)
    local c = cs:byte() - 96
    if t[i] ~= c then
      sts[t[i]]:setValue(i, false)
      t[i] = c
      sts[c]:setValue(i, true)
    end
  else
    local l, r = iqstr:match("%d (%d+) (%d+)")
    l, r = tonumber(l), tonumber(r)
    local cnt = 0
    for i = 1, 26 do
      if sts[i]:getRange(l, r) then cnt = cnt + 1 end
    end
    print(cnt)
  end
end


Measured memory_bytes: 220940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
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; }

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

	vector<int> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}

	int a=0, b=0, c=0, x, y, z;
	vector<vector<int>> vv(N);
	rep(i, M) {
		std::cin >> x >> y;
		vv.at(x-1).push_back(y-1);
		vv.at(y-1).push_back(x-1);
	}

	bool flag;
	rep(i, N) {
		// 自分の高さ
		x = v.at(i);
		flag = true;
		for (auto tem : vv.at(i)) {
			// 繋がってるとこの高さ
			if (x <= v.at(tem)) {
				flag = false;
			}
		}
		if (flag) {
			a++;
		}
	}
	std::cout << a << '\n';
}


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


int main(){
    int N,M; //NはIDｶｰﾄﾞ､Mはゲート
    vector<int> L(M);
    cin >> N >> M;
    int Lmax=0,Rmin=1e5+1;
    for(int i=0;i<M;i++){
        int L,R;
        cin >> L >> R;
        Lmax = max(Lmax,L);
        Rmin = min(Rmin,R);
    }
    if(Lmax > Rmin){
        cout << 0;
    }else{
    cout << Rmin - Lmax + 1;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

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

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int N, K;
	cin >> N >> K;
	vi bunny(N+1);

	REP(i, K) {
		int n;
		cin >> n;
		REP(j, n) {
			int m;
			cin >> m;
			bunny[m] = i;
		}
	}

	int R;
	cin >> R;

	vi bad(N+1);
	REP(i, R) {
		int x, y;
		cin >> x >> y;
	
		if(bunny[x] == bunny[y]) {
			bad[x] = bad[y] = 1;
		}
	}

	int count = 0;
	REP(i, N+1) {
		if(bad[i]) {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s[1]!=s[2])
    cout << "No" << endl;
  else if (s[1] == s[0] || s[2] == s[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;
const long long MOD = 998244353;

///mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 1010;
int n, m;
char a[N][N];
int d[N][N];

bool valid(int x, int y) {
        return (x >= 1 && x <= n && y >= 1 && y <= m);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};


void solve() {


        cin >> n >> m;
        int x0, y0, x1, y1;
        cin >> x0 >> y0;
        cin >> x1 >> y1;
        for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                        cin >> a[i][j];
                        d[i][j] = 1e9;
                }
        }


        set<pair<int, pair<int, int> > > s;

        d[x1][y1] = 0;
        s.insert({0, {x1, y1}});

        while (!s.empty()) {
                auto f = s.begin();
                int x = f->second.first;
                int y = f->second.second;
                s.erase(s.begin());
//                cerr << x << ' ' << y << endl;

                for (int i = 0; i < 4; i++) {
                        int X = x + dx[i];
                        int Y = y + dy[i];
                        if (valid(X, Y) && a[X][Y] == '.' && d[X][Y] > d[x][y]) {
                                s.erase({d[X][Y], {X, Y}});
                                d[X][Y] = d[x][y];
                                s.insert({d[X][Y], {X, Y}});
                        }
                }


                        for (int X = x - 2; X <= x + 2; X++) {
                                for (int Y = y - 2; Y <= y + 2; Y++) {
                                        if (valid(X, Y) && a[X][Y] == '.') {
                                                if (d[X][Y] > d[x][y] + 1) {
                                                        s.erase({d[X][Y], {X, Y}});
                                                        d[X][Y] = d[x][y] + 1;
                                                        s.insert({d[X][Y], {X, Y}});
                                                }
                                        }
                                }
                        }
        }
        if (d[x0][y0] == 1e9) cout << -1 << endl;
        else
                cout << d[x0][y0] << endl;

}


int main() {
#ifdef QWERTY
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
        ios_base::sync_with_stdio(false);


        int t = 1;
//        cin >> t;

        for (int i = 1; i <= t; i++) {
//                cout << "Case #" << i << ": ";
                solve();
        }

        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
        return 0;
}

Measured memory_bytes: 8736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <bitset>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int a[N] ;
int gcd(int a , int b){
	return b == 0 ? a : gcd(b , a % b) ;
}
int work()
{
  int n ;
	scanf("%d" , &n) ;
  unordered_map<int , int> mp ;
	int flag = 1 ;
	for(int i = 1; i <= n ;i ++ ) {
		scanf("%d" , &a[i]) ;
		int t = a[i] ;
		if(flag)
		for(int j = 2 ;j * j <= t ;j ++ ) {
			if(t % j == 0) {
				if(mp[j]) {
					flag = 0 ;
					break ;
				}
        mp[j] = 1 ;
				while(t % j == 0) t /= j ;
			}
		}
		if(t > 1) {
			if(mp[t]) {
				flag = 0 ;
			}else mp[t] = 1 ;
		}
	}
	if(flag) puts("pairwise coprime") ;
	else {
		int ans = a[1] ;
		for(int i = 2; i <= n ;i ++ )
		 ans = gcd(ans , a[i]) ;
		if(ans == 1) puts("setwise coprime") ;
		else puts("not coprime") ;
	}
  return 0 ;
}
int main()
{
  //   freopen("C://Users//spnooyseed//Desktop//in.txt" , "r" , stdin) ;
  //   freopen("C://Users//spnooyseed//Desktop//out.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


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

int main(){
    int a, b, c;
    string ans = "No";
    cin >> a >> b >> c;
    if (a < b){
        if(b < c){
            ans = "Yes";    
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n, m;
vint p(10);
vvint s(10, vint(10));
int ans = 0;

void check(vbool state) {
    rep(i, m) {
        int on = 0;
        for (int sw : s[i]) {
            on += state[sw];
        }
        if (on % 2 != p[i]) return;
    }
    ans++;
    return;
}

void dfs(vbool state, int depth) {
    if (depth < n-1) { 
        state[depth] = true;
        dfs(state, depth+1);
        state[depth] = false;
        dfs(state, depth+1);
    } else {
        state[depth] = true;
        check(state);
        state[depth] = false;
        check(state);
    }
    return;
}

int main() {
    
    cin >> n >> m;
    
    rep(i, m) {
        int k;
        cin >> k;
        int si;
        s[i].resize(k);
        rep(j, k) {
            cin >> si;
            s[i][j] = si - 1;
        }
    }
    p.resize(m);
    rep(i, m) cin >> p[i];

    vbool state(n);
    dfs(state, 0);

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

Measured memory_bytes: 256
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
    const row = readRows(1)[0];
    int plus = cast(int)row.count('+');
    int minus = cast(int)row.count('-');
    writefln("%d", plus - minus);
}

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

using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();

    vector<vector<ll>> s_found(26);
    for (int i = 0; i < n; i++)s_found[s[i] - 'a'].push_back(i);
    bool canmake = true;
    for (int i = 0; i < t.size(); i++)
        if (s_found[t[i] - 'a'].size() == 0)canmake = false;

    if (canmake) {
        ll index = -1;
        ll ret = 0;
        for (int i = 0; i < t.size(); i++) {
            auto p = upper_bound(s_found[t[i] - 'a'].begin(), s_found[t[i] - 'a'].end(), index);
            if (p == s_found[t[i] - 'a'].end()) {
                ret += s_found[t[i] - 'a'][0] - index + n;
                index = s_found[t[i] - 'a'][0];
            } else {
                ret += *p - index;
                index = *p;
            }
        }
        cout << ret << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, n;
	cin >> n;
	a = n % 100 % 10;
	if(a == 3){
		cout << "bon";
    } else if(a == 0 || a == 1 || a == 6 || a == 8){
		cout << "pon";
	} else {
		cout << "hon";
	}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string ABC;
    rep(i, 3) {
        char c;
        cin >> c;
        ABC.push_back(c);
    }
    ll maxi = 0;
    do {
        rep(i, 2) maxi = max(maxi, stoll(string(ABC.begin(), ABC.begin() + 1 + i)) + stoll(string(ABC.begin() + 1 + i, ABC.end())));
    } while(next_permutation(ABC.begin(), ABC.end()));
    cout << maxi << endl;
    return 0;
}


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

int main()
{
	int n, a, b,  i;

	scanf("%d %d %d", &n, &a, &b);
	char *s = (char*)malloc(n * sizeof(char));

	scanf("%s", s);


	int aco = 0, bco = 0;

	for (i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (aco+bco < a+b) {
				printf("Yes\n");
				aco++;
			}
			else printf("No\n");
		}
		else if (s[i] =='b') {
			if (aco+bco<a+b&&bco < b) {
				printf("Yes\n");
				bco++;
			}
			else printf("No\n");
		}
		else printf("No\n");
	}
	free(s);
	
	return 0;

}

Measured memory_bytes: 640
def li():
    return list(map(int, input().split()))


N, M, C = map(int, input().split())

B = li()

res = 0

for i in range(N):
    A = li()
    point = 0
    for j in range(M):
        point += A[j] * B[j]
    point += C

    if point > 0:
        res += 1

print(res)


Measured memory_bytes: 3060
x1, y1, x2, y2 = map(int,input().split())
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(y3-y2)
y4 = y3+(x3-x2)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
N, M = map(int, input().split())
cities = {}
for i in range(1, N+1):
    cities[i] = 0
for _ in range(0, M):
    a, b = map(int, input().split())
    cities[a] += 1
    cities[b] += 1
# 都市をkeyにしたdictを作って、その内容をインクリしていく?
for i in range(1, N+1):
    print (cities[i])

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

#define REP(i, n) for ( int i = 0; i < (n); i++ )

int a[110][110];

int main(){

    int r, c;
    std::cin >> r >> c;

    int x;

    REP(i, r) REP(j, c) std::cin >> a[i][j];
    REP(i, r) REP(j, c) a[i][c] += a[i][j];
    REP(i, c + 1) REP(j, r) a[r][i] += a[j][i];

    REP(i, r + 1) {

        REP(j, c + 1) {
            if ( j ) std::cout << " ";
            std::cout << a[i][j];
        }

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

    return 0;
}



Measured memory_bytes: 3136
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int A,B;
int main() {
	scanf("%d %d",&A,&B);
  	if(A%B!=0){
      printf("%d\n",A);
    }else{
	printf("-1\n");
    }
	return 0;
}


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

bool check(vector<P> st){
    int bottom, last= 0;
    for(P p :st){
        bottom = last + p.first;
        if (bottom < 0) return false;
        last += p.second;
    }
    return true;
}


int main(){
    int n;
    cin >> n;
    vector<P> left, right;
    int total = 0;
    rep(i, n){
        string s;
        cin >> s;
        int bottom = 0, last = 0;
        for(char c :s){
            if (c == '(') last += 1;
            else last -= 1;
            bottom = min(bottom, last);
        }
        if (last > 0) left.emplace_back(bottom, last);
        else right.emplace_back(bottom - last, -last);
        total += last;
    }
    sort(left.rbegin(), left.rend());
    sort(right.rbegin(), right.rend());

    if (check(left) && check(right) && total == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
} 

Measured memory_bytes: 18872