akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline void chmin(T& a,T b){if(a>b)a=b;}
template<class T> inline void chmax(T& a,T b){if(a<b)a=b;}

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,i;
	cin>>n;
	long long int dp[n];
	int h[n];
	for(i=0;i<n;i++)cin>>h[i];
	for(i=0;i<n;i++)dp[i]=1000000;
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long 
const int maxn = 1e5+10;
int vis[maxn];
int a[maxn];
int n,m;
char c[20];
int main()
{
    scanf("%d%d",&n,&m);
    int ans=0,bns=0,tmp;
	while(m--)
    {
    	scanf("%d",&tmp);
    	scanf("%s",c);
    	if(c[0]=='A')
    	{
    		if(vis[tmp]) continue;
    		ans++;
    		bns+=a[tmp];
    		vis[tmp]=1;
		}
		else
		{
			a[tmp]++;
		}
	}
	printf("%d %d",ans,bns);
    return 0;
} 

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class abc100a {
public:
    void solve(istream& in, ostream& out) {
        int A, B;
        in >> A >> B;
        if (A <= 8 && B <= 8) {
            out << "Yay!\n";
        } else {
            out << ":(\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	abc100a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  int l[50];
  for (int i=0; i<n; i++) {
    cin>>l[i];
  }
  sort(l,l+n);
  reverse(l,l+n);
  int ans=0;
  for (int i=0; i<k; i++) {
    ans+=l[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from heapq import heappush, heappushpop

def resolve():
    it = map(int, sys.stdin.read().split())

    T = next(it)
    ans = []
    for i in range(T):
        N = next(it)

        val = 0; a1 = []; a2 = []
        for i, v1, v2 in ((next(it), next(it), next(it)) for i in range(N)):
            diff = v1 - v2
            if diff == 0:
                val += v1
            elif diff > 0:
                a1.append((i, diff))
                val += v2
            else:
                a2.append((N-i, -diff))
                val += v1
        a1.sort(); a2.sort()

        for aa in (a1, a2):
            dq = []
            for i, diff in aa:
                ld = len(dq)
                if ld < i:
                    heappush(dq, diff)
                else:
                    diff = heappushpop(dq, diff)

            val += sum(dq)

        ans.append(val)


    print(*ans, sep="\n")



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 124604
package main

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

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

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N, _ := io.nextInt()
	V := make([]int, N)
	C := make([]int, N)
	for i := 0; i < N; i++ {
		V[i], _ = io.nextInt()
	}
	for i := 0; i < N; i++ {
		C[i], _ = io.nextInt()
	}
	payment := 0
	for i := 0; i < N; i++ {
		if dif := V[i] - C[i]; dif > 0 {
			payment += dif
		}
	}
	io.PutInt(payment)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, x) for (int i = x; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 300;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    vector<double> p(n + 1);
    in(p, 1);

    vector<vector<ld>> dp(n + 1, vector<ld>(n + 1, 0.0));

    dp[0][0] = 1.0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i][j] += dp[i - 1][j] * (1.0 - p[i]);
            if (j > 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
        }
    }

    ld answ = 0;

    for (int k = n / 2 + 1; k <= n; ++k) {
        answ += dp[n][k];
    }

    cout.precision(10);
    cout << fixed << answ;
}

Measured memory_bytes: 141056
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

L, R, d = MI()

cnt = 0

for i in range(L,R+1):
    if i % d == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 26996
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	static String F = ".#";
	
	static boolean trial(int l, int r, int t, char[][] map)
	{
		for(int i = 0;i < 2;i++){
			for(int j = 0;j < 2;j++){
				map[0][t] = F.charAt(i);
				map[1][t] = F.charAt(j);
				for(int k = l;k < r;k++){
					out.print(map[0][k]);
				}
				out.println();
				for(int k = l;k < r;k++){
					out.print(map[1][k]);
				}
				out.println();
				out.flush();
				char res = in.next().charAt(0);
				if(res == 'T'){
					return true;
				}
			}
		}
		return false;
	}
	
	static void solve()
	{
		int n = ni();
		char[][] map =  new char[2][400];
		int l = 200, r = 201;
		trial(l, r, l, map);
		while(true){
			if(!trial(l, r+1, r, map))break;
			r++;
		}
		while(true){
			if(!trial(l-1, r, l-1, map))break;
			l--;
		}
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 13088
n = int(input())
word_list = []
ans = "Yes"
preword = input()
word_list.append(preword)
for i in range(n-1):
    w = input()
    if w in word_list:
        ans = "No"
    if preword[-1] != w[0]:
        ans = "No"
    word_list.append(w)
    preword = w
print(ans)

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll K;
  cin>>K;
  ll N = 50LL;
  vector<ll> ans(N);
  ll t = K/N;
  ll s = K%N;
  for(ll i = 0; i < N; i++){
    if(i<s) ans[i]=N-1+t+N-(s-1);
    else ans[i]=N-1+t-s;
  }
  cout<<N<<endl;
  for(auto x:ans) cout<<x<<" ";
  cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    ll a,b,x;
    cin>>a>>b>>x;
    if(a!=0)cout<<b/x-(a-1)/x<<endl;
    else if(a==0&&b==0)cout<<1<<endl;
    else cout<<b/x+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  cin>>N;
  if (N%2== 1){
    cout << N*2 << endl;
  }else{
    cout << N << endl;
  }
  return 0;
}



Measured memory_bytes: 256
program eee
implicit none
 
integer(8) :: n, w, i, j
integer(8),allocatable,dimension(:) :: ww, vv
integer(8),allocatable,dimension(:,:) :: dp
! 初期値の設定
read*, n, w
allocate(ww(n),vv(n))
do i=1, n
	read*, ww(i), vv(i)
end do
allocate(dp(0:n,0:sum(vv)))
dp=w*n+1
dp(0,0)=0
! end 初期値の設定
 
do i=1,n
	do j=0,sum(vv)
		if(j>=vv(i)) then					!追加可能パターン
        	dp(i,j)=dp(i-1,j-vv(i))+ww(i)	!i-1の場合の、価値j-v(i)から参照
        end if
        dp(i,j)=min(dp(i,j),dp(i-1,j))		!追加したものとしていないものの比較を行う
    end do
end do
 
do j=sum(vv),0,-1
    if(dp(n,j)<=w) then
    	write(*,'(i0)') j
        return
    end if
end do
 
end program


Measured memory_bytes: 79104
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	long k = read.to!long;
	
	int[] as;
	foreach(i; 0 .. n) as ~= read.to!int;
	log("as:", as);
	
	int[][int] aq;
	foreach(int i, a; as){
		if(a !in aq) aq[a] = [];
		aq[a] ~= i;
	}
	log("aq:", aq);
	
	int[int] next; // next[i] = i2 ならば i は i2 でクリアされる
	bool[int] over; // over[i] は i はその周期の中でクリアされない
	int[] aqks = aq.keys;
	foreach(a; aqks){
		for(int ix = 0; ix < aq[a].length; ix ++){
			if(ix < aq[a].length - 1){
				next[aq[a][ix]] = (aq[a][ix + 1] + 1) % n;
				over[aq[a][ix]] = 0;
			}
			else{
				next[aq[a][ix]] = (aq[a][0] + 1) % n;
				over[aq[a][ix]] = 1;
			}
		}
	}
	log("next:", next);
	log("over:", over);
	
	int[int] last; // last[j] は j ( = 0 , ...) 回目の周期が実質どこから始まるか (=最後にクリアしたときの i に対して、i + 1)
	int cnt = 0; // 何周でもとにもどるか
	for(int i = 0; ; i = next[i]){
		if(over[i]){
			last[cnt] = i;
			cnt += 1;
		}
		if(next[i] == 0){
			last[cnt] = i;
			cnt += 1;
			break;
		}
	}
	log("last:", last);
	log("cnt:", cnt);
	
	int k2 = (k % cnt).to!int; // 実質、何周すればよいか
	log("k2:", k2);
	
	if(k2 == 0){
		"".writeln;
		return;
	}
	
	int i2 = last[k2 - 1]; // 実質、ここから始める
	log("i2:", i2);
	
	int[] ans;
	for(int i = i2; i < n; ){
		if(over[i]){
			ans ~= as[i];
			i += 1;
		}
		else i = next[i];
		if(i == 0) break;
	}
	
	ans.map!(to!string).array.join(" ").writeln;
}
	


Measured memory_bytes: 82704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
vector <vll> g;
vector <bool> vis;
vll ts, dp;
void dfs(ll cur, ll p)
{
    if(!vis[cur])
    {
        vis[cur] = 1;
        if(p)
            dp[cur] = 0;
        for(auto x : g[cur])
        {
            dfs(x, p);
            if(p)
            {
                // cout << cur << " " << x << endl;
                dp[cur] = max(dp[cur], 1 + dp[x]);
            }
        }
        if(!p)
            ts.pb(cur);
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, m, i, u, v;
    cin >> n >> m;
    g.resize(n + 1);
    dp.resize(n + 1);
    for(i = 0; i < m; i++)
    {
        cin >> u >> v;
        g[u].pb(v);
    }
    vis.resize(n + 1, 0);
    for(i = 1; i <= n; i++)
        dfs(i, 0);
    reverse(all(ts));
    fill(all(vis), 0);
    for(i = 1; i <= n; i++)
        dfs(i, 1);
    ll ans = 0;
    for(i = 1; i <= n; i++)
        ans = max(dp[i], ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10360
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll a[5];for(ll i=0;i<5;i++)cin>>a[i];
    ll k;cin>>k;
    cout<<(a[4]-a[0]<=k?"Yay!":":(");
}





Measured memory_bytes: 256
from operator import itemgetter


def main():
    n = int(input())
    ab = []
    for _ in range(n):
        a, b = list(map(int, input().split()))
        ab.append((a, b))

    ab = sorted(ab, key=itemgetter(1))

    acc = 0
    answer = 'Yes'
    for a, b in ab:
        acc += a
        if acc > b:
            answer = 'No'
            break

    print(answer)


main()

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

using namespace std;

const int maxn = 100010;
int n, ans = 0;
char m[maxn];

int main()
{
    cin>>m;
    n = strlen(m);
    for(int i = 0; i <= n / 2 - 1; i ++) {
        if(m[i] != m[n - i - 1]) ans ++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<pair<int,int>> vp(n);
  for(int i = 0;i < n;i++){
    cin >> vp[i].second >> vp[i].first;
  }
  sort(begin(vp), end(vp), greater<pair<int,int>>());

  long long tmp_sum = 0;
  long long num = 0;
  map<int,int> M;
  stack<int> s;
  for(int i = 0;i < k;i++){
    if (M.count(vp[i].second) == 0){
      num++;
    } else {
      s.push(vp[i].first);
    }
    tmp_sum += vp[i].first;
    M[vp[i].second]++;
  }
  long long ans = tmp_sum + num*num;
  for(int i = k;i < vp.size() && num != k;i++){
    //pop
    if (M.count(vp[i].second) == 0){
      num++;
      int tmp = s.top();s.pop();
      tmp_sum -= tmp;
      tmp_sum += vp[i].first;
      M[vp[i].second]++;
      ans=  max(ans, tmp_sum + num * num);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4096
n,c,k = gets.split.map(&:to_i)

arr=[]

n.times{
    
    arr<<gets.to_i}
arr = arr.sort



ans=0

now=0
bus = []
busnow = 0
i = 0
n.times{
    
 now = arr[i]
 
 if bus[0] && bus[0]+k<now
     
     ans+=1
     bus = [arr[i]]
     busnow = 1
     
     
elsif  bus[0] && bus[0]+k==now
     
     ans+=1
     bus = []
     busnow = 0
     
     
else 
    bus<<arr[i]
    busnow+=1
     
end
 
 
 if busnow>=c
     ans+=1
     busnow = 0
     bus = []
     
 end
 
 
 i+=1
 
    
    
    
}

if busnow>0
  ans+=1
end


p ans
    
    

Measured memory_bytes: 4656
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int c = 0;
		if(A > B) { c = A; A--; }
		else { c = B; B--; }
		System.out.println(c + Math.max(A, B));
	}
}

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

using namespace std;

map<int,int> m;
int n;
vector<int> v;
long long ans;

int main(){
	cin>>n;
	int i,j;
	int x;
	for (i=1;i<=n;i++){
		cin>>x;
		if (m[x]==0)v.push_back(x);
		m[x]++;
	}
	for (i=0;i<v.size();i++){
		x=v[i];
		if (m[x]>=x)ans+=m[x]-x;
		else ans+=m[x];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);



int main(){
    ll n;cin >>n;
    vector<mint> v(max_n);
    vector<mint> dp(n+1,0);
    dp[0]=1;
    ll pre=-1;
    rep(i,n){
        ll a;cin >> a;
        dp[i+1]=dp[i];
        if(pre==a)continue;
        dp[i+1]+=v[a];
        v[a]=dp[i+1];
        pre=a;
    }
    cout << dp[n] <<endl;
}

Measured memory_bytes: 6528
// no proof is included. may have unused libraries. may have unused variables. possibly dirty code - contest mode

#include <iostream> // std::cin, std::cout
#include <cstring> // std::memset()
#include <algorithm> // std::max_element(), std::min_element(), std::reverse(), std::sort(), std::__gcd()

using namespace std;

bool debug = true;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int p[n];
    int min = 2e5 + 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        if (p[i] < min) {
            min = p[i];
            ans ++;
        }
    }

    cout << ans << endl;
    
    return 0;
}


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

// 入力
int H, W;
vector<vector<int>> field;

// 探索
void dfs(int h, int w) {
    field[h][w] = 0;

    // 八方向を探索
    for (int dh = -1; dh <= 1; ++dh) {
        for (int dw = -1; dw <= 1; ++dw) {
            int nh = h + dh, nw = w + dw;

            // 場外アウトしたり、0 だったりはスルー
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (field[nh][nw] == 0) continue;

            // 再帰的に探索
            dfs(nh, nw);
        }
    }
}

int main() {
    // 入力受け取り
    while (cin >> W >> H) {
        if (H == 0 || W == 0) break;
        field.assign(H, vector<int>(W, 0));
        for (int h = 0; h < H; ++h) for (int w = 0; w < W; ++w) cin >> field[h][w];

        // 探索開始
        int count = 0;
        for (int h = 0; h < H; ++h) {
            for (int w = 0; w < W; ++w) {
                if (field[h][w] == 0) continue; // 残島じゃなかったらスルー
                dfs(h, w);
                ++count;
            }
        }
        cout << count << endl;
    }
}


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

int main() {
    long long N;
    cin >> N;
    for(int A=(int)sqrt(N); A >= 1; --A) {
        if(N % A == 0) {
            cout << (int)log10(N / A) + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
  
void leap_year(int start_year, int end_year);
  
int main(void)
{
    int start_year;
    int end_year;
    int i = 0;
    while(1) {
        scanf("%d %d", &start_year, &end_year);
        if (start_year == 0 && end_year == 0) {
            break;
        } else {
            if ( i == 1) {
                printf("\n");
            }
            leap_year(start_year, end_year);
            i = 1;
        }
    }
    return 0;
}
  
void leap_year(int start_year, int end_year)
{
    int n = 0;
    for (int year = start_year; year <= end_year; year++) {
        if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
            printf("%d\n", year);
            n++;
        }
    }
    if (n == 0) {
        printf("NA\n");
    }
}

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

int main () {
	int n;
	int cmp;
	scanf("%d", &n);
	char str[255];
	int ctr[10] = {0};
	
	for (int i = 0 ; i < n ; i++) {
		scanf("%s", &str);
		if (cmp = strcmp(str, "AC") == 0) {
			++ctr[1];
		}
		if (cmp = strcmp(str, "WA") == 0) {
			++ctr[2];
		}
		if (cmp = strcmp(str, "TLE") == 0) {
			++ctr[3];
		}
		if (cmp = strcmp(str, "RE") == 0) {
			++ctr[4];
		}
	}
	printf("AC x %d\n", ctr[1]);
	printf("WA x %d\n", ctr[2]);
	printf("TLE x %d\n", ctr[3]);
	printf("RE x %d\n", ctr[4]);
	return 0;
}

Measured memory_bytes: 1704
using System;
using System.Text;

namespace _017_CaesarCipher
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			int[,] pattern = { 
								 { 12, 3, 0 }, 
								 { -14, -23, 0 }, 
								 { 12, -1, 16 }, 
								 { -14, 25, -10 }, 
								 { 12, 7, -19 }, 
								 { -14, -19, 7 }, 
							 };

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int convertNum = 0;

				foreach (var item in inputStr.Split (' '))
				{
					//the
					if (item.Length == 3)
					{
						int[] chDistance = { item[0] - item[1], item[1] - item[2] };

						if (chDistance[0] == pattern[0, 0] || chDistance[1] == pattern[0, 1] &&
							chDistance[0] == pattern[1, 0] || chDistance[1] == pattern[1, 1]) 
						{
							convertNum = item[0] - 't';
							break;
						}
					}
					//this
					//that
					else if (item.Length == 4)
					{
						int chDistance = item[0] - item[1];

						if (chDistance == pattern[2, 0] || chDistance == pattern[3, 0]) 
						{
							int[] chDistance2 = { item[1] - item[2], item[2] - item[3] };

							if (chDistance2[0] == pattern[2, 1] || chDistance2[1] == pattern[2, 2] &&
								chDistance2[0] == pattern[3, 1] || chDistance2[1] == pattern[3, 2]) 
							{
								convertNum = item[0] - 't';
								break;
							}
							if (chDistance2[0] == pattern[4, 1] || chDistance2[1] == pattern[4, 2] &&
								chDistance2[0] == pattern[5, 1] || chDistance2[1] == pattern[5, 2]) 
							{
								convertNum = item[0] - 't';
								break;
							}
						}
					}
				}

				StringBuilder result = new StringBuilder (inputStr.Length);

				foreach (var item in inputStr)
				{
					if (char.IsLower (item))
					{
						int ch = item - convertNum;

						if (ch < 'a')
							ch += 26;
						else if ('z' < ch)
							ch -= 26;

						result.Append ((char) ch);
					}
					else
					{
						result.Append (item);
					}
				}

				Console.WriteLine (result.ToString ());
			}
		}
	}
}

Measured memory_bytes: 9004
/******************************************************************************

                              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>

using namespace std;

int main()
{
    long long n;
    cin>>n;
    cout<<(1000-n%1000)%1000;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <string>
using namespace std;

long long mypower(long long x, int y){
  long long result = 1;
  while(y > 0){
    result *= x;
    y--;
  }
  return result;
}


int main(){
  long long N;
  cin >> N;

  string S;
  cin >> S;

  long long alphabet[26] = {};
  for(int i=0;i<26;i++){
    alphabet[i] = 0;
  }

  for(int i=0;i<N;i++){
    if(S[i] == 'a'){
      alphabet[0]++;
    }else if(S[i] == 'b'){
      alphabet[1]++;
    }else if(S[i] == 'c'){
      alphabet[2]++;
    }else if(S[i] == 'd'){
      alphabet[3]++;
    }else if(S[i] == 'e'){
      alphabet[4]++;
    }else if(S[i] == 'f'){
      alphabet[5]++;
    }else if(S[i] == 'g'){
      alphabet[6]++;
    }else if(S[i] == 'h'){
      alphabet[7]++;
    }else if(S[i] == 'i'){
      alphabet[8]++;
    }else if(S[i] == 'j'){
      alphabet[9]++;
    }else if(S[i] == 'k'){
      alphabet[10]++;
    }else if(S[i] == 'l'){
      alphabet[11]++;
    }else if(S[i] == 'm'){
      alphabet[12]++;
    }else if(S[i] == 'n'){
      alphabet[13]++;
    }else if(S[i] == 'o'){
      alphabet[14]++;
    }else if(S[i] == 'p'){
      alphabet[15]++;
    }else if(S[i] == 'q'){
      alphabet[16]++;
    }else if(S[i] == 'r'){
      alphabet[17]++;
    }else if(S[i] == 's'){
      alphabet[18]++;
    }else if(S[i] == 't'){
      alphabet[19]++;
    }else if(S[i] == 'u'){
      alphabet[20]++;
    }else if(S[i] == 'v'){
      alphabet[21]++;
    }else if(S[i] == 'w'){
      alphabet[22]++;
    }else if(S[i] == 'x'){
      alphabet[23]++;
    }else if(S[i] == 'y'){
      alphabet[24]++;
    }else if(S[i] == 'z'){
      alphabet[25]++;
    }
  }

  long long result = 1;
  for(int i=0;i<26;i++){
    if(alphabet[i] != 0){
      result *= (alphabet[i] + 1);
      result = result % (mypower(10,9) + 7);
    }
  }
  result--;
  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<string> res;
    for(int i = 0; i + K < N; i++) {
        if(A[i] < A[i + K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4840
a,b=map(float,input().split())
a=int(a//1)
bigb=int((b*1000)//1)
a_front=a//1000
a_back=a-a_front*1000
#print(a,b,bigb,a_front,a_back)
 
ans_front=a_front*bigb
ans_back=a_back*b
ans_back=int(ans_back//1)
print(int(ans_front+ans_back))

Measured memory_bytes: 9132
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int n;
void dfs(string s)
{
    if(s.size()==n)
    {
        OUT s<<endl
    }
    else
    {
        loop(i,0,s.size()+1)
        {
            int temp=0;
            loop(j,0,s.size())
            {
                temp= max(temp,s[j]-'a');
            }
            if(s=="" || (i-temp)<=1)
            {
                string ns= s + char('a'+i);
                dfs(ns);
            }
        }
    }
}
int main()
{
    FAST
    FO
    FI
    IN n;
    dfs("");
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	bool ok = 1;
	int n=s.length(); 
	if(n%2==0)ok=0;
	string ss = s;
	reverse(all(ss));
	if(s!=ss)ok = 0;
	ss = s.substr(0,n/2); //cout << ss << endl;
	string sss = ss;
	reverse(all(sss));
	if(ss!=sss)ok = 0;
	ss = s.substr(n/2+1,n/2); 
	sss = ss;
	reverse(all(sss));
	if(ss!=sss)ok = 0;
	if(ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}	
/* Benq's
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

constexpr int MAX_N=(int)1e5;

int n;
int a[MAX_N],b[MAX_N];

int main() {

    std::cin>>n;

    for(int i=0;i<n;++i)
        std::cin>>a[i]>>b[i];
    int minv=std::min_element(b,b+n)-b;

    int ans=a[minv]+b[minv];

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<double,int> pdou;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
template <class typ> struct BIT{
	vector<typ> x;
	BIT(int n):x(n,0){}
	typ sum(int a,int b){
		if(a==0){
			typ s=0;
			for(int i=b;i>=0;i=(i&(i+1))-1) s+=x[i];
			return s;
		}
		else return sum(0,b)-sum(0,a-1);
	}
	void add(int ind,typ f){
		for(int i=ind;i<x.size();i|=i+1) x[i]+=f;
	}
};
int n,num;
double inf=1e10,eps=1e-10;
int pos[45450];
vector<pdou> v;
int ca(double T,double a[],double b[],double c[]){
	v.clear();rep(i,n) v.pb(mp(a[i]/b[i],i));
	sort(All(v));
	rep(i,n) pos[v[i].se]=i;
	//rep(i,n) cout<<v[i].se<<' ';cout<<endl;
	
	v.clear();
	rep(i,n) v.pb(mp((c[i]-T*a[i])/b[i],i));
	sort(All(v));
	//rep(i,n) cout<<v[i].se<<' ';cout<<endl;
	
	//rep(i,n) cout<<pos[i]<<' ';cout<<endl;
	//rep(i,n) cout<<pos[v[i].se]<<' ';cout<<endl;
	
	BIT<int> bit(n+10);int ret=0;
	rep(i,n){
		int it=v[i].se;
		ret+=bit.sum(pos[it]+1,n+5);
		bit.add(pos[it],1);
	}
	
	return ret;
}
double cal(double a[],double b[],double c[]){
	double lo=-inf,hi=inf;
	rep(i,114){
		double mi=0.5*(lo+hi);
		//cout<<mi<<' '<<ca(mi,a,b,c)<<endl;
		if(ca(mi,a,b,c)<(num+1)/2) lo=mi;else hi=mi;
	}
	return lo;
}
int main()
{
	double a[45450],b[45450],c[45450];
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	num=n*(n-1)/2;
	printf("%.12f %.12f\n",cal(a,b,c),cal(b,a,c));
	//cout<<ca(0.9,a,b,c)<<endl;
}


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

int main()
{

  int a,b,c;
  cin>>a>>b>>c;
  if((a!=b)&&(a!=c))
  {
      cout<<a<<endl;
  }
 else if((b!=a)&&(b!=c))
 {
      cout<<b<<endl;
 }
 else
 {
     cout<<c<<endl;

 }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){
  return o<<"("<<p.first<<","<<p.second<<")";
}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
 

signed main(){
  while(1){
    int n,mod;
    cin>>n>>mod;
    if(n == 0 && mod==0) return 0;

    vector<int> A(n);
    cin>>A;

    multiset<int> S;
    vector<int> Mod(n);
    for(int i=0,s=0;i<n;i++){
      s += A[i];
      S.insert(s%mod);
      S.insert(s%mod+mod);
      Mod[i] = s%mod;
    }
    
    int ofset = 0;
    int ans = 0;
    for(int i=0;i<n;i++){
      int s = *(--S.upper_bound(ofset + mod-1));
      Max(ans,s - ofset);
      S.erase(S.find(Mod[i]));
      S.erase(S.find(Mod[i]+mod));
      ofset = (ofset + A[i]) %mod;
    }
    cout<<ans<<endl;
    
  }
   
  return 0;
}




Measured memory_bytes: 6148
n=int(input())
a,b,c=[-1]*n,[-1]*n,[-1]*n
for i in range(n):
    a[i],b[i],c[i]=map(int,input().split())
dpa=[-1]*n
dpb=[-1]*n
dpc=[-1]*n
dpa[0]=a[0]
dpb[0]=b[0]
dpc[0]=c[0]
for i in range(1,n):
    dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i])
    dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i])
    dpc[i]=max(dpa[i-1]+c[i],dpb[i-1]+c[i])
print(max(dpa[-1],dpb[-1],dpc[-1]))

Measured memory_bytes: 53080
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000
#define MAX 100000

bool isprime[MAX];
vector<int> primes;

void make_list(){
    fill(isprime, isprime+MAX, true);
    isprime[0]=isprime[1]=false;
    for(int i=2; i<=MAX/2; i++){
        if(isprime[i]){
            for(int j=i*2; j<=MAX; j+=i) isprime[j]=false;
            primes.pb(i);
        }
    }
}

int main(){
    make_list();
    int m,a,b;
    int n=primes.size();
    while(cin>>m>>a>>b, m|a|b){
        bool flg=true;
        int p,q;
        while(flg){
            rep(i,n){
                if(m <= primes[i]) break;
                if( m%primes[i]==0 && isprime[m/primes[i]]==true ){
                    p = primes[i];
                    q = m/primes[i];
                    if(p>q) swap(p,q);
                    if(a*q>b*p) break;
                    flg=false;
                    break;
                }
            }
            m--;
        }
        cout<<p<<" "<<q<<endl;
    }

    return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main()
{
  int a, b, c, sum;
  // long long sum = 0;

  cin >> a >> b >> c;

  for (int i = 0; i < b; i++)
  {
    sum += a;
    if (sum % b == c)
    {
      cout << "YES" << endl;
      exit(0);
    }
  }
  if (a == 1)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<stdlib.h>
using namespace std;
int compare(const void *a,const void*b);
int main(){
  int data[10];
  int i;
  for(i=0;i<10;i++){
    cin>>data[i];
  }
  qsort(data,10,sizeof(int),compare);
  for(i=0;i<3;i++){
    cout<<data[i]<<endl;
  }
  return 0;
}

int compare(const void *a,const void*b){
  return *(int *)b-*(int *)a;
}
  

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

bool sosu(int n) {
  if(n < 2) return false;//2以下除く
  else if(n == 2) return true;//2は素数
  else if(n % 2 == 0) return false;//偶数除く
  int root = sqrt(n);
  for(int i=3; i<=root; i+=2) {//奇数で割る
    if(n % i == 0) return false;
  }
  return true;
}

int main() {
  int n; cin >> n;
  int sum = 0;
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    if(sosu(x) == true) sum++;
  }
  cout << sum << endl;
}



Measured memory_bytes: 3072
import java.util.Scanner;


class UnionFind {

	private int n;
	private int par[] = new int[114514];
	// private int sz[] = new int[114514];
	
	public UnionFind(int _n) {
		n = _n;
		for (int i = 0; i < n; i++) {
			par[i] = i;
		//	sz[i] = 1;
		}
		
	}
	
	public int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	public boolean same(int x, int y) {
		return (find(x) == find(y));
	}
	
	
	public void unite(int x, int y) {
		// System.out.println("x = "+x+", y = "+y);
		if (same(x, y)) return;
		par[find(x)] = y;
	}
}


public class Main implements Runnable {

	public static void main(String[] args) {
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();	
	}
	
	public void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		UnionFind uf = new UnionFind(n+100);
		
		for (int i = 0; i < m; i++) {
			int u = scan.nextInt();
			int v = scan.nextInt();
			uf.unite(u,v);
		}
		
		int q = scan.nextInt();
		for (int i = 0; i < q; i++) {
			int u = scan.nextInt();
			int v = scan.nextInt();
			
			if (uf.same(u,v)) {
				System.out.println("yes");
			}
			else {
				System.out.println("no");
			}
		}
	}

}







Measured memory_bytes: 105108
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1000050;
//ここまでテンプレ
int main(){
	cout<<setprecision(20);
	int N;
	cin>>N;
	vector<double> X,Y;
	for(int i=0;i<N;i++){
		double x,y;
		cin>>x>>y;
		X.pb(x);
		Y.pb(y);
	}
	int count[150]={};
	const int points=5000000;
	for(int i=0;i<points;i++){
		long double theta=2*M_PI/points*i;
		long double maxi=-1e100;
		int num=0;
		for(int j=0;j<N;j++){
			long double dist=sin(theta)*X[j]+cos(theta)*Y[j];
			if(dist>maxi){
				maxi=dist;
				num=j;
			}
		}
		count[num]++;
	}
	for(int i=0;i<N;i++)
		cout<<fixed<<1.*count[i]/points<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
int a[4];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	rep(i,1,3) cin>>a[i];
	int cnt=0;
	rep(i,1,3) {
		rep(j,i+1,3) {
			if(a[i]==a[j]) cnt++;
		}
	}
	if(cnt==1) cout<<"Yes"<<'\n';
	else cout<<"No"<<'\n';
    return 0;
}


Measured memory_bytes: 256
//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
template< class T >
struct BinaryIndexedTree
{
  vector< T > data;

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

  T sum(ll k)//区間 [0,k] の合計を求める(閉区間なので注意)。
  {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(ll k, T x)//要素 k に値 x を加える。
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int c[500001];
int last[500001];
vector<pair<pint,int> > rli;
int ans[500001];
int main(){
	int N,Q;
	scan(N>>Q);
	BinaryIndexedTree< int > bit(N);

	fill(last,last+N,-1);
	rep(i,N){
		scan(c[i]);
		c[i]--;
	}
	rep(q,Q){
		int l,r;
		scan(l>>r);
		l--; r--;
		rli.push_back({{r,l},q});
	}
	sort(ALL(rli));
	int oldr=-1;
	rep(q,Q){
		int r=rli[q].first.first,l=rli[q].first.second,qnum=rli[q].second;
		if(r>oldr){
			for(int i=oldr+1;i<=r;i++){
				if(last[c[i]]!=-1){
					bit.add(last[c[i]],-1);
				}
				last[c[i]]=i;
				bit.add(i,1);
			}
			oldr=r;
		}
		ans[qnum]=bit.sum(r)-bit.sum(l-1);
	}
	rep(q,Q){
		prin(ans[q]);
	}
	return 0;
}


Measured memory_bytes: 17564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll mod=1000000007;
  //ll k=30958682112;cout<<k%mod;return 0;
  ll n;cin>>n;string s1,s2;cin>>s1>>s2;
  ll ts=0;
  vector<ll>v={};
  for(ll i=0;i<n-1;){
    if(s1[i]==s1[i+1]){
      ts++;
      i+=2;
      v.push_back(2);
    }
    else{
      ts++;
      i++;
      v.push_back(1);
    }
  }
  if(s1[n-2]!=s1[n-1]){
    ts++;
    v.push_back(1);
  }
  //cout<<ts;return 0;
  ll dp[ts][2];
  if(v[0]==1){
    dp[0][0]=1;
    dp[0][1]=1;
  }
  else{
    dp[0][0]=1;
    dp[0][1]=2;
  }
  for(ll i=1;i<ts;i++){
    for(ll j=0;j<2;j++){
      if(j==0){
        if(v[i]==1&&v[i-1]==2)dp[i][0]=dp[i-1][1];
        else
        dp[i][0]=dp[i-1][1]*2;
        //dp[i][0]%=mod;
      }
      if(j==1){
        if(v[i]==1)dp[i][1]=dp[i][0];
        else{
          if(v[i-1]==1)dp[i][1]=dp[i][0];
          else{
            dp[i][1]=(dp[i][0]/2)*3;
            //dp[i][1]%=mod;
          }
        }
      }
    }
  }
  //cout<<dp[16][1]<<endl;
  cout<<(dp[ts-1][1]*3)%mod<<endl;
}
  

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

#define M 100
#define mCap 100001
#define ull long long

ull N,C,w[M],v[M],dp[M][mCap];

inline ull knap (ull ind, ull peso)
{
	if(ind>=N || peso>=C) return 0;
	if(dp[ind][peso]!=-1) return dp[ind][peso];
	
	if(peso+w[ind]<=C) return dp[ind][peso]=max(knap(ind+1,peso+w[ind])+v[ind],knap(ind+1,peso));
	else return dp[ind][peso]=knap(ind+1,peso);
}

int main ()
{
	cin >> N >> C;
	for(int i=0; i<N; i++) cin >> w[i] >> v[i];
	for(int i=0; i<M; i++) for(int j=0; j<mCap; j++) dp[i][j]=-1;
	cout << knap(0,0);
}

Measured memory_bytes: 78336
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String scnum = sc.next();
        
        boolean badFlag = true;
        for(int i = 0; i < 3; i++){
            if ( scnum.charAt(i) == scnum.charAt(i+1) ) {
                badFlag = false;
                break;
            }
        }
        
        System.out.println( badFlag ? "Good" : "Bad" );
        
    }
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    for (int i=0;i<N;i++) cin >> X[i];
    ll ans = 0;
    for (int i=0;i<N-1;i++){
        ans += min((X[i+1]-X[i])*A,B);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024