akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,taro_point=0,hanako_point=0;
    string taro,hanako;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> taro >> hanako;
        if(taro>hanako) taro_point+=3;
        if(taro==hanako){
            taro_point+=1;
            hanako_point+=1;
        }
        if(taro<hanako) hanako_point+=3;
    }
    cout<<taro_point<<" "<<hanako_point<<endl;
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	cin >> s;
	int l = 0, r = s.size() - 1, co = 0;
	for (;;) {
		if (l == r || r == l - 1) {
			break;
		}
		if (s[l] == s[r]) {
			l++;
			r--;
			continue;
		}
		else if (s[l] == 'x') {
			co++;
			l++;
			continue;
		}
		else if (s[r] == 'x') {
			co++;
			r--;
			continue;
		}
		else {
			cout << "-1" << endl;
			return 0;
		}
		cout << l << " " << r << endl;
	}
	cout << co << endl;
}


Measured memory_bytes: 512
/* knapsack Problem */
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define W_MAX 10000 +10
int main()
{
  //input
  ios::sync_with_stdio(false);
  int N,W; cin >> N >> W;
  vector<int> value(N+1),weight(N+1);
  for(int i=1;i<=N;i++){
    cin >> value[i] >> weight[i];
  }
  //solve
  int DP[W_MAX]={};
  for(int n=1;n<=N;n++){
    for(int w=W;w-weight[n]>=0;w--){
      DP[w]=max(DP[w],DP[w-weight[n]]+value[n]);
    }
  }
  cout<<DP[W]<<endl;
  
  return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    if(k > (n-1)*(n-2)/2){
        cout << "-1\n";
        return 0;
    }
    cout << n-1+(n-1)*(n-2)/2-k << "\n";
    for(int i = 2; i <= n; ++i){
        cout << "1 " << i << "\n";
    }
    int cnt = 0;
    while(cnt < (n-1)*(n-2)/2 - k){
        for(int i = 2; i < n; ++i){
            for(int j = i+1; j <= n; ++j){
                cout << i << " " << j << "\n";
                ++cnt;
                if(cnt >=  (n-1)*(n-2)/2 - k) goto END;
            }
        }
    }
    END:;
    return 0;
}

Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int S, W;
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe";
        return;
    }
    cout << "safe";
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
long long ps(long long a, long long b){
  if (b>a) swap(a,b);
  return a*(a+1)/2+b*(b-1)/2;
}
int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<pair<long long,long long>> tb;
  if (S[0] == '<') tb.push_back(make_pair(1,0));
  if (S[0] == '>') tb.push_back(make_pair(0,1));
  for (int i = 0; i < N - 1; i++){
    if (S[i+1] == '>') tb[tb.size()-1].second++;
    if (S[i] == '<' && S[i+1] == '<') tb[tb.size()-1].first++;
    if (S[i] == '>' && S[i+1] == '<') tb.push_back(make_pair(1,0));
  }
  long long sum = 0;;
  for (int i = 0; i < tb.size(); i++){
    sum += ps(tb[i].first,tb[i].second);
  }
  cout << sum;
}

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

int main() {
  int n; cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];
  double b = 0.0;
  rep(i, n) b += 1.0/a[i];
  printf("%.10f\n", 1.0/b);
  return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int) -> V.Vector (U.Vector Int)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) b c
    UM.unsafeWrite (arr `V.unsafeIndex` b) a c
  forM_ [0..n-1] $ \a -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr `V.unsafeIndex` k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr `V.unsafeIndex` i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.unsafeRead a_i k
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  forM_ [0..n-1] $ \a -> do
    let !a_a = arr `V.unsafeIndex` a
    forM_ [0..n-1] $ \b -> do
      let v = graph `V.unsafeIndex` a `U.unsafeIndex` b
      when (v <= fromIntegral l) $ do
        UM.unsafeWrite a_a b 1
    UM.unsafeWrite a_a a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr `V.unsafeIndex` k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr `V.unsafeIndex` i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.unsafeRead a_i k
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,c)
  let !w1 = warshallFloyd1 n edges
      !w2 = warshallFloyd2 n l w1
  q <- readLn
  replicateM_ q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let d = w2 `V.unsafeIndex` (s-1) `U.unsafeIndex` (t-1)
    print $ if d > 10^9 then -1 else d - 1


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    string S;
    cin >> S;

    int N = S.length();
    vector<int> a(N + 1);
    for (int i = 0; i < N; ++i) {
        while (S[i] == '<' && i < N) {
            a[i + 1] = a[i] + 1;
            ++i;
        }
    }

    for (int i = N - 1; i >= 0; --i) {
        while (S[i] == '>' && i >= 0) {
            a[i] = max(a[i + 1] + 1, a[i]);
            --i;
        }
    }

    ll sum = 0;
    for (auto i : a)
        sum += i;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2844
#include <stdio.h>
int main( void )
{
	 int d;
	 
	 scanf("%d", &d);
	 if( d == 25 ) {
		 printf("Christmas\n");
	 } else if( d == 24 ) {
		 printf("Christmas Eve\n");
	 } else if( d == 23 ) {
		 printf("Christmas Eve Eve\n");
	 } else {
		 printf("Christmas Eve Eve Eve\n");
	 }

	 return 0;
}

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

typedef long long ll;


int main() {

    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    string s;
    cin >> s;

    int is_diff = 0;

    for(int i = 0; i < 2; i++) {
        if(s[i] != s[i + 1]) is_diff = 1;
    }

    if(is_diff) cout << "Yes\n";
    else cout << "No\n"; 


    
}


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

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

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010


ll N, Q;
string S;
vector<char> T;
vector<char> D;

// 左から消滅できるなら true
static inline bool check_l(ll ind) {
    ll cur = ind;   // 現在地
    REP(i, Q) {
        if(T[i] == S[ind]) {
            if(D[i] == 'L') {
                ind--;
                if(ind < 0) { return true; }
            }
            else {
                ind++;
            }
        }
    }
    return false;
}
// 右から消滅できるなら true
static inline bool check_r(ll ind) {
    ll cur = ind;   // 現在地
    REP(i, Q) {
        if(T[i] == S[ind]) {
            if(D[i] == 'L') {
                ind--;
            }
            else {
                ind++;
                if(ind >= N) { return true; }
            }
        }
    }
    return false;
}

ll solve() {
    // 左側に消える最大のインデックス
    ll del_l = -1;
    ll lb = 0, rb = N-1;
    while(rb - lb > 1) {
        ll mid = (lb + rb) / 2;
        if(check_l(mid)) { lb = mid; }
        else { rb = mid; }
    }
    if(check_l(rb)) { del_l = rb; }
    else if(check_l(lb)) { del_l = lb; }

    // 右側に消える最大のインデックス
    ll del_r = -1;
    lb = 0;
    rb = N - 1;
    while(rb - lb > 1) {
        ll mid = (lb + rb) / 2;
        bool ret = check_r(mid);
        if(ret) { rb = mid; }
        else { lb = mid; }
    }
    if(check_r(lb)) { del_r = lb; }
    else if(check_r(rb)) { del_r = rb; }

    if(del_l == -1) {
        if(del_r == -1) { return N; }
        return del_r;
    }
    if(del_r == -1) {
        return N - (del_l + 1);
    }
    if(del_l >= del_r) { return 0; }
    return N - (del_l + 1) - (N - del_r);
}

signed main()
{
    cin >> N >> Q >> S;
    T.resize(Q);
    D.resize(Q);
    REP(i, Q) { cin >> T[i] >> D[i]; }

    ll ans = solve();
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 900
#include <iostream>

using namespace std;

int k;
int x;

int main() {
    cin >> k >> x;
    int a[2 * k - 1];

    for (int i = 0; i < (2 * k - 1); ++i) {
        a[i] = x - k + 1 + i;
    }

    for (int j = 0; j < (2 * k - 1); ++j) {
        cout << a[j] << " ";
    }
    cout << endl;
}


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

void f(int l, int r, string t){
    int m=(l+r)/2;
    string s;
    cout<<m<<endl;
    cin>>s;
    if(s=="Vacant")return;
    int a=(m-l)%2,b=0;
    if(s!=t)b=1;
    if(a+b==1){
        f(l, m, t);
    }else{
        f(m, r, s);
    }
}

int main(void){
    int n;
    string s;
    cin>>n;
    cout<<0<<endl;
    cin>>s;
    if(s=="Vacant")return 0;
    f(0, n, s);
    return 0;
}


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

int main(){
  	int N, Add;
	Add = 0;
  	cin >> N;
	
  	for(int i = N; i > 0; i /= 10){
      	Add += i % 10;
    }
	
  	//結果出力
  	if( N % Add == 0)
      	cout << "Yes" << endl;
  	else
      	cout << "No"  << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int[] NK = IntLine();
        int N = NK[0], K = NK[1];

        int[] a = IntLine();
        bool[] dp = new bool[K + 10];
        for (int i = 1; i <= K; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (i < a[j]) continue;
                //勝利手しか存在しなければそのi個の山では必敗
                if (!dp[i - a[j]]) dp[i] = true;
            }
        }
        //for (int i = 0; i <= K; i++)
        //{
        //    Console.WriteLine(i + " : " + dp[i]);
        //}
        Console.WriteLine(dp[K] ? "First" : "Second");
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(c).Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 13288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

    ll x;
    cin >> x;
    ll ans = 0;
    ans = x/500*1000;
    x = x%500;
    ans += x/5*5;

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 1e5+9;
const double pi=3.14159265358979323846264;
const int inf = 1e9;
const ll mod = 1e9+7;
int op[20],pq[20][20];
int main()
{
    ios::sync_with_stdio(false);
    int n,m,x;
    cin>>n>>m>>x;
    for(int i=0;i<n;++i){
        cin>>op[i];
        for(int j=0;j<m;++j){
            cin>>pq[i][j];
        }
    }
    int jk=-1;
    for(int i=0;i<(1<<n);++i){
        int tmp[20],ans=0;
        mst(tmp,0);
        for(int j=0;j<n;++j){
            if(i>>j&1){
                for(int k=0;k<m;++k) tmp[k]+=pq[j][k];
                ans+=op[j];
            }
        }
        int fg=1;
        for(int j=0;j<m;++j){
            if(tmp[j]<x) {
                fg=0;
                break;
            }
        }
        if(fg&&(jk==-1||jk>ans)) jk=ans;
    }
    cout<<jk;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		// int n,x,T;
		// cin>>n>>x>>T;
		// int ans=(n/x)*T;
		// if(n%x!=0)
		// 	ans+=T;
		// cout<<ans<<endl;
		string s;
		cin>>s;
		int cnt=0;
		for(int i=0;i<s.size();i++){
			cnt+=(s[i]-'0');
		}
		if(cnt%9==0)
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll L, R;
  cin>>L>>R;
  if(R-L>=2019) cout<<0<<endl;
  else {
    ll ans = big;
    for(ll i=L;i<=R;++i) {
      for(ll j=i+1;j<=R;++j) {
        ans = min(ans, i*j%2019);
      }
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;

class UnionFind
{
	vector<ll> par;
	vector<ll> sz;

public:
	UnionFind(ll n) {
		par = vector<ll>(n);
		sz = vector<ll>(n);
			for (ll i = 0; i < n; i++) {
				par[i] = i;
				sz[i] = 1;
			}
	}

	ll find(ll x) {
		if (x == par[x]) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
		}
	}

	ll size(ll x) {
		if (x == par[x]) {
			return sz[x];
		}
		else {
			return sz[find(x)];
		}
	}
    
    ll parent(ll x){
        return par[x];
    }

	bool same(ll x, ll y) {
		return find(x) == find(y);
	}
};

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> a(m), b(m);
	UnionFind uf(n);
	ll ans = 0;
    vector<ll> anss(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    for(int i = m - 1; i >= 0; i--){
		anss[i] = ans;
		if (!(uf.same(a[i], b[i]))) {
			ans += uf.size(a[i]) * uf.size(b[i]);
			uf.unite(a[i], b[i]);
		}
	}
    for(int i = 0; i < m; i++){
        cout << ans - anss[i] << endl;
    }
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int k=500,x,n;
    cin>>n>>x;
    if(n*k>=x)
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n, m;
	cin >> n >> m;
	string s[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] = " " + s[i];
	}
	const int mod = 1e9 + 7;
	int dp[n + 1][m + 1];
	memset(dp, 0, sizeof dp);
	dp[1][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i][j] == '.') {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
		}
	}
	cout << dp[n][m] << "\n";
}



Measured memory_bytes: 9088
n = int(input())
data = list(map(int, input().split()))

for i in range(n - 1):
    if data[i] < data[i + 1]:
        data[i + 1] -= 1

for i in range(n - 1):
    if data[i] > data[i + 1]:
        #print("i:{0}".format(i))#
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 15020
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans=0;
  cin>>N;
  string s,t="ABC";cin>>s;
  rep(i,N){
      rep(j,3){
        if(i+j>=N||s[i+j]!=t[j])break;
      }
      ans+=(j==3);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int n; cin >> n;
  int a = 0, b = 0;
  vector<int> ar(n);
  rep(i,n) cin >> ar[i];
  sort(ar.begin(), ar.end());
  reverse(ar.begin(), ar.end());
  for(int i = 0; i < n; i++){
    if(i&1) b += ar[i];
    else a += ar[i];
  }
  int ans = a - b;
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0; i<n; i++){
        cin>>v.at(i);
    }
    int ms=100000000;
    int c=0;
    for(int i=0; i<n; i++){
        ms=min(ms,v.at(i));
        if(v.at(i)<=ms) c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 1024
# abc121_a.py
# https://atcoder.jp/contests/abc121/tasks/abc121_a

# A - White Cells /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# H行 W列の白色のマス目があります。
# あなたは h個の行と w個の列を選び、選んだ行または列に含まれるマス目を全て黒色で塗りつぶします。
# 白色のマス目はいくつ残るでしょうか。
# なお、残る白色のマス目の数は行や列の選び方によらないことが証明できます。

# 制約
#     入力は全て整数である。
#     1≤H,W≤20
#     1≤h≤H
#     1≤w≤W

# 入力
# 入力は以下の形式で標準入力から与えられる。
# H W
# h w

# 出力
# 残る白色のマス目の数を出力せよ。

# 入力例 1
# 3 2
# 2 1

# 出力例 1
# 1

# 3行 2 列の白色のマス目があり、2 行と 1 列を選んで黒色で塗りつぶしたとき、白色のマス目は必ず 1個だけ残ります。

# 入力例 2
# 5 5
# 2 3

# 出力例 2
# 6

# 入力例 3
# 2 4
# 2 4

# 出力例 3
# 0


def calculation(lines):
    # line = lines[0]
    # N = int(lines[0])
    H, W = list(map(int, lines[0].split()))
    h, w = list(map(int, lines[1].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))

    return [(H-h)*(W-w)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 2', '2 1']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['5 5', '2 3']
        lines_export = [6]
    if pattern == 3:
        lines_input = ['2 4', '2 4']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int n[101][101];
int main() {
	int r, c;
	cin >> r >> c;
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> n[i][j];
			n[i][c] += n[i][j];
			n[r][j] += n[i][j];
			n[r][c] += n[i][j];
		}
	}
	for (int i = 0; i <= r; i++){
		for (int j = 0; j < c; j++){
			cout << n[i][j] << " ";
		}
		cout << n[i][c] << endl;
	}
	return 0;
}


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

#define inf 1000000007
int dp[101][20000];
int main(){
    int n,W;
    cin >> n >> W;
    vector<int>v(n),w(n);
    for(int i=0;i<n;i++)cin >> v[i] >> w[i];
    for(int i=0;i<=100;i++){
        for(int j=0;j<10010;j++){
            dp[i][j] = inf;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=10000;j++){
            if(j-v[i]>=0&&dp[i][j-v[i]]!=inf){
                dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
            }
        }
        for(int j=0;j<=10000;j++){
            dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
        }
    }
    int ans = 0;
    for(int i=0;i<=10000;i++){
        if(dp[n][i]<=W){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	string s;
	cin >> s;

	// A[i][j] i文字目から遠い
	vector<vector<int>> A(s.size(), vector<int>(26));

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < 26; j++) {
			A[i][j] = s.size() - i;
		}
		for (int j = i; j < s.size(); j++) {
			A[i][s[j] - 'a'] = min(abs(i - j), A[i][s[j] - 'a']);
		}
	}
	vector<int> max_dis(26, 0);
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < 26; j++) {
			// cout << A[i][j] << " ";
			if (A[i][j] != s.size()) {
				max_dis[j] = max(max_dis[j], A[i][j]);
			}
		}
		// cout << "\n";
	}
	int result = s.size();
	for (int j = 0; j < 26; j++) {
		result = min(result, max_dis[j]);
	}

	cout << result;
	return 0;
}

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

int main(void){
   string A,B,C;
   cin>>A>>B>>C;
   if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> d(K,0);
    int temp=0;
    vector<int>a(N,0);
    for(int i=0;i<K;i++){
        cin>>d[i];
        for(int j=0;j<d[i];j++){
            cin>>temp;
            a[temp-1]++;
        }
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        //cout<<i<<" "<<a[i]<<endl;
        if(a[i]==0){
            
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

 

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 9223372036854775807LL;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

struct edge {int from, to, cost;};
vector<edge> es;
int d[1005];
int n, m;

bool shortest_path(int s, int n) {
    for (int i = 0; i < n; i++) {
        d[i] = INFLL / 2LL;
    }
    d[s] = 0;
    int cnt = 0;
    while (true) {
        cnt++;
        if (cnt == n) break;
        bool update = false;
        for (auto e : es) {
            if (d[e.from] != INFLL / 2LL && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (!update) break;
    }
    int tmp = d[n - 1];
    if (cnt == n) {
        for (auto e : es) {
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    if (d[n - 1] < tmp) {
        return true;
    }
    else return false;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back({a, b, -c});
    }
    if (shortest_path(0, n)) {
        cout << "inf" << endl;  
    }
    else {
        cout << -d[n - 1] << endl;
    }
    //rep(i, n) cout << -d[i] << endl;
}

Measured memory_bytes: 384
n,k=map(int,input().split())
Snk=[0]*n
for j in range(k):
    
    d=int(input())
    T=list(map(int,input().split()))
    for a in T:
        if Snk[a-1]==0:
            Snk[a-1]=1
x=0
for i in Snk:
    if i==0:
        x+=1

print(x)


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

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

  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if ((i+1) % 3 == 0 || (i+1) % 5 == 0) {
    }
    else {
      sum += i+1;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <set>
#include <cmath>
#include <string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    string a, b;
    cin >> a >> b;
    rep(i, a.size()-b.size()+1){
        bool ok = true;
        rep(j, b.size()){
            if (!(b[j] == '_' || a[i + j] == b[j])){
                ok = false;
            }
        }
        if (ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 1184
n,m=map(int,input().split())
l=[0]*(n+1)
for i in range(m):
    a,b=[int(j) for j in input().split()]
    l[a]=(l[a]+1)%2
    l[b]=(l[b]+1)%2
if sum(l)==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, x;
    cin >> n >> x;
    vi a(n);
    ll asum = 0;
    rep(i,n) {
        cin >> a[i];
        asum += a[i];
    }
    if(asum < x) cout << n - 1 << endl;
    else {
        int ans = 0;
        sort(a.begin(), a.end());
        int i = 0;;
        while(x - a[i] >= 0 && i != n) {
            x -= a[i];
            i++;
        }
        cout << i << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, K = map(int, input().split(" "))
c = 0
 
if K != 0:
    for b in range(K+1, N+1):
        s = N % b
        t = N - s
        p = t // b * (b - K)
        q = max(0, s - (K - 1))
        c += (p + q)
        
else:
    c = N ** 2

print(c)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    string s;
    cin >> s;
    int n = s.size()/2;

    int cnt = 0;
    rep(i, n)if(s[i]!=s[s.size()-1-i])cnt++;
    cout << cnt << endl;
}

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

using namespace std;

string a[1010], b[2];
bool same[1010][1010];

bool check(int si, int sj) {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (a[si + i][sj + j] == b[i][j]) continue;
      return false;      
    }
  }
  return true;
}

int main(void) {
  int m, n;
  cin >> m >> n;

  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < 2; i++) {
    cin >> b[i];
  }

  int cnt1 = 0;
  for (int i = 0; i + 1 < m; i++) {
    for (int j = 0; j + 1 < n; j++) {
      same[i][j] = check(i, j);
      cnt1 += same[i][j];
    }
  }

  string ord = "JOI";
  int di[] = {-1, -1, 0, 0}, dj[] = {-1, 0, -1, 0};
  int ans = cnt1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 3; k++) {
        if (a[i][j] == ord[k]) continue;
        int cnt2 = cnt1;
        char tmp = a[i][j];
        a[i][j] = ord[k];
        for (int l = 0; l < 4; l++) {
          int ni = i + di[l], nj = j + dj[l];
          if (ni >= 0 && ni < m && nj >=0 && nj < n) {
            if (same[ni][nj]) cnt2--;
            else cnt2 += check(ni, nj);
          }
        }
        a[i][j] = tmp;
        ans = max(ans, cnt2);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5048
#include <iostream>

int main() {
  char s[3], t[3];
  char ch;
  for (int i = 0; i < 3; i++) {
    std::cin >> ch;
    s[i] = ch;
  }
  for (int i = 0; i < 3; i++) {
    std::cin >> ch;
    t[i] = ch;
  }
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) cnt++;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<LP> v(n);
    rep(i, n) {
        ll x, l;
        cin >> x >> l;
        v[i].first = x - l;
        v[i].second = x + l;
    }

    sort(ALL(v), [](LP a, LP b){return a.second < b.second;});
    ll ans = 0;
    ll value = v[0].second;
    ans++;
    rrep(i, n - 1) {
        if(v[i].first < value) continue;
        else {
            value = v[i].second;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>

int main(){
  char str[5];
  char week[7][5] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int i;
  scanf("%s",str);
  for(i = 0;i < 7;i++){
    if(strcmp(str, week[i]) == 0){
      printf("%d",7-i);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    ll cnt=0;
    REP(i,s.size()){
        if(s[i] != t[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3784
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A[200001];
int dist[200000];

int main(){
	int K, N;
	cin >> K >> N;

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

	A[N] = K + A[0];

	for (int i=0; i<N; i++) {
		dist[i] = A[i+1] - A[i];
	}

	sort(dist, dist+N);

	ll ans = 0;
	for (int i=0; i<N-1; i++) {
		ans += dist[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;

int main(void) {
	int i, j;
	string s;
	cin >> s;
	for (i = 0; i < s.size(); i++) {
		for (j = 0; j < s.size(); j++) {
			if (i == j) {
				break;
			}
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;


	return 0;
}

Measured memory_bytes: 256
K, X = list(map(int, input().split()))

min_X = min(max(-1000000, X-(K-1)), 1000000)
max_X = min(max(-1000000, X+(K-1)), 1000000)

string = [str(i) for i in range(min_X, max_X+1)]
print(' '.join(string))

Measured memory_bytes: 3060
import Control.Monad

main=do
  q<-readLn::IO Int
  abs<-replicateM q $ map read.words<$> getLine::IO[[Int]]
  --
  putStr.unlines.map show.map solve $ abs
--
solve (a:b:_)
  | a > b = solve [b,a]
  | a==b = (a-1)*2
  | a+1==b = (a-1)*2
  | True = f (a*b)
--
f n
  | c*c+c >= n = (c-1)*2
  | True = c*2-1
  where c = g n
g n
  | sq*sq < n = sq
  | True = sq-1
  where sq = truncate.sqrt.fromIntegral $ n

Measured memory_bytes: 1020
//
//  main.cpp
//  atcoderX
//
//  Created by 村井真奈美 on 2018/06/16.
//  Copyright © 2018年 村井真奈美. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int main() {
    
    int N;
    cin >> N;
    
    vector<int> card(N);
    
    for (int i=0 ; i<N ; i++){
        cin >> card[i];
    }
    
    sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
    
    int a,b;
    a=b=0;
    for(int i=0 ; i<N ; i++){
        if(i%2 == 0) a += card[i];
        if(i%2 != 0) b += card[i];
    }
    
    cout << a-b << endl;

}


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x==y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    uf.unite(a,b);
  }

  int ans = 0;
  rep(i,n) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[][] NM = new int[2][1];
		for(int j = 0; j < 2; j++) {
			NM[j][0] = sc.nextInt();
		}

		int N = NM[0][0];
		int M = NM[1][0];

		int[][] SM = new int[M][2];
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < 2; j++) {
				SM[i][j] = sc.nextInt();
			}

		}

		int A = -1;
		int B = -1;
		int C = -1;
		int D = 0;

		int count_1 = 0;
		int count_2 = 0;
		int count_3 = 0;


		for(int i = 0; i < M; i++) {
			if(SM[i][0] == 1) {
				if((count_1 > 0) && (A == SM[i][1])) {
					continue;
				}
				A = SM[i][1];
				count_1++;
			}else if(SM[i][0] == 2) {
				if((count_2 > 0) && (B == SM[i][1])) {
					continue;
				}
				B = SM[i][1];
				count_2++;
			}else {
				if((count_3 > 0) && (C == SM[i][1])) {
					continue;
				}
				C = SM[i][1];
				count_3++;
			}
			if((count_1 > 1) || (count_2 > 1) || (count_3 > 1)) {
				D = -1;
				break;
			}
		}

		if(D == 0){
			if(N == 3) {
				if(A == 0) {
					D = -1;
				}else {
					if(B == -1) {
						B = 0;
					}
					if(C == -1) {
						C = 0;
					}
					if(A == -1) {
						D = 1 * 100 + B * 10 + C;

					}else {
						D = A * 100 + B * 10 + C;

					}

				}
			}else if(N == 2) {
				if(A == 0) {
					D = -1;
				}else {
					if(A == -1) {
						A = 1;
					}
					if(B == -1) {
						B = 0;
				}
					D = A * 10 + B;
				}
			}else {
				D = A;
			}
		}
		if(M == 0) {
			if(N == 3) {
				D = 100;
			}else if( N == 2) {
				D = 10;
			}else {
				D = 0;
			}

		}
		System.out.println(D);

		sc.close();
	}
}


Measured memory_bytes: 21972
import java.io.*;
import java.util.*;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private ArrayList<Integer>[] adj;

    private void addEdge(int u, int v) {
        adj[u].add(v);
    }

    public static void main(String[] args) {
        Main main = new Main();
        FastReader scanner = new FastReader();
        int N = scanner.nextInt();

        main.adj = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            main.adj[i] = new ArrayList<>();
        }

        int M = scanner.nextInt();
        for (int i = 0; i < M; i++) {
            main.addEdge(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }

        int max = 0;
        int[] DP = new int[N];

        boolean[] visited = new boolean[N + 1];


        for (int i = 0; i < N; i++) {
            if (!visited[i])
                main.DFS(visited, i, DP);
        }

        for (int i = 0; i < N; i++) {
            max = Math.max(max, DP[i]);
        }
        System.out.println(max);
    }

    private void DFS(boolean[] visited, int n, int[] DP) {
        visited[n] = true;
        for (Integer ix : adj[n]) {
            if (!visited[ix]) {
                DFS(visited, ix, DP);
            }
            DP[n] = Math.max(DP[n], 1 + DP[ix]);
        }
    }

}

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

#define ll long long int

using namespace std;


int main(){
	
	int arr[6];
	int ans;
	
	for(int i=1; i<=5; i++){
		cin>>arr[i];
		if (arr[i] == 0)
			ans = i;
	}
	cout<<ans<<endl;
	
	return 0;
}


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

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b,c;
	cin >> a >> b >> c;
	
	seiyaku_check(a,1,20);
	seiyaku_check(b,1,50);
	seiyaku_check(c,1,50);
	
	if(a*b <= c){
		cout << a*b << endl;
	}else{
		cout << c << endl;
	}
	
return 0;
}


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

int main(){
  bool prime[1000000] = {};
  int sum[1000000]; sum[0] = sum[1] = 0;
  for(int i = 2 ; i < 1000000 ; i++ ){
    sum[i] = sum[i - 1];
    if(!prime[i]){
      for(int j = i + i ; j < 1000000 ; j += i ){
        prime[j] = true;
      }
      sum[i]++;
    }
  }

  int n;
  while(cin >> n){
    cout << sum[n] << endl;
  }
}

Measured memory_bytes: 6048