akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
const int N = 305;
const int M = 305;
int main ()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		bool ok = true, go = false;
		if(n == 0 && m == 0)
		{
			break;
		}
		for(int i = 0; i <n; i++)
		{
			if(ok)
			{
				go = true;
				for(int j = 0; j < m ; j++)
				{
					if(go)
					{
						printf("#");
						go = false;
					}
					else
					{
						printf(".");
						go = true;
					}
				}
				printf("\n");
				ok = false;
			}
			else
			{
				go = true;
				for(int j = 0; j < m ; j++)
				{
					if(go)
					{
						printf(".");
						go = false;
					}
					else
					{
						printf("#");
						go = true;
					}
				}
				printf("\n");
				ok = true;
			}
		
		}
	printf("\n");
	}		
	return 0;
}


Measured memory_bytes: 2624
#include <stdio.h>
int main(){
	int a, b, tmp, r, c, d;
	while(scanf("%d%d",&a,&b)!=EOF){
		c = a; d = b;
		while(1){
			if(b>a){tmp = a; a = b; b = tmp; }
			r = a % b;
			if(r == 0) break;
			a = b; b = r;
		}
		tmp = b*(c/b)*(d/b);
		printf("%d %d\n", b, tmp);
	}
	return 0;
}

Measured memory_bytes: 596
use std::io::*;
//use std::str::*;

fn main() {
	let mut s = get_in();
	
	s.replace_range(3.., "");
	
	println!("{}", s);
}

fn get_in() -> String {
	let mut buf = String::new();
	stdin().read_line(&mut buf).ok();
	
	buf
}


Measured memory_bytes: 2096
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	deque<int> a;
	int b;
	for (int i = 0 ; i < n ; i++) {
		cin >> b;
		if (i % 2) a.push_back(b);
		else a.push_front(b);
	}
	if (n % 2 == 0) reverse(a.begin(), a.end());
	for (int i = 0; i < n ; i++) cout << a[i] << ' ';
	/*
	vector<char> b;
	char a;
	for (int i = 0 ; i < n ; i++) {
		cin >> a;
		b.push_back(a);
		reverse(b.begin(), b.end());
		cout << b[i] << ' ';
	}
	*/
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

/*
Log order calcuration of power
*/
ll bi_pow(ll x, ll n){
  ll res = 1;
  while (n>0){
    if (n%2==1) {res = res * x % MOD;}
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}


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

  ll N;
  cin >> N;

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

  sort(C.begin(), C.end(), greater<ll>());

  ll ans = 0;
  REP3(i,1,N+1){
    ll ci = bi_pow(4,N-1) * (i+1) % MOD;
    ans += C[i-1] * ci;
    ans %= MOD;
  }
  cout << ans << "\n";
  return 0;
}

/*
Count of adding C[i]
sigma(k<=i) (i-1Ck-1 *  k * 2^(i-1) * 4^(N-i))
= 2^(i-1) * 4^(N-i) * sigma(k<=i) (i-1Ck-1 * k)

Consider the last sigma : it is the sum of cost when fix left number all 0.

Ex. i=2   left=000
  ------------------------------------------------
              right     number of dif (= number of 1)
   k=1 -> 1*1  100        -> 1
   k=2 -> 2*2  110        -> 2
               101        -> 2
   k=3 -> 1*3  111        -> 3
  ------------------------------------------------
The sum of number of dif equals count of 1 digits,
then, it can be obtained vertically.
Count of 1 in left digits is 2*i and in the rest digits is 2*(i-1), then
   2^i + 2^(i-1) + 2*(i-1) + ....
 = 2^i + (i-1) * 2^(i-1)
 = (i+1) * 2^(i-1)

 Thus,
 Count of adding C[i] = 4^(N-1) * (i+1)
*/


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

       Scanner sc =new Scanner(System.in);

        int N=sc.nextInt();
        String ans="No";
        int c=0;
        int d=0;

        while((4*c+7*d)<=N){
            while((4*c+7*d)<=N){
               if((4*c+7*d)==N){
                    ans="Yes";
                    break;
                }else{c++;}
            }
            d++;
            c=0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22608
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int H,W;
    cin >> H >> W;
    char S[H][W];
    rep(i,H) cin >> S[i];
    int L[H][W]={};
    int R[H][W]={};
    int U[H][W]={};
    int D[H][W]={};
    rep(i,H) rep(j,W){
        if(S[i][j]=='#'){
            L[i][j]=-1;
            R[i][j]=-1;
            U[i][j]=-1;
            D[i][j]=-1;
        }
    }
    rep(i,H) rep(j,W){
        if(j==0) continue;
        if(S[i][j]=='#') continue;
        L[i][j]=L[i][j-1]+1;
    }
    rep(i,H) reprev(j,W){
        if(j==W-1) continue;
        if(S[i][j]=='#') continue;
        R[i][j]=R[i][j+1]+1;
    }
    rep(i,W) rep(j,H){
        if(j==0) continue;
        if(S[j][i]=='#') continue;
        U[j][i]=U[j-1][i]+1;
    }
    rep(i,W) reprev(j,H){
        if(j==H-1) continue;
        if(S[j][i]=='#') continue;
        D[j][i]=D[j+1][i]+1;
    }
    int ans=0;
    rep(i,H) rep(j,W) if(S[i][j]!='#') ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]);
    cout << ans+1 << endl;
}

Measured memory_bytes: 66688
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(long long X, long long Y){
    int ret = 0;
    while (X <= Y) {
        X = X << 1;
        ret++;
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long X;
    long long Y;
    scanf("%lld",&X);
    scanf("%lld",&Y);
    solve(X, Y);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [int(x) for x in input().split()]
ans = 0

for i in range(len(s)-2):
  a = s[i]
  for j in range(i + 1, len(s)-1):
    b = s[j]
    if a == b:
      continue
    for k in range(j + 1, len(s)):
      c = s[k]

      if a == c or b == c:
        continue
      if a > b and a > c and a < b + c:
        ans += 1
      elif b > c and b > a and b < c + a:
        ans += 1
      elif c > a and c > b and c < a + b:
        ans += 1

print(ans)


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

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

using namespace std;
using P = pair<int, int>;

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; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int a, b; cin >> a >> b;
    cout << max( { a + b, a - b, a * b } ) << endl;
}

Measured memory_bytes: 256
// code gen begin
// -------------------------
package main

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

func unUsedFunction() string {
	return "I am unused unexported function"
}
func UnUsedFunction() string {
	return "I am unused exported function"
}
func swap(a int, b int) (int, int) {
	return b, a
}
func (u UnionFind) Size(x int) int {
	return -u.par[u.Find(x)]
}
func (u UnionFind) Same(x, y int) bool {
	return u.Find(x) == u.Find(y)
}
func (u UnionFind) Union(x, y int) {
	xr := u.Find(x)
	yr := u.Find(y)
	if xr == yr {
		return
	}
	if u.Size(yr) < u.Size(xr) {
		yr, xr = swap(yr, xr)
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) Find(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.Find(u.par[x])
	return u.par[x]
}
func NewUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}

type UnionFind struct{ par []int }

func ModPow() int64 {
	return int64(math.Max(1, 3))
}
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n, m int
	fmt.Fscan(r, &n, &m)
	uf := NewUnionFind(n)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscan(r, &a, &b)
		a--
		b--
		uf.Union(a, b)
	}
	ans := 0
	for i := 0; i < n; i++ {
		if ans < uf.Size(i) {
			ans = uf.Size(i)
		}
	}
	fmt.Fprintln(w, ans)
}
// -------------------------
// code gen end

Measured memory_bytes: 6320
module M = Set.Make(struct
  type t = int * int
  let compare = compare
end)

let () =
  Scanf.scanf "%d" @@ fun k ->
  let (+%) a b = (a + b) mod k in
  let ( *%) a b = (a * b) mod k in

  let a = Array.make k k in
  a.(1) <- 1;
  let rec loop pq =
    if M.is_empty pq then () else begin
      let (d, m) = M.min_elt pq in
      let pq' = M.remove (d, m) pq in
      if d > a.(m) then loop pq' else
      [(d+1, m+%1); (d, m *% 10)] |> List.fold_left (fun q (d',m') ->
        if d' < a.(m') then begin
          a.(m') <- d';
          M.add (d', m') q
        end else q
      ) pq' |> loop
    end
  in
  loop (M.singleton (1, 1));
  Printf.printf "%d\n" a.(0)

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll power(ll x,  ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

bool comp(std::vector<ll> a, std::vector<ll> b)
{
    if(a[1]==b[1]&&a[2]==b[2])
        return a[0]<b[0];
    else if(a[1]==b[1])
        return a[2]>b[2];
    else
        return a[1]<b[1];
}

int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll dp[n][n];
    ll a[n];
    ll sm = 0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        sm+=a[i];
        dp[i][i] = a[i];
    }
    for(ll i=0;i<n-1;i++)
    {
        dp[i][i+1] = max(a[i],a[i+1]);
    }
    for(ll gap = 2;gap<n;gap++)
    {
        for(ll i=0;i<n-gap;i++)
        {
            dp[i][i+gap] = max(a[i]+min(dp[i+1][i+gap-1],dp[i+2][i+gap]),a[i+gap]+min(dp[i][i+gap-2],dp[i+1][i+gap-1]));
        }
    }
    cout<<2*dp[0][n-1]-sm<<endl;
}

Measured memory_bytes: 49756
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N,M;
//点iと点j1,点j2,点j3...が隣接していて、
//かつそれぞれの移動コストがc1,c2,c3....である時
//adj[i] = {(c1,j1),(c2,j2),(c3,j3),.....}と決める
vector<vector<pair<LL,LL>>> adj;
vector<pair<LL,LL>> edge;

LL ans = 0;

void solve(){
	map<pair<LL,LL>,bool> is_passed; 
	for(int start=1;start<=N;start++){
		//pair<スタート地点からの最短距離,頂点番号>
		//pairのfirstが小さいものから取り出せる優先度付きキュー
		priority_queue<pair<LL,LL>,vector<pair<LL,LL>>,greater<pair<LL,LL>>> q;
		vector<LL> dist(N+1,INF);//スタート地点と点iの最小距離をdist[i]とおく
		vector<LL> from(N+1,INF);//点iにどこからきたかを格納
		dist[start] = 0;//点startをスタート地点に決める
		q.push(pair<LL,LL>(0,start));

		while(!q.empty()){
			pair<LL,LL> now = q.top();q.pop();
			int now_v = now.second;
			if(dist[now_v]<now.first) continue;
			for(int i=0;i<adj[now_v].size();i++){
				LL next_v = adj[now_v][i].second;
				LL cost = adj[now_v][i].first;
				if(dist[next_v]>dist[now_v]+cost){
					dist[next_v] = dist[now_v] + cost;
					from[next_v] = now_v;
					q.push(pair<LL,LL>(dist[next_v],next_v));
				}
			}
		}

		for(int end=start+1;end<=N;end++){
			int now = end;
			while(now!=start){
				is_passed[pair<LL,LL>(now,from[now])] = 1;
				is_passed[pair<LL,LL>(from[now],now)] = 1;
				now = from[now];
			}
		}
	}

	for(int i=0;i<edge.size();i++){
		if(!is_passed[edge[i]]) ans++;
	}
}
 
int main(){
    cin >> N >> M;
    adj = vector<vector<pair<LL,LL>>>(N+1);
    for(int i=0;i<M;i++){
    	LL a,b,c;cin >> a >> b >> c;
    	adj[a].push_back(pair<LL,LL>(c,b));
    	adj[b].push_back(pair<LL,LL>(c,a));
    	edge.push_back(pair<LL,LL>(a,b));
    }
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void solve()
{
	int am, pm;
	while(cin >> am >> pm)
	{
		if(!am && !pm)
		{
			break;
		}
		int sum[5] = {0};
		sum[0] = am + pm;
		int index = 0;
		int max = sum[0];
		for(int i = 1; i < 5; ++i)
		{
			cin >> am >> pm;
			sum[i] = am + pm;
			if(sum[i] > max)
			{
				max = sum[i];
				index = i;
			}
		}
		printf("%c %d\n", 'A' + index, max);
	}
}

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

Measured memory_bytes: 0
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt();
    VI a(n);
    generate(all(a), nxt);
    int low = a[0];
    int count = 0;
    REP(i, n){
        low = min(low, a[i]);
        count += a[i] == low ? 1 : 0;
    }
    printf("%d", count);
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    string ans = "Three";
    rep(i,n) {
        char c;
        cin >> c;
        if(c == 'Y') ans = "Four";

    }
    cout << ans << endl;
    
return 0;
}

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

int N;

int main() {
    cin >> N;
    vector<pair<int, int>> A(2 * N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].first >> A[N + i].first;
        A[i].second = i;
        A[N + i].second = N + i;
    }
    sort(A.begin(), A.end());
    
    vector<bool> B(N, false);
    long long sum = 0;
    bool flag = false, flagA = true, flagB = true;
    for (int i = 0; i < N; i++) {
        sum += A[i].first;
        if (flagA && A[i].second >= N) {
            flagA = false;
        }
        if (flagB && A[i].second < N) {
            flagB = false;
        }
        if (B[A[i].second % N]) {
            flag = true;
        } else {
            B[A[i].second % N] = true;
        }
    }
    
    if (flag || flagA || flagB) {
        cout << sum << endl;
        return 0;
    }
    
    long long ans = sum + 1e9;
    for (int i = 0; i < N; i++) {
        if (A[i].second % N == A[N].second % N) {
            ans = min(ans, sum - A[i].first + A[N + 1].first);
        } else {
            ans = min(ans, sum - A[i].first + A[N].first);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


k = int(input())
total = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            total += gcd(a, b, c)
print(total)

Measured memory_bytes: 74912
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll a[100000];
ll b[100000];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll sum=0;
	ll cnt=0;
	for(int i=0;i<n;i++)
		sum+=a[i];
	cnt=(ll)(n+1)*(ll)n/2LL;
	if(sum%cnt!=0)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	cnt=sum/cnt;//何回で構築できるか
	bool ans=true;
	for(int i=0;i<n;i++)
	{
		int prev=i-1;
		if(i==0)
			prev=n-1;
		ll dif=a[i]-a[prev];
		if(!((cnt-dif)%(ll)n==0LL && cnt-dif>=0))
			ans=false;
		b[i]=(cnt-dif)/(ll)n;
	}
	if(!ans)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	ll tmp=0;
	for(int i=0;i<n;i++)
		tmp+=b[i];
	if(tmp==cnt)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,d;
	cin >> n;
	int x[n];
	for(int i=0;i<n;i++){
		cin >> x[i];
	}
	int c = 0;
	for(int i=1;i<n-1;i++){
		
			m =max(max(x[i-1],x[i]),x[i+1]);
			d =min(min(x[i-1],x[i]),x[i+1]);
			if((m > x[i]) && (x[i] > d))
			{
				c++;
			}
	}
	cout << c <<endl;	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define P 1000000007
#define M 1000005
using namespace std; 
int A[M];

int main(){ 
	int s=0;
	int n,L,mi=1e9;
	cin>>n>>L;
	for(int i=1;i<=n;i++){
		int x=L+i-1;
		s+=x;
		if(abs(x)<abs(mi))mi=x;
	}
	printf("%d\n",s-mi);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
bool check(ll n )
{
    ll res = 0 ;
    forn(i , 1 , n){
       if(n % i == 0){
        ++res;
       }
    }
    if(res == 8) return true;
    return false;
}
int main()
{
    ios;
    ll n ;
    cin >> n ;
    ll cnt  = 0 ;
    forn(i , 1 , n ){
       if(i % 2 == 0 ) continue;
       if(check(i) == true){
        ++cnt;
      }
    }
    cout << cnt <<el;

}


























Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int mod = 1e9+7;

ll GCD(ll a, ll b) {
	if (a % b != 0)return GCD(b, a % b);
	else return b;
}

map<int, int> primeFactor(ll in) {
	map<int, int> ans;
	if (in < 3) return ans;
	ll a = 1;
	while (a*a <= in) a *= 2;
	for (int b = 2; b <= a; b++) {
		while (in % b == 0) {
			in /= b;
			ans[b]++;
		}
	}
	if (in != 1) ans[in]++;
	return ans;
}

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

	map<int, int> ret = primeFactor(GCD(A, B));

	cout << ret.size()+1 << endl;

	return 0;
}

Measured memory_bytes: 384
//
//  main.cpp
//  C - Next Prime
//
//  Created by Hashizo on 2019/12/29.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
int main(int argc, const char * argv[]) {
//	string ans = "Yes";
//
//	string s;
//	cin >> s;
//
//	ll n;
//	cin >> n;
//
//	vector<ll> point(n);
//	REP(i, n) {
//		cin >> point[i];
//	}
//
//	cout << ans << endl;
//	return 0;




	ll x,i,j,yakusuu;
	
	cin >> x;

	

	for(i=x ;i<=1000000;i++)
	{
		yakusuu=0;
		for(j=1;j<=i;j++)
		{
			if(i%j==0) yakusuu++;
		}

		if(yakusuu==2) {
			cout << i << endl;
			return 0;
		}
	}


	













}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if(N*A<B) cout<<N*A<<endl;
  else cout<<B<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

//----------------------------------------------------------------

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> next;
    map<ll, ll> rensou;
    ll a, b;
    bool flag = false;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if (a == 1)
        {
            next.push_back(b);
        }
        if (b == n)
        {
            rensou[a]++;
        }
    }
    for (auto f : next)
    {
        if (rensou[f])
        {
            flag = true;
        }
    }
    if (flag)
    {
        cout << "POSSIBLE" << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 13556
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void)
{
    int n,i,k;
    char s[1001],str[10000];
    
    scanf("%s",s);
    n = strlen(s);
    
    if(s[n - 1] == 's')
    {
        
        printf("%ses\n",s);
        return 0;
    }
    else
    {
        
        printf("%ss\n",s);
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 1736
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	function<long long(int l, int r, int x, int y)>DP = [&](int l, int r, int x, int y) ->long long int {
		if (l + 1 == r)return 0;
		long long int ret = MOD * MOD;
		for (int i = l + 1; i < r; i++) {
			ret = min(ret, ((DP(l, i, x, x + y)) + (DP(i, r, x + y, y)) + v[i] * (x + y)));
		}
		return ret;
	};
	cout << DP(0, N - 1, 1, 1) + v.front() + v.back() << endl;
}

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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

const ll inf = 1e18;

ll get_score(vector<ll> a) {
    assert(!a.empty());
    return *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    forn(i, n) {
        cin >> a[i];
    }
    vector<ll> pre(n+1);
    forn(i, n) {
        pre[i+1] = pre[i] + a[i];
    }
    
    auto get_sum = [&](int i, int j) {
        return pre[++j] - pre[i];
    };
    
    auto calc = [&](int i, int j, int k) {
        if(j == k) {
            return inf;
        }
        return llabs(get_sum(i, j) - get_sum(j+1, k));
    };
    
    ll ans = inf;
    debug() nav(a);
    for(int k = 2; k < n-1; k++) {
        int lo = 0, hi = k-2;
        while(lo < hi) {
            int mid = (lo + hi + 1)/2;
            debug() nav(mid) nav(k-1) nav(calc(0, mid, k-1)) nav(calc(0, mid+1, k-1));
            if(calc(0, mid, k-1) >= calc(0, mid+1, k-1)) {
                lo = mid;
            } else {
                hi = mid-1;
            }
        }
        if(calc(0, lo, k-1) > calc(0, lo+1, k-1)) lo++;
        vector<ll> v;
        v.push_back(get_sum(0, lo));
        v.push_back(get_sum(lo+1, k-1));
        lo = k, hi = n-2;
        while(lo < hi) {
            int mid = (lo + hi + 1)/2;
            if(calc(k, mid, n-1) >= calc(k, mid+1, n-1)) {
                lo = mid;
            } else {
                hi = mid-1;
            }
        }
        if(calc(k, lo, n-1) > calc(k, lo+1, n-1)) lo++;
        v.push_back(get_sum(k, lo));
        v.push_back(get_sum(lo+1, n-1));
        debug() nav(k) nav(v);
        min_self(ans, get_score(v)); 
    }
    
    cout << ans << endl;
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 2560
S=input()
bit=[0]*len(S)
for i in range(len(S)):
  if S[i]=="A" or S[i]=="T" or S[i]=="G" or S[i]=="C":
    bit[i]=1
count=[0]*len(S)
for i in range(len(S)):
  if bit[i]==0 :
    continue
  else :
    count[i]+=1
    for j in range(i+1,len(S)):
      if bit[j]==1 :
        count[i]+=1
      else :
        break
print(max(count))

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
pii r[110], b[110];
int used[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> r[i].first >> r[i].second;
  }
  for (int i = 0; i < N; i++) {
    cin >> b[i].first >> b[i].second;
  }
  sort(r, r + N);
  sort(b, b + N);
  for (int i = 0; i < N; i++) {
    int pos = -1;
    for (int j = 0; j < N && r[j].first < b[i].first; j++) {
      if (used[j] || !(r[j].second < b[i].second)) continue;
      if (pos < 0 || r[j].second > r[pos].second) pos = j;
    }
    if (pos < 0) continue;
    used[pos] = 1;
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += used[i];
  }
  cout << ans << endl;

  return 0;
}

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

// 条件を満たすような分割が出来る=>2部グラフになっている
// もし2部グラフでないなら、分割不可。2部グラフならグラフの直径+1が最大分割数となる
int main() {
    int n;
    cin >> n;
    vector<vector<int>> s(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            char c;
            cin >> c;
            if (c == '0')
                s[i][j] = INF;
            else
                s[i][j] = 1;
        }
    }

    // ワーシャルフロイド
    for (int k = 0; k < s.size(); k++) {
        for (int i = 0; i < s.size(); i++) {
            for (int j = 0; j < s.size(); j++) {
                if (s[i][k] == INF || s[k][j] == INF)
                    continue;
                s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
            }
        }
    }

    // 頂点間の距離を偶数奇数で考えて、行のパターン数が二種類なら二部グラフである。
    set<vector<int>> sv;
    int diam = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j)
                diam = max(s[i][j], diam);
            s[i][j] = s[i][j] % 2;
        }
        sv.insert(s[i]);
    }

    int k;
    if (sv.size() != 2)
        k = -1;
    else
        k = diam + 1;
    cout << k << endl;
    return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 111, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    ll ans = 0;
    string s;
    ll k;
    cin >> s;
    cin >> k;
    string pr;
    pr += s[0];
    string suf = "";
    suf += s.back();
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != s[i - 1]) {
            break;
        }
        pr += s[i];
    }
    for (int i = int(s.size()) - 2; i >= 0; --i) {
        if (s[i] != s[i + 1]) {
            break;
        }
        suf += s[i];
    }
    if (pr.size() == s.size()) {
        ans = (1LL * s.size() * k) / 2;
        cout  << ans << endl;
        return 0;
    }
    if (pr.size() + suf.size() == s.size()) {
        ans = 1LL * (pr.size() / 2 + suf.size() / 2);
        ans *= k;
        cout << ans << endl;
        return 0;
    }
    int cnt = 1;
    for (int i = pr.size() + 1; i < s.size() - suf.size(); ++i) {
        if (s[i] == s[i - 1]) {
            ++cnt;
        } else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    if (pr[0] != suf[0]) {
        ans += suf.size() / 2;
        ans += pr.size() / 2;
        ans *= k;
        cout << ans << endl;
        return 0;
    }
    ans *= k;
    ans += suf.size() / 2;
    ans += pr.size() / 2;
    ans += (1LL * (k - 1) * ((suf.size() + pr.size()) / 2));
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        long a = in.nextLong();
        long b = in.nextLong();
        long c = in.nextLong();


        if(a==b && b==c)
        {
            System.out.println("No");
        }
        else{
            if(a==b || b==c || a==c)
            {
                System.out.println("Yes");
            }
            else
            {
                System.out.println("No");
            }
        }

    }

}


Measured memory_bytes: 21588
#include <stdio.h>

//Istiyak Hossain

int main()
{
    int a, b, i, j;

    scanf("%d %d", &a, &b);

    while(a | b)
    {
        for(i = 0; i < a; i++)
        {
            for(j = 0; j < b; j++)
            {
                if((i && j)&& ((i != a-1) && (j != b-1))){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &a, &b);
    }

    return 0;
}



Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,k;cin>>n>>m>>k;
  for(int i=0;i<=n;i++){
  	for(int j=0;j<=m;j++){
    	if((i*(m-j)+j*(n-i))==k){
        	cout<<"Yes"<<endl;
          	return 0;
        }
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char a[100004];
int main()
{
	scanf("%s",a+1);
	int n=strlen(a+1);
	for(int i=1;i!=n;++i) if(a[i]==a[i+1]) {printf("%d %d\n",i,i+1);return 0;}
	for(int i=1;i<n-1;++i) if(a[i]==a[i+2]) {printf("%d %d\n",i,i+2);return 0;}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 256
class Main{
    public static void main(String[] a){
    	int b=1;
    	int c=1;
    	do{
    		if(c<10){
    		System.out.println(b+"x"+c+"="+b*c);
    			c++;
    		}
    		else if(c>9){
    			b++;
    			c=1;
    		}
    	}while(b<10);

    }
}

Measured memory_bytes: 9012
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long Q,ch[501][501],mc,pc,p[100001],m[100001],n, bc, now, C, H, W, X[100000],K, Y, ans, r, l, numcon, N, M;
string S,s,a[101],b[101],c[101];
bool h,k[101];

int main() {
	cin >> N;
	Q = 0;
	while (1) {
		for (int i = 0; i * 7 < 100; i++) {
			if (Q + (i * 7) == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		Q += 4;
		if (Q > N) break;
	}
	cout << "No" << endl;
	return 0;

}




Measured memory_bytes: 256
import sys


try:
    sys.stdin = open(sys.path[0] + '\\input.txt', 'r')
    sys.stdout = open(sys.path[0] + '\\output.txt', 'w')
except FileNotFoundError:
    pass


s = input()
t = input()

n, m = len(s), len(t)

if s == t[:n]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9104
#include<stdio.h>
int main(){
	int n,d[100],sum=0;
	long long ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
		sum=sum+d[i];
	}
	for(int i=0;i<n;i++){
		sum=sum-d[i];
		ans=ans+d[i]*sum;
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
T next_combination(T sub) {
    T x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.rbegin(), res.rend());
    return res;
}

int main(){

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

    ll n;
    cin >> n;
    if(n == 2LL or n == 1LL){
        ppp(0);
        return 0;
    }
    vector<ll> div = calc_divisor(n);

    // cerr << div << endl;
    ll sum = 0ll;
    int l = div.size();
    for(int i = 0; i < l/2; ++i){
        if(n%(div[i]-1) == 0) continue;
        sum += div[i]-1LL;
    }

    ppp(sum);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n,a[200010],ans[200010] = {};

signed main(){
	vector<int> vec;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = n;i >= 1;i--){
		int sum = 0;
		for(int j = i * 2;j <= n;j += i){
			sum += ans[j];
		}
		if(sum % 2 != a[i]){
			vec.pb(i);
			ans[i] = 1;
		}
	}
	cout << vec.size() << endl;
	for(int i = 0;i < vec.size();i++) cout << (i ? " " : "") << vec[i];
	cout << endl;
}


Measured memory_bytes: 4852
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int c[500],s[500],f[500];
    rep(i,n) cin >> c[i] >> s[i] >> f[i];

    rep(i,n){
        int thisans = 0;
        for(int j = i; j < n - 1; j++){
            if(thisans < s[j]) thisans = s[j];
            else if(thisans % f[j] == 0);
            else thisans += f[j] - thisans % f[j];
            thisans += c[j];
        }
        cout << thisans << endl;
    }
}

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



int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    rep(i,n) {
        cin >> v[i];
    }
    
    map<int,int> cnt1, cnt2;
    rep(i,n) {
        if(i % 2 == 0)
            cnt1[v[i]]++;
        else
            cnt2[v[i]]++;
    }
    
    int f_id1, f_mx1, s_id1, s_mx1, f_id2, f_mx2, s_id2, s_mx2;
    f_id1 = s_id1 = f_id2 = s_id2 = -1;
    f_mx1 = s_mx1 = f_mx2 = s_mx2 = 0;
    
    for(auto x : cnt1) {
        if(f_mx1 < x.second) {
            s_id1 = f_id1;
            s_mx1 = f_mx1;
            f_id1 = x.first;
            f_mx1 = x.second;
        }
        else if(s_mx1 < x.second) {
            s_id1 = x.first;
            s_mx1 = x.second;
        }
    }
    for(auto x : cnt2) {
        if(f_mx2 < x.second) {
            s_id2 = f_id2;
            s_mx2 = f_mx2;
            f_id2 = x.first;
            f_mx2 = x.second;
        }
        else if(s_mx2 < x.second) {
            s_id2 = x.first;
            s_mx2 = x.second;
        }
    }
    
    int ans;
    if(f_id1 != f_id2) {
        ans = n - f_mx1 - f_mx2;
    }
    else {
        if(s_id1 == -1 && s_id2 == -1) {
            ans = n - max(f_mx1, f_mx2);
        }
        else if(s_id1 == -1) {
            ans = n - max(f_mx2, f_mx1 + s_mx2);
        }
        else if(s_id2 == -1) {
            ans = n - max(f_mx1, f_mx2 + s_mx1);
        }
        else {
            ans = n - max(f_mx1 + s_mx2, s_mx1 + f_mx2);
        }
    }
    
    //cout << s_id1 << " " << s_id2 << endl;
    cout << ans << endl;
    
    
    return 0;
}


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

int mod = 1000000007;
int power(int x, int y) { //x^y
	long long p = 1;
	for (long long b = x; y > 0; y >>= 1, b = b * b % mod) {
		if (y & 1)
			p = p * b % mod;
	}
	return p;
}

int main() {
	string l;
	cin >> l;
	int n = l.size();
	int leftPopBit = 0;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (l[i] == '1') {
			sum += (long long) power(2, leftPopBit) * power(3, n - i - 1) % mod;
			sum %= mod;
			leftPopBit++;
		}
	}
	sum += power(2, leftPopBit);
	sum %= mod;
	cout << sum << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int a[100];
    int n;

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

    for (int i = n-1; i >= 0; i--) {
        printf("%d", a[i]);
        if (i != 0)
            putchar(' ');
    }
    putchar('\n');
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N; cin >> N;
	string S;
	long long ac = 0, wa = 0, tle = 0, re = 0;
	for (long long i = 0; i < N; i++) {
		cin >> S;
		if (S == "AC") ac++;
		else if (S == "WA") wa++;
		else if (S == "TLE") tle++;
		else if (S == "RE") re++;
	}
	cout << "AC x " << ac << endl
		<< "WA x " << wa << endl
		<< "TLE x " << tle << endl
		<< "RE x " << re << endl;
}

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long ans = 0;
  int l = 0;
  long x = 0;
  for (int r = 0; r < N; r++) {
    while ((x & A[r]) > 0) {
      x ^= A[l];
      l++;
    }
    x ^= A[r];
    ans += r - l + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<> p(n); for (int i = 0; i < n; i++) cin >> p[i], p[i]--;
  int res = !!p[0];
  p[0] = 0;
  VV<> ch(n);
  for (int v = 1; v < n; v++) ch[p[v]].push_back(v);
  V< pair<int, int> > d(n);
  queue<int> que;
  d[0] = {0, 0}; que.push(0);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int w : ch[v]) {
      d[w] = {d[v].first + 1, w}; que.push(w);
    }
  }
  sort(d.rbegin(), d.rend());
  V<> invd(n);
  for (int i = 0; i < n; i++) invd[d[i].second] = i;
  for (int i = 0; i < n; i++) if (d[i].first > k) {
    res++;
    int s = d[i].second;
    for (int _ = 0; _ < k - 1; _++) s = p[s];
    d[invd[s]].first = 0; que.push(s);
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (int w : ch[v]) if (d[invd[w]].first) {
        d[invd[w]].first = 0; que.push(w);
      }
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================

vi g[N];
bool dp[N][2];

void solve() {
	int i, j, n, m;
	int k;
	cin >> n >> k;
	set<int> s;
	int a;
	fo(i, n) {
		cin >> a;
		s.insert(a);
	}
	memset(dp, 0, sizeof(dp));
	dp[0][1] = 1;
	dp[0][0] = 1;
	Fo(i, 1, k + 1) {
		fo(j, 2) {
			for (auto it : s) {
				if (it <= i) {
					if (i == it)
						dp[i][j] = 1;
					else
						dp[i][j] |= !dp[i - it][1 ^ j];
				}

			}
		}
	}
	// Fo(i, 1, k + 1) {
	// 	fo(j, 2) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	if (dp[k][0]) cout << "First\n";
	else cout << "Second\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 11244