akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
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 Int() {
        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] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        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] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();
        int Q = cin.Int();
        var L = new int[M];
        var R = new int[M];

        var cnt = new int[510, 510];
        for (int i = 0; i < M; i++) {
            L[i] = cin.Int();
            R[i] = cin.Int();
            cnt[L[i], R[i]]++;
        }
        var sum = new int[510, 510];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                sum[i, j] = sum[i, j - 1] + cnt[i, j];
            }
        }

        var p = new int[Q];
        var q = new int[Q];
        for (int i = 0; i < Q; i++) {
            p[i] = cin.Int();
            q[i] = cin.Int();
        }

        for (int i = 0; i < Q; i++) {
            int ans = 0;
            for (int j = p[i]; j <= q[i]; j++) {
                ans += sum[j, q[i]] - sum[j, p[i] - 1];
            }
            Console.WriteLine(ans);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 20132
import math

n=int(input())
dp=[0]*(10**6)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            dp[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(n):
    print(dp[i+1])


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

constexpr int inf = 1e9;

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    vector<int> hs;
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
        hs.push_back(h[i]);
    }
    sort(begin(hs), end(hs));
    hs.erase(unique(begin(hs), end(hs)), end(hs));
    const int m = hs.size();
    vector<int> cnt(m + 1);
    for(int i = 0; i < n; ++i) {
        const int idx = lower_bound(begin(hs), end(hs), h[i]) - begin(hs);
        cnt[idx + 1] += 1;
    }
    for(int i = 0; i < m; ++i) {
        cnt[i + 1] += cnt[i];
    }

    int ans = 2 * inf;
    for(int i = 0; i < m; ++i) {
        int lb = i, ub = m;
        while(ub - lb > 1) {
            const int mid = (ub + lb) >> 1;
            if(cnt[mid] - cnt[i] >= k) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        if(cnt[ub] - cnt[i] < k) continue;
        ans = min(ans, hs[ub - 1] - hs[i]);
    }

    cout << ans << endl;
}


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

int main(){
  int n,z,w;
  cin>>n>>z>>w;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  if(n==1)cout<<abs(a[0]-w)<<endl;
  else cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))<<endl;
}

Measured memory_bytes: 3608
#NotFound
s = list(input())
s = set(s)
s = sorted(s)
a = list(str('abcdefghijklmnopqrstuvwyz'))
for i in range(len(s)):
  if s[i] in a:
    a.remove(s[i])
if len(a) == 0:
  print('None')
else:
  print(a[0])

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> v(100000+1);
    for(int i=0;i<N;i++){ 
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    int ans = 0;
    priority_queue<int> Q;
    for(int i=1;i<=M;i++){
        for(auto x:v[i]) Q.push(x);
        if(Q.empty()) continue;
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int gcd(int x, int y){int r;while((r=x%y)!=0)x=y,y=r;return y;}

int main(void){

    int sx,sy;
    int tx,ty;
    int x,y;
    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
    
    x=tx-sx;
    y=ty-sy;
    
    for(int i=0;i<y;i++){
        printf("U");
    }
    for(int i=0;i<x;i++){
        printf("R");
    }
    for(int i=0;i<y;i++){
        printf("D");
    }
    for(int i=0;i<x;i++){
        printf("L");
    }
    
    printf("L");
    for(int i=0;i<y+1;i++){
        printf("U");
    }
    for(int i=0;i<x+1;i++){
        printf("R");
    }
    printf("DR");
    for(int i=0;i<y+1;i++){
        printf("D");
    }
    for(int i=0;i<x+1;i++){
        printf("L");
    }
    printf("U");
    printf("\n");
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int nC2 = N * (N-1) / 2;
    int mC2 = M * (M-1) / 2;
    cout << nC2 + mC2 << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

string s[30][30];

int main(void){
	int i,j;

	int H,W;
	cin >> H >> W;
	for(i=1;i<=H;i++) for(j=1;j<=W;j++) cin >> s[i][j];
	for(i=1;i<=H;i++) for(j=1;j<=W;j++) if(s[i][j]=="snuke"){
		cout << (char)('A'+j-1) << i << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int num[3];
    int i,j;
    int max, min;

    for(i=0; i<3; i++){
        scanf("%d", &num[i]);
    }

    if(num[0] > num[1]){
        max = num[0];
        min = num[1];
    }else{
        max = num[1];
        min = num[0];
    }

    if(num[2] > min && num[2] <max){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

int main (){
  int N,K;
  cin >> N >> K;
  
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  sort(a,a+N,greater<int>());
  
  int sum=0;
  for(int i=0;i<K;i++){
    sum+=a[i];
  }
  
  cout << sum << endl;
  return 0;
}
  
  


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 2000;
const int INF = (1<<30);
struct edge{
    int to; edge *nxt;
}edges[2*MAXN + 5], *adj[MAXN + 5], *ecnt=&edges[0];
void addedge(int u, int v) {
    edge *p = (++ecnt);
    p->to = v, p->nxt = adj[u], adj[u] = p;
    p = (++ecnt);
    p->to = u, p->nxt = adj[v], adj[v] = p;
}
int a[MAXN + 5], N;
int f[MAXN + 5], s[MAXN + 5];
void dfs(int x, int fa) {
    s[x] = a[x], f[x] = 0;
    for(edge *p=adj[x];p;p=p->nxt) {
        if( p->to == fa ) continue;
        dfs(p->to, x), s[x] += s[p->to];
        f[x] += f[p->to] + s[p->to];
    }
}
int get(int x, int fa) {
    int mx = 0;
    for(edge *p=adj[x];p;p=p->nxt) {
        if( p->to == fa ) continue;
        if( mx == 0 || f[p->to] > f[mx] ) mx = p->to;
    }
    if( mx == 0 ) return 0;
    int k = get(mx, x) + s[mx];
    if( f[x] - f[mx] - s[mx] >= k ) return f[x] & 1;
    else return k - (f[x] - f[mx] - s[mx]);
}
char S[MAXN + 5];
int main() {
    scanf("%d%s", &N, S + 1);
    for(int i=1;i<=N;i++) a[i] = S[i] - '0';
    for(int i=1;i<N;i++) {
        int u, v; scanf("%d%d", &u, &v);
        addedge(u, v);
    }
    int ans = INF;
    for(int j=1;j<=N;j++) {
        dfs(j, 0);
        if( get(j, 0) == 0 )
            ans = min(ans, f[j]/2);
    }
    if( ans == INF ) printf("-1\n");
    else printf("%d\n", ans);
}

Measured memory_bytes: 384
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, r= MAP()

if(n<10):
    print(r + 100*(10-n))
else:
    print(r)

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

#define int long long

int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    vector<int> dp(n + 1);

    dp[0] = 1;

    for (int i = 3; i <= n; ++i) {
        for (int j = 3; j <= i; ++j) {
            dp[i] = (dp[i] + dp[i - j]) % MOD;
        }
    }

    cout << dp[n];
}

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

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

    while (t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3600
import sys
input = sys.stdin.readline
H,W = map(int,input().rstrip().split())
h,w = map(int,input().rstrip().split())
cells = [[1]*W]*H
cells = cells[h:]
cells = list(zip(*cells))
cells = cells[w:]
print(sum(list(map(sum,list(zip(*cells))))))

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

//struct position{int x;};

int main(void){
	ll a,b,c;
	cin>>a>>b>>c;
	ll na,nb,nc;
	ll ans=0;
	while(a%2==0&&b%2==0&&c%2==0){
		na = (b+c)/2;
		nb=(c+a)/2;
		nc=(a+b)/2;
		if(min(na,min(nb,nc)) == min(a,min(b,c)) && max(na,max(nb,nc)) == max(a,max(b,c))){
			cout<<-1<<endl;
			return 0;
		}
		a=na;
		b=nb;
		c=nc;
		ans++;

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


Measured memory_bytes: 512
s=input()
n=len(s)
ans=""
res=[]
for i in range(n):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or  s[i]=="C":
        ans+=s[i]
    else:
        if ans!="":
            res.append(ans)
        ans=""
        continue
res.append(ans)
if not res:
    print(0)
    exit()
print(len(max(res, key=len)))

Measured memory_bytes: 38384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

    int ans = 1e9;
    REP(i,n){
        int x = 0;
        while (a[i] % 2 == 0){
            x++;
            a[i] /= 2;
        }
        ans = min(ans, x);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l=nxt(),r=nxt(),d=nxt();
    int test=0;
    for(int i=l;i<=r;i++)
        if(i%d==0)
            test++;
        cout<<test<<endl;


    return 0;   
}


 
 


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main(void)
{
    FastIO;
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll p[4];
    p[0]=a*c;
    p[1]=a*d;
    p[2]=b*c;
	p[3]=b*d;
	sort(p,p+4);
	cout<<p[3];
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  int res=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o')res++;
  }
  res+=(15-s.size());
  if(res>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    for(int i=0;i<S.length()-1;i++){
        if(S[i]==S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._
    val s = readLine()
    val stack = scala.collection.mutable.Stack[Char]()
    s foreach {
      case c @ ('0' | '1') => stack.push(c)
      case 'B' => if (stack.nonEmpty) stack.pop()
    }
    println(stack.reverse.mkString)
  }

}


Measured memory_bytes: 27180
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    auto n = to!int(chomp(readln()));
    for(int i=0;i<n;i++){
	auto s = split(readln());
	real[] a;
	foreach(j;s) a ~= to!real(j);
	real R2 = (a[0] - a[3])*(a[0] - a[3]) + (a[1] - a[4])*(a[1] - a[4]);
	if(R2 > (a[2] + a[5])*(a[2] + a[5])) writeln("0");
	else if(R2 <= (a[2] + a[5])*(a[2] + a[5])){
	    if( sqrt(R2) + a[2] < a[5]) writeln("-2");
	    else if(sqrt(R2) + a[5] < a[2]) writeln("2");
	    else writeln("1");
	}
    }
}

Measured memory_bytes: 2460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<ul, ul> puu;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define do(i, j, k) for(int i = j; i <= (k); i ++)
#define enum(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i <  (k); i ++)
#define dec(i, j, k)  for(int i = j; i >= (k); i --)
#define mfil(x, k) memset(x, k, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y, true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y, true) : false; }
struct __init { __init()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout.precision(16); cout << fixed;
    srand(time(0) ^ ul(new char));
} } static __init__;
/* default code ends here */

const int maxn = 1e5 + 10;
int n;
ll x;
struct ex
{
    ll b, l, r;
    ll val;
    void input()
    {
        cin >> b >> l >> r;
        val = b * l + (x - b) * r;
    }
    bool operator < (ex p) const
    {
        return val > p.val;
    }
} pool[maxn];
int main()
{
    cin >> n >> x;
    do(i, 1, n)
        pool[i].input();
    sort(pool + 1, pool + n + 1);
    ll hhh = 0;
    do(i, 1, n)
        hhh += pool[i].b * pool[i].l;
    ll sum = 0;
    int t = 1;
    while(sum < hhh)
        sum += pool[t ++].val;
    t --;
    if(sum > hhh)
        sum -= pool[t --].val;
    if(t == n)
    	return cout << t * x << '\n', 0;
    //cerr << x << ' ' << t << ' ' << hhh - sum << ' ' << pool[t + 1].val << endl;
    ll ans = x;
    do(i, 1, t)
    {
        ll d = hhh - (sum + pool[t + 1].val - pool[i].val);
        if(pool[i].b * pool[i].l >= d)
            chkmin(ans, (d + pool[i].l - 1) / pool[i].l);
        else
            chkmin(ans, pool[i].b + (d - pool[i].b * pool[i].l + pool[i].r - 1) / pool[i].r);
    }
    //cout << ans << endl;
    do(i, t + 1, n)
    {
        ll d = hhh - sum;
        if(pool[i].val >= d)
        {
            if(pool[i].b * pool[i].l >= d)
                chkmin(ans, (d + pool[i].l - 1) / pool[i].l);
            else
                chkmin(ans, pool[i].b + (d - pool[i].b * pool[i].l + pool[i].r - 1) / pool[i].r);
        }
    }
    cout << ans + x * t << '\n';
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
	int N,C,p[100]={},i,goukei=0,ans=0;
	scanf("%d %d",&N,&C);
	for(i=0;i<C;i++){
		scanf("%d",&p[i]);
		goukei=goukei+p[i];
	}
	ans=goukei/(N+1);
	if(goukei%(N+1)!=0){
		printf("%d\n",ans+1);
	}else{
		printf("%d\n",ans);
	}	
	return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>
using namespace std;
bool b[4];
int main(){
	string a;
	int i,n;
	int s=0;
	cin>>a;
	for(i=0;i<a.size();i++){
		if(a[i]=='N'){
			b[0]=true;
		}
		if(a[i]=='S'){
			b[1]=true;
		}
		if(a[i]=='W'){
			b[2]=true;
		}
		if(a[i]=='E'){
			b[3]=true;
		}
	}
	if(b[0]){
		if(!b[1])s=1;
	}
	if(b[1]){
		if(!b[0])s=1;
	}
	if(b[2]){
		if(!b[3])s=1;
	}
	if(b[3]){
		if(!b[2])s=1;
	}
	if(s==1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}
	
		

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

#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define fi first
#define se second

const int inf = 1e17 + 9;

typedef pair<int, int> P;

int n, m;
int k[160];

int dp[160][16][80];

signed main()
{
  while (cin >> n >> m, n){
    vector<P> s[160];
    rep(i, n){
      cin >> k[i];
      rep(j, k[i]){
        int d, x;
        cin >> x >> d;
        s[i].push_back(P(x, d));
      }
    }

    rep(i, 160) rep(j, 16) rep(l, 80) dp[i][j][l] = inf;

    rep(j, k[0]) dp[0][j][m] = 0;
    if (m) rep(j, k[1]) dp[1][j][m - 1] = 0;

    rep(i, n - 1){
      rep(j, k[i]){
        rep(l, m + 1){
          if (i == n - 2 && l > 0) continue;

          rep(t, k[i + 1]){
            int cost = (s[i][j].se + s[i + 1][t].se) * abs(s[i][j].fi - s[i + 1][t].fi);
            //printf("%d:%d -> %d:%d = %d\n", i, j, i + 1, t, cost);
            dp[i + 1][t][l] = min(dp[i + 1][t][l], dp[i][j][l] + cost);
          }

          if (l > 0){
            rep(t, k[i + 2]){
              int cost = (s[i][j].se + s[i + 2][t].se) * abs(s[i][j].fi - s[i + 2][t].fi);
              //printf("%d:%d -> %d:%d = %d\n", i, j, i + 2, t, cost);
              dp[i + 2][t][l - 1] = min(dp[i + 2][t][l - 1], dp[i][j][l] + cost);
            }
          }
        }
      }
    }

    int ans = inf;
    rep(j, k[n - 1]) rep(l, m + 1) ans = min(ans, dp[n - 1][j][l]);
    rep(j, k[n - 2]) for (int l = 1; l <= m; l++) ans = min(ans, dp[n - 2][j][l]);

    cout << ans << endl;
  }
}

Measured memory_bytes: 4752
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> Hs(N);
    int ans = 0;
    int prev = 0;
    REP(n, N){
        int h;
        cin >> h;
        if (h > prev) ans += h - prev;
        prev = h;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
NUM = 3
MAX_N = 100
def check(ty, yx, n):
    flg = False
    ty[yx[n]] += 1
    if NUM == ty[yx[n]]:
        flg = True
    return flg

def check_naname(nnm, y, x, n):
    flg = False
    if y[n] == x[n]:
        nnm[0] += 1
        if (NUM == nnm[0]):
            flg = True
    if y[n] == NUM - x[n] - 1:
        nnm[1] += 1
        if (NUM == nnm[1]):
            flg = True
    return flg

def main():
    y = [-1] * MAX_N
    x = [-1] * MAX_N
    for i in range(NUM):
        *A, = map(int, input().split())
        for j in range(NUM):
            A[j] -= 1
            y[A[j]] = i
            x[A[j]] = j
    N = int(input())
    tate = [0] * NUM
    yoko = [0] * NUM
    naname = [0] * 2
    flg = False
    for i in range(N):
        b = int(input())
        b -= 1
        if -1 == y[b]:
            continue
        flg = check(yoko, y, b)
        if flg:
            break
        flg = check(tate, x, b)
        if flg:
            break
        flg = check_naname(naname, y, x, b)
        if flg:
            break
    print("Yes" if flg else "No")
    return


main()


Measured memory_bytes: 3188
#include <stdlib.h>
#include <iostream>
using namespace std;

int main(void){
  int A,B,C,tmp;
  
  cin >> A >> B >> C;
  
  tmp = A;
  A = B;
  B = tmp;
  
  tmp = A;
  A = C;
  C = tmp;
  
  printf("%d %d %d\n", A, B, C);
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,Ans;
  int A[2000];
int solve(int i ,int m){
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  Ans=solve(i+1,m-A[i])|solve(i+1,m);
  return Ans;
}

int main(){
  int q,m,i;

  scanf("%d",&n);
  for( i=0;i<n;i++){
  scanf("%d",&A[i]);
}
scanf("%d",&q);
for(i=0;i<q;i++){
  scanf("%d",&m);
if  (solve(0,m))printf("yes\n");
else printf("no\n");
}

  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <map>
using namespace std;

vector<long long> v;

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

   v.assign(n + 1, 0);

   for (int i = 2; i <= n; i++)
   {
      for (int k = i; k <= n; k += i)
      {
         v[k]++;
      }
   }

   long long ans = 0;
   for (int i = 1; i <= n; i++)
   {
      ans += (v[i] + 1) * i;
   }

   cout << ans;

   return 0;
}

Measured memory_bytes: 81324
#include <iostream>

using namespace std;

int main()
{
    int K;
    cin >> K;
    int sum = 0;
    int a = 7;
    for (int i = 1; i <= K; i++)
    {
        sum += a;
        sum %= K;
        if (sum == 0)
        {
            cout << i;
            return 0;
        }
        a = (a * 10) % K;
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 3620
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int n,x,y;
vector<vector<int>>adjl;
int main()
{
    cin>>n>>x>>y;
    x--,y--;
    adjl.resize(n,vector<int>(n));

    for(int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            adjl[i][j]=abs(i-j);
        }
    }

    adjl[x][y]=1;
    adjl[y][x]=1;


    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            adjl[i][j]=min(adjl[i][j],adjl[i][x]+1+adjl[y][j]);
            adjl[i][j]=min(adjl[i][j],adjl[i][y]+1+adjl[x][j]);
        }
    }

    vector<int>ans(n+1);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
                ans[adjl[i][j]]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<ans[i]/2<<endl;

    return 0;
}



Measured memory_bytes: 16000
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int N, A, B, C;
vector<int> L;

int rec(int idx, int a, int b, int c)
{
    if (idx == N) {
        if (a == 0 or b == 0 or c == 0) return INF;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int res = rec(idx+1, a, b, c);

    res = min(res, rec(idx+1, a+L[idx], b, c) + (a ? 10 : 0));
    res = min(res, rec(idx+1, a, b+L[idx], c) + (b ? 10 : 0));
    res = min(res, rec(idx+1, a, b, c+L[idx]) + (c ? 10 : 0));

    return res;
}

int main()
{
    cin >> N >> A >> B >> C;
    rep (i, 0, N) {
        int l; cin >> l;
        L.push_back(l);
    }

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
satisfaction = 0
for i in range(N):
    satisfaction += B[i]
    if i > 0 and A[i-1] + 1 == A[i]:
        satisfaction += C[A[i-1] - 1]
print(satisfaction)

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

struct UnionFind{
  //これは一段上の点を示す．自分が最上位（ルート）なら負のサイズをもつ
  vector<int> Parent;
  
  UnionFind(int n){
    Parent=vector<int>(n,-1);
  }

  int root(int a){
    if(Parent[a]<0) return a;
    Parent[a]=root(Parent[a]);
    return Parent[a];
  }
  
  int size(int a){
    return -Parent[root(a)];
  }
  
  bool connect(int a,int b){
    if(root(a)==root(b)) return false;
    if(size(a)<size(b)) swap(a,b);
    Parent[root(a)]-=size(b);
    Parent[root(b)]=root(a);
    return true;
  }
};
int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> bridge;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    bridge.push_back(make_pair(a-1,b-1));
  }
  reverse(bridge.begin(),bridge.end());
  UnionFind land(n);
  ll inc=(ll)(n-1)*n/2;
  vector<ll> ans;
  ans.push_back(inc);
  for(int i=0;i<m;i++){
    
    int a=bridge[i].first,b=bridge[i].second;
    //くっついてなかった場合
    if(land.root(a)!=land.root(b)){
      inc-=(ll)(land.size(a)*land.size(b));
      land.connect(a,b);
      ans.push_back(inc);
    }
    //すでにくっついてる場合，変化はない
    else ans.push_back(inc);
  }
  reverse(ans.begin(),ans.end());
  ans.erase(ans.begin());
  for(ll x:ans){
    cout<<x<<endl;
  }
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int n,i,ans=0,sum=0;
  cin>>s;
  n=3;
  for(i=0;i<n;i++)
  {
    if(s[i]=='R')
    {
      sum++;
      if(sum>ans) ans=sum;
    }
    else
    {
      sum=0;
    }
  }  
  cout<<ans;
 	return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env ruby

turn = gets.to_i
line = []
taro_points = 0;hanako_points = 0
turn.times do 
    line = gets.split
    if line[0] == line[1] then
        taro_points += 1
        hanako_points += 1
    elsif line[0] > line[1] then
        taro_points += 3
    elsif line[0] < line[1] then
        hanako_points += 3
    end
end

puts "#{taro_points} #{hanako_points}"


Measured memory_bytes: 6892
/*
 * Author : Sadi
 * Wed 08/07/2020
 * 23:27:06.51
 */
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;

long long gcd(long long a, long long b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
    	cin >> v[i];
    }
    long long lcm = v[0];
    for(int i = 1; i < n; ++i) {
    	lcm = (v[i] * lcm) / gcd(v[i], lcm);
    }
    long long result = 0;
    for(int i = 0; i < n; ++i) {
    	result += (lcm / v[i]);
    }
    double ans = (double) lcm / (double) result;
    cout << fixed << setw(6) << ans << endl;
    return 0;
}


Measured memory_bytes: 3796
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}

vector<ll>v[Max+10];

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


    cin>>n;

    ll ara[n+2],bra[n+2]={};

    for(i=1; i<=n; i++)
        {
            cin>>ara[i];

            if(i%2)bra[1]+=ara[i];

            else bra[1]-=ara[i];

        }




    cout<<bra[1]<<" ";

    for(i=2; i<=n; i++)
    {
        sum=bra[i-1]/2;

        sum=ara[i-1]-sum;

        sum*=2;



        bra[i]=sum;

       cout<<sum<<" ";
    }

    cout<<endl;





}



Measured memory_bytes: 52032
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define LP(i, a, n) for(int i = a; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef struct node node;
int main() {
  int n, q, b, c=0;
  int a[100000];
  cin >> n;
  lp(n) cin >> a[i];
  cin >> q;
  lp(q) {
    cin >> b;
    if(binary_search(begin(a), begin(a) + n, b)) c++;
  }
  cout << c << endl;
  return 0;
}




Measured memory_bytes: 3472
def d_integer_cards(N, M, A, Operation_info):
    from bisect import bisect_left
    from collections import deque

    a = deque(sorted(A))
    Operation_info.sort(key=lambda x: x[1], reverse=True)

    tmp = []
    for b, c in Operation_info:
        index = bisect_left(a, c)
        if index > 0:
            for j in range(min(b, index)):
                a.popleft()
                tmp.append(c)
    return sum(list(a) + tmp)

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
Operation_info = [[int(i) for i in input().split()] for j in range(M)]
print(d_integer_cards(N, M, A, Operation_info))

Measured memory_bytes: 27884
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a[3];
	int d[3];
	int ans=0;
	int odd=0;
	
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0;i<3;i++)
	{
		if(a[i]%2==1)
			odd++;
	}
	if(odd==1)
	{
		for(int i=0;i<3;i++)
		{
			if(a[i]%2==0)
				a[i]++;
		}
		ans++;
	}else if(odd==2){
		for(int i=0;i<3;i++)
		{
			if(a[i]%2==1)
				a[i]++;
		}
		ans++;
	}
	d[0]=0;
	sort(a,a+3);
	for(int i=0;i<3;i++)
	{
		ans += (a[2]-a[i])/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    int n = s.length();
    string t1 = s;
    reverse(all(t1));
    string s2 = s.substr(0, (n - 1) / 2);
    string t2 = s2;
    reverse(all(t2));
    string s3 = s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1);
    string t3 = s3;
    reverse(all(t3));
    if (s == t1 && s2 == t2 && s3 == t3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
var log = console.log;
if (typeof process != "undefined") {
    var input = "";
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function (chunk) {
        input += chunk;
    });
    process.stdin.on('end', function () {
        var lines = input.split("\n");
        main(lines);
    });
}
 
//-----
 
function main(lines) {
    lines.shift();
    while (lines.length > 0) {
        var dataset = lines.slice(0, 2);
        dataset = dataset.map(function (row) {
            return row.split("").filter(function (e) {
                var code = e.charCodeAt(0);
                return (97 <= code && code <= 122)||(65 <= code && code <= 90);
            }).join("");
        });
        processDataset(dataset);
        lines = lines.slice(2);
    }
}
 
function processDataset(dataset) {
    var A = [];
    var f = dataset[0];
    var s = dataset[1];
    for (var i = 0; i < f.length; i++) {
        A[i] = [];
        for (var j = 0; j < s.length; j++) {
            if (f.charAt(i) == s.charAt(j)) {
                A[i][j] = 1;
            } else {
                A[i][j] = 0;
            }
            if (i == 0 && j == 0) {
                A[i][j] += 0;
            } else if (i == 0) {
                A[i][j] = Math.max(A[i][j - 1], A[i][j]);
            } else if (j == 0) {
                A[i][j] = Math.max(A[i - 1][j], A[i][j]);
            } else {
                if(f.charAt(i) == s.charAt(j)){
                    A[i][j] = A[i-1][j-1]+1;
                }else{
					A[i][j] = Math.max(A[i][j-1],A[i-1][j]);
				}
            }
            if(i == f.length - 1 && j == s.length - 1){
                log(A[i][j]);
            }
        }
    }
}

Measured memory_bytes: 97780
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
using ll = long long;
using ld = long double;
const int mxn = 1e5+10;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x; cin>>x;
	if(x<=599) cout << 8 << '\n';
	else if(x<=799) cout << 7 << '\n';
	else if(x<=999) cout << 6 << '\n';
	else if(x<=1199) cout << 5 << '\n';
	else if(x<=1399) cout << 4 << '\n';
	else if(x<=1599) cout << 3 << '\n';
	else if(x<=1799) cout << 2<< '\n';
	else cout <<1 << '\n';

	return 0;
}

Measured memory_bytes: 3620
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1,n):
  for j in range(max(0,i-k),i):
    dp[i] = min(dp[i],dp[j]+abs(h[j]-h[i]))
print(dp[-1])

Measured memory_bytes: 85148
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    # ai, ao, at, aj, al, as, az
    A = LI()

    res = 0
    for e in (0, 3, 4):
        res += A[e] // 2 * 2

    if all([A[0], A[3], A[4]]):
        tmp = 3
        for e in (0, 3, 4):
            tmp += (A[e] - 1) // 2 * 2
        if res < tmp:
            res = tmp

    return res + A[1]


print(main())


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

using namespace std;

typedef long long ll;

ll find(int n) {
    int left = 1, right = n;
    while (left < right) {
        int mid = (left + right + 1) / 2;
        if ((1ll * mid * (mid + 1)) / 2 > n) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }
    return left;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    string s;
    cin >> s;
    vector<pair<int, int>> dp(s.size());
    dp[0].first = 1;
    dp[0].second = -1e9;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i - 1] != s[i]) {
            dp[i].first = max(dp[i - 1].first, dp[i - 1].second) + 1;
        } else {
            dp[i].first = dp[i - 1].second + 1;
        }
        if (i == 1) {
            dp[i].second = 1;
        } else if (i == 2) {
            dp[i].second = 1 + dp[i - 2].first;
        } else {
            if (s[i] + s[i - 1] != s[i - 2] + s[i - 3]) {
                dp[i].second = max(dp[i - 2].first, dp[i - 2].second) + 1;
            } else {
                dp[i].second = dp[i - 2].first + 1;
            }
        }
    }
    cout << max(dp[s.size() - 1].first, dp[s.size() - 1].second);
    return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define pii pair<int,int>
using namespace std;

const int Mod = 1e9+7;

signed main() {
    int a[3];
    for(int i=0;i<3;i++) cin>>a[i];
    int k;cin>>k;

	bool ok=0;
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			for(int z=0;z<=k;z++){
				if(x+y+z<=k){
					int p = (a[0]*(1LL<<x)) , q = (a[1]*(1LL<<y)) , r = (a[2]*(1LL<<z));
					if(q>p && r>q){
						// cout<<p<<" "<<q<<" "<<r<<endl;
						ok=1;
					}
				}
			}
		}
	}
   	if(ok) cout<<"Yes"<<endl;
   	else cout<<"No"<<endl;
}

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

int main() {
  int64_t w,h,x,y;
  cin>>w>>h>>x>>y;
  int64_t k=w*h;
  double s=k/2.0;
  cout << fixed << setprecision(20);
  cout << s;
  if ((w==x*2) & (h==y*2)) {
    cout << " 1" << endl;
  } else {
    cout << " 0" << endl;
  }
}




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

using namespace std;

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  map<pair<string, string>, int> mp;
  for (int i = 0; i < 1 << n; i++) {
    string x, y;
    for (int j = 0; j < n; j++) {
      if ((1 << j) & i) {
        x += s[j];
      } else {
        y += s[j];
      }
    }
    reverse(y.begin(), y.end());
    mp[{x, y}]++;
  }
  long long ans = 0;
  for (int i = 0; i < 1 << n; i++) {
    string x, y;
    for (int j = 0; j < n; j++) {
      if ((1 << j) & i) {
        x += s[2 * n - j - 1];
      } else {
        y += s[2 * n - j - 1];
      }
    }
    reverse(y.begin(), y.end());
    ans += mp[{x, y}];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 87040
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

struct node
{
	int x;
	LL p;

	node() { }
	node(int _x, LL _p): x(_x), p(_p) { }
};

int n, S;

deque<node> a;

inline void input()
{
	n = read<int>(), S = read<int>();
	for(int i = 0; i < n; ++i)
	{
		int x = read<int>(), p = read<int>();
		a.emplace_back(x, p);
	}
}

LL ans = 0;

inline int calc()
{
	if(S <= a.front().x)
	{
		int p = a.back().x;
		ans += p - S, a.clear();
		return p;
	}
	else if(S >= a.back().x)
	{
		int p = a.front().x;
		ans += S - p, a.clear();
		return p;
	}
	else
	{
		int p;
		if(a.front().p < a.back().p)
		{
			p = a.front().x;
			a.back().p += a.front().p;
			a.pop_front();
		}
		else
		{
			p = a.back().x;
			a.front().p += a.back().p;
			a.pop_back();
		}
		ans += abs(calc() - p);
		return p;
	}
}

inline void solve()
{
	ans = 0, calc();
	printf("%lld\n", ans);
}

int main()
{
#ifdef K_ON
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long  ll;
const int N = 1e5 + 4;

int memo[N] , n , m;
vector<int> adj[N];


int solve(int node){

    int &ret = memo[node];
    if(~ret)
        return ret;
    ret = 0;
    for(int child : adj[node])
        ret = max(ret , 1 + solve(child));
    return ret;
}

int main() {
    ios::sync_with_stdio() , cin.tie(0) , cout.tie();
    cin >> n >> m;

    for(int i = 0 ; i < m ; ++i){
        int u , v;
        cin >> u >> v;
        adj[u].pb(v);
    }

    memset(memo , -1 , sizeof memo);
    int mx = 0;

    for(int i = 1 ; i <= n ; ++i)
        mx = max(mx , solve(i));

    cout << mx << '\n';
}


Measured memory_bytes: 7424
import itertools
n, W = list(map(int, input().split()))
data = [[] for i in range(4)]
base = 0
for i in range(n):
    w, v = map(int, input().split())
    if i == 0:
        base = w
    data[w-base].append(v)
for i in range(4):
    data[i].sort(reverse=True)
    data[i] = list(itertools.accumulate(data[i]))
ans = 0
for r_0 in range(len(data[0])+1):
    for r_1 in range(len(data[1])+1):
        for r_2 in range(len(data[2])+1):
            for r_3 in range(len(data[3])+1):
                if (r_0 * base) + (r_1 * (base + 1)) + (r_2 * (base + 2)) + (r_3 * (base + 3)) <= W:
                    cand = 0
                    if r_0 >= 1:
                        cand += data[0][r_0-1]
                    if r_1 >= 1:
                        cand += data[1][r_1-1]
                    if r_2 >= 1:
                        cand += data[2][r_2-1]
                    if r_3 >= 1:
                        cand += data[3][r_3-1]
                    ans = max(ans, cand)
print(ans)



Measured memory_bytes: 45292