akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define STEP(i, n, step) for(int i=0; i < n; i+=step)
#define RANGE(n) for(int _=0; _<n ; _++)
#define FOR(i, m, n) for(int i = m; i < n; i++)

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

const long long INF = 1LL << 60;
const int INT_INF = 1 << 29;

const int MAX = 100010;


void solve() {
  int N;
  cin >> N;
  int counter = 0;
  // cout << pow(N,.5) << endl;
  REP(i,N){
    for(int d=1;d * d <= i; d++){
      if(i % d == 0){
        if(i/d == d) counter++;
        else counter+=2;
      }
    }
  }
  cout << counter << endl;
  return;
}
 
int main() {
    solve();
    return 0;
}




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

struct data2
{
	int p, y, nn, num;
}c[100010];

bool cmp(data2 u, data2 v)
{
	if (u.p == v.p) return u.y<v.y;
	return u.p < v.p; 
}
bool cmp2(data2 u, data2 v)
{
	return u.nn < v.nn; 
}

int ans[100010];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i)
		scanf("%d%d", &c[i].p, &c[i].y), c[i].nn = i;
	sort(c+1, c+m+1, cmp);
	for (int i=1, j=1; i <= m; i=j)
	{
		int k = 0;
		while (j <= m && c[j].p == c[i].p) 
		{
			++k;
			c[j].num = k;
			++j; 
		}
	}
	sort(c+1, c+m+1, cmp2);
	for (int i = 1; i <= m; ++i)
		printf("%06d%06d\n", c[i].p, c[i].num);
	return 0;
} 

Measured memory_bytes: 5392
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let p: i32 = read();
    println!("{}", (3 * a + p) / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, ar[N];

bool check(int x) {
	int t[N];
	bool fl = false;
	for(int i = 1; i <= 2 * n - 1; i++)
		t[i] = ar[i] >= x;
	for(int i = 1; i < 2 * n - 1; i++)
		if(t[i] == t[i + 1])
			fl = true;
	if(!fl) {
		if(n % 2 == 1)
			return t[n] == 1;
		else
			return t[n] == 0;
	}
	int ind1 = n, ind2 = n;
	while(1) {
		if(t[ind1] == t[ind1 - 1])
			return t[ind1];
		else if(t[ind2] == t[ind2 + 1])
			return t[ind2];
		ind1--;
		ind2++;
	}
}

int bs(int x, int y) {
	if(x == y)
		return x;
	if(x + 1 == y) {
		if(check(y))
			return y;
		else
			return x;
	}
	if(check(mid))
		bs(mid, y);
	else
		bs(x, mid - 1);
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= 2 * n - 1; i++)
		cin >> ar[i];
	if(n == 1)
		cout << 1;
	else
		cout << bs(1, 2 * n - 1);
}

Measured memory_bytes: 3840
#include <stdio.h>

int team[1000000][2];

int main(){
  int n, c, m1, s1, m2, s2, m3, s3, m4, s4, i, j, min;

  while(scanf("%d", &n) && n){
    for(i = 0; i < n; i++){
      scanf("%d%d%d%d%d%d%d%d%d", &team[i][0],&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
      team[i][1] = (m1 + m2 + m3 + m4) * 60 + s1 + s2 + s3 + s4;
    }

    for(i = 0; i < n; ++i){
      min = i;
      for(j = i + 1; j < n; ++j)
	if(team[j][1] < team[min][1]) min = j;
      if(min != i){
	int t = team[min][0]; team[min][0] = team[i][0]; team[i][0] = t;
	t = team[min][1]; team[min][1] = team[i][1]; team[i][1] = t;
      }
    }


    printf("%d\n%d\n%d\n", team[0][0], team[1][0], team[n - 2][0]);
  }
  return 0;
}

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

#ifdef ONLINE_JUDGE
#include <atcoder/all>
using namespace atcoder;
#endif

using namespace std;

#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

int N,Q;
inline void input(){
    fast_io();
    cin >> N >> Q;
}

inline int solve(){
    dsu D(N);
    for (int i = 0; i < Q; i++)
    {
        int t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            D.merge(u,v);
        }
        else{
            cout << D.same(u,v) << endl;
        }
    }
    return 0;
}   

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


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
const int N = 100005;
int s[N], b[N];
int main()
{
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	rep1(i, n) cin >> s[i];
	int num = 0, ans = 0;
	rep1(i, n + 1)
	{
		if (s[i] == i) num++;
		else
		{
			if(num) ans += (num + 1) / 2;
			num = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
    n:Chars
  }
  let mut x = 0;
  for i in 0..n.len() {
      x += n[i] as i64-'0' as i64;
  }
  println!("{}",if x%9 == 0 {"Yes"} else {"No"});
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==2&& b== 2) cout << "Yes" << endl;
  else if(a==4||a==6||a==9||a==11){
    if(b==4||b==6||b==9||b==11) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(a==1||a==3||a==5||a==7||a==8||a==10||a==12){
    if(b==1||b==3||b==5||b==7||b==8||b==10||b==12) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
c = 3.times.map { gets.split.map(&:to_i) }

heIsRight = false
a = Array.new(3)
b = Array.new(3)
  isOut = false
  a[0] = 0
  (0...3).each do |i|
    b[i] = c[0][i] - a[0]
  end

  a[1] = c[1][0]-b[0]
  (0...3).each do |j|
    if c[1][j] != a[1]+b[j]
      isOut = true
    end
  end

  a[2] = c[2][0]-b[0]
  (0...3).each do |k|
    if c[2][k] != a[2]+b[k]
      isOut = true
    end
  end

if !isOut
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
def isPrime(n):
    f = [True]*(n+1)
    f[0] = f[1] = False
    for i in range(2,int(n**0.5)+1):
        if f[i]:
            for j in range(i**2, n+1, i): f[j] = False
    return f

l = isPrime(1000000)
while True:
    a,d,n = map(int,input().split())
    if not(n): break
    cnt = 0
    while True:
        if l[a]: cnt += 1
        if cnt==n: break
        a += d
    print(a)
    

Measured memory_bytes: 14956
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
typedef long long ll;

using namespace std;


int main() {
	int a, b;
	char c;
	cin >> a >> c >> b;
	if (c=='+') {
		cout << a + b;
	}
	else {
		cout << a - b;
	}
	}







Measured memory_bytes: 256
#coding:utf-8

N, M, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))

'''
result1 = (X < Z) and (Z <= Y)

num_violate2 = len([i for i in x if i >= Z])
if num_violate2 > 0:
    result2 = False
else:
    result2 = True

num_violate3 = len([i for i in x if i < Z])
if num_violate3 > 0:
    result3 = False
else:
    result3 = True

if result1 and result2 and result3:
    print('No War')
else:
    print('War')
'''

x.append(X)
y.append(Y)

x = sorted(x)
y = sorted(y)

if x[-1] < y[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <iomanip>

using namespace std;

const int N = 100 * 1000;
int in[N];
int par[N];
int mark[N];
int n, m, root;
vector<int> graph[N];
void dfs(int v)
{
	mark[v] = true;
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		in[u]--;
		
	}
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (!mark[u] && in[u] == 0)
		{
			par[u] = v + 1;
			dfs(u);
		}
	}
}


int main() 
{
	cin >> n >> m;
	for (int i = 0; i < n - 1 + m; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u - 1].push_back(v - 1);
		in[v - 1]++;
	}
	for (int i = 0; i < n; i++)
	{
		if (in[i] == 0)
		{
			root = i;
		}
	}
	//cout << root << endl;
	par[root] = 0;
	dfs(root);
	for (int i = 0; i < n; i++)
	{
		cout << par[i] << endl;
	}
}



























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

int zz[100005],n;
string dat;

int main()
{
	cin>>n>>dat;
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
		{
			zz[0]=i;
			zz[1]=j;
			for(int k=1;k<n-1;k++)
			{
				zz[k+1]=zz[k]^zz[k-1]^(dat[k]=='x');
			}
			if((dat[n-1]=='x')==(zz[n-2]^zz[n-1]^zz[0]) && (dat[0]=='x')==(zz[n-1]^zz[0]^zz[1]))
			{
				for(int k=0;k<n;k++)
					cout<<(zz[k]?"W":"S");
				cout<<endl;
				return 0;
			}
		}
	cout<<"-1"<<endl;
	return 0;
}

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

int main(){
	int a, max, all;
	cin >> a;
	int arr[a];
	for(int i=0; i<a; i++){
		cin >> arr[i];
	}
	max=arr[0]; all=1;
	for(int i=1; i<a; i++){
		if(arr[i]>=max){
			max=arr[i];
			all++;
		}
	}
	cout << all << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin>>N;
    int a[N];
    for(int i=0;i<N;i++) cin>>a[i];
    sort(a,a+N);
    int f=0,s=0;
    for(int i=0;i<N-1;i++){
        if(a[i]==a[i+1]){
            s=f;
            f=a[i];
            i++;
        }
    }
    cout<<(long long)f*s<<endl;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        string S = Read();
        int upper = int.Parse(S.Substring(0, 2));
        int lower = int.Parse(S.Substring(2));
        if(upper<=12 && upper>=1)
        {
            if(lower<=12 && lower>=1)
            {
                return "AMBIGUOUS";
            }
            else
            {
                return "MMYY";
            }
        }
        else if(lower <= 12 && lower >= 1)
        {
            return "YYMM";
        }
        else
        {
            return "NA";
        }
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll A,B;
    cin>>A>>B;
    cout<<(A*B)-(A+B-1);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
using namespace std;
int main(){
    int N,x,cnt=0,ans=1;
    cin >> N >> x;
    int c[N];
    for(int i=0;i<N;i++){
        cin >> c[i];
        cnt+=c[i];
        if(cnt>x){
            break;
        }
        ans++;
    }
    cout << ans << endl;

}

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


class Program
{
    static void Main(string[] args)
    {
        string[] KN = Console.ReadLine().Split(' ');
        int K = int.Parse(KN[0]);
        int N = int.Parse(KN[1]);

        string[] Astr = Console.ReadLine().Split(' ');
        int[] A = new int[N];
        for(int i=0; i<N; i++){
            A[i] = int.Parse(Astr[i]);
        }

        int maxDist = A[0] + K - A[N-1];

        for(int i=0; i<N-1; i++){
            maxDist = Math.Max(maxDist, A[i+1]-A[i]);
        }

        Console.WriteLine(K - maxDist);
    }
}

Measured memory_bytes: 34652
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m, q; scanf("%d%d%d", &n, &m, &q);
	std::vector<int> a(q), b(q), c(q), d(q);
	for(int i = 0; i < q; i++) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);

	std::vector<int> A(n + 1); A[0] = 1;
	auto solve = [&](auto&& solve, int i) -> int {
		if(i == n + 1) {
			int ret = 0;
			for(int j = 0; j < q; j++) if(A[b[j]] - A[a[j]] == c[j]) ret += d[j];
			return ret;
		}
		
		int ret = 0;
		for(int j = A[i - 1]; j <= m; j++) {
			A[i] = j;
			ret = std::max(ret, solve(solve, i + 1));
		}
		return ret;
	};
	printf("%d\n", solve(solve, 1));
	return 0;
}


Measured memory_bytes: 3804
import numpy as np
h, w, k = list(map(int, input().split()))
ss = []
for _ in range(h):
    s = list(map(int, list(input())))
    ss.append(s)

from itertools import product

mi = 1e9
ss = np.array(ss)
sss = np.cumsum(ss, axis = 1)
for binary in product([0, 1], repeat=h - 1):
    binary  = [0] + list(binary)
    
    ssss = [0]
    for j in range(h):
        if binary[j] == 1:
            ssss.append(sss[j])
        else:
            ssss[-1] = sss[j] + ssss[-1]
        
    ssss = np.array(ssss)
    if np.max(np.diff(ssss, axis = 1)) > k:
        continue
    
    count = 0
    for i in range(w):
        if max(ssss[:, i]) > k:
            ssss -= ssss[:, i - 1][:, None]
            count += 1
    count += sum(binary)
#     print(binary, count)
#     aaaaaa
    if count < mi:
        mi = count
print(mi)


Measured memory_bytes: 14924
package main

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

func Solve() {
  var N, K int
  NextInt(&N, &K)
  var P, C []int
  NextIntSlice(&P)
  for i := range P { P[i]-- }
  NextIntSlice(&C)
  V := make([]int, N)
  for i := range V { V[i]-- }
  L := make([][]int, N)
  for i := range V {
    if V[i] >= 0 { continue }
    V[i] = i
    p := P[i]
    c := C[p]
    l := 1
    for p != i {
      V[p] = i
      p = P[p]
      c += C[p]
      l++
    }
    L[i] = []int{l, c}
  }
  A := make([]int, N)
  for i := range A {
    lc := L[V[i]]
    A[i] = C[P[i]]
    k := K / lc[0]
    if k > 0 { A[i] = MaxInt(k * lc[1], A[i]) }
    p := i
    c := 0
    for j := 1; j < lc[0]; j++ {
      if j > K { break }
      p = P[p]
      c += C[p]
      A[i] = MaxInt(c, A[i])
      if k > 0 {
        if j <= K % lc[0] {
          A[i] = MaxInt(c + k * lc[1], A[i])
        } else {
          A[i] = MaxInt(c + (k - 1) * lc[1], A[i])
        }
      }
    }
  }
  Write(MaxInt(A...))
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

Measured memory_bytes: 2496
#include <iostream>

int main(){
    std::string str;
    std::cin >> str;

    int index1 = 0, index2 = 1;
    std::string odd = "RUD", even = "LUD";
    bool flg1 = true, flg2 = true;

    while(index1 <= str.length() - 1){
        if(std::string::npos != odd.find(str.at(index1))){
            index1 += 2;
        }else{
            flg1 = false;
            break;
        }
    }

    while(index2 <= str.length() - 1){
        if(std::string::npos != even.find(str.at(index2))){
            index2 += 2;
        }else{
            flg2 = false;
            break;
        }
    }

    std::string ans = "No";
    if(flg1 && flg2){
        ans = "Yes";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,a[500010],b[500010],cnt[500010];
int pd(int i,int x){
	int sum,mid,l=m-i+1,r=m,hh=m-i;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]<x)hh=mid,l=mid+1;
		 else r=mid-1;
	}
	sum=b[hh]-b[m-i];
	sum=(hh-m+i)*x-sum;
	return b[m-i]>=sum;
}
int main(){
	int i,x,l,r,mid,mx;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		cnt[x]++;
	}
	for(i=1;i<=n;i++)if(cnt[i]){
		m++;
		a[m]=cnt[i];
	}
	sort(a+1,a+m+1);
	for(i=1;i<=m;i++)b[i]=b[i-1]+a[i];
	for(i=1;i<=n;i++){
		if(i>m){
			puts("0");
			continue;
		}
		mx=0;
		l=1;r=n/i;
		while(l<=r){
			mid=(l+r)/2;
			if(pd(i,mid))mx=mid,l=mid+1;
			 else r=mid-1;
		}
		printf("%d\n",mx);
	}
}

Measured memory_bytes: 4992
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n= int(sys.stdin.readline())
    S= list(map(int, sys.stdin.readline().split()))
    q= int(sys.stdin.readline())
    T= list(map(int, sys.stdin.readline().split()))
    c=0
    for i in T:
        if i in S:
            c+=1
    print(c)



Measured memory_bytes: 8248
#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 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;

int main(){
	ll n, a, b, c, d;
	cin >> n >> a >>b >>c >>d;
	if(a > b) swap(a, b);
	rep(i, n) {
		int k = n - i-1;
		if(c*i-d*k <= b - a && b - a <= d*i-c*k) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

int main(){
ll N;
cin>>N;
for(ll i=0; i<N; ++i){
if(N==1)cout<<1<<endl;
else if(N>=2&&N>=i*i&&N<(i+1)*(i+1))
cout<<i*i<<endl; 
}
}


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

#define int long long

#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int mod = 1000000007;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s, t; cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int ans = INF;
	rep(i, n - m + 1) {
		int cnt = 0;
		rep(j, m) {
			if (s[i + j] != t[j]) {
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

long long calc(std::vector<int> v, int val) {
	long long cost = 0;
	for (int i = 0; i < v.size(); i++) {
		cost += (v[i] - val) * (v[i] - val);
	}
	return cost;
}

int main() {
	int n;

	std::cin >> n;
	
	std::vector<int> v(n);
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
	}

	long long min = LLONG_MAX;

	for (int i = -100; i <= 100; i++) {
		min = std::min(min, calc(v, i));
	}

	std::cout << min << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

int X, Y, y;

int main() {
  std::cin >> X >> Y;

  y = X * 2;
  if (y == Y) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  for (int i = 1; i <= X; i++) {
    y += 2;
    if (y == Y) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int sum = 0;
    while(true){
    if(K > N){
        sum += 1;
        break;
    }
    N /= K;
    sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  vector<double>in;
  double a;
  int count=0;
  while(cin >> a!='\0'){
    in.push_back(a);
    count++;
  }
  //cout << in[0] << endl;

  sort(in.begin(),in.end());

  //cout << count << endl;

  cout << in[count-1]-in[0]<< endl;

}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n);
  int count=0;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    if(a[a[i]-1]==i+1){
      count++;
    }
  }
  cout<<count/2<<'\n';
  return(0);
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, K = map(int, input().split())
H = list(map(int, input().split()))

cnt = 0
for i in range(N) :
  if H[i] >= K :
    cnt += 1
print (cnt)


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

int main() {
	string s;
	cin >> s;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
		cout << "3";
	else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
		cout << "2";
	else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
		cout << "1";
	else
		cout << "0";
	return 0;
}

Measured memory_bytes: 3592
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    s = 0
    P = int(1e9)+7
    for k in range(60):
        cnt = 0    
        for e in a:
            if (e>>k) & 1:
                cnt += 1
        s += cnt*(n-cnt)*pow(2, k, P)
        s %= P
    print(s)
if __name__ == '__main__':
    main()


Measured memory_bytes: 34212
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N = 1e5;
const ll oo = LONG_LONG_MAX;

ll n;
vector<ll> v, w; //values, weights
int main()
{
    ll cap;
    ll max_v = -1;
    cin >> n >> cap;
    v.push_back(0);
    w.push_back(0);
    for (int i = 0; i < n; i++)
    {
        long long wi, vi;
        cin >> wi >> vi;
        w.push_back(wi);
        v.push_back(vi);
        max_v = max(max_v, vi);
    }

    pair<ll, bool> dp[n + 1][(max_v * n) + 1];
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= max_v * n; j++)
        {
            if (i == 0 || j == 0)
                dp[i][j] = {oo, 0};
            else if (j == v[i] && w[i] <= cap)
                dp[i][j] = {min(w[i], dp[i-1][j].first), 1};
            else
            {
                if (dp[i - 1][j - v[i]].first + w[i] <= cap && dp[i - 1][j - v[i]].second == true)
                    dp[i][j] = {min(dp[i - 1][j - v[i]].first + w[i], dp[i-1][j].first), true};
                else
                    dp[i][j] = dp[i - 1][j];
            }

            // cout << "{" << (dp[i][j].first == oo? 0 : dp[i][j].first) << "," << dp[i][j].second << "}"
            //      << " ";
        }
        // cout << endl;
    }
    for (int i = max_v * n; i >= 1; i--)
    {
        if (dp[n][i].second == 1)
        {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 158080
def main():
    N = int(input())
    A = list(map(int, input().split()))
    n_odd = 0
    n_4mul = 0
    n_2mul = 0
    for a in A:
        if a % 2 == 1:
            n_odd += 1
        elif a % 4 == 0:
            n_4mul += 1
        else:
            n_2mul += 1
    if n_odd == 0:
        print('Yes')
    elif n_odd <= n_4mul and n_2mul > 0:
        print('Yes')
    elif n_odd == n_4mul + 1 and n_2mul == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 85376
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>

constexpr intmax_t MOD = 1e9+7;

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

  char buf[64];
  scanf("%s", buf);
  std::string S1 = buf;
  scanf("%s", buf);
  std::string S2 = buf;

  std::vector<int> pat;
  for (size_t i = 0; i < N; ++i) {
    if (S1[i] == S2[i]) {
      pat.push_back(1);
    } else {
      pat.push_back(0);
      ++i;
    }
  }

  intmax_t res = 3;
  if (pat[0] == 0) res *= 2;
  for (size_t i = 1; i < pat.size(); ++i) {
    if (pat[i-1] == 1) {
      res *= 2;
    } else if (pat[i] == 0) {
      res *= 3;
    }
    res %= MOD;
  }
  printf("%jd\n", res);
}


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

const int N = 1e5 + 5;
int n,m, p[N], connected[N];
stack<int> a,b;

int findset(int x){
    return p[x] == x?x:p[x] = findset(p[x]);
}
void unite(int x,int y){
    x = findset(x);
    y = findset(y);
    
    if(x!=y){
        int total = connected[x] + connected[y];
        connected[y] = total;
        p[x] = y;
    }
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    
 
    cin>>n>>m;
    for(int i = 1; i<= n; i++) p[i] = i, connected[i] = 1;
    int t1, t2;
    for (int i = 0; i < m; i++){
        cin>>t1>>t2;
        a.push(t1);
        b.push(t2);
    }
    
    ll total = (ll) n * (n-1)/2;
    stack<ll> ans;
    ans.push(total);
    ll temp = total;
    for (int i = 1; i < m; i++){
        t1 = a.top();a.pop();
        t2 = b.top();b.pop();
        if(findset(t1) != findset(t2)){
            t1 = findset(t1);
            t2 = findset(t2);
            temp -= (ll)connected[t1]* (ll)connected[t2];
            unite(t1, t2);
        }
        ans.push(temp);
    }

    while (!ans.empty()) {
        cout<<ans.top()<<endl;
        ans.pop();
    }
    
    return 0;
}


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

int main(){
    char A[4];
    for(int i = 0; i < 4; i++)  cin >> A[i];
    if((A[0]==A[1] && A[1]==A[2]) || (A[1]==A[2] && A[2]==A[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
int n, x, d;
struct segment{
    ll l, r;
    bool operator < (const segment & x ) const{
        return l == x.l ? r < x.r : l < x.l;
    }
};
map<int, vector<segment>> ss;

int main(){
    scanf("%d %d %d", &n, &x, &d);
    ///if(d == 0) ?
    if(d == 0){
        ///(x = 0 and d = 0) 1
        /// x x x x x x x x x x (n) tokens
        /// 2 1 0
        /// 1 1
        /// 0 1 2
        /// x 0 -> (n * (n + 1)) /2
        return !printf("%lld\n", x == 0 ? 1LL : n + 1);
    }
    auto calc = [&] (int x){
        return 1LL * x * (x + 1) / 2;
    };
    /// for each chosen k numbers
    for(int k = 0 ;k <= n ; k ++){
        int res = 1LL * k * x % d;
        ll nd = 1LL * k * x / d; // 2
        ll lft = calc(k - 1); // 2
        ll rgh = calc(n - 1) - calc(n - 1 - k); // 5
        lft += nd;
        rgh += nd;
      //  fprintf(stderr, "%d %d %lld %lld\n", k , res, lft, rgh);
        ss[res].push_back({lft, rgh});
    }
    ll ans = 0;
    for(auto &it : ss){
        auto a = it.second;
        sort(a.begin(), a.end());
        ll cL = a[0].l, cR = a[0].r;
        for(int i = 1 ;i < (int)a.size() ; i ++){
            if(a[i].l > cR){
                ans += (cR - cL + 1);
                cL = a[i].l;
                cR = a[i].r;
                continue;
            }
            cR = max(cR, a[i].r);
        }
        ans += cR - cL + 1;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,M;
	scanf("%d %d",&N,&M);
	char arr[N][N];
	char arr1[M][M];
	for(int i=0; i<N; i++)
    	scanf("%s",arr[i]);
	for(int i=0;i<M;i++)
	    scanf("%s",arr1[i]);
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			int c=0;
			for(int a=0; a<M; a++){
				for(int b=0; b<M; b++)
				{
					if(arr1[a][b]==arr[i+a][j+b])
					c++;
				}
			}
			if(c==(M*M))
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
for i in range(1,n):
    print(*a)
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        a[j+1]=a[j]
        j-=1
    a[j+1]=v
print(*a)



Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, vector<int>>> v(m);
  vector<int> p(m);
  rep(i,m) {
    int k;
    cin >> k;
    v[i].first = k;
    rep(j,k) {
      int s;
      cin >> s;
      v[i].second.push_back(s- 1);
    }
  }
  rep(i,m) cin >> p[i];

  int ans = 0;

  for (int bit = 0; bit < (1 << n); bit++) {
    bool isOk = true;
    rep(i, m) {
      int count = 0;
      int k = v[i].first;
      auto s = v[i].second;
      rep(j,k) {
        if (bit & (1 << s[j])) count++;
      }
      if (count % 2 != p[i]) isOk = false;
    }
    if (isOk) ans++;
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3632
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	
	static boolean[] prime = new boolean[50100];
	static int[] bp = new int[50100];
	static int[] np = new int[50100];
	
	public static void main(String[] args){
		ersis();
		while(scan.hasNext()){
			int n = si();
			out.println(bp[n]+" "+np[n]);
		}
		out.flush();
	}
	
	static void ersis(){
		prime[0] = prime[1] = true;
		for (int i = 0; i*i < 50100 ; i++){
			if(!prime[i]){
				for (int j = i*2; j < 50100 ; j+=i)
					prime[j] = true;
			}
		}
		int tmp = 0;
		for (int i = 0; i < 50100; i++){
			bp[i] = tmp;
			if(!prime[i]){
				for (int j = tmp; j < i ; j++)
					np[j] = i;
				tmp = i;
			}
		}
	}
	
	static int si(){
		return Integer.parseInt(scan.next());
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int max_b = 50;
bool bit[max_b];


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

	ll n, m;
	cin >> n >> m;

	ll a[n];
	rep(i, n) cin >> a[i];

	ll b[n+1];
	b[0] = 0;
	rep(i, n) b[i+1] = (b[i] + a[i]) % m;

	map<ll, ll> mp;

	ll ans = 0;
	rep(i, n+1){
		ans += mp[b[i]];
		mp[b[i]]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define SPEED ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define ll long long int
#define inf 999999999
#define maxn 100003
const ll mod = 1e9+7;
using namespace std;
void code()
{
	ll n, sum = 0;
	cin >> n;
	ll ar[n];
	for (ll i = 0; i < n; ++i)
	{
		cin >> ar[i];
	}
	ll suffixarray[n];
	suffixarray[n-1] = ar[n-1];
	for(ll  i = n-2; i>= 0; --i)
	{
		suffixarray[i] = suffixarray[i+1]+ar[i];
		suffixarray[i] = suffixarray[i]%mod;
	}
	ll ans = 0;
	for(ll i = 0; i < n-1; i++)
	{
		sum = (suffixarray[i+1]*ar[i])%mod;
		ans+=sum;
		ans%=mod;
	}
	cout << ans;
}
int main()
{
	SPEED
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	int t = 1;
	while(t--)
	{
		code();
	}
}

Measured memory_bytes: 6744
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n,A,B,K,ans,P=998244353,f[300005],inv[300005];

ll Pow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)(res*=a)%=P;
		(a*=a)%=P;b>>=1;
	}
	return res;
}

ll C(ll a,ll b){
	if(b>n)return 0;
	return (f[a]*inv[b]%P)*inv[a-b]%P;
}

int main(){
	scanf("%lld%lld%lld%lld",&n,&A,&B,&K);
	if(K==0){cout<<1;return 0;}
	if((A+B)*n<K){cout<<0;return 0;}
	f[1]=1;f[0]=1;inv[0]=1;
	for(int i=2;i<=n;++i)f[i]=f[i-1]*i%P;
	inv[n]=Pow(f[n],P-2);
	for(int i=n-1;i;--i)inv[i]=(i+1)*inv[i+1]%P;
	for(ll x=0;x<=n&&x*A<=K;++x){
		if((K-A*x)%B)continue;
		ll y=(K-A*x)/B;
		(ans+=C(n,x)*C(n,y))%=P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
def main(X,A,N):
    for i in range(N-1):
        X[i+1] = 2*A[i] - X[i]
    return X
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Aoddsum = sum(A[1:N:2])
X1 = S - 2*Aoddsum
X = [0]*N
X[0] = X1
main(X,A,N)
for x in X:
    print(x, end=" ")


Measured memory_bytes: 14028
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int h[n],cost[n];
    cost[0]=0;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    cost[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        cost[i]=min(abs(h[i]-h[i-1])+cost[i-1] , abs(h[i]-h[i-2])+cost[i-2]);
    }
    cout<<cost[n-1];




}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
using namespace std;


int main() {
int n=1;
int x;
int k=0;
cin >> x;
int N = 0;

rep(i,180){
N = n+i;
if((N*360)%x==0){
    k = N*360/x;break;
}
}
//cout << N << endl;
cout << k << endl;
}


Measured memory_bytes: 3592
#include <iostream>

using std::cout;
using std::cin;

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    
    int c[6];
    int yen[]={1,5,10,50,100,500};
    int sum,ans;
    for(int i=0;i<6;i++)
    {
        cin>>c[i];
        sum+=c[i]*yen[i];
    }
    
    sum>=1000?ans=1:ans=0;
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 1200
import sys
import math 
from collections import defaultdict
input = lambda : sys.stdin.readline().strip()
n = int(input())
factors = defaultdict(int)
while n%2==0:
    factors[2]+=1
    n = n//2
for i in range(3,int(n**0.5)+1,2):
    while n%i==0:
        factors[i]+=1
        n = n//i 
if n>2:
    factors[n]+=1
ans = 0
for k in factors:
    ans += (-1+int((1+8*(factors[k]))**0.5))//2
print(ans)

Measured memory_bytes: 9736
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  ll ans = 1;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(All(v));
  bool f = true;
  if(n % 2 == 1){
    if(v[0] != 0)f = false;
    for(int i = 1; i < n-1; i+=2){
      if(v[i] != v[i+1])f = false;
    }
    if(f){
      for(int i = 0; i < (n-1)/2; i++){
        ans *= 2;
        ans %= MOD;
      }
    }
    else ans = 0;
  }
  else{
    for(int i = 0; i < n-1; i+=2){
      if(v[i] != v[i+1])f = false;
    }
    if(f){
      for(int i = 0; i < n/2; i++){
        ans *= 2;
        ans %= MOD;
      }
    }
    else ans = 0;
  }
  cout << ans << endl;
  system("pause");
}

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

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

int main(void) {
	map<char, int> m;
	string s;
	int i;
	cin >> s;
	rep (i, s.size()) {
		m[s[i]]++;
	}
	if (max(max(m['a'], m['b']), m['c']) - min(min(m['a'], m['b']), m['c']) > 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <stdio.h>

int n;
int F[50];

int main() {
    scanf("%d", &n);
    F[0] = F[1] = 1;
    
    for (int i = 2; i <= n; i++) {
        F[i] = F[i-1] + F[i-2];
    }
    
    printf("%d\n", F[n]);
}




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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	int a, b, c;
	cin >> a >> b >> c;
		if (a + b >= c) { c("Yes"); }
		else  c("No"); 
	
	
	ed;
	return 0; 
}



Measured memory_bytes: 256
'''
Created on 2020/08/23

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  ans=0
  for i in range(1,N+1):
    ans+=((N//i)*(N//i+1)*i)//2
  print(ans)
  return
main()
#間に合わなそう

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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


  ll n = s.size();

  ll cnt = 0;
  ll i = 0;
  for(; i < n-1; i++){
    if(s[i] == s[i+1]){
      if(s.substr(i, 1) != s.substr(i+1, 2)){
        i += 2;
        cnt++;
      }
      else{
        i++;
      }
    }
    cnt++;
  }
  if(i == n-1) cnt++;

  cout << cnt << endl;

  
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long long n;
    long long mn = 1e16+1;

    cin >> n;
    for (int i = 0; i < 5; i++) {
        long long tmp;
        cin >> tmp;
        mn = min(mn, tmp);
    }

    long long ans = n / mn + 4;
    if (n % mn != 0) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> S(M);
    rep(i,M){
        int k;
        cin >> k;
        rep(j,k){
            int s;
            cin >> s;s--;
            S[i].push_back(s);
        }
    }
    vector<int> p(M);
    rep(i,M){
        cin >> p[i];
    }
    int ans = 0;
    rep(bit,1<<N){
        bool ok = true;
        rep(i,M){
            int cnt = 0;
            for(auto j : S[i]){
                if(bit & 1<<j)cnt++;
            }
            if(cnt % 2 != p[i])ok = false;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int A,B;
  cin>>A>>B;
  int key=0;
  for(int i=0;i<20000;i++) {
    if(floor(i*0.08)==A && floor(i*0.1)==B) {
      cout << i << endl;
      key++;
      break;
    }
  }
  if(key==0) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
  int  l,c,n;
  scanf("%d%d%d", &l,&c,&n);

  if(l>=c){
    for(int i=1; i<=c; i++){
      if(l*i >= n)
      {
        printf("%d\n", i);
        break;
      }
    }
  }
  else
  {
    for(int i=1; i<=l; i++){
      if(c*i >= n)
      {
        printf("%d\n", i);
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define pp pair<int,int>
#define N 107 // check
#define M 10000
#define K 76
#define ll long long
using namespace std;

int n;

int tab[N];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin >> n;

    for(int i = 0; i < n; ++i) {
        cin >> tab[i];
    }

    int ans = 0;

    tab[n] = 1000000;

    int ctr = 1;

    for(int i = 1; i <= n; ++i) {
        if(tab[i-1] == tab[i]) {
            ctr++;
        } else {
            ans += ctr/2;
            ctr = 1;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    ans = [0, 0]
    for _ in range(n):
        a, b = LI()
        if ans[0] < a:
            ans = [a, b]
    print(sum(ans))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 41816
n=int(input())
A=list(map(int,input().split()))
b=0
for i in range(n):
  if A[i]<0:
    b=b+1
for i in range(n):
  A[i]=abs(A[i])
if b%2==0:
  print(sum(A))
else:
  print(sum(A)-min(A)*2)

Measured memory_bytes: 14412
#include<bits/stdc++.h>
#define LL long long
static const LL INF = 1<<50;

using namespace std;

int n,k,ans;
LL s[10001];
string num[11];
int t=0;
void cal(string sum,int depth,int bit){
    if(depth==k){
        int num;
        num=atoi(sum.data());
        s[t]=num;
        t++;
        return;
    }
    for(int i=1;i<=n;++i){
        int b=1<<i;
        if(bit&b){
            int k=bit-b;
            cal(sum+num[i],depth+1,k);
        }
    }
}

int main(){
    while(1){
        t=0;
        for(int i=0;i<11;++i)num[i]='0';
        memset(s,0,sizeof(s));
        int p=1;
        cin>>n>>k;
        if(n==0&&k==0)break;
        string a;
        for(int i=1;i<=n;++i){
            p+=pow(2,i);
        }
        for(int i=1;i<=n;++i){
            cin>>num[i];
        }
        cal(a,0,p);
        sort(s,s+t);
        for(int i=0;i<t;++i){
            if(s[i]&&s[i]!=s[i+1]){
                ans++;
            }
        }
        cout<<ans<<endl;
        ans=0;
    }
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll n;
  cin >> n;

  ll x = 0;
  ll y;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i == 0) {
      if (i > x) {
        //debug(x);
        //debug(y);
        x = i;
        y = n/i;
      }
    }
  }

  //debug(x);
  //debug(y);
  cout << x-1 + y-1 << endl;
  return 0;
}

Measured memory_bytes: 256
def f3(n):
    a=b=c=0
    for _ in range(n):
        a,b,c=(a+b+c+1)%100000007,a,b
    return a
    
def f5(n):
    a=b=c=d=e=0
    for _ in range(n):
        a,b,c,d,e=(a+b+c+d+e+1)%100000007,a,b,c,d
    return a

while 1:
    s=input()
    if s=="#":break
    ans=1
    num="_"
    cnt=1
    for n in s+"_":
        if n==num:
            cnt+=1
        else:
            if num in "80":
                ans=ans*f3(cnt)%100000007
            else:
                ans=ans*f5(cnt)%100000007
            num=n
            cnt=1
    print(ans)


Measured memory_bytes: 6040