akhauriyash/Code-Regression huggingface dataset:
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define dash 12
#endif

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Extra --------------------------------------------------------------------

#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

const ll mx = 2e5 + 10;
vector<ll> a(mx);
vector<ll> vis(mx);

void solve(ll &T)
{
    ll n, k;
    std::cin>>n>>k;

    loop(i,0,n) {
        std::cin>>a[i];
        vis[i+1] = -1;
    }

    ll ans = 0;
    ll x = 1;
    for(ll i=0; i<n, k>0; i++)
    {
        d(x,k);
        if(vis[x]!=-1)
        {
            ll len = i - vis[x];
            k %= len;
            d(k, len);
            while(k>0) {
                x = a[x-1];
                ans = x;
                k--;
            }
            break;
        }
        vis[x] = i;
        x = a[x-1];
        ans = x;
        k--;
    }
    std::cout<<ans<<"\n";    
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    loop(Case,1,t+1)
    {
        d(Case);
        solve(Case);
    }
    return 0;
}

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<double,int> P;

#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n,m;
    cin >> n >> m;
    if(n==m){
        Yes;
    }else{
        No;
    }
}

Measured memory_bytes: 3568
#include <iostream>
#include<vector>
#include<map>
using namespace std;
#define ll long long
int main(void){

int x,y;
cin>>x>>y;

int c=0, t=x;
while(t>=0){
    if(t*4+ c*2==y)
        {
            cout<<"Yes";
            return 0;
        }
    c++;
    t--;
}
cout<<"No";
    
}



Measured memory_bytes: 3032
using System;
using System.Collections.Generic;
					
public class my
{
	static int a, b;
	
	public static void Main()
	{
		var n = my.GetInt();
		
		for(int i = 0; i < n; i++) {
			var C = my.GetIntArray(10);
			a = 0;
			b = 0;
			
			Console.WriteLine(my.YShapeTube(C, 0)? "YES" : "NO");
		}
	}
	
	private static bool YShapeTube(int[] C, int j)
	{
		if(j >= C.Length) return true;
		
		if(C[j] > a) {
			a = C[j];
			return my.YShapeTube(C, j+1);
		} 
		if(C[j] > b) {
			b = C[j];
			return my.YShapeTube(C, j+1);
		}
		
		return false;
	}
	
	private static void Swap(int[] A, int i, int j)
	{
		int tmp = A[i];
		A[i] = A[j];
		A[j] = tmp;
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}
	
	private static int[] GetIntArray(int n, string t)
	{
		var A = new int[n];
		var s = t.Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	private static int[] GetIntArray(char c, string s)
	{
		return Array.ConvertAll(s.Split(c), int.Parse);
	}
	
	private static int[] GetIntArray(string s)
	{
		return Array.ConvertAll(s.Split(' '), int.Parse);
	}
	
	private static double[] GetDoubleArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteVector(Vector v)
	{
		Console.WriteLine("{0:f8} {1:f8}", v.X, v.Y);
	}
}

public struct Vector
{
	public double X,Y;
}

Measured memory_bytes: 8856
#include<iostream>
#include<string>
using namespace std;
int main (void){

    string s, a;
    int i, j, z = 0;

    cin >> s >> a;

    i = s.size();

    for(j = 0;j < i;j++){

        if(s[j] != a[j]){
            z = 1;
            break;
        }


    }



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


    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    string s;cin>>s;
    int n=s.length();bool flag=1;
    rep(i,0,n/2){
        if(s[i]!=s[n-1-i]){
            flag=0;
            break;
        }
    }
    rep(i,0,n/4){
        if(s[i]!=s[n/2-1-i]){
            flag=0;
            break;
        }
    }
    rep(i,n/2+1,n){
        if(s[i]!=s[n-1-i]){
            flag=0;
            break;
        }
    }
    if(flag)cout<<"Yes";
    else cout<<"No";

 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int A[10100], B[10100], n, dp[10110][1010];
int fun(int a, int b){
	if(a <= 0)
		return 0;
	if(b == n)
		return 1e9;
	if(dp[a][b] != -1)
		return dp[a][b];
	return min(B[b] + fun(a - A[b], b), fun(a, b + 1));
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h;
	cin >> h >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i] >> B[i];
	for(int i = 0; i < n; i++)
		dp[0][i] = 0;
	for(int i = 1; i <= h; i++){
		for(int j = 0; j < n; j++){
			dp[i][j] = 1e9;
			dp[i][j] = min(B[j] + dp[max(0, i - A[j])][j], dp[i][j]);
			if(j)
				dp[i][j] = min(dp[i][j], dp[i][j - 1]);
		}
	}
	cout << dp[h][n - 1] << '\n';

}

Measured memory_bytes: 39680
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int i,N,e=0,w=0,min,a;
    string S;
    cin>>N>>S;
    min=N;
    for(i=0;i<N;i++){
        if(S[i]=='E') e++;
    }
    for(i=0;i<N;i++){
        a=w;
        if(S[i]=='W') w++;
        a+=e+w-i-1;
        if(a<min) min=a;
    }
    cout<<min;
}


Measured memory_bytes: 900
#include <iostream>
#include <vector>

using namespace std;

int N, M, Q, a[100005], b[100005], v[100005],c[100005],d[100005];

vector<int> Adj[100005];
int q[100005];
int dis[100005];

/*int D_base;
int query_num;

void INIT(int K, int D) {

	dis[K] = D;

	if ((q[K] > 0) && ( D_base - dis[K] <= d[q[K]])) {
		if (query_num < q[K]) { query_num = q[K];  }
	}

	if (D > 0) {
		for (int u = 0; u < (int)Adj[K].size(); u++) {
			int H = Adj[K][u];
			if (dis[H] < D) { INIT(H, D - 1); }
		}
	}

	dis[K] = 0;
}
*/

int check[100005];
int color[100005];

/*void PAINT(int v, int d, int c) {
	
	check[v] = d;
	
	if (color[v] == 0) { color[v] = c; }

	if (d > 0) {
		for (int u = 0; u < (int)Adj[v].size(); u++) {
			int w = Adj[v][u];
			if (check[w] < d) { PAINT(w, d - 1, c); }
			//PAINT(w, d - 1, c);
		}

	}
	check[v] = 0;
}*/

int memo[100005][15];

void FUNC(int V, int D, int C) {
	//cout << "V= " << V << " D= " << D <<" C= " <<C<< endl;

	if (memo[V][D] > 0) { return; }
	memo[V][D] = C;

	if (D>0) { FUNC(V,D - 1,C); }

	for (int u = 0; u < (int)Adj[V].size(); u++) {
		int H = Adj[V][u];
		if (D>0) { FUNC(H, D - 1, C); }
	}
}

int main(void) {

	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
		Adj[a[i]].push_back(b[i]);
		Adj[b[i]].push_back(a[i]);
	}

	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> v[i] >> d[i] >> c[i];
		q[v[i]] = i;
	}

	for (int i = Q; i >= 1; i--) {
		FUNC(v[i], d[i], c[i]);
	}


/*
	for (int i = 1; i <= N; i++) {
		query_num = -1;
		D_base = 10;
		INIT(i, 10);
		//cout << "query_num= " << query_num << endl;
		if (query_num == -1) { cout << 0 << endl; }
		else { cout << c[query_num] << endl; }
	}*/

	/*for (int i = Q; i >=1; i--) {
		PAINT(v[i], d[i], c[i]);
	}

	for (int i = 1; i <= N; i++) {
		cout << color[i] << endl;
	}
	*/

	for (int i = 1; i <= N; i++) {
		cout << memo[i][0] << endl;
	}
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 15864
# coding: utf-8

I, O, T, J, L, S, Z = [int(i) for i in input().split()]

K = (I//2)*2 + O + (J//2)*2 + (L//2)*2
if I % 2 == 1 and J % 2 == 1 and L % 2 ==1:
    K += 3
elif (I % 2 + J % 2 + L % 2 == 2) and (I * J * L > 0):
    K += 1
print(K)

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

int main() {
    long long n,k;
    cin >> n>>k;
  	long long h[n],a[n];
  
  	for(int i=0;i<n;i++){
     	cin>>h[i];
    }
  	a[0]=0;
  	a[1] = abs(h[0]-h[1]);
  	for(long long i =2;i<min(n,k);i++){
      	long long s = INT_MAX;
    	for(long long j=1;j<=i;j++){
        	s= min(s,a[i-j]+abs(h[i]-h[i-j]));
        }
      	a[i]=s;
    }
  	for(long long i =k;i<n;i++){
      	long long s = INT_MAX;
    	for(long long j=1;j<=k;j++){
        	s= min(s,a[i-j]+abs(h[i]-h[i-j]));
        }
      	a[i]=s;
    }
  	cout<<a[n-1]<<endl;
  	  	
	return 0;
}


Measured memory_bytes: 1792
"use strict";

function main(arg) {
    const N = parseInt(arg.split("\n")[0]);
    let answer = 0;
    
    for(let i=1; i<=N; i=i+2) {
        let cnt = 0;
        for(let j=1; j<=i; j++) {
            if(i % j === 0) {
                cnt++;
            }
        }
        if(cnt === 8) {
            answer++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int N, X, T;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> X >> T;
    int ans;
    if(N % X == 0) {
        cout << (N / X) * T << endl;
    } else {
        cout << (N / X + 1) * T << endl;
    }
    return 0;
}


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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

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

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  N++;
  vector<ll> X(N);
  for (int i = 0; i < N - 1; i++) cin >> X.at(i);
  X.at(N-1) = X.at(N-2) + 1;
  ll L; cin >> L;
  int Q; cin >> Q;

  vector<vector<int>> D;
  D.push_back(vector<int>(N));
  auto setZero = [&]() {
    int i = 0;
    for (int j = 0; j < N; j++) {
      while(i+1 < N && X.at(i+1) - X.at(j) <= L) i++;
      D.at(0).at(j) = i;
    }
  };
  setZero();
  DLOG("D.at(0)", D.at(0));
  auto setAbove = [&]() -> int {
    int k = 0;
    for ( ; D.at(k).at(0) < N-1; k++) {
      D.push_back(vector<int>(N));
      for (int i = 0; i < N; i++) {
	D.at(k+1).at(i) = D.at(k).at(D.at(k).at(i));
      }
      DLOG("k+1", k+1, "D.at(k+1)", D.at(k+1));
    }
    return k;
  };
  int K = setAbove();
  for (int q = 0; q < Q; q++) {
    int d = 0;
    int c, g; cin >> c >> g; c--; g--;
    if (c > g) swap(c, g);
    while (true) {
      if (c == g) {
	cout << d << "\n";
	break;
      }
      if (g <= D.at(0).at(c)) {
	cout << d + 1 << "\n";
	break;
      }
      int k = 0;
      for ( ; k+1 <= K && D.at(k+1).at(c) <= g ; k++) ;
      d += 1 << k;
      c = D.at(k).at(c);
    }
  }

  return 0;
}



Measured memory_bytes: 10240
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
# from bisect import *
# from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
MOD = 10**9+7

n = int(input())
S, T = input().split()
X = ''
for i in range(n):
    X += S[i] + T[i]
print(X)


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

double p[6], q[6];

double f(double x) {
  double ret = 0;
  for (int i = 0; i < 6; ++i)
    ret += max(x * p[i], (1 - x) * q[i]);
  return ret;
}

int main() {
  for (int i = 0; i < 6; ++i) {
    scanf("%lf", &p[i]);
    p[i] /= 100;
  }
  for (int i = 0; i < 6; ++i) {
    scanf("%lf", &q[i]);
    q[i] /= 100;
  }
  double l = 0, r = 1;
  for (int i = 0; i < 100; ++i) {
    double a = l + (r - l) / 3;
    double b = r - (r - l) / 3;
    if (f(a) > f(b)) l = a;
    else r = b;
  }
  printf("%.12f\n", f((l + r) / 2));
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, A[100001], B[100001], C[100001], ans;
int main() {
    cin >> N;
    for(int i{}; i < N; ++i) cin >> A[i];
    for(int i{}; i < N; ++i) cin >> B[i];
    for(int i{}; i < N; ++i) cin >> C[i];
    sort(A, A + N), sort(B, B + N), sort(C, C + N);
    for(int i{}; i < N; ++i)
        ans += distance(A, lower_bound(A, A + N, B[i])) * (N - distance(C, lower_bound(C, C + N, B[i] + 1)));
    cout << ans << endl;
}


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

signed main(){
    int h,w;cin>>h>>w;
    char c[h][w];
    rep(i,h)rep(j,w)cin>>c[i][j];
    int dp[h+1][w+1];
    fill(dp[0],dp[h+1],0);
    dp[0][0]=1;
    rep(i,h)rep(j,w){
        dp[i][j]%=(int)(1e9+7);
        rep(k,2){
            if(c[i+1-k][j+k]=='#')continue;
            dp[i+1-k][j+k]+=dp[i][j];
        }
    }
    cout<<dp[h-1][w-1]%(int)(1e9+7)<<endl;
}

Measured memory_bytes: 9088
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N = int(input())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

K = int(input())
v_to_p = [None] * (N+1)
for _ in range(K):
    v,p = map(int,input().split())
    v_to_p[v] = p

# 各頂点に対して、子側から見て矛盾しない値の区間[min,max]を持つ
rng = [None] * (N+1)

def calc_rng(v=1,parent=None):
    # None : 自由
    # False : 矛盾
    x = v_to_p[v]
    y = x
    for c in graph[v]:
        if c == parent:
            continue
        ret = calc_rng(c,v)
        if ret == False:
            return False
        x1,y1 = ret
        if x1 is None:
            continue
        # merge [x,y] and [x1-1,y1+1]
        if x is None:
            x,y = x1-1, y1+1
            continue
        # どちらも値が入っている
        if not (x - x1) & 1:
            return False
        if x < x1 - 1:
            x = x1 - 1
        if y > y1 + 1:
            y = y1 + 1
    if x is not None and x > y:
        return False
    rng[v] = (x,y)
    return x,y

def set_value(v=1, parent=None):
    if v_to_p[v] is None:
        p = v_to_p[parent]
        x,y = rng[v]
        if x is None:
            v_to_p[v] = p + 1
        else:
            if x <= p+1 <= y:
                v_to_p[v] = p+1
            else:
                v_to_p[v] = p-1
    for c in graph[v]:
        if c == parent:
            continue
        set_value(c,v)

ret = calc_rng()
if ret == False:
    print('No')
else:
    v_to_p[1] = rng[1][0]
    set_value()
    print('Yes')
    print('\n'.join(map(str,v_to_p[1:])))

Measured memory_bytes: 147888
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define rep(i,n) for(LL i=0;i<n;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) ((int)s.size())
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 10000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion


//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

void y_n(bool p) {
	if (p)_y();
	else _n();
}

void Y_N(bool p) {
	if (p) _Y();
	else _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	
	int n;
	cin >> n;
	vi v(n), c(n);
	vi ans(n);
	f_vI(v, n); f_vI(c, n);
	rep(i, n) {
		ans[i] = v[i] - c[i];
	}
	int res = 0;
	
	sort(all(ans), greater<int>());
	f(i, 0, n) {
		if (ans[i] > 0) {
			res += ans[i];
		}
	}
	cout << res;
	return 0;
}

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

double r(string s){
	if(s=="north")return 0;
	if(s=="west")return 90;
	int n = count(s.begin(),s.end(),'w')+count(s.begin(),s.end(),'n')-1;
	if(s[0]=='n')return r(s.substr(5))-90. / (1<<n);
	else return r(s.substr(4))+90. / (1<<n);
}

int main(){
	for(string s;cin>>s,s!="#";){
		double A=r(s),B=1;
		while(A!=(int)A){
			A*=2;
			B*=2;
		}
		int G= __gcd((int)abs(A),(int)B);
		A/=1;
		B/=1;
		cout<<(int)A;
		if(B!=1)cout<<"/"<<(int)B;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1200
N = int(input())

ans = 0
res = 'No'

for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        ans += 1
    else:
        ans = 0
    if ans == 3:
        res = 'Yes'
        break
print(res)

Measured memory_bytes: 9172
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define INF ll(1e18)
#define MOD 1000000007

bool isPrime(int n) 
{  
    if (n <= 1) return false;  
    for (int i = 2; i < n; i++) 
        if (n % i == 0) return false; 
     return true; 
} 

int main()
{
 
      
  ll t=0;
  cin>>t;
  ll s=t%1000;
  if(s!=0)
    s=1000-s;
  cout<<s<<endl;
  }


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll q; cin >> q;
    ll com, b, e, ans;
    rep(i, q) {
        cin >> com >> b >> e;
        if (com == 0) {
            ans = 1000000001;
            for (ll j = b; j < e; ++j) {
                ans = min(ans, a[j]);
            }
            cout << ans << endl;
        }
        if (com == 1) {
            ans = -1000000001;
            for (ll j = b; j < e; ++j) {
                ans = max(ans, a[j]);
            }
            cout << ans << endl;
        }
    }

}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, k;
li a[200200];
li imos[200200];


int main() {
    cin >> n >> k;
    rin{
        cin >> a[i];
    }
    rep(i, k) {
        //dump(a, n);
        rep(j, n + 1) {
            imos[j] = 0;
        }
        rep(j, n) {
            //p4(i, j, max(0ll, j - a[j]), min(n, j + a[j] + 1));
            imos[max(0ll, j - a[j])]++;
            imos[min(n, j + a[j] + 1)]--;
        }
        //dump(imos, n + 1);
        a[0] = imos[0];
        rep(j, n) {
            a[j + 1] = a[j] + imos[j + 1];
        }
        bool all_max = true;
        rep(j, n) {
            if (a[j] != n) {
                all_max = false;
                break;
            }
        }
        if (all_max) {
            break;
        }
    }
    rin{
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 6724
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#include <numeric>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll X, K, D; cin >> X >> K >> D;
    ll c = X / D;
    
    if (abs(c) < K) {

        if ((K - abs(c)) % 2==0) {
            cout << abs(X - c * D) << endl;
       
        }
        else {
            cout << min(abs(X - c * D + D), abs(X - c * D - D)) << endl;
            
        }
    }
    else {
        if (X > 0) {
            cout << X - K * D << endl;
        }
        else {
            cout <<abs( X + K * D )<< endl;
        }
    }
}



        






























  

























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

int gcd(int a,int b){
    int r = a % b;
    if (r == 0)return b;
    return gcd(b,r);
}

int main(){
    int n;
    int ans;
    cin >> n;
    vector<int> d(n);
    rep(i,n)cin >> d[i];

    if (d.size() % 2 == 0){
        sort(d.begin(),d.end());
        int end = d[d.size()/2];
        int start = d[d.size()/2-1];
        ans = end - start;
    }
    else ans = 0;
    cout  << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  auto dfs = [&](auto&& dfs, string s) -> void {
    if (sz(s) == n) {
      cout << s << endl;
      return;
    }

    int ma = -1;
    rep(i, sz(s)) chmax(ma, s[i] - 'a');

    rep(i, ma + 2) {
      s += i + 'a';
      dfs(dfs, s);
      s.pop_back();
    }
  };
  dfs(dfs, "");
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  if ((r * 100 + g * 10 + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 3644
#include<stdio.h>
int main(void){
  double a,b[10000],tmp;
  int n=0,i,j;
  while(scanf("%lf",&a)!=EOF){
    b[n]=a;
    n++;
  }
  for(j=0;j<n-1;j++){
    for(i=n-1;i>j;i--){
      if(b[i]>b[i-1]){
	tmp=b[i];
	b[i]=b[i-1];
	b[i-1]=tmp;
      }
    }
  }
  printf("%.2f\n",b[0]-b[n-1]);
  return (0);
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int n,q;
	ll sum=0;
	cin>>n;

	int a[n];
	map<int,int> mp;

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

	cin>>q;

	for(int i=0;i<q;i++)
	{
		int b,c;
		
		cin>>b>>c;

		if(mp[b])
		{
			mp[c]+=mp[b];
			sum+=(c-b)*mp[b];
			mp[b]=0;
		}

		cout<<sum<<endl;
	}
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 8268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define pll pair<ll,ll>
#define vll vector<long long>
#define f first
#define s second
long long mod = 1e9+7;
typedef vector<map<char,int>> vmci;

// int diry[] = {-1,-1,-1,0,0,1,1,1};
// int dirx[] = {-1,0,1,-1,1,-1,0,1};

ll pow(ll x, ll y, ll p) {
    ll res = 1;
    x %= p;
    if(x == 0) {
        return 0;
    }
    while(y > 0) {
        if(y & 1) {
            res = (res * x) % p;
        }
        y >>= 1;
        x = (x * x) % p;
    }
    return res;
}

// ll factorial(ll n) 
// { 
//     int res = 1, i; 
//     for (i = 2; i <= n; i++) 
//         res *= i; 
//     return res; 
// }

void seg_sieve(ll max,ll arr[]){
    ll i,j;
    for(i=2;i*i<=max;i++){
        if(arr[i]==0){
            for(j=i*i;j<=max;j+=i)
                arr[j]=1;
        }
    }
}


vector<ll> getdivs(ll n){
    vector<ll> a;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(n/i==i){
                a.push_back(i);
            }
            else{
                a.push_back(i);
                a.push_back(n/i);
            }            
        }
    }
    return a;
}

int lte(vector<ll> array, int start_idx, int end_idx, ll search_val) {

   if( start_idx == end_idx )
      return array[start_idx] <= search_val ? start_idx : -1;

   int mid_idx = start_idx + (end_idx - start_idx) / 2;

   if( search_val < array[mid_idx] )
      return lte( array, start_idx, mid_idx, search_val );

   int ret = lte( array, mid_idx+1, end_idx, search_val );
   return ret == -1 ? mid_idx : ret;
}

bool noob(const pii &a,const pii &b){
    if(a.second == 0 ) return true;
    return a.first*1.0/a.second > b.first*1.0/b.second;
}

unordered_map<bitset<1000>,int> dp;

void dfs(vector<set<int>> &adj,vector<bool> &vis,int x,int &lmax){
    vis[x]=1;
    lmax++;
    for(auto i:adj[x]){
        if(!vis[i]){
            dfs(adj,vis,i,lmax);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;    
    // cin>>t;        
    while(t--){    
        int n,m;
        cin>>n>>m;
        vector<set<int>> adj(n);
        vector<bool> vis(n,false);

        for(int i=0;i<m;i++){
            int a,b;
            cin>>a>>b;
            a--,b--;
            adj[a].insert(b);
            adj[b].insert(a);
        }
        int gmax=0,lmax=0;
        for(int i=0;i<n;i++){
            if(!vis[i]){
                dfs(adj,vis,i,lmax);
                gmax = max(gmax,lmax);
                lmax=0;
            }
        }
        cout<<gmax;

    }
    
}

Measured memory_bytes: 43848
#1. imput
a, b = map(int, input().split())

s = ''

W = '.'
B = '#'
N = '\n'

h = 0

#2. make board(width=100)
#2.1 white
#2.1.1 if a>50
while a>=51:
    s += (B+W)*50 + N
    s += B*100 + N
    h += 2
    
    a -= 50

#2.1.2 after a<= 50
a -= 1

s += B*100 + N
s += (B+W)*a + (B+B)*(50-a) + N
s += B*100 + N
h += 3

# 2.2 black
s += W*100 + N
h += 1

# 2,2,1 if b>50
while b >= 51:
    s += (B+W)*50 + N
    s += W*100 + N
    h += 2
    
    b -= 50

# 2.2.2 after b<=50
b -= 1
    
s += (B+W)*b + (W+W)*(50-b) + N
h += 1

#3. output    
print(h, 100)
print(s)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
L = []
for i in range(N) :
    l = int(input())
    L.append(l)
L = sorted(L)
ans = 10**9+1
for i in range(len(L)-K+1) :
    mi = L[i]
    ma = L[i+K-1]
    di = ma - mi
    if di < ans :
        ans = di
print(ans)


Measured memory_bytes: 8280
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/


/*long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}*/

int main(){
    int n, k, a, b;
    LL s;
    cin >> n >> k >> s;
    VL ans(n, s+1);
    if(s==1e9){
        REP(i,n){
            ans[i]-=s;
        }
    }
    REP(i,k){
        ans[i]=s;
    }
    REP(i,n-1){
        cout << ans[i] << ' ';
    }
    cout << ans[n-1] << endl;

}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll t,n,i,j,ok = 0;
	cin>>n;
	unordered_map<ll,ll> freq;
	for(i = 0;i<n;i++)
	{
		cin>>j;
		freq[j]++;
		if(freq[j] >= 2)
		ok = 1;
	}
	
	if(!ok)
	cout<<"YES";
	else
	cout<<"NO";
	
}

Measured memory_bytes: 8520
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];

		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		int[] amari = new int[N];

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

		Arrays.sort(amari);

		int ans = K - amari[N-1];

		System.out.println(ans);
	}

}


Measured memory_bytes: 87800
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
typedef struct{
    int o;
}STACK;

int getInt(char o[]){
    int i;
    int len,result=0;
    len=strlen(o);
    for(i=0;i<len;i++){
        result=result+(int)((o[i]-'0')*pow(10,len-1-i));
    }
    return result;
}
void enzan(STACK s[],int *i,char d){
    int A,B;
    A=s[*i-1].o;
    B=s[*i].o;
    switch(d){
        case '+':
            s[*i-1].o=A+B;
            s[*i].o=0;    
            *i=*i-1;
            break;
        case '-':
            s[*i-1].o=A-B;
            s[*i].o=0;    
            *i=*i-1;
            break;
        case '*':
            s[*i-1].o=A*B;
            s[*i].o=0;    
            *i=*i-1;
            break;
        default:
            printf("error\n");
    }
    
    return;
}

int main(void){
    int i;
    int size;

    STACK *s;
    s=(STACK*)malloc(sizeof(STACK));
    size=1;
    i=0;
    
    char c[8];
    scanf("%s",c);
    s[0].o=getInt(c);
    
    while(1){
        strcpy(c,"\0");
        scanf("%s",c);
        if(c[0]=='\0')break;
        switch(c[0]){
            case '+':
            case '-':
            case '*':
                enzan(s,&i,c[0]);
                break;
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
                i++;
                if(i>=size){
                    size++;
                    s=(STACK*)realloc(s,sizeof(STACK)*(size));
                }
                s[i].o=getInt(c);
                break;
            default:
                printf("error\n");
                return -1;
        }
    }
    
    printf("%d\n",s[0].o);
    
    free(s);
    
    return 0;
    
}



Measured memory_bytes: 2040
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int a[5]={1,2,3,4,5};
int main()
{
  int n,x,y=0,t=4;
  scanf("%d",&n);
  x=n/100;
  n=n%100;
  while(n!=0)
  {

    if(n%a[t]==0)
    {
       y+=n/a[t];
        n=n%a[t];
    }
    t--;
  }
  if(y<=x)
  printf("1\n");
  else
  printf("0\n");
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, p; cin >> n >> p;
	ll ans = 1;
	int flag = 0;
	for( int i = 0; i < n; ++i ){
		int temp; cin >> temp;
		if( temp % 2 ){
			flag = 1; 
			break;
		}
	}
	if( !flag && p == 1 ){
		cout << 0 << endl;
		return 0;
	}
	for( int i = 0; i < n-max(flag, 0); ++i ){
		ans *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin>>s;

    int n = s.length();

    rep(i,(1<<n-1)){
        int t=i;
        ll temp=0;
        ll add=s[0]-'0';

        rep(j,n-1){
            if(t%2==0){
                //cout<<"+"<<add<<" ";

                temp+=add;
                add=(s[j+1]-'0');
            }else{
                add*=10;
                add+=(s[j+1]-'0');
            }

            t>>=1;
        }
        //cout<<"+"<<add<<" ";
        temp += add;

        //ln;
        ans += temp;
    }
    //cout <<fixed<<setprecision(16)<< << endl;
    
    cout<<ans<<endl;
    
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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


int n, k;

int main(){
	cin >> n >> k;
	n-=2;
	int a = 4, ans = (n / 11) * 5;
	n %= 11;
	int cnt = 0;
	for(int j = 0; j < n; j++){
		for(int i = 0; i < 5; i++){
			if((i*9 + a) %11 == k)cnt++;
		}
		a += 8; a %= 11;
	}
	cout << ans + cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
x,n = gets.chomp.split.map(&:to_i)
if n == 0
  puts x
  exit
end
set = Set.new(gets.chomp.split.map(&:to_i))

unless set.include? x
  puts x
  exit
end

1.upto(1000) do |i|
  unless set.include? (x - i)
    puts x - i
    exit
  end
  unless set.include? (x + i)
    puts x + i
    exit
  end
end



Measured memory_bytes: 14724
N = int(input())
hList = [int(x) for x in input().split()]

def calc(x:list, count:int, before:int):
    if len(x) == 0:
        return 0
    sortedx = sorted(x)
    count = count + (sortedx[0] - before)
    afterList = []

    for _ in range(sortedx.count(sortedx[0])):
        idx = x.index(sortedx[0])
        if len(x[0:idx]) > 0:
            afterList.append(x[0:idx])
        del x[0:idx+1]
    if len(x) > 0:
        afterList.append(x)

    for x in afterList:
        count = calc(x, count, sortedx[0])

    return count

print(calc(hList, 0, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int cnt;
int b[300];
int main(){
    string A;
    
    cin>>A;
    
   for(int i=0;i<A.size();i++)
   {
       b[A[i]]++;
   }
   bool yes=true;
   
  for(int i=0;i<300;i++)
  {
      if(b[i]%2!=0)
      {
          yes=false;
      }
  }
  if(yes==false)
  {
      printf("No");
  }
  else
  {
      printf("Yes");
  }
}
  

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

#define f first
#define s second
#define ins insert
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define sz(c) (int) (c).size()
#define trav(x,c) for(auto &(x) : (c))
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(int (i) = (a) ; (i) < (n); ++(i))
#define _rfor(i,a,n) for(int (i) = (n)-1 ; (i) >= (a); --(i))
#define db(x) cout << (#x) << ": " << (x) << endl;
#define _db(c) trav(x,c) cout << (x) << " "; cout << endl;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(0);
#define tc int t; cin >> (t); while ((t)--)

int main() {
	godspeed;
	int a; cin >> a;
	cout << a + a*a + a*a*a;
}

Measured memory_bytes: 3604