akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int n;
    cin >> n;
    int x[n];
    int y[n];
    long double manhattan = 0;
    long double euclid = 0;
    long double cdist = 0;
    int chebyshev = 0;
    REP(i, n)
        cin >> x[i];
    REP(i, n){
        cin >> y[i];
        manhattan += abs(x[i] - y[i]);
        euclid += square(x[i] - y[i]);
        cdist += cube(abs(x[i] - y[i]));
        chebyshev = max(chebyshev, abs(x[i] - y[i]));
    }
    cout << setprecision(10);
    cout << manhattan << endl << sqrt(euclid) << endl << cbrt(cdist) << endl << chebyshev << endl;

    return 0;
}

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

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

 int sum = 0;
 rep(i, n.length()){
    sum += (int)(n[i]-'0');
 }
 if (sum % 9 == 0){
  cout << "Yes" << endl;
 } else {
  cout << "No" << endl;
 }
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary   
int main()
{
      fast;ll t;t=1;
      while(t--)
      {
            ll n,i,a;
            cin>>n;
            ll x[n+2];
            cin>>x[0];a=x[0];
            for(i=1;i<n;i++){
                  cin>>x[i];a=a ^ x[i];
            }
            //cout<<a;
            for(i=0;i<n;i++){
                  cout<<(a ^ x[i])<<" ";
            }
      }     
}

Measured memory_bytes: 5088
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    if(n%2 == 0){
    	int[] d = new int[n];
    	for(int i=0; i<n; i++){
			d[i] = sc.nextInt();
    	}
    

    	Arrays.sort(d);
      
    	int ans = d[n/2]-d[n/2-1];
    	System.out.println(ans);
    }
    else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 50420
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$b=explode(" ",trim(fgets(STDIN)));
$c=explode(" ",trim(fgets(STDIN)));
$ans=$b[$a[0]-1];
$i=1;
while($i<$n){
  $ans+=$b[$a[$i]-1];
  if($a[$i]==$a[$i-1]+1){
    $ans+=$c[$a[$i-1]-1];
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4728
#include<stdio.h>
#include<math.h>
 
int main(void)
{
    int n;
    int i;
    int x[100];
    int y[100];
    int z[100];
    double L_1 = 0, L_2 = 0, L_3 = 0, L_inf;
     
    scanf("%d\n", &n);
    for(i = 0; i<n; i++)
        scanf("%d", &x[i]);
    for(i = 0; i<n; i++)
        scanf("%d", &y[i]);
    for(i = 0; i<n; i++) {
        z[i] = (x[i] - y[i]>0)? x[i] - y[i]: y[i] - x[i];
        if(i == 0) L_inf = z[0];
        else {
            if(z[i] > L_inf) L_inf = z[i];
        }
    }
     
    for(i=0; i<n; i++) {
        L_1 += z[i];
        L_2 += z[i] * z[i];
        L_3 += z[i] * z[i] * z[i];
    }
     
    L_2=pow(L_2, 1.0/2);
    L_3=pow(L_3, 1.0/3);
     
    printf("%f\n%f\n%f\n%f\n", L_1, L_2, L_3, L_inf);
     
    return 0;
}


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

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

    int a, b;
    if (A * 100 % 8 == 0) {
        a = A * 100 / 8;
    }
    else {
        a = A * 100 / 8 + 1;
    }
    b = B * 10;
    int ans = max(a, b);

    if (ans * 8 / 100 == A && ans * 10 / 100 == B) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
N, L = [int(n) for n in input().split()]
ans = [L+i-1 for i in range(1,N+1)]
if 0 in ans:
    print(sum(ans))
elif L < 0 and N <= abs(L):
    print(sum(ans)-max(ans))
else:
    print(sum(ans)-min([abs(n) for n in ans]))


Measured memory_bytes: 3060
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()
c0, c1, c2, c3 = 0,0,0,0
for i in range(N):
    s = S()
    if s == "AC":
        c0 += 1
    elif s == "WA":
        c1 += 1
    elif s == "TLE":
        c2 += 1
    elif s == "RE":
        c3 += 1

print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))

Measured memory_bytes: 27248
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        
        int n = int.Parse(Console.ReadLine());
        int[] seq = new int[n];
        
        for(int i=0; i<n; i++){
            seq[i] = int.Parse(Console.ReadLine());
        }
        
        int[] sortSeq = new int[n];
        Array.Copy(seq, sortSeq, n);
        Array.Sort(sortSeq);
        
        if(sortSeq[n-1] == sortSeq[n-2]){
            for(int k=0; k<n; k++) Console.WriteLine(sortSeq[n-1]);
        }
        else{
            int index1st = Array.IndexOf(seq, sortSeq[n-1]);
            for(int l=0; l<n; l++){
                if(l==index1st) Console.WriteLine(sortSeq[n-2]);
                else Console.WriteLine(sortSeq[n-1]);
            }
        }
    }
}

Measured memory_bytes: 18132
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int n;
	int i;
	
	while (scanf("%d", &n) != EOF){
		
		i = 0;
		for (a = 0; a < 10; a++){
			for (b = 0; b < 10; b++){
				for (c = 0; c < 10; c++){
					for (d = 0; d < 10; d++){
						if (a + b + c + d == n){
							i++;
						}
					}
				}
			}
		}
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int calc(vector<int> X, int N)
{
	vector<int> v(N);
	iota(v.begin(), v.end(), 1);

	int count = 0;
	do {
		count++;

		if (v == X) return count;

	} while (next_permutation(v.begin(), v.end()));     // 次の順列を生成

	return 0;
}

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

	vector<int> P(N, 0);
	rep(i, N)
	{
		cin >> P[i];
	}

	vector<int> Q(N, 0);
	rep(i, N)
	{
		cin >> Q[i];
	}

	cout << abs(calc(Q, N) - calc(P, N)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(){
  int n,i;
  double a[MAX],sum;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&a[i]);
  }
  
  sum=0;
  for(i=0;i<n;i++){
    sum += 1/a[i];
  }
  
  printf("%lf", 1/sum);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

        int count = 0;
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            //0:??? 1:?????? 2:??? 3:??????
            int x = 0;
            int y = 0;
            int s = 0;
            int[][] list = new int[n][n];
            for (int i = 0; i < n * n; i++) {
                list[y][x] = i + 1;
                switch (s) {
                case 1:
                    x--;
                case 2:
                    y++;
                    break;
                case 3:
                    y--;
                case 0:
                    x++;
                    break;
                }
                if (y == 0 && x != n - 1 && s == 3 || y == n - 1 && s == 1) {
                    s = 0;
                } else if (y == 0 && s == 0 || x == n - 1 && s == 2) {
                    s = 1;
                } else if (x == 0 && y != n - 1 && s == 1 || x == n - 1 && s == 3) {
                    s = 2;
                } else if (x == 0 && s == 2 || y == n - 1 && s == 0) {
                    s = 3;
                }
            }
            count++;
            System.out.println("Case " + count + ":");
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    System.out.printf("%3d", list[i][j]);
                }
                System.out.println();
            }

        }
    }
}

Measured memory_bytes: 26236
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) {
    cout << "Yes" << endl;
  } else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;



int main()
{
	int N,C,K;
	cin>>N>>C>>K;
	int ans = 0;
	int deadLine = 0;
	int count = 0;
	int *T = new int[N];
	for(int i = 0; i < N; i++){
		cin>>T[i];
	}
	sort(T,T+N);
	for(int i = 0; i < N; i++){
		if(count == 0){
			deadLine = T[i] + K;
			count++;
			ans++;
		}else if(count == C){
			deadLine = T[i] + K;
			count = 1;
			ans++;
		}else if( T[i] > deadLine){
			deadLine = T[i] + K;
			count = 1;
			ans++;
		}else{
			count++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()

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

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(void){
    ll A, B;
    cin >> A >> B;
    ll gcd=__gcd(A, B);
    auto p=prime_factor(gcd);
    int cnt=1+p.size();
    cout << cnt << endl;
    return 0;
}


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

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

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 62)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll sz = 2e5 + 10;
ll ara[sz];

int main()
{
    ll n;
    cin >> n;
    for1(i, n) sl(ara[i]);

    sort(ara+1, ara+n+1, greater<ll>());

    ll ans = ara[1], ptr = 3;
    for(ll i = 2; i <= n && ptr <= n; i++) {
        ans += ara[i];
        ptr++;

        if(ptr <= n) {
            ans += ara[i];
            ptr++;
        }
    }

    cout << ans << EL;

    return 0;
}


Measured memory_bytes: 5324
sd = input()
t = input()

def compaierStr(expected: list, actual: list) -> bool:
    for e, a in zip(expected, actual):
        if e != a and a != "?":
            return False

    return True

candidates = []
for i in range(len(sd)-len(t)+1):
    if compaierStr(t, sd[i:i+len(t)]):
        candidates.append((sd[:i] + t + sd[i+len(t):]).replace("?", "a"))

if len(candidates) == 0:
    print("UNRESTORABLE")
else:
    ans = "z"*(len(sd))
    for _c in candidates:
        if _c < ans:
            ans = _c

    print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
    int i,ans=0;
    int data[5];
    for(i=0;i<5;i++){
        scanf("%d",&data[i]);
        if(data[i]<40){
            data[i]=40;
        }
        ans+=data[i];
    }
    ans = ans/5;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 600
s=require('fs').readFileSync('/dev/stdin','utf8').split(' ').map(n=>n|0)
c=0;for(i=0;++i<=s[0];s[1]<=a&&a<=s[2]&&(c+=i))
	a=(i+'').split('').map(n=>n|0).reduce((a,b)=>a+b)
console.log(c)

Measured memory_bytes: 10984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int r = 0;
  int l, rN, lN;
  bool flag = true;
  vector<int> rec(N);
  for(int i = 0; i < N; ++i){
    if(!flag && S[i] == 'R'){
      flag = true;
      rN = l - r;
      lN = i - l;
      r = i;
      rec[l-1] = (rN+1)/2 + lN/2;
      rec[l] = rN/2 + (lN+1)/2;
    }else if(flag && S[i] == 'L'){
      flag = false;
      l = i;
    }
  }
  rN = l - r;
  lN = N - l;
  rec[l-1] = (rN+1)/2 + lN/2;
  rec[l] = rN/2 + (lN+1)/2;
  for(int i = 0; i < N; ++i){
    if(i) cout << " ";
    cout << rec[i];
  }
  cout << endl;
}


Measured memory_bytes: 1024
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    G=[[] for _ in range(n+1)]
    for i in range(m):
        a,b=map(int,readline().split())
        G[a].append(b)
        G[b].append(a)

    ans=[0]*(n+1)
    flags=[False]*(n+1)
    flags[1]=True
    d=deque([1])
    while len(d)>0:
        now=d.popleft()
        v=now
        for u in G[v]:
            if flags[u]==False:
                flags[u]=True
                ans[u]=v
                d.append(u)

    print("Yes")
    for i in range(2,n+1):
        print(ans[i])
        
if __name__=="__main__":
    main()


Measured memory_bytes: 34928
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextLine

  val x = N.foldLeft(0L)((z, x) => z + x.toString.toLong)
  val z = if (x % 9 == 0) "Yes" else "No"

  println(z)
}


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

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int score=0;
  rep(i,n-1){
    if(s[i]==s[i+1])score++;
  }
  int ans;
  ans = min(score+2*k,n-1);
  cout << ans << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
 
int main() {
  int N;
  cin >> N;

  vector<pair<pair<string,int>,int>> rest(N);
  REP(i, N){
    string S;
    int a;

    cin >> S >> a;
    a = -1 * a;

    rest.at(i).first.first = S;
    rest.at(i).first.second = a;
    rest.at(i).second = i + 1;
  }

  sort(rest.begin(), rest.end());

  REP(i, N)
  cout << rest.at(i).second << endl;

}

Measured memory_bytes: 256
#include<cstdio>
int main() {
	int n, y, a, b;
	scanf("%d%d", &n, &y);
	for (a = 0; a * 10000 <= y; a++) {
		for (b = 0; a * 10000 + b * 5000 <= y; b++) {
			if (a * 10000 + b * 5000 + (n - a - b) * 1000 == y) {
				printf("%d %d %d", a, b, n - a - b);
				return 0;
			}
		}
	}
	printf("-1 -1 -1");
	return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     ((a*b)/__gcd(a,b))
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	string s;
	cin>>s;
	n=s.length();
	rep(i,0,n){
		if(s[i]!=s[n-1-i]) ans++,s[i]=s[n-1-i];
	}	
	ret(ans)
	return 0;
}

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

int main(){
  int N, M;
  while(cin >> N >> M, N){
    vector<int> X(N), Y(M);
    for(int i = 0; i < N; ++i){
      cin >> X[i];
    }
    for(int i = 0; i < M; ++i){
      cin >> Y[i];
    }
    int x = 1;
    for(int i = 0; i < M; ++i){
      x += Y[i];
      x += X[x-1];
      if(x >= N){
        cout << i+1 << endl;
        break;
      }
    }
  }
}



Measured memory_bytes: 3068
main(){
	int n,A,B,a,b;
	for(;scanf("%d",&n),n;){
		A=B=0;
		for(;n--;){
			scanf("%d%d",&a,&b);
			if(a>b)
				A+=a+b;
			else if(a<b)
				B+=a+b;
			else
				A+=a,B+=b;
		}
		printf("%d %d\n",A,B);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll a[100010];
ll b[100010];
int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    ll tmp = 0;
    rep(i, n){
        tmp += a[i];
        b[i+1] = tmp;
    }
    map<ll, ll> mp;

    rep(i, n+1){
        mp[b[i]%m]++;
    }
    ll ans = 0;
    for(auto v : mp){
        ll num = v.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {


    int h,w;
    cin>>h>>w;
    int masu[h][w];
    rep(i,h){
        rep(j,w){
            cin>>masu[i][j];
        }
    }

    vector<P> a1;
    vector<P> a2;


    for(int i=0;i<w;i++){

        if(i%2==0) {
            for (int j = 0; j < h-1 ; j++) {
                if (masu[j][i] % 2) {
                    masu[j][i]--;
                    masu[j + 1][i] += 1;
                    a1.push_back({j, i});
                    a2.push_back({j+1,i});
                }
            }
            if(i+1<w){
                if(masu[h-1][i]%2==1){
                    masu[h-1][i]--;
                    masu[h-1][i+1] += 1;
                    //cout<<i+1<<" "<<h-1<<endl;
                    a1.push_back({h-1,i});
                    a2.push_back({h-1,i+1});
                }
            }
        }else{

            for(int j=h-1;j>=1;j--){

                if(masu[j][i]%2){
                    masu[j][i]--;
                    masu[j-1][i]+=1;
                    a1.push_back({j,i});
                    a2.push_back({j-1,i});
                }
            }

            if(i+1<w){
                if(masu[0][i]%2==1){
                    masu[0][i]--;
                    masu[0][i+1] += 1;
                    a1.push_back({0,i});
                    a2.push_back({0,i+1});
                }
            }

        }

//        rep(i,h){
//            rep(k,w){
//                cout<<masu[i][k]<<endl;
//
//            }
//        }

    }
    ll ans=0;
    cout<<a1.size()<<endl;
    rep(i,a1.size()){
        cout<<a1[i].first+1<<" "<<a1[i].second+1<<" "<<a2[i].first+1<<" "<<a2[i].second+1<<endl;
    }



    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i, n, 1000){
		int m=i, x[3];
		REP(j, 3){
			x[j]=m%10;
			m/=10;
		}
		if(x[0]==x[1] && x[1]==x[2]){
			cout<<i<<'\n';
			return 0;
		}
	}
	return 0;
}


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

int main() {
  int n,d;
  cin >> n >> d;
  int num=0, ans=0;
  for (int i; i<n; i++) {
    num+=2*d+1;
    ans++;
    if (num>=n) {
      break;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
//code by PARTH_4399 for competitive programming
#include<bits/stdc++.h>
using namespace std;
#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
//const double pi=acos(-1.0); // cout<<fixed<<setprecision(n)<<pi; - for n decimal digits, use <iomanip.h>
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code
  	ll int n,a,b;
  	cin>>n>>a>>b;
  	if(n*a<b)
      cout<<n*a;
  	else
      cout<<b;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	{
	  x = x->right;
	}
    }
  z->parent = y;
  if(y == NIL)
    {
      root = z;
    }
  else
    {
      if(z->key < y->key)
	{
	  y->left = z;
	}
      else
	{
	  y->right = z;
	}
    }
}

void inorder(Node u){
  if(u != NIL)
    {
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }
}
void preorder(Node u){
  if(u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }
  }
  return 0;
}



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

long long N, M;
vector<long long> ppp;
vector<long long> ppn;
vector<long long> pnn;
vector<long long> nnn;
vector<long long> nnp;
vector<long long> npp;
vector<long long> npn;
vector<long long> pnp;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		long long x,y,z;
		cin >> x >> y >> z;
		ppp.push_back(x+y+z);
		ppn.push_back(x+y-z);
		pnn.push_back(x-y-z);
		nnn.push_back(-x-y-z);
		nnp.push_back(-x-y+z);
		npp.push_back(-x+y+z);
		npn.push_back(-x+y-z);
		pnp.push_back(x-y+z);
	}

	sort(ppp.begin(), ppp.end(), greater<long long>());
	sort(ppn.begin(), ppn.end(), greater<long long>());
	sort(pnn.begin(), pnn.end(), greater<long long>());
	sort(nnn.begin(), nnn.end(), greater<long long>());
	sort(nnp.begin(), nnp.end(), greater<long long>());
	sort(npp.begin(), npp.end(), greater<long long>());
	sort(npn.begin(), npn.end(), greater<long long>());
	sort(pnp.begin(), pnp.end(), greater<long long>());

	long long pppret = 0;
	long long ppnret = 0;
	long long pnnret = 0;
	long long nnnret = 0;
	long long nnpret = 0;
	long long nppret = 0;
	long long npnret = 0;	
	long long pnpret = 0;
	for(long long i = 0; i < M; i++){
		pppret += ppp[i];
		ppnret += ppn[i];
		pnnret += pnn[i];
		nnnret += nnn[i];
		nnpret += nnp[i];
		nppret += npp[i];
		npnret += npn[i];
		pnpret += pnp[i];
	}

	long long ret = 0;
	ret = max(ret, pppret);
	ret = max(ret, ppnret);
	ret = max(ret, pnnret);
	ret = max(ret, nnnret);
	ret = max(ret, nnpret);
	ret = max(ret, nppret);
	ret = max(ret, npnret);
	ret = max(ret, pnpret);

	cout << ret << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


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

    int n = s.size();
    for (int i=0; i<n; i++) {
        if (s[i]!='a' && (26-(s[i]-'a')) <= k) {
            k -= (26-(int)(s[i]-'a'));
            s[i] = 'a';
        }
    }
    s.back() = 'a' + ((int)(s.back() - 'a') + k)%26;

    cout << s << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n+1];
  for(int i=1; i<=n; i++)
    cin >> a[i];
  for(int i=k+1; i<=n; i++){
    if(a[i]>a[i-k])
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    string S;
    cin >> S;
    int N = S.size();
    int A[N+1]{}, B[N+1]{}, C[N+1]{}, ans{};
    C[0] = 1;
    rep(i,N){
        if(S[i] == '?'){
            C[i+1] = C[i] * 3;
            A[i+1] = A[i] * 3 + C[i];
            B[i+1] = B[i] * 3 + A[i];
            ans = ans * 3 + B[i];
        }
        else{
            C[i+1] = C[i];
            if(S[i] == 'A'){
                A[i+1] = A[i] + C[i];
                B[i+1] = B[i];
            }
            else if(S[i] == 'B'){
                A[i+1] = A[i];
                B[i+1] = B[i] + A[i];
            }
            else if(S[i] == 'C'){
                A[i+1] = A[i];
                B[i+1] = B[i];
                ans += B[i];
            }
        }
        A[i+1] %= MOD;
        B[i+1] %= MOD;
        ans %= MOD;
        C[i+1] %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;

const int N = 100010;

char s[N];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i - 1]) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int A;
    cin >> A ;
    if(A<10) cout << A <<endl;
    else if(A<100) cout << 9 <<endl;
    else if(A<1000) cout << 9+A-99 <<endl;
    else if(A<10000) cout << 909 <<endl;
    else if(A<100000) cout << 909+A-9999 <<endl;
    else  cout << 90909 <<endl;

}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_Volume20_2013
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) break;

                List<data> dts = new List<data>();

                for (int i = 0; i < n; i++)
                {
                    var s = Console.ReadLine().Split();

                    DateTime dt1 = DateTime.ParseExact(s[0], "HH:mm:ss", null);
                    DateTime dt2 = DateTime.ParseExact(s[1], "HH:mm:ss", null);
                    dts.Add(new data() { time = dt1, div = 1 });
                    dts.Add(new data() { time = dt2, div = -1 });
                }

                dts = dts.OrderBy(x => x.time).ThenBy(y => y.div).ToList();

                int[] comb = new int[2 * n + 1];
                comb[0] = 0;

                int ans = 0;
                for (int i = 0; i < 2 * n; i++)
                {
                    comb[i + 1] = dts[i].div + comb[i];
                    ans = Math.Max(ans, comb[i + 1]);
                }

                Console.WriteLine(ans);
            }
            Console.ReadKey();
        }

        struct data
        {
            public DateTime time;
            public int div;
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 39244
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// Time Manipulation
// 2012/12/04
public class Main{
	Scanner sc=new Scanner(System.in);

	void run(){
		for(;;){
			long n=sc.nextLong();
			int m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			long[] p=new long[m];
			for(int i=0; i<m; i++){
				p[i]=sc.nextLong();
			}
			long sum=0;
			long num=0;
			for(int i=1; i<1<<m; i++){
				int bit=Integer.bitCount(i);
				long lcm=1;
				for(int k=0; k<m; k++){
					if((i>>k&1)==1){
						lcm=lcm/gcd(lcm, p[k])*p[k];
						if(lcm>n){
							break;
						}
					}
				}
				if(bit%2==0){
					num-=n/lcm;
					sum-=lcm*(n/lcm+1)*(n/lcm)/2;
				}else{
					num+=n/lcm;
					sum+=lcm*(n/lcm+1)*(n/lcm)/2;
				}
			}
			long a=n*(n+1)/2-sum;
			long b=n-num;
			if(b==0){
				println("0");
			}else{
				println(String.format("%.10f", (double)a/b));
			}
		}
	}

	long gcd(long m, long n){
		return m==0?n:gcd(n%m, m);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = 0, W = 0;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();

			if (H == 0 && W == 0) {
				break;
			}

			for (int h = 0; h < H; h++) {
				for (int w = 0; w < W; w++) {
					if (h % 2 == 0) {
						if (w % 2 == 0) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} else {
						if (w % 2 == 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}


Measured memory_bytes: 34600
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;
const ll MOD = 1000000007;

int main(void){
    int N; cin >> N;
    ll ans = 1;
    for(int i = 1; i <= N; i++){
        ans = (ans * i) % MOD;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int count = 0;
  rep(i,k) count += a.at(i);
  cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	int a[110];
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, n) {
		for (int j = 0; j < d; ++j) {
			int xx = j * a[i] + 1;
			if (xx > d) {
				break;
			}
			ans++;
		}
	}
	ans += x;
	cout << ans << endl;
}


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

double s[100000];

int main()
{
	int n,m,j,k,i,t,ans,T,a,b;
	cin>>n;
	cin>>a>>b;		
	for (i=0;i<n;i++)
	{
		cin>>s[i];
		s[i]  = a - 0.006*s[i];
	}
	double min = 1000000000.0;
	for (i=0;i<n;i++)
	{
		if (fabs(s[i] - b)<= min)
		{
			min = fabs(s[i]-b);
			ans = i; 
		}
	}
	cout<<ans+1<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, X; cin >> N >> X; 
	int S[210] = {}; 
	for(int i = 0; i < N; i++) cin >> S[i]; 
	sort(S, S+N); 
	long long P = 1000000007; 
	long long dp[205][100010] = {}; 
	dp[0][X] = 1; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= X; j++){
			if(dp[i][j] == 0) continue; 
			for(int k = 0; k < N; k++){
				if(j < S[k]){
					dp[i+1][j] += dp[i][j] * (N - k - i); 
					if(dp[i+1][j] >= P) dp[i+1][j] %= P; break; 
				}
				dp[i+1][j % S[k]] += dp[i][j]; 
				dp[i+1][j % S[k]] %= P; 
			}
		}
	}
	long long ans = 0; 
	for(int i = 1; i <= X; i++){
		ans += dp[N][i] * i % P; 
		ans %= P; 
	}
	cout << ans << endl; 
}

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

int main(){
  int x,y,z;
  int n;
  cin>>n;
   for(int i=1;i<=n;i++){
     int counter=0;
     
     for (x=1;x<=50;x++){
       for(y=x;y<100;y++){
         for(z=y;z<100;z++){
           if(i==x*x+y*y+z*z+x*y+y*z+z*x && x==y && y==z) counter=counter+1;
           else if(i==x*x+y*y+z*z+x*y+y*z+z*x && x==y && y!=z) counter=counter+3;
           else if(i==x*x+y*y+z*z+x*y+y*z+z*x && x!=y && y==z) counter=counter+3;
           else if(i==x*x+y*y+z*z+x*y+y*z+z*x ) counter=counter+6;
           
         }
       }
     }
      cout<<counter<<endl;
   }
}


Measured memory_bytes: 3552
#include <iostream>
#include <vector>

using namespace std;

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

    size_t sum = 0;
    for(size_t i = 1; i <= N; ++i)
    {
        for(size_t j = i; j <= N; j += i)
        {
            sum += j;    
        }
    }

    cout << sum << endl;

    return 0;    
}

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

int main() {
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(dp[i-1]+abs(h[i]-h[i-1])),abs(dp[i-2]+abs(h[i]-h[i-2])));
	}
	cout<<dp[n-1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[100001];
  for (int i = 0; i < n; i++) cin >> a[i];
  int divideCount = 1;
  bool incre = false, decre = false;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      continue;
    } else if (a[i] > a[i + 1]) {  //単調非増加
      decre = true;
    } else if (a[i] < a[i + 1]) {  //単調非減少
      incre = true;
    }
    if (decre && incre) {
      decre = false;
      incre = false;
      divideCount++;
      continue;
    }
  }
  cout << divideCount << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main(void){
  int i,j,n,odd=0,even=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    if(i%2==0) even++;
    else odd++;
  }
  printf("%d",even*odd);
  return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		_memo = new Dictionary<int, double>();
		var s = Input();
		var n = s[0].ToInt();
		var k = s[1].ToInt();
		var p = Input().ToInt();
		
		double cura = 0;
		for(int i = 0; i < k-1; i++)
		{
			var r = GetRate(p[i]);
			cura += r;
		}
		
		double maxr = 0;
		for(int i = k-1; i < n; i++)
		{
			var r = GetRate(p[i]);
			cura += r;
			maxr = (double)Math.Max(maxr, cura);
			cura -= (double)GetRate(p[i-(k-1)]);
		}
		Console.WriteLine(maxr);
		
	}
	private static Dictionary<int, double> _memo;
	
	private static double GetRate(int v)
	{
		if(_memo.ContainsKey(v))
			return _memo[v];
		long wa = 0;
		for(int i = 1; i <= v; i++)
		{
			wa += i;
		}
		var p = (double)wa / v;
		_memo.Add(v, p);
		return p;
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 29020
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int a[2 * MaxN + 5],s[2 * MaxN + 5];

int main()
{
	int c,b,x,n,m;
	while(~scanf("%d",&n))
	{
		for(int i = 1;i <= n;i++)
		{
			scanf("%d",&s[i]);
			a[i] = s[i];
		}
		sort(s + 1,s + 1 + n);
		c = s[n / 2];
		b = s[n / 2 + 1];
		for(int i = 1;i <= n;i++)
		{
			if(a[i] <= c) printf("%d\n",b);
			else printf("%d\n",c);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    rep(i,h){
        rep(j,w){
            char t;cin>>t;
            if(t=='#')  dp[i][j]=-1;
        }
    }
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(i==0&&j==0)  continue;
            if(dp[i][j]<0)  continue;
            if(i)   dp[i][j]=(dp[i][j]+max(0ll,dp[i-1][j]))%mod;        
            if(j)   dp[i][j]=(dp[i][j]+max(0ll,dp[i][j-1]))%mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}


Measured memory_bytes: 8064
'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  if(input[1]===1){
    console.log(0);
    return;
  }else{
    console.log(input[0]-input[1]);
  }
})(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7500
#ABC-134-C
N = int(input())
A = {}
for i in range(N):
    A[i] = int(input())

value_sorted = sorted(A.items(), key=lambda x:x[1])
max_value = 0

for i in range(N):
    max_value_tapple = value_sorted[-1]
    if max_value_tapple[0] == i:
        max_value_tapple = value_sorted[-2]
        max_value = max_value_tapple[1]
    else:
        max_value = max_value_tapple[1]
    print(max_value)

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

int pop(void);
void push(int);

int S[200],top = 0;

int main(){
  int x,a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x){
  top++;
  S[top] = x;
}

int pop(void){
  top--;
  return S[top+1];
}



Measured memory_bytes: 2108
function main (input) {
  const a = parseInt(input.split(' ')[0],10);
  const b = parseInt(input.split(' ')[1],10);

  ptnAdd = a + b;
  ptnSub = a - b;
  ptnMul = a * b;

  ans = Math.max.apply(null,[ptnAdd,ptnSub,ptnMul]);
  if (ans === -0) {
    ans = 0;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <string>
#include <memory.h>
#include <bitset>
#include <stack>
#include <assert.h>
using namespace std;
#define ll  long long
#define ld long double
#define ppi pair<int, int>
#define mp make_pair	
const int mod = 1e9 + 7;
const int N = 2e5 + 111, N2 = 1e2 + 11;
ll dp[N2][N], cum[N];
int arr[N2];
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("inp.txt", "r", stdin);
#endif
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	dp[n][0] = 1;
	for (int i = 0; i <= k; i++)
		cum[i + 1] = 1;
	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = 0; j <= k; j++)
			dp[i][j] = (cum[j + 1] - cum[max(j - arr[i], 0)] + mod) % mod;
		for (int j = 0; j <= k; j++)
			cum[j + 1] = (cum[j] + dp[i][j]) % mod;
	}
	cout << dp[0][k];
}


Measured memory_bytes: 159232
N,X=map(int,input().split())
S=list(map(int,input().split()))
S.sort()
mod=10**9+7
dp=[[0 for i in range(10**5+1)] for j in range(N)]

for i in range(10**5+1):
    dp[0][i]=i%S[0]

for i in range(1,N):
    for j in range(10**5+1):
        dp[i][j]=(i*dp[i-1][j]+dp[i-1][j%S[i]])%mod

print(dp[N-1][X])

Measured memory_bytes: 282100
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;

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

typedef long long ll;

int main() {
	//入力;
	int N;
	ll K;
	cin >> N >> K;

	FOR(x, 0, N + 1) {
		FOR(y, 0, N + 1) {
			int z = (K - x * 10000 - y * 5000) / 1000;
			if (z==N-x-y&&z>=0&&z<=N){
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	
	cout << "-1 -1 -1" << endl;
	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256