akhauriyash/Code-Regression huggingface dataset:
stack=[]
n=int(input())
color=[]
graph={}
d_time=[]
f_time=[]
time=0
root=[i for i in range(1,n+1)]

for i in range(n):
    tmp=list(map(int,input().split()))
    graph[tmp[0]]=[0 for j in range(n+1)]
    color=["white" for l in range(n+1)]
    d_time=[0 for j in range(n+1)]
    f_time=[0 for j in range(n+1)]
    for k in range(tmp[1]):
        graph[tmp[0]][tmp[2+k]]=1
        if tmp[2+k] in root:
            root.remove(tmp[2+k])

def function(number):
    global time
    stack.append(number)
    color[number]="gray"
    time+=1
    d_time[number]=time
    while stack!=[]:
        u=stack[-1]
        if 1 in graph[u]:
            v=graph[u].index(1)
            graph[u][v]=0
            if color[v]=="white":
                color[v]="gray"
                time+=1
                d_time[v]=time
                stack.append(v)
        else:
            stack.pop()
            color[u]="black"
            time+=1
            f_time[u]=time

if root==[]:
    function(1)
else:
    for i in range(len(root)):
        function(root[i])

for i in range(1,n+1):
    print(i,d_time[i],f_time[i])


Measured memory_bytes: 5736
#include <bits/stdc++.h>
using namespace std;
int main() {
  int count;
  int num;
  int run_cnt;
  int ans = 1000000000;  
  cin >> count;
  for (int i = 0; i < count; i++) {
	cin >> num;
    run_cnt = 0;
    while(num%2 == 0){
      run_cnt++;
      num = num / 2;
    }
//    cout << "run_cnt :" + to_string(run_cnt) << endl;
      ans = min(ans,run_cnt);
  }
  cout << ans << endl;
}   

Measured memory_bytes: 256
# ABC113C - ID
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    P = tuple(map(int, input().split()) for _ in range(M))
    A = sorted((p, y, i) for i, (p, y) in enumerate(P))
    ans, cnt = [""] * M, 1
    ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt)
    for i in range(1, M):
        if A[i - 1][0] == A[i][0]:
            cnt += 1
        else:
            cnt = 1
        ans[A[i][2]] = "{:06}{:06}".format(A[i][0], cnt)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 62516
#include <iostream>
#include <cstring>

using namespace std;

int main(void){
	bool t[32];
	memset(t,0,sizeof(t));
	int n;
	while(cin>>n){
		t[n]=true;
	}
	for(n=1;n<31;n++){
		if(!t[n]) cout << n << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
int test[123456];
int main() {
	int a, b, c;
	cin >> a >> b >> c;
 
    if (a == b && c == b && a % 2 == 0) {
       cout << -1 << std::endl;
       return 0;
    }
 
    int count = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
       count++;
       int next_a = b / 2 + c / 2;
       int next_b = c / 2 + a / 2;
       int next_c = a / 2 + b / 2;
 
       a = next_a;
       b = next_b;
       c = next_c;
    }
       cout << count << endl;

}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
rec = [[0] * 3 for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                rec[j][k] = 1
Lotto = False

for i in range(3):
    if sum(rec[i]) == 3:
        Lotto = True
        break

for i in range(3):
    if rec[0][i] == rec[1][i] and rec[1][i] == rec[2][i]:
        if rec[0][i] == 1:
            Lotto = True
            break

if rec[1][1] == 1:
    if rec[0][0] == rec[2][2] and rec[0][0] == 1:
        Lotto = True
    if rec[0][2] == rec[2][0] and rec[0][2] == 1:
        Lotto = True

if Lotto:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    int K, X;
    cin >> K >> X;
    if (500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 888
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []; x = []
s = sum(t)

for i in range(m):
    S,T = input().split()
    p.append(int(S))
    x.append(int(T))

for j in range(m):
    ans = s - (t[p[j]-1] - x[j])
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

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

  int now = S[0];
  int left_num = 1;

  for(int i=1; i<S.size(); i++) {

    if(now==-1) {
      now = S[i];
      left_num++;
    } else if(now != S[i]) {
      left_num--;
      if(left_num==0) now = -1; // empty
    } else { //now==S[i]
      left_num++;
    }

  }

  cout << S.size() - left_num << endl;


  return 0;
}

Measured memory_bytes: 512
class Queue:
    def __init__(self,l):
        self.values = []
        self.l = l
        for _ in range(l):
            self.values.append(None)
        self.head = 0
        self.tail = 0
    def inc(self,n):
        if n+1 >= self.l:
            return 0
        else:
            return n+1
    def enqueue(self,v):
        if self.inc(self.head) == self.tail:
            print 'overflow'
            exit()
        self.values[self.head] = v
        self.head = self.inc(self.head)
    def dequeue(self):
        if self.head == self.tail:
            print 'underflow'
            exit()
        v = self.values[self.tail]
        self.tail = self.inc(self.tail)
        return v
    def size(self):
        if self.head >= self.tail:
            return self.head-self.tail
        else:
            self.head + (self.l-self.tail)

n,q = map(int,raw_input().split(' '))
queue = Queue(200000)
for _ in range(n):
    n,t = raw_input().split(' ')
    t = int(t)
    queue.enqueue((n,t))

c = 0
while queue.size()>0:
    n,t = queue.dequeue()
    if t <= q:
        c += t
        print n,c
    else:
        queue.enqueue((n,t-q))
        c += q

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

int main(){
	int H,W;
	while(cin >> H >> W){
		if(H==0&&W==0) break;	
		for(int i=0;i<H;i++){
			for(int j =0 ; j<W ; j++){
				if(i%2==0 && j%2==0 || j%2==1 && i%2==1) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int INF = 1e9+10;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> sum(n+1, 0);
    for(int i = 0; i < n; i++) sum[i+1] = sum[i] + a[i];
    int h = n-1;
    int l = -1;
    while(h - l > 1)
    {
        int mid = (h + l) >> 1;
        ll s = sum[mid+1];
        bool flag = true;
        for(int i = mid+1; i < n; i++)
        {
            if(2 * s >= a[i])
            {
                s += a[i];
            }
            else
            {
                flag = false;
                break;
            }
        }
        if(flag) h = mid;
        else l = mid;
    }
    cout << n - h << endl;
}


Measured memory_bytes: 4808
import numpy
import numpy as np
N=int(input())
AList=list(map(int,input().split()))
AListSum=sum(AList)
CumSum=numpy.cumsum(numpy.array(AList))
CumSum=list(CumSum)
#print(AList)
#print(CumSum)
#print(AListSum)

def getNearestValue(List, num):
    idx = np.abs(np.asarray(List) - num).argmin()
    return idx
#print(getNearestValue(CumSum, AListSum/2))

MAE=sum(AList[:(getNearestValue(CumSum, AListSum/2))+1])
USHIRO=sum(AList[(getNearestValue(CumSum, AListSum/2))+1:])
print(abs(MAE-USHIRO))

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int n, k, x, ans = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> x;
        ans += min<int>(abs(k - x), x);
    }
    
    cout << ans * 2;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        int[][] d1 = new int[n][m];
        int[][] d2 = new int[m][l];

        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                d1[i][j] = sc.nextInt();
            }
        }

        for(int i=0; i<m; i++) {
            for(int j=0; j<l; j++) {
                d2[i][j] = sc.nextInt();
            }
        }

        long[][] ans = new long[n][l];
        for(int i=0; i<n; i++) {            // height
            for(int k=0; k<l; k++) {        // width
                for(int j=0; j<m; j++) {    // content
                    ans[i][k] += d1[i][j]*d2[j][k];
                }
            }
        }

        for(int i=0; i<n; i++) {
            for(int j=0; j<l; j++) {
                if(j == l-1) {
                    System.out.println(ans[i][j]);
                } else {
                    System.out.print(ans[i][j] + " ");
                }
            }
        }
    }
}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5 + 5;
const ll llinf = 1e18;

int N, a[maxn];

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N;
  for(int i = 1; i <= N; ++i)
    cin >> a[i];
  int sum = 0; ll res = 0;
  int j = 1;
  for(int i = 1; i <= N; ++i){
    while(j <= N && (sum & a[j]) == 0) sum ^= a[j], ++j;
    res += j - i;
    sum ^= a[i];
  }
  cout << res;
}


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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;

char s[105];
int n, m, cnt[26] = {0};

void ans(const char *s) {
	puts(s);
	exit(0);
}

int main() {
	scanf("%d%d", &n, &m);
	if(n == 1 && m == 1) ans("Yes");

	for(int i = 0; i < n; ++i) {
		scanf("%s", s);
		for(int j = 0; s[j]; ++j) {
			++cnt[s[j] - 'a'];
			cnt[s[j] - 'a'] %= 4;
		}
	}

	int odd = 0, even = 0;
	for(int i = 0; i < 26; ++i) {
		if(!cnt[i]) continue;

		if(cnt[i] & 1) ++odd;
		else ++even;
	}

	if(n == 1) {
		if(m & 1) {
			if(odd != 1) ans("No");
		} else {
			if(odd) ans("No");
		}
		ans("Yes");
	} else if(m == 1) {
		if(n & 1) {
			if(odd != 1) ans("No");
		} else {
			if(odd) ans("No");
		}
		ans("Yes");
	}

	if(m & n & 1) {
		if(odd != 1) ans("No");
		if(even > (m / 2) + (n / 2)) ans("No");
		ans("Yes");
	} else if(m & 1) {
		if(odd) ans("No");
		if(even > (n / 2)) ans("No");
		ans("Yes");
	} else if(n & 1) {
		if(odd) ans("No");
		if(even > (m / 2)) ans("No");
		ans("Yes");
	} else {
		if(odd) ans("No");
		if(even) ans("No");
		ans("Yes");
	}

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
using namespace std;
typedef long long LL;
const int N=100010;
int n,tot,ft[N],s[N],d[N];
LL ans;
struct edge{int t,w,n;}E[N<<1];
void dfs(int u){
	s[u]=1;
	for (int o=ft[u],v;v=E[o].t;o=E[o].n){
		if (d[v]) continue;
		d[v]=d[u]+1;
		dfs(v);
		s[u]+=s[v];
	}
}
int judge(int u,int v){
	int su=s[u],sv=s[v];
	if (su>sv) su=n-sv; else sv=n-su;
	return su>sv;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		E[++tot]=(edge){b,c,ft[a]},ft[a]=tot;
		E[++tot]=(edge){a,c,ft[b]},ft[b]=tot;
	}
	d[1]=1;
	dfs(1);
	int mn=1e9;
	rep(i,1,n-1){
		int u=E[i*2].t,v=E[i*2-1].t;
		int s1=min(s[u],s[v]),s2=n-s1;
		ans+=2ll*min(s1,s2)*E[i*2].w;
		if (s1==s2) ans-=E[i*2].w;
	}
	rep(i,1,n){
		int flag=1;
		int u=i;
		for (int o=ft[u],v;v=E[o].t;o=E[o].n)
			flag&=judge(u,v);
		if (flag){
			for (int o=ft[u],v;v=E[o].t;o=E[o].n)
				mn=min(mn,E[o].w);
			ans-=mn;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
def submit():
    k = int(input())

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

    def gcd3(a, b, c):
        lst = [a, b, c]
        lst.sort()
        x, y, z = lst
        return gcd(gcd(x, y), z)

    ans = 0
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                ans += gcd3(a, b, c)

    print(ans)


submit()

Measured memory_bytes: 83532
N,W=list(map(int,input().split()))
wv=[list(map(int,input().split())) for _ in range(N)]

dp=[[-1]*(W+1) for _ in range(N+1)]
dp[0][0]=0

for i in range(N):
    for w in range(W+1):
        if w-wv[i][0]>=0 and dp[i][w-wv[i][0]]>=0:
            dp[i+1][w]=max(dp[i][w],dp[i][w-wv[i][0]]+wv[i][1])
        else:
            dp[i+1][w]=dp[i][w]

print(max(dp[N]))

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

int main(){
  int n, r;
  cin >> n >> r;
  if(n >= 10) cout << r << endl;
  else cout << r + 100*(10-n) << endl;
  return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
class mint:
    def __init__(self, i):
        self.i = i
    def __add__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __radd__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __mul__(self, m):
        return mint(self.i * (m.i if isinstance(m, mint) else m) % MOD)
    def __sub__(self, m):
        t = self.i - m.i
        if t < 0:
            t += MOD
        return mint(t)
    def __pow__(self, m):
        i = self.i
        res = 1
        while(m > 0):
            if m & 1:
                res = res * i % MOD 
            i = i * i % MOD
            m >>= 1
        return mint(res)
    def __truediv__(self, m):
        return mint(self.i * (m ** (MOD - 2)).i % MOD)
    def __repr__(self):
        return repr(self.i)

L, R = map(int, input().split())
dp = [[mint(0) for _ in range(4)] for _ in range(61)]

for d in range(60, 0, -1):
    l = L >> d - 1 & 1
    r = R >> d - 1 & 1
    
    if (L >> d - 1) == 0:
        if (R >> d - 1) > 1:
            dp[d-1][3] += 1
        elif (R >> d - 1) == 1:
            dp[d-1][2] += 1
    elif (L >> d - 1) == 1:
        if (R >> d - 1) > 1:
            dp[d-1][1] += 1
        else:
            dp[d-1][0] += 1

    # x bound, y bound
    if l == r:
        dp[d-1][0] += dp[d][0]
    elif l < r:
        dp[d-1][0] += dp[d][0]
        dp[d-1][1] += dp[d][0]
        dp[d-1][2] += dp[d][0]
    # x bound, y free
    if l == 0:
        dp[d-1][1] += dp[d][1] * 2
        dp[d-1][3] += dp[d][1]
    else:
        dp[d-1][1] += dp[d][1]
    # x free, y bound
    if r == 1:
        dp[d-1][2] += dp[d][2] * 2
        dp[d-1][3] += dp[d][2]
    else:
        dp[d-1][2] += dp[d][2]
    # x free, y free
    dp[d-1][3] += dp[d][3] * 3

print(sum(dp[0]))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
long n,a,b,c;
string ansyn="Yes";
int main() {
  cin >> n >> a >> b >> c;
  vector<string> s(n+1);
  vector<string> ans(n);
  for(long i=0;i<n;i++) cin >> s[i];
  for(long i=0;i<n;i++) {
    if(s[i]=="AB") {
      if(a==0&&b==0){
        ansyn="No";
        break;
      }
      if((a==1&&b==1)&&s[i+1]=="BC") a--,b++,ans[i]="B";
      else if(a>b) a--,b++,ans[i]="B";
      else a++,b--,ans[i]="A";
    } else if (s[i]=="AC") {
      if(a==0&&c==0){
        ansyn="No";
        break;
      }
      if((a==1&&c==1)&&s[i+1]=="BC") a--,c++,ans[i]="C";
      else if(a>c) a--,c++,ans[i]="C";
      else a++,c--,ans[i]="A";
    } else {
      if(b==0&&c==0){
        ansyn="No";
        break;
      }
      if((b==1&&c==1)&&s[i+1]=="AC") b--,c++,ans[i]="C";
      else if(b>c) b--,c++,ans[i]="C";
      else b++,c--,ans[i]="B";
    }
  }

  cout << ansyn << endl;
  if(ansyn=="Yes") for(long i=0;i<n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 9592
def roop_punch(list,num):
    while 1:
        list.sort()
        list=[i for i in list if i>0]
        min_hp=min(list)
        min_index=list.index(min(list))
        for x in range(len(list)):
            if x==0:
                continue
            if list[x]/min_hp>0:
                list[x]=list[x]%min_hp
            else:
                list[x]-min_hp
        if min(list)==max(list):
            break
    return min(list)
a =int(input())
input_list = list(map(int, input().split()))
s=roop_punch(input_list,a)
print(s)


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

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

ll mod=1e9+7;

int main(){
  string S;
  cin >> S;
  if(S.size()%2==1){
    cout << "No" <<endl;
    return 0;
  }
  bool ans=true;
  for(int i=0;i<S.size();i+=2){
    if(S.at(i)!='h'||S.at(i+1)!='i'){
      ans=false;
    }
  }
  if(ans){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}
      
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+7;

int main() {
	ll n, m;
	string s;
	cin >> n >> m;
	cin >> s;
	if(s[0]=='1') {
		cout << -1 << endl;
		return 0;
	}
	int now = n;
	vector<int> ans;
	while(now != 0) {
		int next = 0;
		for(int mi=1;mi<=m;mi++) {
			if(s[now-mi] == '0') {
				if(next <= mi and now-mi >= 0) {
					next = mi;
				}
			}
		}
		if(next == 0) {
			cout << -1 << endl;
			return 0;
		} else{
			now -= next;
			ans.push_back(next);
		}
	}
	for(int i=ans.size()-1;i>=0;i--) {
		cout << ans[i] << ((i==0)?"\n":" ");
	}
}

Measured memory_bytes: 1144
N = input()
T = list(map(int, input().split()))
M = input()
sum = sum(T)
PX = []
ansList = list()
for i in range(int(M)):
    PX.append(list(map(int, input().split())))
for i in range(int(M)):
    ansList.append(sum - (T[PX[i][0]-1] - PX[i][1]))
    print(ansList[i])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define N 300004
#define LL long long
#define ULL unsigned long long
#define pp pair<int,int>
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define REP(i,n) for(int i=0;i<(n);++i)
#define FWD(i,a,b) for (int i=(a); i<(b); ++i)
#define BCK(i,a,b) for (int i=(a); i>(b); --i)
#define SIZE(c) ((int)((c).size()))
#define ALL(u) (u).begin(),(u).end()
#define K 41
LL fpw(LL a, ULL b, LL p){
    LL r = 1; while(b){if(b&1) r=r*a%p; a=a*a%p; b/=2;} return (LL)r;
}

using namespace std;
int n, m;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    if (n & 1) n++;
    if (n/2 >= m) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch, Cw, Dh, Dw = Ch-1, Cw-1, Dh-1, Dw-1

maze = [input() for _ in range(H)]
visit = [[-1] * W for _ in range(H)]
visit[Ch][Cw] = 0

DQ = deque([[Ch, Cw]])
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

while DQ:
  px, py = DQ.popleft()
  if px==Dh and py==Dw:
    print(visit[px][py])
    exit()
  
  for i in range(4):
    nx = px + dx[i]
    ny = py + dy[i]
    if 0<=nx<=H-1 and 0<=ny<=W-1 and maze[nx][ny]=="." and  (visit[nx][ny]>visit[px][py] or visit[nx][ny]==-1):
      visit[nx][ny] = visit[px][py]
      DQ.appendleft([nx, ny])
    
  for i in range(-2, 3):
    for j in range(-2, 3):
      if i==j==0:
        continue
      nx = px + i
      ny = py + j
      if 0<=nx<=H-1 and 0<=ny<=W-1 and maze[nx][ny]=="." and visit[nx][ny]==-1:
        visit[nx][ny] = visit[px][py] + 1
        DQ.append([nx, ny])

print(-1)

Measured memory_bytes: 100204
n,k,q = map(int,input().split())

s = [k-q for i in range(n) ]

for i in range(q):
  t = int(input())
  s[t - 1] += 1


for i in range(n):
  if(s[i] > 0):
    print("Yes")
  else:
    print("No")

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

const int maxn=1e5+10;
int m[maxn],par[maxn];
int n,i,j,q,v;

int find(int x){ return (par[x]==x)?x:find(par[x]);}

int main(){
	scanf("%d%d",&n,&q);
	while (n!=0&&q!=0){
	  ll ans=0; par[1]=1;
	  for (i=2;i<=n;i++) scanf("%d",&par[i]);
	  for (i=1;i<=q;i++){
        char ch; getchar();
	    scanf("%c %d",&ch,&v);
	    if (ch=='M') par[v]=v; else ans+=find(v);
      }
      printf("%lld\n",ans);
      scanf("%d%d",&n,&q);
	}
	return 0;
}


Measured memory_bytes: 3508
#include<cstdio>

using namespace std;

const int MAX = 100005;
int dp[MAX];

int main(){

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

  while(n--){
    int a,b;
    scanf("%d %d",&a,&b);
    for(int i = a; i <= b; i++) dp[i]++;
  }

  for(int i = MAX-1; i>0; i--)
    if(dp[i] >= i-1){
      printf("%d\n",i-1);
      break;
    }
  return 0;
}

Measured memory_bytes: 1412
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 10):
        if N <= 111 * i:
            print(111*i)
            break
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> n >> a >> b;
	c = n / (a + b);
	ll d = n % (a + b);
	d = min(d, a);
	cout << c*a + d << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
    return f?-x:x;
}
inline void Yeah()
{
	puts("Yes");
	exit(0);
}
int main()
{ 
    int n=read(),m=read(),k=read();
    for(int i=1;i<=n;++i)
	{
        int kk=(k-i*m),a=n-i-i;
        if(!kk||a&&(kk>>31&1)==(a>>31&1)&&kk%a==0&&kk/a<=m)Yeah();
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
num = 0
alleven = true
while alleven do
	for i in 0..n-1 do
	  if s[i] % 2 == 1 then
	    alleven = false
	  else
	    s[i] /= 2
	  end
   	  if i == n-1 && alleven == true then
        num += 1
  	  end
    end
end
print num

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

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

    ll n, ans = 4, _min = 2e15;
    vector<ll> x(5);
    cin >> n;
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
        if (x[i] < _min)
            _min = x[i];
    }

    ans += (n % _min) ? (n / _min + 1) : (n / _min);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<vector<char >> MAP(52, vector<char>(52,'#'));


int bfs(int a, int b){
    vector<vector<int>> dist(52, vector<int>(52,-1));
    queue<int> X;
    queue<int> Y;

    X.push(a); Y.push(b);
    int xaxis[4]={0,1,0,-1};
    int yaxis[4]={1,0,-1,0};
    dist[a][b] = 0;

    int maximum = 0;

    while (!X.empty()){
        int x = X.front(); X.pop();
        int y = Y.front(); Y.pop();
        for (int i = 0; i < 4; ++i) {
            if(MAP[x+xaxis[i]][y+yaxis[i]]!='#' && dist[x+xaxis[i]][y+yaxis[i]]==-1){
                X.push(x+xaxis[i]); Y.push(y+yaxis[i]);
                dist[x+xaxis[i]][y+yaxis[i]] = dist[x][y]+1;
                maximum = max(maximum, dist[x+xaxis[i]][y+yaxis[i]]);
            }
        }
    }

    return maximum;

}


int main(void) {

    int H,W; cin>>H>>W;

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin>>MAP[i][j];
        }
    }


    int maximum=0;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            if(MAP[i][j]!='#') maximum = max(bfs(i,j), maximum);
        }
    }
    cout<<maximum<<endl;

    return 0;

}

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

using namespace std;

const long long mod = 1e9 + 7;
int N;


int main(){
    cin>>N;
    vector<vector<int>> compatible(N, vector<int> (N));
    vector<int> dp (1 << N);

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin>>compatible[i][j];
        }
    }

    dp[0] = 1;

    for(int mask = 0; mask < (1 << N) - 1; mask++){
        int man = __builtin_popcount(mask);
        for(int j = 0; j < N; j++){
            if((mask & (1 << j)) == 0 && compatible[man][j] == 1){
                int temp = mask | (1 << j);
                dp[temp] += dp[mask];
                dp[temp] %= mod;
            }
        }
    }

    cout<<dp[(1 << N)-1];

    return 0;
}


Measured memory_bytes: 11444
import java.util.*;

public class Main {
	
	static int judge(double x,double y,double r, double X, double Y, double R){
		double l = Math.sqrt((x-X)*(x-X)+(y-Y)*(y-Y));
		double s1 = Math.abs(R-r);
		double s2 = R+r;
		if(s1 > l) return (r>R) ? 2 : -2;
		if(s2 < l) return 0;
		return 1;		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i=0; i<N; i++){
			double xa,ya,ra,xb,yb,rb;
			xa = sc.nextDouble();
			ya = sc.nextDouble();
			ra = sc.nextDouble();
			xb = sc.nextDouble();
			yb = sc.nextDouble();
			rb = sc.nextDouble();
			
			System.out.println(judge(xa,ya,ra,xb,yb,rb));
			
		}
	}

	
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){

   int a[3][3];
   for(int i=0;i<3;i++){
     for(int j=0;j<3;j++){
        cin>>a[i][j];
     }
   }
   int n;
   cin>>n;
   vector<int> b(n);

   for(int k=0;k<n;k++) {
     cin>>b[k];
     for(int i=0;i<3;i++){
     for(int j=0;j<3;j++){
      if(a[i][j]==b[k]){
          a[i][j]=-1;
       }
     }
    }
   }


   for(int i=0;i<3;i++){
      if((a[i][0] == a[i][1]) and (a[i][1] == a[i][2]) and (a[i][2] == -1)){
          cout<<"Yes"<<endl;
          return 0;
      }
   }

    for(int i=0;i<3;i++){
        if((a[0][i] == a[1][i]) and (a[1][i] == a[2][i]) and (a[2][i] == -1)){
          cout<<"Yes"<<endl;
          return 0;
      }
   }

   if(((a[0][0]==a[1][1]) and (a[2][2]==a[1][1]) and (a[2][2]==-1)) or ((a[0][2]==a[1][1]) and (a[1][1]==a[2][0]) and (a[2][0]==-1)))
   {
     cout<<"Yes"<<endl;
     return 0;
   }

   cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,ii,jj;
ll n,m,ans=0,sum;
ll x,y,k;
ll a[100005];
ll hidari,migi,mid;
bool dp[5105][5105];
int dd[5100];
 
 
 
bool solve(ll x){
	if(dd[x]==2){
		return true;
	}else if(dd[x]==1){
		return false;
	}
    //x番目を除いたらどうなるか
    for(i=0;i<n+2;i++){
        for(j=0;j<k+2;j++){
            dp[i][j]=false;
        }
    }
    ll z=1;
	dp[0][0]=true;
    for(i=0;i<n;i++){
        if(i==x)continue;
        for(j=0;j<k;j++){
            if(dp[z-1][j] && j+a[i]<=k)dp[z][j+a[i]]=true;
            if(dp[z-1][j])dp[z][j]=true;
        }
        z++;
    }
	bool flag=false;
	y = max(0ll,k-a[x]);
    for(j=y;j<k;j++){
        if(j>=0 && dp[n-1][j])flag=true;
    }
	if(flag){
		dd[x] = 2;
		return true;//必要
	}else{
		dd[x] = 1;
		return false;//不必要
	}
}
 
 // huhitu huhitu huhitu huhitu hitu hitu って並ぶ
 // 1 1 1 1 2 2 2 2 2
int main(){
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    hidari=0;
    migi=n-1;
    while(migi-hidari>1){
        mid=(migi+hidari)/2;
        if(solve(mid)){
            migi=mid;
        }else{
            hidari=mid;
        }
    }
	/*for(int i=0;i<n;i++){
		if(solve(i)){
			pe(i);p("は必要");
		}else{
			pe(i);p("は不必要");
		}
	}*/
    for(ii=hidari-2;ii<=hidari+2;ii++){
        if(ii<0 || ii>=n)continue;
        if(!solve(ii)){
			ans=ii;
		}else{
			ans = ii-1;
			break;
		}
        
    }
	p(ans+1);
    return 0;
}

Measured memory_bytes: 31232
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
int a[3];
int main(){
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	int d = a[2] - a[1] + a[2] - a[0];
	if(d&1){
		printf("%d\n",d/2+2);
	}else{
		printf("%d\n",d/2);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;


int main() {
	int n;
	vector<int>a;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
        sort(a.begin(), a.end());
	cout << a[a.size() - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

ns, ew = 0, 0
if "N" in s:
    ns += 1
if "S" in s:
    ns -= 1
if "E" in s:
    ew += 1
if "W" in s:
    ew -= 1

if ns == 0 and ew == 0:
    print("Yes")
else:
    print("No")

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

int main()
{
    string num;
    cin >> num;
    int a = num[0] - '0';
    int b = num[1] - '0';
    int c = num[2] - '0';
    int d = num[3] - '0';

    if (a + b + c + d == 7)
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    else if (a + b + c - d == 7)
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    else if (a + b - c - d == 7)
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    else if (a + b - c + d == 7)
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    else if (a - b + c - d == 7)
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    else if (a - b - c + d == 7)
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    else if (a - b + c + d == 7)
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    else if (a - b - c - d == 7)
        printf("%d-%d-%d-%d=7\n", a, b, c, d);
}

Measured memory_bytes: 256
public class Program
{
  public static void Main()
  {
    string s = System.Console.ReadLine();
    if(s[0] == '7')
    {
      System.Console.WriteLine("Yes");
      return;
    }
    if(s[1] == '7')
    {
      System.Console.WriteLine("Yes");
      return;
    }
    if(s[2] == '7')
    {
      System.Console.WriteLine("Yes");
      return;
    }
    System.Console.WriteLine("No");
  }
}

Measured memory_bytes: 17340
import sys

def main():
    list = [[i for i in map(int, line.rstrip().split())] for line in sys.stdin.readlines()]
    a = (list[0][0] - list[1][0]) *  (list[0][1] - list[1][1])
    print(a)

if __name__ == '__main__':
    sys.exit(main())



Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	string s; cin >> s;
	bool ki = s.size() % 2;
	bool en = s[0] == s.back();
	if (ki == en) cout << "Second" << endl;
	else cout << "First" << endl;
	system("pause");
}

Measured memory_bytes: 760
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
    printf("a < b\n");
}
    else if(a > b){
    printf("a > b\n");
}
    else if(a == b){
    printf("a == b\n");
}
    return 0;
}


Measured memory_bytes: 1960
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = sc.nextInt();
		int count = 0;
		Set<Integer> number = new HashSet<Integer>();
		while (count < len) {
			number.add(sc.nextInt());
			count++;
		}
		if (number.size() == len) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 100444
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  t=1;
  while(t--)
  {
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
      cin>>arr[i];
    vector<int> cost(n,0);
    cost[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
    cost[i]=min(abs(arr[i]-arr[i-1])+cost[i-1],cost[i-2]+abs(arr[i-2]-arr[i]));}
    cout<<cost[n-1];
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(500010);
    int h = 1, cnt = 0;
    for(int i=0; i<n; ++i) {
        int x; cin >> x;
        if(v[0]) {
            cout << "No" << endl;
        } else if(x >= v.size()-1) {
            cout << "Yes" << endl;
        } else {
            while(v[h]) {
                h++;
            }
            if(h <= x) {
                cout << "Yes" << endl;
                int now = x;
                v[now]++;
                cnt++;
                while(v[now] == 2) {
                    v[now] = 0;
                    now -= 1;
                    v[now]++;
                    cnt--;
                }
                h = min(h, now+1);
            } else {
                if(x == cnt) {
                    cout << "Yes" << endl;
                    v[0] = 1;
                } else {
                    cout << "No" << endl;
                }
            }
        }
    }
}


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

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

using namespace std;

typedef long long ll;

int main()
{
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    // (0が連続する区間の始点, 0が連続する区間の終点,　始点の左に何個1が連続しているか, 終点の右に何個1が連続しているか)
    vector<tuple<int, int, int, int>> zeroBlock;
    bool isZero = S[0] == '0';
    bool isOne = S[0] == '1';
    int contZero = isZero ? 1 : 0;
    int contOne = isOne ? 1 : 0;
    int stZero, endZero;
    int prevContOne = 0;
    for (int i = 1; i < N; ++i)
    {
        if (isZero)
        {
            if (S[i] == '0')
            {
                contZero++;
            }
            else
            {
                isZero = false;
                isOne = true;
                stZero = i - contZero;
                endZero = i - 1;
                prevContOne = contOne;
                contOne = 1;
            }
        }
        else if (isOne)
        {
            if (S[i] == '0')
            {
                isZero = true;
                isOne = false;
                if (contZero != 0)
                {
                    zeroBlock.push_back(make_tuple(stZero, endZero, prevContOne, contOne));
                }
                contZero = 1;
            }
            else
            {
                contOne++;
            }
            
        }
    }
    if (S[N - 1] == '0')
    {
        stZero = N - contZero;
        endZero = N - 1;
        zeroBlock.push_back(make_tuple(stZero, endZero, contOne, 0));
    }
    else
    {
        if (contZero != 0) zeroBlock.push_back(make_tuple(stZero, endZero, prevContOne, contOne));
    }
    
    int ans;
    if (zeroBlock.size() <= K)
    {
        ans = N;
    }
    else
    {
        ans = -1;
        for (int i = 0; i + K - 1 < zeroBlock.size(); ++i) 
        {
            int current = get<1>(zeroBlock[i + K - 1]) - get<0>(zeroBlock[i]) + 1 + get<2>(zeroBlock[i]) + get<3>(zeroBlock[i + K - 1]);
            ans = max(ans, current);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<int> x(1e5+2,0);

    REP(i,N) {
        int n;
        cin >> n;
        REP(j,3) {
            if (n+j-1 < 0) continue;
            x[n+j-1]++;
        }
    }

    int maxi = 0;
    REP(i,1e5+2) {
        chmax(maxi,x[i]);
    }

    cout << maxi << endl;

    return 0;
}


Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;

public class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int l = int.Parse(input[1]);
        int taste = 0;
        int exclude = 0;

        if (l < 0 && (l + n -1) > 0)
        {
            exclude = 0;
        }
        else if (l < 0)
        {
            exclude = l + n - 1;
        }
        else
        {
            exclude = l;
        }

        taste = Enumerable
            .Range(1, n)
            .Select(x => x + l -1)
            .Sum() - exclude;

        Console.WriteLine("{0}", taste);
    }
}

Measured memory_bytes: 13396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

using Ki = vector<vector<int>>;
using Vi = vector<int>;

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    int a,b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
}

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

int main() {
	long long a, b, n;
	cin>>a>>b>>n;
	if(n < b){
		cout<<((n*a)/b)-(a*(n/b))<<endl;
	}else{
		n = b - 1;
		cout<<((n*a)/b)-(a*(n/b))<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
N=int(input())
A=list(map(int, input().split()) )
B=list(map(int, input().split()) )
C=list(map(int, input().split()) )

#print(N,A,B,C)

s=0
for j in range(N):
  if j>=1 and A[j]==A[j-1]+1:
    s=s+B[A[j]-1]+C[A[j-1]-1]  
  else:
    s=s+B[A[j]-1]
    
print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int h,w;
  cin >> h >> w;
  vstring mass(h);
  rep(i,h) cin >> mass[i];
  vvint U(h,vint(w));
  vvint D(h,vint(w));
  vvint L(h,vint(w));
  vvint R(h,vint(w));
  for(int j = 0;j < w;j++){
    for(int i = 0;i < h;i++){
      if(mass[i][j] == '#') U[i][j] = 0;
      else if(i == 0) U[i][j] = 1;
      else U[i][j] = U[i-1][j] + 1;
    }
  }
  for(int j = 0;j < w;j++){
    for(int i = h-1;i >= 0;i--){
      if(mass[i][j] == '#') D[i][j] = 0;
      else if(i == h-1) D[i][j] = 1;
      else D[i][j] = D[i+1][j] + 1;
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(mass[i][j] == '#') L[i][j] = 0;
      else if(j == 0) L[i][j] = 1;
      else L[i][j] = L[i][j-1] + 1;
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = w-1;j >= 0;j--){
      if(mass[i][j] == '#') R[i][j] = 0;
      else if(j == w-1) R[i][j] = 1;
      else R[i][j] = R[i][j+1] + 1;
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,w){
      ans = max(ans,U[i][j] + D[i][j] +L[i][j] + R[i][j] - 3);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 129664
import java.util.Scanner;

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

        double[] std = new double[100];
        int cnt=0;
        double sum=0;
        double mean;
        while(true){
            int n;
            n = sc.nextInt();
            if(n == 0)
                break;
            sum=0;
            mean=0;
            double[] s = new double[n];
            for(int i=0; i<n; i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            mean = sum/n;
            sum = 0;
            for(int i=0; i<n; i++){
                sum += Math.pow((s[i] - mean), 2); 
            }
            mean = sum/n;
            std[cnt] = Math.sqrt(mean);
            cnt++;
        }

        for(int i=0; i<cnt; i++){
            System.out.printf("%.8f\n", std[i]);
        }

        sc.close();
    }
}


Measured memory_bytes: 34048
#import sys
#input = sys.stdin.readline
def getInv(N,Q):
    inv = [0] * (N + 1)
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q % i]) % Q
    return inv

def getCmb(N,Q):
    inv = getInv(N,Q)
    nCr = [1] * (N + 1)
    for i in range(1, N + 1):
        nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q
    return nCr


def main():
    p = int( input())
    A = list( map( int, input().split()))
    ANS = [A[0]]
    pm1Ck = getCmb(p-1,p)
    Pow = [[0]*p for _ in range(p+1)]
    for i in range(p+1):
        Pow[i][0] = 1
    for i in range(1,p):
        for k in range(p-1):
            Pow[i][k+1] = Pow[i][k]*i%p
    for k in range(1,p):
        now = 0
        for i in range(p):
            now -= A[i]*Pow[p-i][p-1-k]*pm1Ck[k]
#            now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]
            now %= p
        ANS.append(now)
    print( " ".join( map( str, ANS)))
    # for i in range(p):
    #     now = 0
    #     for k in range(p):
    #         now += ANS[k]*pow(i,k,p)
    #         now %= p
    #     print(A[i], now)
if __name__ == '__main__':
    main()


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

string s;
 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	cin >> s;
	int ans;
	if (s == "SUN") ans = 7;
 	else if (s == "MON") ans = 6;
 	else if (s == "TUE") ans = 5;
 	else if (s == "WED") ans = 4;
 	else if (s == "THU") ans = 3;
 	else if (s == "FRI") ans = 2;
 	else if (s == "SAT") ans = 1;
 	cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256