akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long n = sc.nextLong();
		System.out.println(n * (n + 1) / 2 - n);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i,0,(n))
#define pb(n) push_back(n)
#define mp(n,m) make_pair(n, m)
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;


int main(){
	int n;
	cin>>n;
	vi v(n);
	rep(i, n) cin>>v[i];
	ll dp[110][30];
	for(int i = 0; i < 110; i++){
		for(int j = 0; j < 30; j++){
			dp[i][j]=-1;
		}
	}
	dp[0][v[0]] = 1LL;
	for(int i = 1; i < n-1; i++){
		for(int j = 0; j <= 20; j++){
			if(dp[i-1][j] >= 0){
				if(j+v[i] <= 20) {
					dp[i][j + v[i]] = max(dp[i][j + v[i]], 0LL);
					dp[i][j+v[i]] += dp[i-1][j];
				}
				if(j-v[i]>=0){
					dp[i][j - v[i]] = max(dp[i][j - v[i]], 0LL);
					dp[i][j - v[i]] += dp[i-1][j];
				}
			}
		}
	}
	cout<<dp[n-2][v.back()]<<endl;
}

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

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

LL N,M;
vector<pair<LL,LL>> data;//pair<誕生年,県>

map<pair<LL,LL>,string> ans;

string num2str(LL x,int digit){
	LL num = x;
	string ret = "";
	for(int i=0;i<digit;i++){
		ret = (char)(num%10 + '0') + ret;
		num /= 10;
	}
	return ret;
}

void solve(){
	//pair<誕生年,県>
	vector<pair<LL,LL>> data_sorted(data);
	sort(data_sorted.begin(),data_sorted.end());
	vector<int> counter(N+1,0);//すでに県iが何回登場したかをcounter[i]とおく
	for(int i=0;i<M;i++){
		LL y = data_sorted[i].first;
		LL p = data_sorted[i].second;
		counter[p]++;
		ans[data_sorted[i]] = num2str(p,6) + num2str(counter[p],6);
	}
}
 
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
    	LL p,y;cin >> p >> y;
    	data.push_back(pair<LL,LL>(y,p));
    }
 
    solve();
 
    for(int i=0;i<data.size();i++) cout << ans[data[i]] << endl;
    return 0;
}

Measured memory_bytes: 15832
digits = int(input())
num_list = [int(i) for i in list(input())]
flag1 = 0
flag2 = 0
counter = 0


for num1 in range(10):
	for num2 in range(10):
		for num3 in range(10):
			flag1 = 0
			flag2 = 0
			for digit in range(digits):
				if flag1 == 0 and flag2 == 0 and num1 == num_list[digit]:
					flag1 = 1
					continue
				if flag1 == 1 and num2 == num_list[digit]:
					flag2 = 1
					flag1 = 0
					continue
				if flag2 == 1 and num3 == num_list[digit]:
					counter += 1
					flag2 = 0
					break
print(counter)



Measured memory_bytes: 70936
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(u==s){a--;}else{b--;}  
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
 
using namespace std;
 
int main()
{
    int a;
    cin >> a;
    int resA,resB,resC;
    resA = a / 3600;
    resB = a % 3600 / 60;
    resC = a % 3600 % 60;
    cout << resA << ":" << resB << ":" << resC << endl;
    return 0;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var data = Console.ReadLine().Split(' ');
            var ans = "APPROVED";

            for (int i = 0; i < n; i++)
            {
                if (int.Parse(data[i]) % 2 == 0&& int.Parse(data[i]) % 3 != 0 && int.Parse(data[i]) % 5 != 0)
                {
                    ans = "DENIED";
                    break;

                }
            }

            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 13140
program speedrun
    implicit none
    integer::N
    character(10),allocatable,dimension(:)::S
    integer,allocatable,dimension(:)::Votecnt
    integer::i
    integer::maxnum,cnt,cnting
    read*,N
    allocate(S(N))
    do i=1,N
        read*,S(i)
    end do
    call heapsort(N,S)
    
    allocate(Votecnt(N))
    Votecnt=0
    maxnum=0
    cnt=0;cnting=1
    do i=1,N
        if(S(cnting)==S(i))then
            cnt=cnt+1
        else
            Votecnt(cnting)=cnt
            maxnum=max(maxnum,cnt)
            cnting=i;cnt=1
        endif
    end do
    Votecnt(cnting)=cnt
    maxnum=max(maxnum,cnt)
    do i=1,N
        if(Votecnt(i)==maxnum)then
            print"(A)",trim(S(i))
        endif
    enddo
contains
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  character(10),intent(inout) :: array(1:n)
  integer::i,k,j,l
  character(10):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort

end program speedrun

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int a[222222];
int main()
{
	long long n,a,b=0,ba=0;
	cin>>n;
	while(n--)
	{
		cin>>a;
		if(a<b)
		{
			ba+=b-a;
			a=b;
		}
		b=a;
	}
	cout<<ba;
	return 0; 
} 

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int MAX_N = 7 + 100000;
///----------------------------------------------
bool f[MAX_N];
int main() {
	
	///read
	string str; cin>>str;
	
	///work
	static string tab[4] = {"dream","dreamer","erase","eraser"};
	memset(f,false,sizeof(f)); f[0]=true;
	rep(i,0,sz(str)) {
		rep(j,0,4) if (i+1>=sz(tab[j])) {
			if (i-sz(tab[j])==-1 || f[i-sz(tab[j])])
				if (str.substr(i-sz(tab[j])+1,sz(tab[j]))==tab[j]) {
					f[i]=true;
					break;
				}
		}
		//debug(f[i]);
	}
	
	///print
	puts(f[sz(str)-1] ? "YES" : "NO");




}


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

int main(void){
  long N, T;
  cin >> N >> T;
  long t[N];
  for (int i = 0; i<N; i++){
    cin >> t[i];
  }
  long ans;
  for (int j = 0; j<N; j++){
    if (j == N-1) ans += T;
    else if (t[j+1]-t[j]<T) ans += t[j+1] -t[j];
    else ans += T;
  }
  cout << ans << endl;
} 

Measured memory_bytes: 1792
function Main(input){
	var a = input.split("\n");
  if(a[0] == 1){
  	return "Hello World";
  }
  if(a[0] == 2){
  	return (a[1]*1) + (a[2]*1);
  }
}
 
console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
// ------------------------------------
// Date:2018/ 3/17
// Problem:_ _ _ d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int main()
{
  int N;
  scanf("%d", &N);
  vector< int > a(N);
  REP(i, N) scanf("%d", &a[i]);
  vector< int > b(N);
  REP(i, N) scanf("%d", &b[i]);


  ll ans = 0;
  REP(bit, 29) {
    ll T = 1 << bit; 
    // [0, 29)の区間の各ビットを調査

    vector< int > aModT(N);
    REP(i, N) {
      // mod 2*Tを求める
      aModT[i] = a[i] % (T * 2);
    }

    vector< int > bModT(N);
    REP(i, N) {
      // mod 2*Tを求める
      bModT[i] = b[i] % (T * 2);
    }

    sort(ALL(bModT));

    ll cnt = 0;
    REP(ai, N) {
      // aModT[ai]として固定
      int a = aModT[ai];
      int tmp1 = lower_bound(ALL(bModT), T - a) - bModT.begin();
      int tmp2 = lower_bound(ALL(bModT), 2 * T - a) - bModT.begin();
      int tmp3 = lower_bound(ALL(bModT), 3 * T - a) - bModT.begin();

      // cnt += [3*T, 4*T) + [T, 2*T)
      cnt += N - tmp3 + tmp2 - tmp1;
      // debug(tmp1);
      // debug(tmp2);
      // debug(tmp3);

    }
    // xorは奇数の時に1
    if (cnt % 2 == 1) {
      ans += T;
      // cout << "ok" << endl;
    }
  }

  printf("%d\n", ans);
  return 0;
}



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

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (mut a, mut b) = (v[0], v[1]);
    if a == 1 {
        a = 100;
    }
    if b == 1 {
        b = 100;
    }
    if a > b {
        println!("Alice");
    } else if a < b {
        println!("Bob");
    } else {
        println!("Draw");
    }
}

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 <bits/stdc++.h>
    
using namespace std;
    
#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define fst first
#define snd second
    
typedef long long ll;

struct STree { // example: range sum with range addition
	vector<ll> st,lazy;int n;
	STree(int n): st(4*n+5,0), lazy(4*n+5,0), n(n) {}
	void init(int k, int s, int e, int *a){
		lazy[k]=0;  // lazy neutral element
		if(s+1==e){st[k]=a[s];return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=st[2*k]+st[2*k+1]; // operation
	}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		st[k]+=lazy[k]; // update st according to lazy
		if(s+1<e){ // propagate to children
			lazy[2*k]+=lazy[k];
			lazy[2*k+1]+=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, ll v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]+=v; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]= max(st[2*k], st[2*k+1]); // operation
	}
	ll query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return 0; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b)return st[k];
		int m=(s+e)/2;
		return max(query(2*k,s,m,a,b), query(2*k+1,m,e,a,b)); // operation
	}
	void init(int *a){init(1,0,n,a);}
	void upd(int a, int b, ll v){upd(1,0,n,a,b,v);}
	ll query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

int n, m;

map<int, vector<pair<int, int>>> mp;

ll calc() {
    STree rmq(n + 1);
    ll q = 0;
    for(int i = n; i >= 0; i--) {
        for(auto p : mp[i + 1]) {
            rmq.upd(i + 1, p.fst, p.snd);
        }
        q = rmq.query(i + 1, n + 1);
        rmq.upd(i, i + 1, q);
        // cout << q << endl;
    }
    return q;
}

int main() {
    cin >> n >> m;
    fore(i, 0, m) {
        int l, r, a; cin >> l >> r >> a;
        mp[l].pb({r + 1, a});
    }
    cout << calc() << endl;
    return 0;
}

Measured memory_bytes: 34560
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007

int freq[8];

int32_t main()
{ 
    csl;

    int n;
    cin >> n;

    int arr[n];
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
        if(arr[i]>=3200)
        {
            count++;
        }
    }

    for(int i=0;i<n;i++)
    {
        int curr = arr[i];

        if(curr>=1&&curr<400)
        {
            freq[0]++;   
        }
        else if(curr>=400 && curr<800)
        {
            freq[1]++;
        }
        else if(curr>=800&&curr<1200)
        {
            freq[2]++;
        }
        else if(curr>=1200&&curr<1600)
        {
            freq[3]++;
        }
        else if(curr>=1600&&curr<2000)
        {
            freq[4]++;
        }
        else if(curr>=2000&&curr<2400)
        {
            freq[5]++;
        }
        else if(curr>=2400&&curr<2800)
        {
            freq[6]++;
        }
        else if(curr>=2800&&curr<3200)
        {
            freq[7]++;
        }
    }
    int count0=0;
    for(int i=0;i<8;i++)
    {
        if(freq[i]>0)
        {
            count0++;
        }
    }
    if(count0==0&&count>0)
    {
        cout << 1 << " " << count << "\n";
    }
    else
    {
        cout << count0 << " " << count+count0 << "\n";
    }
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long hp = sc.nextLong();
        System.out.println(hit(hp));
    }

    private static long hit(long hp) {
        return hp == 1 ? 1 : hit(hp / 2) * 2 + 1;
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t / a) << endl;
}


Measured memory_bytes: 256
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int Mx = 1 << 17;
vector<int> N[Mx];

bool DFS(int v, int p = -1) {
	int c = 0;
	for(int u : N[v])
		if(u != p)
			c += DFS(u, v);
	if(c == 0) return 1;
	if(c == 1) return 0;
	cout << "First";
	exit(0);
}

int main() {
	int n; cin >> n;
	int m = 0;
	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		N[v].push_back(u);
		N[u].push_back(v);
		if(N[v].size() > N[m].size()) m = v;
		if(N[u].size() > N[m].size()) m = u;
	}
	cout << (DFS(m) ? "First" : "Second");
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 093 C / Link: http://abc093.contest.atcoder.jp/tasks/abc093_c  ----- */


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


	LL A, B, C; cin >> A >> B >> C;
	LL ans = LINF;
	auto f = [](LL A,LL B,LL C,LL T) {
		if (A > T || B > T || C > T)return LINF;
		LL diffsum = 3 * T - A - B - C;
		if (diffsum & 1)return LINF;
		return diffsum / 2;
	};
	FOR(T, 0, 100) {
		ans = min(ans, f(A, B, C, T));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+2;
int pre1[maxn],pre2[maxn];
int finds(int x,int *pre)
{
    return pre[x] == x? pre[x]:pre[x] = finds(pre[x],pre);
}
void join(int x,int y,int *pre)
{
    int px = finds(x,pre);
    int py = finds(y,pre);
    if( px!=py)
    {
        pre[px] = py;
    }
}
int main()
{
    int n,k,l;
    cin>>n>>k>>l;
    for(int i = 1;i<=n;i++)
        pre1[i] = i,pre2[i] = i;
    for(int i = 1;i<=k;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre1);
    }
    for(int i = 1;i<=l;i++)
    {
        int x,y;
        cin>>x>>y;
        join(x,y,pre2);
    }
    for(int i = 1;i<=n;i++)
    {
        finds(i,pre1);
        finds(i,pre2);
    }
    map<pair<int,int>,int> mp;
    for(int i = 1;i<=n;i++)
    {
        mp[make_pair(pre1[i],pre2[i])] ++;
    }
    for(int i = 1;i<=n;i++)
    {
        cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
    }
    cout<<endl;
}

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


Measured memory_bytes: 2068
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MAX_N  ((1 << 18) - 1)
#define MAX_L  100000

#define min(a, b)  ((a) < (b) ? (a) : (b))
#define max(a, b)  ((a) > (b) ? (a) : (b))

int n;
int val[MAX_N], wgt[MAX_N];

int dpn;

typedef struct wgtval {
  int wgt, val;
} wgtval;

struct wgtval_list {
  int size;
  wgtval *list;
} dp[MAX_N];

#define set_wgtval(wv, w, v)  ((wv).wgt = (w), (wv).val = (v))

int compare_wgt(const void *a, const void *b)
{
  const wgtval *p = a;
  const wgtval *q = b;
  if (p->wgt == q->wgt) {
    return p->val < q->val ? -1 :
           p->val > q->val ?  1 : 0;
  }
  return p->wgt < q->wgt ? -1 : 1;
}

void compute_dp()
{
  int u;

  /* initialize */
  dpn = min(n, 1 << 12);
  dp[0].size = 2;
  dp[0].list = malloc(2 * sizeof(wgtval));
  set_wgtval(dp[0].list[0], 0, 0);
  set_wgtval(dp[0].list[1], wgt[0], val[0]);

  /* compute the dp table */
  for (u = 1; u < dpn; u++) {
    int parent = (u - 1) / 2;
    int tail, i;

    dp[u].size = dp[parent].size * 2;
    dp[u].list = malloc(dp[u].size * sizeof(wgtval));
    for (i = 0; i < dp[parent].size; i++) {
      dp[u].list[i * 2] = dp[parent].list[i];
      set_wgtval(dp[u].list[i * 2 + 1],
                 dp[parent].list[i].wgt + wgt[u],
                 dp[parent].list[i].val + val[u]);
    }
    qsort(dp[u].list, dp[u].size, sizeof(wgtval), compare_wgt);

    /* remove unnecessary entries */
    tail = 0;
    for (i = 1; i < dp[u].size; i++) {
      if (dp[u].list[i].wgt > MAX_L) {
        break;
      }
      if (dp[u].list[tail].wgt == dp[u].list[i].wgt) {
        dp[u].list[tail] = dp[u].list[i];
      } else if (dp[u].list[tail].val < dp[u].list[i].val) {
        tail++;
        dp[u].list[tail] = dp[u].list[i];
      }
    }
    dp[u].size = tail + 1;
  }
}

int bsearch_right(wgtval *list, int size, int target)
{
  int lo = 0;
  int hi = size;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (target < list[mid].wgt) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  return lo;
}

int solve(int u, int l)
{
  int parent;
  int s;

  if (u < dpn) {
    int x = bsearch_right(dp[u].list, dp[u].size, l) - 1;
    return dp[u].list[x].val;
  }

  parent = (u - 1) / 2;
  s = solve(parent, l);
  if (l >= wgt[u]) {
    int t = val[u] + solve(parent, l - wgt[u]);
    s = max(s, t);
  }
  return s;
}

int main()
{
  int i, q;

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

  compute_dp();

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    int u, l;
    scanf("%d%d", &u, &l);
    printf("%d\n", solve(u - 1, l));
  }

  return 0;
}


Measured memory_bytes: 82448
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  ll N,K;
  cin >> N >> K;
  ll ans = K;
  rep(i,N-1) ans *= (K-1);
  cout << ans << endl;

}


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

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    deque<ll> mv, pv;
    vector<Pll> ansv;
    rep(i,N){
        if(A[i]>0){
            pv.push_back(A[i]);
        }else{
            mv.push_back(A[i]);
        }
    }
    sort(pv.begin(), pv.end());
    sort(mv.rbegin(), mv.rend());
    ll M = 0;
    rep(i,N-2){
        if(mv.empty()){
            ll p1 = pv.front();
            pv.pop_front();
            ll p2 = pv.front();
            pv.pop_front();
            mv.push_back(p1-p2);
            ansv.push_back(Pll(p1,p2));
        }else if(mv.size() > 1 && !pv.empty()){
            ll m1 = mv.front();
            mv.pop_front();
            ll p1 = pv.front();
            pv.pop_front();
            pv.push_back(p1-m1);
            ansv.push_back(Pll(p1,m1));
        }else if(mv.size() > 1 && pv.empty()){
            ll m1 = mv.front();
            mv.pop_front();
            ll m2 = mv.front();
            mv.pop_front();
            pv.push_back(max(m1,m2) - min(m1,m2));
            ansv.push_back(Pll(max(m1,m2), min(m1,m2)));
        }else{
            ll m1 = mv.front();
            mv.pop_front();
            ll p1 = pv.front();
            pv.pop_front();
            mv.push_back(m1-p1);
            ansv.push_back(Pll(m1,p1));
        }
    }
    ll p1 = pv.front();
    ll m1 = mv.front();
    ansv.push_back(Pll(p1,m1));
    cout << p1-m1 << endl; 
    rep(i,N-1){
        cout << ansv[i].fi << " " << ansv[i].se << endl;
    }
}

Measured memory_bytes: 7000
def solve(n,a,b,c):
    dp = [[0]*3 for _ in range(n)]

    #dp[][0] = a, dp[][1] = b, dp[][2] = c
    dp[0][0] = a[0]
    dp[0][1] = b[0]
    dp[0][2] = c[0]
    for i in range(1,n):
        for j in range(3):
            if j == 0:
                dp[i][j] = max(dp[i-1][1],dp[i-1][2]) + a[i]
            if j == 1:
                dp[i][j] = max(dp[i-1][0],dp[i-1][2]) + b[i]
            if j == 2:
                dp[i][j] = max(dp[i-1][0],dp[i-1][1]) + c[i]

    print(max(dp[n-1]))








if __name__ == '__main__':
    n = int(input())
    a = []
    b = []
    c = []
    for i in range(n):
        t1,t2,t3 = map(int,input().split())
        a.append(t1)
        b.append(t2)
        c.append(t3)

    solve(n,a,b,c)

Measured memory_bytes: 40516
#include <iostream>
using namespace std;
int map[10001][101]={0};
int main(){
map[0][0]=1;
int N;
cin >>N;
int s;
for(int i=0;i<N;i++){
cin>>s;
for(int j=0;j<10001;j++){
map[j][i+1]|=map[j][i];
if(j+s<10001)map[j+s][i+1]|=map[j][i];
}}
int m=0;
for(int i=10000; i>=0;i--){
if(i%10==0)continue;
if(map[i][N]==1){
m=i;
break;
}}
cout << m<< endl;
return 0;}


Measured memory_bytes: 4224
#include<iostream>

using namespace std;

typedef long long ll;

ll mod = 1000000007;

ll modpow(ll a,ll p){
  if(p==0) return 1;
  if(p%2==0){
    ll halfP = p/2;
    ll half = modpow(a,halfP);
    return half * half % mod;
  }
  else{
    return a * modpow(a,p - 1) % mod;
  }
}

long comb(ll a,ll b){
  if(b>a-b) return comb(a,a-b);
  ll ansMul = 1;
  ll ansDiv = 1;
  for(int i=0;i<b;i++){
    ansMul *= (a-i);
    ansDiv *= (i+1);
    ansMul %= mod;
    ansDiv %= mod;
  }
  ll ans = ansMul * modpow(ansDiv,mod-2) % mod;
  return ans;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 1;
  ans = modpow(2,n);
  ans = ans - comb(n,a) - comb(n,b) - 1;
  while(ans < 0){
   ans += mod;
   }
  cout << ans << endl;
}

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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll big[n+1],small[n+1];
  big[n]=2,small[n]=2;
  bool check=true;
  for(int i=n-1;i>=0;i--){
    ll max_group=big[i+1]/a[i];
    ll min_group=(small[i+1]-1)/a[i]+1;
    if(max_group<min_group){
      check=false;
    }
    big[i]=(max_group+1)*a[i]-1;
    small[i]=min_group*a[i];
  }
  if(check){
    cout << small[0] << " " << big[0] << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
bool solve(const string &s) {
  int n = s.length();
  REP(i, n / 2) {
    if (s[i] != s[n / 2 + i]) return false;
  }
  return true;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  while (true) {
    s.pop_back();
    s.pop_back();
    if (solve(s)) {
      cout << s.length() << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	double a[n][m];
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			cin>>a[i][j];
	double tot;
	double sum;
	int kkksc03=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<i;++j){
			tot=0;
			for(int k=0;k<m;++k){
				sum=abs(a[i][k]-a[j][k]);
				tot+=sum*sum;
			}
			if(sqrt(tot)==int(sqrt(tot)))
				++kkksc03;
		}
	cout<<kkksc03<<endl;
	return 0;
}

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

int main(){
    int N, idx ;
    cin >> N ;
    vector <int> A(N);
    rep(i,N-1){
        cin >> idx ;
        A[idx-1]++ ;
    }
    rep(i,N) cout << A[i] << "\n";
}

Measured memory_bytes: 4044
a, v = tuple(map(int, input().split()))
b, w = tuple(map(int, input().split()))
t = int(input())

if v-w <= 0:
    print('NO')
    exit()

ans = abs(b-a) / (v-w)

if ans <= t:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define traverse(container,it)  for(auto it = container.begin();it != container.end(); it++)
ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt","r",stdin);
    int n,m = MOD,sign = 0;
    bool zero = false;
    ll sum = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(x == 0) zero = true;
        else if(x < 0)sign++;
        m = min(m,abs(x));
        sum += abs(x);
    }
    if(zero == false && sign%2 == 1){
        sum -= 2*(ll)m;
    }
    cout << sum << endl;
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

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

  map<string, int> cnt;
  rep(i,n){
    cnt[s[i]]++;
  }

  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;
}

Measured memory_bytes: 6376
import java.util.Scanner;

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

        int K = sc.nextInt();

        System.out.println(solve(K));

        sc.close();
    }

    static int solve(int K) {
        int even = K / 2;
        int odd = K - even;

        return even * odd;
    }
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
//#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
   	ll n;
   	cin>>n;

   	double arr[3005] =  {0};
   	for(int i=1;i<=n;i++)
   	{
   		cin>>arr[i];
   	}

   	double dp[3005][3005] = {0};

   	dp[0][0] = 1;

   	for(int i=1;i<=n;i++)
   	{
   		dp[i][0] = dp[i-1][0] *(1-arr[i]);
   	}

   	for(int i=1;i<=n;i++)
   	{
   		for(int k=1;k<=n;k++)
   		{
   			dp[i][k] = arr[i]*(dp[i-1][k-1]) + (1-arr[i])*(dp[i-1][k]);
   		}

   	}

   	double ans = 0;
   	for(int k = n/2 + 1;k<=n;k++)
   	{
   		ans += dp[n][k];
   		//cout << dp[n][k] << "\n";
   	}

   	//cout  << ans << "\n";
   	printf("%0.12f\n",ans);
	return 0;
}

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

int main(){

    long long x,k,d;
    cin >> x >> k >> d;

    long long minp = ((long long)(abs(x)) + d) % d;
    long long minn = minp - d;

    long long ss = ((long long)(abs(x)) - minp) / d;
    if(ss > k){
        if(x > 0) cout << x - k*d << endl;
        else cout << (long long)(abs(x + k*d)) << endl;
    }

    else{

        if(x < 0){
            minp = -minp;
            minn = -minn;
        }

        k -= ss;

        if((k + 2) % 2 == 0){
            cout << (long long)abs(minp) << endl;
        }
        else{
            cout << (long long)abs(minn) << endl;
        }

    }


    return 0;
}

Measured memory_bytes: 3632
import Control.Monad
import qualified Data.Vector.Unboxed as V

main = do
  [k, q] <- map read.words <$> getLine
  d <- V.fromList.map read.words <$> getLine
  nxm <- replicateM q $ map read.words <$> getLine
  mapM_ (print.solve k d) nxm

count :: (V.Unbox a, Eq a) => a -> V.Vector a -> Int
count a v = V.length $ V.elemIndices a v

solve :: Int -> V.Vector Int -> [Int] -> Int
solve k d' [n, x, m] = n - 1 - eqs - gts where
  d = V.map (`rem` m) d'
  eqs = count 0 d * quot (n-1) k + count 0 (V.take (rem (n-1) k) d)
  gts = quot alast m - quot x m
  alast = V.foldl (+) x dcnt
  (nq, nr) = quotRem (n-1) k
  cnt i | i < nr = nq + 1
        | otherwise = nq
  dcnt = V.map f $ V.indexed d
  f (i, d) = cnt i * d

Measured memory_bytes: 20604
#include<iostream>
#include<cstdio>
const int N=100005;
int n,m,s[N],ans;
bool v[N];
int read()
{
	int r=0,f=1;
	char p=getchar();
	while(p>'9'||p<'0')
	{
		if(p=='-')
			f=-1;
		p=getchar();
	}
	while(p>='0'&&p<='9')
	{
		r=r*10+p-48;
		p=getchar();
	}
	return r*f;
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		s[i]=1;
	v[1]=1;
	while(m--)
	{
		int x=read(),y=read();
		if(v[x])
			v[y]=1;
		s[x]--,s[y]++;
		if(!s[x])
			v[x]=0;
	}
	for(int i=1;i<=n;i++)
		if(v[i])
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


int main(){
    double R; cin >> R;

    cout << setprecision(10);
    cout << 2 * R * 3.141592 << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <string>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int digitsum(int x) {
    int ret = 0;
    while(x) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

ll power(ll x, int n) {
    if(n == 0)
        return 1;
    else if(n % 2)
        return x * power(x, (n - 1));
    else
        return power(x * x, n / 2);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, t;
    priority_queue<int> Q;
    cin >> n;
    vector<int> s[n];
    rep(i, n) {
        cin >> m;
        rep(j, m) {
            cin >> t;
            s[n - 1 - i].push_back(t);
        }
    }
    ll c = 0;
    rep(i, n) {
        for(auto e : s[i]) {
            Q.push(e);
        }
        c += Q.top();
        Q.pop();
    }
    cout << c << endl;
}



Measured memory_bytes: 19484
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n; ll A; ll a[200000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A; a[i] = A;
	}
	int ri = 0; int le = 0;
	ll b = 0; ll sum = 0;
	ll out = 0;
	while (le < n) {
		while (ri<n&&(a[ri] ^ b) == sum + a[ri]) {
		    b ^= a[ri]; sum += a[ri]; ri++;
		}
		out += (ll)ri-(ll)le;
		b = b ^ a[le]; sum -= a[le]; le++;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 1792
x = input().split()
plist = [int(x[1]) for i in range(int(x[0]))]
y = []
l = 0
while l < int(x[2]):
    ans = input()
    y.append(int(ans))
    l += 1

for i in y:
    plist[i-1] += 1

for p in plist:
    if p - int(x[2]) > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 11784
#include <stdio.h>
int main(void){
    int size[20] = {};
    int number[100] = {};
    int max, min, total;
    
    for (int i = 0; i < 20; i++){
        scanf ("%d", &size[i]);
        if (size[i] == 0) break;
        max = 0, min = 1000, total = 0;
        for (int j = 0; j < size[i]; j++){
            scanf ("%d", &number[j]);
            total += number[j];
            if (max < number[j]) max = number[j];
            if (min > number[j]) min = number[j];
        }
        total -= max + min;
        total /= size[i] - 2;
        printf ("%d\n", total);
    }
}

Measured memory_bytes: 1712
N = int(input())
SList = list(input())
max = 0
i = 0
while i < N-1:
    left = SList[0:i+1]
    right = SList[i+1:N]
    common = list(set(left)&set(right))
    l = len(common)
    if max < l:
        max=l
    i += 1

print(max)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,k,i,j,dp[2005][2005],mod=1e9+7,fac[4000005],inv[4000005],fi[4000005];
int c(int x,int y)
{
	return 1ll*fac[x]*fi[y]%mod*fi[x-y]%mod;
}
int main()
{
	fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;
	fz(i,2,4000000){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fi[i]=1ll*fi[i-1]*inv[i]%mod;
	}
	scanf("%d%d",&n,&k);
	if(k==1){
		puts("1");
		return 0;
	}
	dp[0][0]=1;
	fz1(i,n)fz0g(j,i){
		dp[i][j]=0;
		inc(dp[i][j],dp[i-1][j])
		if(j)inc(dp[i][j],1ll*dp[i][j-1]*(n-j+1)%mod*c(n-i+(n-j+1)*(k-1)-1,k-2)%mod)
	}
	cout<<dp[n][n]<<endl;
	return 0;
}

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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse).ToList();
            if (!CheckTri(a.Sum())) { Console.WriteLine(-1);  goto next; }
            var ans = GetTri(a);
            Console.WriteLine(ans);
            next:;
        }
    }
    public static bool CheckTri (int a)
    {
        var x =(int) Math.Sqrt(8 * a + 1);
        var k = (x - 1) / 2;
        return k * (k + 1) / 2 == a;
    }
    public static int GetTri  (List<int> a)
    {
        var count = 0;
        while (count <= 10000)
        {
            if (CheckList(a)) return count;
            var ca = a.Count();
             a= a.Select(x => x - 1).ToList();
            a.Add(ca);
            a.RemoveAll(x => x == 0);
            count++;
        }
        return -1;
    }
    public static bool CheckList (List<int > a)
    {
        var ap  = a[0];
        if (ap != 1) return false;
        for (int i = 1; i < a.Count(); i++)
            if (a[i] != ap + 1) return false;
            else ap = a[i];
        return true;
    }
}

Measured memory_bytes: 9808
/*
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*b/gcd(a,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, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
while(n=gets.to_i)>0
d=[[0,0]]*n
r=0...n
p r.map{gets;w=0;(d=r.map{|j|h,w=$_[j]<?.?[0,0]:[d[j][0]+1,w+1];[h,[h,w,d[j-1][1]+1].min]}).map{|h,s|s}.max}.max
end

Measured memory_bytes: 6128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right;
};

typedef struct Node * NodePointer;

void insert( NodePointer t , int z){
	NodePointer x;
	if ( t -> key <= z){
		if  ( t -> right  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> right = x;
		}else {
			insert ( t -> right , z);
		}

	}else {
		if  ( t -> left  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> left = x;
		}else {
			insert ( t -> left , z);
		}
	}
};

void search ( NodePointer t, int tag){
	int flag = 0;
	while ( t != NULL){
		if ( t -> key == tag){flag = 1; break;}
		else if ( t -> key >= tag){
			t = t -> left;
		}else {
			t = t -> right;
		}
	}
	if (flag == 0 ){ printf("no\n");
	}else if (flag == 1){printf("yes\n");}
};

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


int main (){
	int kazu;
	scanf("%d\n",&kazu);

	NodePointer tree = (NodePointer) malloc (sizeof(struct Node));

	char input [8];
	int k;

	for ( int i = 0; i  < kazu; i++){
		scanf("%s" ,&input);

		if ( strcmp( input , "insert") == 0 ){
			scanf("%d\n",&k);
			if ( i == 0)
			{
			tree -> key = k;
			tree -> right = NULL;
			tree -> left = NULL;
			}
			else {insert(tree , k);
			}
		}else if ( strcmp( input , "find") == 0 ){
			scanf("%d\n",&k);
			search( tree , k);
		}else {
			inorder(tree);
			printf("\n");

			preorder(tree);
			printf("\n");
		}
	}


	return 0;
}



Measured memory_bytes: 20452