akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 1e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    int n;
    cin >> n;
    vector<int> cnt(4, 0);
    for(int j = 1; j <= n; j++){
        int x;
        cin >> x;
        cnt[x] ++;
    }
    vector< vector< vector<double> > > dp(n+1, vector < vector<double> >(n+1, vector<double>(n+1, 0)));
    for(int k = 0; k <= n; k++){
        for(int j = 0; j <= n; j++){
            for(int i = 0; i <= n; i++){
                if((i+j+k) > n) continue;
                if(i == 0 && j == 0 && k == 0) continue;

                double p = (double)(n - i - j - k)/(double)(n); // p-ty that we select a plate with no sushi 
                // divide at last by (1 - p)
                dp[i][j][k] = 1;
                if(i > 0){
                    // can remove from plate having 1 sushi
                    dp[i][j][k] += (double)i * dp[i-1][j][k]/(double)n;
                }
                if(j > 0){
                    // can remove from plate with 2 sushi
                    dp[i][j][k] += (double)j * dp[i+1][j-1][k]/(double)n;
                }
                if(k > 0){
                    // can remove from plate with 3 sushi
                    dp[i][j][k] += (double)k * dp[i][j+1][k-1]/(double)n;
                }
                dp[i][j][k] /= ((double)1 - p);
            }
        }
    }
    cout << fixed << setprecision(9) << dp[cnt[1]][cnt[2]][cnt[3]] << endl; 
    return 0;
}

Measured memory_bytes: 216832
#include<bits/stdc++.h>
#define INF 1000000
#define MAX_N 1000000010
using namespace std;
long A[101];
long n, x;
int main()
{
	cin >> n >> x;
	for(int i=0; i<n; i++)
	{
		scanf("%ld",&A[i]);
	}
	sort(A, A + n);
	long ans = 0;
	int i = 0;
	while(1)
	{
		//cout << ans << endl;
		x -= A[i];
		ans++;
		i++;
		if(x < 0)
		{
			ans--;
			break;
		}
		else if(x == 0)
		{
			break;
		}
		else if(i > n)
		{
			ans--;
			if(x > 0)
				ans--;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    long long int a,r,x,y,box;
    while(scanf("%lld %lld",&x,&y)!=EOF){
        a=x*y;
        if(x<y){
            box=x;
            x=y;
            y=box;
        }
        r=x%y;
        while(r!=0){
            x=y;
            y=r;
            r=x%y;
        }
        printf("%lld %lld\n",y,a/y);
    }
return 0;
}

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

int main() {
  int a,b,s=0;
  cin >> a >> b;
  
  for (int i=a;i < b+1;i++) {
    int k=0,m=1;
    
    for (int j=0;j < 5;j++) {
      k += i%(10*m)/m;
      
      if (j == 4)
       break;
      
      m *=10;
      k *=10;
    }
    
    if (i == k)
      s++;
   }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,i,sum=0,a=0,b=0,count1=0,count2=0;
    scanf("%d",&n);
    int x[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&x[i]);
        sum+=x[i];
    }
    a=sum/n;
    b=sum/n+1;
    for(i=0;i<n;i++)
    {
        count1+=(x[i]-a)*(x[i]-a);
        count2+=(x[i]-b)*(x[i]-b);
    }
    if(count1<=count2)
    {
        printf("%d",count1);
    }
    else
    {
       printf("%d",count2);
    }
    return 0;
}


Measured memory_bytes: 128
n, m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
count = 0
for i in range(2**n):
    switch = [0]*n
    for j in range(n):
        if ((i >> j) & 1):
            switch[j] = 1
    All = True
    for k in range(m):
        on = 0        
        for l in lis[k][1:]:
            on += switch[l-1]
        if on % 2 == p[k]:
            continue
        else:
            All = False
            break
    if All == True:
        count += 1
        
print(count)

Measured memory_bytes: 3064
object Main {
  def perfect_num(n: Int): String = {
    val rn = math.sqrt(n).floor.toInt
    def go(t: Int, res: Array[Int]): Array[Int] = {
      if (rn < t)
        res
      else if (n % t == 0)
        go(t+1, res :+ t)
      else
        go(t+1, res)
    }

    val tmp = go(2, Array())
    val prime = Array.concat(tmp.map(n / _), tmp) :+ 1
    val res = prime.distinct.sum
    if (res == n)
      "perfect number"
    else if(res > n)
      "abundant number"
    else
      "deficient number"
  }

  def main(args: Array[String]): Unit = {
    var n = io.StdIn.readInt
    while (n != 0) {
      if (n <= 3)
        println("deficient number")
      else
        println(perfect_num(n))
      n = io.StdIn.readInt
    }
  }
}

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

int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int k;cin>>k;
  if(a[4]-a[0]>k) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
}
  

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <fstream>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, b, a) for(int i = b - 1; i >= a; --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)

#define ALL(V) V.begin(), V.end()
#define SIZE(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define EPS 1e-7
#define Pi 3.14159265358979
#define FILL(a,v) memset(a,v,sizeof(a))

using namespace std;


typedef long long Long;
typedef unsigned long long ULong;
typedef unsigned int Uint;
typedef unsigned char Uchar;
typedef vector <int> VI;
typedef pair <int, int> PII;




int main() {
    ios_base::sync_with_stdio(false);

    int n,x;
    cin >> n >> x;

    int a[200];

    REP(i,n)
        cin >> a[i];

    sort(a,a+n);
    a[n] = x + 1;

    int res = 0;
    while (x >= a[res]) {
        x -= a[res];
        ++res;
    }

    if (x != 0 && res == n)
        --res;

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
#define mod 1000000007
#define int long long
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00%jousu(10,y00)) / jousu(10, y00-1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}


signed main() {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1 << endl;
	}
	else {
		cout << a * b << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x;
   cin>>x;
   if(x>=400&&x<=599)
      cout<<"8";
    else if(x>=600&&x<=799)
      cout<<"7";
   else if(x>=800&&x<=999)
      cout<<"6";
  else if(x>=1000&&x<=1199)
      cout<<"5";
  else if(x>=1200&&x<=1399)
      cout<<"4";
  else if(x>=1400&&x<=1599)
      cout<<"3";
  else if(x>=1600&&x<=1799)
      cout<<"2";
  else 
      cout<<"1";
  return 0;
   
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
N = int(input())

ans = "No"

x = 0
y = 0

while N >= 4 * x:
    y= 0
    while N >= (4 * x) + (7 * y):
        if N == (4 * x) + (7 * y):
            ans = "Yes"
            break

        y += 1

    if ans == "Yes":
        break
    
    x += 1



print(ans)

Measured memory_bytes: 3060
import sys
import collections
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n = I()
    mylist = list(MI())
    max_a = max(mylist)
    exclude_set = set()
    tlist = [False] * (max_a+1)
    for a in mylist:
        if tlist[a]:
            exclude_set.add(a)
        else:
            tlist[a] = True
    ans = 0
    
    for i in range(1, max_a//2 + 1):
        if not tlist[i]:
            continue
        else:
            for j in range(2*i, max_a+1, i):
                tlist[j]=False
    for i in range(len(tlist)):
        if tlist[i] and not i in exclude_set:
            ans += 1
    print(ans)
                
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 106364
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve()
{
    int n;

    cin >> n;

    vector<int> nums = fetch_vec<int>(n);
    map<int, int> tails;

    for (int i = 0; i < n; ++i)
    {
        tails[nums[i]]++;

        auto it = tails.find(nums[i]);
        if (it != tails.begin())
        {
            --it;
            it->second--;
            if (it->second == 0)
                tails.erase(it);
        }
    }

    int counter = 0;
    for (auto& it: tails)
        counter += it.second;

    cout << counter << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 5248
import sys
input = sys.stdin.readline

def main():
  n = int(input())
  input_line = list(map(int, input().split()))
  
  flag = 0
  i = 0
  buf = []
  for x in input_line:
    if len(buf) > 2:
      break
    elif (i + 1) != x:
      buf.append(i)
    i += 1
    
  if input_line == sorted(input_line):
    print("YES")
  elif len(buf) != 2:
    print("NO")
  else:
    first = buf[0]
    second = buf[1]
    s = input_line[first]
    input_line[first] = input_line[second]
    input_line[second] = s
    if input_line == sorted(input_line):
      print("YES")
    else:
      print("NO")


if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left, bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
B = LIST()
C = LIST()

A.sort()
B.sort()
C.sort()

ans = 0
for i in range(N):
    ans += bisect_left(A, B[i]) * (N-bisect(C, B[i]))
print(ans)


Measured memory_bytes: 24912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main(void)
{
	long long a, b;

	std::cin >> a >> b;

	std::vector<long long> primes(10000000);

	primes[0] = 2;
	int prime_i = 1;

	for (long long i = 3; i * i < 100000000LL; i++) {
		bool prime = true;
		for (long long j = 0; j < prime_i; j++) {
			if (i % primes[j] == 0) {
				prime = false;
				break;
			}
		}
		if (prime) {
			primes[prime_i] = i;
			prime_i++;
		}
	}


	for (int i = 0; i < prime_i; i++) {
		if ((a * primes[i]) % b != 0) {
			std::cout << a * primes[i] << std::endl;
			return 0;
		}
	}
	std::cout << -1 << std::endl;
	return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
//	x -> n - 1 - x -> n+1 - (n-1-x) 
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> a[2];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = n-1; i >= 0;i --) {
		if ((n - 1 - i) % 2 == 0) {
			a[0].push_back(v[i]);
		}
		else a[1].push_back(v[i]);
	}
	reverse(a[1].begin(),a[1].end());
	for (int j = 0;j < 2; j++)
	for (int i : a[j]) {
		cout << i <<' ';
	}
	
}

Measured memory_bytes: 5160
a = parse(Int, readline())
b = parse(Int, readline())
c = parse(Int, readline())
x = parse(Int, readline())

ans = 0
for i in 0:a
  for j in 0:b
    for k in 0:c
      if i*500+j*100+k*50==x
        global ans += 1
      end
    end
  end
end

println(ans)

Measured memory_bytes: 167000
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

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

	auto sum = 0;
	if (A > B)
	{
		sum += A;
		--A;
	}
	else
	{
		sum += B;
		--B;
	}

	sum += max(A, B);

	cout << sum << endl;

	return 0;
}


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

int n;
int t[17][17], dp[66000];

int rec(int a){ //????????¢??¶???a
	if(dp[a]>0) return dp[a];

	if(a==(1<<n)-1) return 0;
	
	int x, y=100000000;
	for(int i=1; i<=n; ++i){ //?¬?????????\??????????????????????????¶
		if(a>>(i-1) & 1) continue; //??¢????????\??????
		else{
			int min=t[i][0];
			int p=0;
			
			//????????£???????????¢????????????????????????????°???????????±???????
			for(int j=1; j<=n; ++j){
				if(a>>(j-1) & 1){ //??¢????????\??????	
					if(min>t[i][j]){
						min=t[i][j];
						p=j;
					}
				}	
			}	
			
			x=rec(a + (1<<(i-1)))+min;
			if(y>x) y=x;
			//printf(" a= %ld, i= %d, x= %d\n", a, i, x);
		}
		
	}
	return dp[a]=y;
}

int main(){
	while(1){
		scanf(" %d", &n);
		if(n==0) break;
		
		for(int i=1; i<=n; ++i)
		for(int j=0; j<=n; ++j)
		scanf(" %d", &t[i][j]);		

		memset(dp, -1, sizeof(dp));
		dp[0]=0;
		printf("%d\n", rec(0));
	}
}

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

int main() {
  string s;
  cin >> s;
  rep(i, s.size()-1) {
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int a[10002], n, d; ll dp[10002][102][2]; string s;
ll solve(int pos, int sum, bool lmt){
    if(pos == n) return sum == 0;
    if(dp[pos][sum][lmt] != -1) return dp[pos][sum][lmt];
    int hi = lmt? a[pos]: 9; ll ret = 0;
    for(int i=0; i<=hi; i++){
        ret += solve(pos+1, (sum+i)%d, lmt && (i==a[pos])); 
    }
    return dp[pos][sum][lmt] = ret % mod;
}
int main(){
    memset(dp, -1, sizeof(dp));
    cin >> s >> d; n = s.size();
    for(int i=0; i<n; i++) a[i] = s[i] - '0';
    cout << ( solve(0, 0, 1) - 1 + mod) % mod << endl;
}

Measured memory_bytes: 17152
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_c"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

func solve(n int, u [][]int) int {
	t := make([][]int, n+1, n+1)
	for i := range t {
		t[i] = make([]int, 3, 3)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				if v := t[i][j] + u[i][k]; t[i+1][k] < v {
					t[i+1][k] = v
				}
			}
		}
	}
	max := math.MinInt64
	for _, v := range t[n] {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.Int()
	u := make([][]int, n+1, n+1)
	for i := 0; i <= n; i++ {
		u[i] = []int{scan.Int(), scan.Int(), scan.Int()}
	}
	fmt.Println(solve(n, u))
}


Measured memory_bytes: 13696
#include <cstdio>
int main(){
	char x, y, z;
	while(true){
		scanf("%d%d%d", &x, &y, &z);
		if(x+y+z<-2) return 0;
		if(x*y<0) puts("F");
		else if(x+y>=80) puts("A");
		else if(x+y>=65) puts("B");
		else if(x+y>=50) puts("C");
		else if(x+y>=30){
			if(z>=50) puts("C");
			else puts("D");
		}
		else puts("F");
	}
}


Measured memory_bytes: 2572
public class Main {
	public static void main(String[] args){
		java.util.Scanner sc = new java.util.Scanner (System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			int temp = 0;

			if(a > b){
				temp = a;
				a = b;
				b = temp;
			}
			if(b > c){
				temp = b;
				b = c;
				c =temp;
			}
			if(a > b){
				temp = a;
				a = b;
				b = temp;
			}
			System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 26176
import sys
input = sys.stdin.readline

import collections as cl

def main() :
    N = int(input())
    A_list = [int(i) for i in input().split()]
    current_sum = sum(A_list)

    # 数のバリエーションが多いと詰むなあ
    c = cl.Counter(A_list)
    # print(c)
    # print(c[1])
    # c[1] = 100
    # print(c[1])
    Q = int(input())
    for i in range(Q) :
        B,C = map(int,input().split())
        diff = C-B
        num = c[B]
        current_sum += diff * num
        c[B] = 0
        c[C] += num
        print(current_sum)

main()

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 1e5, LOG = 18;
int jmp[N][LOG];
int x[N];

void solve() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int L, q; cin >> L >> q;
  int id = n - 1;
  for (int i = n - 1; i >= 0; i--) {
    while (x[id] - x[i] > L)
      id--;
    jmp[i][0] = id;
  }
  for (int lvl = 1; lvl < LOG; lvl++) {
    for (int i = 0; i < n; i++) {
      int j = jmp[i][lvl - 1];
      jmp[i][lvl] = jmp[j][lvl - 1];
    }
  }
  for (int i = 0; i < q; i++) {
    int l, r; cin >> l >> r; l--, r--;
    if (l > r) swap(l, r);
    int v = l, res = 0;
    for (int lvl = LOG - 1; lvl >= 0; lvl--) {
      int nv = jmp[v][lvl];
      if (nv < r) v = nv, res += (1 << lvl);
    }
    cout << res + 1 << "\n";
  }
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 11116
s=input()
n2a = lambda c: chr(c+64).lower()
ans=100
n=len(s)
for i in range(1,27):
  al=n2a(i)
  sc= s.count(al)
  if sc==0:
    continue
  f=0
  l=[-1]
  for _ in range(sc):
    li=s.find(al,f)
    l.append(li)
    f=li+1
  if len(l)==1:
    continue
  l.append(n)
  d=0
  for j in range(1,len(l)):
    d=max(d,l[j]-l[j-1]-1)
  ans=min(ans,d)
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int n,a[200000],ans,m;
bool f=false;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	m=a[1];
	f=true;
	for(int i=2;i<=n;i++){
		if(a[i]==m) f=!f;
		else{
			if(f) ans++;
			m=a[i];
			f=true;
		}
	}
	if(f) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;



ll func(ll a, ll b, int len) {
  if (a>b) return 0;
  ll x = b/3 - (a-1)/3;
  ll y = b/5 - (a-1)/5;
  ll z = b/15 - (a-1)/15;
  ll res = 0;
  
  res += len * (b-a+1);
  res -= len * (x+y-z);
  res += 4   * (x+y);
  
  return res;
}

ll f(ll x) {
  ll res = 0;
  ll p = 1;
  REP(i,18) {
    if (x <= p*10-1) {
      res += func(p,x,i+1);
      //cout << res << endl;
      return res;
    }
    res += func(p,p*10-1,i+1);
    //cout << i << "," << res << endl;
    p *= 10;
  }
  return res;
}
  
int main() {
  // REP(i,20) {
  //   cout << i << " " << f(i) << endl;
  // }
  // return 0;
  ll s;
  while(cin >> s) {
    ll low = 0, high = 1e18+1;
    while(low+1<high) {
      ll mid = (low+high) / 2;
      if (f(mid) < s) {
        low = mid;
      } else {
        high = mid;
      }
    }
    int offset = s - f(low) - 1;
    //cout << low << " " << f(low) << " "<< f(low+1) << " ; " << offset <<  endl;
    stringstream ss;
    for (ll i=low+1; i<low+50; ++i) {
      if (i%3==0) ss << "Fizz";
      if (i%5==0) ss << "Buzz";
      if (i%3&&i%5) ss << i;
    }
    //cout << ss.str() << endl;
    cout << ss.str().substr(offset,20) << endl;
  }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/13  Problem: ABC 124 A / Link: http://abc124.contest.atcoder.jp/tasks/abc124_a  ----- */


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

	LL A, B; cin >> A >> B;
	LL ans = max({A+A-1,B+B-1,B+A});
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int r, g, b;
	cin >> r >> g >> b;

	if ((100 * r + 10 * g + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String args[]) {
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a > 8 || b > 8) {
      System.out.println(":(");
    } else {
      System.out.println("Yay!");
    }
  }
}

Measured memory_bytes: 22740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<Integer> prime = new ArrayList<>();
		for (int i = 0; i < 200000; i++) {
			if (isPrime(i)) {
				prime.add(i);
			} else {
				prime.add(-1);
			}
		}

		while (true) {
			String str[] = br.readLine().split(" ");
			int n = Integer.parseInt(str[0]);
			int p = Integer.parseInt(str[1]);

			if (n == -1 && p == -1)
				break;

			int list[] = new int[p + 1];
			int count = 0;
			for (int i = n + 1;; i++) {
				if (prime.get(i) == -1)
					continue;
				else {
					list[count] = prime.get(i);
					count++;
				}
				if (count == p + 1)
					break;
			}
			ArrayList<Integer> ans = new ArrayList<>();
			for (int i = 0; i <= p; i++) {
				for (int j = i; j <= p; j++) {
					ans.add(list[i] + list[j]);
				}
			}
			Collections.sort(ans);
			System.out.println(ans.get(p - 1));
		}
	}

	static boolean isPrime(int n) {
		if (n == 0 || n == 1)
			return false;
		for (int i = 2; i * i <= n; i++) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}


Measured memory_bytes: 67016
S = input()
T = input()
 
ans = 0
if T in S:
  print(ans)
  exit()
ls = len(S)
lt = len(T)
ans = 100000
for i in range(ls-lt+1):
  cnt = 0
  for j in range(lt):
    if S[i+j] != T[j]:
      cnt += 1
  ans = min(ans,cnt)
 
print(ans)

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	ans=1;
	for(int i=1;i<=m;++i) ans*=2;
	printf("%lld",ans*(1900*m+100*(n-m)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<int> ans;
vector<set<int>> visited;
vector<vector<int>> adj;

void solve(int v, int d, int c) {
	if (visited[v].find(d) == visited[v].end()) {
		visited[v].insert(d);
		if (d == 0) ans[v] = c;
		else {
			solve(v, d - 1, c);
			for (auto p : adj[v]) {
				solve(p, d - 1, c);
			}
		}
	}

}

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

	int n, m, q, i, j, k, a, b, v, d, c;
	cin >> n >> m;

	adj.resize(n + 1);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cin >> q;
	vector<tuple<int, int, int>> query(q);
	for (i = 0; i < q; i++) {
		cin >> v >> d >> c;
		query[i] = make_tuple(v, d, c);
	}

	ans.assign(n + 1, 0);
	visited.resize(n + 1);

	for (i = q - 1; i >= 0; i--) {
		tie(v, d, c) = query[i];
		solve(v, d, c);
	}

	for (i = 1; i <= n; i++) cout << ans[i] << "\n";		

	return 0;
}


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

typedef pair<double, int> PINT;

int main() {
  vector<PINT> v;
  double n1;
  int n2;

  for(int j = 0; j < 3; j++) {
    for(int i = 0; i < 8; i++) {
      cin >> n2 >> n1;
      v.push_back(make_pair(n1, n2));
    }
    
    sort(v.begin() + j*8, v.end());
    cout << v[j*8].second << " " << v[j*8].first << endl; v[j*8].first = 10000000.0;
    cout << v[j*8+1].second << " " << v[j*8+1].first << endl; v[j*8+1].first = 10000000.0;
  }

  sort(v.begin(), v.end());
  printf("%d %.2f\n", v[0].second, v[0].first);
  printf("%d %.2f\n", v[1].second, v[1].first);

  return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long a[n];
  for (int i=0;i<n;i++)
    cin>>a[i];
  long long money=1000;
  for (int i=0;i<n-1;i++){
  	long long stocks=money/a[i];
    money+=stocks*max(a[i+1]-a[i],0ll);
  }
  cout<<money;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;
typedef pair<int,int>P;

int main() {

  ll n;cin>>n;

  for(ll i=1;;i++){
    if(i*i>n){
      out((i-1)*(i-1));
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

graph = [[] for i in range(N)]

for i in range(M):
  u,v = map(int,input().split())
  graph[u - 1].append(v - 1)

S,T = map(int,input().split())
S -= 1
T -= 1

from collections import deque
q = deque([])
q.append([S, 0, 0])

seen = [[False] * 3 for i in range(N)]

while q:
  v,cost,step = q.popleft()
  if seen[v][step]:
    continue
  seen[v][step] = True
  if step == 0:
    if v == T:
      print(cost)
      break
    cost += 1
    step = 3
  for u in graph[v]:
    q.append([u, cost, step - 1])
else:
  print(-1)

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

namespace Volume0_0021
{
    class Program
    {
        static void Main(string[] args)
        {
            int dataNum = int.Parse(Console.ReadLine());
            var datas = new Queue<string>();

            for (int i = 0; i < dataNum; i++)
            {
                datas.Enqueue(Console.ReadLine());
            }

            foreach (var data in datas)
            {
                var c = data.Split(' ').Select(double.Parse).ToArray();
                Vector2 v1, v2;
                v1 = new Vector2(c[2] - c[0], c[3] - c[1]);
                v2 = new Vector2(c[6] - c[4], c[7] - c[5]);

                Console.WriteLine(Vector2.Cross(v1, v2) == 0 ? "YES" : "NO");
            }
        }

        static bool IsNearZero(double d, double epsilon)
        {
            return Math.Abs(d) <= epsilon;
        }
    }

    struct Vector2
    {
        public double X, Y;

        public Vector2(double x, double y)
        {
            this.X = x;
            this.Y = y;
        }

        public static Vector2 Add(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
        }


        public static Vector2 operator +(Vector2 v1, Vector2 v2)
        {
            return Add(v1, v2);
        }


        public static Vector2 Subtract(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
        }

        public static Vector2 operator -(Vector2 v1, Vector2 v2)
        {
            return Subtract(v1, v2);
        }

        public static Vector2 Multiply(double x, Vector2 v)
        {
            return new Vector2(x * v.X, x * v.Y);
        }

        public static Vector2 operator *(double x, Vector2 v)
        {
            return Multiply(x, v);
        }

        public static Vector2 Divide(Vector2 v, double x)
        {
            return new Vector2(v.X / x, v.Y / x);
        }

        public static Vector2 operator /(Vector2 v, double x)
        {
            return Divide(v, x);
        }

        public static double Dot(Vector2 v1, Vector2 v2)
        {
            return v1.X * v2.X + v1.Y + v2.Y;
        }

        public static double Cross(Vector2 v1, Vector2 v2)
        {
            return v1.X * v2.Y - v1.Y * v2.X;
        }

        public static Vector2 Negate(Vector2 v)
        {
            return new Vector2(-v.X, -v.Y);
        }

        public static Vector2 operator -(Vector2 v)
        {
            return Negate(v);
        }

        public double Length()
        {
            return Math.Sqrt(X * X + Y * Y);
        }
    }
}

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

int main()
{
int n,k;
cin >> n >> k;
while(n!=0||k!=0){
  int i=0, a[n], S[n-1];
  S[0] = 0;
  while(i < n){
    cin >> a[i];
    if (i>=1)
      S[i] = S[i-1]+a[i-1];
    i++;
  }
  i = 0;
  int m = S[k]-S[0];
  while(k+i<n){
    if (m < S[i+k]-S[i])
      m = S[i+k]-S[i];
    i++;
  }
  cout << m << endl;
cin >> n >> k;
}}




Measured memory_bytes: 3872
N,M,C=(int(i) for i in input().split())
B=[int(i) for i in input().split()]
A=[]
for i in range(N):
  A.append([int(i) for i in input().split()])
answer=0
for i in range(N):
  f=C
  for j in range(M):
    f=f+A[i][j]*B[j]
  if f>0:
    answer=answer+1
    
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

typedef int Weight;
struct Edge {
  int from, to;
  Weight weight;
  Edge(int from, int to, Weight weight) :
    from(from), to(to), weight(weight) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

Matrix adjacency(const Graph &graph) {
  int n = graph.size();
  Matrix distance(n, Array(n, 1e9));
  for (const Edges &edges : graph) for (const Edge &edge : edges) {
    distance[edge.from][edge.to] = edge.weight;
  }
  return distance;
}

void debug(const Graph &g) {
  for (const Edges &es : g) for (const Edge &e : es) {
    cerr << e.from << " " << e.to << " " << e.weight << endl;
  }
}

int solve(const Graph &graph, int v, bitset<100> bit) {
  int res = 1;
  for (const auto &edge : graph[v]) if (!bit[edge.to]) {
    bit[edge.to] = true;
    res = max(res, solve(graph, edge.to, bit) + 1);
    bit[edge.to] = false;
  }
  return res;
}

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break; 
    Graph graph(100);
    for (int i : range(n)) {
      int a, b;
      cin >> a >> b;
      --a, --b;
      graph[a].emplace_back(a, b, 1);
      graph[b].emplace_back(b, a, 1);
    }
    int res = 1;
    for (int i : range(100)) {
      bitset<100> bit;
      bit[i] = true;
      res = max(res, solve(graph, i, bit));
    }
    cout << res << endl;
  }
}

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

int main() {
    int n, m, p;
    while(cin >> n >> m >> p, n) {
        vector<vector<vector<int>>> v(n, vector<vector<int>>(n, vector<int>(n, -1)));
        string winner;
        int moves;
        bool finished = false;
        for(int i=0; i<p; ++i) {
            int x, y;
            cin >> x >> y;
            if(finished) continue;

            int z;
            for(int j=0; j<v[x-1][y-1].size(); ++j) {
                if(v[x-1][y-1][j] == -1) {
                    v[x-1][y-1][j] = i%2; // 0:black 1:white
                    z = j;
                    break;
                }
            }

            finished = [i2 = i, n, m, &winner, &moves, &v]() {
                int dx[13] = {1, 0, 0, 1, -1, 1, -1, 0,  0, 1, -1, -1,  1},
                    dy[13] = {0, 1, 0, 1,  1, 0,  0, 1, -1, 1,  1, -1, -1},
                    dz[13] = {0, 0, 1, 0,  0, 1,  1, 1,  1, 1,  1,  1,  1};
                for(int i=0; i<n; ++i) {
                    for(int j=0; j<n; ++j) {
                        for(int k=0; k<n; ++k) {
                            for(int l=0; l<13; ++l) {
                                int cnt = 0;
                                for(int l2=0; l2<m; ++l2) {
                                    int nx = i + dx[l] * l2,
                                        ny = j + dy[l] * l2,
                                        nz = k + dz[l] * l2;
                                    if(nx < 0 || n <= nx || ny < 0 || n <= ny || nz < 0 || n <= nz || v[nx][ny][nz] == -1) {
                                        cnt = -1;
                                        break;
                                    }
                                    cnt += v[nx][ny][nz];
                                }
                                if(cnt == 0) {
                                    winner = "Black";
                                    moves = i2+1;
                                    return true;
                                } else if(cnt == m) {
                                    winner = "White";
                                    moves = i2+1;
                                    return true;
                                }
                            }
                        }
                    }
                }
                return false;
            }();
        }
        if(winner == "") {
            cout << "Draw" << endl;
        } else {
            cout << winner << " " << moves << endl;
        }
    }
}


Measured memory_bytes: 3156
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MOD = 2019

def main():
    L, R = i2nn()
    LN = L // MOD
    RN = R // MOD
    if LN != RN:
        print(0)
        return
    LM = L % MOD
    RM = R % MOD
    LM2 = min(LM, RM)
    RM2 = max(LM, RM)
    n = int(1e+9)
    for i in range(LM2, RM2):
        for j in range(i+1, RM2+1):
            t = (i * j) % MOD
            if n > t:
                n = t
    print(n)

main()


Measured memory_bytes: 40176
def main():
    card = dict()

    for i in range(2, 13+1):
        card[str(i)] = i
    card["1"] = 14

    A, B = input().split()

    if card[A] > card[B]:
        print("Alice")
    elif card[A] < card[B]:
        print("Bob")
    else:
        print("Draw")

main()

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int N,A,B,C,D,X,Y,E,F;

int main(){
cin>>N>>A>>B>>C>>D;
E=N/A;
if(E*A<N){
E+=1;
}
X=B*E;
F=N/C;
if(F*C<N){
F+=1;
}
Y=D*F;
if(X<Y){
    cout<<X<<endl;
}else{
    cout<<Y<<endl;
}
}


Measured memory_bytes: 3136
#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
// Do not use: System.Numerics;

public class Test
{
    public static void Main()
    {
        long MOD = 1;
        for (int i = 0; i < 9; i++)
        {
            MOD *= 10;
        }
        MOD += 7;

        var line0 = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        long n = line0[0];
        long m = line0[1];

        var x_i = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var y_i = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        
        long temp = n - 1;
        long sum = 0;

        long x_sum = 0;
        for (int i = 0; i < n - 1; i++)
        {
            sum = (sum + temp + MOD) % MOD;
            long multiplier = sum;
            //Console.WriteLine(multiplier);
            temp -= 2;

            long length = x_i[i + 1] - x_i[i];

            x_sum = (x_sum + multiplier * length + MOD) % MOD;
        }

        long y_sum = 0;
        temp = m - 1;
        sum = 0;
        for (int i = 0; i < m - 1; i++)
        {
            sum = (sum + temp + MOD) % MOD;
            long multiplier = sum;
            //Console.WriteLine(multiplier);
            temp -= 2;

            long length = y_i[i + 1] - y_i[i];

            y_sum = (y_sum + multiplier * length + MOD) % MOD;
        }

        long result = (y_sum * x_sum) % MOD;

        Console.WriteLine(result);
    }
}


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

class Program
{
	static void Main(string[] args)
	{
		long[] longArray = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
		long N = longArray[0];
		long A = longArray[1];
		long B = longArray[2];
		if(A == 0)
        {
			Console.WriteLine(0);
			return;
		}
		long ans = A * (N / (A + B)) + Math.Min(A, N % (A + B));
		Console.WriteLine(ans);
	}
}


//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;


int main(){
	string S;
	cin >> S;
	S[0] = '2';
	S[1] = '0';
	S[2] = '1';
	S[3] = '8';

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

def solve(N, A):
    m = [int()] * (N)
    for i in range(N):
        m[0] += A[i] * (-1)**i

    for i in range(1, N):
        m[i] = ((A[i-1]) * 2 - m[i-1])

    m = map(str, m)
    print(' '.join(m))

def main():
    N = int(input())
    A = list(map(int, input().split()))
    solve(N, A)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18072
n,k,q = (int(i) for i in input().split())
d = -q+k
p =[d]*(n+1)


for i in range(q):
    v = int(input())
    p[v] += 1


for i in range(1,len(p)) :
  if 0 < p[i] :
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 6580
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
    int n,a[101],i,j,min=1000000,diff=0,s1=0,s2=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        s1+=a[i];
        for(j=i+1;j<n;j++){
            s2+=a[j];
        }
        diff=abs(s1-s2);
        if(diff<min){
            min=diff;
        }
        s2=0;
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "functional"

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)


//3

int main(void) {
	int h, w;
	cin >> h >> w;
	vector<string> art = vector<string>();
	rep(0, h) {
		string str = "";
		cin >> str;
		art.push_back(str);
	}
	vector<int> dx{ 0,1,0,-1 };
	vector<int> dy{ -1,0,1,0 };

	string ans = "Yes";
	for (int i = 0; i < h; i++) { //行
		for (int j = 0; j < w; j++) { //列
			if (art[i][j] == '#') {
				bool isAble = false;
				for (int k = 0; k < 4; k++) {
					int x = j + dx[k];
					int y = i + dy[k];
					if (x < 0 || x >= w || y < 0 || y >= h) continue;
					if (art[y][x] == '#') {
						isAble = true;
						break;
					}
				}
				if (!isAble) {
					ans = "No";
					break;
				}
			}
		}
		if (ans == "No") break;
	}
	cout << ans << endl;
}


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

ll solve() {
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> w[i] >> v[i];
    }
    const ll INF = 1LL<<60;
    vector<ll> dp(W+1, -INF);
    dp[0] = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int k = W; k >= 0; k-- ) {
            ll j = k - w[i];
            if ( j < 0 ) continue;
            if ( dp[j] < 0 ) continue;
            dp[k] = max(dp[k], dp[j] + v[i]);
        }
    }
    ll ans = 0;
    for ( int j = 0; j <= W; j++ ) {
        ans = max(ans, dp[j]);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,mx;

int main()
{
	cin>>n>>k;
	mx=((LL)pow(2,n))-1LL;
	if(k>mx)
	{
		puts("-1");
		rt0;
	}
	if(k==0)
	{
		rep(i,mx+1) cout<<i<<' '<<i<<' ';
		cout<<endl;
		rt0;
	}
	if(n==1)
	{
		puts("-1");
		rt0;
	}
	cout<<k<<' ';
	rep(i,mx+1) if(i!=k) cout<<i<<' ';
	cout<<k<<' ';
	for(int i=mx;i>=0;i--) if(i!=k) cout<<i<<' ';
	cout<<endl;
	rt0;
}

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

int main(){
    ll n;
    cin>>n;
    ll a[n],ans=0,mx=1000000;
    vector<ll> v(mx+10,0);
    for(ll i=0;i<n;i++) cin>>a[i],v[a[i]]++;
    for(ll i=2;i<mx+10;i++) if(v[i]>1)  ans=-1;
    for(ll i=2;i<=mx;i++){
        ll cnt=0;
        for(ll j=i;j<=mx;j+=i){
            if(v[j])   cnt++;
        }
        if(cnt>1){
            ans=-1;
            break;
        }
    }
    if(ans!=-1){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    ans=a[0];
    for(ll i=1;i<n;i++) ans=__gcd(ans,a[i]);
    if(ans==1)  cout<<"setwise coprime"<<endl;
    else        cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 18784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  int c = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1] )|| (p[i-1] > p[i] && p[i] > p[i+1])) {
      c++;
    }
    
  }
  cout << c << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)print("Yes");
	else print("No");






	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k&1){
        cout << b-a << endl;
    }else{
        cout << a-b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256