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

using namespace std;

int digitSum(int x) {
	int sum = 0;
	while(x > 0) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}

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

	int n;
	cin >> n;

	int ans = 999999;

	for(int i = 1; i < n; i++)
		ans = min(ans, digitSum(i) + digitSum(n-i));
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int m;
	int q;
	int x;
	int i,j;
	int cnt;
	set<int>s;
	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>m;
		s.insert(m);
	}
	cin>>q;
	cnt=0;
	for(i=0;i<q;i++){
		cin>>x;
		auto it=s.find(x);
		if(it!=s.end())	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3120
BIG_NUM = 2000000000


N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()


Measured memory_bytes: 5876
import java.util.*;
class Main{
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] argv){
		c();
	}
  	static void c(){
		int n = scan.nextInt();
		Map<Integer, Integer> mapEven = new HashMap<>();
		Map<Integer, Integer> mapOdd = new HashMap<>();
		for(int i=0;i<n;i++){
			int temp = scan.nextInt();
			if(i%2==0){
				mapEven.put(temp,mapEven.getOrDefault(temp, 0)+1);
			}
			else{
				mapOdd.put(temp,mapOdd.getOrDefault(temp, 0)+1);
			}
		}
		List<Map.Entry<Integer, Integer>> o = new ArrayList<>(mapOdd.entrySet());
    	List<Map.Entry<Integer, Integer>> e = new ArrayList<>(mapEven.entrySet());
    	o.sort((o1, o2) -> o2.getValue() - o1.getValue());
    	e.sort((o1, o2) -> o2.getValue() - o1.getValue());
		int o1 = o.get(0).getValue();
    	int o2 = o.size() == 1 ? 0 : o.get(1).getValue();
    	int e1 = e.get(0).getValue();
    	int e2 = e.size() == 1 ? 0 : e.get(1).getValue();
		if (!o.get(0).getKey().equals(e.get(0).getKey())) {
      		System.out.println(n - o1 - e1);
    	}
		else {
      		System.out.println(n - Math.max(o1 + e2, o2 + e1));
    	}
	}
}

Measured memory_bytes: 63288
#include <cstdio>
#include <cstring>
#include <algorithm>
#define INF (1145141919)
using namespace std;

int n;

int from[6000];
int to[6000];
int cost[6000][2];

int d[100];
int r;
void Search(int s)
{
	for (int i = 0; i < 100; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	while (true){
		bool update = false;
		
		for (int i = 0; i < n * 2; i++){
			if (d[from[i]] != INF && d[to[i]] > d[from[i]] + cost[i][r]){
				d[to[i]] = d[from[i]] + cost[i][r];
				update = true;
			}
		}
		
		if (!update){
			break;
		}
	}
}
	

int main()
{	
	int m;
	while (scanf("%d %d", &n, &m), n + m){
		for (int i = 0; i < n; i++){
			int a, b, c, t;
			scanf("%d %d %d %d", &a, &b, &c, &t);
			a--;
			b--;
			
			
			from[i * 2] = a;
			to[i * 2] = b;
			cost[i * 2][0] = c;
			cost[i * 2][1] = t;
			
			from[i * 2 + 1] = b;
			to[i * 2 + 1] = a;
			cost[i * 2 + 1][0] = c;
			cost[i * 2 + 1][1] = t;
		}
		
		int k;
		scanf("%d", &k);
		
		for (int i = 0; i < k; i++){
			int p, q;
			scanf("%d %d %d", &p, &q, &r);
			p--;
			q--;
			
			Search(p);
			printf("%d\n", d[q]);
		}
	}
	
	return 0;
}

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

int main() {
	string s1,s2;
	int count = 0;
	cin >> s1 >> s2;
	for(int i=0;i<3;i++){
		if(s1[i]==s2[i]) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int rgb = 100*r + 10*g+ b;
		if(rgb % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (k >= (int)s.size()) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
    
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

int N,C,D[33][33],c[555][555];
int ans;
int mc[30][4];
int i,j,k;
int main(){
    scanf("%d%d",&N,&C);
    fornum(i,0,C){
        fornum(j,0,C){
            scanf("%d", &D[i][j]);
        }
    }
    fornum(i,0,N){
        fornum(j,0,N){
            scanf("%d", &c[i][j]);
        }
    }

    fornum(i,0,C){
        fornum(j,0,N){
            fornum(k,0,N){
                mc[i][(j + k) % 3] += D[c[j][k]-1][i];
            }
        }
    }
    ans = INT_MAX;
    fornum(i,0,C){
        fornum(j,0,C){
            if(i==j)
                continue;
            fornum(k,0,C){
                if(i==k||j==k)
                    continue;
                int sum = mc[i][0] + mc[j][1] + mc[k][2];
                ans = sum < ans ? sum : ans;
            }   
        }
    }
    
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1280
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

class UnionFindTree
    attr_accessor:par,:rank
    def initialize(n)
        @par=Array.new(n){|i| i}
        @rank=array(n,0)
    end

    def find(x)
        return x if @par[x]==x
        @par[x]=find(@par[x])
        return @par[x]
    end

    def union(x,y)
      x=find(x)
      y=find(y)
      return if x==y
      if @rank[x]<@rank[y]
          @par[x]=y
      else
          @par[y]=x
          @rank[x]+=1 if @rank[x]==@rank[y]
      end  
    end

    def same?(x,y)
        return find(x)==find(y)
    end
end

uft=UnionFindTree.new(12)
uft.union(0,2)
uft.union(2,4)
uft.union(4,6)
uft.union(6,7)
uft.union(7,9)
uft.union(9,11)
uft.union(3,5)
uft.union(5,8)
uft.union(8,10)
x,y=get_i
x-=1
y-=1
if uft.same?(x,y)
    puts "Yes"
else
    puts "No"
end

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

using namespace std;

int main(){
    string input;
    cin >> input;
    string right = "CODEFESTIVAL2016";

    int ans = 0;
    for(int i = 0;i < 16;i++){
      if(input[i] != right[i]){
        ans++;
      }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
d1,d2,d3 = map(int, input().split('/'))


if d1< 2019 :
  print("Heisei")
elif d1 == 2019 :
  if d2 <= 4:
    print('Heisei')
  else :
    print('TBD')
else :
  print('TBD')

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int maxn=100000;
int n;
int lose[maxn+5];
vector<int> win[maxn+5];

int dfs(int x) {
    if (win[x].empty()) return 0;
    vector<int> vec;
    for (int y:win[x]) {
        vec.pb(dfs(y));
    }
    sort(vec.begin(),vec.end());
    int dep=0;
    for (int i=0;i<vec.size();i++) {
        dep=max(dep,vec[i])+1;
    }
    return dep;
}

int main() {
    scanf("%d",&n);
    for (int i=2;i<=n;i++) {
        scanf("%d",lose+i);
        win[lose[i]].pb(i);
    }
    int res=dfs(1);
    printf("%d\n",res);
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    cout << (ll)pow(floor(sqrt(n)), 2) << endl;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- inpi toInt
  mapM_ print $ solve xs

solve :: [Int] -> [Int]
solve = map npn

npn :: Int -> Int
npn n = length . takeWhile (<= n) $ pns

pns :: [Int]
pns = [2,3] ++ f [] (tail pns) 5
  where
    f rs (x:xs) n = ps ++ f (rs ++ [x]) xs (x ^ 2 + 2)
      where
        g y = all ((/= 0) . (mod y)) rs
        ps = filter g [n, n+2 .. x ^ 2 - 2]

toInt :: String -> Int
toInt s = read s

inpi :: (String -> a) -> IO [a]
inpi f = map f . lines <$> getContents

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

#define NMAX 50000

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int N, K;
char str[100];

int main()
{
    cin >> N >> K;
    cin.get();
    cin.getline(str, N + 1);
    str[K - 1] += 32;
    cout << str << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){  
	int N;
	cin >> N;
	int T[N];
	int M;
	int allT;
	for(int i = 0; i < N; i++){
		cin >> T[i];
		allT += T[i];
	}
	cin >> M;
	for(int i = 0; i < M; i++){
		int P;
		int X;
		cin >> P >> X;
		cout << allT - T[P - 1] + X - 4197030 << endl;
	}	
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

    int H, W;
    cin>>H>>W;
    vector<string> s(H);
    
    rep(i,H) cin >> s[i];
    
    rep(h,H){
        rep(w,W){
            if(s[h][w]=='#'){
                cout << '#';
                continue;
            }
            int cnt=0;
            for(int i=-1;i<=1;i++)for(int j=-1; j<=1; j++){
                if(i==0&&j==0) continue;
                if(h==0 && i==-1) continue;
                if(h==H-1 && i==1) continue;
                if(w==0 && j==-1) continue;
                if(w==W-1 && j==1) continue;
                if(s[h+i][w+j]=='#') cnt++;
            }
            cout << cnt;
        }
        cout << endl;
    }
    
    return 0;
}


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

x=N

import math
xr=math.ceil(math.sqrt(x))

LIST=[]
for i in range(1,xr+1):
    if x%i==0:
        LIST.append(i)
        LIST.append(x//i)

ANS=1<<60

for l in LIST:
    ANS=min(ANS,l-1+N//l-1)

print(ANS)


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	set<int> pro;
	for( int a = 1; a <= 9; ++a ){
		for( int b = 1; b <= 9; ++b ){
			pro.insert(a*b);
		}
	}
	int n; cin >> n;
	if( pro.count(n) ) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d+2):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    
  return False

def reachable2(b, d):
  for k in range(b-1,d):
    if S[k] == S[k+1] == S[k+2] == ".":
      return True
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable2(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

constexpr ll MOD = 1e9+7;

namespace math { namespace integer {

template<class value_type> value_type mod_mul(value_type x, value_type k, ll m) { if(k == 0) { return 0; } if(k % 2 == 0) { return mod_mul((x+x) % m, k/2, m); } else { return (x + mod_mul(x, k-1, m)) % m; } }
template<class value_type> value_type mod_pow(value_type x, value_type n, ll mod) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(mod_mul(x, x, mod) % mod, n / 2, mod); } else { return mod_mul(x, mod_pow(x, n - 1, mod), mod); } }
template<class value_type> value_type extgcd(value_type a, value_type b, value_type& x, value_type& y) { value_type d = a; if(b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; }
template<class value_type> value_type mod_inverse(value_type x, ll mod) { return mod_pow(x, value_type(mod-2), mod); /* use fermat */ }
template<class value_type> value_type mod_inverse_composite_num_mod(value_type a, ll mod) { value_type x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; }

}}
using namespace math::integer;


int main() {

  ll N; ll D; ll X;
  while(cin >> N >> D >> X && (N|D|X)) {
    static ll dp[2022][2022]; zero(dp);
    dp[0][0] = 1;
    ll comb_huge = 1;
    ll ans = 0;
    rep(i, min(N, D)) {
      comb_huge *= (D - i) % MOD;
      comb_huge %= MOD;
      comb_huge *= mod_inverse((ll)i+1, MOD);
      comb_huge %= MOD;

      ll sum[2022] = {};
      rep(j, N+1) {
        sum[j] = (j ? sum[j-1] : 0) + dp[i][j];
        sum[j] %= MOD;
      }

      rep(j, N+1) {
        if(j) dp[i+1][j] += sum[j-1];
        dp[i+1][j] %= MOD;
        dp[i+1][j] -= j - X>= 0 ? sum[j-X] : 0;
        dp[i+1][j] += MOD;
        dp[i+1][j] %= MOD;
        /*
        rep( k , X ){
          if(k==0)continue;
          if(j - k >= 0){
            dp[i+1][j] += dp[i][j-k];
            dp[i+1][j] %= MOD;
          }
        }
        */
      }
      ans += comb_huge * dp[i+1][N];
      ans %= MOD;
    }

    cout << ans << endl;

  }
  
  return 0;
}

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    string s;
    cin>>s;

    if(s[s.length()-1] == 's') s += "e";

    s += "s";
    cout<<s;
}

Measured memory_bytes: 3616
from collections import Counter

N = int(input())
L = list(map(int, input().split()))
A = Counter(L)
C = {0:0}

for i in range(1, max(A.values())+1):
    C[i] = C[i-1]+(i-1)
ans = 0
for a in A.keys():
    key = A[a]
    ans += C[key]

for l in L:
    key = A[l]-1
    tmp = ans - C[A[l]]
    print(tmp+C[key])

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


modint dp[200005];
int memo[200005];

void solve() {
    int N; cin >> N;
    vec c(N);
    rep(i, N) cin >> c[i];
    c.push_back(-1);
    dp[0] = 1;
    rep(i, N){
        if(c[i] != c[i+1]){
            if(memo[c[i]] == 0){
                dp[i+1] = dp[i];
                memo[c[i]] = i+1;
            }else{
                dp[i+1] = dp[i] + dp[memo[c[i]]];
                memo[c[i]] = i+1;
            }
        }else{
            dp[i+1] = dp[i];
        }
    }
    cout << dp[N] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 10596
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	int W,a,b;
	cin>>W>>a>>b;
	if(a > b) swap(a, b);
	int ax = a + W;
	int ans = b - ax;
	if(ans <= 0) ans = 0;
	
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

vector<unsigned int> table { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };

void solve(int from, int to)
{
	unsigned int b0	= 0;
	if( from != -1 ) {
		b0 = table[from];
	} 
	unsigned int b1 = table[to];
	cout << static_cast<bitset<7>>( b0 ^ b1 ) << endl;
}

int main(int argc, char* argv[])
{
	int num, d;
	vector<int> ds;

	while(1) {
		cin >> num;
		if( num == -1 )
			break;

		for( int i = 0; i < num; i++ ) {
			cin >> d;
			ds.push_back(d);
		}
		int v0 = -1;
		for( auto  v1 : ds ) {
			solve(v0, v1);
			v0 = v1;
		}
		ds.clear();		
	}

    return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

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

int main(void){  
  long long a,b,n;
  while(cin>>a>>b>>n){
    /*
    long long s=0;
    bool second = false;
    int f[100]; //(int)((double)a*10/b)%10
    for(int i=0; i<n; i++){
      double c = (double)a / b * pow(10,(double)i+1) ;
      f[i] = (int)c%10;
      //if((int)c%10==0) break;
      for(int k=0; k<i; k++){
        if(f[i]==f[k]){
          second = true;
          for(int j=i; j<n; j++){
            s+=f[(j-k)%(i-k)+k];
          }
        break;
        }
      }
      if(second) break;
      s += (int)c%10;
    }
    */
    long long s = 0;
    long long amari;
    long long f[10000] = {0};
    amari = a%b * 10;
    bool second = false;
    for(int i=0; i<n; i++){
      s+=amari/b;
      amari = amari%b*10;
      /*
      for(int j=0; j<=i; j++){
        if(amari[i+1]==amari[j]){
          for(int k=i+1; k<n; k++){
            s+=(f[(k-j)%(i+1-j)+k]);
          }
          second = true;
          break;
        }
      }
      if(second) break;
      */
    }
    cout << s << endl;
  }
  return 0;

}

Measured memory_bytes: 0
def main():
    n = int(input())
    if n % 2 == 0:
        bb = [1, 1]
    else:
        bb = [0]
    while len(bb) < n:
        b = bb[-1] + 2
        bb += [b, b]
    aa = sorted(map(int, input().split()))
    if aa != bb:
        print(0)
    else:
        print(2 ** (n // 2) % 1000000007)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16344
import java.util.Scanner;

public class Main {

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

        int min = 1000000000;


        for(int i = 0; i < n; i++) {
            r[i] = sc.nextInt();
        }

        int maxProfit = r[1] - r[0];

        for(int i = 0; i < n - 1; i++) {
            if(r[i] < min) {
                min = r[i];
                for(int j = i + 1; j < n; j++) {
                    int dif = r[j] - r[i];
                    if(dif > maxProfit) maxProfit = dif;
                }
            }
        }

        System.out.println(maxProfit);
    }

}


Measured memory_bytes: 100304
import java.io.*;
public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s;
        try{
            while((s=br.readLine())!=null){
                String[] str=s.split(" ");
                int n=Integer.parseInt(str[0])+Integer.parseInt(str[1]);
                System.out.println(Integer.toString(n).length());
            }
            br.close();
        }catch(Exception e){
        }
    }
}

Measured memory_bytes: 24048
n = int(input())
def divminus2(n):
    if n%2 == 1:
        q = n // -2 + 1
        r = abs(n % 2)
    else:
        q = n // -2
        r = 0
    return q,r

ans_list = []
while n != 0:
    q,r = divminus2(n)
    n = q
    ans_list.append(str(r))

ans_list.reverse()
if ans_list == []:
    print("0")
else:
    print("".join(ans_list))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		int n = s.size();
		for(int i =0 ;i<n;i++){
			int j = i+1;
			if(j&1){
				if(s[i]=='L')return cout<<"No",0;
			}
			else {
				if(s[i]=='R')return cout<<"No",0;
			}
		}
		cout <<"Yes\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    vc<ll> v(101);
    v[0]=0;
    rep(a,1,101)
        v[a]=v[a-1]+a;
    ll ans=0;
    for(ll a=2;a*a<=n;a++)
    {
        if(n%a==0)
        {
            ll cnt=0;
            while(n%a==0)
            {
                cnt++;
                n/=a;
            }
            ll p=lb(all(v),cnt)-v.begin();
            ans+=p;
            if(v[p]>cnt)
                ans--;
        }
    }
    if(n>1)
        ans++;
    cout<<ans<<endl;
	printclock;
	return 0;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;

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

int power(int a,int n)
{
    a %= mod;
    if(n == 1) return a;
    if(n == 0) return 1;
    if(n%2) return (a*(power((a*a)%mod,n/2)%mod))%mod;           //n is odd
    return power((a*a)%mod,n/2)%mod;                             //n is even
}

const int inf = (int) 1e18;

int inverse(int x)
{
    return power(x,mod-2)%mod;     //Fermat's little theorem
}*/

int main()
{
    SAM;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    ll temp1=a*c,temp2=a*d,temp3=b*c,temp4=b*d;
    
    ll m1=max(temp1,temp2),m2=max(temp3,temp4);
    
    ll m=max(m1,m2);
    
    cout<<m;
    
    
    
    return 0;
}




Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

const double PI = acos(-1.0);

int main() {
	while (1) {
		int h, w;
		cin >> h >> w;

		if (h == 0 && w == 0) {
			return 0;
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}



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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    string s;
    cin >> s;

    cout << (s == "ABC" ? "ARC" : "ABC") << newl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main(){
  int A, B, C, D, P;
  cin >> A >> B >> C >> D >> P;
  int X = A * P;
  int Y = B + D * max(0, P - C);

  cout << min(X, Y) << endl;
}


Measured memory_bytes: 3096
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var h, w int
	fmt.Fscanf(in, "%d%d", &h, &w)

	a := make([]string, h)

	for i := 0; i < h; i++ {
		fmt.Fscan(in, &a[i])
	}

	for j := 0; j < w; j++ {
		chk := true
		for i := 0; i < h; i++ {
			if a[i][j] == '#' {
				chk = false
				break
			}
		}
		if chk {
			for i := 0; i < h; i++ {
				a[i] = a[i][:j] + "x" + a[i][j+1:]
			}
		}
	}

	for i := 0; i < h; i++ {
		if strings.Index(a[i], "#") >= 0 {
			fmt.Fprintln(out, strings.Replace(a[i], "x", "", -1))
		}
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;

 int f(vector <int>& h, int k){
    int n = h.size();
    vector <int> dp(n);

    dp[1] = abs(h[1]-h[0]);

    for(int i=2 ; i<n ; i++){
       dp[i] = INT_MAX;
       for(int j=i-1 ; j>=0 && j>=i-k ; j--){
           dp[i] = min(dp[i], abs(h[i]-h[j]) + dp[j]);
       }
    }
        return dp[n-1];
 }

 int32_t main() {
   int n,k; cin>>n>>k; 
   vector <int> h(n);
   for(int i=0 ; i<n ; i++) cin>>h[i];
   cout<<f(h,k);
}

Measured memory_bytes: 1792
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	public int x;
	public int y;

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	
	 int n=sc.nextInt();
	 Deque<Long> l=new ArrayDeque<Long>();
	 
	 if(n%2==0) {
		 for(int i=0;i<n;i++) {
			 long temp=sc.nextLong();
			 if(i==0||i%2!=0) {
				 l.addFirst(temp);
			 }else {
				 l.addLast(temp);
			 }
		 }
	 }else {
		 for(int i=0;i<n;i++) {
			 long temp=sc.nextLong();
			 if(i==0||i%2!=0) {
				 l.addLast(temp);
			 }else {
				 l.addFirst(temp);
			 }
		 }
	 }
	 
	 for(int i=0;i<n;i++) {
		 System.out.println(l.poll());
	 }
	 
			 
	 
	 
	
	 

	 
	
	 
    
}
}


Measured memory_bytes: 97096
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;
string s;

int main(){
    //cin >> ;
    //cout << ans << endl;

    cin >> s;

    if(s.at(1) == 'R'){
        cout << "ABC";
    }
    else{
        cout << "ARC";
    }
    //cout << ;
    cout << endl;
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    vector<ll> L;
    cin >> N;
    for (int i = 0; i < N; i++) {
        ll l; cin >> l;
        L.pb(l);
    }
    asort(L);
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            for (int k = j+1; k < N; k++) {
                if(L[i] != L[j] && L[i] != L[k] && L[j] != L[k] && L[k] < L[i] + L[j]){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
#N, Mを受け取る
N, M = gets.split.map(&:to_i)

#Ai, Biを受け取る
as = Array.new(M).map! do |v|
  v = gets.split.map(&:to_i)
end

#nodeをクラス化
#parent -> 親ノードの番号
#size -> 自分が根なら集合のサイズ, 子なら0
class Node
  attr_accessor :parent, :size
  def initialize(n)
    @parent = n
    @size = 1
  end
end

#ここからUnion-find#
class Union_find
  #コンストラクタ
  def initialize(n)
    @node = Array.new(n).map!.with_index do |v, i|
      v = Node.new(i)
    end
  end
  
  #x番目の島の根を返す
  def find(x)
    return x if @node[x].parent == x
    
    #一度見たノードは根に繋ぐ, 経路圧縮
    @node[x].parent = find(@node[x].parent)
  end
  
  #ノードxとノードyが同じ集合に属するか？
  def is_same?(x, y)
    return find(x)==find(y)
  end
  
  #ノードxとノードyを併合
  #併合による不便さの変化deltaを返す
  def unite(x,y)
    delta = 0
	x = find(x)
    y = find(y)
    
    if !is_same?(x,y) then
      #deltaを更新
  	  delta = @node[x].size * @node[y].size
      
      #xの方が大きければswap(x, y), 経路平坦化
      x,y = y,x if @node[x].size > @node[y].size
      
      #yが新しい親になる
      @node[x].parent = y
      @node[y].size += @node[x].size
      @node[x].size = 0
    end
    return delta
  end
end

#エントリーポイント#
#入力の後ろから繋ぎたいので、入力を逆順にする
as = as.reverse

#Union_findをnew
uni = Union_find.new(N)

#ansを初期化
ans = Array.new(M,0)
ans[M-1] = N*(N-1)/2

#一つずつ繋ぎつつ答えをansに格納
(M-1).times do |i|
  #つないで答えをもらってくる
  ans[M-2-i] = ans[M-1-i] - uni.unite(as[i][0]-1,as[i][1]-1)
end
 
puts ans

Measured memory_bytes: 18812
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    const double eps=1e-12;
    long double tmp0=(long double)n/1.08;
    long double tmp1=(long double)(n+1)/1.08;
    int a=(int)(tmp0-eps)+1;
    if(a<tmp1) {
        printf("%d\n", a);
    }
    else {
        printf(":(\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

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

    int N,D;
    cin >> N >> D;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int x1,x2;
        cin >> x1 >> x2;
        double distance = sqrt(pow(x1,2)+pow(x2,2));
        if(distance <= D) cnt++;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	double n, d;
	cin >> n >> d;
	if (n / (2 * d + 1) - (ll)(n / (2 * d + 1)) > 0) {
		cout << (ll)(n / (2 * d + 1) + 1) << endl;
	}
	else {
		cout << (ll)(n / (2 * d + 1)) << endl;
	}
}

Measured memory_bytes: 256
s = input()

for i in range(2**3):
    op = ["+"]*3
    op.append("")
    fomula = ""
    for j in range(3):
        if(i >> j & 1):
            op[j] = "-"
    for k in range(4):
        fomula += s[k] + op[k]
    if eval(fomula) == 7:
        print(fomula + "=7")
        break


Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int M = 1e9 + 7;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  set<int> s;
  while (k--)
  {
    int d;
    cin >> d;
    while (d--)
    {
      int x;
      cin >> x;
      s.insert(x);
    }
  }
  cout << n - s.size();

}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N;

	cin >> N;

	long long A[N];

	for(long long i = 0; i < N; i++){
		cin >> A[i];
	}

	sort(A, A+N);

	vector<long long>c;

	for(long long i = 0; i<2;i++){
		long long am = sqrt(A[i]);
		c.push_back(A[i]);

		for(long long j =2 ;j<=am;j++){
			if(A[i] % j == 0){
				c.push_back(j);
				c.push_back(A[i]/j);
			}
		}
	}

	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());

	long long tmp = 0;
	for(long long i = c.size() -1 ; i > 0;i--){
		if(tmp == c[i]) c.erase(c.begin()+i);
		else tmp = c[i];
	}

	long long ans = 1;
	for(long long i = 0; i < c.size(); i++){
		long long out = 0;
		for(long long j=0; j < N; j++){
			if(A[j] % c[i] != 0) {
				out++;
				if(out >= 2) break;
			}
		}
		if(out <= 1){
			ans = c[i];
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;
ll qpow(ll a,ll b,ll m)
{
    ll ans=1;
    ll base = a;
    while(b>0)
    {
        if(b&1==1)
            ans = (ans * base) % m;
        base = (base * base) % m;
        b >>= 1;
    }
    return ans;
}
ll C(ll n,ll m)
{
    ll ans = 1;
    for (ll i = 1;i<=m; i++)
    {
        ll tmp;
        tmp = (n - i + 1) % mod;
        ans *= (tmp * qpow(i, mod - 2, mod)) % mod;
        ans %= mod;
    }
    return ans;
}

int main()
{
    fast_io();
    
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans;
    ans = qpow(2, n, mod) - 1;
    ans=(ans+mod-C(n, a))%mod;
    ans=(ans+mod-C(n, b))%mod;
    cout << ans;
    //system("pause");
    return 0;
}

Measured memory_bytes: 384
def int_ceil(x):
  last=int(str(x)[-1])
  return([x+10-last,last])

dishes =[0]*5
min=10
for i in range(5):
  x=(int(input()))
  if x % 10 != 0:
    ceiled=int_ceil(x)
    if ceiled[1] < min:
      min=ceiled[1]
    dishes[i]=ceiled[0]
  else:
    dishes[i]=x
print(sum(dishes) - 10 + min)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int n;
	cin >> n;
	int daigakudata[5][4][11] = {};
	int b, f, r, v;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		daigakudata[b][f][r] += v;
	}
	for (int i = 1; i < 5; i++) {
		for (int j = 1; j < 4; j++) {
			for (int o = 1; o < 11; o++) {
				cout << " " << daigakudata[i][j][o];
			}
			cout << endl;
		}
		if (i != 4) {
			cout << "####################" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 double w,h,x,y;
  cin>>w>>h>>x>>y;
  int m=0;
  if (x==w/2 && y==h/2){
    m=1;}
  
  cout<<w*h/2<<' '<<m<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll x;
    cin>>x;

    ll t = x % 11;
    ll ans = (x / 11) * 2 + t / 6;
    if(t % 6 != 0){
        ans += 1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256