akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
           String s;
           boolean isf=false;
           int ans[]=new int[26];
           for(int i=0;i<26;i++){
               ans[i]=0;
           }
           while(sc.hasNextLine()){
               s=sc.nextLine();
          int n=s.length();
          s=s.toLowerCase();
          for(int i=0;i<n;i++){
            if('a'<=s.charAt(i)&&s.charAt(i)<='z'){
                  int add=s.charAt(i)-'a';
                  ans[add]++;
              }
          }
           }
           for(int i=0;i<26;i++){
               char x='a';
               x+=i;
               System.out.println(x+" : "+ans[i]);
           }
}
}



Measured memory_bytes: 26268
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}

int myPow(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    return x * myPow(x, p-1);
}

int main() {
    Int N;
    cin >> N;
    string ans = "No";

    if(N<82 && N>9){
        REP(i,2,10){
            if(N%i==0 && N/i < 10){
                ans = "Yes";
            }
        }
    }else if(N<10){
        ans = "Yes";
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
var
 n:longint;
 s:longint;
 map:array[1..210,1..210]of boolean;
 mark:array[1..210]of boolean;
 link:array[1..210]of longint;

procedure init;
var
 i,x,y,j:longint;
 a:array[1..210,1..2]of longint;
begin
 fillchar(map,sizeof(map),0);
 read(n);
 for i:=1 to n do
   readln(a[i,1],a[i,2]);
 for i:=1 to n do
  begin
   read(x,y);
   for j:=1 to n do
     if (x>a[j,1])and(y>a[j,2]) then begin map[j,i+n]:=true;  map[i+n,j]:=true; end;
  end;
 n:=n shl 1;
end;



function find(x:longint):boolean;
var
 i,q:longint;
begin
 for i:=1 to n do
  if map[x,i] and not mark[i] then
   begin
   q:=link[i]; link[i]:=x; mark[i]:=true;
   if (q=0) or find(q) then exit(true);
   link[i]:=q;
   end;
 exit(false);
end;



procedure main;
var
 i:longint;
begin
 s:=0;
 for i:=1 to n do
  begin
  fillchar(mark,sizeof(mark),false);
  if find(i) then inc(s);
  end;
 writeln(s shr 1);
 readln;
 readln;
end;

begin
 init;
 main;
end.
        

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

signed main() {
    string S;
    cin >> S;
    vector<bool> check(250, false);
    for (int i = 0; i < S.length(); ++i) {
        check[S[i]] = true;
    }
    if (check['N'] && check['S']) {
        if ((check['W'] && check['E']) || (!check['W'] && !check['E'])) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else if (check['W'] && check['E']) {
        if ((check['N'] && check['S']) || (!check['N'] && !check['S'])) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <list>

using namespace std;



int main(void){
    long long N,M,tmp,A,B;
    map<long long,long long> H;
    map<long long,bool> flg;
    long long ans=0;

    cin>>N>>M;

    for(long long i=1;i<=N;i++){
        cin>>H[i];
        flg[i]=true;
        // cout<<"H_"<<i<<":"<<tmp<<endl;
    }

    for(long long i=1;i<=M;i++){
        cin>>A>>B;

        // cout<<"A:"<<A<<" B:"<<B<<endl;

        // cout<<"H[A]:"<<H[A]<<" H[B]:"<<H[B]<<endl;

        if(H[A] <= H[B]){
            flg[A]=false;
        }
        if(H[A] >= H[B]){
            flg[B]=false;
        }
    }

    for(long long i=1;i<= N;i++){
        // cout<<"i:"<<i<<" "<<flg[i]<<endl;
        if(flg[i]){
            ans++;
        }
    }

    cout<<ans<<endl;





    return 0;
}



Measured memory_bytes: 16100
from collections import defaultdict

M = 10**9 + 7
N = int(input())
C = [0]*N
for i in range(N):
    C[i] = int(input())

class increment:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

ui = defaultdict(increment())
clists = []
Nc = 0
for i in range(N):
    n = ui[C[i]]
    if n >= Nc:
        clists.append([i])
        Nc += 1
    else:
        clists[n].append(i)

P = [0]*N
Q = [0]*N
Q[0] = 1
QS = [0]*Nc
QS[ui[C[0]]] = 1
for i in range(1,N):
    if C[i] == C[i-1]:
        Q[i] = 0
    else:
        Q[i] = (P[i-1] + Q[i-1]) % M
    
    cind = ui[C[i]]
    P[i] = QS[cind]
    QS[cind] = (QS[cind] + Q[i]) % M

print((P[N-1]+Q[N-1]) % M)

Measured memory_bytes: 62356
#include <iostream>

using namespace std;

int main(){
    int w,n;
    int lots[30];

    cin>>w;
    for (int i=0;i<w;i++){
        lots[i]=i+1;
    }
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int a,b;

        scanf("%d,%d",&a,&b);
        swap(lots[a-1],lots[b-1]);
    }
    for (int j = 0; j < w; ++j) {
        cout<<lots[j]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
int n;cin>>n;
string s;cin>>s;
string ans="Yes";
if(n%2!=0){
  cout<<"No"<<endl;
}else{
  rep(i,n/2){
    if(s.at(i)!=s.at(i+n/2)){
      ans="No";
    }
  }
  cout<<ans<<endl;
}

}

Measured memory_bytes: 256
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    n = 1
    P = 10 % L
    while True:
        if P == 1:
            print(n)
            break
        n += 1
        P = (10 * P) % L

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int a;
	cin >> a;
	string ans = "NO";
	if(a == 3 || a == 5 || a == 7)ans = "YES";
	cout << ans << endl;
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    string S, T; cin >> S >> T;
    int ans=0;
    for (int i=0; i<3;i++)
        if (S[i]==T[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n = inputs(0).toInt
  val p = inputs(1).split(" ").mkString("").toInt
  val q = inputs(2).split(" ").mkString("").toInt

  println(solve(n, p, q))

  def solve(n: Int, p: Int, q: Int): Int = {
    val comb = (1 to n).permutations.map(_.mkString("")).map(_.toInt).toSeq
    return Math.abs(comb.indexOf(p) - comb.indexOf(q))
  }
}

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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	map<string,bool> M;

	int ans=0;

	while(n--)
	{
		string s;
		cin>>s;
		if(!M[s]) ans++;
		M[s]=1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 19216
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    ll l, n; cin>>l>>n;
    vector<ll> x(n+1, 0);
    for(int i=1; i<=n; i++) cin>>x[i];

    vector<ll> xsum(n+10, 0);
    for(int i=1; i<=n; i++){
        xsum[i] = xsum[i-1] + x[i];
    }

    ll dist;
    ll ans = 0;
    for(int i=1; i<=n; i++){
        int m = (i + n + 1) / 2;
        if((i + n) % 2 == 0){
            dist = 2 * (xsum[m] - xsum[i-1]) - x[m] - 2 * (xsum[n] - xsum[m]) + (n - i) * l;
        }
        else{
            dist = 2 * (xsum[m-1] - xsum[i-1]) - 2 * (xsum[n] - xsum[m-1]) + x[m] + (n - i) * l;
        }

        chmax(ans, dist);
    }
    for(int i=1; i<=n; i++){
        int m = (i + 1) / 2;
        if(i % 2 == 0){
            dist = 2 * xsum[m] - x[m] + i * l - 2 * (xsum[i] - xsum[m]);
        }
        else{
            dist = 2 * xsum[m-1] + i * l - 2 * (xsum[i] - xsum[m-1]) + x[m];
        }

        chmax(ans, dist);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
n = gets.to_i

a = gets.split.map(&:to_i)
count = 0
even = []

a.each do |i|
  if i.even?
    even << 1
    if (i % 3 == 0) || (i % 5 == 0)
      count += 1
    end
  end
end


puts even.size == count ? "APPROVED": "DENIED"

Measured memory_bytes: 1788
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
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)*}};}
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, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0382>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:usize,C:usize,p:[usize;C]);
    let sum = p.into_iter().sum::<usize>();
    let mut ans = 0;
    ans += sum/(N+1);
    if sum%(N+1) != 0{
        ans+=1;
    }
    println!("{}",ans);
}


Measured memory_bytes: 5036
N, M, X, Y = map(int, input().split())
XL = list(map(int, input().split())) + [X]
YL = list(map(int, input().split())) + [Y]
XL.sort()
YL.sort(reverse=True)
xt = XL.pop()
yt = YL.pop()
if xt < yt:
    print('No War')
else:
    print('War')


Measured memory_bytes: 9180
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    for(int i=A;i<=B;i++){
        if(i<A+K) cout << i << "\n";
        else if(i>B-K) cout <<i<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){

		Scanner ob = new Scanner(System.in);
		String S = ob.next();
		String T = ob.next();
		int C = 0;

		for (int i = 0; i < S.length(); i++) {
			
			if(S.charAt(i) != T.charAt(i) ){
				C++;
			}
		}
		System.out.println(C);
	}
}

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

int main(void){
    char s[101];
    int i, n, h;
    scanf("%d",&n);
    scanf("%s",s);
    h = strlen(s);

    if(h<=n){
        printf("%s",s);
    }else{
        for(i=0;i<n;i++){
            printf("%c",s[i]);
        }
        printf("...");
    }

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	int k; cin >> k;
	string s; cin >> s;
	if (s.size()<=k) cout << s << "\n";
	else{
		for (int i=0;i<k;i++){
			cout << s[i];
		}
		cout << "..." << "\n";
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int B = 63;
struct Z2N {
  vector<ll> basis;
  Z2N() {
    basis.resize(B, 0);
  }
  bool add(ll x, bool upd) {
    for (int b = B - 1; b >= 0; b--) {
      if (x & (1ll << b)) {
        x ^= basis[b];
      }
      if (x & (1ll << b)) {
        if (upd) basis[b] = x;
        return true;
      }
    }
    return false;
  }
};

int solve() {
  int n; cin >> n;
  vector<ll> a(n);
  for (ll& x: a) cin >> x;
  string s; cin >> s;

//  ll used = 0;
//  for (int i = n - 1; i >= 0; i--) {
//    if (s[i] == '1' && (used & a[i]) != a[i]) {
//      return 1;
//    }
//    used |= a[i];
//  }

  Z2N vs;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '1') {
      if (vs.add(a[i], false)) {
        return 1;
      }
    } else {
      vs.add(a[i], true);
    }
  }

  return 0;
}

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

  int t; cin >> t;
  while (t--) {
    cout << solve() << '\n';
  }

  return 0;
}


Measured memory_bytes: 3608
def nCk(n, k, m=10**9+7):
    a = b = 1
    for i in range(k):
        a = (a * (n-i)) % m
        b = (b * (i+1)) % m
    return (a * pow(b, m-2, m)) % m

n,m = map(int, input().split())
ans = 0
if n > 1:
    ans += nCk(n, 2)
if m > 1:
    ans += nCk(m, 2)
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> P;
const LL INF = 1LL << 60;
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
const int SIZE = 1 << 18;
vector<LL> dat[2 * SIZE - 1];
int n;
LL a[200000];
void init(int n_) {
	n = 1;
	while (n < n_) n *= 2;
	for (int i = 2 * n - 2; i >= 0; i--) {
		if (i >= n - 1) {
			int idx = i - (n - 1);
			if (idx >= n_) dat[i].push_back(INF);
			else  dat[i].push_back(a[idx]);
		}
		else {
			dat[i] = vector<LL>(dat[i * 2 + 1].size() + dat[i * 2 + 2].size());
			merge(dat[i * 2 + 1].begin(), dat[i * 2 + 1].end(), dat[i * 2 + 2].begin(), dat[i * 2 + 2].end(), dat[i].begin());
		}
	}
}
LL count(int a, int b, LL x, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l&&r <= b) {
		return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
	}
	else {
		LL vl = count(a, b, x, k * 2 + 1, l, (l + r) / 2);
		LL vr = count(a, b, x, k * 2 + 2, (l + r) / 2, r);
		return vl + vr;
	}
}
int main() {
	int N, K;
	cin >> N >> K;
	rep(i, N) {
		cin >> a[i];
		a[i] -= K;
	}
	rep(i, N - 1) {
		a[i + 1] += a[i];
	}
	init(N);
	LL ans = 0;
	rep(i, N) {
		ans += count(0, i, a[i], 0, 0, n);
		if (a[i] >= 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 63360
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	double X[60], Y[60]; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i]; 
	}
	double ans = 114514.1919; 
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			double cx = 0.5 * (X[i] + X[j]); 
			double cy = 0.5 * (Y[i] + Y[j]); 
			double rr = (X[i] - cx) * (X[i] - cx) + (Y[i] - cy) * (Y[i] - cy); 
			bool ok = true; 
			for(int k = 0; k < N; k++){
				if(k == i || k == j) continue; 
				double tmp = (X[k] - cx) * (X[k] - cx) + (Y[k] - cy) * (Y[k] - cy); 
				if(tmp > rr + 1e-9) ok = false; 
			}
			if(ok) ans = min(ans, pow(rr, 0.5)); 
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			for(int k = j+1; k < N; k++){
				if(abs((X[i] - X[j]) * (Y[i] - Y[k]) - (Y[i] - Y[j]) * (X[i] - X[k])) < 1e-9) continue; 
				double cx1 = (Y[i]-Y[k]) * (Y[i] * Y[i] - Y[j] * Y[j] + X[i] * X[i] - X[j] * X[j]); 
				double cx2 = (Y[i]-Y[j]) * (Y[i] * Y[i] - Y[k] * Y[k] + X[i] * X[i] - X[k] * X[k]); 
				double cx3 = (Y[i]-Y[k]) * (X[i]-X[j]) - (Y[i]-Y[j]) * (X[i]-X[k]);  
				double cx = 0.5 * (cx1 - cx2) / cx3; 
				double cy1 = (X[i]-X[k]) * (X[i] * X[i] - X[j] * X[j] + Y[i] * Y[i] - Y[j] * Y[j]); 
				double cy2 = (X[i]-X[j]) * (X[i] * X[i] - X[k] * X[k] + Y[i] * Y[i] - Y[k] * Y[k]); 
				double cy3 = (X[i]-X[k]) * (Y[i]-Y[j]) - (X[i]-X[j]) * (Y[i]-Y[k]);  
				double cy = 0.5 * (cy1 - cy2) / cy3; 
				double rr = (X[i] - cx) * (X[i] - cx) + (Y[i] - cy) * (Y[i] - cy); 
				bool ok = true; 
				for(int m = 0; m < N; m++){
					if(m == i || m == j || m == k) continue; 
					double tmp = (X[m] - cx) * (X[m] - cx) + (Y[m] - cy) * (Y[m] - cy); 
					if(tmp > rr + 1e-9) ok = false; 
				}
				if(ok) ans = min(ans, pow(rr, 0.5)); 
			}
		}
	}
	cout.precision(12); 
	cout << ans << endl; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    if (n%1000==0)
    {
    	cout << 0 << "\n";
    	return 0;
    }
    cout << 1000-n%1000 <<"\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long int> A(N), L(N + 1, 0), R(N + 1, 0);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) L.at(i + 1) = L.at(i) + A.at(i);
  for (int i = N - 1; i >= 0; i--) R.at(i) = R.at(i + 1) + A.at(i);
  long long int ans = 1000000000000000000;
  for (int i = 0; i <= N; i++) ans = min(ans, abs(L.at(i) - R.at(i)));
  cout << ans << endl;
}

Measured memory_bytes: 7928
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, T;
    cin >> N >> T;
    int ans = INT_MAX;
    rep(i, 0, N)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T)
        {
            chmin(ans, c);
        }
    }
    if (ans == INT_MAX) cout << "TLE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long n;
    long long ans;
    int x,y;
    cin >> n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int mina = a[0];
    int maxa = a[n-1];
    ans = maxa-mina;
    if(n>2){
    for(int i=1;i<n/2;i++){
            x = a[n-i-1] - mina;
            y = maxa - a[i];
            mina = a[i];
            maxa = a[n-i-1];
            ans = ans + x + y;
    }
    }
    if(n%2==1){
        ans = ans + max(abs(a[n/2]-maxa),abs(a[n/2]-mina));
    }
    cout << ans << endl;
    return 0;
}

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

	int a, b;
	for(int i=0;i<4;i++){
	cin>>a>>b;
	if(a == 1) cout<<6000 * b<<endl;
	if(a == 2) cout<<4000 * b<<endl;
	if(a == 3) cout<<3000 * b<<endl;
	if(a == 4) cout<<2000 * b<<endl;
	}
	return 0;
}



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

int main(){
  int64_t N;
  scanf("%ld", &N);

  vector<int64_t> vec(N+1);
  vec.at(0) = 2;
  vec.at(1) = 1;
  
  for(int64_t i = 2; i <= N; i++){
       vec.at(i) = vec.at(i-2) + vec.at(i-1);
  }
  printf("%lld", vec.at(N));
}

Measured memory_bytes: 256
using System;

class M
{
	static void Main()
	{
		Func<int[]> read = () => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		var h = read();
		var a = read();
		int n = h[0], k = h[1];

		var dp = new long[n + 1, k + 1];
		for (int i = 0; i <= n; i++) dp[i, 0] = 1;
		for (int j = 0; j <= k; j++) dp[0, j] = 1;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= k; j++)
				dp[i, j] = MInt(dp[i, j - 1] + dp[i - 1, j] - (j > a[i - 1] ? dp[i - 1, j - a[i - 1] - 1] : 0));
		Console.WriteLine(MInt(dp[n, k] - (k > 0 ? dp[n, k - 1] : 0)));
	}

	const int m = 1000000007;
	static long MInt(long x) => (x %= m) < 0 ? x + m : x;
}


Measured memory_bytes: 89824
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val output =
      (for {
        i <- 1 to n
        if i % 3 == 0 || include3(i)
      } yield s" $i").mkString
    println(output)
  }

  def include3(x: Int): Boolean = {
    var included = false
    var i = x
    while (!included && i > 0) {
      included |= i % 10 == 3
      i /= 10
    }
    included
  }
}

Measured memory_bytes: 47608
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	n--;
	vector<int> c(n), s(n), f(n);
	for(int i = 0; i < n; ++i) {
		cin >> c[i] >> s[i] >> f[i];
	}
	
	vector<int> ans;
	for(int i = 0; i < n; ++i) {
		int t = c[i] + s[i];
		
		for(int j = i + 1; j < n; ++j) {
			if( t < s[j] ) { 
				t += s[j] - t;	
			} else if( t > s[j] && t % f[j] != 0) { 
				t += (f[j] - t % f[j]);
			}
			
			t += c[j];
		}
		
		ans.push_back(t);
	}
	
	ans.push_back(0);
	
	for(auto& x : ans) {
		cout << x << endl;
	}
	
	return 0;
}


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

using namespace std;

pair<int, int> spr[10];

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

int sdx[] = {-1,1,0,0,-1,1,1,-1,0};
int sdy[] = {0,0,-1,1,-1,-1,1,1,0};

using namespace std;

int N;
bool ans;

void solve(int const X, int const Y, int const SPRI) {
  if(ans) return;
  if(SPRI == N) {
    ans = 1;
    return;
  }
  
  for(int k=0; k<12; k++) {
    int npx = X+dx[k], npy = Y+dy[k];
    if(npx<0 || npx>9 || npy<0 || npy>9) continue;
    
    for(int kk=0; kk<9; kk++) {
      int const nsprx = spr[SPRI].first + sdx[kk];
      int const nspry = spr[SPRI].second + sdy[kk];
      if(nsprx<0 || nsprx>9 || nspry<0 || nspry>9) continue;
      
      if(npx == nsprx && npy == nspry) {
	solve(npx, npy, SPRI+1);
      }
    }
    
  }
  
}

int main() {
  int sx, sy;
  
  while(cin >> sx >> sy && (sx|sy)) {
    cin >> N;
    for(int i=0; i<N; i++) {
      cin >> spr[i].first >> spr[i].second;
    }
    
    ans = 0;
    solve(sx, sy, 0);
    if(ans) {
      cout << "OK" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
  
  return 0;
}

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

int main(){
  int A;
  int B;
  cin >> A;
  cin >> B;
 if(A>=13){
  cout << B; 
 }else if(A>=6 && A<=12){
   cout << B/2;
 }else if(A<=5){
   cout << "0";
 }
	return 0;
}


Measured memory_bytes: 3568
//template by I_Love_Totoro, inspired by chamow
//Doing VC Everyday #SpecialistByMarch
//refer cook_book and AC  of/Ubuntu folder _FunWithCP_ dated:16/03/2020- for POC and more insights respectively
//interactive comments ahead! : for the love of CP <3
//note to self:for the love of everything good, uncomment fastread whenever applicable :) 

/* footnotes/ obs
*
*/

/*main idea:
*
*/

/*similar to:
*
*/

/*re-learnt/ got better clarity
*
*/

/*corollary
*
*/

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define repn(i,a,n) for(i=n;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define PI (atan(1)*4)
#define INF (int)1e9

#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//typedef vec vector<ll>
typedef long long ll;
typedef long double ld;
typedef long int li;

using namespace std;

ll lcm(ll val1,ll val2)
{
	if(val1==0||val2==0)
		return 0;
	else
		return (val1*val2)/__gcd(val1,val2);
}

ll pw(ll base,ll p)
{
	if(base==1||p==0)				
		return 1;
	if(p%2==0){
		ll interm=pw(base,p/2);
		return interm*interm;

	}
	else
		return base*pw(base,p-1);

}

int main()
{

	//fastread;
	/*
	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    */
	
	ll n,x,k;   //k = 2;
	cin>>n>>k;
	vector<ll>vec,dp(n,1e10),ans(n,0);

	for (ll i = 0; i < n; i ++) {
		cin>>x;
		vec.pb(x);
	}

	dp[0] = 0;//vec[0];
	ans[0] = dp[0];
	dp[1] = abs(vec[1]-vec[0]);
	ans[1] = dp[1];

	ll ansr = 0;
	for (ll i = 2; i < n; i++){
		//dp[i] += min(abs(vec[i] - vec[i-1]),abs(vec[i] - vec[i-2]));
		/*if (abs(vec[i]-vec[i-1])<abs(vec[i]-vec[i-2]))
			dp[i] += abs(vec[i] - vec[i-1]) + dp[i-1];
		//else
			dp[i] += abs(vec[i] - vec[i-2]) + dp[i-2];
		//ansr += dp[i];*/
		
		/*ans
		dp[i] = min(dp[i],min(dp[i-1] + abs(vec[i]-vec[i-1]),dp[i-2] + abs(vec[i] - vec[i - 2])));
		*/

		for (ll j = 1; j <= k && i - j >= 0; j ++)
			dp[i] = min(dp[i], dp[i-j] + abs(vec[i] - vec[i-j]));
	}

	//for (ll i = 0; i < n; i ++)
	//	cout<<dp[i]<<" ";
	//cout<<"\n";

	cout<<dp[n-1]<<"\n";
	//cout<<ansr<<"\n";
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
     
        int n; int naj = 0;
        cin >> n;
     
        int res = 0;
        for (int i = 0; i < n; ++i)
        {
            int v; cin >> v;
            if (v >= naj) ++res, naj = v;
        }
     
        cout << res << '\n';
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define INFTY  (1 << 30)
const int Total = 101;
const int White = 0;//未访问
const int Grey = 1;//访问中
const int Black = 2;//不再访问
int  totalnode,Matrix[Total][Total], Color[Total], DistanceBetweenRootAndNode[Total],Parent[Total];
void includeBuildSingleSourceShortestPath()
{
	int minimumdistance, min;
	DistanceBetweenRootAndNode[0] = 0;//默认以0为根
	Parent[0] = -1;
	Color[0] = Grey;
	while (1)
	{
		minimumdistance = INFTY;
		for (int i = 0; i < totalnode; i++)
		{
			if (Color[i] != Black && DistanceBetweenRootAndNode[i] < minimumdistance)//在未访问或访问的点中找出最短的那个
				minimumdistance = DistanceBetweenRootAndNode[i], min = i;
		}
		if (minimumdistance == INFTY)break;//全部为黑色
		Color[min] = Black;//以min为基础搜相连的结点
		for (int i = 0; i < totalnode; i++)
		{
			if (Matrix[min][i] != 0 && Color[i] != Black)//找出相连且未被设为不再访问的结点
			{
				if (DistanceBetweenRootAndNode[min] + Matrix[min][i] < DistanceBetweenRootAndNode[i])
					//若根到点min的距离 加上 点min到点i的距离 小于 之前根到点i的距离
				{
					DistanceBetweenRootAndNode[i] = DistanceBetweenRootAndNode[min] + Matrix[min][i];
					Parent[i] = min;
					Color[i] = Grey;
				}

			}

		}


	}
}
int main()
{
	int frontnode,backnode,degree,distancebetweenfrontnodeandbacknode;
	cin >> totalnode;
	for (int i = 0; i < totalnode; i++)DistanceBetweenRootAndNode[i] = INFTY;//初始化距离
	for (int i = 0; i < totalnode; i++)Color[i] = White;
	for (int i = 0; i < totalnode; i++)
		for (int j = 0; j < totalnode; j++)
			Matrix[i][j] = 0;
	for (int i = 0; i < totalnode; i++)//有向图
	{
		cin >>frontnode>>degree;//frontnode中题目其实就默认从0开始
		for (int j = 0; j < degree; j++)
		{
			cin >> backnode>> distancebetweenfrontnodeandbacknode;
			Matrix[frontnode][backnode] = distancebetweenfrontnodeandbacknode;
		}
	}
	includeBuildSingleSourceShortestPath();
	for (int i = 0; i < totalnode; i++)
		cout << i <<" "<< DistanceBetweenRootAndNode[i]<<endl;
}



Measured memory_bytes: 3124
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <stack>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, x, n) for (int i = x; i < n; ++i)

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    int n;
    ull k;
    scanf("%d %lld", &n, &k);

    vv next(n);
    REP(i, n)
    {
        int a;
        scanf("%d", &a);
        next[i].push_back(a - 1);
    }

    v r(n, 0);
    int x = 0;
    int lastx = 0;
    int count = 0;
    while (true)
    {
        if (count == k)
        {
            printf("%d", lastx + 1);
            return 0;
        }
        if (r[x])
        {
            break;
        }
        ++count;
        lastx = next[x][0];
        r[x] = 1;
        x = lastx;
    }

    int length = 1;
    x = lastx;
    while (lastx != next[x][0])
    {
        x = next[x][0];
        ++length;
    }

    x = lastx;
    int ans = x;
    int extra = (k - count) % length;
    REP(i, extra)
    {
        ans = next[x][0];
        x = ans;
    }
    printf("%d\n", ans + 1);
}

Measured memory_bytes: 14460
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

bool mycom(i_i a, i_i b){
  return a.Y > b.Y;
}

signed main(void){
  int i, j;
  for(int testcase = 0;;testcase++){
    vector<i_i> lis;
    for(;;){
      int a, b;
      scanf("%d,%d", &a, &b);
      if(a == 0 && b == 0)break;
      lis.pb(mp(a, b));
    }

    sort(all(lis), mycom);

    for(int x;scanf("%d", &x) != EOF;){
      int cnt = 1;
      for(i = 0;;){
        if(lis[i].X == x)break;
        ++i;
        if(i >= lis.size())break;
        if(lis[i - 1].Y != lis[i].Y)cnt++;
      }
      pri(cnt);
    }


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1208
N,L=[int(x) for x in input().rstrip().split()]
l=[L+i for i in range(N)]

if 0<=L:
  print(sum(l[1:]))
elif l[0]<0 and 0<=l[N-1]:
  print(sum(l))
else:
  print(sum(l[0:N-1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll v[3005][3005];
ll dp[3005][3005][5];

signed main(){
	//cout << fixed << setprecision(10);
	ll R,C,n; cin >> R >> C >> n;
	rep(i,0,n){
		ll a,b,value;
		cin>>a>>b>>value;
		v[a-1][b-1]=value;
	}
	rep(i,0,R){
		rep(j,0,C){
			for(int k=2;k>=0;--k){
				chmax(dp[i][j][k+1],dp[i][j][k]+v[i][j]);
			}
			rep(k,0,4){
				chmax(dp[i+1][j][0],dp[i][j][k]);
				chmax(dp[i][j+1][k],dp[i][j][k]);
			}
		}
	}
	ll ans=0;
	rep(k,0,4)chmax(ans,dp[R-1][C-1][k]);
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 426264
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
r = 0
for a, b, c in combinations(L, 3):
    if a !=b and b != c and c != a:
        if a+b > c and b+c > a and c+a > b:
            r += 1
print(r)


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

int main(){
	int N;
  	cin>>N;
  	for(int i=0;i<26;++i){
    	for(int j=0;j<15;++j)
          	if(4*i+7*j==N){cout<<"Yes"<<endl;return 0;}
    }cout<<"No"<<endl;return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  

}

int mod=1e9+7;
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,a,b;
   cin>>n>>a>>b;
   int ans=0;
   ans=(power(2,n,mod)-1+mod)%mod;
      int z=1,y=1;
      for(int i=1;i<=a;i++)
      {
         z=(z*(n-i+1))%mod;
         y=(y*i)%mod;         
      }
      z=(z*power(y,mod-2,mod))%mod;
      ans=(ans-z+mod)%mod;
      z=1;
      y=1;
      for(int i=1;i<=b;i++)
      {
         z=(z*(n-i+1))%mod;
         y=(y*i)%mod;         
      }
      z=(z*power(y,mod-2,mod))%mod;
      ans=(ans-z+mod)%mod;
      cout<<ans;
// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int cnt=0;
    for (int i = 1; i <=1e6; i++)
    {
        cnt+=(n-1)/i;
    }
    
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(long long int i=a; i<=b; i++)
#define ll long long
#define MOD 2019

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	ll l, r;
	cin >> l >> r;
	ll mini = INT_MAX;
	if (r >= l+MOD) mini = 0;
	else {
		l %= MOD;
		r %= MOD;
		rept(i, l, r) {
			rept(j, i+1, r) {
				ll ans = (i*j) % MOD;
				mini = min(mini, ans);
			}
		}
	}
	cout << mini << endl;



	return 0;
}



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

int main(void){
    //入力
    long N;
    cin>>N;
    long L=0,R=0;
    vector<long> W(N);
    for(int i=0;i<N;i++){
        cin>>W.at(i);
        R+=W.at(i);
    }
    
    //計算
    long ans=100000000000000;
    for(int T=0;T<N-1;T++){
        L+=W.at(T);
        R-=W.at(T);
        ans=min(ans,abs(L-R));
    }
    
    //出力
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

const int MAX_N = 512;
const int MAX = 1e6 + 10;
int sum[MAX_N];
int dp[MAX];
int odddp[MAX];

void init() {
    for (int i = 1; i < MAX_N; i++) {
        sum[i] = i * (i + 1) * (i + 2) / 6;
    }
    for (int i = 1; i < MAX; i++) {
        dp[i] = odddp[i] = i;
    }
    for (int i = 1; i < MAX_N; i++) {
        for (int j = 0; j + sum[i] < MAX; j++) {
            chmin(dp[j + sum[i]], dp[j] + 1);
            if (chmin(odddp[j + sum[i]], (sum[i] % 2 % 2 ? odddp[j] + 1 : INF))) {
                //if (j + sum[i] <= 40) {DEBUG(j)DEBUG(sum[i])DEBUG(j + sum[i])puts("");}
            }
        }
    }
}

void solve(int n) {
    cout << dp[n] << " " << odddp[n] << endl;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    init();
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 10780
n,k = map(int,input().split())
s = input()

s += 'x'
l = list()
cnt = 1
for i in range(1,n+1):
  if s[i]!=s[i-1]:
    l.append(cnt)
    cnt = 1
  else:
    cnt += 1

m = min(2*k+1, len(l))
ans = sum(l[0:m]) - 1 

for j in range(m,len(l)):
  ans += l[j] - 1

print(ans)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

string to_binString(int val)
{
    if( !val )
        return std::string("0");
    string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

int main()
{
    ll n,k,q;
    cin >> n >> k >> q;
    vll a(q),b(n,0);
    rep(i,q){
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }

    rep(i,n){
        b[i] += k-q;
        if(b[i] < 1)cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    
    return 0;
}

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

// 連想配列
void answer1() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  map<int, bool> mp;
  int in;
  while (cin >> in) {
    auto itr = mp.find(in);
    if (itr == mp.end()) {
      mp[in] = true;
    } else {
      mp.erase(itr);
    }
  }
  cout << mp.size() << endl;
}

// バケット
void answer2() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<bool> bucket(pow(10, 9) + 1, false);
  for (int i = 0; i < N; i++) {
    int in;
    cin >> in;
    bucket.at(in) = ! bucket.at(in);
  }

  int count = 0;
  for (bool b: bucket) {
    if (b) {
      count++;
    }
  }
  cout << count << endl;
}

// ソート
void answer3() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<long long> a(N);
  for (auto& a_i: a) {
    cin >> a_i;
  }
  sort(a.begin(), a.end());

  long long pre = 0;
  int pre_count = 0;
  int count = 0;

  for (auto a_i: a) {
    if (a_i == pre) {
      pre_count++;
    } else {
      if (pre_count % 2 == 1) {
        count++;
      }
      pre = a_i;
      pre_count = 1;
    }
  }
  if (pre_count % 2 == 1) {
    count++;
  }
  cout << count << endl;
}

int main() {
  //answer1();
  //answer2(); // 実行時間制限超過
  answer3();
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;
string st[10000];
int n,m;
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
		cin>>st[i];
	for (int i=1;i<=n;i++)
    for (int j=i;j<=n;j++)
    	if (st[i]>st[j]) swap(st[i],st[j]);
    for (int i=1;i<=n;i++)
    {
    	cout<<st[i];
    }
}

Measured memory_bytes: 384