akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h" // {{{
using namespace std;
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U) template<class T, class U>
#ifdef DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t= " << (x) << '\n'
#define line()      fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define LN()
#endif
using ll  = long long;
using pii = pair<int,int>;
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y) { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
inline bool inner(int val, int min, int max){ return min <= val && val < max; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f'3f3f3f3fLL;

namespace ydk{ // }}}

constexpr int LIM = (int)1e5 + 10;

ll N, K;
pii a[LIM];

signed _vim_is_god_()
{
    cin >> N >> K;

    rep(i, N) {
        int x, y;
        cin >> x >> y;
        a[i] = pii(x, y);
    }

    sort(a, a+N);
    ll sum = 0;
    int idx = 0;

    for(idx = 0; idx < N && sum < K; ++idx) {
        sum += a[idx].se;
        show(idx);
    }

    outl(a[idx-1].fi);

    return 0;
}

} // {{{

signed main(){ydk::_vim_is_god_(); return 0;} // }}}



Measured memory_bytes: 1024
import java.util.Collections;
import java.util.ArrayList;
import java.util.*;
import java.util.regex.Pattern;  
import java.util.Scanner;  
import java.util.regex.Matcher; 
public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		{
			int x=sc.nextInt();
			int sum=0;
			if(x/500>=1)
			{
				sum=sum+(x/500)*1000+((x%500)/5)*5;
			}
			else
			{
				sum=sum+(x/5)*5;
				
			}
			System.out.println(sum);
				
			
					
		     
		     }		
			
		
	}

	
	
	
}
		


Measured memory_bytes: 22868
package main

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

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

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

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

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

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

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

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

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	for i := 1; i <= n; i++ {
		if (i+1)*i/2 >= n {
			for j := 1; j <= i; j++ {
				if j == (i+1)*i/2-n {
					continue
				}
				fmt.Fprintln(writer, j)
			}
			return
		}
	}
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int ans = 0, n, k, a_min = 100000, start = 0, temp;
	vector<int> a(100000);

	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a_min = min(a_min, a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] != a_min)
			continue;
		temp = (i - start) / (k - 1);
		ans += temp;
		start += temp * (k - 1);
	}
	ans += (n - 1 - start - 1) / (k - 1) + 1;
	cout << ans << endl;
}


Measured memory_bytes: 3792
import numpy as np

x, n = list(map(int, input().split()))
ps = list(map(int, input().split()))
cand = [i for i in range(-2, 110) if i not in ps]
abs_cand = [abs(x - c - 0.1) for c in cand]

print(cand[np.array(abs_cand).argmin()])


Measured memory_bytes: 27152
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  char b;
  cin >> b;

  if (b == 'A') cout << 'T' << endl;
  if (b == 'T') cout << 'A' << endl;
  if (b == 'G') cout << 'C' << endl;
  if (b == 'C') cout << 'G' << endl;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
#define INF 1000000007
void chmin(int &a, int b) { if (a > b) a = b; }

int n,A,B,C;
vector<int> l;

int rec(int i, int a, int b, int c){
    if(i == n){
        if(!a || !b || !c)return INF;
        return abs(a - A) + abs(b - B) + abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
    }

    int res = rec(i+1,a,b,c);
    
    chmin(res, rec(i+1, a + l[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + l[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + l[i]) + (c ? 10 : 0));
    return res;
}

int main(){
    cin >> n;
    l.resize(n);
    cin >> A >> B >> C;
    rep(i,n)cin >> l[i];
    cout << rec(0,0,0,0) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left
S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1
mod = 10**9 + 7

for i in range(len(S)):
  x = S[-(i+1)]
  if x == '?':
    for k in range(10):
      for j in range(13):
        dp[i+1][(mul*k+j)%13] += dp[i][j]
        dp[i+1][(mul*k+j)%13] %= mod
  else:
    k = int(x)
    for j in range(13):
      dp[i+1][(mul*k+j)%13] += dp[i][j]
      dp[i+1][(mul*k+j)%13] %= mod
  mul = mul*10 % 13  
print(dp[len(S)][5])

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

int main(void){
    int a,b;
    int add,sub,mul;
    int most;
    scanf("%d" "%d",&a,&b);
    add = a+b;
    sub = a-b;
    mul = a*b;
    if(add<sub){
        most = sub;
    }
    else
    {
     most = add;   
    }
    
    if(most<mul)
        most = mul;

    printf("%d",most);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)     array<x,y>
#define p(x,y)      pair<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
/* template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; */

template<typename T>
T gcd(T a,T b){
    return b ? gcd(b, a%b) : a;
}

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int power(int x,int y){
    int res = 1;
    while(y > 0){
         if(y & 1) res *= x;
         y >>= 1;
         x *= x;
    }
    return res;
}

int power(int x,int y,int mod){
     int res = 1;
     x %= mod;
     while(y > 0){
          if(y & 1) res = (res * x) % mod;
          y >>= 1;
          x = (x * x) % mod;
     }
     return res;
}

class Template {
    int* readArray(int n){
        int *res = new int[n];
        for(int i = 0; i<n; i++){
            cin >> res[i];
        }
        return res;
    }
    void destroy(int *x){
        delete[] x;
    }
    v(int) readVector(int n){
        v(int) res(n);
        for(int i = 0; i<n; i++){
            cin >> res[i];
        }
        return res;
    }
    public:
    void solveOne(istream &in, ostream &out) {
        int a,b,c,d;
        in >> a >> b >> c >> d;
        out << max({a*c,b*d,a*d,b*c}) << "\n";
    }
    
    void solve(istream &in, ostream &out) {
        int nt = 1;
        //in >> nt;
        for (int it = 0; it < nt; ++it) {
            solveOne(in, out);
        }
    }
};
 
signed main() {
  fastio();
  Template solver;
  istream& in(cin);
  ostream& out(cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]%2!=0&&(i+1)%2!=0)
        cnt++;
        
    }
    cout<<cnt<<endl;
}

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

using namespace std;

int main()
{
	long N;
	cin >> N;
	
	long answer = (N - 1) * N / 2;
	cout << answer << endl;
	
	
	// 実験用コード
	/*
	vector<long> vec(N);
	for (int i = 0; i < N; i++)
	{
		vec[i] = i + 1;
	}
	
	do {
		int ans = 0;
		
		for (int i = 0; i < N; i++)
		{
			ans += (i + 1) % vec[i];
		}
		cout << ans << " ";
		
		for (int i = 0; i < N; i++)
		{
			cout << vec[i] << " ";
		}
        
		cout << endl;
		
	} while (next_permutation(vec.begin(), vec.end()));
	*/
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i+2 < n; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s,t;
    cin>>s>>t;
    int x=s.size(), y =t.size();
    int ans=inf;
    rep(i,x){
        int ret =0;
        rep(j,y){
            if(i+j==x){
                ret =inf;
                break;
            }
            if(s[i+j]==t[j]) continue;
            else ret ++;
        }
        ans =min(ans,ret);
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main()
{
	int N;
	cin >> N;
	vector<ll> a(N);

	for(int i = 0; i < N; i++)
		cin >> a[i];
	ll ans = 0;
	for(int i = 0; i < N; i++) 
		ans += a[i] - 1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();

    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> a;
	int A;
	cin >> A; a.emplace_back(A);
	cin >> A; a.emplace_back(A);
	cin >> A; a.emplace_back(A);
	sort(a.begin(),a.end());
	if(a[0]==5 && a[1]==5 && a[2]==7)
		cout << "YES" <<endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#define S(a,b) if(a>b){a^=b^=a^=b;}
a,b,c;
main(){
    scanf("%d%d%d",&a,&b,&c);
    S(a,b) S(a,c) S(b,c)
    printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
using namespace std;
il int read() {
	int res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 1005,M = 1e6+5; int n,m,id[N][N],cnt,c[2][2],dx[4] = {1,-1,-1,1},dy[4] = {1,-1,1,-1}; il bool check(int x,int y) {return x > 0 && y > 0 && x <= n && y <= n;}
	struct Graph {
		int d,ecnt,head[M],col[M]; struct Edge {int v,nxt;} e[M*100]; il void add(int u,int v) {e[++ecnt] = (Edge){v,head[u]}; head[u] = ecnt;} void dfs(int u,int c) {col[u] = c; grep(i,u) if (!col[v]) dfs(v,3-c);}
		il void solve() {rep(i,1,n) rep(j,1,n) {int y = sqrt(d),p,q; rep(x,0,sqrt(d)) {while (x*x+y*y > d) --y; if (x*x+y*y == d) rep(k,0,3) if (check(p = i+dx[k]*x,q = j+dy[k]*y)) add(id[i][j],id[p][q]);}} rep(i,1,cnt) if (!col[i]) dfs(i,1);}
	} g[2];
	il void solve(int a,int b) {int c = m*m,x; rep(i,1,n) rep(j,1,n) {x = id[i][j]; if (g[0].col[x] == a && g[1].col[x] == b) {printf("%d %d\n",i-1,j-1); if (!--c) return;}}}
	void main() {
		m = read(); n = m*2; rep(i,0,1) g[i].d = read(); rep(i,1,n) rep(j,1,n) id[i][j] = ++cnt; rep(i,0,1) g[i].solve();
		rep(i,1,cnt) ++c[g[0].col[i]][g[1].col[i]]; rep(i,0,1) rep(j,0,1) if (c[i][j] >= m*m) {solve(i,j); return;}
	}
}
int main() {
	qiqi::main(); return 0;
}

Measured memory_bytes: 135836
#include <iostream>
using namespace std;
 
int main(){
 char str[3];
  cin >> str;
  int answer=0;
  int ln=0;
  for(int i=0; i < 3; i++){
    
    if(str[i]=='R') ln++;
    else ln = 0;
    answer = answer < ln ? ln : answer;
  }
  cout << answer;
}

Measured memory_bytes: 3628
n = int(input())

s = ['' for i in range(n)]
def dfs(k, c):
    if k == n:
        print("".join(s))
        return
    for i in range(c):
        s[k] = chr(i+ord('a'))
        dfs(k+1, c)
    s[k] = chr(c+ord('a'))
    dfs(k+1, c+1)

dfs(0, 0)


Measured memory_bytes: 4340
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int a[100001];
int b[100000];

int main()
{
	int n;
	cin >> n;
	rep(i, n + 1) cin >> a[i];
	rep(i, n) cin >> b[i];

	ll ans = 0;
	rep(i, n) {
		if (b[i] <= a[i]) {
			ans += b[i];
			a[i] -= b[i];
		}
		else if (b[i] <= (a[i] + a[i+1])) {
			ans += b[i];
			a[i + 1] -= b[i] - a[i];
			a[i] = 0;
		}
		else {
			ans += a[i] + a[i + 1];
			a[i] = 0;
			a[i + 1] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int count=0;
  int N,D;
  cin >> N >> D;
  vector<vector<int>> data(N, vector<int>(D));
  REP(i,N) REP(j,D) cin >> data.at(i).at(j);
  REP(i,N-1){
    FOR(j,i+1,N){
      double sum=0;
      REP(k,D){
        sum += (data.at(i).at(k)-data.at(j).at(k))*(data.at(i).at(k)-data.at(j).at(k));
      }
      double d;
      if(modf(sqrt(sum),&d)==0.0) ++count;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e11

typedef long long ll;

ll n, s;

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

int main() {
    scanf("%lld%lld", &n, &s) ;
    if(s > n) return puts("-1"), 0;
    if(s == n) return printf("%lld\n", n + 1), 0;
    ll bl = sqrt(n) + 1;
    for (ll i = 2; i <= bl; ++i) if (f(i, n) == s) return printf("%lld\n", i), 0;
    ll ans = INF; 
	n -= s;
    for (ll i = 1; i <= sqrt(n); ++i) if (n % i == 0) {
        ll b = n / i + 1;
        if (f(b, n + s) == s) ans = std :: min(ans, b);
    }
    printf("%lld\n", ans != INF ? ans : -1);
    return 0 ;
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

vi G[100005];
int f(int u, int p) {
    int res = 0;
    int cnt = 0;
    each(v, G[u]) {
        if (v == p)continue;
        int tmp = f(v, u);
        if (tmp == 0)cnt++;
        else res += tmp;
    }
    if (cnt > 0)res += cnt - 1;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    int root = -1;
    rep(i, N)if (sz(G[i]) > 2)root = i;
    if (root == -1) {
        cout << 1 << endl;
        exit(0);
    }

    cout << f(root, -1) << endl;
}

Measured memory_bytes: 9216
N, M = map(int, input().split())
if N == 0:
    ans = M * (M - 1) / 2
elif M == 0:
    ans = N * (N - 1) / 2
else:
    ans = (M * (M - 1) / 2) +(N * (N - 1) / 2)
print(int(ans))

Measured memory_bytes: 2940
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

char s[100];

int main(){
	int n=ci();
	scanf("%s",s+1);
	int ans=0;
	rep(i,1,n) if( s[i]=='A' && s[i+1]=='B' && s[i+2]=='C' ) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
t = input()
s = list(t)
k = int(input())

ans = 0

s = s+s
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] = "0"
    if i>=len(s)//2:
      ans += k-1
    else:
      ans += 1
      
if len(set(list(t))) == 1 and len(t)%2 == 1:
  ans = len(t) * (k//2) + (k%2==1)*(len(t)//2)
print(ans)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int cur = sc.nextInt();
		int max = cur;
		for(int i = 0; i < n; i++){
			final int in = sc.nextInt();
			final int out = sc.nextInt();
			
			cur = cur + in - out;
			
			if(cur < 0){
				System.out.println(0);
				return;
			}
			
			max = Math.max(max, cur);
		}
		
		System.out.println(max);
	}

}

Measured memory_bytes: 41904
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            
            var line = System.Console.ReadLine();
            int N = Convert.ToInt32(line);
            int count = 0;
            int[][] c = new int[10][];
            for (int i = 0; i < 10; i++)
            {
                c[i] = new int[10];
            }

            for (int i = 1; i < N +1; i++)
            {
                c[Convert.ToInt32(i.ToString().Substring(0, 1))][Convert.ToInt32(i.ToString().Substring(i.ToString().Length - 1, 1))] += 1;
            }

            for (int j = 1; j <= 9; j++)
            {
                for (int k = 0; k <= 9; k++)
                {
                    count += c[j][k] * c[k][j];
                }
            }
             Console.WriteLine(count);
        }
    }

Measured memory_bytes: 15416
let n = Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref 0
let _ = for i = 0 to n - 3 do if ps.(i) < ps.(i + 1) && ps.(i + 1) < ps.(i + 2) || ps.(i) > ps.(i + 1) && ps.(i + 1) > ps.(i + 2) then incr ans done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 2432
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B;
	std::cin >> A >> B;
	std::cout << (6 - A - B) << "\n";
}


Measured memory_bytes: 256
n = int(input())

li = list(map(int,input().split()))

count=0

for i in range(n-2):
    if(li[i]<li[i+1] and li[i+1]<li[i+2] or li[i]>li[i+1] and li[i+1]>li[i+2]):
        count += 1
    
print(count)


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

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

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  cin >> n;

  vector<int> d(n);
  rep (i, 0, n)
    cin >> d[i];

  ll res = 0;
  rep (i, 0, n) {
    rep (j, i + 1, n) {
      res += (d[i] * d[j]);
    }
  }

  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
r = []
# ruiseki
su = 0
for i in range(n):
  su += sa[i]
  r.append(su)
ans = 1

for i in range(n-1):
  if (r[~i-1]*2 >= sa[~i]):
    ans += 1
  else:
    break
print(ans)

Measured memory_bytes: 84996
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inp(n);
    inpv(a, n);
    vl cnt(1000005, 0);
    for(auto i:a){
        unordered_map <ll, ll> m;
        ll x = i;
        for(ll j=2; j*j<=x; j++){
            while(x%j==0){
                m[j]++;
                x/=j;
            }
        }
        if(x>1){
            m[x]++;
        }
        for(auto j:m){
            cnt[j.ff] = max(cnt[j.ff], j.ss);
        }
    }
    ll x = 1;
    for(int i=2; i<=1000000; i++){
        ll y = xmodpow(i, cnt[i], MOD);
        x*=y;
        x%=MOD;
    }
    ll ans = 0;
    for(auto i:a){
        ll j = xmodpow(i, MOD-2, MOD);
        j*=x;
        j%=MOD;
        ans+=j;
        ans%=MOD;
    }
    cout << ans << endl;
}

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

struct UnionFind {
  vector<int> t;
  UnionFind(int n) : t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> d(n);
  map<int, vector<int>> mp;
  for (int v = 0; v < n; ++v) {
    cin >> d[v];
    mp[d[v]].push_back(v);
  }
  struct Edge { int u, v; };
  vector<Edge> es(m);
  vector<vector<int>> g(n);
  for (int id = 0; id < m; ++id) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    es[id] = {u, v};
    g[u].push_back(id);
    g[v].push_back(id);
  }
  UnionFind uf(n);
  vector<bool> st(m), used(n);
  for (auto e : mp) {
    for (int v : e.second) {
      used[v] = true;
    }
    for (int v : e.second) {
      for (int id : g[v]) {
        int u = v ^ es[id].u ^ es[id].v;
        if (used[u]) {
          if (not uf.same(v, u)) {
            uf.unite(v, u);
            st[id] = true;
          }
        }
      }
    }
    for (int v : e.second) {
      if (uf.size(v) == 1) {
        cout << "-1\n";
        return 0;
      }
    }
  }
  UnionFind buf(2 * n);
  for (int id = 0; id < m; ++id) {
    if (st[id]) {
      buf.unite(es[id].u, n + es[id].v);
      buf.unite(n + es[id].u, es[id].v);
    }
  }
  string s(n, '?');
  for (int v = 0; v < n; ++v) {
    s[v] = buf.same(0, v) ? 'B' : 'W';
  }
  cout << s << '\n';
  for (int id = 0; id < m; ++id) {
    if (st[id]) {
      cout << max(d[es[id].u], d[es[id].v]) << '\n';
    } else {
      cout << (int)1e9 << '\n';
    }
  }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	int ans = (1 << m) * (1900 * m + 100 * (n - m));
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
//Battlefield control establishing...
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#define MCV main
#include<iomanip>
#define reset(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
//Get ready? LET'S ROCK!
int a[7500];
int MCV()
{
   int n;
   cin>>n;
   int tmp=0;
   int sign;
   for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>tmp)
        {
            tmp=a[i];
            sign=i;
        }
    }
    int sum=0;
   for(int i=0;i<n;i++)
   {
       if(i!=sign)
         sum+=a[i];
   }
   if(sum>tmp)
    cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,K,i,x,y;
 cin >> N >> K;
  
  for (i = 0; i < N; i++) {
   cin >> x;
    if (K - x < x) {
     y += (K - x)* 2;
   }
    else {
      y += x * 2;
    }
  }
    cout << y << endl;
}
    

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

int ones(ll x) {
    return __builtin_popcountll(x);
}

vector<int> res;


void solve(int n, int a, int b, int st, int e) {
    if (n == 1) {
        res[st] = a;
        res[st + 1] = b;
        return;
    }
    int id = 0;
    int c = a ^ b;
    while ((c & 1) == 0) {
        c /= 2;
        ++id;
    }
    c = (a >> id) & 1;
    a = (a & ((1 << id) - 1)) + ((a >> (id + 1)) << id);
    b = (b & ((1 << id) - 1)) + ((b >> (id + 1)) << id);
    int m = (st + e) / 2;
    solve(n - 1, a, a ^ 1, st, m);
    solve(n - 1, a ^ 1, b, m, e);
    for (int i = st; i < m; ++i) {
        res[i] = (res[i] & ((1 << id) - 1)) + ((res[i] >> id) << (id + 1)) + (c << id);

    }
    c ^= 1;
    for (int i = m; i < e; ++i) {
        res[i] = (res[i] & ((1 << id) - 1)) + ((res[i] >> id) << (id + 1)) + (c << id);
    }

}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    int x = ones(a ^ b);

    if (x % 2 == 0) {
        cout << "NO\n";
        return;
    }
    int up = 1 << n;
    res.resize(up);
    
    cout << "YES\n";
    solve(n, a, b, 0, up);
    for (int i = 0; i < up; ++i) {
        cout << res[i] << " ";
    }
    cout << endl;


    

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 1536
def d_lazy_faith(A, B, Q, S, T, X):
    from bisect import bisect_right

    # 出発地点の東西いずれかに神社または寺がないという状態を避けるため、
    # 自明に訪ねる意味がないような位置に寺社を建てる
    INF = float('inf')
    s = [-INF] + S + [INF]
    t = [-INF] + T + [INF]

    ans_tmp = []
    for x in X:
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        # 出発地点xに対し、左右の神社どちらへ行くか？
        # 左右の寺のどちらへ行くか？
        # 寺と神社どちらを先に訪ねるか？
        # 8通りに対し最も距離が短かったものがクエリに対する答え
        for shrine in [s[b - 1], s[b]]:
            for temple in [t[d - 1], t[d]]:
                res = min(res,
                          abs(shrine - x) + abs(temple - shrine),
                          abs(temple - x) + abs(shrine - temple))
        ans_tmp.append(res)
    ans = '\n'.join(map(str, ans_tmp))
    return ans

A, B, Q = [int(i) for i in input().split()]
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
print(d_lazy_faith(A, B, Q, S, T, X))

Measured memory_bytes: 121304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n;


    cout<<n*(n+1)/2<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

using Long = long long;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string cod;
	cin >> cod;

	bool hard = false;
	
	for (int i = 0; i < cod.size() - 1; ++i)
	{
		if(cod[i] == cod[i + 1]){
			hard = true;
		}	
	}

	if(hard){
		cout << "Bad";
	}
	else{
		cout << "Good";
	}
	
	
	return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var param = lines[0].split(' ').map(Number);
  var result = (function(a,b,c) {
    var count = 0;
    for (var i = a; i < b + 1; i++){
        if (c % i === 0) count++;
    }
    return count;
  }(param[0],param[1],param[2]
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15612
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    k = a[0]
    for i in range(1,n):
        if a[i] < k:
            ans += k-a[i]
            a[i] = k
        k = a[i]
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 91428
#include <bits/stdc++.h>
using namespace std;
using ul=unsigned long long;
int s[500],t[500],tmp[500][500],S[500],T[500],n,bit=-1,IN;
ul ans[500][500],u[500],v[500];
void ng(){
  cout<<-1;
  exit(0);
}
struct P{int va,idx,ve,ne,al;};
bool operator <(const P&a,const P&b){return a.va<b.va;};
priority_queue<P>que;
#define REP(i) for(int i=0;i<n;i++)
#define U ((u[i]>>bit)&1)
#define V ((v[j]>>bit)&1)
#define F(va) {\
  if(!~tmp[i][j]){\
    ans[i][j]+=((ul)1<<bit)*(tmp[i][j]=va);\
    if(++S[i]<n&&IN)que.push({S[i],i,'S',s[i]});\
    if(++T[j]<n&&IN)que.push({T[j],j,'T',t[j]});\
  }\
}
void AL(){
  int KO=1;
  while(KO--){
    REP(i)
      if(s[i]==U){
        bool f=0;
        REP(j)f|=tmp[i][j]==s[i];
        if(f)REP(j){KO|=tmp[i][j]<0;F(s[i]^1);}
      }
    REP(j)
      if(t[j]==V){
        bool f=0;
        REP(i)f|=tmp[i][j]==t[j];
        if(f)REP(i){KO|=tmp[i][j]<0;F(t[j]^1);}
      }
  }
}
int main(){
  cin>>n;
  REP(i)cin>>s[i];
  REP(i)cin>>t[i];
  REP(i)cin>>u[i];
  REP(i)cin>>v[i];
  while(++bit<64){
    memset(tmp,-1,sizeof(tmp));
    memset(S,0,sizeof(S));
    memset(T,0,sizeof(T));
    IN=0;
    REP(i)if(s[i]^U)REP(j)F(s[i]^1);
    REP(j)if(t[j]^V)REP(i)F(t[j]^1);
    REP(i)REP(j)if(s[i]==U&&U==t[j]&&t[j]==V)F(s[i]);
    AL();
    IN=1;
    REP(i)if(S[i]<n)que.push({S[i],i,'S',s[i],1});
    REP(j)if(T[j]<n)que.push({T[j],j,'T',t[j],1});
    while(que.size()){
      P p=que.top();que.pop();
      if(p.ve=='S'){
        int i=p.idx;
        if(p.va<S[i])continue;
        REP(j)
          if(!~tmp[i][j]){
            F(p.ne);
            p.ne^=p.al;p.al=0;
          }
        AL();
      }
      else{
        int j=p.idx;
        if(p.va<T[j])continue;
        REP(i)
          if(!~tmp[i][j]){
            F(p.ne);
            p.ne^=p.al;p.al=0;
          }
        AL();
      }
    }
  }
  REP(i){
    ul A=ans[i][0];
    REP(j)
      if(s[i])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=u[i])ng();
  }
  REP(j){
    ul A=ans[0][j];
    REP(i)
      if(t[j])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=v[j])ng();
  }
  REP(i){
    REP(j)cout<<ans[i][j]<<" ";cout<<endl;
  }
}


Measured memory_bytes: 18328
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a/gcd(a,b)*b;}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n, x, res = 1;
    cin >> n;
    for (intt i = 1; i <= n; i++)
        cin >> x, res = lcm (res, x);
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define CLR(a, b) memset((a), (b), sizeof((a)))
template <typename t> bool ckmin(t& a, const t& b) {return a > b ? a = b, true : false;}
template <typename t> bool ckmax(t& a, const t& b) {return a < b ? a = b, true : false;}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
if (DEBUG) std::cerr

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

    int r;
    cin >> r;

    cout << fixed << setprecision(9) << 2*M_PI*r << endl;
}




Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    while (true) {
        int r0, w0, c, r;
        cin >> r0 >> w0 >> c >> r;
        if (r0 == 0 and w0 == 0 and c == 0 and r == 0) {
            break;
        }
        if (r0 >= w0 * c) {
            cout << 0 << endl;
            continue;
        }
        const int rr = w0 * c - r0;
        cout << (rr + (r - 1)) / r << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#define range(i,a,b) for(auto i=a;i<=b;++i)
#define LL long long
#define itrange(i,a,b) for(auto i=a;i!=b;++i)
#define rerange(i,a,b) for(auto i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
int n;
LL ans[2],num[int(1e5+5)];
bool cmp(int a,int b){
    return a>b;
}
void init(){
    cin>>n;
    range(i,1,n)cin>>num[i];
    sort(num+1,num+1+n,cmp);
}
void solve(){
    int cnt=1,pos=0;
    range(i,2,n){
        if(num[i]==num[i-1])++cnt;
        else cnt=1;
        if(cnt==2||cnt==4)ans[pos++]=num[i];
        if(pos==2)break;
    }
    if(pos<2)cout<<0<<endl;
    else cout<<ans[0]*ans[1]<<endl;
}
int main() {
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1024
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = [readline().decode('utf8') for _ in range(3)]

print(A[0][0]+A[1][1]+A[2][2])


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using LL = long long;
const LL inf = 1e17;
const int kN = 200000 + 5;
int n, a[kN];
LL dp[kN][5];

template<typename T>
void update(T &a, T b) {
  if (a > b) a = b;
}

int even_cost(int x) {
  int w = std::max(2, (x + 1) / 2 * 2);
  return std::abs(w - x);
}

int odd_cost(int x) {
  int w = std::max(1, x / 2 * 2 + 1);
  return std::abs(w - x);
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++ i) scanf("%d", a + i);
  for (int i = 1; i <= n; ++ i) {
    std::fill(dp[i], dp[i] + 5, inf);
    update(dp[i][0], dp[i - 1][0] + a[i]);
    update(dp[i][1], dp[i - 1][1] + even_cost(a[i]));
    update(dp[i][2], dp[i - 1][2] + odd_cost(a[i]));
    update(dp[i][3], dp[i - 1][3] + even_cost(a[i]));
    update(dp[i][4], dp[i - 1][4] + a[i]);
    for (int j = 1; j < 5; ++ j)
      update(dp[i][j], dp[i][j - 1]);
  }
  printf("%lld\n", dp[n][4]);
}


Measured memory_bytes: 8704
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int n=int.Parse(Console.ReadLine());
    string[] siritori=new string[n];
    string ans="Yes";
    for(int i=0;i<n;i++)
    {
      siritori[i]=Console.ReadLine();
    }
    for(int i=0;i<n-1;i++)
    {
      for(int j=i+1;j<n;j++)
      {
        if(siritori[i]==siritori[j]){ans="No";goto end;}
      }
      if(siritori[i][siritori[i].Length-1]!=siritori[i+1][0]){ans="No";goto end;}
    }
    end:
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092