akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int, input().split()))
q=[0]*11


ans=0
while(True):
    for i in range(n):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)



Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{ ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m,s=0;
cin>>n>>m;
int A[m];
for(int i=0;i<m;i++)
{   cin>>A[i];
    s+=A[i];
}
int diff=n-s;
if(diff>=0)
    cout<<diff;
else
    cout<<-1;

    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

//System.out.println();
public class Main implements Runnable { //クラス名はWelcomeToAtCoder

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerWelcomeToAtCoder sc = new FastScannerWelcomeToAtCoder(System.in);

		try {
			int N = sc.nextInt();
			int M = sc.nextInt();
			int[] p = new int[M];
			int[] acc = new int[N + 1], wa = new int[N + 1];
			String[] S = new String[M];

			for (int m = 0; m < M; m++) {
				p[m] = sc.nextInt();
				S[m] = sc.nextLine().trim();
			}

			int ans_c = 0;
			int ans_p = 0;

			for (int m = 0; m < M; m++) {
				//System.out.println(m + " " + Collections.binarySearch(ac, p[m]));
				if (acc[p[m]] == 1) {
					continue;
				}

				if (S[m].equals("AC")) {
					acc[p[m]] = 1;
				} else if (S[m].equals("WA")) {
					wa[p[m]] += 1;
				}
			}

			for (int n = 1; n <= N; n++) {
				ans_c += acc[n];
				if (wa[n] >= 1) {
					if (acc[n] == 1) {
						ans_p += wa[n];
					} else {
						continue;
					}
				}
			}

			System.out.println(ans_c + " " + ans_p);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerWelcomeToAtCoder {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerWelcomeToAtCoder(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 44064
#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 <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


    int main() {
        int N, M; cin >> N >> M;
        vector<vector<int>> G(N);
        for (int i = 0; i < M; ++i) {
            int a, b;
            cin >> a >> b;
            G[a-1].push_back(b-1);
            G[b-1].push_back(a-1);
        }
        vector<int> dist(N, -1);
        queue<int> que;

        dist[0] = 0;
        que.push(0);
        vector<int> z(N);
        while (!que.empty()) {
            int v = que.front();
            que.pop();

            for (int nv : G[v]) {
                if (dist[nv] != -1) continue;

                dist[nv] = dist[v] + 1;
                z.at(nv) = v + 1;
                que.push(nv);
            }
        }
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) {
            cout << z.at(i) << endl;
        }
    }

Measured memory_bytes: 10656
"""#################################################################
【ABC120】
B_K-th_Common_Divisor
#################################################################"""

#インポート
import sys

#入力用
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(input())
def S(): return input()

lst = []
A, B, K = MI()
for i in range(1, min(A, B)+1):
    if A%i == 0 and B%i == 0:
        lst.append(i)
lst = sorted(lst, reverse = True)
print(lst[K-1])


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

const (
	mod = 1000000007
)

func pow(x, y int64) int64 {
	if y == 0 {
		return 1
	}
	if y == 1 {
		return x
	}
	if y%2 == 0 {
		x2 := x * x % mod
		return pow(x2, y/2) % mod
	}
	return x * pow(x, y-1) % mod
}

func divide(x, y int64) int64 {
	return x * pow(y, mod-2) % mod
}

func main() {
	var n, a, b, c int64
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	x := make([]int64, n+1)
	y := make([]int64, n+1)

	var expected int64
	for i := int64(0); i < n; i++ {
		if i == 0 {
			x[i] = 1
			y[i] = 1
		} else {
			x[i] = x[i-1] * (n - 1 + i) % mod
			y[i] = y[i-1] * i % mod
		}
		comb := divide(x[i], y[i])

		anp := pow(divide(a, a+b), n) * pow(divide(b, a+b), i) % mod
		anp = anp * comb % mod
		anp = anp * (n + i) % mod
		bnp := pow(divide(b, a+b), n) * pow(divide(a, a+b), i) % mod
		bnp = bnp * comb % mod
		bnp = bnp * (n + i) % mod
		x := (anp + bnp) * 100 % mod
		x = divide(x, a+b)
		expected = (expected + x) % mod
	}

	fmt.Println(expected)
}


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

int main()
{
	int n = 0;

	cin >> n;

	while (n > 0) {

		int a[1001] = { 0 }, t1 = 0, t2 = 0;

		double m = 0, s = 0;

		for (int i = 0; i < n; i++) {
			cin >> a[i];
			t1 += a[i];
			t2 += a[i] * a[i];
		}

		m = (double) t1 / (double) n;
		s = sqrt((double) t2 / (double) n - m * m);

		cout << setprecision(10) << setiosflags(ios::showpoint) << s << endl;

		cin >> n;
	}
    return 0;
}

Measured memory_bytes: 3224
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <stack>
#include <queue>
#include <string>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define getddd(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d\n",a);
#define pfii(a,b) printf("%d %d\n",a,b);
#define pfl(a) printf("%lld\n",a);
#define pfll(a,b) printf("%lld %lld\n",a,b);
#define  SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;


int gcd(int a, int b) {
    while (a > 0 && b > 0)
        if (a > b) a %= b;
        else b %= a;
    return a + b;
}

int lcm(int a, int b) {
    return a*b / gcd(a,b);
}

int grid [1003][1003];


long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}
ll isprime(ll i){
    if (i==2 || i == 3){
        return 0;
    }
    bool ctr =0;
    for(ll k = 2;k*k <i;k++){
        if(i%k==0)ctr=1;
    }
    if(ctr)return 1;
    else return 0;

}


double x1,x2,y11,y2,v1,v2;
double timet=0;
double f ( double dd){
    timet = 0;
    timet +=sqrt(((dd-x1)*(dd-x1)+(0-y11)*(0-y11)))/v1;
    timet +=sqrt(((dd-x2)*(dd-x2)+(0-y2)*(0-y2)))/v2;
    return timet;
}

double tesearch(double left,double right,double eps = 1e-7){
    while(right-left > eps){
        double mid1= left+(right-left)/3;
        double mid2 = right-(right-left)/3;
        if(f(mid1) > f(mid2)){
            left = mid1;
        }else{
            right=mid2;
        }

    }
    return f(left);
}

int main (){
    ll a ,b;
    cin >> a>>b;

    if(a >= b)cout << 10;
    else cout << 0;


    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
		String[] line = b.readLine().split(" ");

		int N = Integer.parseInt(line[0]);
		int L = Integer.parseInt(line[1]);

		String[] S = new String[N];

		for (int i = 0; i < N; i++) {
			S[i] = b.readLine();
		}
		Arrays.sort(S);
		for (int i = 0; i < N; i++) {
			System.out.print(S[i]);
		}
		
	}

}

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

using namespace std;

const int N = 1e5 + 5;
int n, m, k, par[N], siz[N], deg[N], block[N];

int find(int v){
    if(par[v] == v){
        return v;
    } else {
        return (par[v] = find(par[v]));
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a != b){
        if(siz[a] < siz[b]){
            swap(a, b);
        }
        siz[a] += siz[b];
        par[b] = a;
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        par[i] = i;
        siz[i] = 1;
    }
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        unite(a, b);
        deg[a]++;
        deg[b]++;
    }

    for(int i = 1; i <= k; i++){
        int a, b;
        cin >> a >> b;
        if(find(a) == find(b)){
            block[a]++;
            block[b]++;
        }
    }
    for(int i = 1; i <= n; i++){
        int ans = siz[find(i)];
        ans = ans - block[i] - deg[i] - 1;
        cout << ans << " ";
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string s;
	int len, ans = 0, non_x = 0;
	vector<int> vec;

	cin >> s;
	s = 'a' + s + 'a';
	len = s.length();

	rep(i, len) {
		if (s[i] != 'x') {
			non_x++;
			vec.push_back(i);
		}
	}

	int pre = 0;
	int pos = non_x - 1;

	while (pre <= pos) {
		if (s[vec[pre]] != s[vec[pos]]) {
			cout << -1 << endl;
			return 0;
		}

		if (pre != 0) {
			ans += abs((vec[pre] - vec[pre - 1]) - (vec[pos + 1] - vec[pos]));
		}

		pre++;
		pos--;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
  int x;
  cin >> x;
  int c = x % 7;
  if(c == 1){
    cout << "fri" << endl;
  }else if(c == 2){
    cout << "sat" << endl;
  }else if(c == 3){
    cout << "sun" << endl;
  }else if(c == 4){
    cout << "mon" << endl;
  }else if(c == 5){
    cout << "tue" << endl;
  }else if(c == 6){
    cout << "wed" << endl;
  }else if(c == 0){
    cout << "thu" << endl;
  }
}


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

const int MAXN = 2e5 + 10;
int n, a[MAXN], b[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], b[i] = a[i];
	sort(a, a + n);
	int f = a[n / 2 - 1], s = a[n / 2];
	for (int i = 0; i < n; i++) {
		if (b[i] <= f)
			cout << s;
		else
			cout << f;
		cout << '\n';
	}
}

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

int main() {
  int P;
  string S;
  cin >> S;
  bool flagA = false, flagB = false, flagC = true;
  if (S.at(0) == 'A') flagA = true;
  for (int i=2; i<S.size()-1; i++) {
    if (S.at(i) == 'C') {
      flagB = true;
      S.erase(S.begin() + i);
      break;
    }
  }
  S.erase(S.begin());
  for (int i=0; i<S.size(); i++) {
  if ('A' <= S.at(i) && S.at(i) <= 'Z') flagC = false;
  }
  
  if (flagA && flagB && flagC) cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long ans = x / 11 * 2;
    if((x % 11) > 6){
      ans += 2;
    }else if(x % 11 == 0){
      
    }else{
      ans += 1;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*
pairを使うソート。すべての要素を最初のものから昇順ソートしてくれるらしい。
*/
pair<pair<string,int>,int> P[110];
int main()
{   
    int N,tmp;
    string S;
    cin >> N;
    REP(i,N){
        cin >> S >> tmp;
        P[i] = make_pair(make_pair(S,-tmp),i+1);
    }
    sort(P,P+N);
    REP(i,N) fin(P[i].second);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[1111111];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b;
  for(int n=0;n<a;n++) cin >>i[n];
  for(int n=1;n<a;n++){
    if(i[n]+i[n-1]>b){
      if(min(i[n],i[n]+i[n-1]-b)<i[n]+i[n-1]-b){
	d+=i[n],d+=i[n-1]-b,i[n]=0,i[n-1]-=i[n]+i[n-1]-b;
      }
      else
	d+=min(i[n],i[n]+i[n-1]-b),i[n]-=min(i[n],i[n]+i[n-1]-b);
    }
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 2304
def solve():
  R, C, K = map(int, input().split())
  item = [[0]*C for _ in range(R)]
  for i in range(K):
    r,c,v = map(int, input().split())
    item[r-1][c-1] = v
  last_dp = [[0]*(C+1) for _ in range(5)]
  for i in range(1,R+1):
    dp = [[0]*(C+1) for _ in range(5)]
    for j in range(1,C+1):
      for k in range(4): #横から取らない
        dp[k][j] = dp[k][j-1]
      #上から取らない
      dp[0][j] = max(dp[0][j],last_dp[-1][j])
      if item[i-1][j-1]>0:
        #上からとる
        dp[1][j] = max(dp[1][j],last_dp[-1][j]+item[i-1][j-1])
        for k in range(1,4): #横から取る
          dp[k][j] = max(dp[k][j],dp[k-1][j-1]+item[i-1][j-1])
      for k in range(4):
        dp[-1][j] = max(dp[-1][j],dp[k][j])
    last_dp = dp
  ans = last_dp[-1][-1]
  return ans
print(solve())

Measured memory_bytes: 207492
# https://atcoder.jp/contests/abc055/tasks/arc069_a
# C - Scc Puzzle
import math
N, M = list(map(int, input().split()))

c = 0
# 使えるSを全部使えるか
# CがM * 2個いる
if M >= N * 2:
    # Sを全部使う
    c += N
    # 残っているcだけでSccを作れるだけ作る
    c += math.floor((M - N * 2) / 4)
else:
    # Sを使えるだけ使う
    max_pair = math.floor(M / 2)
    c += max_pair

c = int(c)
print(c)

Measured memory_bytes: 2940
import java.util.*;

class State {
    private static LinkedList<State> ret = new LinkedList<>();
    private static int[] vy = {0, 1, 0, -1};
    private static int[] vx = {1, 0, -1, 0};

    private int[][] nums;
    private int zeroY, zeroX;
    private int hash;
    int step;

    State(int[][] _nums, int _zeroY, int _zeroX, int _step) {
        nums = _nums;
        zeroY = _zeroY;
        zeroX = _zeroX;
        hash = -1;
        step = _step;
    }

    @Override
    public int hashCode() {
        if (hash != -1) return hash;
        hash = 0;
        for (int y=0; y<2; y++) {
            for (int x=0; x<4; x++) {
                hash = hash*10 + nums[y][x];
            }
        }
        return hash;
    }

    LinkedList<State> nextMove() {
        ret.clear();
        
        for (int i=0; i<4; i++) {
            int nextZeroY = zeroY + vy[i];
            if (nextZeroY < 0 || nextZeroY >= 2) continue;
            int nextZeroX = zeroX + vx[i];
            if (nextZeroX < 0 || nextZeroX >= 4) continue;

            int[][] nextNums = new int[2][4];
            for (int y=0; y<2; y++) {
                for (int x=0; x<4; x++) {
                    nextNums[y][x] = nums[y][x];
                }
            }

            nextNums[nextZeroY][nextZeroX] = 0;
            nextNums[zeroY][zeroX] = nums[nextZeroY][nextZeroX];
            ret.add(new State(nextNums, nextZeroY, nextZeroX, step+1));
        }
        return ret;
    }
}

public class Main {
    public static void main(String[] args) {
        Map<Integer, Integer> map = new HashMap<>();
        Queue<State> queue = new LinkedList<>();

        int[][] rootNums = {
                {0, 1, 2, 3},
                {4, 5, 6, 7}
        };
        State rootState = new State(rootNums, 0, 0, 0);

        map.put(rootState.hashCode(), rootState.step);
        queue.add(rootState);

        while (!queue.isEmpty()) {
            State nowState = queue.poll();

            for (State nextState : nowState.nextMove()) {
                if (!map.containsKey(nextState.hashCode())) {
                    map.put(nextState.hashCode(), nextState.step);
                    queue.add(nextState);
                }
            }
        }

        Scanner sc = new Scanner(System.in);

        int hash;
        while (sc.hasNext()) {
            hash = 0;
            for (int i=0; i<8; i++) {
                hash = hash*10 + sc.nextInt();
            }
            System.out.println(map.get(hash));
        }
    }
}

Measured memory_bytes: 48984
#include <algorithm>
#include <iostream>
#include<string>
#include<vector>
#include <numeric>
#include <queue>
using namespace std;

int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

struct point {int x; int y;};
bool operator <(const point& a, const point& b) {return std::tie(a.x, a.y) < std::tie(b.x, b.y);}

int getLen(int x) {
    int ans = 0;
    while(x) {
        ans ++;
        x /= 10;
    }
    return ans;
}

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

    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        int len = getLen(i);
        if(len % 2)
            ans++;
    }
    cout << ans << endl;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  vector<ll> x(N),y(N);
  ll maxi(-INFll), mini(INFll);
  ll maxj(-INFll), minj(INFll);
  for(int i(0);i<N;i++){
    cin>>x[i]>>y[i];
    maxi = max(maxi, x[i]+y[i]);
    mini = min(mini, x[i]+y[i]);
    maxj = max(maxj, ll(10e9)-x[i]+y[i]);
    minj = min(minj, ll(10e9)-x[i]+y[i]);
  }
  cout << max(abs(maxi-mini),abs(maxj- minj)) << endl;
  return 0;
}



Measured memory_bytes: 6392
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 1];

int head[MAX_N], cnt;
void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int N, f[MAX_N];

void dfs(int u, int v) {
  for (int i = head[u]; i; i = e[i].nxt)
    if (e[i].to != v)
      dfs(e[i].to, u);
  int vis = 0, twice = 0;
  for (int i = head[u]; i; i = e[i].nxt) 
    if (e[i].to != v) {
      twice |= vis & f[e[i].to];
      vis |= f[e[i].to];
    }
  if (!twice) {
    f[u] = vis + 1;
  } else {
    int k = 20;
    while (!(twice >> k & 1)) k--;
    f[u] = (vis ^ (vis & ((1 << k + 1) - 1))) + (1 << k + 1);
  }
}

int main() {
  scanf("%d", &N);

  for (int i = 1, a, b; i < N; ++i) {
    scanf("%d%d", &a, &b);
    addedge(a, b);
  }

  dfs(1, 0);
  
  int k = 20;
  while (!(f[1] >> k & 1)) k--;

  printf("%d\n", k);
  return 0;
}


Measured memory_bytes: 5888
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

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

	int a, b, c;
	string result;
	cin >> a >> b >> c;
	if (a + b >= c) {
		result = "Yes";
	}
	else {
		result = "No";
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
ll i,j,k;
ll x[100005];

bool solve(){
	cin >> n >> a >> b;
	if(n + a + b == 0){
		return false;
	}
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	ll num = -100;;
	ll ansind = -1;
	for(i=a-1;i<b;i++){
		ll sa = x[i] - x[i+1];
		if(sa >= num){
			num = sa;
			ansind = i;
		}
	}
	cout << ansind + 1<< endl;
	return true;
}


int main(){
	while(solve());
	return 0;
	
}


Measured memory_bytes: 3084
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
g = [input() for i in range(h)]
dp = [[0]*w for i in range(h)]
for i in range(h):
    if g[i][0] == '#':
        break
    dp[i][0] = 1
for i in range(w):
    if g[0][i] == '#':
        break
    dp[0][i] = 1

for y in range(h-1):
    for x in range(w-1):
        if g[y+1][x+1] == '#':
            continue
        dp[y+1][x+1] = dp[y+1][x] + dp[y][x+1]
        dp[y+1][x+1] %= mod
print(dp[-1][-1])
# pprint.pprint(dp)

Measured memory_bytes: 77292
import java.util.*;

class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int S = sc.nextInt();
  int s = S % 60;
  int M = S / 60;
  int m = M % 60;
  int h = M / 60;
    System.out.println(h + ":" + m + ":" + s);
 }
}


Measured memory_bytes: 26200
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    p,q,r = LI()
    print(p+q+r-max(p,q,r))
    return

#B
def B():
    n = I()
    w = LI()
    ans = float("inf")
    for i in range(n):
        m = sum(w[:i])
        l = sum(w[i:])
        ans = min(ans,abs(m-l))
    print(ans)
    return

#C
def C():
    n,m = LI()
    f = defaultdict(lambda : 1)
    for i in range(m):
        a = I()
        f[a] = 0
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(1,n+1):
        if f[i]:
            dp[i] = dp[i-1]+dp[i-2]
            dp[i] %= mod
    print(dp[n])
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 56408
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MAX = 1000000000;
int main() {
    int n, k;
    ll s;
    cin >> n >> k >> s;

    rep(i,k) {
        cout << s << " ";
    }
    srep(j,k,n) {
        if (s != MAX) cout << MAX << " ";
        else cout << 1 << " ";
    }
    cout << endl;
    return 0;
}








Measured memory_bytes: 1280
#include <cstdio> 
using namespace std;

const int maxn=20, maxm=120, maxs=4e4, p=1e9+7;
int n, m, a[maxm], b[maxm], c[maxs], d[maxs], mi2[maxm];
long long f[2][maxs], ans;  
//f[0/1][i]表示包含0/1的集合i,从0/1出发刚好能到达所有点的方案数 

int main(){
	scanf("%d%d", &n, &m);
	for (int i=mi2[0]=1; i<maxm; ++i)
		mi2[i]=mi2[i-1]*2%p;
	for (int i=0; i<m; ++i){
		scanf("%d%d", &a[i], &b[i]);  //a b 存边 
		--a[i]; --b[i]; }
	for (int i=0; i<(1<<n); ++i)   
		for (int j=0; j<m; ++j){
			if ((i>>a[j]&1)&&(i>>b[j]&1)) ++c[i];  //c:两边都在s中的点数 
			if ((i>>a[j]&1)||(i>>b[j]&1)) ++d[i];  //d:恰好一个点在s中的点数 
		}
	for (int i=0; i<2; ++i)
		for (int j=0; j<1<<n; ++j){
			if ((j>>i&1)==0) continue;
			f[i][j]=mi2[c[j]];
			for (int k=j; k>0; k=(k-1)&j)  //注意是“刚好能到所有点” 
				f[i][j]=(f[i][j]+p-f[i][j-k]*mi2[c[k]])%p;
		}
	for (int i=0; i<1<<n; ++i){
		for (int j=0; j<1<<n; ++j){
			if ((i&j)||c[i]+c[j]!=c[i|j]) continue;
			ans=(ans+f[0][i]*f[1][j]%p*mi2[m-d[i|j]])%p;  //不与集合相连的边随便选 
		}
	}
	printf("%lld\n", (mi2[m]-ans+p)%p);
	return 0;
}

Measured memory_bytes: 896
S = input()

befal = ""
ans = 0
bef = ""
for s in S:
  if bef == "":
    stmp = s
  else:
    stmp = bef + s
  if stmp != befal:
    ans += 1
    befal = stmp
    bef = ""
  else:
    bef = stmp
print(ans)

Measured memory_bytes: 3500
#include <iostream>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  std::string s;
  std::cin >> s;

  char * wp = const_cast<char *>(s.c_str());

  if ((*(wp + 2) == *(wp + 3)) && (*(wp + 4) == *(wp + 5))) {
    std::puts("Yes");
  } else {
    std::puts("No");
  }
  return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  cout << n * n * n << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
#include <bitset>

//#include <random>
 
using namespace std;
 
 
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
const int MOD = 1e9 + 7;
const int BASE = 1327; 
typedef pair<int64, int64> pii;
const int MAXN = 100100;
const int64 LINF = 2e18; 
const int LN = 30;
int n, q, m, l;

int mas[MAXN];

void solve()
{
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &mas[i]);	
	}
	int64 ans = 1e18;
	for(int i = -100; i <= 100; ++i)
	{
		int64 cur = 0;
		for(int j = 0; j < n; ++j)
		{
			cur += (mas[j] - i) * (mas[j] - i);
		}
		ans = min(ans, cur);
	}
	printf("%lld\n", ans);
}
 

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    srand(1313);
	
	int t = 1;
	//scanf("%d", &t);
	for(int i = 0; i < t; ++i)
	{
		solve();
	}
	
    return 0;
}      

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

const string G = "GREATER";
const string L = "LESS";
const string E = "EQUAL";

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

  if(s.size()>t.size()) {
    cout << G << endl;
    return 0;
  } else if(t.size()>s.size()) {
    cout << L << endl;
    return 0;
  }

  bool equal = true;

  for(int i=0;i<s.size();i++) {
    if(s[i] > t[i]) {
      equal = false;
      cout << G << endl;
      break;
    } else if (s[i] < t[i]) {
      equal = false;
      cout << L << endl;
      break;
    }
  }

  if(equal) {
    cout << E << endl;
  }

  return 0;
}

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

string S;
int N;

int main(){
    cin >> N >> S;
    string A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int a;
    for(auto& s: S){
        for(int i = 0; i < A.length(); ++i){
            if(s == A[i]){
                a = i;
                break;
            }
        }
        s = A[(a+N)%26];
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  char s[10];
  int i,j=0,t[10];

  for(i=0;i<10;i++) {
    t[i] = 0;
  }

    for(i=0;i<10;i++) {
      s[i] = getchar();
    }


  for (i=0;i<10;i++) {
      if(s[i] == 'A'||s[i] == 'T'||s[i] == 'G'||s[i] == 'C') {
        t[j]++;
      }
      else
        j++;
  }




  for(i=0;i<9;i++) {
    t[i+1] = (t[i]>t[i+1] ? t[i]:t[i+1]);
  }

  printf("%d\n", t[9]);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        for (int i = 0;; i += 2) {
            c -= b;
            if (c <= 0) {
                cout << "Yes\n";
                break;
            }
            a -= d;
            if (a <= 0) {
                cout << "No\n";
                break;
            }
        }
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n;
int a[200005], b[200005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  map<int, int> ma;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    ma[a[i]] += 1;
  }
  map<int, int> mb;
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    mb[b[i]] += 1;
  }

  map<int, pair<int, int>> mp;
  set<pair<int, int>> st;
  for (auto iter : mb) {
    int x = iter.first;
    mp[x] = {iter.second, ma[x]};
    st.insert({min(iter.second, ma[x]), x});
  }

  bool flag = true;
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    bool find = false;
    auto iter = st.end();
    int x = a[i];
    while (iter != st.begin()) {
      iter--;
      if (iter->second != x) {
        find = true;
        break;
      }
    } 
    if (!find) {
      flag = false;
      break;
    }
    int y = iter->second;
    ans[i] = y;
    st.erase(iter);
    mp[y].first -= 1;
    //printf("%d %d\n", y, mp[y].first);
    if (mp[y].first > 0) {
      st.insert({min(mp[y].first, mp[y].second), y});
    }

    int w = min(mp[x].first, mp[x].second);
    st.erase({w, x});
    if (mp[x].second > 0) {
      mp[x].second -= 1;
    }
    if (mp[x].first > 0) {
      st.insert({min(mp[x].first, mp[x].second), x});
    }
  }
  if (flag) {
    puts("Yes");
    for (int i = 0; i < n; i++) {
      printf("%d", ans[i]);
      if (i != n - 1) {
        printf(" ");
      }
    }
    puts("");
  } else {
    puts("No");
  }
 
 
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 46252
h=int(input())
#a,b,x=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

i=0
count=1
while h>1:
    i+=1
    count+=2**i
    h=h//2

print(count)

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

#define ll long long


int main() {
	ll n;
	cin >> n;
	ll sqr = sqrt(n);
	
	for(int i = sqr; i > 0; i--) {
		if(n%i == 0) {
			printf("%lld\n", i+n/i-2);
			return 0;
		}
	}
}

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}

void NO() {
    cout << "Impossible" << endl;
    exit(0);
}

void YES() {
    cout << "Possible" << endl;
    exit(0);
}

int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    multiset<int> s;
    int n;
    cin >> n;
    int mx = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        s.insert(x);
        mx = max(mx, x);
    }
    if(s.count(mx) == 1) NO();
    s.erase(s.find(mx));
    s.erase(s.find(mx));

    for(int x = 1; x < mx; x++) {
        int y = max(x, mx - x);
        if(s.find(y) == s.end()) NO();
        s.erase(s.find(y));
    }
    while(s.size() > 0) {
        auto x = *s.begin();
        if(x < (mx+1)/2 + 1) NO();
        s.erase(x);
    }
    YES();
}





Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    int[] _weight, _value;
    long[,] _dp;

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        int w = cin.nextInt();

        _weight = new int[n + 1];
        _value = new int[n + 1];

        for (int i = 1; i <= n; ++i)
        {
            _weight[i] = cin.nextInt();
            _value[i] = cin.nextInt();
        }

        _dp = new long[n + 1, w + 1];

        for (int index = 1; index <= n; ++index)
        {
            for (int totalWeight = 1; totalWeight <= w; ++totalWeight)
            {
                if (totalWeight - _weight[index] >= 0)
                {
                    //_dp[index, totalWeight] = Math.Max(_dp[index, totalWeight], _dp[index - 1, totalWeight - _weight[index]] + _value[index]);
                    _dp[index, totalWeight] = _dp[index - 1, totalWeight - _weight[index]] + _value[index];
                }

                _dp[index, totalWeight] = Math.Max(_dp[index, totalWeight], _dp[index - 1, totalWeight]);
            }

        }

        Console.WriteLine(_dp[n, w]);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

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

	int N; cin >> N;
	long long a[100010], m[100010];
	long long su = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		su += a[i];
	}
	m[0] = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		m[(i + 2) % N] = 2 * (a[(i + 1) % N] - a[i % N]) + m[i % N];
		su -= m[(i + 2) % N];
	}
	su /= N;
	for (int i = 0; i < N; i++) {
		cout << su + m[i] << " ";
	}
}

Measured memory_bytes: 2944
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
   //	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	
  //  console.log(a,b);
    var c = 6 -(a+b);
    console.log(c);

	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(void){
  int n; cin >> n;
  vector<int> vec(n);
  rep(i,n){
    int x; cin >> x;
    vec.at(i)=x-1;
  }

  int now = 0,c=0;
  while(true){
    if(now==1){
      cout << c << endl;
      return 0;
    }

    if(c>=n){
      puts("-1");
      return 0;
    }

    c++;
    now=vec.at(now);
  }
}

Measured memory_bytes: 640
A, B, K = map(int, input().split())

if K<=A:
  print(A-K, B)
elif A<K<=(A+B):
  print(0, B-(K-A))
else:
  print(0,0)
"""
for k in range(K):
  if A>0 and B!=0:
    A+=-1
  elif A==0 and B>0:
    B+=-1
  elif A==0 & B==0:
    break
print(A, B)
"""



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

const int MAX_N = 20;
int a[MAX_N];
int n;
bool make(int i,int sum,int m){
    if(i>n) return false;
    if(sum == m) return true;
    
    
    if(make(i+1,sum+a[i],m)) return true;
    
    if(make(i+1,sum,m)) return true;
    
    return false;
}
int main(int argc, const char * argv[]) {
    int q;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    cin >> q;
    int m[q];
    for(int i=0;i<q;i++)
        cin >> m[i];
    
    for(int i=0;i<q;i++){
        if(make(0,0,m[i]))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
import collections

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
c = collections.Counter(dists)
for K in range(1,N):
    print(c[K])

Measured memory_bytes: 117844
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using lond = long double;
lond pi(void) {
 return atan(1.0) * 4.0;
}
#define PI 3.14159265358979323846264338327950L
//const double PI = acos(-1);
int main(){
	lond A,B,H,M;
	cin >> A >> B >> H >> M;
	lond ans;
	lond d_h,d_m;//lint
	d_h = (lond)(H * 60.0 + M) * 0.5;
	//d_h = (lond)(H * 60 + M)/720 * 360;//上のと一緒
	//d_h = (lond)(H * 60 + M)/720 * 2*PI;
	d_m = (lond)(M * 6.0);
	//d_m = M/60 * 360;
	//d_m = M/60 * 2*PI;
	// if (d_h >= (lond)360)
	// 	d_h = (lond)(d_h % (lond)360);
	// if (d_m >= 360.0)
	// 	d_m = (lond)(d_m % (lond)360);

	lond d_a = abs(d_h - d_m);//シータ
	// if (d_a > 18 0)
	// 	d_a = 360 - d_a;
	//cout << d_a << endl;
	lond rad = d_a * PI/180;
	cout << fixed << setprecision(20);
	ans = sqrt((lond)(B*B + A*A) - (lond)(2*A*B)*cos(rad));//度数からラジアンにしてcosに入れる
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4132
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b, c, d;
int cnt1, cnt2, cnt3;
int ta;

signed main() {
	cin >> a >> b >> c >> d;
	cnt1 = b / c - (a - 1) / c;
	cnt2 = b / d - (a - 1) / d;
	ta = lcm(c, d);
	cnt3 = b / ta - (a - 1) / ta;
	cout << (b - (a - 1)) - cnt1 - cnt2 + cnt3 << endl;
}

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

const long long INF = LLONG_MAX;

int main()
{
	int n, k = 3;
	cin >> n;
	
	vector < vector < long long > > v(n);
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < k; j++)
		{
			long long a;
			cin >> a;
			v[i].push_back(a);
		}
	}
	
	long long dp[n][k];
	
	for(int i = 0; i < k; i++)
		dp[0][i] = v[0][i];
	
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < k; j++)
		{
			dp[i][j] = 0;
		}
	}
	
	for(int i = 0; i < n - 1; i++)
	{
		for(int j = 0; j < k; j++)
		{
			for(int j2 = 0; j2 < k; j2++)
			{
				if(j == j2)
					continue;
				
				dp[i + 1][j2] = max(dp[i + 1][j2], dp[i][j] + v[i + 1][j2]);
			}
		}
	}
	
	long long res = 0;
	
	for(int i = 0; i < k; i++)
	{
		res = max(res, dp[n - 1][i]);
	}
	
	cout << res;
	
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll INF = 1e10;

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h) co("Yes");
	else co("No");
	return 0;
}


Measured memory_bytes: 3116