akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {

   char str[100];
   cin >> str;
   int lowAlphabet[26] = {0}, j;
   for(int i=0; str[i]!='\0'; i++)
   {
      if (str[i] >= 'a' && str[i] <= 'z')
        {
         j = str[i] - 'a';
         ++lowAlphabet[j];
        }
   }
   int count1=0,count2=0;
   for (int i = 0; i < 26; i++)
   {
       if(lowAlphabet[i]!=0 && lowAlphabet[i]%2==0)
        count1++;
        else if(lowAlphabet[i]!=0 && lowAlphabet[i]%2!=0)
        count2++;
   }
   if(count1!=0&&count2==0)
    cout << "Yes";
   else
    cout << "No";

   return 0;
}


Measured memory_bytes: 3600
// ABC079 C - Train Ticket

#include <iostream>
#include <string>

int SolveSushiki(std::string s) {
    int n = s.size();
    int sum = s.at(0) -'0';
    for (int i = 1; i < n; i++) {
        if (s.at(i) == '+') {
            sum += s.at(i+1) - '0';
        }else if (s.at(i) == '-') {
            sum -= s.at(i+1) - '0';
        }
    }
    return sum;
}

int main() {
    std::string s;
    std::cin >> s;

    for (int mask = 0; mask < (1 << 3); mask++) {
        std::string sushiki = "";
        for (int i = 0; i < 3; i++) {
            sushiki += s.at(i);
            if((mask >> i)&1) {
                sushiki += '+';
            }else{
                sushiki += '-';
            }
        }
        sushiki += s.at(3);
        if (SolveSushiki(sushiki) == 7) {
            std::cout << sushiki << "=7" << std::endl;
            return 0;
        }
    }

    std::cout << "miss" << std::endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=1e5+10;
char ch[M],s[M],t[M];
int n,m;
int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	int ans=m;
	F(i,1,n-m+1){
		int tmp=m;
		F(j,1,m){
			tmp-=(t[j]==s[i+j-1]);
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<'\n'; 
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793

  int main()
{
  long long A,b;
  int B,C;
  cin>>A;
  scanf("%d.%d",&B,&C);
  b=B*100+C;
  printf("%lld",A*b/100);

  return 0;
} 



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int func(int n){
    int cnt = 0;
    while(n){
        if(n%2 == 0){
            cnt++;
            n /= 2;
        }
        else{
            break;
        }
    }
    return cnt;
}
int main(){

    string s;
    cin >> s;
    map<char, int> mp;
    for(int i = 0; i < (int)s.size(); i++){
        mp[s[i]]++;
    }
    bool ok = true;
    for(auto c: mp){
        if(c.second > 1) ok = false;
    }
    if(ok) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

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

ll num[100010];

int main(){
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    RFOR(i,1,K+1){
      ll n = K / i;
      ll cnt = 0;
      FOR(j,1,n) cnt += num[i+i*j];
      num[i] = modpow(n,N,MOD) - cnt;
      while(num[i] < 0) num[i] += MOD * 100100100;
      num[i] %= MOD;
      ans += num[i] * i;
      ans %= MOD;
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 4376
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  vvl edges(n, vl(2));
  vector<unordered_set<ll>> elist(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edges[i][0] = a;
    edges[i][1] = b;
    elist[a].insert(i);
    elist[b].insert(i);
  }
  ll maxi = 0;
  ll colors = elist[0].size();
  REP(i, 1, n) {
    if (colors < elist[i].size()) {
      maxi = i;
      colors = elist[i].size();
    }
  }

  vl c(n - 1, -1);
  queue<ll> que;
  que.push(maxi);
  // unordered_set<ll> uu;
  // REP(x, 1, colors + 1) uu.insert(x);
  // vector<unordered_set<ll>> unused(n, uu);
  // rep(i, n) { unused[i] = uu; }
  vector<vector<bool>> used(n, vector<bool>(colors, false));

  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    queue<ll> unused;
    for (auto& ei : elist[u]) {
      // if (u == 4) cerr << ei << endl;
      if (c[ei] > 0) {
        // unused[u].erase(unused[u].find(c[ei]));
        used[u][c[ei] - 1] = true;
        continue;
      }

      // assign color
      ll c0 = -1;
      rep(x, colors) {
        if (!used[u][x]) {
          c0 = x + 1;
          break;
        }
      }
      // ll c0 = *unused[u].begin();
      c[ei] = c0;
      used[u][c0 - 1] = true;
      // unused[u].erase(unused[u].begin());

      ll a = edges[ei][0], b = edges[ei][1];
      ll v = a;
      if (a == u) {
        v = b;
      }
      used[v][c0 - 1] = true;
      elist[v].erase(elist[v].find(ei));
      if (elist[v].size() > 0) {
        que.push(v);
      }
    }
  }
  cout << colors << endl;
  rep(i, n - 1) { cout << c[i] << endl; }
  return 0;
}


Measured memory_bytes: 324276
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;
	multiset<int,greater<int> > a;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin >> tmp;
		a.insert(tmp);
	}

	vector<long long> pow2;
	for(int i=0;i<1000;i++)
	{
		pow2.push_back(pow(2,i));
		if(pow(2,i)>10000000000)break;
	//	cout << pow2[i] << endl;
	}

	int cnt=0;
	while(true)
	{
		auto itr=a.begin();
		if(itr==a.end())break;
		int now=*itr;
		a.erase(itr);
	//	cout << now << endl;
		int target=0;
		for(int i=0;i<pow2.size();i++)
			if(pow2[i]>now)
			{
				target=pow2[i];
				break;
			}
		auto finditr=a.find(target-now);
		if(finditr==a.end())
			continue;
		else
		{
			cnt++;
			a.erase(finditr);
			cerr << now << " " << target-now << endl;
		}

	}

	cout << cnt << endl;




}

Measured memory_bytes: 9600
#include<cstdio>
#include<iostream>

using namespace std;
#define INF 1500000


int main(void) {

	while (1) {
		int max = INF, min = 0;
		int floor, n, book[102] = { 0 };
		cin >> floor >> n;

		if (floor == 0)return 0;

		for (int i = 0; i < n; i++) {
			cin >> book[i];
		}
		while (max - min > 1) {
			int count = floor;
			int  mid = (max + min) / 2;
			int length = mid;
			int i = 0;
			while (count != 0 && i < n) {
				if (length >= book[i]) {
					length -= book[i];
					i++;
				}
				else {
					length = mid;
					count = count - 1;
				}
			}	
				if (count != 0) {
					max = mid;
				}else {
					min = mid;
				
			}
		}
		cout << max << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

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

        int K = scanner.nextInt();
        String S = scanner.next();

        if (S.length() <= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }
    }
}


Measured memory_bytes: 38448
#include <cstdio>
#define mod 1000000007
typedef long long LL;
const int maxn = 100000 + 10;

int main() {
	int a,b;
	scanf("%d %d",&a,&b);
	if((a+b)%3==0||a%3==0||b%3==0) {
		printf("Possible");
	}
	else {
		printf("Impossible");
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int x,i;
	cin>>x>>i;
	string ans="No";
  for(int j=0;j<=x;j++)
  {
    int k=j*2+(x-j)*4;
    if(k==i)
      ans="Yes";
  }
  cout<<ans;

}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int T = 200000;
int aa[T];
int main() {
	int k, n; cin >> k >> n;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	int ans = aa[n - 1] - aa[0];
	for (int i = 1; i < n; i++)
		ans = min(ans, aa[i - 1] + k - aa[i]);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int A, B, K; cin >> A >> B >> K;
  
  repi(i,A,min(B,A+K-1)) {
    cout << i << endl;
  }
  
  repi(i,max(B-K+1,A+K),B) {
    cout  << i << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dp[2000][2000];
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h,w;
    cin >> h >> w;
    rep(i,h){
        rep(j,w){
            dp[i][j] = 1e9;
        }
    }
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    queue<P> que;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                que.push(P(i,j));
                dp[i][j]=0;
            }
        }
    }
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int val = dp[p.first][p.second];
        rep(i,4){
            if (p.first + dy[i] >= h || p.first + dy[i]<0){
                continue;
            }
            if(p.second+dx[i]>=w || p.second+dx[i]<0){
                continue;
            }
            if(dp[p.first+dy[i]][p.second+dx[i]]>val+1){
                dp[p.first + dy[i]][p.second + dx[i]] = val + 1;
                que.push(P(p.first+dy[i],p.second+dx[i]));
            }
        }
    }
    int mx = 0;
    rep(i,h){
        rep(j,w){
            mx = max(mx,dp[i][j]);
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 17680
n = int(input())
hs = list(map(int, input().split()))

if n == 1:
    print("Yes")
    exit()

hs[0] -= 1
for i in range(n-1):
    if hs[i] < hs[i+1]:
        hs[i+1] -=1
    elif hs[i] > hs[i+1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 14252
object Main extends App{
  import scala.io.StdIn.readLine
  import scala.io.StdIn.readInt
  
  val m = readLine.split(" ")(2).toInt
  val a = readLine.split(" ").map(_.toLong)
  val b = readLine.split(" ").map(_.toLong)
  
  val coupons = (1 to m).map(x => readLine).map(_.split(" ").map(_.toInt))
  val buys = coupons.map(x => (a(x(0) - 1) + b(x(1) - 1) - x(2)))
  println( ((a.min+b.min) +: buys).min.toString)
}


Measured memory_bytes: 79892
import javax.annotation.processing.SupportedSourceVersion;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] h = sc.nextIntArray(n);
    boolean[] isGood = new boolean[n];
    Arrays.fill(isGood, true);
    int[] a = new int[m];
    int[] b = new int[m];
    for (int i = 0; i < m; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
    }
    for (int i = 0; i < m; i++) {
      if (h[a[i]] < h[b[i]]) {
        isGood[a[i]] = false;
      } else if (h[a[i]] > h[b[i]]) {
        isGood[b[i]] = false;
      } else {
        isGood[a[i]] = false;
        isGood[b[i]] = false;
      }
    }
    int sum = 0;
    for (boolean good : isGood) {
      sum += good ? 1 : 0;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 49476
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int answer[100000] = {};

int main(void) {

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		answer[a - 1] = i + 1;
	}

	for (int i = 0; i < n; i++) {
		cout << answer[i] << " ";
	}


	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main(){
    int n,m;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>m;
        if(a[m]==0)a[m]=1,ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j

int main(){
    int n; cin >> n;
    int cnt[n];
    rep(i,n) cnt[i]=0;
    int a[n],b[n];
    vector<vector<int>> to(n);
    map<P,int> mp;
    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        cnt[a[i]]++; cnt[b[i]]++;
        to[a[i]].pb(b[i]);
        to[b[i]].pb(a[i]);
    }
    int res=0;
    rep(i,n){
        if(cnt[res]<cnt[i]) res=i;
    }
    cout << cnt[res] << endl;
    
    queue<P> q;
    vector<bool> visit(n,0);
    q.push({res,-1});
    visit[res]=1;
    while(!q.empty()){
        P d=q.front(); q.pop();
        int i=1;
        for(int u:to[d.fi]){
            if(visit[u]) continue;
            visit[u]=1;
            if(i==d.se) i++;
            mp[{min(d.fi,u),max(d.fi,u)}]=i;
            q.push({u,i});
            i++;
        }
    }
    rep(i,n-1){
        cout << mp[{a[i],b[i]}] << endl;
    }
    return 0;
}


Measured memory_bytes: 13440
use proconio::{input, fastout};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


#[fastout]
fn main() {
    input!{
        n: usize,
        h: [usize;n],
    }
    let mut active = 0;
    let mut ans = 0;
    for i in 0..n {
        if active >= h[i] {
            active = h[i];
        } else {
            ans += h[i] - active;
            active = h[i];
        }
    }
    println!("{}", ans);
    
}


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

int main() {
  int N,a,b,c,d;
  cin >> N;
  d=N % 10;
    c=(N/10)%10;
    b=(N/100)%10;
    a=(N/1000)%10;
      
  if ((a==b&&b==c)||(b==c&&c==d)) {
    cout << "Yes" << endl;
  }
  else{
    cout<< "No"<<endl;
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const int N = ((int)1e5) + 5;
const int M = ((int)1e3) + 5;
typedef long long int lli;

int n,k;
int ans;

int main ()
{
	fast;
	//freop;
	cin >> n >> k;
	for (int i = 1,a = 0; i <= n; i++)
		cin >> a,ans += (a >= k);
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[105];
int dp[100005];
int main() {
	scanf("%d%d",&n,&k);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	dp[0]=2;
	for(int i=1; i<=k; i++) {
		dp[i]=2;
		for(int j=0; j<n; j++) {
			if(a[j]<=i && dp[i-a[j]]==2) dp[i]=1;
		}
	}
	if(dp[k]==1) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    double ans = 0.0;
    for(int i = 0; i < n; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        } else {
            ans += x*380000;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

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

  int n;
  string s, t;
  cin >> n >> s >> t;

  string res = "";
  rep(i, n) {
    res += s[i];
    res += t[i];
  }

  
  cout << res << endl;
}


Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

//
// solution 
//
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        S: chars,
        K: usize,
    }

    for s in S.iter() {
        K -= 1;
        if *s as u32 - '1' as u32 > 0 {
            println!("{}", s);
            return
        } else if K == 0 {
            println!("1");
            return
        }
    }
}


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

 
int main(){
	int n;
	map<int,int>mp;
	cin>>n;
	vector<int>a(n);
	rep(i,n-1){
		cin>>a[i];
		mp[a[i]]++;
	}
	// for(auto p:mp){
	// 	cout<<p.second<<endl;
	// }
	for(int i=1;i<=n;++i){
		cout<<mp[i]<<endl;
	}
}

Measured memory_bytes: 13492
#include <iostream>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
//#include <unordered_map>
#include <stack>
#include <cstdlib>
#include <numeric>
#include <cassert>
#include <complex>
using namespace std;
#define maxn 3000007
#define maxm 400007
#define maxq 1000007
#define maxl 1234
#define modn 998244353
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define scanl2(a,b) scanf("%lld%lld",&a,&b)
#define scans(a) scanf("%s",a)
#define scans2(a,b) scanf("%s%s",a,b)
#define scand(a) scanf("%lf",&a)
#define scan2(a,b) scanf("%d%d",&a,&b)
#define scand2(a,b) scanf("%lf%lf",&a,&b)
#define scan3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scan5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define print(a) printf("%d\n",a);
#define printl(a) printf("%lld\n",a);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>= b;i--)
#define fscan(a) fscanf(stream,"%d", &a);
#define mp      make_pair	
#define pb      push_back
#define eb      emplace_back
#define mm(a,b) memset(a,b,sizeof a)
#define log2(n) (double)(log(n) / log(2.0))
#define _crt_disable_perfcrit_locks
#define bll __int128
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef pair <char, int> pci;
typedef complex<double> cd;
typedef vector<complex<double> > vcd;

const double eps = 1e-8;
const double PI = 2 * acos(0.0);

int cc, bb; char ch; inline int F() {
	while (ch = getchar(), (ch < 48 || ch> 57) && ch != '-'); ch == '-' ? cc = bb = 0 : (cc = ch - '0', bb = 1);
	while (ch = getchar(), ch > 47 && ch < 58)cc = (cc << 1) + (cc << 3) + (ch ^ 48); return bb ? cc : -cc;
}
void write(int x) {
	int y = 10, len = 1;
	while (y <= x) { y *= 10; len++; }
	while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}
int main() {
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//FILE* stream = fopen("L:/20.in", "rb+")
	int x;
	cin >> x;
	int res = x / 500 * 1000 + (x % 500) / 5 * 5;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int c1,c5,c10,c50,c100,c500;
scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);
if(c1+5*c5+10*c10+50*c50+100*c100+500*c500 >=1000)printf("1\n");
else printf("0\n");
return 0;
}
  

Measured memory_bytes: 584
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
j=0
A=int(input())
B=int(input())
ans=[1,2,3]
#print(ans)
for j in range(100):
 for i in range(3):
  if ans[i]!=A and ans[i]!=B:
      print(ans[i])
      sys.exit()

#    i=i+1
#    break
  #elif ans[i]==B:
#     i=i+1
#     break
#print(ans[i])
#sys.exit()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int count = 0;
            for(int i =0; i<=(S.Length-1)/2; i++)
            {
                if(S[i] != S[S.Length - 1 - i])
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }

    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


const int MAX = 910000;


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

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

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

int main(){
    ll S;
    cin>>S;
    if(S<3){
        cout<<0<<endl;
        return 0;
    }
      COMinit();

    ll tmmp = (ll)(1.0*S/3.0);
    ll sum=0;
    for(ll i=1;i<=tmmp;i++){
        ll ama = S-3*i;
        if(ama<0){
            break;
        }
        sum += COM(i+ama-1,ama);
        sum=sum%MOD;
    }











cout<<sum%MOD<<endl;
    
}

Measured memory_bytes: 24908
#include<iostream>

using namespace std;

int main() {
    string S;

    cin >> S;

    for(int i = 0; i < S.length() - 1; i++){
        if(S[i] == S[i + 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    n = n+n;
    vector<int> a(n);
    for (int i=0; i<n; i++)     cin>>a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    for (int i=0; i<n; i+=2)    ans += a[i];

    cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N, M;

int main() {
    map<string, int> mp;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        string t;
        cin >> t;
        mp[t]--;
    }

    int mx = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int val = itr->second;
        mx = max(mx, val);
    }

    cout << ((mx > 0) ? mx : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	int k, x;
	cin >> k >> x;
	deque<int> v;
	v.push_back(x);
	rep(i, k - 1) {
		v.push_front(x - i - 1);
		v.push_back(x + i + 1);
	}
	rep(i, v.size()) cout << v.at(i) << " ";
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size() - 1; ++i) if (s[i] != s[i + 1]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;

int main() {
  string s;
  cin>>s;
  int N=s.size();
  for(int i=0;i<N;i++){
    if(i+1<N&&s[i]==s[i+1]){cout<<i+1<<" "<<i+2<<endl;return 0;}
    if(i<N-2&&s[i]==s[i+2]){cout<<i+1<<" "<<i+3<<endl;return 0;}
  }
  cout<<"-1 -1"<<endl;
  return 0;  
}

Measured memory_bytes: 3704
/*
    @uthor: Amit Kumar
    user --> GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define int    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"

vector<int> arr;
void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        arr.push_back(count);
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            arr.push_back(count);
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        arr.push_back(1);
} 

void virus(){
        int n;
        cin>>n;
        factorize(n);
        int pre[100000];
        pre[0]=1;
        for(auto i=1;i<100000;i++){
            pre[i] = pre[i-1] + (i+1);
        }
        int cnt = 0;
        for(auto i:arr){
            //cout<<i<<endl;
            cnt += (upper_bound(pre,pre+100000,i) - pre);
        } 
        cout<<cnt;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    int t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 4480
class nCrMod():
    def __init__(self, mod):
        self.mod = mod
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]

    def prep(self, n):
        mod = self.mod
        f, fi = self.fac[-1], self.finv[-1]
        for i in range(len(self.fac), n + 1):
            fn = f * i % mod
            v = -self.inv[mod % i] * (mod // i) % mod
            fin = fi * v % mod
            f, fi = fn, fin
            self.fac.append(f)
            self.finv.append(fi)
            self.inv.append(v)

    def __call__(self, n, r):
        if len(self.fac) <= n:
            self.prep(n)
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.mod

def main():
    mod = 10 ** 9 + 7
    nCr = nCrMod(mod)
    N, K = map(int, input().split())
    r = 0
    for i in range(1, K + 1):
        if i - 1 > N - K:
            print(0)
            continue
        print(nCr(K - 1, i - 1) * nCr(N - K + 1, i) % mod)
main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, sum=0;
	cin >> n;
	vector<lli> b(n);
	vector<lli> a(n+1);
	loop(i, 1, n) cin >> b[i];
	a[1] = b[1];
	a[n] = b[n-1];
	sum = a[1]+a[n];

	loop(i, 2, n){
		a[i] = Min(b[i-1], b[i]);
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read_=sys.stdin.buffer.readline

N=int(read_())
A=input().split()

if len(A)==1:
    print(A[0])
    exit()

B1=A[::2]
B2=A[1::2]

if N%2==0:
    B2.reverse()
    B2.extend(B1)
    print(' '.join(B2))
else:
    B1.reverse()
    B1.extend(B2)
    print(' '.join(B1))

Measured memory_bytes: 26472
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, a[N], ans = 1, x;

int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    ull n2, n1;
    ull n;
    ull r;
    cin>>n;
    n1  = 1;
    r = 1;

    for(ull i = 2; i<=n; i++)
    {
      r = (r*i)%mod;
       //r = r%mod;
    }
    cout<<r<<endl;






    return 0;
}



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	ll W=in<ll>(),H=in<ll>();
	ll x=in<ll>(),y=in<ll>();
	double cw=W/2.0,ch=H/2.0;
	bool same = false;
	if(abs(x-cw)<1e-9 && abs(y-ch)<1e-9) same = true;

	double S = W*H;
	S *= 0.5;

	//std::cout << std::cout.precision(12);
	printf("%.12lf %d\n",S,same?1:0);
	//cout << S  << ' ' << (same ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int x, y;
	int total;
	int m = 0;

	while(cin >> x >> y){

		total = x + y;

		while(total != 0) {
			total /= 10;
			m++;
		}

		cout << m << endl;
		m = 0;

	}
}

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

const int mod = 2019;

int main() {
    int64_t L, R;
    cin >> L >> R;
    if(R - L >= mod) {
        cout << 0 << '\n';
        return 0;
    }
    int64_t ans = mod;
    for(int64_t i = L; i < R; ++i) {
        for(int j = L + 1; j <= R; ++j) {
            ans = min(ans, i * j % mod);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> board(H, vector<char>(W));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            cin >> board[i][j];
        }
    }

    vector<vector<char>> rows;
    for (const auto &row : board)
    {
        if (find(row.begin(), row.end(), '#') != row.end())
        {
            rows.push_back(row);
        }
    }

    vector<int> colIndices;
    for (int col = 0; col < W; ++col)
    {
        bool shouldAdd = false;
        for (int i = 0, n = static_cast<int>(rows.size()); i < n; ++i)
        {
            if (rows[i][col] == '#')
            {
                shouldAdd = true;
                break;
            }
        }
        if (shouldAdd)
        {
            colIndices.push_back(col);
        }
    }

    vector<string> ans;
    for (const auto &row : rows)
    {
        string ansRow;
        for (const int &col : colIndices)
        {
            ansRow.push_back(row[col]);
        }
        ans.push_back(ansRow);
    }

    for (const auto ansRow : ans)
    {
        cout << ansRow << endl;
    }
}

Measured memory_bytes: 256
(let ((lst (loop for i from 1 to (read)	collect (= i (read)))))
  (labels ((f (count lst)
	     (cond ((null lst) count)
		   ((null (car lst)) (f count (cdr lst)))
		   (t (f (1+ count) (cddr lst))))))
    (princ (f 0 lst))))

Measured memory_bytes: 59752
#include <iostream>
#include <cmath>

using namespace std;

auto gcd(long long a, long long b) {
    while(true) {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

auto lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main() {
  long a ,b, c, d;
  long long i,j,k,answer,div_num;
  
  cin >> a >> b >> c >> d;
  
  long long num = (b - a + 1);

  i = b/c - (a-1)/c;
  j = b/d - (a-1)/d;
  k = b/lcm(c,d) - (a-1)/lcm(c,d);
  
  div_num = i + j - k;
  answer = num - div_num;
  
  cout << answer;
  
  return 0;
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, q; cin >> n >> q;
	vvi g(n);
	for (int i = 0; i + 1 < n; i++) {
		int u, v; cin >> u >> v; u--, v--;
		g[u].push_back(v); g[v].push_back(u);
	}
	vi pda(n + 1);
	vi visTime(n), fiTime(n);
	int timer = 0;
	function<void(int, int)> dfs = [&] (int u, int p) {
		visTime[u] = timer++;
		for (int v : g[u]) if (v - p) dfs(v, u);
		fiTime[u] = timer;
	};
	dfs(0, -1);
	for (int i = 0; i < q; i++) {
		int u, w; cin >> u >> w;
		u--;
		pda[visTime[u]] += w;
		pda[fiTime[u]] -= w;
	}
	vi ans(n + 1);
	partial_sum(pda.begin(), pda.end(), ans.begin());
	for (int i = 0; i < n; i++) cout << ans[visTime[i]] << ' ';
	cout << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 32128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int mod[11][5] = {
	{ 4, 2, 0, 9, 7},
	{ 1,10, 8, 6, 4},
	{ 9, 7, 5, 3, 1},
	{ 6, 4, 2, 0, 9},
	{ 3, 1,10, 8, 6},
	{ 0, 9, 7, 5, 3},
	{ 8, 6, 4, 2, 0},
	{ 5, 3, 1,10, 8},
	{ 2, 0, 9, 7, 5},
	{10, 8, 6, 4, 2},
	{ 7, 5, 3, 1,10}
};  

int cnt[11];

int main()
{
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < 11; ++i){
		for (int j = 0; j < 5; ++j){
			++cnt[mod[i][j]];
		} // end for
	} // end for

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	n -= 2;
	int res = cnt[k]*(n/11);
	n = n % 11;
//	cerr << "res: " << res << endl;
//	cerr << "n: " << n << endl;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < 5; ++j){
			res += (mod[i][j] == k);
		} // end for
	} // end for
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(), std::greater<int>())
#define swap(a, b) \
  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
#define vi vector<int>
using namespace std;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int N, X, D;

int calculate_choco(int a) {
  int cnt = 0;
  int d = 1;
  while(1) {
    if(d > D) {
      break;

    }
    cnt += 1;
    d += a;
  }
  return cnt;
}

int main() {

  
  vi A;
  cin >> N >> D  >> X;
  
  REP(i, N) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  int s = 0;
  for(auto a: A) {
    s += calculate_choco(a);
  }
  cout << X + s << endl;

  
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int S,a,b;
scanf("%d",&S);

a = S/100;
b = S - a*100;

if(1<=a && a<=12){
  if(1<=b && b<=12){
    printf("AMBIGUOUS");
  }else{
    printf("MMYY");
  }
}else{
  if(1<=b && b<=12){
    printf("YYMM");
  }else{
    printf("NA");
  }
}
return(0);
}


Measured memory_bytes: 128
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,m,dp[1 << 17],ans,a,b;
vector<int>vec[1 << 17];

void dfs(int nod)
{
	dp[nod] = 1;
	int mx = 0;
	for(auto it : vec[nod])
	{
		if(!dp[it]) dfs(it);
		mx = max(mx,dp[it]);
	}
	dp[nod] += mx;
}

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n >> m;
	for(int i = 1;i <= m;i++)
	{
		cin >> a >> b;
		vec[a].pb(b);
	}
	for(int i = 1;i <= n;i++)
	{
		if(!dp[i])
		{
			dfs(i);
		}
	}
	for(int i = 1;i <= n;i++)
	{
		ans = max(ans,dp[i]);
	}
	rc(ans - 1);
}

Measured memory_bytes: 8192
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int n,k;
vector<int> x,y;
long long  ans;

int main(){
    int xt[51], yt[51];
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> xt[i] >> yt[i];
        x.push_back(xt[i]);
        y.push_back(yt[i]);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    
    ans = 1LL * (x[n-1] - x[0]) * (y[n-1] - y[0]);
    for(int xi = 0; xi < n; xi++){
        for(int xj = xi + 1; xj < n; xj++){
            for(int yi = 0; yi < n; yi++){
                for(int yj = yi+1; yj < n; yj++){
                    int c=0;
                    for(int i = 0; i < n; i++){
                        if(x[xi] <= xt[i] && x[xj] >= xt[i] && y[yi] <= yt[i] && y[yj] >= yt[i])    c++;
                    }
                    if(k <= c){
                        ans = min(ans,1LL * (x[xj]-x[xi]) * (y[yj]-y[yi]));
                    }
                }
            }
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 256