akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }
    int g = as[0];
    for(int i = 1; i < n; i++){
        g = gcd(g, as[i]);
    }
    for(int i = 0; i < n; i++){
        if(as[i] >= k && (as[i] - k) % g == 0){
            cout << "POSSIBLE" << '\n';
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << '\n';
    return 0;
}


Measured memory_bytes: 640
# import decimal
import time
time1 = time.time()

N, K = map(int, input().split())
# N = 200000
# K = 50000
A_list = list(map(int, input().split()))
# A_list = [2 for i in range(N)]
# Score_list = [1 for i in range(N+1)]

for i in range(K+1, N+1): #KからNの数字が入る
    # print(i-1)
    # print(i-2-K)
    if A_list[i-1] > A_list[i-1-K]:
        print("Yes")
    else:
        print("No")
    # if i == K:
    #     S = 1
    #     for j in range(i-K, i):
    #         S *= A_list[j]
    #     Score_list[i] = S
    # else:
    #     Score_list[i] = int(Score_list[i-1] / A_list[i-1-K])
    #     Score_list[i] *= A_list[i-1]
    # if i > K:
    #     if Score_list[i] > Score_list[i-1]:
    #         print("Yes")
    #     else:
    #         print("No")
    # # print(Score_list)

# print(Score_list)
time2 = time.time()
# print(time2-time1)


Measured memory_bytes: 94116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int n, m, q;
vector<int> a, b, c, d;

int dfs(vector<int> v) {
	if (v.size() == n) {
		int res = 0;
		rep(i, q) {
			if (v[b[i]] - v[a[i]] == c[i])  {
				res += d[i];
			}
		}
		return res;
	}
	int res = 0;
	for (int i = v[v.size()-1]; i <= m; i++) {
		vector<int> u = v;
		u.push_back(i);
		res = max(res, dfs(u));
	}
	return res;
}


int main() {
	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	rep(i,q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		vector<int> v(1, i);
		ans = max(dfs(v), ans);
	}
	cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	std::vector<char> v;
	for (int i = 0; i < s.size(); i++)
		v.push_back(s[i]);
	if (v.back() != 's') {
		v.push_back('s');
	}
	else {
		v.push_back('e');
		v.push_back('s');
	}
	for (auto x : v)
		cout << x;
}

Measured memory_bytes: 3628
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 9223372036854775807
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
	//////////////////////////////////
	stack []byte
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}


func main() {
	n:=goint()
	s := gostring()
	dp := make([][]int,n+1)
	for i,_ := range dp {
		dp[i] = make([]int, n+1)
	}
	for i:=n-1;i>=0;i--{
		for j:=n-1;j>=0;j--{
			if s[i] == s[j]{
				dp[i][j] = dp[i+1][j+1] + 1
			}
		}
	}
	ans := 0
	for i:=n-1;i>=0;i--{
		for j:=n-1;j>=0;j--{
			ans = max(ans,min(dp[i][j],abs(i-j)))
		}
	}
	fmt.Println(ans)
}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

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

int main(){
  int n,H,W,count=0;
  cin>>n>>H>>W;
  for(int i=0;i<n;i++){
    int h,w;
    cin>>h>>w;
    if(h>=H && w>=W) count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl

use utf8;
use strict;

sub ok
{
    my ($s) = @_;

    if ($s =~ m/(AGC|GAC|ACG|A.GC|AG.C)/) {
        return 0;
    }

    return 1;
}

sub solve3
{
    my %last3 = ();
    my @ACGT = ("A", "C", "G", "T");

    # リスト生成
    for (my $i = 0; $i < 64; $i++) {
        my $key;
        $key  = $ACGT[int($i / (4 ** 0) % 4)];
        $key .= $ACGT[int($i / (4 ** 1) % 4)];
        $key .= $ACGT[int($i / (4 ** 2) % 4)];
        if (&ok($key)) {
            $last3{$key} = 1;
        }
    }

    # カウント
    my $sum = 0;
    foreach my $key (keys %last3) {
        $sum += $last3{$key};
    }

    return ($sum, %last3);
}

sub solve
{
    my ($n) = @_;
    my @ACGT = ("A", "C", "G", "T");

    if ($n == 3) {
        return &solve3();
    }

    # (n - 1)のリスト生成
    my (undef, %last3) = solve($n - 1);

    # リスト生成
    my %new3 = ();
    for (my $i = 0; $i < 4; $i++) {
        my $c = $ACGT[$i];
        foreach my $key (keys %last3) {
            my $s = $key.$c;
            if (&ok($s)) {
                $new3{substr($s, -3, 3)} += $last3{$key};
                $new3{substr($s, -3, 3)} %= (1e+9 + 7);
            }
        }
    }

    # カウント
    my $sum = 0;
    foreach my $key (keys %new3) {
        $sum += $new3{$key};
        $sum %= (1e+9 + 7);
    }

    return ($sum, %new3);
}

my $n = <STDIN>;
chomp $n;

my ($ans, undef) = &solve($n);
print "$ans\n";

exit;


Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
 
const int N=1000005;
 
int a[N],n;
bool st[N];
 
bool insert(int x)
{
    for(int i=2;i*i<=x;i++)
        if(x%i==0)
        {
            while(x%i==0)x/=i;
            if(st[i])return true;
            st[i]=true;
        }
    if(x>1)
    {
        if(st[x])return true;
        st[x]=true;
    }
    return false;
}
 
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
 
int main()
{
    scanf("%d",&n);
    bool flag=true;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",a+i);
        if(insert(a[i]))flag=false;
    }
    if(flag)return puts("pairwise coprime"),0;
    int d=a[n];
    for(int i=1;i<n;i++)
    {
        d=gcd(d,a[i]);
        if(d==1)return puts("setwise coprime"),0;
    }
    puts("not coprime");
    return 0;
}

Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
 
const long INF = (1<<30);
 
int loop(int n) {
  int sum = 0;
  while(n != 0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}
 
int main() {
  int n;
  cin >> n;
  int sum = loop(n);
  
  if(n % sum == 0)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    vector<ll> x(5);
    for (ll i = 0; i < 5; i++) {
        cin >> x[i];
    }

    ll m = 10;
    ll s = 0;
    for (ll i = 0; i < 5; i++) {
        if (x[i] % 10 != 0) {
            m = min(m, x[i] % 10);
        }
        s += (x[i] % 10 == 0 ? x[i] : x[i] + 10 - x[i] % 10);
    }

    cout << s - 10 + m << endl;
}

Measured memory_bytes: 256
// abc136_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B, C;
    cin >> A >> B >> C;
    int ans = max(0, C + B - A);

    print(ans);
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
 
K = int(read())
 
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    int s,t;
    cin >> s >> t;
    s--;t--;
    vector<vector<int>> seen(n,vector<int>(3,-1));
    int kaisu =0, l=0;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        queue<int> nq;
        swap(q,nq);
        while(!nq.empty()){
            int u=nq.front();
            nq.pop();
            if(seen[u][l]==-1){
                seen[u][l] = kaisu;
                for(int nu:G[u]){
                    q.push(nu);
                }
            }
        }
        kaisu++;
        l=(l+1)%3;
    }

    int ans = seen[t][0];
    ans/=3;
    if(ans==0)ans = -1;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>

int main() {
int n, m;
std::cin >> n >> m;

int* b = new int[m];
int** A = new int*[n];
int* c = new int[n];

for(int i = 0; i < n; i++){
A[i] = new int[m];
}

for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
std::cin >> A[i][j];
}
}

for(int k = 0; k < m; k++){
std::cin >> b[k];
}

for(int l = 0; l < n; l++){
c[l] = 0;
}

for(int x = 0; x < n; x++){
for(int y = 0; y < m; y++){
c[x] += A[x][y] * b[y];
}
}

for(int z = 0; z < n; z++){
std::cout << c[z] << std::endl;
}
}

Measured memory_bytes: 3136
N, *A = map(int, open(0).read().split())
MOD = 998244353

S = sum(A)
dp0 = [0]*(S+1)
dp0[0] = 1
for a in A:
    for i in range(S, a-1, -1):
        dp0[i] = (dp0[i] + dp0[i-a]*2) % MOD
dp1 = [0]*(S+1)
dp1[0] = 1
for a in A:
    for i in range(S, a-1, -1):
        dp1[i] = (dp1[i] + dp1[i-a]) % MOD

ans = pow(3, N, MOD)
for L in range(0, S//2+1):
    ans = (ans - dp0[L]*3) % MOD
if S % 2 == 0:
    ans = (ans + dp1[S//2]*3) % MOD
print(ans)

Measured memory_bytes: 44252
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	a := make(map[int]int, n)
	var ans int
	for i := 0; i < n; i++ {
		t := r()
		if a[t] == 1 {
			a[t] = 0
			ans--
		} else {
			a[t] = 1
			ans++
		}
	}
	fmt.Println(ans)
}


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


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1; // cin >> t;
    for (; tt; tt--) {
    int n; cin >> n;
    int mod = 1e9 + 7;
    int dv = (mod + 1) / 2;
    vector<int> a(n); int sm = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sm += a[i];
        sm %= mod;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int d = (sm + mod - a[i]) % mod;
        ans += (a[i] * d) % mod;
        ans %= mod;
    }
    cout << (ans * dv) % mod << "\n";
    }
    return 0;
}




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

MOD = 1000000007  # type: int

def solve(N: int, M: int, a: "List[int]"):
    a = set(a)
    res = [0 for _ in range(N+1)]
    res[0] = 1
    if 1 in a:
        res[1] = 0
    else:
        res[1] = 1
    
    for i in range(2, N+1):
        if i in a:
            continue
        
        res[i] = (res[i-1] + res[i-2]) % MOD

    print(res[N])

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 55512
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	grid := makeInts(h+1, w+1)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			tile := getNextInt(scanner)
			if tile == 1 {
				continue
			}
			grid[i+1][j+1] = math.MaxInt32
		}
	}

	ans := 0
	for i := 0; i < w; i++ {
		for j := 0; j < h; j++ {
			if grid[j+1][i+1] == 0 {
				continue
			}

			if grid[j+1][i+1] > grid[j+1][i]+1 {
				grid[j+1][i+1] = grid[j+1][i] + 1
			}
			if grid[j+1][i+1] > grid[j][i+1]+1 {
				grid[j+1][i+1] = grid[j][i+1] + 1
			}
			if grid[j+1][i+1] > grid[j][i]+1 {
				grid[j+1][i+1] = grid[j][i] + 1
			}
			if ans < grid[j+1][i+1] {
				ans = grid[j+1][i+1]
			}
		}
	}

	fmt.Fprintln(writer, ans*ans)
	writer.Flush()
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}



Measured memory_bytes: 19052
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



long long gcd(long long a, long long b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}





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

	long long a, b, c, d ,e;
	cin >> a >> b >> c >> d;

	e = c / gcd(c, d) * d;


	auto x = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / e;
	auto y = (b) - (b) / c - (b) / d + (b) / e;

	cout << y - x << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long


int main()
{
	string S;
	cin >> S;
	string ans[] = { "Sunny","Cloudy","Rainy","Sunny" };
	for (int i = 0; i < 4; i++) {
		if (S == ans[i]) {
			cout << ans[i + 1] << endl;
			return 0;
		}
	}
}


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

using namespace std;

int main()
{
    int a,b,ans=1;
    cin>>a>>b;
    while(a){
        ans*=2;
        --a;
        if(ans>=b) break;
//        cout<<ans;
    }
    while(a){ans+=b; --a;}
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 384
# coding:utf-8

import sys
import math
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False
        prime += step
        step = 6 - step
    return True


n = II()
ans = []
for i in range(2, 55555):
    if i % 5 != 1:
        continue
    if not is_prime(i):
        continue
    ans.append(i)
    if len(ans) == n:
        break

print(*ans)


Measured memory_bytes: 3316
#include <stdio.h>

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

    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++){
	scanf("%d",&a[i][j]);
	a[i][n] += a[i][j];
	a[n][j] += a[i][j];
      }
      a[n][n] += a[i][n];
    }
    for(i = 0; i < n + 1; i++){
      for(j = 0; j < n + 1; j++){
	printf("%5d",a[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main()
{
  string s;  cin >> s;
  ll k;      cin >> k;
  
  int i = 0;
  while(s[i] == '1')
  {
    i++;
    if(i == k)
    {
      cout << 1 << endl;
      return 0;
    }
  }
  
  cout << s[i] << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const long long INF = 1e10;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back
#define mp make_pair

// lower_bound を使う練習
signed main (){
  ll n;
  cin >> n;
  vector<ll> l(n);
  for(ll & x : l){
    cin >> x;
  }
  sort(l.begin(), l.end());
  ll ans = 0;
  auto it1 = l.begin();
  auto it2 = l.begin();
  rep(i,n) {
    it2 = l.begin() + i + 1;
    Rep(j,i+1,n) {
      // a <= b <= c を仮定する。lがソート済みのとき a = l[i], b = l[j]として良い。
      //探索範囲は j+1番目 ~ end まで

      // 三角不等式から c < a + b (*)がわかっているので、
      //c >= a + b を満たす最小要素のイテレータを取得する
      auto it = lower_bound(l.begin() + j + 1, l.end(), *it1 + *it2);
      if(it != l.end()) {
        // イテレータがある場合は  最小の不等式(*)を満たさない要素のindex - 始点
        // ※ 3番目から6番目前満たす時、 7番目のitが帰ってくるので 7 - 3 = 4 でほしい値になるよ
        ans += it - (l.begin() + j + 1);
      } else {
        // イテレータが無いってことは j+1 ~ n-1は(*)を満たす。
        // (n-1) - (j+1) + 1= n - j - 1
        // ※ 3~6, 6 - 3 + 1　個が満たすよ。
        ans += n - j - 1;
      }
      ++it2;
    }
    ++it1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

int n , m;
bool dp[105][10005];

void calc (int idx , int res){

    if (idx == n){
        if (res == m){
            cout << "Yes";
            exit(0);
        }
        return;
    }

    if (res > m || dp[idx][res])
        return;

    dp[idx][res] = 1;

    calc(idx+1,res+2);
    calc(idx+1,res+4);

}

void Suhaib_Sawalha (){

    cin >> n >> m;
    calc(0,0);
    cout << "No";

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3820
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int H, W;

	cin >> H >> W;

	vector<vector<char>> map(H + 2);

	for (int i = 0; i <= H + 1; i++) {
		map[i] = vector<char>(W + 2);
		for (int j = 0; j <= W + 1; j++) {
			map[i][j] = '.';
		}
	}

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

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (map[i][j] == '#' && map[i - 1][j] == '.' && map[i + 1][j] == '.' && map[i][j - 1] == '.' && map[i][j + 1] == '.') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int tt = 0, xx = 0, yy = 0;
    bool can = true;
    for(int i = 0; i < n; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        int dx = abs(x - xx);
        int dy = abs(y - yy);
        int dt = t - tt;
        can &= dx + dy <= dt && (dt - dx + dy) % 2 == 0;
        xx = x;
        yy = y;
        tt = t;
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
s=[[]for i in range(N)]
w=0
for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    s[x].append(y)
    s[y].append(x)
from itertools import permutations
for j in permutations(range(1,N)):
    j=[0]+list(j)
    for k in range(1,N):
        if j[k] not in s[j[k-1]]:
            break
    else:
        w+=1
print(w)            
        
        


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

mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

b,w=map(int,input().split())
x=0
y=0
for i in range(1,b+w+1):
  x=(x*2+cmb(i-2,b-1))%mod
  y=(y*2+cmb(i-2,w-1))%mod
  print((mod+pow(2,i-1,mod)-x+y)*pow(pow(2,i,mod),mod-2,mod)%mod)

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

int main(void){
  int c,i;
  c = 0;
  char s[200001];
  char t[200001];  
 
  scanf("%s", &s);
  scanf("%s", &t);
  
  for(i=0;s[i]!='\0';i++){
  	if(s[i]!=t[i])
              	c = c+1;			
  	}
    printf("%d", c);    
} 


Measured memory_bytes: 2068
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(i,a,b) for(int i=a;i<b;i++)
#define incl(i,a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define PII pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

int mygcd(int a,int b)
{
    if(b==0)
        return a;
    return mygcd(b,a%b);
}

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

signed main()
{
    fatafat;
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    bool possible=true;
    for(int i=n-1;i>0;i--)
    {
        if(h[i]<h[i-1])
            h[i-1]--;
        if(h[i]<h[i-1])
        {
            possible=false;
            break;
        }
    }
    if(possible)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 1024
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	long x = readln.chomp.to!long;
	
	long i;
	for(i = 0; i * (i + 1) / 2 < x; i ++){
		
		}
	
	i.writeln;
	
	}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int child[500010][2];
ll depth[500010];
ll cnt[500010];
ll dp[500010];
int order[500010];

int main() {
  while (scanf("%d", &n) > 0) {
    MEMSET(depth, 0);
    MEMSET(cnt, 0);
    MEMSET(dp, 0);
    REP(i, n - 1) {
      int a, b;
      scanf("%d %d", &a, &b);
      a--; b--;
      child[i][0] = a; child[i][1] = b;
    }
    queue<pair<int, int> > que;
    que.push(make_pair(0, 0));
    ll ans = 0;
    int m = 0;
    dp[n - 1] = 0;
    cnt[n - 1] = 1;
    while (!que.empty()) {
      int from = que.front().first;
      int d = que.front().second;
      que.pop();
      if (from == n - 1) { ans += d; continue; }
      depth[from] = d;
      order[m++] = from;
      que.push(make_pair(child[from][0], d + 1));
      que.push(make_pair(child[from][1], d + 1));
    }
    assert(m == n - 1);
    reverse(order, order + m);
    REP(i, m) {
      int node = order[i];
      int lc = child[node][0];
      int rc = child[node][1];
      ll d = depth[node];
      cnt[node] = cnt[lc] + cnt[rc];
      dp[node] = max(dp[lc] + dp[rc], max(cnt[lc] * d + dp[rc], cnt[rc] * d + dp[lc]));
    }
    printf("%lld\n", ans - dp[0]);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll a[220000];
vector<ll> p,m,r;
int main(){
    ll n,k,ans=1,tmp=0;
    cin>>n>>k;
    rep(i,0,n){
        cin>>tmp;
        tmp>=0?p.pb(tmp):m.pb(tmp);
    }
    sort(p.rbegin(),p.rend());
    sort(m.begin(),m.end());

    if(p.size()==0&&k%2==1){
     
        irep(i,n-1,n-k)r.pb(m[i]);
    }
    else if(k==n){
        rep(i,0,p.size())r.pb(p[i]);
        rep(i,0,m.size())r.pb(m[i]);
    }
    else if(k%2==0) {
        ll cnt=0;
        ll ppos=0,mpos=0;
        while(cnt<k){
            ll pv=-1,mv=-1;
            if(p.size()>ppos+1)pv=p[ppos]*p[ppos+1];
            if(m.size()>mpos+1)mv=m[mpos]*m[mpos+1];

            if(pv>=mv){r.pb(p[ppos]);r.pb(p[ppos+1]);ppos+=2;cnt+=2;}
            else {r.pb(m[mpos]);r.pb(m[mpos+1]);mpos+=2;cnt+=2;}
        }
    }
    else{
        r.pb(p[0]);
        ll cnt=1;
        ll ppos=1,mpos=0;
        while(cnt<k){
            ll pv=-1,mv=-1;
            if(p.size()>ppos+1)pv=p[ppos]*p[ppos+1];
            if(m.size()>mpos+1)mv=m[mpos]*m[mpos+1];

            if(pv>=mv){r.pb(p[ppos]);r.pb(p[ppos+1]);ppos+=2;cnt+=2;}
            else {r.pb(m[mpos]);r.pb(m[mpos+1]);mpos+=2;cnt+=2;}
        }
    }
    rep(i,0,r.size())ans=(ans*r[i])%mod;
    cout<<(mod+ans)%mod<<endl;

  

}




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

int main()
{
	cout << fixed << setprecision(10);

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

	double n;
	cin >> n;
	cout << 2 * n * 3.14;

	return 0;
}


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

int a,v,b,w,t;

signed main()
{
	cin>>a>>v>>b>>w>>t;
	if (abs(a-b)<=t*(v-w))  cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
    int A,B,C,D,E=0;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    while(A>0 && C>0)
    {
      if(E%2 == 0)
      {
        C=C-B;
        E++;
      }
      else
      {
        A=A-D;
        E++;
      }
    }
    if(A<=0)
    {
      printf("No\n");
    }
    else
    {
      printf("Yes\n");
    }
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<string> grid(n);
    for (int i = 0; i < n; ++i) cin >> grid[i];
    bool fl = true;
    for (int i = 0; i < n; ++i) fl &= count(grid[i].begin(), grid[i].end(), '#') == 0;
    if (fl) {
        cout << -1 << endl;
        return 0;
    }
    int ans = n * n * n;
    vector<int> ok(n), cl(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (grid[i][j] == '#') ok[j] = 1;
        }
    }
    int cf = 0;
    for (int i = 0; i < n; ++i) {
        int wh = -1, cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (grid[j][i] == '.') {
                cnt++;
                wh = j;
            }
        }
        if (cnt == 0) ++cf;
        else if (cnt == 1) ++cl[wh];
    }
    for (int i = 0; i < n; ++i) {
        int cv = count(grid[i].begin(), grid[i].end(), '#');
        int res = 0;
        if (cv < n) {
            if (!ok[i]) res++;
            res += n - cv;
        }
        res += n - cf;
        ans = min(ans, res);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
def main():
    K = int(input())
    op = K//50
    ans = [i+op for i in range(50)]
    op_d = K % 50
    for i in range(op_d):
        for j in range(50):
            if i == j:
                ans[j] += 50
            else:
                ans[j] -= 1
    print(50)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> a(n),b(n),c(n-1);
	rep(i,n){cin>>a[i];a[i]--;}
	rep(i,n)cin>>b[i];
	rep(i,n-1)cin>>c[i];

	int ans = 0;
	int now = -1;
	rep(i,n){
		if(now>=0 && now+1==a[i]){
			ans += c[now];
		}
		now = a[i];
		ans += b[now];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 1; i< b; i++){
        if(((a*i)-c)%b==0){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
#define N 8

int ptn[7]={18, 48, 6, 30, 20, 34, 16};

int main(void){
    string str,tmp;
	while (true){
		int i=0;
		getline(cin,tmp);
		if (cin.eof()) break;
		if (tmp.length()>0){
			str = tmp;
			i++;
		}else str = "";

		while (i<N){
			getline(cin,tmp);
			str+=tmp;
			i++;
		}
		int s=0, mini=(int)str.length();
		for (int i=0; i<str.length(); i++){
			if (str[i]=='1'){
				if (i<mini) mini =i;
				s+=i;
			}
		}
		s -= mini*4;
		for (int i=0; i<7; i++){
			if (ptn[i]==s){ 
				cout<<char(i+'A')<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1172
import random
import time

start = time.time()
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]


def main():
    cnt = 0
    best_ans, best_score = generate_first_ans()
    while time.time() - start < 1.8:
        cnt += 1
        ans = best_ans[:]
        si, sj = random.randint(0, 364), random.randint(0, 364)
        ans[si], ans[sj] = ans[sj], ans[si]
        score = calc_score(ans)
        if score > best_score:
            best_score = score
            best_ans = ans

    for a in best_ans:
        print(a + 1)


def generate_first_ans():
    best_ans = []
    best_score = 0
    last_day = [-1] * 26
    for d in range(365):
        d_ans = -1
        d_score = -float('inf')
        d_last_day = [-1] * 26
        for t in range(26):
            d_tmp_score = 0
            d_tmp_score += S[d][t]
            d_tmp_last_day = last_day[:]
            d_tmp_last_day[t] = d
            for c, ld in zip(C, d_tmp_last_day):
                d_tmp_score -= c * (d - ld)

            if d_tmp_score > d_score:
                d_ans = t
                d_score = d_tmp_score
                d_last_day = d_tmp_last_day[:]

        best_ans.append(d_ans)
        best_score += d_score
        last_day = d_last_day[:]

    return best_ans, best_score


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d, t in enumerate(T):
        score += S[d][t]
        last_day[t] = d
        for c, ld in zip(C, last_day):
            score -= c * (d - ld)
    return score


if __name__ == "__main__":
    main()


Measured memory_bytes: 81408
nums =[int(e) for e in input().split()]
yakusuu = []
yakusuu_count = 0
for j in range(1,nums[2]+1):
    if nums[2]%j== 0:
        yakusuu.append(j)
for k in range(len(yakusuu)):
    if nums[0]<=yakusuu[k] and yakusuu[k]<=nums[1]:
        yakusuu_count += 1
print(yakusuu_count)


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

int main() {
    string x;

    cin >> x ;

    char a, b, c;

    a = x[0];
    b = x[1];
    c = x[2];

    int count = 0;

    if (a == '1') {
        count = count + 1;
    }
    if (b == '1') {
        count = count + 1;
    }
    if (c == '1') {
        count = count + 1;
    }

    cout << count << endl;

 
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
N=int(input());AB=[tuple(map(int,input().split())) for _ in range(1,N)]

co=[0 for _ in range(N)]
prev=0
color=1
for a,b in sorted(AB):
  if prev!=a:
    color=1
  if co[a-1]==color:
    color+=1
  co[b-1]=color
  prev=a
  color+=1

print(max(co))
for _,b in AB:
  print(co[b-1])


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

int main() {
    ll N, P, Q, ans = 0, sum = 0;
    vector<ll> c, ls;
    cin >> N >> P >> Q;
    c.resize(N);
    // すべて食堂で食べたとする
    for(int i=0;i<N;i++){
        cin >> c[i];
        sum += c[i];
        ls.push_back(P*i + c[i]);
    }
    ans = sum;
    // P*i*c[i]が小さいものから自炊に置き換える
    sort(ls.begin(), ls.end());
    for(int i=0;i<N;i++){
        sum += P*(Q + 2*i) - ls[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10944
// https://atcoder.jp/contests/abc140/tasks/abc140_d
#include <bits/stdc++.h>

using namespace std;

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

    int n,k;
    string s;

    cin >> n >> k >> s;
    if(s.empty())
    {
        cout << 0;
        return 0;
    }
    char first = s[0];
    int ct = 0;
    for(int i =0; i < n-1; ++i)
    {
        if(s[i] == s[i+1])
            ct++;

    }
    bool ok = false;

    for(int i =1; i< n && k && ct< n-1; ++i)
    {
        if(s[i] == first && s[i-1] !=first)
        {
            k--;
            ct+=2;
            ok = false;
        }
        else if(s[i]!= first)
        {
            ok = true;
        }
        
    }
    if(ok && k)
        ct++;
    cout << ct << '\n';

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
  ll n;cin>>n;
  int m=0;
  int last=0;
  vector<int>a(n+1);
  REP(i,1,n+1)cin>>a[i];
  vector<int>b(n+1);
  for(int i=n;i>=1;i--){
    int k=0;
    for(int j=i*2;j<=n;j+=i){
      k+=b[j];
    }
    if(a[i]%2==k%2)continue;
    else{
      b[i]++;
      m++;
      last=max(last,i);
    }
  }
  if(m){
    cout<<m<<endl;
    for(int i=1;i<last;i++){
      if(b[i])cout<<i<<' ';
    }
    cout<<last<<endl;
  }
  else cout<<m<<endl;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

int dfs(int ind, vector<bool>& v, vector<vector<int>>& gr){
    if(v[ind]){
        v[ind]=false;
        int ans=0;
        for(auto x:gr[ind]) ans+=dfs(x,v,gr);
        return ans+1;
    }
    return 0;
}

void solve(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> gr(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        gr[x].pb(y);
        gr[y].pb(x);
    }
    int ans=0;
    vector<bool> v(n,true);
    for(int i=0;i<n;i++) ans=max(ans,dfs(i,v,gr));
    cout<<ans<<"\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 23528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   int sum = 0;
   for(int t = 0; t < T + 0.5; t++){
      if(t % A == 0){
         sum+=B;
      }
   }

   cout << sum - B << endl;

   return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

s = []
for i in range(h):
    s.append([x for x in input().split()])


for i in range(h):
    for j in range(w):
        cnt = 0
        shape = 0

        if s[i][0][j] == "#":
            if i != 0 :
                cnt += 1
                if s[i-1][0][j] == "#":
                    shape += 1
            if i != h-1:
                cnt += 1
                if s[i+1][0][j] == "#":
                    shape += 1
            if j != 0:
                cnt += 1
                if s[i][0][j-1] == "#":
                    shape += 1
            if j != w-1:
                cnt += 1
                if s[i][0][j+1] == "#":
                    shape += 1

            if shape == 0:
                print("No")
                exit(0)

print("Yes")

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

#define MAX_N 100
#define MAX_W 10000

struct item {
    int v, w;
};

using namespace std;

item items[MAX_N + 5];
int T[MAX_N + 5][MAX_W + 5];

int main()
{
    int n, w, i, j;
    scanf("%d %d", &n, &w);
    for (i = 1; i <= n; i++) {
        scanf("%d %d", &(items[i].v), &(items[i].w));
    }
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= w; j++) {
            T[i][j] = 0;
        }
    }
    for (i = 1; i <= n; i++) {
        for (j = 0; j <= w; j++) {
            if (j < items[i].w) {
                T[i][j] = T[i - 1][j];
            }
            else {
                T[i][j] = max(T[i - 1][j], T[i][j - items[i].w] + items[i].v);
            }
        }
    }
    printf("%d\n", T[n][w]);

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi; 
typedef pair<int,int> pi; 
typedef vector<ll> vll; 


#define F first;
#define S second;
#define PB push_back;
#define MP make_pair;
#define rep(i, a, b) for (int i=a; i<b; i++)

int main(){
	ll t;
	cin >>t;
    
    if(t<=111){
        cout<<"111";
    }
    else if(t<=222){
        cout << "222";
    }
    else if(t<=333){
        cout << "333";
    }
    else if(t<=444){
        cout << "444";
    }
    else if(t<=555){
        cout << "555";
    }
    else if(t<=666){
        cout << "666";
    }
    else if(t<=777){
        cout << "777";
    }
    else if(t<=888){
        cout << "888";
    }
    else if(t<=999){
        cout << "999";
    }

	return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[3][101];
int i,j,n,ans;
int main()
{
	cin>>n;
	for(i=0;i<3;i++)cin>>a[i];
	for(i=0;i<n;i++)
	 {if(a[0][i]!=a[1][i]&&a[1][i]!=a[2][i]&&a[0][i]!=a[2][i])ans+=2;
	  else if(!(a[0][i]==a[1][i]&&a[1][i]==a[2][i]))ans++;
	 }
	cout<<ans<<endl;
}

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

ll gcd(ll a,ll b){
  if(a==b) return a;
  if(b==0) return a;
  return gcd(b,a%b);
}

int main() {
  int n;
  ll k;
  cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll b[n];
  ll x=a[0];
  ll y;
  for(int i=0;i<n;i++){
    y=a[i];
    b[i]=gcd(x,y);
    x=gcd(x,y);
  }
  ll m=0;
  for(int i=0;i<n;i++){
    m=max(m,a[i]);
  }
  if(k%b[n-1]==0&&k<=m){
    cout<<"POSSIBLE"<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}
template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

const int MAX_N = 18;
ll dp[1<<MAX_N][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m = 1<<n;
    vl a(m);
    rep(i, m) cin >> a[i];
    rep(i, 1<<MAX_N) rep(j, 2) dp[i][j] = -1;
    dp[0][0] = 0;
    auto update = [&](int i, int j) {
        vector<int> idx;
        rep(k, 2) if(dp[i][k] != -1) idx.push_back(dp[i][k]);
        rep(k, 2) if(dp[j][k] != -1) idx.push_back(dp[j][k]);
        sort(all(idx));
        idx.erase(unique(all(idx)), idx.end());
        sort(all(idx), [&](int x, int y) {return a[x] > a[y];});
        dp[i][0] = idx[0];
        dp[i][1] = idx[1];
    };
    REP(i, 1, m) {
        dp[i][0] = i;
        rep(j, n) if(i&(1<<j)) update(i, i - (1<<j));
    }
    ll ans = -1;
    REP(k, 1, m) {
        int i = dp[k][0];
        int j = dp[k][1];
        chmax(ans, a[i] + a[j]);
        cout << ans << '\n';
    }
    // REP(k, 1, m) {
    //     int i = dp[k][0];
    //     int j = dp[k][1];
    //     dump(mp(i, j));
    // }
    return 0;
}

Measured memory_bytes: 9216