akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){

    int num, dig, sum=0;
    scanf("%d", &num);

    int tmp = num;
    while(tmp){
        dig = tmp % 10;
        sum = sum + dig;
        tmp = tmp / 10;
    }
    if(num%sum==0) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
tarou = 0
hanako = 0
n = int(input())
for i in range(n):
    str1, str2 = input().split()
    if str1 > str2:
        tarou += 3
    elif str1 < str2:
        hanako += 3
    else:
        tarou += 1
        hanako += 1
print("{0} {1}".format(tarou, hanako))

Measured memory_bytes: 7632
a=(1..n=gets.to_i).map{(1..gets.to_i).map{gets.split.map &:to_i}}
p (0...2**n).map{|b|i=-1;a.all?{|t|b[i+=1]<1||t.all?{|x,y|b[x-1]==y}}?b.to_s(2).count(?1):0}.max

Measured memory_bytes: 2172
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b){
            System.out.println("a < b");
        }else if(a == b){
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }
    }
}


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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 6;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 3;
const int SM = 1e3 + 7;
const double EPS = 3e-16;

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

	long long n; cin >> n;
	
	vector<long long> a(n);
	for(long long i = 0; i < n; i++){
		cin >> a[i];
	}
	
	long long sum = 0;
	for(long long i = 0; i < n; i++){
		for(long long j = i + 1; j < n; j++){
			sum += a[i] * a[j];
		}
	}
	
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

//２項定理(MOD使用)
const ll MAX = 1000000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    vector<ll> len;
    pair<ll, ll> pre;
    pre.first = 0;
    pre.second = 0;
    ll x, y;

    cin >> x >> y;

    len.push_back(1);
    COMinit();

    ll a = 0, b = 0;
    ll n = 0;
    rep(i, 0, 1000000){
        a += 2;
        b += 1;
        n++;
        if(a - x == y - b){
            cout << COM(n, a - x) << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
using namespace std;
int main(){
	int a,b;

	while(1){
		cin >> a >> b;
	if(a>b){
		int x;
		x = a;
		a = b;
		b = x;
	}
	if(a==0 && b==0) break;
	cout << a << " " << b << endl;
	}
	
	return 0;

}

Measured memory_bytes: 1160
n, x = map(int, input().split())
t = list(map(int, input().split()))

def gcd(a, b):
  c = a%b
  if c == 0:
    return b
  return gcd(b, c)

ans = 0

for i in t:
  j = abs(x-i)
  if ans == 0:
    ans = j
  else:
    ans = gcd(ans, j)

print(ans)

Measured memory_bytes: 15020
N = int(input())
h_list = input().split()
h_list = [int(i) for i in h_list]
current_V = [0]
current_value = [0] * N
current_cost = 0
while (current_V != []):

    V = current_V.pop(0)
    if N - 1 >= V + 1 :
        if V + 1 not in current_V :
            current_V.append(V + 1)
            current_value[V + 1] = current_value[V] + abs(h_list[V] - h_list[V + 1])
        else:
            value = current_value[V] + abs(h_list[V] - h_list[V + 1])
            if value < current_value[V + 1]:
                current_value[V + 1] = value
    if N - 1 >= V + 2 :
        if V + 2 not in current_V :
            current_V.append(V + 2)
            current_value[V + 2] = current_value[V] + abs(h_list[V] - h_list[V + 2])
        else:
            value = current_value[V] + abs(h_list[V] - h_list[V + 2])
            if value < current_value[V + 2]:
                current_value[V + 2] = value
print(current_value[N - 1])


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

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

const ll inf = 1LL << 60;

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

typedef pair<ll, ll> P;
vec color;
mat graph;

bool dfs (ll v, ll c) {
    color[v] = c;
    for (ll nv : graph[v]) {
        if (color[nv] == c) return false;
        if (color[nv] == 0 and !dfs(nv, -c)) return false;
    }

    return true;
}

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

    ll N, M;
    cin >> N >> M;
    graph.assign(N, vec());
    color.assign(N, 0);
    Rep (i, M) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }

    ll ans;
    if (dfs(0, 1)) {
        ll cnt = 0;
        for (ll e : color) {
            if (e == 1) cnt++;
        }
        ans = cnt * (N-cnt);
    } else {
        ans = N * (N-1) / 2;
    }

    ans -= M;

    cout << ans << "\n";
}

Measured memory_bytes: 7424
def sum(a)
    s = 0
    a.each do |v|
        s += v
    end
    return s
end

def copy(a)
    b = []
    a.each do |v|
        b.push(v)
    end
    return b
end

input_data = gets.chomp.split(" ")
taro = input_data[0].to_i
hanako = input_data[1].to_i

while taro != 0 do 
    taroNumberArr = []
    taro.times do |i|
        taroNumber = gets.chomp.to_i
        taroNumberArr.push(taroNumber)
    end
    taroNumberArr.sort!
    
    hanakoNumberArr = []
    hanako.times do |j|
        hanakoNumber = gets.chomp.to_i
        hanakoNumberArr.push(hanakoNumber)
    end
    hanakoNumberArr.sort!
    
    endFlug = false
    taro.times do |i|
        hanako.times do |j|
            tc = copy(taroNumberArr)
            hc = copy(hanakoNumberArr)
            #要素のスワップをする。
            tem = tc[i]
            tc[i] = hc[j]
            hc[j] = tem
            if(sum(tc) == sum(hc))
                puts taroNumberArr[i].to_s + ' '+ hanakoNumberArr[j].to_s
                endFlug = true
                break
            end
        end
        break if endFlug
    end
    
    puts -1 unless endFlug
    input_data = gets.chomp.split(" ")
    taro = input_data[0].to_i
    hanako = input_data[1].to_i
end


Measured memory_bytes: 11900
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 10000000
#define ll long long
using namespace std;

int main(){
    ll d,t,s;
    cin>>d>>t>>s;
    if(d>t*s) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
  int A, B, sum = 0,j = 0, l = 0, k= 0, f = 0;
  cin >> A >> B;
  
  int n1 = 0, n2 = 0, n4= 0, n5 = 0;
 
  // ここにプログラムを追記
    rep2(i ,A ,B+1 ) {
      l = i;
        
      n1 = l / 10000;
      l = l % 10000;
      
      n2 = l / 1000;
      l = l % 1000;
      l = l % 100;
      
      n4 = l / 10;
      n5 = l % 10;
      
        if ((n1 == n5)&&(n2 == n4)) {
          sum = sum + 1;
        }
  	}
    	cout << sum;
}

Measured memory_bytes: 256
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		int[] D = new int[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			D[i] = Integer.parseInt(tokens[i]);
		}
		long MOD = 998244353L;
		Map<Integer, Integer> counts = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			if (!counts.containsKey(D[i])) {
				counts.put(D[i], 1);
			} else {
				counts.put(D[i], counts.get(D[i]) + 1);
			}
		}
		long result = 0L;
		if (!enableA(counts)) {
			System.out.println(result);
		} else if (!enableB(D, counts)) {
			System.out.println(result);
		} else {
			result = 1L;
			int n = counts.keySet().size();
			for (int i = 2; i < n; ++i) {
				long base = (long) counts.get(i - 1);
				long mul = 1L;
				for (int j = 0; j < counts.get(i); ++j) {
					mul *= base;
					mul %= MOD;
				}
				result *= mul;
				result %= MOD;
			}
			System.out.println(result);
		}
	}

	static boolean enableB(int[] D, Map<Integer, Integer> counts) {
		if (D[0] != 0) {
			return false;
		} else if (counts.get(0) > 1) {
			return false;
		} else {
			return true;
		}
	}

	static boolean enableA(Map<Integer, Integer> counts) {
		boolean result = true;
		int n = counts.keySet().size();
		for (int i = 0; i < n; ++i) {
			if (!counts.containsKey(i)) {
				result = false;
				break;
			}
		}
		return result;
	}
}

Measured memory_bytes: 44056
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main() {
	
	while(true){
		int H;
		cin >> H;
		
		if(H == 0){
			break;
		}
		
		int ss = 0;
		int a[20][20] = {};
		
		for(int i = H - 1; i >= 0; i--){
			for(int j = 1; j <= 5; j++){
				cin >> a[i][j];
				ss += a[i][j];
			}
		}
		
		while(true){
			
			bool is_ext = false;
			bool ext[20][20] = {};
			
			for(int i = 0; i < H; i++){
				for(int j = 1; j <= 5; j++){
					if(a[i][j - 1] == a[i][j] && a[i][j] == a[i][j + 1] && a[i][j] > 0){
						ext[i][j - 1] = true;
						ext[i][j] = true;
						ext[i][j + 1] = true;
						is_ext = true;
						//cout << i << " " << j << endl;
					}
				}
			}
			if(!is_ext){
				break;
			}
			
			for(int i = 0; i < H; i++){
				for(int j = 1; j <= 5; j++){
					if(ext[i][j]){
						a[i][j] = -1;
					}
				}
			}
			
			/*
			for(int i = H - 1; i >= 0; i--){
				for(int j = 1; j <= 5; j++){
					cout << a[i][j] << " ";
				}
				cout << endl;
			}
			cout << endl;
			*/
			
			for(int loop = 0; loop <= H; loop++){
				for(int i = 0; i < H; i++){
					for(int j = 1; j <= 5; j++){
						if(a[i][j] == -1){
							a[i][j] = a[i + 1][j];
							a[i + 1][j] = -1;
						}
					}
				}
			}
			
			/*
			for(int i = H - 1; i >= 0; i--){
				for(int j = 1; j <= 5; j++){
					cout << a[i][j] << " ";
				}
				cout << endl;
			}
			cout << endl;
			*/
		}
		
		int rem = 0;
		
		for(int i = H - 1; i >= 0; i--){
			for(int j = 1; j <= 5; j++){
				//cout << a[i][j] << " ";
				if(a[i][j] > 0){
					rem += a[i][j];
				}
			}
			//cout << endl;
		}
		
		cout << ss - rem << endl;
		
	}
	return 0;
}




Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int a,b;
    cin >> a >> b;
    int ans = -1;
    for(int i = 0;i < 10;i++){
        int sum = b*10+i;
        //cout << (int)sum*0.08 << endl;
        int aa = sum*0.08,bb = sum*0.1;
        if(aa == a && bb == b){
            ans = sum;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
for i in range(2,min(n-1,int(n**.5)+1)):
# for i in range(2,n*+1):
  if n % i == 0:
    tmp = n

    while tmp % i == 0:
      tmp //= i
    if tmp % i == 1:ans += 1

    if n //i == i or n //i == n or n // i == n-1:continue

    tmp = n; i = n // i
    while tmp % i == 0:
      tmp //= i
    if tmp % i == 1:ans += 1

  elif (n-1) % i == 0:
    if (n-1)//i != i and  (n-1) //i != n and (n-1) // i != n-1:ans += 2
    else: ans += 1

if n != 2:ans += 2
else: ans += 1
print(ans)


Measured memory_bytes: 40044
#[allow(unused_macros)]
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)*}
    };
}

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

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

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        h: usize,
        w: usize,
        k: usize,
    }
    let MOD:i64 = 1_000_000_007;
    let mut dp = vec![vec![0;w];h+1];
    dp[0][0] = 1;
    for hi in 0..h {
        for wi in 0..w {
            for bit in 0..(1<<(w-1)) {
                let mut ok = true;
                if w==1 {
                    continue;
                }
                for i in 0..w-2 {
                    if (((bit>>i) & 1) != 0) && (((bit>>(i+1)) & 1) != 0) {
                        ok = false;
                    }
                }
                if ok {
                    if wi >= 1 && (((bit>>(wi-1)) & 1) != 0) {
                        dp[hi+1][wi-1] += dp[hi][wi];
                        dp[hi+1][wi-1]%=MOD;
                    }else if wi+2 <= w  && (((bit>>wi) & 1) != 0){
                        dp[hi+1][wi+1] += dp[hi][wi];
                        dp[hi+1][wi+1]%=MOD;
                    }else{
                        dp[hi+1][wi] += dp[hi][wi];
                        dp[hi+1][wi]%=MOD;
                    }
                }
            }
        }
    }
    let ans = if w==1 {
        1
    }else{
        dp[h][k-1]
    };
    // println!("{:?}", dp);
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		Map<Integer, Boolean> map = new HashMap<>();
		int ans = 0;
		int multiCount = 0;
		for(int i = 0; i < n; i++){
			int key = scan.nextInt();
			if(!map.containsKey(key)){
				ans++;
				map.put(key, true);
			}else{
				multiCount++;
			}
		}
		
		if(multiCount % 2 != 0){
			ans--;
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 51732
import math
a, b, x = map(int, input().split())


if x <= (a*a*b)/2:
    h = (2*x)/(a*b)
    print(math.degrees(math.atan(b/h)))
else:
    t = (2*x)/(a*a) - b
    print(math.degrees(math.atan((b-t)/a)))


Measured memory_bytes: 3316
n = gets.to_i
a = gets.split.map { |t| t.to_i }

m = 1000
k = 0

b = []
a.each_with_index do |t, i|
  # p [t, i]
  if (i == 0 || a[i-1] >= t) && (i+1 < n && t < a[i+1])
    b << t
  elsif (0 <= i-1 && a[i-1] < t) && (i == n-1 || t >= a[i+1])
    b << t
  end
end

b.pop if b.size.odd?
b.each_with_index do |t, i|
  if i.even?
    k_add = m / t
    k += k_add
    m -= t * k_add
  else
    m_add = k * t
    k = 0
    m += m_add
  end
  # p m
end

puts m

Measured memory_bytes: 14300
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    static final char[] DIRECTIONS = { 'L', 'R', 'D', 'U' };
    static final int[] X_OFFSETS = { -1, 1, 0, 0 };
    static final int[] Y_OFFSETS = { 0, 0, -1, 1 };
    static final int REGULATION_MOVE = 0;

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

        int N = sc.nextInt();
        int[] X = new int[N];
        int[] Y = new int[N];
        for (int i = 0; i < N; ++i) {
            X[i] = sc.nextInt();
            Y[i] = sc.nextInt();
        }

        System.out.println(solve(X, Y));

        sc.close();
    }

    static String solve(int[] X, int[] Y) {
        if (IntStream.range(0, X.length).map(i -> Math.abs((X[i] + Y[i]) % 2)).distinct().count() != 1) {
            return "-1";
        }

        boolean regulationNeeded = (X[0] + Y[0]) % 2 == 0;

        if (regulationNeeded) {
            for (int i = 0; i < X.length; ++i) {
                X[i] -= X_OFFSETS[REGULATION_MOVE];
                Y[i] -= Y_OFFSETS[REGULATION_MOVE];
            }
        }

        int[] d = IntStream.range(0, 31).map(i -> 1 << i).toArray();

        String[] w = new String[X.length];
        for (int i = 0; i < w.length; ++i) {
            int x = X[i];
            int y = Y[i];
            char[] path = new char[d.length];
            for (int j = path.length - 1; j >= 0; --j) {
                for (int k = 0;; ++k) {
                    int nextX = x - X_OFFSETS[k] * d[j];
                    int nextY = y - Y_OFFSETS[k] * d[j];

                    if ((long) Math.abs(nextX) + Math.abs(nextY) <= (1 << j) - 1) {
                        x = nextX;
                        y = nextY;
                        path[j] = DIRECTIONS[k];

                        break;
                    }
                }
            }

            w[i] = new String(path);
        }

        if (regulationNeeded) {
            d = Arrays.copyOf(d, d.length + 1);
            d[d.length - 1] = 1;

            for (int i = 0; i < w.length; ++i) {
                w[i] += DIRECTIONS[REGULATION_MOVE];
            }
        }

        return String.format("%d\n%s\n%s", d.length,
                Arrays.stream(d).mapToObj(String::valueOf).collect(Collectors.joining(" ")), String.join("\n", w));
    }
}

Measured memory_bytes: 43116
package main

import "fmt"

var CYCLE = 1000000007
var N, K int
var a [100]int
var results [100][100001]int

func max(a int, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	fmt.Scan(&N, &K)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	for j := 0; j <= a[N-1] && j <= K; j++ {
		results[N-1][j] = 1
	}

	for i := N - 2; i >= 0; i-- {
		for j := 0; j <= K; j++ {
			r := results[i+1][j]
			if j > 0 {
				r += results[i][j-1]
			}
			if j-1-a[i] >= 0 {
				r -= results[i+1][j-1-a[i]]
			}
			results[i][j] = (r + CYCLE) % CYCLE
		}
	}

	fmt.Println(results[0][K])

	// for i := 0; i < N; i++ {
	// 	fmt.Println(results[i][:K+1])
	// }
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    string S;
    cin >> S;
    int n = S.size();
    int ans = 0;
    bool flag = true;
    for (int k = 0; k < n; k++){
        if (S[k] == 'A' || S[k] == 'T' || S[k] == 'G' || S[k] == 'C')       continue;
        else{
            flag = false;
        }
    }
    if (flag) ans = n;
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= n -i; ++j){
            string tmp = S.substr(i, j);
            bool flag = true;
            for (int k = 0; k < tmp.size(); k++){
                if (tmp[k] == 'A' || tmp[k] == 'T' || tmp[k] == 'G' || tmp[k] == 'C') continue;
                else{
                    flag = false;
                }
            }
            if (flag){
                ans = max(ans, (int)tmp.size());
            }
        }
    }

    printf("%d\n", ans);
}
int main(void){
    //////////////////////////

    solve();

    //////////////////////////
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
count = 0
ans = 0
(1..n).each do |a|
  if a.odd?
    (1..a).each do |b|
      if (a % b) == 0
        count += 1
      end
    end
  end
  if count == 8
    ans += 1
  end
  count = 0
end

puts ans


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

string grid[4];
bool visited[4][4];

vector<pair<int, int>> adj[105];
int main() {
	for(int i = 1; i <= 3; ++i) {
		for(int j = 1; j <= 3; ++j) {
			int x;
			cin >> x;
			adj[x].push_back({i, j});
		}
	}
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		for(pair<int, int> y : adj[x])
			visited[y.first][y.second] = true;
	}
	bool ok = false;
	for(int i = 1; i <= 3; ++i) {
		int cnt = 0;
		for(int j = 1; j <= 3; ++j)
			cnt += visited[i][j];
		if(cnt == 3)
			ok = true;
	}
	for(int i = 1; i <= 3; ++i) {
		int cnt = 0;
		for(int j = 1; j <= 3; ++j)
			cnt += visited[j][i];
		if(cnt == 3)
			ok = true;
	}
	if(visited[1][1] + visited[2][2] + visited[3][3] == 3 || visited[1][3] + visited[2][2] + visited[3][1] == 3)
		ok = true;
	if(ok)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int A, B; std::cin >> A >> B;
  if ( A <= 8 && B <= 8 ) std::cout << "Yay!" << std::endl;
  else std::cout << ":(" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

ll dp[2][2019];
int main(){
  string S; cin >> S;
  int N = sz(S);
  ll ans = 0;
  rep(i,N){
    rep(j,2019){
      dp[(i+1)%2][(j*10+(int)(S[i]-'0'))%2019] = dp[i%2][j];
    }
    dp[(i+1)%2][S[i]-'0']++;
    //cout << dp[(i+1)%2][0] << " " <<  dp[(i+1)%2][1] <<" " << dp[(i+1)%2][8] << " "<< dp[(i+1)%2][18] << endl;
    //cout << "aa" << endl;
    ans += dp[(i+1)%2][0];
  }

  cout << ans << endl;
  //cout << dp[N%2][0] << endl;
  return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
using namespace std;
queue<ll> q;
int n;
int main()
{

    cin>>n;
    for(int i=1;i<=9;i++)
    {
        q.push(i);
    }
    for(int i=1;i<=n;i++)
    {

        ll pre=q.front();
        q.pop();
        if(i==n)
        {
            cout<<pre<<endl;
        }
        ll r=pre%10;
        pre=pre*10+r;
        if(r>0)
            q.push(pre-1);
        q.push(pre);
        if(r<9)
        {
            q.push(pre+1);
        }
    }

    return 0;
}


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

int main(){
  vector<int>z={1,2,3};
  int a,b;
  cin >> a >> b;
  vector<int>x(3);
  for(int i=0;i<3;i++){
    if(a==i+1){
      x[i]=a;
    }
    if(b==i+1){
      x[i]=b;
    }
  }
  for(int i;i<3;i++){
    if(z[i]!=x[i]){
      cout << i+1 << endl;
    }
  }
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split('');
    var cnt = 0;
    if(args[0]==='1'){
        cnt++;
    }
    if(args[1]==='1'){
        cnt++;
    }
    if(args[2]==='1'){
        cnt++;
    }
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
n = gets.to_i
# dp[桁][二つ前][ひとつ前]
# 選ばない=0, a=1, g=2, c=3, t=4
# a=1,g=2にc=3が続いてはダメ
# g=2,a=1にc=3が続いてはダメ
# a=1,c=3にg=2が続いてはダメ
# a=1,g=2,なんとか,にc=3が続いてはダメ
# a=1,なんとか,g=2,にc=3が続いてはダメ
# あとは自由

MOD = 10**9+7
dp = Array.new(n + 1) { Array.new(1000, 0) }
dp[0][0] = 1 # [桁][直近3回の状態を3桁の10進数で]

def each_state
  5.times do |i|
    5.times do |j|
      5.times do |k|
        yield i * 10 + j, j * 10 + k, i * 100 + j * 10 + k
      end
    end
  end
end

n.times do |i|
  each_state do |s1, s2, s3|
    1.upto(4) do |v|
      next if s2 == 12 && v == 3
      next if s2 == 21 && v == 3
      next if s2 == 13 && v == 2
      next if s1 == 12 && v == 3
      next if s3 == 112 && v == 3
      next if s3 == 122 && v == 3
      next if s3 == 132 && v == 3
      next if s3 == 142 && v == 3
      ns = s2 * 10 + v
      dp[i + 1][ns] += dp[i][s3]
      dp[i + 1][ns] %= MOD
    end
  end
end

ans = dp[n].inject(0, :+)
puts ans % MOD


Measured memory_bytes: 2556
def f753():
    s=["3","5","5"]
    while 1:
        lens=len(s)
        for i in range(lens-1,-1,-1):
            if s[i]!="7":
                s[i]="5" if s[i]=="3" else "7"
                for ii in range(i+1,lens):
                    s[ii]="3"
                break
        else:
            s=["3"]*(lens-1)+["5","7"]
        if len(set(s))<3:continue
        yield int("".join(s))

n=int(input())
cnt=0
for n753 in f753():
    if n753>n:break
    cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	string s, t;
	cin >> s >> t;
	vector<array<int, 26>> table(s.size());
	for (auto& x : table)for (auto& y : x)y = -1;
	for (char i = 'a'; i <= 'z'; ++i) {
		int p, j = 0;
		for (; j < s.size(); ++j) {
			if (s[j] == i) {
				p = j;
				break;
			}
		}
		if (j == s.size())continue;
		int k = (j - 1 + s.size()) % s.size();
		for(int x = 0; x < s.size(); ++x) {
			table[k][i-'a'] = p;
			if (s[k] == i) p = k;
			k = (k - 1 + s.size()) % s.size();
		}
	}
	ll ans,p;
	auto st = s.find_first_of(t[0]);
	if (st == string::npos) {
		PRI(-1);
		return 0;
	}
	ans = st + 1;
	p = st;
	for (char& c : t.substr(1,t.size()-1)) {
		if (table[p][c - 'a'] == -1) {
			PRI(-1);
			return 0;
		}
		if (table[p][c - 'a'] <= p) ans += s.size() - p + table[p][c - 'a'];
		else ans += table[p][c - 'a'] - p;
		p = table[p][c - 'a'];
	}
	PRI(ans);
	return 0;
}




Measured memory_bytes: 13820
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll am[26],dp[1<<26],MOD=1e9+7;


ll solve(int msk){
  if(!msk) return 0;
  ll &r=dp[msk];
  if(r>=0) return r;
  int id=__builtin_ctz(msk);
  bitset<26> b(msk);
  if(msk^(1<<id)){
    ll pre=solve(msk^(1<<id));
    r=(am[id]+1)*pre%MOD;
  }
  else{
    r=(am[id]+1);
  }
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  int n;
  string s; cin >> n >> s;
  fore(i,0,n){
    am[s[i]-'a']++;
  }
  cout << solve((1<<26)-1)-1 << endl;
}

Measured memory_bytes: 524800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

//                 L  U
const int dx[2] = {-1, 0};
const int dy[2] = {0, -1};

// Self settings
// clang-format off
#define MAX_HW 1000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on
int H, W;
bool board[MAX_HW][MAX_HW];
ll dp[MAX_HW + 1][MAX_HW + 1];
const int mod = 1000000007;

int neighbor(int x, int y)
{
  ll n = 0;
  for (int i = 0; i < 2; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    // 盤外か岩なら組み合わせからはずす
    if (xx < 0 || yy < 0 || !board[xx][yy]) continue;
    n = (n + dp[xx][yy]) % mod;
  }
  return n;
}

void solve()
{
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      // 岩もしくは最初はスキップ
      if (!board[i][j] || (i == 0 && j == 0)) continue;
      dp[i][j] = neighbor(i, j);
    }
  }
  cout << dp[H - 1][W - 1] << endl;
}

int main(void)
{
  cin >> H >> W;
  REP(i, H) REP(j, W)
  {
    char x;
    cin >> x;
    if (x == '.')
      board[i][j] = true;
    else
      board[i][j] = false;
  }
  solve();
  return 0;
}


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

typedef complex<double> P;

const double eps = 1e-8;
const double inf = 1.0 / 0.0;

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

namespace CCW {
  enum { COUNTER_CLOCKWISE = 1, CLOCKWISE = -1,
         ONLINE_BACK = 2, ONLINE_FRONT = -2,
         ONSEGMENT = 0 };
}

int ccw(P p0, P a, P b) {
  a -= p0;
  b -= p0;
  if(cross(a, b) > eps) return CCW::COUNTER_CLOCKWISE;
  if(cross(a, b) < -eps) return CCW::CLOCKWISE;
  if(dot(a, b) < -eps) return CCW::ONLINE_BACK;
  if(norm(b)-norm(a) > eps) return CCW::ONLINE_FRONT;
  return CCW::ONSEGMENT;
}

bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
           ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0 );
}

double getDistanceLP(P s1, P s2, P p) {
  return abs(cross(s2 - s1, p - s1)/abs(s2 - s1));
}

double getDistanceSP(P s1, P s2, P p) {
  if(dot(s2 - s1, p - s1) < 0.0) return abs(p - s1);
  if(dot(s1 - s2, p - s2) < 0.0) return abs(p - s2);
  return getDistanceLP(s1, s2, p);
}

double getDistance(P a1, P a2, P b1, P b2) {
  if(isIntersect(a1,a2,b1,b2)) return 0.0;
  return min(min(getDistanceSP(a1,a2,b1), getDistanceSP(a1,a2,b2)),
             min(getDistanceSP(b1,b2,a1), getDistanceSP(b1,b2,a2)));
}

int main() {
  for (int N; cin >> N && N; ) {
    P s, t;
    cin >> s.real() >> s.imag() >> t.real() >> t.imag();
    vector<P> a(N), b(N);
    vector<double> h(N);
    for (int i = 0; i < N; ++i) {
      cin >> a[i].real() >> a[i].imag()
          >> b[i].real() >> b[i].imag()
          >> h[i];
    }

    double res = inf;
    for (int i = 0; i < N; ++i) {
      if (a[i].real() <= s.real() && s.real() <= b[i].real() &&
          a[i].imag() <= s.imag() && s.imag() <= b[i].imag()) {
        res = 0;
        break;
      }
      if (a[i].real() <= t.real() && t.real() <= b[i].real() &&
          a[i].imag() <= t.imag() && t.imag() <= b[i].imag()) {
        res = 0;
        break;
      }
      double d = getDistance(s, t,
                             P(a[i].real(), a[i].imag()),
                             P(b[i].real(), a[i].imag()));
      d = min(d, getDistance(s, t,
                             P(a[i].real(), b[i].imag()),
                             P(b[i].real(), b[i].imag())));
      d = min(d, getDistance(s, t,
                             P(a[i].real(), a[i].imag()),
                             P(a[i].real(), b[i].imag())));
      d = min(d, getDistance(s, t,
                             P(b[i].real(), a[i].imag()),
                             P(b[i].real(), b[i].imag())));
      if (d <= h[i]) {
        res = min(res, d);
      } else {
        res = min(res, (d*d + h[i]*h[i]) / (2*h[i]));
      }
    }
    printf("%.10f\n", res);
  }
  return 0;
}

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

using namespace std;

int main(){
    unsigned long time_sec;
    int hh,mm,ss;
    cin >> time_sec;
    hh = time_sec/3600;
    mm = (time_sec-hh*3600)/60;
    ss = time_sec%60;
    cout << hh << ":" << mm << ":" << ss << "\n";
    return 0;
    
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<string.h>
#define true 1
#define false 0
typedef long long ll;

int main(void){

int i,j;
  int l,r,d;
    int c = 0;
    scanf("%d %d %d",&l,&r,&d);
  
  for(i=l;i<=r;i++){
    if(i % d == 0) c++; 
  }


printf("%d\n",c);

return 0;
}


Measured memory_bytes: 1684
#include<iostream>
//#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include <iomanip>
#include <set>
#include<cmath>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define int long long
#define mp make_pair
#define error(x) cout<<#x<<"="<<(x)<<endl;
void sp(double y,int x){cout<<fixed<<setprecision(x)<<y;}
int inf=1e9+10;
int const M=2e5+10;
int const M2=1e6+10;
int const M3=1e3+10;
int mod=1e9+7;
int a[M];
int cnt[M];
int sa(int x,int y){if(x%y==0)return x/y;return x/y+1;}
int binp(int x,int y){int ans=1;int t=x;while(y!=0){if(y%2==1){ans*=t;ans;}y/=2;t*=t;t;}return ans;}
main(){
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]==i)
        {
            if(a[i+1]==i+1)
                swap(a[i],a[i+1]);
            else
                swap(a[i],a[i-1]);
            ans++;
        }
    }
    cout<<ans;
}

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

int main (){
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1') ++counter;
  if (s[1] == '1') ++counter;
  if (s[2] == '1') ++counter;
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
card    = list(map(int, input().split()))
if card[0] > card[3]:
    print(card[3])
else:
    count  = card[3] - card[0] - card[1]
    answer = card[0]

    if count > 0:
        if count < card[2]:
            answer = answer + (count * -1)
            print(answer)
        else:
            answer = answer + (card[2] * -1)
            print(answer)
    else:
        print(answer)


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    int n, w; cin >> n >> w;
    vector<pair<ll, ll>> items(n+1);
    for (int i = 1; i <= n; i++) cin >> items[i].first >> items[i].second;

    // dp[items][weight]
    vector<vector<ll>> dp(n+1, vector<ll>(w+1, -LINF));

    dp[0][0] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < w+1; j++) {
            // take item
            if (j-items[i].first >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-items[i].first] + items[i].second);
            // don't take item
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }

    ll ans = 0;
    for (int i = 0; i < w+1; i++) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def mod_com_once(n, r, MOD):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    numer = denom = 1
    for i in range(1, r + 1):
        numer = numer * (n - r + i) % MOD
        denom = denom * i % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


def main():
    MOD = 1000000007
    X, Y = map(int, readline().split())

    p = (2 * X - Y) // 3
    q = (-X + 2 * Y) // 3

    if (X + Y) % 3 or p < 0 or q < 0:
        print(0)
        return

    print(mod_com_once(p + q, p, MOD))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define repi(i, a, b) for(int i = (int)(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

inline void Main() {
  // code
  int k, s;
  cin >> k >> s;

  int n;
  int res = 0;
  rep(i, k+1) {
    rep(j, k+1) {
      n = s - i - j;
      if(0<=n && n<=k) res++;
    }
  }

  cout << res << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool prime[7000000];

int main(){
	rep(i,7000000)prime[i]=true;
	prime[0]=prime[1]=false;
	loop(i,2,10000){
		for(int j=i*2;j<7000000;j+=i){
			prime[j]=false;
		}
	}
	long long a,d,n;
	while(cin>>a>>d>>n,a||d||n){
		long long num=a,cnt=0;
		while(cnt!=n){
			if(prime[num])cnt++;
			if(cnt!=n)num+=d;
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  if (op == '+') {
    cout << A + B << endl;
  }
  else if (op == '-') {
    cout << A - B << endl;
  }
}

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

int main()
{
  int N;
  int ans;
  ans=0;

  cin >> N ;
  vector<string> A(N);
  
  for(int i=0;i<N;i++){      
    cin >> A.at(i) ;
  }
  
	sort(A.begin(), A.end());
  
   for(int i=0;i<N;i++){
	if(A[i]==A[i+1])
      ans++;
   }
  
  cout << N-ans << endl;

return 0;
}


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

using namespace std;


int main() {
  long long a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 1 << '\n';
    return 0;
  }
  int r = -1, k = -1;
  for (int bit = 60; bit >= 0; bit--) {
    if (((1LL << bit) & a) != ((1LL << bit) & b)) {
      r = bit;
      break;
    }
  }
  for (int bit = r - 1; bit >= 0; bit--) {
    if ((1LL << bit) & b) {
      k = bit;
      break;
    }
  }
  a &= ((1LL << (r + 1)) - 1);
  b &= ((1LL << (r + 1)) - 1);
  vector<pair<long long, long long>> p = {{a, (1LL << r) - 1}, {1LL << r, b}, {1LL << r, (1LL << r) + (1LL << (k + 1)) - 1}, {(1LL << r) + a, (1LL << r) + (1LL << r) - 1}};
  sort(p.begin(), p.end());
  long long last = -1;
  long long ans = 0;
  for (auto& e : p) {
    ans += max(0LL, e.second - max(last, e.first) + 1);
    last = max(last, e.second + 1);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    std::string right = "yuiophjklnm";
    std::string S;
    while(std::cin >> S, S != "#"){
        int prev = -1, res = 0;
        for(const auto &c : S){
            int which = right.find(c) != std::string::npos;
            if(prev == -1){
                prev = which;
            }else if(which != prev){
                ++res; prev = which;
            }
        }

        printf("%d\n", res);
    }
}

Measured memory_bytes: 1188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

        int[] arr = new int[n+1];
        for (int i = 0; i < n-1; ++i) {
            if (s.charAt(i) == 'A' && s.charAt(i+1) == 'C')
                arr[i+1] = arr[i] + 1;
            else
                arr[i+1] = arr[i];
        }

        for (int i = 0; i < k; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            System.out.println(arr[b] - arr[a]);
        }
    }
}

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

int main() {
  int n,k;cin>>n>>k;
  vector<int> v(n);
  int x=k;
  int c=1;
  while(true){
    if(x>=n){break;}
    x+=k-1;c++;
  }
  
  cout<<c;
}
      



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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	unordered_set <string> stringSet ;
	int n;
	cin >> n;
	char a[100];

	for (int i = 0; i < n ; i++) {
		cin >> a;
		stringSet.insert(a) ;
	}

	cout << stringSet.size();



}


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

struct Drink {
	llong num;
	llong price;

	bool operator<(const Drink & another) {
		return num < another.num;
	}
};

void solve() {
	int N, M; cin >> N >> M;
	vector<Drink> drink(N);
	rep(i, N) scanf("%lld%lld", &drink[i].price, &drink[i].num);

	// 個数で昇順ソート
	sort(drink.begin(), drink.end(),
		[](const Drink & a, const Drink & b) {return a.price < b.price; });

	llong res = 0;
	rep(i, N) {
		if (M <= 0) break;
		if (drink[i].num > M) {
			res += M * drink[i].price;
		}
		else if (drink[i].num <= M) {
			res += drink[i].num * drink[i].price;
		}
		M -= drink[i].num;
	}
	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    int sum=0;
    cin >> n;
    vector<int> ans(n);
    vector<int> a(n+2);
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    rep(i,a.size()-1){
        sum += abs(a[i] - a[i+1]);
    }
    for(int i=1; i<=n; i++){
        ans[i-1] = sum - ((abs(a[i-1] - a[i]) + abs(a[i+1] - a[i])) - abs(a[i+1] - a[i-1]));
    }
    rep(i,n){
        cout << ans[i] <<endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
    const long long int mod = 1000000007,INF=50000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    string str;
    long long int n,m,a,b,now=-1;
    long long int dp[100005][4]={},res=0;
    cin>>str;
    dp[0][3]=1;
    for(int i=0;i<str.length();i++){
        dp[i+1][0]=dp[i][0];
        dp[i+1][1]=dp[i][1];
        dp[i+1][2]=dp[i][2];
        dp[i+1][3]=dp[i][3];
        if(str[i]=='A'){
            dp[i+1][2]+=dp[i][3];
        }else if(str[i]=='B'){
            dp[i+1][1]+=dp[i][2];
        }else if(str[i]=='C'){
            dp[i+1][0]+=dp[i][1];
        }else{
            dp[i+1][0]+=2*dp[i][0]+dp[i][1];
            dp[i+1][1]+=2*dp[i][1]+dp[i][2];
            dp[i+1][2]+=2*dp[i][2]+dp[i][3];
            dp[i+1][3]+=2*dp[i][3];
        }
        dp[i+1][0]%=mod;
        dp[i+1][1]%=mod;
        dp[i+1][2]%=mod;
        dp[i+1][3]%=mod;
    }
    cout<<dp[str.length()][0];
} 


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

int main() {
    int dec[10][10] = {}, len[10][10] = {};
    for (int a = 1; a < 10; a++)
        for (int b = 0; b < 10; b++) {
            int x = a, y = b;
            do {
                x += y;
                if (x < 10) { y = b; dec[a][b]++; }
                else { y = x % 10; x /= 10; }
                len[a][b]++;
            } while (x != a || y != b);
        }
    int m; cin >> m;
    long long ans = 0;
    int l = 0;
    while (m--) {
        long long d, c; cin >> d >> c;
        if (l == 0) { l = d; c--; }
        if (d == 0) { ans += c; continue; }
        if (c >= dec[l][d]+1) {
            ans += (c-1) / dec[l][d] * len[l][d];
            c = (c-1) %dec[l][d] + 1;
        }
        while (c--) {
            l += d;
            ans++;
            if (l >= 10) { l = l % 10 + l / 10; ans++; }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(aa,bb,cc) for(int aa=(bb);aa<=(int)(cc);++aa)
using namespace std;
const int maxn=52;
char s[maxn];

template<class T>void read(T &x){
	x=0;char c=getchar();bool symbol=0;
	while(!isdigit(c)) symbol|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x=symbol?-x:x;
}

int main(){
	scanf("%s",s+1);
	For(i,1,strlen(s+1)-8) printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 256
program abc132b
  implicit none
  integer :: n ! 3<=n<=20
  integer :: i, count, a, b, c
  integer, allocatable :: p(:)

  read(*,*) n
  allocate( p(n) )
  read(*,*) p(:)

  count=0
  do i = 2, n-1
    a = p(i-1)
    b = p(i)
    c = p(i+1)

    if (a==b .and. b==c) then
      cycle
    else if ( a<b .and. b<=c) then
      count = count + 1
    else if ( c<b .and. b<=a) then
      count = count + 1
    else
      cycle
    endif
  enddo

  print *, count


  deallocate(p)
end program abc132b


Measured memory_bytes: 256