akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, h[100000], dp[100000];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> h[i];
    int cost = 0;
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << '\n';
    return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			long n = int.Parse(Console.ReadLine());
			string answer = "No";
			List<string> list = new List<string>();

			for (var i = 0; i < n; ++i) {
				list.Add(Console.ReadLine());
			}

			for (var i = 0; i < n; ++i) {
				if (i > 0 && list[i - 1][list[i - 1].Length - 1] != list[i][0]) {
					Console.WriteLine("No");
					Console.ReadLine();
					return;
				}

				for (var j = 0; j < i; ++j) {
					if (list[j] == list[i]) {
						Console.WriteLine("No");
						Console.ReadLine();
						return;
					}
				}

				if (i == n - 1) {
					answer = "Yes";
					Console.WriteLine($"{answer}");
				}
			}

			Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13140
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod

n,k=map(int,input().split())
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,n+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

L=[]
ans=0
for i in range(1,k+1):
  L.append(pow(k//i,n,mod))
for i in range(k,0,-1):
  x=L[i-1]
  for j in range(1,k//i):
    x-=L[i*(j+1)-1]
    x+=mod
    x%=mod
  L[i-1]=x
  ans+=x*i
  ans%=mod
print(ans)

Measured memory_bytes: 93024
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;

int main() {
    string s;
    getline(cin, s);
    for(int i = 0; i < (int)s.length(); i++) {
        if(isalpha(s[i])) {
            if(isupper(s[i])) s[i] = tolower(s[i]);
            else s[i] = toupper(s[i]);
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, x, y;
	cin>>n>>x>>y;
	vector<int> g[2020];
	for(int i=0; i<n-1; i++){
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	x--; y--;
	g[x].push_back(y);
	g[y].push_back(x);
	int d[2020][2020];
	const int INF=1e9+7;
	for(int i=0; i<n; i++){
		fill(d[i], d[i]+n, INF);
		d[i][i]=0;
		queue<int> que;
		que.push(i);
		while(!que.empty()){
			int x=que.front(); que.pop();
			for(auto y:g[x]){
				if(d[i][y]>d[i][x]+1){
					d[i][y]=d[i][x]+1;
					que.push(y);
				}
			}
		}
	}
	int ans[2020]={};
	for(int i=0; i<n; i++) for(int j=0; j<i; j++) ans[d[i][j]]++;
	for(int i=1; i<n; i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 16128
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[1000],t[1000];
    scanf("%s %s",s,t);
    int a = strlen(s), b = strlen(t);
    int cnt = 0, max = 0;
    for(int i = 0; i < a -b + 1; i++)
    {
        cnt = 0;
        for(int j = 0; j < b; j++)
        {
            if(s[i+j] == t[j])
            {
                cnt++;
            }
        }
        if(cnt > max)
        max = cnt;
    }
    printf("%d",b - max);
    return 0;
}

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

using namespace std;

using ll = long long;

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

    set<int> memo;
    int n, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (memo.count(a) == 0) memo.insert(a);
        else memo.erase(a);
    }

    cout << memo.size() << endl;

    return 0;
}


Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys, os
range = xrange

def main():
    inp = [int(x) for x in os.read(0, os.fstat(0).st_size).split()]
    n, m = inp[0],inp[1]

    wi, vi = inp[2], inp[3]


    dp = [0] * (m + 1)
    for j in range(wi, m + 1):
        dp[j] = vi

    for i in range(n - 1):
        wi = inp[2*i + 4]
        vi = inp[2*i + 5]
        for j in reversed(range(wi, m + 1)):
            dp[j] = max(vi + dp[j - wi], dp[j])

    print(dp[-1])
main()

Measured memory_bytes: 31724
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

const int MaxN = 100;
using namespace std;
char s[MaxN + 5];
int n ;
int main()
{
	while(~scanf("%d " , &n)){
		scanf("%s" , s + 1);
		int cont_1 = 0 , cont_2 = 0 , res_1 = 0 , res_2 = 0;
		for(int i = 1;i <= n;i++){
			if(s[i] == '(') cont_1++;
			else {
				if(cont_1 > 0) cont_1--;
				else res_1++;
			}
		}
		cont_1 = cont_2 = 0;
		for(int i = n;i >= 1;i--){
			if(s[i] == ')') cont_2++;
			else {
				if(cont_2 > 0) cont_2--;
				else res_2++;
			}
		}
		for(int i = 1;i <= res_1;i++) printf("(");
		printf("%s" , s + 1);
		for(int i = 1;i <= res_2;i++) printf(")");
		printf("\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int n;
#define rep(i,n) for(int i = 0;i <n;i++)
int main(){
	cin >> n; vector<double> p(n);
	rep(i, n) cin >> p[i];
	vector<vector<double>> dp(n+10, vector<double>(n+10, 0.0));
	dp[0][0] = 1.0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i + 1; j++) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}
	double ans = 0.0;
	for (int i = n / 2 + 1; i <= n; i++) {
		ans += dp[n][i];
	}cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 74292
using System;

namespace Volume0_0000_QQ
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j;

            for (i = 1; i <= 9; i++)
                for (j = 1; j <= 9; j++)
                    Console.WriteLine("{0}x{1}={2}",i,j, i*j);
        }
    }
}

Measured memory_bytes: 8892
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int l = 0, r = 0;
    int cnt = 0;
    bool flag = true;

    rep(i,n){
        if(h[i] > 0){ 
            flag = false;
            break;
        }
    }

    if(flag){
        cout << 0 << endl;
        return 0;
    }

    while(1){
        rep(i,n){
            if(h[i] > 0){ l = i;
                break;
            }
        }
        r = n-1;
        reps(i,l+1,n){
            if(h[i] == 0){ 
                r = i-1;
                break;
            }
        }
        reps(i,l,r+1){
            h[i]--;
        }
        cnt++;

        flag = true;
        rep(i,n){
            if(h[i] > 0) flag = false;
        }
        if(flag) break;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  ll cnt=0,ans=100000000000;
  ll sum2=0;
  rep(i,n){
    cnt=0;
    sum2+=a[i];
    cnt=abs(sum2-(sum-sum2));
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int t=0,i=0;
    while(1){
        if(i%2==0){
            c-=b;
            if(c<=0){
                t=1;
                break;
            }
        }else{
            a-=d;
            if(a<=0){
                t=0;
                break;
            }
        }
        i++;
    }
    if(t) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
long long cnt1[MaxN + 5],cnt2[MaxN + 5],a[MaxN + 5],b[MaxN + 5],c[MaxN + 5],n;

long long cmp1(long long x, long long  y){
	return x < y;
}
long long cmp(long long x, long long y){
	return x > y;
}

int main()
{
	scanf("%lld",&n);
	for(int i = 1; i <= n; i++)
		scanf("%lld",&a[i]);
	for(int i = 1; i <= n; i++)
		scanf("%lld",&b[i]);
	for(int i = 1; i <= n; i++)
		scanf("%lld",&c[i]);
	sort(a + 1, a + n + 1,cmp1);
	sort(b + 1, b + n + 1,cmp1);
	sort(c + 1, c + n + 1, cmp);
	long long p = 1;
	int ok = 1;
	for(int i = 1; i <= n; i++){
		if(p == n + 1){ 
			cnt1[i] = p - 1;
			continue;
		}
		ok = 1;
		while(ok && p <= n){
			if(a[p] < b[i]) p++;
			else ok = 0; 
		}
		cnt1[i] = p - 1;
	}
	p = 1, ok = 1;
	for(int i = n; i >= 1; i--){
		if(p == n + 1){
			cnt2[i] = p - 1;
			continue;
		}
		ok = 1;
		while(ok && p <= n){
			if(c[p] > b[i]) p++;
			else ok = 0;
		}
		cnt2[i] = p - 1;
	}	
	long long sum = 0;
	for(int i = 1; i <= n; i++){
		sum += cnt1[i] * cnt2[i];
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 4096
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    boolean[] arr = new boolean[n];
    for(int i=0;i<k;i++){
      int d = sc.nextInt();
      for(int i2=0;i2<d;i2++){
        int s = sc.nextInt();
        arr[s-1]=true;
      }
    }
    int count=0;
    for(int i1=0;i1<n;i1++){
      if(arr[i1]==false){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 46336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int A[] = new int[N];
		
		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			int num = i+1;
			A[a-1] = num;
		}
		
		StringBuilder s = new StringBuilder();
		for(int a:A) {
			s.append(a);
			s.append(" ");
		}
		System.out.println(s.toString().trim());
		
		sc.close();	
	}
}

Measured memory_bytes: 50756
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
es=[[] for i in range(n)]
l=[list(map(int,input().split())) for i in range(n-1)]
for i in range(n-1):
   l[i][0]-=1
   l[i][1]-=1
   es[l[i][0]].append(l[i][1])
   es[l[i][1]].append(l[i][0])
dic={}
use=[1]*n
def dfs(v,k):
    cnt=0
    use[v]=0
    for i in es[v]:
        if use[i]:
            if cnt==k:
                cnt+=1
            dic[(min(v,i),max(v,i))]=cnt
            dfs(i,cnt)
            cnt+=1
dfs(0,-1)
ans=[0]*(n-1)
k=0
for i in range(n-1):
    ans[i]=dic[l[i][0],l[i][1]]+1
    k=max(k,ans[i])
print(k)
for i in ans:
    print(i)

Measured memory_bytes: 81392
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint
from copy import deepcopy


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


n = I()
L = []
for i in range(n):
    l, r = LI()
    L += [(l, r, i)]

A = sorted(L, reverse=True)
B = sorted(L, key=lambda x:x[1])
used = [0] * n
now = 0
b_idx = 0
a_idx = 0
ans = 0
for i in range(n):
    if i % 2:
        while True:
            li, ri, idx = A[a_idx]
            if used[idx]:
                a_idx += 1
            else:
                used[idx] = 1
                break
        if li <= now <= ri:
            continue
        elif ri < now:
            ans += now - ri
            now = ri
        else:
            ans += li - now
            now = li
    else:
        while True:
            li, ri, idx = B[b_idx]
            if used[idx]:
                b_idx += 1
            else:
                used[idx] = 1
                break
        if li <= now <= ri:
            continue
        elif now < li:
            ans += li - now
            now = li
        else:
            ans += now - ri
            now = ri
ans += abs(now)
used = [0] * n
now = 0
ans1 = ans
b_idx = 0
a_idx = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        while True:
            li, ri, idx = A[a_idx]
            if used[idx]:
                a_idx += 1
            else:
                used[idx] = 1
                break
        if li <= now <= ri:
            continue
        elif ri < now:
            ans2 += now - ri
            now = ri
        else:
            ans2 += li - now
            now = li
    else:
        while True:
            li, ri, idx = B[b_idx]
            if used[idx]:
                b_idx += 1
            else:
                used[idx] = 1
                break
        if li <= now <= ri:
            continue
        elif now < li:
            ans2 += li - now
            now = li
        else:
            ans2 += now - ri
            now = ri
ans2 += abs(now)

print(max(ans1, ans2))








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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

#define MAX_V 10000

struct edge{int to;long long cap,rev;};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from,int to,long long cap){
	G[from].push_back((edge){to,cap,(ll)G[to].size()});
	G[to].push_back((edge){from,0,(ll)G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty())	{
		int v = que.front();que.pop();
		for(int i = 0;i < G[v].size();++i){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v ,int t,long long f){
	if(v == t)return f;
	for(int &i = iter[v];i < G[v].size() ;++i){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			long long d = dfs(e.to,t,min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

long long Dinic(int s,int t){
	long long flow = 0;
	while(1){
		bfs(s);
		if(level[t] < 0)return flow;
		memset(iter,0,sizeof(iter));
		long long f;while((f = dfs(s,t,INF)) > 0)flow += f;
	}
}

ll h, w, x;
ll mp[55][55];

int main(){

	cin >> h >> w >> x;
	ll ans = 0;
	REP(i, h){
		REP(j, w){
			cin >> mp[i][j];
			if(i > 0 && i < h - 1 && j > 0 && j < w - 1)ans += 2 * mp[i][j];
			else ans += mp[i][j];
		}
	}

	REP(i, h-1){
		REP(j, w-1){
			ll now = i * 50 + j;
			ll tmp;
			ll seica = mp[i][j] + mp[i+1][j] + mp[i][j+1] + mp[i+1][j+1];
			if(i % 2 == 0 && j % 2 == 0){
			//	cout << i << " " << j << endl;
				add_edge(2700, now, seica);
				add_edge(now, 2701, x);
			}
			if(i % 2 == 1 && j % 2 == 1){
			//	cout << i << " " << j << endl;
				add_edge(2700, now, x);
				add_edge(now, 2701, seica);
				tmp = (i-1) * 50 + (j-1);
				add_edge(tmp, now, mp[i][j]);
				tmp = (i+1) * 50 + (j-1);
				add_edge(tmp, now, mp[i+1][j]);
				tmp = (i-1) * 50 + (j+1);
				add_edge(tmp, now, mp[i][j+1]);
				tmp = (i+1) * 50 + (j+1);
				add_edge(tmp, now, mp[i+1][j+1]);
			}
		}
	}

	cout << ans - Dinic(2700, 2701) << endl;
	return 0;
}



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

int main(){
	int m,f,r;
	char str[] = "";
	int i;

	while(1){
		scanf("%d %d %d", &m, &f, &r);
		if(m==-1 && f==-1 && r==-1)
			break;
		if(m==-1 || f==-1 || (m+f)<30)
			printf("F\n");
		else{
			if(m+f >= 80)
				printf("A\n");
			else if(m+f >= 65)
				printf("B\n");
			else if(m+f >= 50)
				printf("C\n");
			else if(m+f >= 30){
				if(r>=50)
					printf("C\n");
				else
					printf("D\n");
			}
		}


	}

	return 0;
}

Measured memory_bytes: 584
s = input()
k = int(input())
sign = 1

num_s = len(list(s))
count = 0
temp_count = 1
count_1 = 0
count_2 = 0

if s[0] != s[-1]:
  for i in range(1,num_s):
    if s[i-1] == s[i]:
      temp_count += 1
    elif s[i-1] != s[i]:
      count += temp_count//2
      temp_count = 1
      
  ans = (count+temp_count//2)*k
  
elif s[0] == s[-1]:
  for i in range(1,num_s):
    if s[i-1] == s[i]:
      temp_count += 1
    elif s[i-1] != s[i]:
      if sign == 1:
        count_1 = temp_count
        sign = 0
      elif sign == 0:
        count += temp_count//2
     
      temp_count = 1

  count_2 = temp_count
  
  ans = count*k + ((count_1 + count_2)//2)*(k-1) + (count_1//2) + (count_2//2)

  if sign == 1:
    ans = (k*num_s)//2
    
if num_s == 1:
  ans = k//2
  
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())


int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	
	int n;
	cin >> n;
	vi h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	vi dp(n);

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);

	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
	}

	cout << dp[n - 1] << "\n";

	return 0;
}

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

void countingSort(vector<int> &A, vector<int> &B, int k) {
    vector<int> C(k + 1, 0);
    for (int i = 1; i < A.size(); i++) {
        C.at(A.at(i))++;
    }

    for (int i = 1; i < k + 1; i++) {
        C.at(i) += C.at(i - 1);
    }

    for (int i = B.size() - 1; i > 0; i--) {
        B.at(C.at(A.at(i))) = A.at(i);
        C.at(A.at(i))--;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n + 1);
    vector<int> B(n + 1);
    A.at(0) = -1;
    B.at(0) = -1;
    for (int i = 1; i < n + 1; i++) {
        scanf("%d", &A.at(i));
    }

    countingSort(A, B, 10000);

    for (int i = 1; i < n; i++) {
        printf("%d ", B.at(i));
    }
    printf("%d\n", B.at(n));
}


Measured memory_bytes: 18300
import numpy as np

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

gap = 1000000000000000000000

H = np.asarray(H)

Tem = T-H*0.006

for i in range(N):

    if abs(Tem[i]-A)<gap:
        gap = abs(Tem[i]-A)
        palace = i+1

print(palace)


Measured memory_bytes: 12500
//arc060_d.cpp
//Wed Dec 25 22:20:00 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,s;
	cin >> n >> s;
	ll anscan = 2;
	for (ll i=2;i*i<=n;i++){
		anscan = i;
		ll x = log2(n)/log2(i);
//		cout << i << " " << x  << endl;
		ll tempans = 0;
		ll tempn = n;
		while (x>=0){
			ll sho = tempn/pow(i,x);
			tempans += sho;
			tempn = tempn-sho*pow(i,x);
//			cout << i << " " << x << " " << tempans << endl;
			x--;
		}
//		cout << i << " " << tempans << endl;
		if (tempans==s){
			cout << i << endl;
			return 0;
		}
	}


	ll start = n/anscan+1;

	for (ll i=start;i>0;i--){
		if (s-i<0){
			continue;
		}
		ll b = (n-(s-i))/i;
		if (b>s-i && b*i+(s-i)==n && b>=2 && b>i){
			cout << b << endl;
			return 0;
		}
	}

	if (n==s){
		cout << n+1 << endl;
		return 0;
	}

	cout << -1 << endl;

}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int X,K;
	cin>>K>>X;
	if( K*500>=X)
		cout<<"Yes"<<nl;
	else
		cout<<"No"<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

    bool ans = true;
    for(int i=0; i<S.length(); i++) {
        if((i+1) % 2 != 0) {
            if (S[i] == 'L') {
                ans = false;
                break;
            }
        } if((i+1) % 2 == 0) {
            if (S[i] == 'R') {
                ans = false;
                break;
            }
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;

    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   cin >> a >> b;

   int ans = 0;
   ans = max({a+b,a-b,a*b});

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main() {
    
    int N;
    vector<int> A;
    int sum = 0;
    int ave;
    int ans = 0;
    
    cin >> N;
    
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        A.push_back( a );
        sum += a;
    }
    
    ave = round( static_cast<double>(sum) / static_cast<double>(N) );
    
    for ( int i = 0; i < N; i++ ) {
        ans += ( ave - A[i] ) * (ave - A[i] );
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int n, q, cnt[100001] = {}; 
long long cr = 0;
int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {int x; cin >> x; cnt[x]++; cr += x;}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int u, v; cin >> u >> v;
		cr += (long long)cnt[u] * (v - u);
		cnt[v] += cnt[u];
		cnt[u] = 0;
		cout << cr << "\n";
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int d;
  cin >> d;
  
  if(d == 25){
    cout << "Christmas";
  }
  
  if(d == 24){
    cout << "Christmas Eve";
  }
  
  if(d == 23){
    cout << "Christmas Eve Eve";  
  }
  
  if(d == 22){
    cout << "Christmas Eve Eve Eve";  
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
l = [0] * (k * 2 + 1)
c = '1'
p = 0
ret = 0
for i in range(len(s)):
    if s[i] != c:
        ret = max(ret, i - l[p])
        l.append(i)
        if c == '1':
            p += 2
        c = s[i]
ret = max(ret, n - l[p])
print(ret)


Measured memory_bytes: 7520
// Problem : C - Average Length
// Contest : AtCoder Beginner Contest 145
// URL : https://atcoder.jp/contests/abc145/tasks/abc145_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#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;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int n;
pii x[maxN];
vi vec;

ld odl(pii p1, pii p2) {
	ll sq1 = (p1.st - p2.st) * (p1.st - p2.st);
	ll sq2 = (p1.nd - p2.nd) * (p1.nd - p2.nd);
	return sqrt(sq1 + sq2);
}

ld cnt() {
	ld sum = 0.0;
	RI(i, n - 1) {
		sum += odl(x[vec[i]], x[vec[i - 1]]);
	}	
	return sum;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	ll fact = 1;
	RI(i, n) {
		fact *= i;
		cin >> x[i].st >> x[i].nd;
		vec.pb(i);
	}
	ld sum = 0.0;
	do {
		sum += cnt();
	} while (next_permutation(vec.begin(), vec.end()));
	cout << fixed << setprecision(10) << sum / fact << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
void traceALDS11A(int arr[], int max) {
	for (int i = 0; i < max; ++i) {
		if (i)
			std::cout << " ";
		std::cout << arr[i];
	}
	std::cout << std::endl;
}

int main() {

	int N;
	std::cin >> N;

	int arr[N];
	for (int i = 0; i < N; ++i) {
		std::cin >> arr[i];
	}

	traceALDS11A(arr, N);

	for (int i = 1; i < N; ++i) {
		int v = arr[i];
		for (int j = i - 1; j >= 0; --j) {
			if (v < arr[j]) {
				std::swap(arr[j], arr[j + 1]);
			} else {
				break;
			}
		}
		traceALDS11A(arr, N);
	}

	return 0;
}

Measured memory_bytes: 3084
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


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


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc113/tasks/abc113_d
# おっこの間やったばかり

H, W, K = read_ints()
if W == 1:
    print(1)
    exit()  # コーナーケース
# DP
# dp[h][k] ... 0からスタートしたときに,[0,h)の横線まで考慮して、k番目に到達できる通りの総数
# 繊維は2**8を全探索 ただし、条件を満たさないやつは注意する


dp = [[0] * W for _ in ra(H + 1)]
dp[0][0] = 1


# swapする要素のidxのペアを返す
def check_valid(p):
    # 1が連続してはいけない
    for pp, ppp in zip(p, p[1:]):
        if pp == 1 and ppp == 1:
            return False
    return True


def generate_ij_to_swap():
    ret = []
    for p in product(range(2), repeat=W - 1):
        if not check_valid(p):
            continue
        pre = False
        for i, pp in enu(p):
            if pp:
                ret.append((i, i + 1))
                ret.append((i + 1, i))
            elif pre == 0 and pp == 0:
                ret.append((i, i))  # つながってないやつ
            pre = pp
        if pre == 0:
            ret.append((i + 1, i + 1))
    return ret


swap_idx = generate_ij_to_swap()


for h in ra(H):
    for i, j in swap_idx:
        dp[h + 1][j] += dp[h][i] % MOD  # 遷移の更新

print(dp[H][K - 1] % MOD)


Measured memory_bytes: 38896
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cstdio>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n, z, w;
int a[2001];
int dp[2][2001];

int main(int argc, char const* argv[])
{
	scanf("%d %d %d", &n, &z, &w);
	for(int i = 0; i < n; i++)scanf("%d", a + i);
	if(n == 1){
			cout << abs(a[0] - w) << endl;
			return 0;
	}
	dp[0][n - 1] = abs(a[n-1] - a[n-2]);
	dp[1][n - 1] = abs(a[n-1] - a[n-2]);
	for(int i = n - 2; i >= 0; i--){
			dp[0][i] = -1;
			dp[1][i] = inf;
			for(int j = i + 1; j < n; j++){
					dp[0][i] = max(dp[0][i], dp[1][j]);
					dp[1][i] = min(dp[1][i], dp[0][j]);
			}
			if(i != 0)dp[0][i] = max(dp[0][i], abs(a[i-1]-a[n-1]));
			else dp[0][i] = max(dp[0][i], abs(w - a[n-1]));
			if(i != 0)dp[1][i] = min(dp[1][i], abs(a[i-1]-a[n-1]));
			else dp[1][i] = min(dp[1][i], abs(z - a[n-1]));
	}
	cout << dp[0][0] << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

vector<complex<double>> dft(vector<complex<double>> &f, bool is_inverse = false) {
    int N = f.size();
    if (N == 1) {
        return f;
    }
    vector<complex<double>> res(N);
    vector<complex<double>> F_even(N / 2), F_odd(N / 2);
    for (int i = 0; i < N / 2; i++) {
        F_even[i] = f[2 * i + 0];
        F_odd[i] = f[2 * i + 1];
    }
    F_even = dft(F_even, is_inverse);
    F_odd = dft(F_odd, is_inverse);
    complex<double> zeta(cos(2.0 * M_PI / N), (is_inverse ? -1 : 1) * sin(2.0 * M_PI / N));
    complex<double> pow_zeta = 1;
    for (int i = 0; i < N / 2; i++) {
        res[i] = F_even[i] + pow_zeta * F_odd[i];
        res[i + N / 2] = F_even[i] - pow_zeta * F_odd[i];
        pow_zeta *= zeta;
    }
    return move(res);
}

vector<complex<double>> idft(vector<complex<double>> &f) {
    auto res = dft(f, true);
    for (int i = 0; i < res.size(); i++) {
        res[i] /= res.size();
    }
    return move(res);
}

vector<int> polynomialMultiply(vector<int> &a_, vector<int> &b_) {
    vector<complex<double>> a(a_.size()), b(b_.size());
    for (int i = 0; i < a_.size(); i++) {
        a[i] = double(a_[i]);
    }
    for (int i = 0; i < b_.size(); i++) {
        b[i] = double(b_[i]);
    }
    int size = a.size() + b.size() - 1;
    int N = 1;
    while (N < size)
        N *= 2;
    a.resize(N);
    b.resize(N);
    a = dft(a);
    b = dft(b);
    for (int i = 0; i < N; i++) {
        a[i] *= b[i];
    }
    a = idft(a);
    vector<int> res(size);
    for (int i = 0; i < size; i++) {
        res[i] = a[i].real() + 0.5;
    }
    return move(res);
}

signed main() {
    cin >> N >> M;
    vi a(N);
    cin >> a;
    int mx = *max_element(ALL(a));
    vi b(mx + 1);
    for (int i = 0; i < a.size(); i++) {
        b[a[i]]++;
    }
    vi c = polynomialMultiply(b, b);
    int cnt = 0;
    dump(c);
    RREP(i, c.size()) {
        ans += c[i] * i;
        cnt += c[i];
        if (cnt >= M) {
            ans -= (cnt - M) * i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 28488
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll A, ans;
    string B;
    cin >> A >> B;
    ll N = 0;
    N += 100 * ( B.at(0) - '0' );
    N += 10 * ( B.at(2) - '0' );
    N += B.at(3) - '0';
    ans = A * N;
    cout << ans / 100 << endl;
    return 0;
}


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

int main(){
    int n;cin>>n;
    vi list(n);
    int m;cin>>m;
    int a,b;
    rep(i,m){
        cin>>a>>b;
        a--;b--;
        list[a]++;
        list[b]++;
    }
    
    rep(i,n){
        if(list[i]%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 3780
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String n_x_m [] = s.split(" ", -1);
        long n = Long.parseLong(n_x_m[0]);
        long x = Long.parseLong(n_x_m[1]);
        long m = Long.parseLong(n_x_m[2]);
        long A[] = new long[(int)m];
        long Loop[] = new long [(int)m];
        A[0] = x;
        Loop[(int)x] = 1;

        long y = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0, ans = 0, sum = 0;

        for(int i = 1; i < (int)m; i++){
            y = A[i - 1] * A[i - 1] % m;
            if(y == 0){
                cnt1 = i;
                break;
            }
            if(Loop[(int)y] > 0){
                cnt1 = i - Loop[(int)y] + 1;
                cnt2 = Loop[(int)y] - 1;
                break;
            }
            A[i] = y;
            Loop[(int)y] = i + 1;
        }
        //System.out.println("y:" + y);
        //System.out.println("cnt1:" + cnt1);
        //System.out.println("cnt2:" + cnt2);
        if(y == 0){
            for(long i = 0; i < cnt1; i++){
                ans += A[(int)i];
            }
        }else{
            for(long i = 0; i < cnt2; i++){
                ans += A[(int)i];
            }
            for(long i = cnt2; i < cnt1 + cnt2; i++){
                sum += A[(int)i];
            }
            long a = (n - cnt2) / cnt1;
            cnt3 = (n - cnt2) % cnt1;
            ans += sum * a;
            for(long i = cnt2; i < cnt2 + cnt3; i++){
                ans += A[(int)i];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 37356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

struct UnionFind {
    vector<ll> par, rank,
        cnt;  // par[i]:iの親の番号,rank[r]:rを根とする木の高さ,cnt[r]:rを根とする木の要素数

    UnionFind(ll N) {  //全て根として初期化
        for (ll i = 0; i < N; i++) par.push_back(i);
        rank.assign(N, 0);
        cnt.assign(N, 1);
    }

    ll root(ll x) {  // xの根を返す
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {  // xの木とyの木を併合
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;

        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
            cnt[ry] += cnt[rx];
        } else {
            par[ry] = rx;
            cnt[rx] += cnt[ry];
            if (rank[x] == rank[y]) rank[rx]++;
        }
    }

    ll tsize(ll x) {  //　xの木の要素数を返す
        ll rx = root(x);
        return cnt[rx];
    }

    bool same(ll x, ll y) {  // xとyが同一の木に存在するかを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> v[M];
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int L;
            cin >> L;
            v[L - 1].push_back(i);
        }
    }
    UnionFind tree(N);
    for (int i = 0; i < M; i++) {
        if (v[i].size() <= 1) continue;
        int l = v[i][0];
        for (const auto& x : v[i]) tree.unite(l, x);
    }
    if (tree.tsize(0) == N)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
 
//#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

int dp[100010][13];

signed main(){
    string s; cin >> s;
    int n = (int)s.length();
    reverse(ALL(s));
    if(s[0] != '?'){
        dp[0][s[0]-'0'] = 1;
    }else{
        rep(i,10) dp[0][i] = 1;
    }
    
    int placemod = 10;
    reps(i,1,n-1){
        if(s[i] != '?'){
            int d = s[i] - '0';
            rep(m,13){
                int t = mod(m + d * placemod, 13);
                dp[i][t] = mod(dp[i][t] + dp[i-1][m]);
            }
        }else{
            rep(d,10){
                rep(m,13){
                    int t = mod(m + d * placemod, 13);
                    dp[i][t] = mod(dp[i][t] + dp[i-1][m]);
                }
            }
        }
        placemod = (10 * placemod) % 13;
    }
    
    cout << dp[n-1][5] << endl;
}

Measured memory_bytes: 5584
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int h,w;
	while(cin>>h>>w&&h)
	{
		string a[120];
		for(int i=0;i<h;i++)
		{
			cin>>a[i];
		}
		pair<int,int> p(0,0);
		map< pair<int,int>,int > m;
		m[p]=1;
		bool ok=true;
		while(ok)
		{
			char now=a[p.first][p.second];
			switch(now)
			{
			case '^':
				p.first--;
				break;
			case '>':
				p.second++;
				break;
			case 'v':
				p.first++;
				break;
			case '<':
				p.second--;
				break;
			case '.':
				cout<<p.second<<" "<<p.first<<endl;
				ok=false;
				break;
			}
			if(ok&&m.count(p))
			{
				cout<<"LOOP"<<endl;
				break;
			}
			m[p]=1;
		}
		
	}
	
}

Measured memory_bytes: 1256
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

// inputに入力データ全体が入る
function Main(sc) {

	var N = sc.nextInt();
	var heights = [];
	
	for (var i = 0; i < N; i++) {
		heights[i] = sc.nextInt();
	}
	
	var NmnsHn_Cnt = {};
	for (var i = 0; i < N; i++) {
		var NmnsHn = i - heights[i];
		NmnsHn_Cnt[NmnsHn] = (NmnsHn_Cnt[NmnsHn] == null) ? 1 : NmnsHn_Cnt[NmnsHn] + 1;
	}
	
	var ptncnt = 0;
	for (var i = 0; i < N; i++) {
		var NplsHn = i + heights[i];
		if (NmnsHn_Cnt[NplsHn]) ptncnt += NmnsHn_Cnt[NplsHn];
	}
	
	// 出力
	console.log(ptncnt);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("33"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得


Measured memory_bytes: 96432
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
#include<numeric>
#include<complex>
#include<memory>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main(){
	int K,T;
	cin>>K>>T;
	vector<int> a(T);
	for(auto& val:a)
		cin>>val;

	if(a.size()==1){
		cout<<a[0]-1<<endl;
	}
	else{
		int ans=0;
		sort(begin(a),end(a));

		long long Max=a.back();
		long long rest=0;
		for(const auto& val:a)
			rest+=val;
		rest-=Max;

		if(rest<Max-1){
			cout<<Max-rest-1<<endl;
		}
		else cout<<0<<endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 384
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int f(int x){
    int now=1;
    int ret=0;
    while(now<=x){
        x-=now;
        now++;
        ret++;
    }
    return ret;
}
int main(){
    int an=0;
    LL N;
    R(N);
    for(LL i=2;i*i<=N;i++){
        if(N%i==0){
            int c=0;
            while(N%i==0){
                N/=i;
                c++;
            }
            an+=f(c);
        }
    }
    if(N!=1)an++;
    W(an);
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
string a,b;
int n;

int main()
{
    cin >> a >> b;
    int res = 0;
    for(int i=0;i<a.size();i++) 
        if(a[i]!=b[i])
            res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;

int main(){
    int n, k;
    cin >>n>>k;
    int count[n + 1];
    memset(count,0,sizeof(count));
    fo(i,0,k){
        int d;
        cin >> d;
        fo(i,0,d){
            int a;
            cin >> a;
            count[a]++;
        }
    }
    int ans =0;
    for(int i = 1; i <= n; i++){
        if(count[i] == 0)ans++;
    }
    cout << ans;

}

Measured memory_bytes: 3640