akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

vector<pair<LL, LL>> prime_factorization(LL x) {
	assert(x > 0);
	
	vector<pair<LL, LL>> f;
	LL i = 2;
	while(true) {
		if(x == 1) { break; }
		
		if(i * i > x) { i = x; }
		if(x % i == 0) {
			f.EB(i, 0);
			while(x % i == 0) { f.back().SE++; x /= i; }
		}
		i++;
	}
	
	return f;
}

LL n, p;

int main() {
	cin >> n >> p;
	
	auto f = prime_factorization(p);
	
	LL v = 1;
	inc(i, f.size()) { inc(j, static_cast<int>(f[i].SE / n)) { v *= f[i].FI; } }
	
	cout << v << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,i;
  long a=0;
  scanf("%d",&n);
 for(i=1;i<=n;i++){
   if(i%3!=0 && i%5!=0)
     a+=i;
 }
  printf("%ld\n",a);
  return 0;
}


Measured memory_bytes: 1712
#include <stdio.h>
int main(void)
{
	int a=0,b=0;
	
	scanf("%d %d",&a ,&b);
	
	if(a < b){
		printf("a < b\n");
	}
	if(a > b){
		printf("a > b\n");
	}
	if(a == b){
		printf("a == b\n");
	}


	return 0;
}

Measured memory_bytes: 580
//#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int main()
{
    speed
    string napis;
    cin>>napis;
    if((int)napis.size()&1)
    {
        cout<<"No";
        return 0;
    }
    for(int i=0;i<napis.size();i+=2)
    {
        if(napis[i]!='h'||napis[i+1]!='i')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
class Node
  # property parent : Int32
  # property s : Int32
  attr_accessor :parent, :s # Ruby
    
  def initialize(n)
    @parent = n
    @s = 0
  end
end

class UnionFindTree
  
  # property nodes : Array(Node) # Crystal
  attr_accessor :nodes        # Ruby

  def initialize(n)
    @nodes = (0..n).to_a.map{ |i| Node.new(i) }
  end

  def root(x)
    return x if x == nodes[x].parent
    nodes[x].parent = root(nodes[x].parent)
  end

  def unite(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += nodes[b].s
    true
  end
  
  def unite_by_rank(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += 1 if nodes[a].s == nodes[b].s
  end

  def same?(a, b)
    root(a) == root(b)
  end

  def size(node)
    nodes[root(node)]
  end

end

n, m = gets.to_s.chomp.split.map{|i| i.to_i}
perm = gets.to_s.chomp.split.map{|i| i.to_i - 1 }

uf = UnionFindTree.new(n)
m.times do
  x, y = gets.to_s.chomp.split.map{|i| i.to_i - 1 }
  uf.unite_by_rank(x,y)
end
 
ans = 0
n.times do |i|
  ans += 1 if uf.same?(i, perm[i])
end

puts ans

Measured memory_bytes: 18580
#include <stdio.h>

#define NUM 3

int main()
{
    int Array[NUM];

    scanf("%d %d %d", &Array[0], &Array[1], &Array[2]);

    int tmp, i, j;
    for (i = 0; i < NUM; i++) {
        for (j = i; j < NUM; j++) {
            if (Array[i] > Array[j]) {
                tmp = Array[i];
                Array[i] = Array[j];
                Array[j] = tmp;
            }
        }
    }

    printf("%d %d %d\n", Array[0], Array[1], Array[2]);

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    vec a(3);
    rep(i, 3) cin >> a[i];
    sort(all(a), greater<int>());
    cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  cin >> n;
  cout << (1 ^ n) << endl;
}

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


namespace Test1 {

    


    class ClassMain {




        public static int makeN(string str, string title) {
            int titleL = title.Length;
            int strL = str.Length;
            char head = title[0];
            int cnt = 0;
            for (int sukima = 0; sukima * (titleL - 1) + titleL <= strL; sukima++) {
                int searchL = sukima * (titleL - 1) + titleL;
                for (int hd = 0; hd + searchL <= strL; hd++) {
                    if (str[hd] != head) { continue; }
                    else {
                        bool theyAreEqual = true;
                        for (int titleInd = 1; titleInd < titleL; titleInd++) {
                            if (str[hd + (sukima + 1) * titleInd] != title[titleInd]) {
                                theyAreEqual = false; break;
                            }
                        }
                        if (theyAreEqual) { cnt++; }
                    }
                }
            }
            return (cnt>0)? 1: 0;
        }



        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);

                string title = Console.ReadLine();
                int cnt = 0;
                for (int i = 0; i < n; i++) {
                    cnt += makeN(Console.ReadLine(), title);
                    //Console.Write(cnt);
                }
                Console.WriteLine(cnt);
                break;
            }
            
        }

        
    }

    

    
}

Measured memory_bytes: 5652
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int[string] cnt;
	string len;
	auto str = readln.split;
	foreach (s; str) {
		if (s.length > len.length) {
			len = s;
		}
		cnt[s]++;
	}
	string mode;
	int mode_v;
	foreach (key; cnt.keys) {
		if (cnt[key] > mode_v) {
			mode = key;
			mode_v = cnt[key];
		}
	}
	writeln(mode, " ", len);
}

Measured memory_bytes: 1040
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [i64; N]
    }
    let mut ans = 99999999;
    for i in -100..101{
        let mut sum = 0; 
        for j in 0..N{
            sum += (A[j]-i).pow(2);
        }
        ans = min(ans,sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = -1
nearest = 10**18
for i in range(n):
    target = t - h[i] * 0.006  # まさかのこれ（アホか？
    if abs(a - nearest) > abs(a - target):
        nearest = target
        ans = i + 1
print(ans)


Measured memory_bytes: 9284
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=10005;
char ch[MAXN],ch1[MAXN];
int n,K,vi[MAXN],ln;
int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();K=read();
	scanf("%s",ch+1);int mn=999999999;
	for(int i=1;i<=n;i++)mn=min(mn,ch[i]-'a'+1);
	for(int i=n+1;i<=2*n;i++)ch[i]=ch[n-(i-n)+1];
	int mxp=0;
	for(int i=2*n,j;i>=1;i=j-1)
	{		
		j=i;
		if(ch[i]-'a'+1==mn)
		{
			while(ch[j-1]==ch[i])j--;
			mxp=max(mxp,i-j+1);vi[i]=i-j+1;
		}
	}
	int u=mxp,t=0;
	while(u<n&&t<K-1)u<<=1,++t;
	if(u>=n){for(int i=1;i<=n;i++)putchar(mn+'a'-1);puts("");return 0;}
	for(int i=1;i<=u;i++)putchar(mn+'a'-1);
	ln=0;u=n-u;
	for(int i=2*n;i>=n;i--)if(vi[i]==mxp)
	{
		if(!ln){for(int j=i-mxp;j>=i-mxp-u+1;j--)ch1[++ln]=ch[j];continue;}
		bool tf=true;
		for(int j=i-mxp,o=1;j>=i-mxp-u+1;j--,o++)
		{
			if(ch[j]-'a'<ch1[o]-'a')break;
			if(ch[j]-'a'>ch1[o]-'a'){tf=false;break;}
		}
		if(tf)
		{
			ln=0;
			for(int j=i-mxp;j>=i-mxp-u+1;j--)ch1[++ln]=ch[j];
		}
	}
	for(int i=1;i<=ln;i++)putchar(ch1[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,m,i,r;
  while(scanf("%d %d",&n,&m)!=EOF){
    if(m<n){
      i=n;n=m;m=i;
    }
    while(1){
      if(n==0){
	printf("%d\n",m);
	break;
      }
      r=n;
      n=m%n;
      m=r;
    }
  }
  return 0;
}

Measured memory_bytes: 596
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,a,ret[100100];
int main(){
    I(n);
    REP(i,n){
        I(a);
        ret[a]++;
        ret[a+3]--;
    }
    int ans = 0;
    REP(i,100001){
        ret[i+1] += ret[i];
        ans = max(ans,ret[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
from itertools import accumulate
def inpl(): return list(map(int, input().split()))

N, M = inpl()
A = sorted(inpl())
BC = sorted([inpl() for _ in range(M)], key=lambda x: x[1])
i = 0
while BC:
    b, c = BC.pop()
    while b and i < N:
        if A[i] < c:
            A[i] = c
            i += 1
            b -=1
        else:
            break
print(sum(A))

Measured memory_bytes: 83692
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
void a(){

}

int main(){
   
   long long n,d;
   cin>>n>>d;
   vector<vector<long long>> p(n,vector<long long>(2));
   
   for(int i=0;i<n;i++){
       for(int j=0;j<2;j++){
       cin>>p.at(i).at(j);
   }
   }
   int sum =0;
   for(int i=0;i<n;i++){
       if(d*d >= (p.at(i).at(0))*(p.at(i).at(0)) + (p.at(i).at(1))*(p.at(i).at(1))){
           sum++;

       }
       
   }
   cout<<sum<<endl;


}

Measured memory_bytes: 14352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,c,h[200005],dp[200005];
deque<int> q;
long double check(int x,int y){
	return (dp[x]-dp[y]+h[x]*h[x]-h[y]*h[y])/(2.0*(h[x]-h[y]));
}
int main(){
	n=read(),c=read();
	for(int i=1;i<=n;i++)
		h[i]=read();
	q.push_back(1);
	for(int i=2;i<=n;i++){
		while(q.size()>1 and check(q[0],q[1])<=h[i])q.pop_front();
		dp[i]=dp[q.front()]+(h[i]-h[q.front()])*(h[i]-h[q.front()])+c;
		while(q.size()>1 and check(q[q.size()-2],q[q.size()-1])>=check(q[q.size()-1],i))
			q.pop_back();
		q.push_back(i);
	}
	printf("%lld",dp[n]);
	return 0;
}

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

vector<int> color;
int nv;
void dfs(const Graph &g, int v, int c) {
  color[v] = c;
  for(auto np : g[v]) {
    nv = np.first;
    if(color[nv] == -1) {
      if(np.second % 2 == 0) dfs(g, nv, c);
      else dfs(g, nv, 1-c);
    }
  }
}
int main() {
  int N, a, b, d;cin >> N;
  Graph g(N);
  pair<int, int> p;
  rep(i, N-1) {
    cin >> a >> b >> d;
    p = make_pair(b-1, d);
    g[a-1].push_back(p);
    p = make_pair(a-1, d);
    g[b-1].push_back(p);
  }
  color.assign(N, -1);
  dfs(g, 0, 0);
  for(auto x : color) cout << x << endl;
}

Measured memory_bytes: 11188
program abc125c
  implicit none
  integer(8) n, i
  integer(8),dimension(:),allocatable :: a, lgcd, rgcd
  read *, n
  allocate(a(n),lgcd(n+1),rgcd(n+1))
  read *, a
  lgcd = 0
  rgcd = 0
  do i = 1,n
     lgcd(i+1) = gcd(lgcd(i),a(i))
     rgcd(n-i+1) = gcd(rgcd(n-i+2),a(n-i+1))
  end do
  print *, maxval(gcd([0_8,lgcd],[rgcd,0_8]))
contains
  elemental function gcd(a,b) result(r)
    integer(8),intent(in) :: a, b
    integer(8) r, t, n
    n = a
    r = b
    do while (n /= 0)
       t = n
       n = mod(r,n)
       r = t
    end do
  end function gcd
end program abc125c


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int N;
vector<int> ABC(3);
vector<pair<int,int>> S;
string ans;

void f(int x,int y){
  ABC.at(x)++;
  ABC.at(y)--;
  ans+=(x+'A');
}
void calc(int i,int x,int y){
  if(i==N-1){
    f(x,y);
    return;
  }
  int nx=S.at(i+1).fi;
  int ny=S.at(i+1).se;
  if(nx==x || ny==x) f(x,y);
  else  f(y,x);
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  cin >> N;
  for(int i=0;i<3;i++){
    cin >> ABC.at(i);
    chmin(ABC.at(i),100);
  }
  S.resize(N);
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    S.at(i).fi=(s.at(0)-'A');
    S.at(i).se=(s.at(1)-'A');
  }

  for(int i=0;i<N;i++){
    int s1=S.at(i).fi;
    int s2=S.at(i).se;
    if(ABC.at(s1)==0 && ABC.at(s2)==0){
      cout << "No" << endl;
      return 0;
    }
    if(ABC.at(s1)==1 && ABC.at(s2)==1) calc(i,s1,s2);
    else if(ABC.at(s1)<ABC.at(s2)) f(s1,s2);
    else  f(s2,s1);
  }
  cout << "Yes" << endl;
  for(int i=0;i<sz(ans);i++)  cout << ans.at(i) << endl;

  return 0;
}

Measured memory_bytes: 4320
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef struct{int k;string t;}H;
LL i,j,k,m,n,w[100005];
string s[200040];
H z[200040];
int C(H a,H b){return a.k>b.k||a.k==b.k&&a.t<b.t;}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	for(cin>>n;i++<n;)cin>>s[i];
	sort(s+1,s+n+1);
	for(i=0;i++<n;)
	{
		if(s[i-1]==s[i])z[j].k++;
		else
		{
			z[++j].t=s[i];
			z[j].k=1;
		}
	}
	sort(z+1,z+j+1,C);
	for(i=1;z[i].k==z[1].k;i++)cout<<z[i].t<<endl;
}

Measured memory_bytes: 16000
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define INF 10000000000

struct UF
{
	vector<int> par; // ???
	vector<int> sz; // ??°
	vector<ll> value; // ???
	// ?????????
	UF(int n):par(n),sz(n),value(n) {
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;value[i] = 0;
		}
	}
	// ??¨??????????±???????
	int find(int x) {
		if (par[x] == x)
		{
			value[x] = 0;
			return x;
		}
		else
		{
			int tmp = par[x];
			par[x] = find(par[x]);
			value[x] += value[tmp];
			//cout << x << ' ' << value[x] << endl;
			return par[x];
		}
	}
	ll retValue(int n)
	{
		find(n);
	//	cout << n << "s par is" << par[n] << ' ' << value[n] << endl;
		return value[n];
	}
	
	// x??¨y????±??????????????????????
	void unite(int x, int y,ll weight = 0) {
		int tmpx = x;int tmpy = y;
		x = find(x); y = find(y);
		if (x == y) return;
		par[x] = y;
		value[x] = -value[tmpx] + weight + value[tmpy];
	//	cout << "after unite" << x << "value is" << value[x] << ",par is" << par[x] << endl;
		sz[y] += sz[x];
	}
	// x??¨y?????????????????????true
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int n){return sz[find(n)];}
};

int n,m;

int main()
{
	while(cin >> n >> m,n)
	{
		
		UF uf(n);
		
		REP(i,m)
		{
			char c;int a,b;
			cin >> c >> a >> b;
			a--;b--;
			if(c == '!')
			{
				int w;cin >> w;
				uf.unite(a,b,w);
			}
			else
			{
				if(!uf.same(a,b))
				{
					cout << "UNKNOWN" << endl;
				}
				else
				{
					ll A = uf.retValue(a);
					ll B = uf.retValue(b);
					cout << A-B << endl;
				}
			}
		}
	}
		
	
	return 0;
}

Measured memory_bytes: 6228
class cumsum2D:
    def __init__(self, data):
        self.N = len(data)
        self.M= len(data[0])
        self.cum = [[0] * (self.M + 1) for _ in range(self.N + 1)]
        for i in range(self.N):
            for j in range(self.M):
                self.cum[i + 1][j + 1] = self.cum[i][j + 1] + self.cum[i + 1][j] - self.cum[i][j] + data[i][j]

    def get(self,x1,y1,x2,y2):
        """
        長方形の領域 [x1,x2)*[y1,y2) の範囲内にインプットされた数字の和を取る
        """
        return self.cum[x2][y2] - self.cum[x1][y2] - self.cum[x2][y1] + self.cum[x1][y1]

def five(x):
    cnt1 = 0
    while x%5==0:
        cnt1+= 1
        x = x//5
    cnt2 = 0
    while x%2==0:
        cnt2+= 1
        x = x//2
    return (min(cnt1,18), min(cnt2,18))

def digit_lift(S, l):
    if '.' in S:
        a, b = S.split('.')
        n = int(a + b) * 10 ** (l - len(b))
    else:
        n = int(S) * 10 ** l
    return n

data = [[0]*19 for _ in range(19)]

N = int(input())
Q = set()
for _ in range(N):
    A = digit_lift(input().rstrip(),9)
    x, y = five(A)
    data[x][y] += 1
    Q.add((x,y))

cum = cumsum2D(data)
res = 0
for x, y in Q:
    res += (cum.get(18-x,18-y,-1,-1)- (x>=9 and y>=9))*data[x][y]
print(res//2)

Measured memory_bytes: 69980
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

const int N = 3;

double minkowsky_distance(double[], double[], int, int);


int main(int argc, char const *argv[])
{
	int n = 0;
	cin >> n;

	double x[n], y[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> y[i];
	}

	printf("%9.8f\n", minkowsky_distance(x, y, n, 1));
	printf("%9.8f\n", minkowsky_distance(x, y, n, 2));
	printf("%9.8f\n", minkowsky_distance(x, y, n, 3));
	printf("%9.8f\n", minkowsky_distance(x, y, n, -1));

	return 0;
}

// p = -1 == ∞ とする
double minkowsky_distance(double x[], double y[], int n, int p)
{
	double d = 0;
	switch(p)
	{
		case 1:
		{
			for (int i = 0; i < n; ++i)
			{
				d += fabs(x[i] - y[i]);
			}
			break;
		}
		case 2:
		{
			for (int i = 0; i < n; ++i)
			{
				d += pow(x[i] - y[i], 2.0);
			}
			d = sqrt(d);
			break;
		}
		case 3:
		{
			for (int i = 0; i < n; ++i)
			{
				d += pow(fabs(x[i] - y[i]), 3.0);
			}
			d = cbrt(d);
			break;
		}
		case -1:
		{
			double max = 0;
			for (int i = 0; i < n; ++i)
			{
				d = fabs(x[i] - y[i]);
				if (max < d) max = d;
			}
			d = max;
			break;
		}
		default:
		{
			break;
		}
	}
	return d;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3596
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int t=0;
	int s=N;
	while(s!=0){
		int k=0;
		k=s%10;
		t=t+k;
		s/=10;
	}
	if(t==0)printf("error\n");
	else if(N%t==0)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;


int main() {
	int n, d; cin >> n >> d;
	vector<vector<int>>x(n,vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			double tmp = 0;
			for (int k = 0; k < d; k++) {
				tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			double sqtmp = sqrt(tmp);
			int interger = sqtmp;
			if (sqtmp - interger == 0)ans++;			
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3724
N = int(input())
A = [int(i) for i in input().split()]
dp = [[0,0] for _ in range(N+1)]
dp[0][1] = -1000000007
for i in range(N):
    dp[i+1][0] = max(dp[i][0] + A[i],dp[i][1] - A[i])
    dp[i+1][1] = max(dp[i][0] - A[i],dp[i][1] + A[i])
print(dp[N][0])

Measured memory_bytes: 25588
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

pair<bool, string> check(char f, char sec, string s) {
    int n = s.size();
    string ans = s;
    ans[0] = f;
    ans[1] = sec;
    for(int i = 1; i < n; i++) {
        if (ans[i] == 'S') {
            if (s[i] == 'o') {
                ans[(i+1)%n] = ans[i-1];
            } else {
                ans[(i+1)%n] = (ans[i-1]=='W') ? 'S' : 'W';
            }
        } else { // WALF
            if (s[i] == 'x') {
                ans[(i+1)%n] = ans[i-1];
            } else {
                ans[(i+1)%n] = (ans[i-1]=='W') ? 'S' : 'W';
            }

        }
    }

    if (ans[0] != f) {
        return {false, ans};
    } else {
        bool species = (ans[0] == 'S') ? true : false;
        bool tell = (s[0] == 'o') ? true : false;
        bool neibor = (ans[n-1] == ans[1]);
        //cout << species << " " << tell << " " << neibor << endl;
        //cout << "f = " << f << ", s = " << sec << endl;
        //cout << "last "  << (species^tell^neibor) << endl;
        return {species^tell^neibor, ans};
    }
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    auto res1 = check('S', 'W', s);
    if (res1.first) {
        cout << res1.second << endl;
        return 0;
    }
    res1 = check('W', 'S', s);
    if (res1.first) {
        cout << res1.second << endl;
        return 0;
    }
    res1 = check('W', 'W', s);
    if (res1.first) {
        cout << res1.second << endl;
        return 0;
    }
    res1 = check('S', 'S', s);
    if (res1.first) {
        cout << res1.second << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}




Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
const int MAX_N=50;
int N,K;
string S;
int main(){
    cin >> N >> K;
    cin >> S;
    S[K-1]=tolower(S[K-1]);
    printf("%s\n",S.c_str());
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};

const int MAX = 510000;
mint fac[MAX], finv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * mint(i);
        finv[i] = finv[i-1] * mint(i).inv();
    }
}

mint COM (int n, int k) {
    if (n < k) return mint(0);
    if (n < 0 || k < 0) return mint(0);
    // o(k)
    // if (k < MAX) {
    //     mint ret(1);
    //     Rep (i, k) {
    //         ret *= mint(n-i);
    //         ret /= mint(k-i);
    //     }
    //     return ret;
    // }

    return fac[n] * finv[k] * finv[n-k];
}


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

    ll n, k;
    cin >> n >> k;

    COMinit();

    mint ans(0);
    Rep (i, min(k+1, n)) {
        ans += COM(n, i) * COM(n-1, n-i-1);
    }

    cout << ans << endl;
}

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

int main()
{
	string X, Y;
	cin >> hex >> X >> Y;

	if (X > Y)
		cout << ">" << endl;
	else if (X < Y)
		cout << "<" << endl;
	else cout << "=" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int maxn = 300 + 10;

	public static void main(String[] args) 
	{
		Scanner cin = new Scanner(System.in);
		double a[]=new double [200000+100];
		int n=cin.nextInt();
		int k=cin.nextInt();
		a[0]=0;
		for(int i=1;i<=n;i++)
		{
			double s=cin.nextDouble();
			a[i]=a[i-1]+(s+1)/2;
			
		}
		double ans=0;
		for(int i=k;i<=n;i++)
		{
			if(a[i]-a[i-k]>ans)
				ans=a[i]-a[i-k];
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 160748
fun main(args: Array<String>) {
    abc150d()
}

fun abc150d() {
    val (n, m) = readLine()!!.split(' ').map { it.toLong() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val div2Count = aList.map {
        var curr = it
        var count = 0
        while (curr % 2 == 0L) {
            curr /= 2
            count++
        }
        count
    }.distinct()

    if (div2Count.size != 1) return println(0)

    val answer = m / aList.map { it / 2 }.reduce { acc, l -> lcm(acc, l) } -
            m / aList.reduce { acc, l -> lcm(acc, l) }

    println(answer)
}

private fun lcm(a: Long, b: Long): Long {
    return a / gcd(a, b) * b
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}


Measured memory_bytes: 73824
import java.util.Scanner;

public class Main {
	
	private static final String str = "CODEFESTIVAL2016";
	private static int count = 0;
	
	public static void main(String[] args){
		
		Scanner reader = new Scanner(System.in);
		String str1 = reader.next();
		
		for (int i=0;i<16;i++){
			if (str1.charAt(i)!=str.charAt(i)){
				count++;
			}
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 8916
#include<stdio.h>
int main(){
int a,b,c=0,d,e,f=0;
while(c==0){
scanf("%d %d\n",&a,&b);
if(a==0 && b==0){
break;
}
else{
for(d=0;d<a;d++){
for(e=0;e<b;e++){
if(d%2==0 && f%2==0){
printf("#");
f++;
}
else if(d%2==0 && f%2==1){
printf(".");
f++;
}
if(d%2==1 && f%2==0){
printf(".");
f++;
}
else if(d%2==1 && f%2==1){
printf("#");
f++;
}
}
f=0;
printf("\n");
}
printf("\n");
}
}
return 0;
}


Measured memory_bytes: 2120
//
// Created by syu on 18/05/12.
//
#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int X;
    cin >> X;
    int i,j,max=0,temp;
    if(X<4){
        cout << 1 << endl;
        return 0;
    }
    for(i = 2; i <= sqrt(X); ++i) {
        for(j = 2; (temp=pow(i,j))<=X; ++j) {
            if(max < temp)max = temp;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))



int main(){
	char x;
	cin >> x;
	x++;
	cout << x << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<utility>

#define INF 9999999999

using namespace std;

const int MAX_N = 100000;

int d[MAX_N];

struct edge{
	int to;   //?????????
	int cost; //?????????
};

typedef pair<int,int>P;

void dijkstra(int s,int n)
{
	int k,l,p,q,r,u,v,cost,m;
	vector<edge> edgelist[n];
	for(int i=0;i<n;i++){
		scanf("%d",&u);
		scanf("%d",&m);
		for(int j=0;j<m;j++){
			edge e;
			scanf("%d",&v);
			scanf("%d",&cost);
			e.to = v;	e.cost = cost;
			edgelist[i].push_back(e);
		}
	}
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = edgelist[v].begin();
		while(it != edgelist[v].end()){
			if(d[it->to] > d[v] + it->cost){
				d[it->to] = d[v] + it->cost;
				que.push(P(d[it->to],it->to));
			}
			it++;
		}
	}
}

int main()
{
	int k,l,m,n,s;
	scanf("%d",&n); // ?????°?????\???
	fill(d,d+n,INF);
	dijkstra(0,n);
	for(int i=0;i<n;i++){
		printf("%d %d\n",i,d[i]);
	}
}

Measured memory_bytes: 7800
N=int(input())
all_sum=N*(N+1)/2
mt=N//3
mf=N//5
mfif=N//15
three_sum=3*mt*(mt+1)/2
five_sum=5*mf*(mf+1)/2
fif_sum=15*mfif*(mfif+1)/2
ans=all_sum-three_sum-five_sum+fif_sum
print(int(ans))

Measured memory_bytes: 9124
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int height,A[MAX+1];

void maxheapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=height && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=height && A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxheapify(largest);
  }
}

void increasekey(int i,int key){
  if(key<A[i]) return;
  A[i]=key;
  while (i>1 && A[i/2]<A[i]) {
    swap(A[i],A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  height++;
  A[height]=-INFTY;
  increasekey(height,key);
}

int extract(){
  int maxv;
  if(height<1)return -INFTY;
  maxv=A[1];
  A[1]=A[height--];
  maxheapify(1);
  return maxv;
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com );
    if(com[0]=='e' && com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract() );
    }
  }
  return 0;
}



Measured memory_bytes: 6660
#include<cstdio>
#include<cstdlib>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	char tbl[10][11];
	rep(i,n) scanf("%s",tbl[i]);

	int win[10]={},sum=0;
	rep(i,n) rep(j,n) if(tbl[i][j]=='o') win[i]++, sum++;

	int j;
	rep(t,500){
		printf("%d\n",rand()%n+1); fflush(stdout);
		scanf("%d",&j); j--;
	}

	rep(t,500){
		printf("%d\n",j+1); fflush(stdout);
		scanf("%*d");
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 50;
const ll Amax = 1E16 + 1000;

ll K;
ll N[MAX_N];

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

    cin >> K;

    ll n;

    for (ll i = 2; i <= 50; i++) {
        if (i + K / i <= Amax) {
            n = i;
            break;
        }
    }

    ll p = K / n;
    ll r = K - p * n;
    for (int i = 0; i < n; i++) {
        N[i] = i + p - r;
        if (i <= r - 1) {
            N[i] += n + 1;
        }
    }

    cout << n << "\n";
    for (int i = 0; i < n; i++) {
        cout << N[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
  string s,t;cin >> s >> t;
  int cnt =0;
  rep(i,3)if(s[i] == t[i])cnt++;
  cout << cnt << endl;
}


Measured memory_bytes: 256
import itertools
N,M = map(int,input().split())
Switch = []
for i in range(M):
    Swi = list(map(int,input().split()))
    S = Swi[0]
    Switch.append(Swi[1:S+1])
Plist = list(map(int,input().split()))
Ans = 0
L = [0,1]
c_list = list(itertools.product(L, repeat=N))
for comb in c_list:
    for i in range(M):
        Jud = 0
        Swi = Switch[i]
        for j in Swi:
            Jud += comb[j-1]
        if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1
print(Ans)

Measured memory_bytes: 9316
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

struct edge {
    int to, cost, time;
    edge() = default;
    edge(int to, int cost, int time) : to(to), cost(cost), time(time) {}
};

const int INF = 1LL << 60;
int N, M, S;
int U[110], V[110], A[110], B[110];
int C[51], D[51];
vector<edge> G[51];
int dis[51][5000];

void _main() {
    cin >> N >> M >> S;
    REP (i, M) {
        cin >> U[i] >> V[i] >> A[i] >> B[i];
        U[i]--; V[i]--;
        G[U[i]].emplace_back(V[i], A[i], B[i]);
        G[V[i]].emplace_back(U[i], A[i], B[i]);
    }
    REP (i, N) cin >> C[i] >> D[i];

    REP (i, 50) REP (j, 5000) dis[i][j] = INF;
    S = min(S, 3000LL);
    dis[0][S] = 0;
    using P = tuple<int, int, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, 0, S);

    while (!que.empty()) {
        int dd, v, c;
        tie(dd, v, c) = que.top();
        que.pop();
        if (dis[v][c] < dd) continue;
        for (auto e : G[v]) {
            if (c - e.cost >= 0 && dis[e.to][c - e.cost] > dis[v][c] + e.time) {
                dis[e.to][c - e.cost] = dis[v][c] + e.time;
                que.emplace(dis[e.to][c - e.cost], e.to, c - e.cost);
            }
        }
        int nc = min(c + C[v], 3000LL);
        if (dis[v][nc] > dis[v][c] + D[v]) {
            dis[v][nc] = dis[v][c] + D[v];
            que.emplace(dis[v][nc], v, nc);
        }
    }
    FOR (i, 1, N) {
        int ans = INF;
        REP (j, 5000) ans = min(ans, dis[i][j]);
        cout << ans << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int a, b; cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        if ((s[0] == s[4]) && (s[1] == s[3])) ans++;
    }
    cout << ans << endl;
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];
	
	si st;
	
	cin>>n;
	
	f(i,0,n-1){
        cin>>k;
        st.insert(k);
	}
	
	cout<<st.size()<<endl;
	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    char a[105][105];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
    {
        cin>>a[i][j];
    }
    for(int i=0;i<h;++i)
    {
        int f=1;
        while(f<3)
        {
               for(int j=0;j<w;++j)
    {
        cout<<a[i][j];
    }cout<<endl;
    f++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n, W = map(int,input().split())
dp = [W+1]*(10**5 + 1)
vr=[]
for i in range(n):
  w,v= map(int,input().split())
  vr.append(v)
  if i==0:
  	dp[v]=w
  for j in range(10**5-v,-1,-1):
  	cw=w+dp[j]
  	if j==v and vr.count(v)==1:
  		continue
  	if cw<=W:
  		dp[j+v]=min(dp[j+v],cw)
  dp[v]=min(w,dp[v])

for i in range(10**5,-1,-1):
		
			if dp[i]<=W:
				print(i)
				exit()

			
		

 



Measured memory_bytes: 69612
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll n,m;
	cin>>n>>m;
	vector<ll>v[m];
	for(ll i=0;i<m;i++)
	{
		ll x;
		cin>>x;
		for(ll j=0;j<x;j++)
		{
			ll sw;
			cin>>sw;
			v[i].push_back(sw-1);
		}
	}
	ll p[m];
	input(p,m);
	ll ans=0;
	for(ll i=0;i<(1<<n);i++)
	{
		ll j=i;
		ll on[n]={0},cnt=0;
		while(j)
		{
			if(j&1)
			on[cnt]=1;
			j>>=1;
			cnt++;
		}
		int flag=1;
		for(ll k=0;k<m;k++)
		{
			ll onz=0;
			for(ll l=0;l<v[k].size();l++)
			if(on[v[k][l]])
			onz++;
			if(onz%2!=p[k])
			flag=0;
		}
		if(flag)ans++;
	}
	cout<<ans;
}
		
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"


	
  
  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b+c >= 22){
		cout << "bust";
	}
	else{
		cout << "win";
		
	}
}
		
		
		
		
	





Measured memory_bytes: 3572
n = int(input())
aaa = list(map(int, input().split()))
right = 0
sum = 0
cnt = 0
for left in range(n):
    while right < n and (sum ^ aaa[right]) == (sum + aaa[right]):
        sum += aaa[right]
        right += 1
    cnt += right - left
    if left == right:
        right += 1
    else:
        sum -= aaa[left]
print(cnt)

Measured memory_bytes: 24840