akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto i : x){cerr << " [" << i << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vii = vector<pii>;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int n, answer = inf;
	cin >> n;
	vi a(n), pref(n + 1);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		pref[i + 1] = pref[i] + a[i];
	}
	for (int i = 0; i < n; i++){
		answer = min(answer, abs(pref[n] - pref[i] - pref[i]));
	}
	cout << answer << "\n";
	return 0;
}
 


Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var sum = 0;
	for(var i = 0; i < N; i++){
		sum += 1 / list[i];
	}
	myout(1 / sum);
}


Measured memory_bytes: 31420
function main(input) {
const args = input.split(' ');
const a = parseInt ( args[0] , 10 );
const b = parseInt ( args[1] , 10 );
console.log(Math.max( 2*a - 1 , a + b , 2*b - 1 ));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
if __name__ == "__main__":
    N = int(input())
    a = list(map(int,input().split()))
    b = sorted(a)
    cnt = 0
    for i in range(N):
        if a[i] != b[i]:
            cnt += 1
    if cnt == 2 or cnt == 0:
        print("YES")
    else:
        print("NO")
    

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline long Max(long x,long y){return x>y?x:y;}
int main()
{
  int a=IN(),b=IN(),c=IN(),d=IN();
  return OUT(Max(Max(Max(1l*a*c,1l*a*d),1l*b*c),1l*b*d)),0;
}

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

const int INF = 1001001001;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}




int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
  { // bellman-ford
    vector<int> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      rep(i,m) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        int newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("-1");
        return 0;
      }
    }
    
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
  }
  return 0;
}


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

using namespace std;
#define int long long


signed main(){
    int N;
    cin >> N;
    
    int T[N+10],total=0;
    for(int i=0;i<N;i++){
        cin >> T[i];
        total += T[i];
    }
    
    int M;
    cin >> M;
    
    int P,X,add;
    for(int i=0;i<M;i++){
        cin >> P >> X;
        add = T[P-1]-X;
        
        cout << total-add << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 256
n = int(input())
w = []
for i in range(n):
    w.append(input())

check = []
check.append(w[0])
for i in range(1, n, 1):
    if(w[i-1][-1] == w[i][0]):
        if((w[i] in check) == False):
            check.append(w[i])
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; }

int main(){
	string s; cin >> s;
	if(s[s.size() - 1] == 's'){
		cout << s + "es" << endl;
	}else{
		cout << s + "s" << endl;
	}
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    ll n;
    cin >> n;
    vector<ll>ans;
    while(n){
        n--;
        ans.push_back(n%26);
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()) {
        cout << char(ans[i]+'a');
    }
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var S = Console.ReadLine().Split().Select(int.Parse).ToArray();

			var q = int.Parse(Console.ReadLine());
			var T = Console.ReadLine().Split().Select(int.Parse).ToArray();

			Array.Sort(S);
			Array.Sort(T);

			System.Console.WriteLine(T.Where(t => bin(S, t)).Count());
		}

		static bool bin(int[] array, int val)
		{
			var min = 0;
			var max = array.Length;
			var mid = (max + min) / 2;

			var isFound = false;
			while (min < max)
			{
				if (array[mid] == val)
				{
					isFound = true;
					break;
				}
				else if (array[mid] < val)
				{
					min = mid + 1;
				}
				else
				{
					max = mid;
				}
				mid = (max + min) / 2;
			}

			return isFound;
		}
	}
}



Measured memory_bytes: 29288
#[derive(Debug)]
struct ObservatoryPath {
    from: usize,
    to: usize,
}

fn main() {
    let s = read_line();
    let s = read_num_vec(s, 2);
    let n = s.get(0).unwrap().to_owned();
    let m = s.get(1).unwrap().to_owned();
    let s = read_line();
    let height_vec = read_num_vec(s, n as usize);
    let mut path_vec: Vec<ObservatoryPath> = vec![];
    for _ in 0..m {
        let s = read_line();
        let s = read_num_vec(s, 2);
        let a = s.get(0).unwrap().to_owned();
        let b = s.get(1).unwrap().to_owned();
        path_vec.push(ObservatoryPath {
            from: (a - 1) as usize,
            to: (b - 1) as usize,
        });
    }
    let mut is_good_vec = vec![];
    for _ in 0..n {
        is_good_vec.push(true);
    }

    for path in path_vec {
        let from_height = height_vec.get(path.from).unwrap().to_owned();
        let to_height = height_vec.get(path.to).unwrap().to_owned();
        if from_height >= to_height {
            let is_good = is_good_vec.get_mut(path.to).unwrap();
            *is_good = false;
        }
        if to_height >= from_height {
            let is_good = is_good_vec.get_mut(path.from).unwrap();
            *is_good = false;
        }
    }

    let mut num_good = 0;
    for is_good in is_good_vec.clone() {
        if is_good {
            num_good += 1;
        }
    }

    println!("{}", num_good);
}

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().to_owned()
}

fn read_num_vec(s: String, length: usize) -> Vec<i64> {
    let mut ws = s.split_whitespace();
    let mut result = vec![];
    for _ in 0..length {
        result.push(ws.next().unwrap().parse().unwrap());
    }
    result
}


Measured memory_bytes: 4912
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    ll ret = 1;
    for (int i = 1; i < sqrt(n) + 1; ++i) {
        if (i * i <= n)
            ret = i * i;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n+1)
	a[0] = 1
	a[1] = 1
	for i := 2; i <= n; i++ {
		a[i] = a[i-1] + a[i-2]
	}
	fmt.Println(a[n])
}



Measured memory_bytes: 1112
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static int[] dice;
	static int a;
	static int b;
	static int c;
	static int d;
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		dice = new int[6];
		for(int i=0; i<6; i++) {
			dice[i] = sc.nextInt();
		}

		int o = sc.nextInt();
		for(int i=0; i<o; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			while(true) {
				diceRoll();
				if(dice[0]==a && dice[1]==b) {
					System.out.println(dice[2]);
					break;
				}
			}
		}

		sc.close();
	}

	public static void diceRoll() {
		Random rand = new Random();
		int num = rand.nextInt(4);
		if(num==0) {
			s();
		}else if(num==1) {
			n();
		}else if(num==2) {
			w();
		}else if(num==3){
			e();
		}
	}

	public static void s() {
		a = dice[0];
		b = dice[1];
		c = dice[4];
		d = dice[5];

		dice[0] = c;
		dice[1] = a;
		dice[4] = d;
		dice[5] = b;
	}

	public static void w() {
		a = dice[0];
		b = dice[2];
		c = dice[3];
		d = dice[5];

		dice[0] = b;
		dice[2] = d;
		dice[3] = a;
		dice[5] = c;
	}

	public static void e() {
		a = dice[0];
		b = dice[2];
		c = dice[3];
		d = dice[5];

		dice[0] = c;
		dice[2] = a;
		dice[3] = d;
		dice[5] = b;
	}

	public static void n() {
		a = dice[0];
		b = dice[1];
		c = dice[4];
		d = dice[5];

		dice[0] = b;
		dice[1] = d;
		dice[4] = a;
		dice[5] = c;
	}
}


Measured memory_bytes: 26388
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

using VT = vector<int>;
struct RollingHash {
	static const ll mo0=1000000021,mo1=1000000009;
	static ll mul0,mul1;
	static const ll add0=1000010007, add1=1003333331;
	static vector<ll> pmo[2];
	VT s; int l; vector<ll> hash_[2];
	void init(VT s) {
		this->s=s; l=s.size(); int i,j;
		hash_[0]=hash_[1]=vector<ll>(1,0);
		if(!mul0) mul0=10009+(((ll)&mul0)>>5)%259,mul1=10007+(((ll)&mul1)>>5)%257;
		if(pmo[0].empty()) pmo[0].push_back(1),pmo[1].push_back(1);
		FOR(i,l) hash_[0].push_back((hash_[0].back()*mul0+add0+s[i])%mo0);
		FOR(i,l) hash_[1].push_back((hash_[1].back()*mul1+add1+s[i])%mo1);
	}
	pair<ll,ll> hash(int l,int r) { // s[l..r]
		if(l>r) return make_pair(0,0);
		while(pmo[0].size()<r+2)
			pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((hash_[0][r+1]+(mo0-hash_[0][l]*pmo[0][r+1-l]%mo0))%mo0,
			             (hash_[1][r+1]+(mo1-hash_[1][l]*pmo[1][r+1-l]%mo1))%mo1);
	}
	pair<ll,ll> hash(VT s) { init(s); return hash(0,s.size()-1); }
	static pair<ll,ll> concat(pair<ll,ll> L,pair<ll,ll> R,int RL) { // hash(L+R) RL=len-of-R
		while(pmo[0].size()<RL+2) pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((R.first + L.first*pmo[0][RL])%mo0,(R.second + L.second*pmo[1][RL])%mo1);
	}
};
vector<ll> RollingHash::pmo[2]; ll RollingHash::mul0,RollingHash::mul1;
RollingHash ar,br;

int N;
int A[202020];
int B[202020];
vector<int> As,Bs;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
    // 2Nぐらい考慮
	FOR(i,N*2+5) As.push_back(A[i%N]^A[(i+1)%N]);
	FOR(i,N*2+5) Bs.push_back(B[i%N]^B[(i+1)%N]);
	ar.init(As);
	br.init(Bs);
	// hash比較
	vector<pair<int,int>> V;
	FOR(i,N) {
		if(ar.hash(i,i+N-2)==br.hash(0,N-2)) {
			cout<<i<<" "<<(A[i]^B[0])<<endl;
		}
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	long long int N, K;
	cin >> N >> K;

	// O(n)
	long long int cnt[2] = {0, 0};
	
	for(long long int i=1; i<=N; i++) {
		// 
		if(i%K == 0) cnt[0]++;
		else if((i%K) == (K/2)) cnt[1]++;
	}
	long long int ans = cnt[0] * cnt[0] * cnt[0];

	if(K%2 == 0) {
		// Kが偶数の場合
		ans += cnt[1] * cnt[1] * cnt[1];
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;



int main() {
    int n; cin >> n;
    vector<int> ans;
    rep(i, n) {
        int a; cin >> a;
        if(ans.size() == 0 || ans[ans.size()-1] >= a) {
            ans.push_back(a);
        } else {
            int l = 0, r = ans.size()-1;
            while(r-l > 1) {
                int mid = l + (r - l) / 2;
                if(a > ans[mid]) r = mid;
                else l = mid;
            }
            if(l == 0 && a > ans[0]) ans[l] = a;
            else ans[r] = a;
        }
//
//        cout << "C" << endl;
//        rep(j, ans.size()) {
//            cout << ans[j] << endl;
//        }

    }

    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 892
n = int(input())
e = []
for i in range(n-1):
  a,b = map(int,input().split())
  if a < b:
    e.append((a,b))
  else:
    e.append((b,a))

# 連結成分の個数=頂点数-辺数 (ループが無い場合)
ans = 0
# 頂点数の合計を足す。
# 頂点iが何回カウントされるかを求める。
for i in range(1,n+1):
  ans += i*(i+1)//2
# 辺数の合計を引く。
# ある辺が、何回カウントされることになるかを求める。
for a,b in e:
  ans -= a*(n-b+1)
print(ans)

Measured memory_bytes: 92476
#include <bits/stdc++.h>
typedef long long ll;
ll m = (long long)1e9 + 7;
ll sz = 1e5 + 5;
using namespace std;


void solve(){
    ll n;
    cin >> n;
    ll ans = LLONG_MAX;
    for(ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            ans = min(ans, i-1 + n/i-1);
        }
    }
    cout << ans << "\n";
}


int main()
{
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n+1);
    range(i,1,n+1) cin >> a[i];

    vint res(n+1,0);
    int cnt=0;

    for(int i=n; i>0; i--){
        int sum=0;
        for(int j=2; i*j<n+1; j++){
            sum+=res[i*j];
        }
        if(a[i]==1){
            if(sum%2==1) res[i]=0;
            else res[i]=1,cnt++;
        }else{
            if(sum%2==0) res[i]=0;
            else res[i]=1,cnt++;
        }
    }
    cout<<cnt<<endl;
    range(i,1,n+1) if(res[i]) cout<<i<<' ';
    if(cnt!=0) cout<<endl;
}

Measured memory_bytes: 6240
#include <bits/stdc++.h>
	#define LOCAL
	using namespace std;
	template <typename A, typename B>
	ostream& operator <<(ostream& out, const pair<A, B>& a) {
	out << "(" << a.first << "," << a.second << ")";
	return out;
	}
	template <typename T, size_t N>
	ostream& operator <<(ostream& out, const array<T, N>& a) {
	out << "["; bool first = true;
	for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
	return out;
	}
	template <typename T>
	ostream& operator <<(ostream& out, const vector<T>& a) {
	out << "["; bool first = true;
	for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
	return out;
	}
	template <typename T, class Cmp>
	ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
	out << "{"; bool first = true;
	for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
	return out;
	}
	template <typename U, typename T, class Cmp>
	ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
	out << "{"; bool first = true;
	for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
	return out;
	}
	#ifdef LOCAL
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	#else
	#define trace(...) 42
	#endif
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
	cerr << name << ": " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
	}
	#define rep(i,n) for(int i=0; i<(n); i++)
	using ll = long long;
	#define int long long
	using P = pair<int,int>;
	//#########################################
	signed main(){
		int k,s;cin >> k >> s;
		int ans = 0;
		for(int x = 0;x <= k;x++){
			for(int y = 0;y <= k;y++){
				int z = s-x-y;
				if(z >= 0 && z <= k)ans++;
			}
		}
		printf("%lld\n",ans);
		return 0;
	}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  long long N,M,tmp,tmp_1,half,max_num;
  long long mod=1000000007;
  cin>>N>>M;
  half=sqrt(M);
  vector<long long> v;
  v.push_back(0);
  v.push_back(0);
  max_num=0;
  for(long long i=2;i<=half;++i){
    tmp=0;
    while(M%i==0){
      M=M/i;
      tmp+=1;
    }
    max_num=max(max_num,tmp);
    v.push_back(tmp);
  }
long long ans=1;
//vの中身とMの中身についてcomb計算
long long dp[N+max_num+1][max_num+1];
for(long long j=0;j<=max_num;++j){
  for(long long i=j;i<=N+max_num;++i){
    if(j==0){
      dp[i][j]=1;
    }
    else if(j==1){
      dp[i][j]=(i%mod);
    }
    else if(i==j){
      dp[i][j]=1;
    }
    else{
      dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%mod;
    }
  }
}

for(long long i=2;i<=half;++i){
  ans*=dp[N+v[i]-1][v[i]];
  ans%=mod;
}
  
  if(M!=1){
    ans*=N;
    ans=ans%mod;
  }
  cout<<ans;
return 0;
}


Measured memory_bytes: 23932
/*
      author : nishi5451
      created: 11.08.2020 22:35:30
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
    return 0;
}

Measured memory_bytes: 3508
//yashverma

#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define Pi 3.141592653589793
#define MOD 1000000007
// For i/o
#define sd1(a) scanf("%d",&a)
#define sd2(a,b) scanf("%d %d",&a,&b)
#define sd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sf scanf
#define pf printf
// For debugging
#define deb(a) printf("deb%d\n",a)

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

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B;cin>>A>>B;
    cout<<(A+B)%24<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
  int  N;
  cin >> N;
  vector<string> name(N);
  map<char, long long int> m;
  for(int i = 0; i < N; i++){
    cin >> name[i];
    m[name[i][0]]++;
  }
  string  march = "MARCH";
  long long int ans = 0LL;
  for(int i = 0; i < march.size(); i++){
    for(int j = i + 1; j < march.size(); j++){
      for(int k = j + 1; k < march.size(); k++){
        ans += m[march[i]] * m[march[j]] * m[march[k]];
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 6144
#include<stdio.h>
#include<iomanip>
#include<iostream>
using namespace std;
int main()
{
  long double l;
  long double ans;
  cin>>l;
  ans = (l/3)*(l/3)*(l/3);
  cout<<fixed;
  cout<<setprecision(6)<<ans;
  return(0);
}

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

int main() {
    int n,o,a,b,c,d,e,f,g,h;
    cin >> n;
    o = n;
    a = n / 100000000;
    n -= a * 100000000;
    b = n / 10000000;
    n -= b * 10000000;
    c = n / 1000000;
    n -= c * 1000000;
    d = n / 100000;
    n -= d * 100000;
    e = n / 10000;
    n -= e * 10000;
    f = n / 1000;
    n -= f * 1000;
    g = n / 100;
    n -= g * 100;
    h = n / 10;
    n -= h * 10;

    if(o % (a+b+c+d+e+f+g+h+n) == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;
string rev(string s){
  reverse(s.begin(),s.end());
  return s;
}

int main(){
  int n;
  map<string,int>ans;
  cin >> n;
  while(n--){
    ans.clear();
    string train = "";
    cin >> train;
    for(int i = 1 ; i < train.size() ; i++ ){
      string a = train.substr(0,i);
      string b = train.substr(i,train.size()-i);

      string ra = rev(a);
      string rb = rev(b);

      ans[a+b]=1;ans[a+rb]=1;
      ans[ra+b]=1;ans[ra+rb]=1;
      ans[b+a]=1;ans[rb+a]=1;
      ans[b+ra]=1;ans[rb+ra]=1;
    }
    cout << ans.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1304
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"2
3 4"# => r#"3.5"#,
r#"3
500 300 200"# => r#"375"#,
r#"5
138 138 138 138 138"# => r#"138"#,
}

fn cmp_f64(a: &f64, b: &f64) -> std::cmp::Ordering {
    if a.is_nan() {
        return std::cmp::Ordering::Greater;
    }
    if b.is_nan() {
        return std::cmp::Ordering::Less;
    }
    if a < b {
        return std::cmp::Ordering::Less;
    } else if a > b {
        return std::cmp::Ordering::Greater;
    }
    return std::cmp::Ordering::Equal;
}

fn pot(v: Vec<f64>) -> Vec<f64> {
    let mut value = v.clone();

    if value.len() == 1 {
        value.to_vec()
    } else {
        value.sort_by(cmp_f64);

        let a = (value[0] + value[1]) / 2f64;
        value.push(a);

        pot(value[2..].to_vec())
    }
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        v: [f64; n]
    }

    let nv = pot(v);

    nv[0].to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
	bool bo=false;
	int n;
	cin>>n;
	if(n == 0) return 0;
	int i[1001]={0};
	int p[1001]={0};
	int q[1001]={0};
	int r[1001]={0};
	for(int j=0;j<n;j++){
		cin>>i[j]>>p[j]>>q[j]>>r[j];
	}
	int P,Q,R,C;
	cin>>P>>Q>>R>>C;
	for(int j=0;j<n;j++){
		if(p[j]<=P&&q[j]<=Q&&r[j]<=R){
			if(4*p[j]+9*q[j]+4*r[j]<=C){
				cout<<i[j]<<endl;
				bo=true;
			}
		}
	}
	if(bo == false) cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector <int> n;

int main(){
	int n,m,t,cnt=0;
	double al=0;
	vector <int> a;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>t;
		al+=t;
		a.push_back(t);
	}
	al/=4*m;
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		if(a[i]>=al){
			cnt++;
		}
	}
	if(cnt>=m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  vector<vector<int>> d(h, vector<int>(w, -1));
  queue<P> que;
  rep(i, h) rep(j, w) {
    if (a[i][j] == '.') continue;
    d[i][j] = 0;
    que.push(make_pair(i, j));
  }

  while (que.size()) {
    P p = que.front();
    que.pop();
    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if (d[nx][ny] != -1) continue;
      d[nx][ny] = d[p.first][p.second] + 1;
      que.push(make_pair(nx, ny));
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, d[i][j]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16136
# coding: UTF-8
from collections import deque
n = int(input())
arrow = {}
visited = set()
d = {}
f = {}


for i in range(n):
  raw = list(map(int,input().split()))
  #print(raw)
  u = raw.pop(0)
  k = raw.pop(0)
  raw.sort()
  q = deque(raw)
  arrow[u] = q
  d[u] = -1
  f[u] = -1

def dfslocal(v,t,arrow,f,d):
  t += 1
  d[v] = t
  visited.add(v)
  #print("First visit to " + str(v) + " at " + str(t) + "!")
  while arrow[v]:
    k = arrow[v].popleft()
    if k not in visited:
      
      t = dfslocal(k,t,arrow,f,d)
  f[v] = t+1
  return t+1

def dfsglobal(arrow,f,d):
  t = 0
  for u in range(n):
    if u+1 not in visited:
      t = dfslocal(u+1,t,arrow,f,d)
  return t

t = dfsglobal(arrow,f,d)

for i in range(n):
  print(str(i+1) + " " + str(d[i+1]) + " " + str(f[i+1]))


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	int ans_mask = -1;
	for (int m = 0; m < 8; m++) {
		int s = S[0] - '0';
		for (int i = 0; i < 3; i++) {
			int coeff = (m & (1 << i)) ? 1 : -1;
			s += coeff * (S[i+1]-'0');
		}
		if (s == 7) ans_mask = m;
	}
	assert(ans_mask >= 0);

	string ans = string(1, S[0]);
	for (int i = 0; i < 3; i++) {
		ans += (ans_mask & (1 << i)) ? '+' : '-';
		ans += S[i+1];
	}
	ans += string("=7");
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define ft first
#define sd second
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
const int maxn = 100000+5;


set<ll> allDivisor;
set<ll> disjoint;

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

void getDivisor(ll M){
    for(ll i = 1; i * i <= M; i++){
        if(M % i == 0){
            allDivisor.insert(i);
            allDivisor.insert(M/i);
        }
    }
}

bool isDisjoint(ll x){
    for(auto itr = disjoint.begin(); itr != disjoint.end(); ++itr){
        if(gcd(x, *itr) != 1)
            return false;
    }
    return true;
}

int getMaxSize(ll M){
    for(auto itr = allDivisor.begin(); itr != allDivisor.end(); ++itr){
        if(disjoint.empty()){
            disjoint.insert(*itr);
        }
        else if(isDisjoint(*itr))
            disjoint.insert(*itr);
    }

    return disjoint.size();
}

int main(){
    //freopen("input.txt", "r", stdin);
    ll A, B;
    cin >> A >> B;
    ll M = gcd(A, B);
    getDivisor(M);

    cout<< getMaxSize(M)<<endl;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int m[2], d[2];
    cin >> m[0] >> d[0] >> m[1] >> d[1];
    cout << (d[1] == 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
		long long a,b,c,k,ans;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
		ans=a-b;
		if(k%2==1)ans=ans*(-1);
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

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

    ll ret = 0;
    for (ll i = 0; i < base.size(); ++i) {
        if (base.at(i) != 'A' && base.at(i) != 'T' && base.at(i) != 'G' && base.at(i) != 'C') {
            continue;
        }

        ll tempRet = 0;
        for (ll j = i; j < base.size(); ++j) {
            if (base.at(j) != 'A' && base.at(j) != 'T' && base.at(j) != 'G' && base.at(j) != 'C') {
                break;
            }

            tempRet++;
        }
        ret = max(ret, tempRet);
    }

    cout << ret << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<char> s(n);
  rep(i, n) cin >> s[i];

  rep(i, n) {
    if (s[i] == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	cout << (n+1)/2;

	return 0;
}



Measured memory_bytes: 256
S=input()

c=0
ans=0
for i in range(len(S)):
	if i<len(S)-1:
		if S[i]=="A" or  S[i]=="T" or  S[i]=="G" or  S[i]=="C": c+=1
		else:
			if ans < c: ans = c
			c=0
	else:
		if S[i]=="A" or  S[i]=="T" or  S[i]=="G" or  S[i]=="C": c+=1
		if ans < c: ans = c

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;

void solve(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d ; 
    int a1 = (c + b - 1) / b;
    int a2 = (a + d - 1) / d;
    if(a1 <= a2) {
        cout << "Yes";
    } 
    else {
        cout << "No";
    }
}

 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3640
#include <stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n]!=-1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0];
        int K = NK[1];
        var A = ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(A);

        var max = new Modular(0);
        var min = new Modular(0);

        for (int i = 0; i < N-K+1; i++)
        {
            min += Modular.Ncr(N - i - 1, K - 1) * A[i];
        }
        for (int i = K-1; i < N; i++)
        {
            max += Modular.Ncr(i, K - 1) * A[i];
        }
        var ans = max - min;
        WriteLine((int)ans);
    }
}
class Modular  //Modしながら計算するクラス
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    public static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    public static Modular Fac(int n)   //階乗
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Fac(int r, int n)
    {
        int temp = 1;
        for (int i = r; i <= n; i++)
        {
            temp = (int)(Math.BigMul(temp, i) % M);
        }
        return temp;
    }
    public static Modular Ncr(int n, int r) //nCr
    {
        return (n < r) ? 0
             : (n == r) ? 1
                        : (n < 1000000) ? Fac(n) / (Fac(r) * Fac(n - r))
                            : Fac(n - r + 1, n) / Fac(r);
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}

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

int main() {
    string s, t; cin >> s >> t;
    vector<int> col(26, -1), sc(s.size()), tc(t.size());
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
        if (col.at(s.at(i) - 'a') == -1) {
            sc.at(i) = col.at(s.at(i) - 'a') = c;
            c++;
        } else sc.at(i) = col.at(s.at(i) - 'a');
    }
    for (int i = 0; i < 26; i++) { col.at(i) = -1; }
    c = 0;
    for (int i = 0; i < t.size(); i++) {
        if (col.at(t.at(i) - 'a') == -1) {
            tc.at(i) = col.at(t.at(i) - 'a') = c;
            c++;
        } else tc.at(i) = col.at(t.at(i) - 'a');
    }
    for (int i = 0; i < s.size(); i++) {
        if (sc.at(i) != tc.at(i)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 2312
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;
const int inf = 1e9 +5;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        h.push_back(x);
    }
    vector<int> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min( dp[j] , dp[i] + abs( h[i]  - h[j] ) );
            }

        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N;
    cin >> N;
    bool hasSeven = false;
    string num = to_string(N);
    for(size_t i=0;i<3; i++)
    {
        if(num[i] == '7') hasSeven = true;
    }
    if(hasSeven) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3720
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <sstream>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

string S;
char ops[] = { '-', '+' };

void input() {
  cin >> S;
}

#define toi(x) (x - '0')

void solve() {
  Int x = 0;
  loop(first, 0, 2) {
    loop(second, 0, 2) {
      loop(third, 0, 2) {
        x = toi(S[0]);
        if (first) x += toi(S[1]);
        else x -= toi(S[1]);
        if (second) x += toi(S[2]);
        else x -= toi(S[2]);
        if (third) x += toi(S[3]);
        else x -= toi(S[3]);
        if (x == 7) {
          cout << S[0] << ops[first] << S[1] << ops[second] << S[2] << ops[third] << S[3] << "=7" << endl;
          return;
        }
      }
    }
  }
  cout << -1 << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N,M,K;
LL MOD=1e9+7;
LL c[500021];
LL rc[500021];
void init(){
	c[0]=1;
	rc[0]=1;
	REP(i,500011){
		c[i+1]=c[i]*(i+1);
		c[i+1]%=MOD;
	}
	LL now=MOD-2;
	LL ans=1;
	LL t=c[500010];
	while(now!=0){
		if(now%2==1){
			ans*=t;
			ans%=MOD;
		}
		now/=2;
		t*=t;
		t%=MOD;
	}
	rc[500010]=ans;
	for(int i=500009;i>=0;i--){
		rc[i]=rc[i+1]*(i+1);
		rc[i]%=MOD;
	}
	
}

int main(){
	init();
	cin>>N>>M>>K;
	LL ans=0;
	//LL now=((M*M-1)/2)%MOD;
	LL temp=1;
	REP(i,K-2){
		LL x=(N*M-2-i)%MOD;
		temp*=x;
		temp%=MOD;
	}
	temp*=rc[K-2];
	temp%=MOD;
	/*
	LL temp=c[N+M-2];
	temp*=rc[K-2];
	temp%=MOD;
	temp*=rc[N+M-2-(K-2)];
	temp%=MOD;
	*/
	REP(i,M-1){
		LL now=(i+1)*(LL)(i+2)/2;
		now%=MOD;
		LL a=(temp*now)%MOD;
		a%=MOD;
		a*=N;
		a%=MOD;
		a*=N;
		a%=MOD;
		ans+=a;
		ans%=MOD;
	}
	REP(i,N-1){
		LL now=(i+1)*(LL)(i+2)/2;
		now%=MOD;
		LL a=(temp*now)%MOD;
		a%=MOD;
		a*=M;
		a%=MOD;
		a*=M;
		a%=MOD;
		ans+=a;
		ans%=MOD;
	}
	
	
	cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int N;
    cin >> N;

    map<int, int> m;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        if(m.count(a) == 0) m[a] = 1;
        else m[a]++;
    }

    bool fl = true;
    ll ans = 1;
    if(N % 2 != 0){
        if(m[0] != 1) fl = false;
        for(int i=2; i<N; i=i+2){
            if(m[i] != 2) fl = false;
            ans = ans * 2;
            ans = ans % MOD;
        }
    }else{
        for(int i=1; i<N; i=i+2){
            if(m[i] != 2) fl = false;
            ans = ans * 2;
            ans = ans % MOD;
        }
    }

    if(!fl) cout << 0 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4096