akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;

	queue<int> next;
	vector<lint> depth(N, -INF64);
	vector<vector<pair<int, lint>>> edge(N);

	for (int i = 0; i < M; i++)
	{
		int from, to, dis;
		cin >> from >> to >> dis;
		from--;
		to--;
		edge[from].push_back(make_pair(to, dis));
		edge[to].push_back(make_pair(from, -dis));
	}
	for (int i = 0; i < N; i++)
	{
		if (depth[i] != -INF64)
			continue;

		next.push(i);
		depth[i] = 0;

		for (; !next.empty();)
		{
			int current = next.front();
			next.pop();

			for (auto to : edge[current])
			{
				if (depth[to.first] == -INF64)
				{
					depth[to.first] = depth[current] + to.second;
					next.push(to.first);
				}
				else if (depth[to.first] != depth[current] + to.second)
				{
					cout << "No" << endl;
					return;
				}
			}
		}
	}

	cout << "Yes" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 13824
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		c := make([]int, 0)
		graph[i] = c
	}
	for i := 0; i < m; i++ {
		a, _ := strconv.Atoi(Scanner())
		b, _ := strconv.Atoi(Scanner())
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}
	searched := make([]bool, n)
	fmt.Println(dfs(0, 1, n, graph, 0, searched))
}
func dfs(init int, d int, n int, graph [][]int, counter int, searched []bool) int {
	if d == n {
		return counter + 1
	} else {
		s := make([]bool, n)
		copy(s, searched)
		s[init] = true
		for _, i := range graph[init] {
			if !searched[i] {
				counter = dfs(i, d+1, n, graph, counter, s)
			}
		}
		return counter
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}

int main()
{
   ll n,k;
   cin>>n>>k;
   ll mx = 1e18;
   for(int i=0;i<1000;i++)
   {
	   if(n >=k)n%=k;
	   else n = abs(n-k);
	   mx = min(mx,n);
   }
   cout<<mx;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
root=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    root[a].append(b)
    root[b].append(a)
s=[0]*(n+1)
s[0]=1
s[1]=1
ans=0
def f(a,x):
    global ans
    for i in root[a]:
        if x[i]==0:
            x[i]=1
            f(i,x)
            x[i]=0
    if x.count(1)==n+1:
        ans+=1
f(1,s)
print(ans)



Measured memory_bytes: 73196
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a%3==0 || b%3==0 ||(a+b)%3==0){
    	printf("Possible");
    	return 0;
	}
	else{
		printf("Impossible");
		return 0;
	}
    return 0;
}

Measured memory_bytes: 256
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            var input = Console.ReadLine();
            var a = input.Substring(0, 1);
            var b = input.Substring(1, 1);
            var c = input.Substring(2, 1);
            if (a == "1") n++;
            if (b == "1") n++;
            if (c == "1") n++;

            Console.WriteLine(n);
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
int main(void)
{
  int a[101]={0},n,i,max;
  while(scanf("%d",&n)!=EOF){
      a[n]++;
  }
  max=0;
  for(i=1;i<101;i++){
    if(max<a[i])max=a[i];
  }
  for(i=1;i<101;i++)
    if(max==a[i])printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int x,y,z,check=0;
	int c[15];
	while(true){
		for(int i=0;i<15;i++){
			c[i]=0;
		}
		cin>>x>>y>>z;
		if (cin.eof())break;
		c[x]=1;
		c[y]=1;
		c[z]=1;
		for(int i=1;i<=10;i++){
			if(c[i]==0){
				if(x+y+i<=20){
					check++;
				}
			}
		}
		if(check>=4){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
		check=0;
	}
}

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

using namespace std;

int main(){
	string s;
	cin >> s;

	int n = s.size() + 1;
	vector<int> left(n,0);
	vector<int> right(n,0);
	vector<int> ans(n,0);

	for(int i=n-1;i>=0;i--){
		if(s[i] == '>'){
			right[i] = right[i+1] + 1;
		}
	}
	for(int i=1;i<n;i++){
		if(s[i-1] == '<'){
			left[i] = left[i-1] + 1;
		}
	}
	long long val = 0;
	for(int i=0;i<n;i++){
		ans[i] = max(left[i], right[i]);
		val += ans[i];
	}
	cout << val << endl;

	return 0;
}

Measured memory_bytes: 6788
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut l = vec![0i64; 87];
    l[0] = 2;
    l[1] = 1;
    for i in 2..87 {
        l[i] = l[i - 1] + l[i - 2];
    }
    println!("{}", l[n]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int M = 200005;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
using namespace std ;
const int N =  50  ;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };

int main (){
    int n , k , q ;
   cin >> n >> k >> q ;
    vector<int>v( n + 1   , k ) ;
    vector<int>pre( n + 1   , 0 ) ;

    while ( q--){
         int x ;
         cin >> x ;
         if ( x == 1 )
         pre[ x + 1 ] += -1 ;
         else if ( x == n  )
         {
             pre[1] += -1 ; pre[x ] += 1 ;
         }
         else {
         pre[ x + 1 ] += -1 ;
         pre[1] += -1 ;
         pre[x] += 1 ;

         }
    }
    for ( int i = 1 ; i <= n ; ++ i )
        pre[i] += pre[i-1] ;
    for ( int i = 1 ; i <= n ; ++ i )
     {
     if ( pre[i] + v[i] <= 0 )cout <<"No" ;
     else
        cout << "Yes" ;
     br
     }

return 0 ;

}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,t;cin>>N;
    int cnt = 0;
    REP(i,N){
        cin >> t;
        if(t&1) ++cnt;
    }
    cout << (cnt&1?"NO":"YES") << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8
from numba.types import Omitted

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8), cache=True)
def find_min_length(a, b):
    if a < b:
        a, b = b, a
    return (a + b) // (b + 1)

@njit((i8, i8, i8, i8), cache=True)
def f(a, b, c, d):
    L = find_min_length(a, b)
    ret = ''

    def test(a, b, L):
        # ...B の直後に A を a 個、B を b 個置けるかどうか
        ok = a >= 0 and b >= 0
        if a == 0:
            ok = ok and (b <= L - 1)
        else:
            ok = ok and (a <= L * (b + 1))
            ok = ok and (1 + b <= L * (a + 1))
        return ok

    def add(s, x, t, y, n):
        # 文字列に (s*x + t*y)*n を追加
        nonlocal c, d, ret
        if (x + y) * n < c:
            c -= (x + y) * n
            d -= (x + y) * n
            return
        m = (c - 1) // (x + y)
        c -= m * (x + y)
        d -= m * (x + y)
        n -= m
        while n and c <= d:
            if d <= x:
                ret += s * (d - c + 1)
                d = 0
                return
            if 1 <= c <= x:
                ret += s * (x - c + 1)
                c = x + 1
            ret += t * (min(d, x + y) - c + 1)
            c = 1
            d -= x + y
            n -= 1

    # AAABAAAB と n セット並べてしまって大丈夫かどうか
    l, r = 0, b + 100
    while l + 1 < r:
        m = (l + r) >> 1
        a1, b1 = a - L * m, b - m
        if test(a1, b1, L):
            l = m
        else:
            r = m
    n = l
    flag = n == 0
    add('A', L, 'B', 1, n)
    a -= L * n
    b -= n
    # 次に、A^kB
    l, r = 0, L
    while l + 1 < r:
        m = (l + r) // 2
        if test(a - m, b - 1, L):
            l = m
        else:
            r = m
    k = l
    flag = flag and k == 0
    if k:
        add('A', k, 'B', 1, 1)
        a -= k
        b -= 1
    # 以降は、Aは高々ひとつずつ
    if not a:
        add('B', b, 'A', 0, 1)
        return ret
    if not b:
        add('A', a, 'B', 0, 1)
        return ret

    # B^kA、kはなるべく少なく
    l, r = -1, L - 1
    if flag:
        r = L
    while l + 1 < r:
        m = (l + r) // 2
        if test(a, b - m, L) and b - m <= a * L:
            r = m
        else:
            l = m
    k = r

    if k >= 0:
        add('B', k, 'A', 1, 1)
        a -= 1
        b -= k
    # B^LA をいくつか
    n = min(b // L, a)
    add('B', L, 'A', 1, n)
    a -= n
    b -= n * L
    add('B', b, 'A', 0, 1)
    add('B', 0, 'A', a, 1)
    return ret

ABCD = np.array(read().split(), np.int64)[1:]

for a, b, c, d in ABCD.reshape(-1, 4):
    print(f(a, b, c, d))

Measured memory_bytes: 110780
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[100010];
vector<int> G[100010];

int dfs(int parent, int a) {
	//cout << a << endl;
	int size = G[a].size();
	vector<int> v;
	rep(i, size) {
		int tmp = G[a][i];
		if (tmp != parent)
			v.push_back(dfs(a, tmp));
	}
	if (v.size() == 0) return 0;
	int ret = 0;
	sort(v.begin(), v.end(), greater<int>());
	rep(i, v.size()) {
		ret = max(ret, v[i] + i + 1);
	}
	//cout << a << " " << ret << endl;
	return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	rep(i, N - 1) {
		int a; cin >> a;
		G[i + 2].push_back(a);
		G[a].push_back(i + 2);
	}
	cout << dfs(-1, 1) << endl;


    return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int mx = 0;
  ll ans = 0;
  rep(i, n) {
    ans += max((mx - a[i]), 0);
    mx = max(mx, a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4420
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.d[self.root(x)]



def main():
    n, _, *A = map(int, open(0).read().split())
    uf = UnionFind(n)

    for a, x, y in zip(*[iter(A)]*3):
        if a == 0:
            uf.unite(x, y)
        else:
            print(1 if uf.same(x, y) else 0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28916
#include<bits/stdc++.h>
using namespace std;
int a,b;
string s;
int pd(string);
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>a>>b;
	cin>>s;
	if(s[a]!='-'||pd(s)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}
int pd(string s)
{
	for(int i=0;i<=a+b;i++)
	{
		if(i==a) continue;
		if(s[i]<'0'||s[i]>'9') return 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}



bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    int N, M; cin >> N >> M;
    vi k(M), p(M);
    vvi s(M,vi(INT8_MAX));

    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> s[i][j];
        }
    }

    rep(i, M) cin >> p[i];

    int ans = 0;

    for (int bit = 0; bit < (1 << N); ++bit) {
        vi S = IntegerToVector(bit, N);
        int kk = 0;
        rep(i, M) {
            int jj = 0;
            rep(j, k[i]) {
                if (count(S.begin(), S.end(), s[i][j]-1)) { ++jj; }
            }
            if (jj % 2 == p[i]) { ++kk; }
        }
        if (kk == M) { ++ans; }
    }

    cout << ans << endl;

}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<double> kitai(n);
    rep(i, n)
    {
        cin >> p.at(i);
        kitai.at(i) = (p.at(i) + 1.0) / 2.0;
    }

    // 累積和を求めておく
    vector<double> s(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        s.at(i + 1) = s.at(i) + kitai.at(i);
    }

    double ans = 0;
    for (int i = 0; i < n - k + 1; i++)
    {

        double num = s.at(i + k) - s.at(i);
        ans = max(ans, num);
    }

    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 4096
#include <iostream>

#include <fstream>

using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;

#define rep(i,s,n)for(ll i = s;i<n;i++)
ll N, M;
ll c[1000000] = { 0 };

int main()
{
	cin >> N >> M;
	rep(i, 0, M) {
		ll a, b;
		cin >> a >> b;
		if (a == 1) {
			c[b]++;
		}
		else if (b == N) {
			c[a]++;
		}
	}
	rep(i, 1, N + 1) {
		if (c[i] >= 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1792
//テンプレ
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int S,W;
  cin>>S>>W;
  if(W>=S){
    cout<<"unsafe"<<endl;
  }
  else{
    
      cout<<"safe"<<endl;
  }
}

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func main() {
	sc.Split(bufio.ScanWords)

	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()

	if c > b || a > d {
		fmt.Println(0)
		return
	}

	var min, max, x, y int

	if a > c {
		min, x = c, a
	} else {
		min, x = a, c
	}

	if b > d {
		max, y = b, d
	} else {
		max, y = d, b
	}

	second := 0
	for i := min; i <= max; i++ {
		if x >= i {
			continue
		}

		if i > y {
			break
		}
		second++
	}

	fmt.Println(second)
}

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

int main() {
    string s;
    cin >> s;
    bool app[26];
    for (int i = 0; i < 26; ++i) {
        app[i] = false;
    }
    for (int i = 0; i < s.size(); ++i) {
        app[s[i]-'a'] = true;
    }
    for (int i = 0; i < 26; ++i) {
		if (!app[i]){
			cout << char(i + 'a') << endl;
			return 0;
		}
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdbool.h>

int main(void) {
	int K, A, B;
	
	scanf("%d", &K);
	scanf("%d %d", &A, &B);
	
	for(; A <= B; A++) {
		if(A % K == 0) {
			printf("OK\n");
			return 0;
		}
	}
	
	printf("NG\n");
	
	return 0;
}


Measured memory_bytes: 1664
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	var count int = 0
	var flag bool = false
	var A, B []int

	for i := 0; i < N; i++ {
		var a, b int
		fmt.Scanln(&a, &b)
		A = append(A, a)
		B = append(B, b)
	}
	for i := 0; i < N; i++ {
		if A[i] == B[i] {
			count++
			if count == 3 {
				flag = true
			}
		} else {
			count = 0
		}
	}
	if flag == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int64_t>A(N);
  cin>>A.at(0);
  if(A.at(0)!=0){
    cout << -1;
    return 0; 
  }
  int64_t count = 0;
  for(int i=1;i<N;i++){
    cin>>A.at(i);
  	if(A.at(i-1)+1 == A.at(i)){
      count++;
    }else if(A.at(i-1)+1 < A.at(i)){
      cout << -1;
      return 0; 
    		
    }else{
      count+=A.at(i);
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

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

	int n,m;
	cin >> n >> m;
	int maxL = -1, minR = 1000000;
	for(int i=0; i<m; i++){
		int l,r;
		cin >> l >> r;
		maxL = max(maxL, l);
		minR = min(minR, r);
	}
	
	cout << max(minR - maxL + 1, 0);
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;

struct UnionFind_W {
	vector<pii> data;
	UnionFind_W(int size) : data(size, { -1,0 }) { }
	bool unionSet(int x, int y, int d) { //????????\??£??????????????¨ y?????\??£?????????????????????
		int ox = x,oy =y;
		x = root(x); y = root(y);
		if (x != y) {
			data[x].first += data[y].first;
			data[y].second = data[ox].second - data[oy].second+ d;
			data[y].first = x;
		}
		return x != y;
	}
	int findSet(int x, int y) { //x??????y?????????
		int rx = root(x), ry = root(y);
		if (rx == ry) {
			return data[x].second - data[y].second;
		}
		return INT_MAX;
	}
	int root(int x) {
		if (data[x].first < 0)
			return x;
		int op = data[x].first;
		data[x].first = root(data[x].first);
		data[x].second += data[op].second;
		return data[x].first;
	}
	int size(int x) {
		return -data[root(x)].first;
	}
};


int main() {
	int n;
	while (scanf("%d", &n)) {
		if (!n)
			return 0;
	
		UnionFind_W uf(n*2);
		map<string, int> unit;
		char str[17],str2[17];
		bool f = 1;
		REP(i, n) {
			int d;
			scanf("%*d%s%*s%*d%*c%d%s", str, &d, str2);
			if (!unit.count(str))
				unit[str] = unit.size();
			if (!unit.count(str2))
				unit[str2] = unit.size();

			int he = uf.findSet(unit[str], unit[str2]);
			if (he == INT_MAX) {
				uf.unionSet(unit[str], unit[str2], d);
			}
			else if (he != -d) {
				printf("No\n");
				f = 0;
				rep(j, i, n-1) {
					scanf("%*d%s%*s%*d%*c%d%s", str, &d, str2);
				}
				break;
			}
		}
		if (f)
			printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f;
	cin>>n;
	vc a(n+1),b(n+1);
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)cin>>b[i];
	sort(b.begin()+1,b.end(),greater<ll>());
	ll ele;vc v;
	for(i=1;i<=n;i++)if(a[i]==b[i]){ele=a[i];v.push_back(i);}
	if(v.size()==0)
	{
	    cout<<"Yes\n";
	    //for(i=1;i<=n;i++)cout<<a[i]<<" ";cout<<"\n";
	    for(i=1;i<=n;i++)cout<<b[i]<<" ";cout<<"\n";exit(0);
	}j=0;
	for(i=1;i<=n&&j<v.size();i++)
	{
	    if(a[i]!=ele&&b[i]!=ele)swap(b[v[j++]],b[i]);
	}
	if(j!=v.size())cout<<"No";
	else
	{
	    cout<<"Yes\n";
	    //for(i=1;i<=n;i++)cout<<a[i]<<" ";cout<<"\n";
	    for(i=1;i<=n;i++)cout<<b[i]<<" ";cout<<"\n";exit(0);
	}
	return 0;
}


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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 305, MOD = 1e9 + 7;

int dp[N][N][N];

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <int> l(m), r(m), x(m);
  vector <vector <int>> to_check(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> x[i];
    to_check[r[i]].push_back(i);
  }

  memset(dp, -1, sizeof dp);

  function <int(int, int, int)> rec = [&] (int last_r, int last_g, int last_b) {
    if (~dp[last_r][last_g][last_b]) return dp[last_r][last_g][last_b];
    int last_pos = max({last_r, last_g, last_b});
    for (int i: to_check[last_pos]) {
      vector <int> arr = {last_r, last_g, last_b};
      sort(all(arr));
      if (x[i] == 1 and not (arr[1] < l[i])) return 0;
      if (x[i] == 2 and not (arr[0] < l[i] and l[i] <= arr[1])) return 0;
      if (x[i] == 3 and not (l[i] <= arr[0])) return 0;
    }
    if (last_pos == n) return 1;
    last_pos++;
    int ret = rec(last_pos, last_g, last_b);
    ret += rec(last_r, last_pos, last_b);
    if (ret >= MOD) ret -= MOD;
    ret += rec(last_r, last_g, last_pos);
    if (ret >= MOD) ret -= MOD;
    return dp[last_r][last_g][last_b] = ret;
  };

  cout << rec(0, 0, 0) << endl;
  return (0);
}


Measured memory_bytes: 111104
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF=1000000;
const int maxn=111111;
int f[maxn],g[maxn],Q[maxn];
char ss[maxn];
int main()
{
	int N,M;scanf("%d%d",&N,&M);
	scanf("%s",ss);
	f[N]=0;
	int l=1,r=0;
	Q[++r]=N;
	for(int i=N-1;i>=0;--i)
	{
		while(l<=r&&Q[l]>i+M) ++l;
		if(ss[i]==49) f[i]=INF;
		else g[i]=Q[l],f[i]=f[Q[l]]+1;
		while(l<=r&&f[i]<=f[Q[r]]) --r;
		Q[++r]=i;
//		printf("%d:%d\n",i,f[i]);
	}
	if(f[0]>=INF) puts("-1");
	else
	{
		int Nw=0;
		while(Nw!=N) printf("%d ",g[Nw]-Nw),Nw=g[Nw];
	}
	return 0;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();

		int ns = s.length;
		int nt = t.length;

		if (nt > ns) {
			pr.println("UNRESTORABLE");
			return;
		}

		List<String> ans = new ArrayList<>();
		out:
		for (int i = 0; i + nt - 1 < ns; i++) {
			for (int j = 0; j < nt; j++) {
				if (s[i + j] == '?') {
				} else if (s[i + j] == t[j]) {
				} else {
					continue out;
				}
			}

			char[] tmp = s.clone();
			for (int j = 0; j < nt; j++) {
				tmp[i + j] = t[j];
			}
			for (int j = 0; j < ns; j++) {
				if (tmp[j] == '?') {
					tmp[j] = 'a';
				}
			}
			ans.add(new String(tmp));
		}
		Collections.sort(ans);

		if (ans.size() > 0) {
			pr.println(ans.get(0));
		} else {
			pr.println("UNRESTORABLE");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

const int maxn = 110;
const double PI = acos(-1);
int n;
pair<int, int> p[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &p[i].first, &p[i].second);
    }
    for (int i = 1; i <= n; i++) {
        vector<double> V;
        for (int j = 1; j <= n; j++) if (i ^ j) {
            V.push_back(atan2(p[j].second - p[i].second, p[j].first - p[i].first));
        }
        sort(V.begin(), V.end());
        double ans = max(0.0, PI - (V.back() - V[0]));
        for (int i = 0; i + 1 < V.size(); i++) {
            ans = max(ans, (V[i + 1] - V[i]) - PI);
        }
        printf("%.10f\n", ans / PI / 2);
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int mp[101][101];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int now = 0;
	rep(i, h) {
		if(i % 2 == 0) for (int j = 0; j < w; ++j) {
			if (a[now] == 0) now++;
			mp[i][j] = now + 1;
			a[now]--;
		}
		if(i % 2 == 1) for (int j = w - 1; j >= 0; --j) {
			if (a[now] == 0) now++;
			mp[i][j] = now + 1;
			a[now]--;
		}
	}
	rep(i, h) {
		rep(j, w) cout << mp[i][j] << (j == w - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
    #define BPhuong "vsteps"
    #define maxn 1009
    #define maxm
    #define bit(x, i) ((x>>i)&1)
    #define fid(i,a,b) for(int i = a; i>=b; i--)
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define pii pair<int, int>
    #define ll long long
    #define f first
    #define se second
    #define pb push_back
    using namespace std;
    int n, w[maxn], v[maxn], W;
    ll  f[100005], res = 0;
    void nhap(){
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);cout.tie(NULL);
        srand(time(NULL));
     
        cin >> n >> W;
        fi(i, 1, n)
            cin >> w[i] >> v[i];
    }
    void xuli(){
       fi(i, 1, n)
        fid(j, W, w[i]){
            f[j]  = max(f[j], f[j-w[i]] + v[i]);
            res = max(res, f[j]);
        }
       cout << res;
    }
    int main(){
        nhap();
        xuli();
    }


Measured memory_bytes: 4376
chomp (my $n = <STDIN>);
chomp (my @v = split / /, <STDIN>);
my (%p, %q);
for my $i (0..$n-1) {
  if ($i % 2 == 0) {
    $p{$v[$i]}++;
  } else {
    $q{$v[$i]}++;
  }
}
my @ps = sort {$p{$b}<=>$p{$a}} keys %p;
my @qs = sort {$q{$b}<=>$q{$a}} keys %q;
my ($x, $y) = (0, 0);
my $ans = $n / 2;
my $f = 0;
for my $i (0..$#ps) {
  $x = $ps[$i];
  for my $j (0..$#qs) {
    if ($x != $qs[$j]) {
      $y = $qs[$j];
      $f = 1;
      last;
    }
  }
  last if $f;
}
$ans = $n - $p{$x} - $q{$y} if $f;
($x, $y) = (0, 0);
my $f = 0;
for my $i (0..$#qs) {
  $x = $qs[$i];
  for my $j (0..$#ps) {
    if ($x != $ps[$j]) {
      $y = $ps[$j];
      $f = 1;
      last;
    }
  }
  last if $f;
}
$ans = $n - $q{$x} - $p{$y} if $f && $ans > $n - $q{$x} - $p{$y};
print "$ans\n";

Measured memory_bytes: 28616
#include<stdio.h>
int main(void)
{
    int h,m,s;
    scanf("%d",&s);
    printf("%d",s/3600);
    printf(":");
    printf("%d",(s%3600)/60);
    printf(":");
    printf("%d\n",(s%3600)%60);
    return 0;
}

Measured memory_bytes: 596
mod = 10 ** 9 + 7

n = int(input())
a = map(int, input().split())

cnt = [0] * (n + 1)
cnt[-1] = 3

ret = 1
for x in a:
    ret = ret * cnt[x - 1] % mod
    cnt[x - 1] -= 1
    cnt[x] += 1

print(ret)


Measured memory_bytes: 10644
#include<stdio.h>
#include <string.h>
using namespace std;
//1 以上 K 以下の正の整数から、偶数と奇数ひとつずつの組を選ぶ方法の個数を求めてください。なお、選ぶ順番は考慮しません。                                                                                     


int main(){


  int k;
  scanf("%d", &k);

  int odd;
  int even;

  //  odd = k/2+1;                                                                                                                                                                                          
  //  even = k/2;                                                                                                                                                                                           

  //odd or even                                                                                                                                                                                             
  int mod;
  mod= k%2;
  //  printf("%d\n",mod);                                                                                                                                                                                   
  if(mod==1){
    odd=(k+1)/2;
    even=(k)/2;
  }else if(mod==0){
    odd=k/2;
    even=k/2;
  }
  int answer = odd * even;
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

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

	ans := make([]int, N)
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			ans[0] += A[i]
		} else {
			ans[0] -= A[i]
		}
	}
	for i := 1; i < N; i++ {
		ans[i] = 2 * (A[i-1] - ans[i-1]/2)
	}

	for i := 0; i < N; i++ {
		fmt.Printf("%d ", ans[i])
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 5632
function Main(input) {
  "use strict"
  const temp = input.split("\n")

	const n = parseInt(temp.shift());
  const vn = temp.shift().split(" ").map(e => parseInt(e));
  vn.sort((a,b) => b - a);

  let value = 0;
  for(let i = 0; i < n; i++){
    if(i !== n - 1) value += vn[i] / Math.pow(2, i + 1)
    else value += vn[i] / Math.pow(2, i)
  }
  console.log(value)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    int cnt = 1001001001;
    rep(i, n) {
        int a;
        cin >> a;
        int x = 0;
        while (a % 2 == 0) {
            x++;
            a /= 2;
        }
        chmin(cnt, x);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

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

using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> maxh(n+1, 0);
    int h[n+1];
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    for(int i = 0; i < m; i++)
    {
        int u, v; cin >> u >> v;
        maxh[u] = max(maxh[u], h[v]);
        maxh[v] = max(maxh[v], h[u]);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(maxh[i] < h[i])
            ans++;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4032
K = int(input())
N = 50
a = [N-1+K//N]*N
idx = 0

for _ in range(K%N):
    for i in range(N):
        if i==idx:
            a[i] += N
        else:
            a[i] -= 1

    idx += 1

print(N)
print(*a)

Measured memory_bytes: 38512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int ones = N%10;
		String ans;
		if(ones == 3) {ans ="bon";}
		else if(ones==0 || ones==1 || ones==6 || ones==8) {ans="pon";}
		else {ans = "hon";}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 35708
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import collections
import itertools


BOWL = -1


def simulation(n, p):
    status = collections.defaultdict(int)
    status[BOWL] = p
    for candidate in itertools.cycle(range(n)):
        if status[BOWL] > 0:
            status[candidate] += 1
            status[BOWL] -= 1
            if status[candidate] == p:
                return candidate
        else:
            status[BOWL] += status[candidate]
            status[candidate] = 0


if __name__ == "__main__":
    while True:
        n, p = map(int, input().split())
        if n == 0 and p == 0:
            break
        else:
            print(simulation(n, p))

Measured memory_bytes: 8012
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;

int main(){
    ll b,x=0,y=0,d=0,n,h,w,k,max=-100,ans=0,count=0,sum=0;
    string s;
    cin >> s;
    VI a(s.size());
    vector<pair<char,int> > len;

    for(int i=0;i<s.size();i++){
        while(s[i]=='R'){
           count++;
            i++;
       }
        a[i-1] += (count+1)/2;
        a[i] += count/2;
        count=0;
        int j=i; 
        while(s[i]=='L'){
            if(count%2==0){
                a[j]++;
            }
            else{
                a[j-1]++;
            }
            count++;
            i++;
        }
        i--; 
        count=0;   
    }

    for(int i=0; i<a.size();i++){
        cout << a[i] << endl;
    }

    //cout <<  << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <sstream>
#include <vector>
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int K, X;

  int l;
  cin >> l;
  string s;
  cin >> s;
  string d = "ABC";
  auto p = 0;
  int cnt = 0;

  while ((p = s.find(d)) != string::npos) {
    cnt++;
    s.erase(0, p + d.length());
  }
  cout << cnt << endl;

  return 0;
}


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

int main()
{
	
	int n,i;
	long long int c,r=0;
	string s[100005];
	
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	for(i=0;i<n;i++){
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	
	for(i=1,c=0;i<n;i++){
		if(s[i]==s[i-1]){
			c++;
		}
		else{
			r=r+(c*(c+1)/2);
			c=0;
		}
	}
	if(c>0){
		r=r+(c*(c+1)/2);
	}
	cout<<r<<endl;
	
	return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>

int main(void){
    char c;
    
    while (scanf("%c", &c), 'A'<=c && c<='Z'){
        c -= 'A';
        c = (c+23)%26;
        c += 'A';
        printf("%c",c);
    }
    printf("\n");
   
    return 0;
}

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

#define INF 100100100
#define mod 1000000007

using namespace std;

int main(int argc, char const* argv[])
{
   int N,W;
   cin >> N >> W;
   vector<int>v(N),w(N);
   for(int i=0;i<N;i++)cin >> v[i] >> w[i];
   vector<vector<int> >dp(N+1,vector<int>(W+1));
   for(int i=0;i<=W;i++) dp[0][i] = 0;
   for(int i=0;i<N;i++){
      for(int j=0;j<=W;j++){
         if(j >= w[i])dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
         else dp[i+1][j] = dp[i][j];
      }
   }
   cout << dp[N][W] << endl;
   return 0;
}




Measured memory_bytes: 6872
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var H = sc.ArrayInt(N);

        var max = 0;
        var cnt = 0;
        for (int i = 1; i < N; i++) {
            if (H[i] <= H[i-1]) {
                cnt++;
            } else {
                max = Max(max, cnt);
                cnt = 0;
            }
        }
        max = Max(max, cnt);
        WriteLine(max);
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  int n;
  cin >> n;
  set<int> S;
  S.insert((int)-(1e9+7));
  int a;
  rep(i, 0, n) {
    cin >> a;
    S.insert(a);
  }

  vector<int> A;
  for (auto s: S) {
    A.pb(s);
  }

  int MAX = A[A.size()-1];

  auto it1 = S.lower_bound(MAX/2);
  auto it2 = prev(it1, 1);
  int tmp1 = *it1;
  int tmp2 = *it2;

  if (MAX % 2 == 1) {
    int ok1 = MAX / 2;
    int ok2 = MAX / 2 + 1;
    int dis1_1 = abs(tmp1 - ok1);
    int dis1_2 = abs(tmp1 - ok2);
    int dis2_1 = abs(tmp2 - ok1);
    int dis2_2 = abs(tmp2 - ok2);
    vector<int> ele = { tmp1, tmp1, tmp2, tmp2 };
    vector<int> dis = {dis1_1, dis1_2, dis2_1, dis2_2};
    vector<int> ord(4);
    iota(ord.begin(), ord.end(), 0);

    sort(ord.begin(), ord.end(),  [&](int a, int b) {
      if (dis[a] == dis[b]) return dis[a] > dis[b];
      return dis[a] < dis[b];
    });
    cout << MAX << " " << ele[ord[0]] << endl;
  } else {
    int ok = MAX / 2;
    if (abs(tmp2 - ok) <= abs(tmp1 - ok)) {
      cout << MAX << " " << tmp2 << endl;
    } else {
      cout << MAX << " " << tmp1 << endl;
    }
  }

  return 0;
};


Measured memory_bytes: 5628
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = readmi()
t1 = b // c - (a - 1) // c
t2 = b // d - (a - 1) // d
l = lcm(c, d)
t3 = 0
t3 = b // l - (a - 1) // l
k = t1 + t2 - t3
print(b - (a - 1) - k)

Measured memory_bytes: 6352
package main

import "fmt"

type Dice struct {
	T, S, E, W, N, B int
}

func (p *Dice) roll(direction rune) {

	if direction == 'S' {
		p.S, p.B, p.N, p.T = p.T, p.S, p.B, p.N
	} else if direction == 'N' {
		p.N, p.B, p.S, p.T = p.T, p.N, p.B, p.S
	} else if direction == 'W' {
		p.W, p.B, p.E, p.T = p.T, p.W, p.B, p.E
	} else if direction == 'E' {
		p.E, p.B, p.W, p.T = p.T, p.E, p.B, p.W
	}

}

func main() {

	var (
		t, s, e, w, n, b    int
		num, dist_t, dist_s int
	)

	fmt.Scanln(&t, &s, &e, &w, &n, &b)

	dice1 := Dice{t, s, e, w, n, b}

	fmt.Scanln(&num)

	for i := 0; i < num; i++ {
		fmt.Scanln(&dist_t, &dist_s)

		for j := 0; j < 5; j++ {
			if dice1.T == dist_t {
				break
			} else {
				if j%2 == 0 {
					dice1.roll('N')
				} else {
					dice1.roll('W')
				}
			}
		}

		for j := 0; j < 3; j++ {
			if dice1.S == dist_s {
				break
			} else {
				dice1.roll('N')
				dice1.roll('W')
				dice1.roll('S')
			}
		}

		fmt.Printf("%d\n", dice1.E)
	}

}



Measured memory_bytes: 1160
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
typedef long long ll;
const int INF=0x3f3f3f3f;
//queues<int,vector<int >,greater<int > >q;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
int main()
{
  int n,ss[26];
  mem(ss);
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n;i++)
    ss[s[i]-'a']++;
    ll sum=1;
  for(int q:ss)
    sum=sum%mod*(q+1)%mod;
  cout<<(sum-1+mod)%mod<<endl;
}
/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


Measured memory_bytes: 512
main(n){
	double x,y,u;
	for(;scanf("%d",&n),--n>0;printf("%f\n%f\n",x,y))
		for(x=1,y=0;n--;x+=cos(u),y+=sin(u))u=atan2(y,x)+1.570796;
	exit(0);
}

Measured memory_bytes: 716