akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<set>
#include<map>
#include<sstream>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
int n;
int num[11];
int rr,lll;
bool b;
void dfs()
{
	bitset<10> ans;
	int alll=1<<10;
	while(alll-->0)
	{
		ans=static_cast<bitset<10> >(alll);
		bool b=true;
		rr=0;
		lll=0;
		rep(i,10)
		{
			if(ans[i])
			{
				if(num[i]>lll)
				{
					lll=num[i];
				}
				else
				{
					b=false;
					break;
				}
			}
			else
			{
				if(num[i]>rr)
				{
					rr=num[i];
				}
				else
				{
					b=false;
					break;
				}
			}
		}
		if(b)break; 
	}
	if(alll>=0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return;
}
int main()
{
	cin>>n;
	while(n--)
	{
		rep(i,10)cin>>num[i];
		dfs();
	}
	return 0;
}

Measured memory_bytes: 1152
import sys

L, R = map(int, input().split())
diff = R - L

# 2019以上離れていたら0
if diff >= 2019:    
    print(0)
    sys.exit()
    
k = L / 2019
L = L % 2019
R = R % 2019

# ここまで来れば、2000 * 2000 が2secで終わるはず
min_val = 2018
for l_i in range(L, R):
    for r_i in range(l_i + 1, R + 1):
        target = l_i * r_i
        target = target % 2019

#         print(l_i, r_i)
#         print("test", target)
#         if target == 0:
#             print(l_i, r_i)

        if target < min_val:
            min_val = target

            
print(min_val)

Measured memory_bytes: 3064
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))

#最大公約数
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

#最小公倍数
def lcm(x,y):
    return x*y//gcd(x,y)

ans=a[0]
for i in a:
    ans=lcm(ans,i)
    
print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int num = Integer.parseInt(sc.next());
		
		double ans = (double)num * (double)num * (double)num / 27d;
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21716
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == 500*a + 100*b + 50*c:
                ans += 1
            else:
                continue
print(ans)

Measured memory_bytes: 3060
#![allow(non_snake_case, unused_imports, unused_mut, unused_variables)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

fn ceil(n: i32) -> i32 {
    (n as f32 / 10.0).ceil() as i32 * 10
}

fn main() {
    input! {
        v: [i32; 5],
    }

    let mut ans = 0;
    let mut min = 0;
    for (i, n) in v.iter().enumerate() {
        if (n % 10) != 0 && (n % 10) < (v[min] % 10) {
            min = i;
        }
        if (n % 10) == 0 {
            ans += v[i];
        }
    }

    for (i, n) in v.iter().enumerate() {
        if (n % 10) == 0 {
            continue;
        }
        if i != min {
            ans += ceil(v[i]);
        }
    }

    if !(min == 0 && v[min] % 10 == 0) {
        ans += v[min];
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    string s,t;
    cin >> s >> t;
    vector<vector<int>> dp(s.length()+1,vector<int> (t.length()+1,0));

    for(int i = 1;i < s.length()+1;++i){
        for(int j = 1;j < t.length()+1;++j){
            if(s[i-1] == t[j-1]) dp[i][j] = max(dp[i-1][j-1]+1,max(dp[i-1][j],dp[i][j-1]));
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans = "";
    int a = dp[s.length()][t.length()];
    for(int i = s.length();i > 0;--i){
        for(int j = t.length();j > 0;--j){
            if(dp[i-1][j-1]+1 > dp[i-1][j] && dp[i-1][j-1]+1 > dp[i][j-1] && a == dp[i][j] && dp[i][j] == dp[i-1][j-1]+1){
                ans += t[j-1];
                a--;
                break;
            }else if(dp[i][j] < a) break;
        }
    }

    reverse(all(ans));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35584
#include <algorithm>
#include <iostream>

using namespace std;

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

  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i < min(a + k, b + 1); ++i) {
    cout << i << endl;
  }
  for (int i = max(a + k, b - k + 1); i <= b; ++i) {
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n; cin >> n;
  map<ll, ll> mp;
  for(ll i=0;i<n;++i) {
    ll tmp; cin >> tmp;
    mp[tmp]++;
  }
  vector<ll> b;
  for(auto &e: mp) {
    b.push_back(e.second);
  }
  sort(b.begin(), b.end());
  vector<ll> su((ll)(b.size()));
  su[0] = b[0];
  for(ll i=1;i<(ll)(b.size());++i) {
    su[i] = su[i-1] + b[i];
  }
  for(ll k=1;k<=n;++k) {
    ll l = 0, r = 3 * 100000 + 1;
    while(r - l > 1) {
      ll ans = (l + r) / 2;
      auto it = upper_bound(b.begin(), b.end(), ans);
      ll pos = distance(b.begin(), it);
      ll now = 0;
      if(pos > 0) now += su[pos-1];
      now += ans * ((ll)(b.size()) - pos);
      if(now >= ans * k) {
        l = ans;
      } else {
        r = ans;
      }
    }
    cout << l << endl;
  }
}


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

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

int main(){
    int n,q,l,r;cin>>n>>q; 
    string s;cin>>s;
    int imos[n+3];
    REP(i,n+3){
        imos[i]=0;
    }
    REP(i,n-1){
    if (s[i]=='A'&&s[i+1]=='C')
    {
        /* code */
        imos[i+1]=imos[i]+1;
    }
    else
    {
        imos[i+1]=imos[i];
    }
    
    }

    REP(i,q){
        cin>>l>>r;
        cout<<imos[r-1]-imos[l-1]<<endl;
    }
    

    }
    

Measured memory_bytes: 1408
/*
[exawizards2019] D - Modulo Operations
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 200;
const int MAX_X = 1e5;
const ll MOD = 1e9 + 7;

int N, X;
int S[MAX_N];
ll dp[MAX_N + 1][MAX_X + 1];

ll fact(int n) {
    ll ret = 1;
    for (int i = 2; i <= n; i++) {
        (ret *= i) %= MOD;
    }

    return ret;
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x) % m;
}

ll solve() {
    sort(S, S + N, greater<int>());
    ll fact_n = fact(N);

    dp[0][X] = fact_n;
    for (int i = 0; i < N; i++) {
        ll inv = mod_inv(N - i, MOD);
        for (int j = 0; j <= X; j++) {
            ll p = (dp[i][j] * inv) % MOD;
            ll q = (p * (N - i - 1)) % MOD;
            (dp[i + 1][j % S[i]] += p) %= MOD;
            (dp[i + 1][j] += q) %= MOD;
        }
    }

    ll ans = 0;
    for (int j = 0; j <= X; j++) {
        (ans += j * dp[N][j]) %= MOD;
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 156544
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2000006
#define mo 1000000007
using namespace std;
int n,sum,f[N];
int main()
{
	scanf("%d",&n);f[0]=1;f[1]=sum=n;
	for(int i=2;i<=n;i++){
		f[i]=(sum-f[i-2]+1LL*(n-1)*(n-1)%mo+(n-i+2)+mo)%mo;
		sum=(sum+f[i])%mo;
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 4224
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  int x, ck, n = 1;
  cin >> x ;
  int a[10000] = {0};
  a[0] = 2;
  if(x == 2){cout << 2;}
  else{
    int i = 3;
    while(1){
      ck = 0;
      for(int j = 0; j < n; j++){
        if(i%a[j]==0){ck =1; break;}
      }
      if(ck == 0){
        if(i >= x) {cout << i; break;} 
        else { a[n] = i; n++;}
      }
      i += 2;
    }
  }
}

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

using namespace std;

#define For(i, a, b) for(int i = a; i <= b; ++ i)
#define pb push_back
#define fi first
#define se second

typedef pair < int, int > ii;
const int N = 1e5 + 5, INF = 1e8;
int n, k;
int res[N];
vector < int > adj[N];

priority_queue < ii > pq;
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n; res[n] = INF;
	For(i, 1, n - 1){
		int u, v; cin >> u >> v;
		res[i] = INF;
		adj[u].pb(v); adj[v].pb(u);
	}
	cin >> k;
	For(i, 1, k){
		int u, x; cin >> u >> x; res[u] = x;
		pq.push(ii(x, u));
	}
	while(!pq.empty()){
		int val = pq.top().fi, u = pq.top().se; pq.pop();
		for(int v : adj[u]){
			if(res[v] == INF) res[v] = val - 1, pq.push(ii(res[v], v));
			else if(abs(res[u] - res[v]) != 1){ cout << "No"; return 0; }
		}
	}
	cout << "Yes\n";
	For(i, 1, n) cout << res[i] << "\n";
}

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

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

// [debug]

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

void Main() {
  int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  k--;
  cout << A[k] << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int num;
		while((num = scanner.nextInt()) != 0)
		{
			String r = "";
			String s = String.format("%o", num);
			for(int i = 0; i < s.length(); i++)
			{
				char c = s.charAt(i);
				if(c > '4')
					r += (c-'0')+2;
				else if(c > '3')
					r += (c-'0')+1;
				else
					r += c;
			}
			System.out.println(r);
		}
	}
}

Measured memory_bytes: 63560
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;using System.Collections;
using System.Runtime.Serialization;
using System.Collections.Specialized;
using System.Security.Cryptography;
using System.Globalization;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    static int mod = (int)Pow(10, 9) + 7;
    public static int Mod(int a,int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion





    static void Main()
    {
        List<long> anses = new List<long>();
        while (true)
        {
            int[] NM = ReadInts;
            int N = NM[0];
            int M = NM[1];

            if (N == 0 && M == 0)
            {
                break;
            }
            long infty = 10000000000000000;

            int[] codeBook = new int[M];
            for (int i = 0; i < M; i++)
            {
                codeBook[i] = ReadInt;
            }

            int[] signals = new int[N];
            for (int i = 0; i < N; i++)
            {
                signals[i] = ReadInt;
            }

            //分散dp[考える信号,エンコード後][分散,エンコード後]
            long[,] dp = new long[N + 1, 256];

            for (int i = 0; i < N + 1; i++)
            {
                for (int s = 0; s < 256; s++)
                {
                    dp[i, s] = infty;
                }
            }

            dp[0, 128] = 0;

            for (int n = 1; n < N + 1; n++)
            {
                for (int s = 0; s < 256; s++)
                {
                    for (int m = 0; m < M; m++)
                    {
                        long temp_sig = s + codeBook[m];
                        if (temp_sig < 0)
                        {
                            temp_sig = 0;
                        }
                        else if (temp_sig > 255)
                        {
                            temp_sig = 255;
                        }

                        long temp_d = dp[n - 1, s] + (long)Pow(signals[n - 1] - temp_sig, 2);

                        if(dp[n, temp_sig] > temp_d)
                        {
                            dp[n, temp_sig] = temp_d;
                        }
                    }
                }
            }

            long ans = infty;
            for (int i = 0; i < 256; i++)
            {
                long l = dp[N, i];
                ans = Min(ans, dp[N, i]);
            }
            anses.Add(ans);

        }
        WriteLine(string.Join("\n", anses));

    }

}



Measured memory_bytes: 98236
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;
int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt=1;
    for(ll i=0;i+1<n;i++)
    {
        if(s[i]!=s[i+1])
          cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, M; cin >> N >> M;
    vector<vector<PII>> P(100001);
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        P[a].push_back({a, b});
    }

    priority_queue<PII> Q;
    
    ll ans = 0;
    for(int i=1; i<=M; i++){
        for(int j=0; j<P[i].size(); j++){
            Q.push({P[i][j].sc, P[i][j].fs});
        }
        
        if(Q.size()!=0){
            ans += Q.top().fs;
            Q.pop();
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 5632
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(0);

    int N;
    cin >> N;
    while(N--) {
        unsigned nums[8];
        unsigned sum = 0;
        cin >> std::hex;
        for(int i = 0; i < 8; ++i) cin >> nums[i];
        cin >> sum;

        unsigned K = 0;
        for(int i = 0; i < 32; ++i) {
            unsigned carry = 0;
            for(int j = 0; j < 8; ++j) carry += (nums[j]^K)&((1<<i)-1);
            unsigned subsum = 0;
            for(int j = 0; j < 8; ++j) subsum += (nums[j]>>i)&1;
            unsigned sumbit = (sum>>i)&1;
            sumbit ^= (carry>>i)&1;

            if((subsum&1) != sumbit) K |= (1<<i);
        }

        cout << std::hex << K << endl;
    }

    return 0;
}

Measured memory_bytes: 0
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input()) * 2
    L = readInts()
    L = sorted(L)
    res = 0
    for i in range(0,n,2):
        res += L[i]
    print(res)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
void main()
{
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    auto g = a.group.array;
    int cnt;
    foreach (x; g)
    {
        cnt += x[1] / 2;
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var A, B, C, D int
	con.Scan(&A, &B, &C, &D)
	S1 := A * B
	S2 := C * D
	if S1 > S2 {
		con.Println(S1)
	} else {
		con.Println(S2)
	}
	return nil
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

bool comp(std::vector<int>& a, std::vector<int>& b) {
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b[i])
      return false;
  }
  return true;
}

int main() {
  int n;
  std::vector<int> data;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    std::cin >> x;
    data.push_back(x);
  }
  
  std::vector<int> sorted = data;
  std::sort(sorted.begin(), sorted.end());

  for (int i = 0; i < data.size(); i++) {
    for (int j = i; j < data.size(); j++) {
      std::swap(data[i], data[j]);
      if (comp(data, sorted)) {
        std::cout << "YES" << std::endl;
        return 0;
      }
      std::swap(data[i], data[j]);
    }
  }
  std::cout << "NO" << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
S=input()

if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)


Measured memory_bytes: 61796
#include<stdio.h>
#include<string.h>
#include<queue>
struct S{int x,y,c,a;S(int x,int y,int c,int a):x(x),y(y),c(c),a(a){}bool operator<(const S&s)const{return c>s.c;}};
int main()
{
	char m[66][36];	//ツ湘」ツ可コツ債カツ右ツづ可氾板閉コツ閉ェツ＋3
	int d[66][36][2],h,w,x,y,z,a,i;
	int dx[]={1,1,1,1,1,2,2,2,3};
	int dy[]={2,1,0,-1,-2,1,0,-1,0};

	while(scanf("%d%d",&w,&h),w)
	{
		a=-1;
		memset(m,'X',sizeof(m));
		memset(d,127,sizeof(d));
		std::priority_queue<S>q;
		for(y=3;y<h+3;++y)
			for(x=3;x<w+3;++x)
			{
				scanf(" %c",&m[y][x]);
				if(m[y][x]=='S')
				{
					q.push(S(x,y,0,0));
					q.push(S(x,y,0,1));
					m[y][x]='0';
				}
			}
		while(!q.empty())
		{
			S p(q.top());q.pop();
			if(m[p.y][p.x]=='X')continue;
			if(m[p.y][p.x]=='T'){a=p.c;break;}
			p.c+=m[p.y][p.x]-'0';
			if(d[p.y][p.x][p.a]<=p.c)continue;
			d[p.y][p.x][p.a]=p.c;
			z=p.a*2-1;
			for(i=0;i<9;++i)
			{
				x=p.x+z*dx[i];
				y=p.y+dy[i];
				q.push(S(x,y,p.c,!p.a));
			}
		}
		printf("%d\n",a);
	}
	return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    // No
    int res = 0;
    if(A==B && A != C )
        res = 1;        
    else if(B==C && B !=A )
        res = 1;
    else if(C==A && C!=B)
        res = 1;

    if (res == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int A, B;

int main() {
  cin >> A >> B;

  int cnt_w = 1, cnt_b = 1;
  cout << 100 << " " << 100 << "\n";
  rep(h, 0, 50) {
    rep(w, 0, 100) {
      if (h % 2 == 0 && w % 2 == 0) {
        if (cnt_b < B) {
          cout << '#';
          ++cnt_b;
        } else {
          cout << ".";
        }
      } else {
        cout << ".";
      }
      if (w == 99) {
        cout << "\n";
      }
    }
  }

  rep(h, 50, 100) {
    rep(w, 0, 100) {
      if (h % 2 == 1 && w % 2 == 0) {
        if (cnt_w < A) {
          cout << '.';
          ++cnt_w;
        } else {
          cout << '#';
        }
      } else {
        cout << '#';
      }
      if (w == 99) {
        cout << "\n";
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, k;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }
  V<pii> v, ans;
  FOR(i, 1, n) ans.pb(mp(0, i));
  FOR(i, 1, n)FOR(j, i+1, n) v.pb(mp(i, j));
  FOR(i, k, (n-1)*(n-2)/2) ans.pb(v[i]);
  cout << sz(ans) << endl;
  for(pii p:ans) cout << p.fi+1 << " " << p.se+1 << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t;
    cin >> t;
    rep(i,t.size()){
        if(t[i] == '?') t[i] = 'D';
        cout << t[i];
    }
    cout << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	string s; cin >> s;
	int cnt = 0;
	int idx = -1;
	if (s.at(0) != 'A') {
		cout << "WA" << endl;
		return 0;
	} else {
		for (int i = 2; i < s.size() - 1; i++) {
			if (s.at(i) == 'C') {
				cnt += 1;
				idx = i;
			}
		}
		if (cnt != 1) {
			cout << "WA" << endl;
			return 0;
		}
	}

	for (int i = 1; i < s.size(); i++) {
		if (i == idx) continue;
		if (isupper(s.at(i))) {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;


}



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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


class UnionFind {
private:
    VI par;
    VI sizes;

public:
    UnionFind(int n) : par(n), sizes(n, 1) {
        REP(i, n) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = this->root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        
        if(x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return sizes[root(x)];
    }
};

ll comb2(ll n) {
    return n * (n - 1) / 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    VI a(m), b(m);
    REP(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind uf(n);
    VL ans(m);
    ans[m - 1] = comb2(n);
    FORR(i, m - 1, 1) {
        if(!uf.same(a[i], b[i])) {
            ans[i - 1] = ans[i] - (ll)uf.size(a[i]) * (ll)uf.size(b[i]);
            uf.unite(a[i], b[i]);
        } else {
            ans[i - 1] = ans[i];
        }
    }

    REP(i, m) cout << ans[i] << ln;
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	const int ink[3][4][2]={
		{1,0,0,1,-1,0,0,-1},
		{1,1,-1,1,-1,-1,1,-1},
		{2,0,0,2,-2,0,0,-2},
	};
	int paper[12][12]={0};
	for(int x,y,size;~scanf("%d,%d,%d",&x,&y,&size);){
		paper[2+y][2+x]++;
		rep(i,size)
			rep(j,4)
				paper[2+y+ink[i][j][0]][2+x+ink[i][j][1]]++;
	}
	
	int white=0,thick=0;
	rep(i,10){
		thick=max(thick,*max_element(paper[2+i]+2,paper[2+i]+12));
		white+=count(paper[2+i]+2,paper[2+i]+12,0);
	}
	cout<<white<<endl;
	cout<<thick<<endl;
	
	return 0;
}

Measured memory_bytes: 0
X,K,D=map(int,input().split())
c=[]
k=K
if X<0:
  X=-X
if X-K*D>0:
  print(X-K*D)
else:
  a=X//D
  if a%2==K%2:
    print(min((X-D*a),abs(X-D*(a+2))))
  else:
    print(min((X-D*(a-1)),abs(X-D*(a+1))))
  

Measured memory_bytes: 9148
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    s = list(input())
    ans = []
    for i, val in enumerate(s):
        if i == 0:
            ans.append(val)
            continue
        if i % 2 == 0:
            ans.append(val)
        
    print("".join(ans))
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 50160
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int num[N];
int main(){
	int n,h;scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&h);
		if(h+i<n)num[h+i]++;
		if(i-h>1)ans+=num[i-h];
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
 int N,A,n,r;
  cin >> N >> A;
    n = N/500;
    
  if( N <= A)
    cout<<"Yes"<<endl;
  else if (N>=500 && N-n*500<=A)
      cout<<"Yes"<<endl;
      else if(N>=500 && N-n*500>=A)
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
n = int(input())
cnt = 0
check = 1

a = [0, 9, 0, 900, 0, 90000]

for i in range(1, 6):
    check *= 10

    if (n < check):
        check = int(check / 10)

        if (i % 2 == 1):
            cnt += n - check + 1

        break

    cnt += a[i]

print(cnt)

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

#define MOD 998244353

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> xy( N );
	vector<int> X( N );
	vector<int> Y( N );
	for( int i = 0; i < N; i++ ) {
		cin >> xy[i].first >> xy[i].second;
		X[i] = xy[i].first;
		Y[i] = xy[i].second;
	}

	map<int, int> mx;
	sort( X.begin(), X.end() );
	for( int i = 0; i < N; i++ ) {
		mx[ X[i] ] = i + 1;
	}
	map<int, int> my;
	sort( Y.begin(), Y.end() );
	for( int i = 0; i < N; i++ ) {
		my[ Y[i] ] = i + 1;
	}
	for( int i = 0; i < N; i++ ) {
		xy[i] = make_pair( mx[ xy[i].first ], my[ xy[i].second ] );
	}
	sort( xy.begin(), xy.end() );
	vector<int> upper_left( N );
	vector<int> lower_left( N );
	vector<int> upper_right( N );
	vector<int> lower_right( N );
	BinaryIndexedTree<int> bit1( N + 1 );
	BinaryIndexedTree<int> bit2( N + 1 );
	for( int i = 0; i < N; i++ ) {
		int y = xy[i].second;
		int l = bit1.sum( y );
		int u = i - l;
		upper_left[i] = u;
		lower_left[i] = l;
		bit1.add( y, 1 );
	}
	for( int i = N - 1; i >= 0; i-- ) {
		int y = xy[i].second;
		int l = bit2.sum( y );
		int u = N - 1 - i - l;
		upper_right[i] = u;
		lower_right[i] = l;
		bit2.add( y, 1 );
	}

	long long pow2[N + 1];
	pow2[0] = 1;
	for( int i = 0; i < N; i++ ) {
		pow2[i + 1] = pow2[i] * 2 % MOD;
	}
	long long ans1 = 0;
	for( int i = 0; i < N; i++ ) {
		ans1 += (pow2[ upper_left[i] ] - 1) * (pow2[ upper_right[i] ] - 1);
		ans1 %= MOD;
		ans1 += (pow2[ upper_right[i] ] - 1) * (pow2[ lower_right[i] ] - 1);
		ans1 %= MOD;
		ans1 += (pow2[ lower_right[i] ] - 1) * (pow2[ lower_left[i] ] - 1);
		ans1 %= MOD;
		ans1 += (pow2[ lower_left[i] ] - 1) * (pow2[ upper_left[i] ] - 1);
		ans1 %= MOD;
		ans1 += pow2[ upper_left[i] ] - 1;
		ans1 %= MOD;
		ans1 += pow2[ upper_right[i] ] - 1;
		ans1 %= MOD;
		ans1 += pow2[ lower_right[i] ] - 1;
		ans1 %= MOD;
		ans1 += pow2[ lower_left[i] ] - 1;
		ans1 %= MOD;
	}
	long long ans = ((pow2[N] - 1) * N - ans1 + MOD) % MOD;

	cout << ans << endl;
}


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

int main(){
	int a[30]={};
	for(int i=0; i<28; i++){
		int n;
		cin >> n;
		a[n-1] = 1;
	}
	for(int i=0; i<30; i++){
		if(a[i]==0) cout << i+1 << endl;
	}
}

Measured memory_bytes: 3048
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define MAX(a, b) ((ll)(a) > (ll)(b)) ? (ll)(a) : (ll)(b)
#define MIN(a, b) ((ll)(a) > (ll)(b)) ? (ll)(b) : (ll)(a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll min(ll a, ll b){
	if (a < b)
		return a;


		return b;
}



ll N;

vector<ll> S[100005];
int main() {
	cin >> N;

	ll k;
	bool flag = false;
	for (k = 2; k <= 100005; k++) {
		if (k * (k - 1) == 2 * N) {
			flag = true;
			break;
		}

	}


	if (flag == false) {

		cout << "No" << endl;
		return 0;
	}



	ll num = 1;
	stack<ll> s;
	rep(i, k) {

		ll a = S[i].size();

		rep(j, k - 1 - a) {

			S[i].push_back(num);
			S[i + j + 1].push_back(num);
			num += 1;
		}

	

	}

	cout << "Yes" << endl;
	cout << k << endl;
	rep(i, k) {
		cout << S[i].size() << " ";
		rep(j, S[i].size()) {

			cout << S[i][j] << " ";
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int x, i, j, f=0;
	scanf("%d", &x);
	
	for(i=x; i<100200; i++){
		for(j=2; j<=sqrt(x); j++){
			if(i%j==0){
				f=1; break;
			}
		}
		if(f==0){ printf("%d", i); return 0; }
		f=0;
	}
	
return 0;
}

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

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

int N, Y;

void solve(){
   REP(man,N+1){
       REP(gosen,N+1-man){
           int nokori = Y-man*10000-gosen*5000;
           if(nokori%1000==0 && nokori/1000==N-man-gosen){
               printf("%d %d %d",man, gosen, nokori/1000);
               return;
           }
       }
   }
    printf("-1 -1 -1");
    return ;
}

int main(){
    scanf("%d",&N);
    scanf("%d",&Y);
    solve();
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (auto&& e : p) cin >> e;
  sort(begin(p), end(p));
  cout << reduce(begin(p), next(begin(p), k)) << endl;
}


Measured memory_bytes: 3632
using System;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
//		string[] sH = Console.ReadLine().Split(' ');
		int ans=1;
		for(var i = 0 ;i < 3;i++){
			ans=ans*N;
		}
		Console.Write(ans);
	}
}


Measured memory_bytes: 11092
import static java.lang.Math.abs;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        sc.close();
        int count=0;
        for(int i=0;i<S.length();i++){
            if(S.charAt(i)=='A') count++;
            else count--;
        }
        if(abs(count)==3)System.out.println("No");
        else System.out.println("Yes");    
    }
}

Measured memory_bytes: 21972
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

void dfs(ll idx, vector<vector<ll>> &adj, vector<char> &visited) {

    visited[idx] = 1;
    // printf("%lld", idx);

    for(auto i:adj[idx]) {
        if(!visited[i]) {
            dfs(i,adj,visited);
        }
    }
}

int main() {
    
    get2(n,m);

    vector<vector<ll>> adj(n, vector<ll>());
    rep(i,m) {
        get3(a,b,c);
        --a; --b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    ll c = 0;
    vector<char> visited(n,0);
    rep(i,n)
    if(!visited[i]) {
        dfs(i,adj,visited);
        c++;
    }


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

    return 0;  
}

Measured memory_bytes: 10496
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
 string a;
  cin>>a;
  bool e=0;
  rep(i,a.size()-1){
  if(a[i]=='A'&&a[i+1]=='C')
    e=1;
  }
    if(e)
      cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


int main()
{
    fast();
    string s, t; cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++)
        ans += (s[i] != t[i]);

    cout << ans << endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f[100006],c[100006];
int main(){
    ll n,m,x,y;
    cin>>n>>m;
    c[1]=1;
    for(int i=1;i<=n;i++) f[i]=1;
    while(m--){
        cin>>x>>y;
        if(f[x]){
        if(c[x]==1) {c[y]=1;if(f[x]==1) c[x]=0;}
        f[x]--;f[y]++;
            
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(c[i]) ans++;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;

int ans, cnt[12], len;
long long n, p[12];

void split(long long n){
	len = 0;
	for(int i = 2; 1ll * i * i <= n; i++) if(n % i == 0){
		p[len] = i, cnt[len] = 0;
		do n /= i, cnt[len]++; while(n % i == 0);
		len++;
	}
	if(n != 1) cnt[len] = 1, p[len++] = n;
}

long long mul = 1;
void dfs(int i){
	if(i == len){
		if(mul == 1) return;
		long long tmp = n;
		do tmp /= mul; while(tmp % mul == 0);
		ans += tmp % mul == 1;
		return;
	}
	dfs(i + 1);
	for(int j = 0; j < cnt[i]; j++)
		mul *= p[i], dfs(i + 1);
	for(int j = 0; j < cnt[i]; j++) mul /= p[i];
}

int main(){
	scanf("%lld", &n);
	split(n), dfs(0), split(n - 1);
	mul = 1;
	for(int i = 0; i < len; i++) mul *= cnt[i] + 1;
	printf("%lld", ans + mul - 1);
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto K = RD;
	auto X = RD;

	long[] ans;
	foreach_reverse (i; 0..K)
	{
		ans ~= X-i;
	}
	foreach (i; 1..K)
	{
		ans ~= X+i;
	}

	ans.map!(to!string).join(" ").writeln;
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

primes = primes' [2..]
  where
    primes' (p:l) = (p:primes' (filter ((/=0) . flip mod p) l))

primesLT1e4 = takeWhile (<10000) primes

isPrime x = elem x primesLT1e4 || all ((/=0) . mod x) primesLT1e4

readLn2 = readLn :: IO Int
main = do
  readLn2 >>= flip replicateM readLn2 >>= print . length . filter isPrime

Measured memory_bytes: 8228
import java.util.Scanner;

public class Main {
	private void calc(){
		Scanner scanner = new Scanner(System.in);
		int x =scanner.nextInt();
		int y =scanner.nextInt();
		int z =scanner.nextInt();
		int temp;
		
		if(x>y){
			temp=x;
			x=y;
			y=temp;
		}
		if(x>z){
			temp=x;
			x=z;
			z=temp;
		}
		if(y>z){
			temp=y;
			y=z;
			z=temp;
		}
		System.out.println(x + " " + y + " " + z);
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.calc();

	}
}

Measured memory_bytes: 17352
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <string>
#include <algorithm>

using namespace std;
using namespace __gnu_pbds;

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

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
using namespace std;

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


Measured memory_bytes: 3988
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int k, x; cin >> k >> x;
    for(int i = x - k + 1; i < x + k; ++i){
        if(i != x-k+1) cout << " ";
        cout << i;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256