akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
 
#define rep(i,n) for(int i = 0; i < n; i++)
 
typedef long long ll;
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int> > vp(M);
  rep(i,M) cin >> vp[i].first >> vp[i].second;
  sort(vp.begin(), vp.end());

  bool same = false;
  if(M==0 && N==1){
    cout << 0 << endl;
    return 0;
  }
  else if(M==0 && N==2){
    cout << 10 << endl;
    return 0;
  }
  else if(M==0 && N==3){
    cout << 100 << endl;
    return 0;
  }
  bool zero = true;
  rep(i,M){
    if(!(vp[i].first==1 && vp[i].second==0 && N==1)) zero=false;
  }
  if(zero){
    cout << 0 << endl;
    return 0;
  }
  
  rep(i,M){
    if(i!=0 && vp[i-1].first==vp[i].first) same = true;
    else same = false;
    if((vp[i].first==1 && vp[i].second==0 && N>0) || \
       (same && vp[i-1].second!=vp[i].second)){
      cout << -1 << endl;
      return 0;
    }    
  }
  string ans = "";
  rep(i,N){
    bool done;
    rep(j,M){
      if(i==(vp[j].first-1)){
	ans+=to_string(vp[j].second);
	done = true;
	break;
      }
      else done=false;
    }
    if(i==0 && !done) ans+="1";
    else if(!done) ans+="0";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n;
const ll MOD = 1000000007;

int main() {
	cin >> n;
	vector<ll> a(n, 0);
	rep(i, n)cin >> a[i];
	vector<ll> sum(n, 0);
	sum[n - 1] = a[n - 1];
	for (int i = n - 1; i > 0; i--)sum[i - 1] = (sum[i] + a[i - 1]) % MOD;
	ll ans = 0;
	rep(i, n - 1)ans = (ans + (a[i] * sum[i + 1]) % MOD) % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6416
n = gets.to_i
as = gets.split.map(&:to_i)
tmp = Hash.new()
tmp[0] = {l: 0}

as.each.with_index(1) do |a,i|
  break if as[i].nil?
  tmp[i] = {l: tmp[i-1][:l].gcd(as[i-1])}
end

tmp[n-1][:r] = 0
(n-2).downto(0) do |i|
  tmp[i][:r] = tmp[i+1][:r].gcd(as[i+1])
end

ans = 0
n.times do |i|
  gcd = tmp[i][:l].gcd(tmp[i][:r])
  ans = [ans, gcd].max
end

puts ans


Measured memory_bytes: 41852
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define allr(v) (v).rbegin(),(v).rend()
#define vrsort(v) sort(allr(v))
const ll inf=1LL<<60;

int main(){
  ll i=0,j,N,M;
  ll cost[10]={0,2,5,5,4,5,6,3,7,6};
  cin>>N>>M;
  vec use(M);
  rep(i,M){
    cin>>use[i];
  }
  map<ll,ll> dp;
  For(i,-10,N)dp[i]=-inf;
  dp[0]=0;
  rep(i,N){
    rep(j,M){
      dp[i+cost[use[j]]]=max(dp[i+cost[use[j]]],dp[i]+1);
    }
  }
  i=N;
  vrsort(use);
  while(i>0){
    rep(j,M){
      if(dp[i]-1==dp[i-cost[use[j]]]){
        cout<<use[j];
        i-=cost[use[j]];
        break;
      }
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 896
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[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
           
        }
    }
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    int s;
    cin >> s;
    set<int> st;
    int m = 1;

    while(true){
        st.insert(s);
        if(s & 1){
            s = s * 3 + 1;
        }else{
            s /= 2;
        }
        m++;
        if(st.count(s)){
            cout << m << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int inf = 1e9 + 5;
const int nax = 105;

char sl[nax][nax];
// int pref[nax][nax];
int dp[nax][nax][nax], old[nax][nax][nax];
int fixX[nax][nax], fixY[nax][nax];

/*int getSum(int x1, int y1, int x2, int y2) {
	if(x1 > x2) return 0;
	if(y1 > y2) return 0;
	if(x1 == x2) return fixX[x1][y2] - (y1 ? fixX[x1][y1-1] : 0);
	if(y1 == y2) return fixY[y1][x2] - (x1 ? fixY[y1][x1-1] : 0);
	assert(false);
}*/

int sumY(int y, int x1, int x2) {
	if(x1 > x2) return 0;
	maxi(x1, 0);
	mini(x2, nax - 1);
	return fixY[y][x2] - (x1 ? fixY[y][x1-1] : 0);
}
int sumX(int x, int y1, int y2) {
	if(y1 > y2) return 0;
	maxi(y1, 0);
	mini(y2, nax - 1);
	return fixX[x][y2] - (y1 ? fixX[x][y1-1] : 0);
}


int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	int ex, ey;
	REP(y, h) {
		scanf("%s", sl[y]);
		REP(x, w) {
			if(x) fixY[y][x] += fixY[y][x-1];
			if(y) fixX[x][y] += fixX[x][y-1];
			//if(x) pref[x][y] += pref[x-1][y];
			//if(y) pref[x][y] += pref[x][y-1];
			//if(x && y) pref[x][y] -= pref[x-1][y-1];
			if(sl[y][x] == 'E') {
				ex = x;
				ey = y;
			}
			else if(sl[y][x] == 'o') {
				//++pref[x][y];
				++fixX[x][y];
				++fixY[y][x];
			}
		}
	}
	int ans = 0;
	
	REP(a,nax)REP(b,nax)REP(c,nax) dp[a][b][c] = old[a][b][c] = -inf;
	
	dp[ex][ey][ey] = 0;
	
	FORD(x1, ex, 0) {
		if(x1 != ex) REP(a,nax)REP(b,nax)REP(c,nax) {
			old[a][b][c] = dp[a][b][c];
			dp[a][b][c] = -inf;
		}
		FOR(x2, ex, w - 1) FORD(y1, ey, 0) FOR(y2, ey, h - 1) {
			int & me = dp[x2][y1][y2];
			//if(y2 < h - ey + y1) {
			//	puts("a");
			if(y1 >= (y2 - ey))
				maxi(me, dp[x2][y1+1][y2] + sumY(y1, max(x1, x2 - ex), min(x2, w - 1 - (ex - x1))));
			if(y2 < h - (ey - y1))
				maxi(me, dp[x2][y1][y2-1] + sumY(y2, max(x1, x2 - ex), min(x2, w - 1 - (ex - x1))));
			
			//if(x2 < w - ex + x1) {
			//	puts("b");
			if(x2 < w - (ex - x1))
				maxi(me, (x2 ? dp[x2-1][y1][y2] : 0) + sumX(x2, max(y1, y2 - ey), min(y2, h - 1 - (ey - y1))));
			if(x1 >= (x2 - ex))
				maxi(me, old[x2][y1][y2] + sumX(x1, max(y1, y2 - ey), min(y2, h - 1 - (ey - y1))));
			
			//printf("%d,%d,%d,%d -> %d\n", x1, x2, y1, y2, me);
			maxi(ans, me);
		}
	}
	
	printf("%d\n", ans);
	
	/*FOR(x1, 0, ex) {
		int x2 = ex - 1;
		while(x2 + 1 < w && x2 + 1 + (ex - x1) < w) ++x2;
		if(x2 == ex - 1) continue;
		FOR(y1, 0, ey) {
			int y2 = ey - 1;
			while(y2 + 1 < h && y2 + 1 + (ey - y1) < h) ++y2;
			if(y2 == ey - 1) continue;
			int maybe = pref[x2][y2];
			if(x1) maybe -= pref[x1-1][y2];
			if(y1) maybe -= pref[x2][y1-1];
			if(x1 && y1) maybe += pref[x1-1][y1-1];
			//printf("%d %d %d %d\n", x1, x2, y1, y2);
			maxi(ans, maybe);
		}
	}
	printf("%d\n", ans); */
	return 0;
}


Measured memory_bytes: 9344
ss = gets.chomp.split("")
maxCnt = 0
tmpCnt = 0
ss.each do |s|
    if !(s == "A" || s == "C" || s == "G" || s == "T")
        tmpCnt = 0
        next
    end
    tmpCnt += 1
    if maxCnt < tmpCnt
        maxCnt = tmpCnt
    end
end
puts maxCnt

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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 1e5+1;
const int M = 1e9+7;

int n, tab[MAX], dp[MAX];
int main()
{
    _upgrade;
    cin>>n;
    FOR(i, 0, n)
        cin>>tab[i];
    dp[0] = 0;
    dp[1] = abs(tab[0]-tab[1]);
    FOR(i, 2, n)
        dp[i] = min(dp[i-2] + abs(tab[i-2]- tab[i]), dp[i-1] + abs(tab[i-1]- tab[i]));
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 50009
using namespace std;

const int INF = 0x3f3f3f3f;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a+b >= 10) puts("error");
    else cout << a + b << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    println!("{}", n / 3);
}


Measured memory_bytes: 2164
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }

    val ans = LongArray(N)
    var t = 0L
    for(i in 0 until N){
        if(i % 2 == 0){
            t += A[i]
        }else{
            t -= A[i]
        }
    }
    ans[0] = t
    for(i in 1 until N){
        ans[i] = 2 * A[i - 1] - ans[i - 1]
    }

    println(ans.joinToString(separator = " "))
}

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

int ans = 0;
string S;
int main() {
    cin >> S;
    int n = S.length();

    string T = S;
    int cnt = 0;
    rep(i, n-1) {
        if(T[i]==T[i+1]) {
            T[i+1] = (T[i+1] == '0'? '1':'0');
            cnt++;
        }
    }
    ans = cnt;
    T = S;
    cnt = 0;
    for(int i=n-2; i>=0; i--) {
        if(T[i]==T[i+1]) {
            T[i] = (T[i] == '0'? '1':'0');
            cnt++;
        }
    }
    ans = min(ans, cnt);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque
from heapq import *

def main():
	n=II()
	A=LI()

	X=A[:n]
	Y=[-i for i in A[2*n:]]
	M=A[n:2*n]

	heapify(X)
	heapify(Y)

	xs=sum(X)
	ys=sum(Y)
	XX=[xs]
	YY=[ys]

	for i in M:
		heappush(X,i)
		a=heappop(X)
		xs+=+i-a
		XX.append(xs)

	for i in reversed(M):
		heappush(Y,-i)
		a=heappop(Y)
		ys+=-i-a
		YY.append(ys)

	ans=-10**18

	for i,j in zip(XX,YY[::-1]):
		ans=max(ans,i+j)

	print(ans)
if __name__ == "__main__":
	main()


Measured memory_bytes: 37888
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	if(a==b){cout<<c;}
	else if(b==c){cout<<a;}
	else{cout<<b;}
	








	cout<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    int answer = 0;
    rep(i, int(s.size()))
    {
        if (s.at(i) != t.at(i))
            answer++;
    }

    cout << answer << endl;
}

Measured memory_bytes: 3916
#include <cstdlib>
#include <array>
#include <iostream>
#include <string>


template<
  typename T,
  typename U,
  typename V
>
static inline T
solve(T a, U b, V mod)
{
  for (V i = 1; i < mod; i++) {
    if ((a * i) % mod == b) {
      return i;
    }
  }
  return 0;
}


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

  int a, b, c;
  std::cin >> a >> b >> c;
  auto ans = solve(a, c, b);
  std::cout << (ans == 0 ? "NO" : "YES") << std::endl;

  return EXIT_SUCCESS;
}


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

vector<int> repeat(int M,int N,vector<int> v){  
  int v_num=v.size();
  if(v.size()==0){
	v.push_back(7);
	v.push_back(5);
	v.push_back(3);
  }else{
	for(int i=0;i<v_num;i++){
	  if((int)(v[i]/pow(10,M-N-1))!=0){
		v.push_back(v[i]*10+7);
		v.push_back(v[i]*10+5);
		v.push_back(v[i]*10+3);
	  }
	}
  }
  if(N>0){
	v=repeat(M,N-1,v);
  }
  return v;
}

int main(){
  int N;
  cin >> N;
  int di=0;
  int x=1;
  for(int i=1;i<11;i++){
	if(x>N){
	  break;
	}else{
	  x*=10;
	  di++;
	}
  }

  vector<int> v;

  v=repeat(di-1,di-1,v);
  
  vector<int> ans;
  for(int i=0;i<v.size();i++){
	int v_di=0;
	int v_x=1;
	for(int j=0;j<11;j++){
	  if(v_x>v[i]){
		break;		
	  }else{
		v_di++;
		v_x*=10;
	  }
	}	
	bool a=false;
	bool b=false;
	bool c=false;
	for(int j=0;j<v_di;j++){
	  int t=(int)(v[i]/pow(10,j))-(int)(v[i]/pow(10,j+1))*10;
	  if(t==7){
		a=true;
	  }else if(t==5){
		b=true;
	  }else if(t==3){
		c=true;
	  }
	}

	if(a&&b&&c){
	  if(v[i]<=N){
		ans.push_back(v[i]);
	  }
	}
  }


  cout<<ans.size()<<endl;


  return 0;
}

Measured memory_bytes: 560
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 1000010;
ll cnt[maxn];
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	for (int i = 1;i < maxn;++i)
		for (int j = i;j < maxn;j += i)
			++cnt[j];
	debug(cnt, cnt+10);
	for (int i = 2;i < maxn;++i)
		cnt[i] += cnt[i-1];
	int n;
	cin >> n;
	cout << cnt[n-1] << '\n';
}


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

namespace codefestival_2016_qualA_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            Console.WriteLine(a.Substring(0, 4) + " " + a.Substring(4));

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL k;

LL gsum(LL a)
{
    return a==0?0:a%10+gsum(a/10);
}

int main()
{
    while (scanf("%lld",&k)!=EOF)
    {
        LL ans=1,p=1;
        while (k--)
        {
            printf("%lld\n", ans);
            LL ans1=ans+p;
            LL ans2=ans+p*10;
            if (gsum(ans1)*ans2>=ans1*gsum(ans2)) { ans=ans1; }
            else { ans=ans2; p*=10; }
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int t = 1000;
  while(t < n){
    t += 1000;
  }
  cout<<t-n;
}


Measured memory_bytes: 3652
#include <iostream>
#include <unordered_map>

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

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

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

// Prime factorization of n
// O(\sqrt(n)) time complexity
void factorize(ll n, unordered_map<ll, ll>& out){
    // out.clear();
    while(n % 2 == 0){
        out[2]++;
        n /= 2;
    }
    for(ll p = 3; p * p <= n; p += 2){
        while(n % p == 0){
            out[p]++;
            n /= p;
        }
    }
    if(n > 2){
        out[n]++;
    }
}

int main(){
    ll n;
    cin >> n;
    unordered_map<ll, ll> p;
    for(ll x = 2; x <= n; ++x){
        factorize(x, p);
    }
    mint ans = 1;
    for(auto it = p.begin(); it != p.end(); ++it){
        ans *= (it->second + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

template<typename a>
struct S014 {
  long w, h;
  std::vector<std::vector<a>> z;
  S014(long w, long h, a x) {
    z.resize(h);
    for(long i = 0; i < h; ++i) {
      z[i].resize(w);
    }
    for(long r = 0; r < h; ++r) {
      for(long c = 0; c < w; ++c) {
        z[r][c] = x;
      }
    }
  }
  a& operator()(long c, long r) {
    return z[r][c];
  }
  void foreach(long cl, long cr, long rl, long rr, std::function<void(long,long,a&)> f) {
    for(long r = rl; r < rr; ++r) {
      for(long c = cl; c < cr; ++c) {
        f(c, r, z[r][c]);
      }
    }
  }
};

struct Solver {
  long w, h, n;
  std::vector<std::array<long, 3>> xs;
  Solver() {
    S002 r;
    r >= w >= h >= n >n>= xs;
  }
  void solve() {
    S014<long> z(w, h, 0);
    for(std::array<long, 3> t : xs) {
      long x = t[0];
      long y = t[1];
      long a = t[2];
      if( a == 1 ) {
        z.foreach(0, x, 0, h, [](long, long, long& v){ v = 1; });
      }
      if( a == 2 ) {
        z.foreach(x, w, 0, h, [](long, long, long& v){ v = 1; });
      }
      if( a == 3 ) {
        z.foreach(0, w, 0, y, [](long, long, long& v){ v = 1; });
      }
      if( a == 4 ) {
        z.foreach(0, w, y, h, [](long, long, long& v){ v = 1; });
      }
    }
    long res = 0;
    z.foreach(0, w, 0, h, [&](long, long, long& v){ if( v == 0 ) res += 1; });
    printf("%ld\n", res);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N), R(N, 0), L(N, 0);
    rep(0, i, N)
    {
        cin >> A.at(i);
        if (i + A.at(i) < N)
        {
            R.at(i + A.at(i))++;
        }
        if (i - A.at(i) > -1)
        {
            L.at(i - A.at(i))++;
        }
    }
    ll ans = 0;
    rep(0, i, N)
    {
        ans += R.at(i) * L.at(i);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	uint64_t answer = 0;

	if (N == 1) {
		answer = 1;
	} else {
		uint64_t before2 = 2;  // L2
		uint64_t before1 = 1;  // L1
		
		for (int i = 1; i <= N - 1; i++) {
			answer = before2 + before1;
			before2 = before1;
			before1 = answer;
		}
	}

	cout << answer << endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll M, D;
    cin >> M >> D;
    ll ans = 0;
    repi2(i, 1, M) {
        repi2(j, 1, D) {
            ll d1 = j % 10;
            ll d10 = j / 10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == i) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    vector<int> r(10000);
    for (int i = 0; i < 10000; i++) {
        cin >> r.at(i);
    }
    for (int i = 0; i < r.size(); i++) {
        cout << "Case " << i+1 << ": " << r.at(i) << endl;
    }
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,c;
cin>>n>>m>>c;
int count=0;
 int a[n][m]={0};

 int b[m]={0};
 int result[n]={0};;

int i,j;

for(j=0;j<m;j++){
cin>>b[j];
}
for(i=0;i<n;i++){
for(j=0;j<m;j++){
cin>>a[i][j];
result[i]=a[i][j]*b[j]+result[i];
}
result[i]=result[i]+c;
if(result[i]>0){
count++;
}
}
cout<<count<<endl;

return 0;

}


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

int gcd(int a,int b){
  if(b<a){
  if(b==0){
    return a;
  }else{
	return gcd(b,a%b);
  }
  }else{
  if(a==0){
    return b;
  }else{
	return gcd(a,b%a);
  }
  }
}
  
int main() {
  	int64_t gcd1=0;
  	int64_t sum=0;
	int K;
	cin >> K;
	for(int i=1;i<K+1;i++){
      for(int h=1;h<K+1;h++){
        gcd1=gcd(i,h);
        for(int j=1;j<K+1;j++){
          sum +=gcd(gcd1,j);
        }
      }
    }
  	
  cout << sum << endl;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll k = 0;
    ll a = 1000;

    for(int i=0;i<N-1;i++){
        if(A[i+1] < A[i]){
            a += k * A[i];
            k = 0;
        }else if(A[i+1] > A[i]){
            k += (a / A[i]);
            a %= A[i];
        }
    }

    a += k * A[N - 1];
    cout << a << endl;

}



Measured memory_bytes: 3612
import java.util.LinkedList;
import java.util.Scanner;

class Main{

	public static void main(String[] args) {




		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		char[][] map = new char[H][W];
		int count = 0;
		for(int i = 0;i < H;i++){
			String a = scan.next();
			for(int j = 0;j < W;j++){
				map[i][j] = a.charAt(j);
				if(map[i][j] == '.'){
					count++;
				}

			}
		}
		int INF = Integer.MAX_VALUE;
		int sx = 0;
		int sy = 0;
		int gx = W-1;
		int gy = H-1;

		int[][] d= new int[H][W]; 		//dp
		int[] dx = {1,0,-1,0};
		int[]dy = {0,1,0,-1};

		Pair pair ;
		LinkedList<Pair> queue = new LinkedList<Pair>();
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				d[i][j] = INF;					//通過していないかの判定
			}
		}
		pair = new Pair(sy, sx);
		queue.add(pair);
		d[sy][sx] = 0;

		while(!queue.isEmpty()){
			Pair x = new Pair();
			x = queue.removeFirst();
			if(x.from == gy && x.end == gx){
				break;
			}
			for(int i = 0;i < 4;i++){
				int nx = x.end + dx[i];
				int ny = x.from + dy[i];
				if(0 <= nx && nx < W && 0 <= ny && ny < H && map[ny][nx] != '#' && d[ny][nx] == INF){
					Pair go = new Pair(ny,nx);	
					queue.add(go);
					d[ny][nx] = d[x.from][x.end]+1;
				}
			}

		}
		if(d[gy][gx] == INF){
			System.out.println(-1);
			return;
		}
		System.out.println(count-d[gy][gx]-1);

	}
}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int s,int g) {
		this.from = s;
		this.end = g;
	}
	public Pair() {

	}
	@Override



	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time = (h2-h1) * 60 + (m2 - m1);
    int ans = time - k;
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 3596
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []

for _ in range(M):
  p,x = map(int,input().split())
  P.append(p)
  X.append(x)

sum_T = sum(T)

for i in range(M):
  print(sum_T - (T[P[i]-1] - X[i]))
  





Measured memory_bytes: 3060
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pi pair<ll,ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n, m;
		cin >> n >> m;
		if (m < 2)
		{
			cout << 0;
		}
		else
		{
			// ll a = m / 2;
			if (m < n * 2)
			{
				ll ans = m / 2;
				cout << ans << endl;
			}
			else
			{
				ll ans = 0;
				ans += n;
				m -= n * 2;
				ans += m / 4;
				cout << ans << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3604
# F - Division or Subtraction
def pf(x):
    plist = [1]
    p = 2
    while x>1:
        t = 0
        while x%p==0:
            x /= p
            t += 1
        now = list(plist)
        for i in range(t):
            now = list(map(lambda y:int(y*p), now))
            plist.extend(now)
        if p>int(x**0.5)+1:
            p = x
        elif p==2:
            p = 3
        else:
            p += 2
    return plist
        
N = int(input())
ans = len(pf(N-1))-1
for x in pf(N)[1:]:
    M = N
    while M>1 and M%x==0:
        M //= x
    if M==1 or M%x==1:
        ans += 1
print(ans)

Measured memory_bytes: 9548
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <numeric>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	int n=1;
	cin >> n;
	vector<int> v(n);

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

	int sum = accumulate(v.begin(), v.end(), 0);

	int temp = 0;
	for(int i = 1; i<n; i++) {
		temp += v[i-1];
		if (abs(sum - 2 * temp) <= abs(sum - 2 * (temp + v[i]))) {
			cout << abs(sum - 2 * temp);
			return 0;
		}
	}

	temp += v[n-1];
	cout << abs(sum - 2 * temp);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+5;
char s[N];
int n, q;
ll D[N], M[N], DM[N];
int main() {
    scanf("%d%s", &n, s+1);
    for (int i = 1; i <= n; i++) {
        D[i] = D[i-1], M[i] = M[i-1];
        DM[i] = DM[i-1];
        if (s[i] == 'D') D[i]++;
        if (s[i] == 'M') M[i]++, DM[i] += D[i];
    }
    scanf("%d", &q);
    while (q--) {
        int k; scanf("%d", &k);
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            if (s[i] == 'C') {
                int j = max(0, i-k);
                ans += DM[i]-DM[j]-D[j]*(M[i]-M[j]);
            }
        }
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
    using namespace std;
     
	int le1,le2,ri1,ri2;


    int main() {
      cin >> le1 >> le2 >> ri1 >> ri2;
      
      if (le1 + le2 == ri1 + ri2) {
        
        cout << "Balanced" << endl;
      }
      else if (le1 + le2 >= ri1 + ri2 ){
        cout << "Left" << endl;
      }
      else if (le1 + le2 <= ri1 + ri2) {
        cout << "Right" << endl;
      }
    }

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if (a + b) > (c + d) {
		fmt.Println("Left")
	} else if (a + b) < (c + d) {
		fmt.Println("Right")
	} else {
		fmt.Println("Balanced")
	}
}


Measured memory_bytes: 1836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i, x, y, R;
vector<int> list[maxN];
ll v[maxN];

ll sum[maxN];
ll here[maxN];
ll down[maxN];

ll total;

void no_sol() {
    printf("NO");
    exit(0);
}

void dfs(int node, int root) {
    int i;

    for (i = 0; i < list[node].size(); i++) {
        if (root == list[node][i]) {
            list[node][i] = list[node].back();
            list[node].pop_back();
            i--;
            continue;
        }

        dfs(list[node][i], node);
        down[node] += down[list[node][i]];
        sum[node] += sum[list[node][i]];
    }

    if (list[node].empty()) {
        sum[node] = v[node];
        here[node] = down[node] = 0;
        return;
    }

    ll aux = sum[node] - v[node] - down[node];
    aux *= 2;

    if (aux < 0) no_sol();
    here[node] = aux;
    down[node] += aux;

    total += aux;

    if (here[node] == 0) return;

    vector<int> need = {};
    for (auto to : list[node])
        need.pb(sum[to] - down[to]);

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

    if (need.size() == 1) no_sol();
    ll auxi = 0;
    for (int i = 1; i < need.size(); i++)
        auxi += need[i];

    if (here[node] / 2 > auxi) no_sol();
    if (here[node] / 2 > (auxi + need[0]) / 2) no_sol();

}


int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%lld", &v[i]);
    for (i = 1; i < n; i++) {
        scanf("%d%d", &x, &y);
        list[x].pb(y);
        list[y].pb(x);
    }

    if (n == 2) {
        if (v[1] == v[2])
            printf("YES");
        else
            printf("NO\n");
        return 0;
    }

    for (R = 1; list[R].size() == 1; R++);
    dfs(R, 0);

    if (total != sum[R]) no_sol();

    printf("YES");

    return 0;
}


Measured memory_bytes: 19456
n, m = map(int, input().split())
hist = [0]*n
pena = 0
collect = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if hist[p] != -1 and s == "WA":
        hist[p] += 1
    if hist[p] != -1 and s == "AC":
        pena += hist[p]
        hist[p] = -1

print(hist.count(-1),pena)

Measured memory_bytes: 50648
#include <cstdio>
using namespace std;
int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    if(A>0 && B<0){
        printf("%d\n",A-B);
    }
    else if(A>0 && B>0){
        if(A==1 || B==1){
            printf("%d\n",A+B);   
        }
        else{
            printf("%d\n",A*B);
        }
    }
    else if(A<0 && B>0){
        printf("%d\n",A+B);
    }
    else if(A<0 && B<0){
        printf("%d\n",A*B);
    }
    else if(A==0){
        if(B>=0){
           printf("%d\n",A+B); 
        }
        else if(B<0){
            printf("%d\n",A-B);
        }
    }
    else if(B==0){
        if(A>0){
            printf("%d\n",A+B);
        }
        else if(B<=0){
            printf("%d\n",A*B);
        }
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int x=0;
  for(int i=0;i<n;i++){
    vector<int> s(2);
    cin >> s.at(0) >> s.at(1);
    x = x+s.at(1)-s.at(0)+1;
  }
  cout << x << endl;
}


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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

ll powers[N];
void calc(){
	for(ll i = 1; i <= 2000; i++) {
		powers[i] = i * i * i * i * i;
		// trace(powers[i]);
	}
}

int main(){
	calc();	
	ll x; cin >> x;
	for(ll i = -2000; i <= 2000; i++) {
		// trace(i);
		// trace(binary_search(powers, powers+2001, x + i*i*i*i*i));
		if(binary_search(powers, powers+2001, x + i*i*i*i*i) == 1) {
			ll s2 = lower_bound(powers, powers + 2001, x + i*i*i*i*i) - powers;
			cout << s2 << " " << i << endl;
			break;
		}
	}
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  if(a == b && a == c) {
    cout << 1 << endl;
  } else if(a == b || a == c || b == c) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

const int maxn = 1e5 + 228;

vector <pair<int, int> > g[maxn];

int ans[maxn];
int mx = 0;

void DFS(int v, int clr, int p = -1) {
    int uk = 1;
    for (auto to : g[v]) {
        if (to.first == p)
            continue;
        if (uk == clr)
            uk++;
        ans[to.second] = uk;
        mx = max(mx, uk);
        DFS(to.first, uk++, v);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        g[x].pb({y, i});
        g[y].pb({x, i});
    }
    DFS(1, -1);
    cout << mx << endl;
    for (int i = 0; i < n -1; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

typedef long long ll;

using namespace std;

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

    int y = x;
    int z = y % 10;
    while (y != 0) {
        y = y / 10;
        z += y % 10;
    }

    if (x % z == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, k;
  vector<LL> h;
  Solver2(LL n, LL k) : n(n), k(k), h(n + 1){};

  void solve() {
    h[0] = 0;
    for (int i = 0; i < n; ++i) {
      cin >> h[i + 1];
    }
    vector<vector<LL>> dp(n + 1, vector<LL>(k + 1, LINF));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
      vector<vector<LL>> dp2(n + 1, vector<LL>(k + 1, LINF));
      for (int j = 0; j < i; ++j) {
        for (int g = 0; g <= k; ++g) {
          if (h[i] <= h[j]) {
            dp2[i][g] = min(dp2[i][g], dp[j][g]);
            if (g < k) dp2[j][g + 1] = min(dp2[j][g + 1], dp[j][g]);
          } else {
            dp2[i][g] = min(dp2[i][g], dp[j][g] + (h[i] - h[j]));
            if (g < k) dp2[j][g + 1] = min(dp2[j][g + 1], dp[j][g]);
          }
        }
      }
      swap(dp, dp2);
    }
    LL ans = LINF;
    for (int i = 0; i <= k; ++i) {
      for (int j = 0; j <= n; ++j) {
        ans = min(ans, dp[j][i]);
      }
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, k;
  std::cin >> n >> k;

  Problem::Solver2 sol(n, k);
  sol.solve();
  return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    double a,b,x; cin>>a>>b>>x;
    double t1=(a*a*b)/2;
    if(t1>x){
        double t2=(2*x)/(a*b);
        t2=b/t2;
        t2=atan(t2)*180/PI;
        cout<<fixed<<setprecision(10)<<t2;
        return 0;
    }
    double t=(2*x)/(a*a)-b;
    t=(b-t)/a;
    t=atan(t)*180/PI;
    cout<<fixed<<setprecision(10)<<t;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 512
#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))
#include <functional>
#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
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
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;

int doubling(ll k,vector<int> &a){
    const int n=a.size();
    int logK=log2(k)+1;
    vector<vector<int>> ret(logK,vector<int>(n));
    rep(i,n) ret[0][i]=a[i];
    rep(j,logK-1){
        rep(i,n){
            ret[j+1][i]=ret[j][ret[j][i]];
        }
    }
    int now=0;
    for(int j=0;k>0;j++){
        if(k&1)now=ret[j][now];
        k=k>>1;
    }
    return now+1;
}

signed main(){
    int n; cin >> n;
    ll k; cin >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    cout << doubling(k,a) << endl;
}


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

long long diff(long long p, long long r, long long s, long long u) {
    return max(max(p, r), max(s, u)) - min(min(p, r), min(s, u));
}

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

    int N;
    cin >> N;

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

    vector<long long> ac(N+1, 0);
    for (int i=1; i<=N; ++i) {
        ac[i] = ac[i-1] + A[i-1];
    }

    long long d = LLONG_MAX;
    int s1=1, s2=2, s3=3;
    while (s2 <= N-2) {
        while (s1+1 < s2 && abs(ac[s1+1] - (ac[s2]-ac[s1+1])) < abs(ac[s1] - (ac[s2]-ac[s1]))) {
            s1 ++;
        }
        while (s3+1 <= N-1 && abs((ac[s3+1]-ac[s2]) - (ac[N]-ac[s3+1])) < abs((ac[s3]-ac[s2]) - (ac[N]-ac[s3]))) {
            s3 ++;
        }
        d = min(d, diff(ac[s1], ac[s2]-ac[s1], ac[s3]-ac[s2], ac[N]-ac[s3]));
        s2 ++;
        s3 = max(s3, s2+1);
    }

    cout << d << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
 
int main(void){
  int a[100000],n,k,q,i,j,l;
  scanf("%d%d%d",&n,&k,&q);
  a[n]=0; 
  l=k-q;
  
  for(i=0;i<n;i++){
    a[i]=l;
  };
  for(i=0;i<q;i++){
    scanf("%d",&j);
    a[j-1]++;
  }
  for(i=0;i<n;i++){
    if(a[i]>0){
      printf("Yes\n");
    }
    else
      printf("No\n");
  }
    return 0;
}

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

#define INF 2000000000
#define ll long long

int res;
int N, P;
vector<pair<int, int> > v;
vector<int> com;
int seg[530000];

void Init()
{
	for(int i=0; i<530000; i++)
		seg[i] = -INF;
}

int Update(int idx, int val, int n, int l, int r)
{
	if (r < idx || idx < l) return seg[n];
	if (l == r) return seg[n] = max(seg[n], val);
	int mid = l+r>>1;
	return seg[n] = max(Update(idx, val, n<<1, l, mid), Update(idx, val, n<<1|1, mid+1, r));
}

int Query(int L, int R, int n, int l, int r)
{
	if (r < L || R < l) return -INF;
	if (L <= l && r <= R) return seg[n];
	int mid = l+r>>1;
	return max(Query(L, R, n<<1, l, mid), Query(L, R, n<<1|1, mid+1, r));
}

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		v.push_back({x, y});
		com.push_back(y);
	}
	sort(v.begin(), v.end());

	// 좌표 압축
	sort(com.begin(), com.end());
	com.erase(unique(com.begin(), com.end()), com.end());
	P = com.size();

	Init();
	vector<int> qry;
	for(int i=0; i<v.size(); i++)
	{
		int x = v[i].first, y = v[i].second;
		int idx = lower_bound(com.begin(), com.end(), y) - com.begin();
		Update(idx, -x-y, 1, 0, P-1);
		qry.push_back(i);

		if (i+1==v.size() || v[i].first != v[i+1].first)
		{
			for(int j : qry)
			{
				int x = v[j].first, y = v[j].second;
				int idx = lower_bound(com.begin(), com.end(), y) - com.begin();
				res = max(res, Query(0, idx, 1, 0, P-1)+x+y);
			}
			qry.clear();
		}
	}

	Init();
	for(int i=0; i<v.size(); i++)
	{
		int x = v[i].first, y = v[i].second;
		int idx = lower_bound(com.begin(), com.end(), y) - com.begin();
		Update(idx, -x+y, 1, 0, P-1);
		qry.push_back(i);

		if (i+1==v.size() || v[i].first != v[i+1].first)
		{
			for(int j : qry)
			{
				int x = v[j].first, y = v[j].second;
				int idx = lower_bound(com.begin(), com.end(), y) - com.begin();
				res = max(res, Query(idx, P-1, 1, 0, P-1)+x-y); // idx+1로 하면 Query가 -2e9라 음수 overflow...
			}
			qry.clear();
		}
	}

	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 9416