akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<pair<int,int>> A(N);
    for (int i=0;i<N;i++) cin >> A[i].first >> A[i].second;
    vector<int> order(N);
    for (int i=0;i<N;i++) order[i] = i;
    double S = 0;
    int dx,dy;
    do{
        for (int i=0;i<N-1;i++){
            dx = A[order[i]].first - A[order[i+1]].first;
            dy = A[order[i]].second - A[order[i+1]].second; 
            S += sqrt(pow(dx,2)+pow(dy,2));
        }
    } while (next_permutation(order.begin(),order.end()));
    int cnt = 1;
    while(N >=1){
        cnt *= N;
        N--;
    }
    cout << fixed << setprecision(8) << double(S/cnt) << endl;
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 1; //必ず１種類はあるからね

    if(b != a)
    {
        ans ++;
    }
    if (c != a && c != b)
    {
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
 
#define ll long long
 
int main()
{
    ll X, K, D;
    std::cin >> X >> K >> D;
 
    ll sum = 0;
 
    if(X < 0) {
        X = X * (-1);
    }
    if(X == 0) {
        if(K % 2 == 0) {
            std::cout << sum << std::endl;
        }
        else {
            std::cout << D << std::endl;
        }
    }
    else {
        if(X % D == 0) {
            ll sho = X / D;
            if (sho >= K) {
                sum = X - K * D;
                std::cout << sum << std::endl;
            }
            else {
                sum = 0;
                K = K - sho;
                if(K%2 == 0) {
                    std::cout << sum << std::endl;
                }
                else {
                    std::cout << D << std::endl;
                }
            }
        }
        else {
            ll sho = X / D;
            if(sho >= K){
                sum = X - K * D;
                std::cout << sum << std::endl;
            }
            else {
                sum = X - sho * D;
                K = K - sho;
                if(K % 2 == 0) {
                    std::cout << sum << std::endl;
                }
                else {
                    sum = sum - D;
                    if(sum < 0) {
                        sum = sum * (-1);
                    }
                    std::cout << sum << std::endl;
                }
            }
        }
    }
}

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

int main(){
    int n;  cin>>n;
    vector<int> l(n);
    
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    
    sort(l.begin(),l.end());
    
    for(int i=1;i<n-1;i++){
        l[i]+=l[i-1];
    }
    if(l[n-2]>l[n-1])   cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, k; cin >> n >> k;
	vector<int> a(n + 2); rep(i, 1, n)cin >> a[i];
	
	zep(j, 0, k){
		vector<int> b(n + 2, 0);
		
		rep(i, 1, n){
			b[max(1LL, i - a[i])] += 1;
			b[min(n + 1, i + a[i] + 1)] -= 1;
		}
		
		bool fin = true;
		rep(i, 1, n){
			b[i] += b[i - 1];
			if(b[i] != n)fin = false;
		}
		a.swap(b);
	
		if(fin)break;
	}
	printa(a, 1, n)
	
	return 0;
}

Measured memory_bytes: 4756
import itertools
n = int(input())
p = list(map(int, input().split()))
a  = sorted(p)
q = list(map(int, input().split()))
cntp = 0
cntq = 0
cnt=0
for i in itertools.permutations(a):
  cnt+=1
  if p==list(i):
    cntp=cnt
  if q==list(i):
    cntq = cnt
print(abs(cntp-cntq))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if (s=="SUN")
	{
		cout<<7<<endl;
	}
	if (s=="MON")
	{
		cout<<6<<endl;
	}
	if (s=="TUE")
	{
		cout<<5<<endl;
	}
	if (s=="WED")
	{
		cout<<4<<endl;
	}
	if (s=="THU")
	{
		cout<<3<<endl;
	}
	if (s=="FRI")
	{
		cout<<2<<endl;
	}
	if (s=="SAT")
	{
		cout<<1<<endl;
	}
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
tot = 1
if 0 in A:
    print(0)
    exit()
else:
    for i in range(len(A)):
        tot=tot*A[i]
        if(tot>10**18):
            print(-1)
            exit()
print(tot)
exit()

Measured memory_bytes: 21656
#include <iostream>

#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 rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int x;
    cin>>x;
    int ans;
    if(x>=1800) ans = 1;
    else if(x>=1600) ans = 2;
    else if(x>=1400) ans = 3;
    else if(x>=1200) ans = 4;
    else if(x>=1000) ans = 5;
    else if(x>=800) ans = 6;
    else if(x>=600) ans = 7;
    else ans = 8;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll f(ll num){
	ll cnt=0;
	while(num){
		num/=10;
		cnt++;
	}
	return cnt;
}

int main(){
	ll n;
	cin >> n;
	ll ans,cnt=0;
	arep(1,i,sqrt(n)+1){
		if(n%i==0){
			if(cnt==0){
				cnt++;
				ans=f(n/i);
			}else{
				if(ans>f(n/i))
					ans=f(n/i);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3684
animals_and_legs=input()
list=animals_and_legs.split()
animals=int(list[0])
legs=int(list[1])
j=animals
i=0
something=True
while i<=animals:
    if i*4+j*2==legs:
        print("Yes")
        something=False
        break
    i=i+1
    j=j-1
if something is True:
    print("No")



Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

//マクロ
#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 INF 999999999

//debug
#define dump(x) cout << #x << " = " << (x) << endl;

//配列の要素を順番に出力
void trace(int A[], int N){
    int i;
    for (i = 0; i < N; i++){
        if (i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

///////////////////////////////////////////////////////////////
//ALDS1_2_c
//Stable Sort
struct Card {char suit, value;};

void bubble(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        for (int j = N-1; j >= i; j--){
            if (A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}


void selection(struct Card A[], int N){
    int i, j, minj;
    for (i=0; i<N; i++){
        minj = i;
        for (j=i; j<N; j++){
            if (A[j].value < A[minj].value){
                minj = j;
            }
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }  
}

void print_card(struct Card A[], int N){
    for (int i= 0; i < N; i++){
        if (i > 0) printf(" ");
        printf("%c%c", A[i].suit, A[i].value);
    }
    printf("\n");
}

bool is_stable(struct Card c1[], struct Card c2[], int N){
    for (int i = 0; i < N; i++){
        if (c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

int main(){ 
    Card c1[100], c2[100];
    int N;
    char ch;
    
    scanf("%d", &N);
    REP(i, N) scanf("%s", &c1[i].suit, &c1[i].value);
    REP(i, N) c2[i] = c1[i];
    
    bubble(c1, N);
    selection(c2, N);
    
    print_card(c1, N);
    printf("Stable\n");
    
    print_card(c2, N);
    if (is_stable(c1, c2, N)) printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int R, G, B, N, ans=0;
  cin >> R >> G >> B >> N;

  for(int r=0; r<=N; r+=R)
  {
    for(int g=0; r+g<=N; g+=G)
    {
      int rem = N-r-g;
      if(rem%B == 0)
      {
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

class Puddle
{
private:
	int totalAmount;
	int puddleNum;
	int puddles[10000];
	string inputData;

	void _makeData() {
		size_t it = 0;
		int depth = 0;
		int tempVolume = 0;
		bool bHarfVolume = false;
		bool bInPuddle = false;

		while(inputData.length() > it) {
			switch(inputData[it]) {
				case '\\':
					if(0 == depth) {
						switch(isPuddle(it)) {
							case 1:
								depth++;
								bInPuddle = true;
								bHarfVolume = true;
								break;
							case -1:
								return;
							default:
								break;
						}

					} else {
						tempVolume += depth++;
						if(bHarfVolume) {
							tempVolume++;
							bHarfVolume = false;
						} else {
							bHarfVolume = true;
						}
					}
					break;
				case '_':
					if(0 < depth) {
						tempVolume += depth;
					}
					break;
				case '/':
					if(0 < depth) {
						tempVolume += --depth;
						if(bHarfVolume) {
							tempVolume++;
							bHarfVolume = false;
						} else {
							bHarfVolume = true;
						}
						if(0 == depth) {
							puddles[puddleNum++] = tempVolume;
							tempVolume = 0;
							depth = 0;
						}
					}
					break;
				default:
					break;
			}
			it++;
		}
	}

	int isPuddle(size_t it) {
		int depth = 0;
		bool bExistPuddle = false;
		int size = inputData.length();

		for(size_t i = it; i < inputData.length(); i++) {
			switch(inputData[i]) {
				case '\\':
					depth++;
					break;
				case '/':
					bExistPuddle = true;
					depth--;
					if(0 == depth) {
						return 1;
					}
					break;
			}
		}
		return bExistPuddle ? 0 : -1;
	}

public:
	Puddle()
	: totalAmount(0)
	, puddleNum(0) {
		memset(puddles, 0, sizeof(puddles));
	}

	void makeData(string str) {
		inputData = str;
		_makeData();
		for(int i = 0; i < puddleNum; i++){
			totalAmount += puddles[i];
		}
	}

	void printData() {
		cout << totalAmount << endl
		     << puddleNum;

		for(int i = 0; i < puddleNum; ++i) {
			cout << " " << puddles[i];
		}
		cout << endl;
	}
};

int main() {
	string str;
	Puddle puddle;

	cin >> str;
	puddle.makeData(str);
	puddle.printData();

	return 0;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
  
    ll n;
    cin>>n;
    while(n>0)
    {
        ll r = n%10;
        if(r == 7) {cout<<"Yes";return 0;}
        n/=10;
    }
    cout<<"No";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=61
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n;
  cin>>n;
  if(n>=64){cout<<64<<endl;return 0;}
  else if(n>=32){cout<<32<<endl;return 0;}
  else if(n>=16){cout<<16<<endl;return 0;}
  else if(n>=8){cout<<8<<endl;return 0;}
  else if(n>=4){cout<<4<<endl;return 0;}
  else if(n>=2){cout<<2<<endl;return 0;}
         else cout<<1<<endl;        
}


Measured memory_bytes: 256
N=int(input())
P=[(0,0) for i in range(N)]
for i in range(N):
    x,l=map(int,input().split())
    P[i]=(x-l,x+l)
P.sort(key=lambda y:y[1])
#print(P)
ans=1
t=P[0][1]
for i in range(1,N):
    if t<=P[i][0]:
        ans+=1
        t=P[i][1]
print(ans)

Measured memory_bytes: 52640
#include <iostream>

using namespace std;
typedef long long ll;
const int maxn = 405;
ll dp[maxn][maxn];
ll a[maxn], s[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
        s[i] = s[i-1] + a[i];
    }
    for(int d = 1; d <= n; d++){
        for(int l = 1; l+d <= n; l++){
            int r = d+l;
            dp[l][r] = 1e18 + 5;
            for(int i = l; i+1 <= r; i++){
                dp[l][r] = min(dp[l][r],
                               dp[l][i] + dp[i+1][r] + s[r] - s[l-1]);
            }
        }
    }
    cout<<dp[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 1536
main :: IO()
main = do
    n <- getLine
    ls <- map read . words <$> getLine
    print $ countDiv ls

countDiv :: [Int] -> Int
countDiv [] = 0
countDiv ls
    | a == 0				= 1 + countDiv [div x 2|x <- ls]
    | otherwise				= 0
    where a = length [x | x <- ls, mod x 2 /= 0]


Measured memory_bytes: 1020
def main():
    n = int(input())
    a = list(map(int, input().split()))
    f = False
    for v in a:
        if v == 0:
            f = True
    if f:
        print(0)
    else:
        ans = 1
        for v in a:
            ans *= v
            if ans > 10**18:
                break
        if ans <= 10**18:
            print(ans)
        else:
            print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21708
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	divisoble := 0
	for i := range as {
		divisoble += numPrime(as[i], 2)
	}
	return divisoble
}

func numPrime(n, p int) (ex int) {
	c := n
	for c > 0 && c%p == 0 {
		ex++
		c /= p
	}
	return ex
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2112
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    xy = [list(map(int, input().split())) for _ in range(n)]
    x = sorted(xy, key=lambda a: a[0])
    y = sorted(xy, key=lambda a: a[1])

    res = 10**20
    for l in range(n):
        for r in range(l+1, n):
            for b in range(n):
                for t in range(b+1, n):
                    cnt = 0
                    for vx, vy in x[l:r+1]:
                        if y[b][1] <= vy <= y[t][1]:
                            cnt += 1
                        if cnt >= k:
                            res = min(res, (x[r][0]-x[l][0])*(y[t][1]-y[b][1]))
                            break
    print(res)

if __name__ == '__main__':
    main()



Measured memory_bytes: 45404
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;

string S;

ll N, K;
ll d[100005];
ll ans;
bool flag;


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> N;

	FOR(i, 0, N) {
		cin >> d[i];
	}

	sort(d, d + N);

	cout << d[N / 2] - d[N / 2-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#define ll long long

const ll mod = (ll)1e9 + 7;

using namespace std;

signed main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i)
		cin >> h.at(i);

	int ans = 0;
	int tmp = 0;
	int now = h[0];
	for (int i = 1; i < n; ++i) {
		if (now >= h[i]) {
			tmp++;
			now = h[i];
		}
		else {
			ans = max(ans, tmp);
			tmp = 0;
			now = h[i];
		}
	}
	ans = max(ans, tmp);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
N = int(input())
K = int(input())
x = list(map(int, input().split()))
sum = 0

for i in range(len(x)):
  dist_a = x[i] * 2
  dist_b = abs(K - x[i]) * 2
  if dist_a < dist_b:
    sum += dist_a
  else:
    sum += dist_b

print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#define C 35
#define N 100005
using namespace std;

int n, c, cnt, mx;
bool v[C][N];
int main()
{
	int i, j, t1, t2, t3;
	cin >> n >> c;
	while (n--) {
		scanf("%d %d %d", &t1, &t2, &t3);
		for (i = t1; i <= t2; i++) v[t3][i] = 1;
	}
	for (i = 1; i < N; i++) {
		for (j = 1, cnt = 0; j <= c; j++) cnt += v[j][i];
		mx = max(mx, cnt);
	}
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int H,W;
  cin >> H >> W;
  vector<string> S(H);
  for(int a = 0;a < H;a++){
    cin >> S[a];
  }
  int k = 0;
  int result = 0;
  vector<vector<int>> U(H,vector<int>(W,0));
  vector<vector<int>> D(H,vector<int>(W,0));
  vector<vector<int>> L(H,vector<int>(W,0));
  vector<vector<int>> R(H,vector<int>(W,0));
  //左
  for(int a = 0;a < H;a++){
    for(int b = 0;b < W;b++){
      if(S[a][b] == '#')L[a][b] = -1;
      if(b != 0&&S[a][b] == '.'){
       L[a][b] = L[a][b-1] + 1; 
      }
      
    }
  }
  //右
  for(int a = 0;a < H;a++){
    for(int b = W-1;b >= 0;b--){
      if(S[a][b] == '#')R[a][b] = -1;
      if(b != W-1&&S[a][b] == '.'){
       R[a][b] = R[a][b+1] + 1; 
      }
      
    }
  }
  //上
  for(int a = 0;a < W;a++){
    for(int b = 0;b < H;b++){
      if(S[b][a] == '#')U[b][a] = -1;
      if(b != 0&&S[b][a] == '.'){
       U[b][a] = U[b-1][a] + 1; 
      }
      
    }
  }
  //下
  for(int a = 0;a < W;a++){
    for(int b = H-1;b >= 0;b--){
      if(S[b][a] == '#')D[b][a] = -1;
      if(b != H-1&&S[b][a] == '.'){
       D[b][a] += D[b+1][a] + 1; 
      }
      
    }
  }
  
  for(int a = 0;a < H;a++){
    for(int b = 0;b < W;b++){
      if(S[a][b] == '.'){
      result = max(result,1 + L[a][b] + R[a][b] + D[a][b] + U[a][b]);
      }
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 73652
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,k = iim()
A = iil()
'''
A = [0]*200000
上記でtryしても41回で全て明るさ200000になる
'''

def imos(l):
    n = len(l)
    tmp = [0]*n
    for i,item in enumerate(l):
        l = max(0,i-item)
        r = min(n-1,i+item)
        tmp[l] += 1
        if r+1 < n:
            tmp[r+1] -= 1
    for i in range(1,n):
        tmp[i] += tmp[i-1]
    return tmp

for _ in range(min(k,100)):
    A = imos(A)
#    print(_,min(A))

print(*A)

Measured memory_bytes: 171668
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x, y;
	if (c % b == 0) x = c / b;
	else x = c / b + 1;
	if (a % d == 0) y = a / d;
	else y = a / d + 1;
	if (x <= y) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3596
N, K = gets.split.map(&:to_i)

h = Hash.new(0)
readlines.each do |l|
  a, b = l.split.map(&:to_i)
  h[a] += b
end
k, ans = K, 1
until k <= h[ans] do
  k -= h[ans]
  ans += 1
end
puts ans

Measured memory_bytes: 14076
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<(n);i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int>l(q);
    vector<int>r(q);
    rep(i, q){
        cin>>l[i]>>r[i];
    }
    int cnt=0;
    vector<int> frag(n, 0);
    rep(i, n){
        if(s[i]=='A'){
            if(s[i+1]=='C') {
                frag[i]=1;
                i+=1;
            }
        }
    }
    vector<int>sum(n);
    rep(i, n){
        sum[i+1]=sum[i]+frag[i];
    }
    rep(i, q){
        int ans=sum[r[i]-1]-sum[l[i]-1];
        cout<<ans<<endl;
    }

    
}

Measured memory_bytes: 2560
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1]):
        count += 1
    else:
        continue
print(count)

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

int main(){
    int i, j, k;
    int N, X[1000], Y[1000], S[1000];
    cin >> N;
    for(i=0; i<N; i++){
        cin >> X[i] >> Y[i];
        S[i] = X[i] + Y[i];
        if((S[i] - S[0]) % 2 != 0){
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> values;
    for(i=30; i>=0; i--) values.push_back(1<<i);
    if(S[0] % 2 == 0) values.push_back(1);
    int M = values.size();
    cout << M << endl;
    for(i=0; i<M; i++) cout << values[i] << " \n"[i==M-1];

    for(i=0; i<N; i++){
        int xpy = X[i] + Y[i], xmy = X[i] - Y[i];
        for(auto&& v : values){
            if(xpy >= 0){
                if(xmy >= 0){
                    cout << "R";
                    xpy -= v;
                    xmy -= v;
                }else{
                    cout << "U";
                    xpy -= v;
                    xmy += v;
                }
            }else{
                if(xmy >= 0){
                    cout << "D";
                    xpy += v;
                    xmy -= v;
                }else{
                    cout << "L";
                    xpy += v;
                    xmy += v;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector <ll> a(n),b(n);
    vector <vector <int>> aa(n,vector <int> (31));
    rep(i,n){
        cin >> a[i];
        rep(j,31){
            aa[i][j]=(a[i]>>j)&1;
        }
    }
    vector <vector <int>> c(n,vector <int> (31)),d(n,vector <int> (31));

    b[0]=0;
    ll bb=0;
    rep(i,n-1){
        b[i+1]=(a[i]^a[i+1])^b[i];
        bb=bb^b[i+1];
    }

    ll bb2;
    bb2=bb^a[0];

    rep(i,n){
        b[i]=b[i]^bb2;
        cout << b[i] << endl;
    }

    


    

    return 0;
}

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

const ll mod = 1e9+7;

int main() {
  int n; cin >> n;
  vector<ll> a(n); rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 61) {
    ll m = 0, s = (1ll<<i);
    rep(j, n) if (a[j] & s) m++;
    ans += m * (n - m) % mod * (s % mod) % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

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

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

    if(a > 0){
        cout << "Positive" << endl;
        return 0;
    }else if(a == 0){
        cout << "Zero" << endl;
        return 0;
    }else if(a < 0 && b >= 0){
        cout << "Zero" << endl;
        return 0;
    }

    if(abs(a - b) % 2 == 0){
        cout << "Negative" << endl;
    }else{
        cout << "Positive" << endl;
    }



    return 0;
}

Measured memory_bytes: 3624
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 12/9/2018, 10:40:14 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 100000000000000;

ll f(ll b, ll n)
{
  if (n < b)
  {
    return n;
  }
  return f(b, n / b) + n % b;
}

ll N, S;

int main()
{
  cin >> N >> S;
  if (N < S)
  {
    cout << -1 << endl;
    return 0;
  }
  if (N == S)
  {
    cout << N + 1 << endl;
    return 0;
  }
  for (auto b = 2LL; b * b <= N; b++)
  {
    if (f(b, N) == S)
    {
      cout << b << endl;
      return 0;
    }
  }
  ll ans = infty;
  for (auto p = 1LL; p * p <= N; p++)
  {
    ll q = S - p;
    if ((N - q) % p != 0)
    {
      continue;
    }
    ll b = (N - q) / p;
    if (!(0 <= q && q < b && p < b))
    {
      continue;
    }
    if (f(b, N) == S)
    {
      ans = min(ans, b);
    }
  }
  if (ans < infty)
  {
    cout << ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


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

using namespace std;

const int64_t INF = 1LL << 59;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  int64_t L;
  cin >> N >> M >> L;
  vector<vector<int64_t>> dp(N, vector<int64_t>(N, INF));
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dp[a][b] = dp[b][a] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        chmin(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = dp[i][j] <= L ? 1 : INF;
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        chmin(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    if (dp[s][t] == INF) {
      cout << -1 << '\n';
    } else {
      cout << dp[s][t] - 1 << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 1280
N = int(input())
T = [int(t) for t in input().split()]
A = [int(a) for a in input().split()]

if(T[N-1]!=A[0]):
    print(0)
    exit()

P = 1

for i in range(1,N-1):
    t = 1 if T[i-1]<T[i] else T[i]
    a = 1 if A[i]>A[i+1] else A[i]
    if(t==1):
        if(T[i]>A[i]):
            print(0)
            exit()
    if(a==1):
        if(A[i]>T[i]):
            print(0)
            exit()
    P*=min(t,a)
    P%=1000000007

print(P)

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

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  string s[h];
  for(auto&& ss:s)cin >> ss;
  const int INF = 100000;
  vector<vector<int>> d(h, vector<int>(w, INF)); 
  d[0][0] = 0;
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  const int di[4] = {1, -1, 0, 0};
  const int dj[4] = {0, 0, 1, -1};
  while(!q.empty()){
    int i = q.front().first, j = q.front().second;
    q.pop();
    if(i == h-1 && j == w-1)break;
    for(int k=0;k<4;k++){
      int newi = i + di[k], newj = j + dj[k];
      if(newi < 0 || newi >= h || newj < 0 || newj >= w)continue;
      if(s[newi][newj] == '.' && d[i][j] + 1 < d[newi][newj]){
        d[newi][newj] = d[i][j] + 1;
        q.emplace(newi, newj);
      }
    }
  }
  if(d[h-1][w-1] == INF)cout << -1 << endl;
  else{
    int sh = 0;
    for(auto&& ss:s)for(auto&& c:ss)sh += (c == '#');
    cout << h * w - sh - d[h-1][w-1] - 1 << endl;
  }
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A >= B && A >= C) {
    cout << A * 10 + B + C << endl;
  }
  else if (B >= A && B >= C) {
    cout << B * 10 + A + C << endl;
  }
  else {
    cout << C * 10 + A + B << endl;
  }
}

Measured memory_bytes: 3548
#include<cstring>
#include<algorithm>
#include<cstdio>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
typedef long long LL;
typedef double dob;
using namespace std;
const int P=1000000007;
const int N=1010;
int c[N][N],f[N],g[N],n,k,a[N];
void upd(int &x,int y){x=(x+y)%P;}
int C(int x,int y){return c[x][y];}
int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,k) scanf("%d",a+i);
	f[0]=1;
	rep(i,0,1000) c[i][i]=c[i][0]=1;
	rep(i,1,1000) rep(j,1,i-1) c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
	rep(i,1,k){
		memset(g,0,sizeof(g));
		rep(j,0,n) if (f[j]){
			rep(t,0,min(a[i],n-j)){
				upd(g[j+t],(LL)f[j]*C(n-j,t)%P*C(n-t,a[i]-t)%P);
			}
		}
		swap(f,g);
	}
	f[n]=(f[n]%P+P)%P;
	printf("%d\n",f[n]); 
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <math.h>

using namespace std;
int get_taste(int i,int L){
	int taste;
	taste = L+i-1;
	return taste;
}

int cal(int N,int L){
	int i,sum=0,min_taste=100;
	for(i=1;i<=N;i++){
		sum += get_taste(i,L);
		if(abs(min_taste) > abs(get_taste(i,L)))
			min_taste = get_taste(i,L);
	}
	sum -= min_taste;
	return sum;
}

int main(){
	int N,L,sum=0;
	
	cin >> N;
	cin >> L;

	sum = cal(N,L);
	cout << sum << endl;

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int N;
	cin >> N;
  	cout << 180*(N-2) <<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] nums = new int[n+2];
		int cnt = 0;
		
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			nums[i+1] = num;
			if (num == (i+1)) { cnt++; }
		}
		
		if (cnt == 0) {
			System.out.println(cnt);
			System.exit(0);
		}
		cnt = 0;
		
		for (int i = 1; i <= n; i++) {
			if (nums[i] == i) {
				cnt++;
				int tmp = nums[i];
				nums[i] = nums[i+1];
				nums[i+1] = tmp;
			}
		}
		
		System.out.println(cnt);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

const std::vector<std::vector<int>>
    lines = {{0, 1, 2},
             {3, 4, 5},
             {6, 7, 8},
             {0, 3, 6},
             {1, 4, 7},
             {2, 5, 8},
             {0, 4, 8},
             {2, 4, 6}};

void solve() {
    std::vector<int> pos(100, -1);
    for (int i = 0; i < 9; ++i) {
        int x;
        std::cin >> x;
        pos[--x] = i;
    }

    std::vector<bool> filled(9, false);
    int n;
    std::cin >> n;
    while (n--) {
        int x;
        std::cin >> x;
        --x;
        if (pos[x] != -1) filled[pos[x]] = true;
    }

    for (auto& l : lines) {
        bool ok = true;
        for (auto x : l) {
            if (!filled[x]) ok = false;
        }
        if (ok) {
            std::cout << "Yes" << std::endl;
            return;
        }
    }
    std::cout << "No" << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main(){
  char s[4];
  scanf("%s", s);
  int a;
  if(s[0]=='R' && s[1]=='R' && s[2]=='R') a=3;
  if(s[0]=='R' && s[1]=='R' && s[2]=='S') a=2;
  if(s[0]=='R' && s[1]=='S' && s[2]=='R') a=1;
  if(s[0]=='R' && s[1]=='S' && s[2]=='S') a=1;
  if(s[0]=='S' && s[1]=='R' && s[2]=='R') a=2;
  if(s[0]=='S' && s[1]=='R' && s[2]=='S') a=1;
  if(s[0]=='S' && s[1]=='S' && s[2]=='R') a=1;
  if(s[0]=='S' && s[1]=='S' && s[2]=='S') a=0;
  printf("%d", a);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

ll func(ll a, ll n) {
	if (n == 1) {
		return a;
	}
	ll p = 1000000000 + 7;
	ll num;
	if (n % 2 == 0) {
		num = func(a, n / 2);
		num *= num;
		num %= p;
		return num;
	}
	else {
		num = func(a, (n - 1) / 2);
		num *= num;
		num %= p;
		num *= a;
		num %= p;
		return num;
	}
}

int main() {

	ll x, y;
	cin >> x >> y;
	if (x > 2 * y or 2 * x < y) {
		cout << 0 << endl;
		return 0;
	}

	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}

	ll n, m;
	n = (x + y) / 3;
	m = min(x - n, y - n);
	ll s = 1;

	for (ll i = n-m+1; i < n+1; i++)
	{
		s *= i;
		s %= prime;
	}

	for (ll i = 2; i < m+1; i++)
	{
		s *= func(i, prime - 2);
		s %= prime;
	}

	cout << s << endl;

	return 0;
}


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

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

using namespace std;

int main(){
  int n,k;cin>>n>>k;

  priority_queue<int, vector<int>, greater<int>> q;
  rep(i,n){
    int t;cin>>t;
    q.push(t);
  }
  rep(i,n-k)q.pop();
  int result=0;
  rep(i,k){
    result += q.top();
    q.pop();
  }

  cout<<result;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    //経路が有限であれば、交換可能
    //UnionFindで同じグループに属していれば、交換可能->5,4,2,1,3

    ll N,M;
    cin >> N >> M;
    vector <ll> p(N);
    REP(i,N)
    {
        cin >> p[i];
        --p[i];
    }


    UnionFind uf(N);

    REP(i,M)
    {
        int x,y;
        cin >> x >> y;
        --x;--y;
        //結合
        uf.unite(x,y);
    }

    int res = 0;
    REP(i,N)
    {
        if(uf.same(i, p[i]))++res;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while (true) {
        if (X <= Y) ans++;
        else break;
        X *= 2;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
def init
  x = 1
  while x <= $n
    x <<= 1
  end
  $n = x
  $arr = [0] * (2 * $n - 1)
end
 
def update(i, m)
  i += $n - 1
  $arr[i] += m
  while i > 0
    i = (i - 1) / 2
    $arr[i] = $arr[i*2+1] >= $arr[i*2+2] ? $arr[i*2+1] : $arr[i*2+2]
  end
end

def query(k)
  i = 0
  while i < $n
    i = $arr[i*2+1] >= $arr[i*2+2] ? i*2+1 : i*2+2
  end
  i
end

$n, q = gets.split.map(&:to_i)
init
q.times do
  i, m = gets.split.map(&:to_i)
  update(i, m)
  puts  "#{query($arr[0]) - $n + 1} #{$arr[0]}"
end

Measured memory_bytes: 25256
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int SHEEP = 3;
        
        boolean pos = false;
        if (A % SHEEP == 0){
            pos = true;
        }else if(B % SHEEP == 0){
            pos = true;
        }else if ((A + B) % SHEEP == 0){
            pos = true;
        }
        
        if(pos){
            System.out.println("Possible");
        }else{
            System.out.println("Impossible");
        }
        
    }
    
}


Measured memory_bytes: 23892
N = int(input())
A = list(map(int, input().split()))
afterA = [0] * N
ans = list()

for i in range(N, 0, -1):
  cnt = 0
  for j in range(2, (N//i) + 1):
    cnt += afterA[j*i-1] 
  if(cnt % 2 != A[i-1]):
    afterA[i-1] = 1 
    ans.append(i)
  
print(sum(afterA))
print(*ans)

Measured memory_bytes: 14016
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin *min_element
#define vmax *max_element
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=2e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//f ile input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;

int32_t main()
{
  IOS;
  ll n;
  cin>>n;
  vector <ll> a(n);
  forn(n)
  cin>>a[i];
  vector <ll> dp(n);
  vector <ll> dp1(n);
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(ll i=2;i<n;i++)
  {
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 2560
import re,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
A,B = LI()
S = S()
print('Yes' if re.fullmatch(pattern=r'\d{'+str(A)+'}-\d{'+str(B)+'}',string=S) else 'No')


Measured memory_bytes: 3188
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var A = Scanner.ScanEnumerable<long>().OrderByDescending(x => x).ToArray();
            var list = new List<long>();
            list.Add(0);
            list.Add(A[0]);
            var answer = 0L;
            for (var i = 1; list.Count < N; i++)
            {
                list.Add(A[i]);
                list.Add(A[i]);
            }
            answer = list.Sum();
            if (list.Count > N) answer -= list[list.Count - 1];
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

int main()
{
    int a, b, k, i, cnt = 0;
    cin >> a >> b >> k;
    for (i = 100; i >= 1; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            cnt++;
        }
        if (cnt == k)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
    
    int a_price;
    int b_price;
    int ab_price;

    int a_num;
    int b_num;

    int cost=0;

    cin >> a_price;
    cin >> b_price;
    cin >> ab_price;

    cin >> a_num;
    cin >> b_num;

    int flag1 = 0;  //Aピザ一枚とBピザ一枚の合計の方が小さいとき
    if(a_price+b_price>ab_price*2) flag1 = 1;

    if(a_price>2*ab_price) a_price=2*ab_price;
    if(b_price>2*ab_price) b_price=2*ab_price;
    
    int dif;
    int same;
    int flag2=0;
    if (a_num>b_num){
        dif = a_num - b_num; 
        same = b_num;
        flag2=1;
    }
    else{
        dif = b_num - a_num; 
        same = a_num;
    }

    if(flag1==0){
        cost += (a_price+b_price)*same;
        if(flag2==0){
            cost += dif*b_price;
        }
        else{
            cost += dif*a_price;
        }
    }

    else{
        cost += ab_price*2*same;
        if(flag2==0){
            cost += dif*b_price;
        }
        else{
            cost += dif*a_price;
        }
    }
    
    cout << cost;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: String = read().unwrap();
    let b: String = read().unwrap();
    if a.len() < b.len() {
        println!("LESS");
    } else if b.len() < a.len() {
        println!("GREATER");
    } else {
        for (mya, myb) in a.chars().zip(b.chars()) {
            let av = mya.to_digit(10);
            let bv = myb.to_digit(10);
            if av < bv {
                println!("LESS");
                return;
            } else if bv < av {
                println!("GREATER");
                return;
            }
        }
        println!("EQUAL");
    }
}


Measured memory_bytes: 2076
import java.util.*;
import java.io.*;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String[] s = in.nextLine().split(" ");
        long s1 = new Long(s[0]);
        long s2 = new Long(s[1]);
        long ss = s1 * s2;
        if (ss % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 23764