akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int,input().split()))
flag = True
b = -1
for i in range(n):
    if h[i] - b > 0:
        b = h[i] - 1
    elif h[i] - b == 0:
        b = h[i]

    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include<iostream>

using namespace std;
int main()
{
	string a[4]={"AC","WA","TLE","RE"};
	string b;
	int u=0,y=0,t=0,r=0;
	int n;
	cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>b;
    	if(b=="AC")u++;
    	if(b=="WA")y++;
    	if(b=="TLE")t++;
    	if(b=="RE")r++;
	}
	
		cout<<a[0] <<' '<<'x' <<' '<<u<<endl;
		cout<<a[1] <<' '<<'x' <<' '<<y<<endl;
		cout<<a[2] <<' '<<'x' <<' '<<t<<endl;
		cout<<a[3] <<' '<<'x' <<' '<<r<<endl;
		
	
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, x[5][N], dp[5][N];

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

	scanf("%d", &n);

	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 3; j++)
			scanf("%d", &x[j][i]);

		if(i == 1) {
			for(int j = 0; j < 3; j++)
				dp[j][i] = x[j][i];
		} else {
			for(int a = 0; a < 3; a++)
				for(int b = 0; b < 3; b++) 
					if(a != b) dp[a][i] = max(dp[a][i], dp[b][i - 1] + x[a][i]);
		}
	}

	cout << max(dp[0][n], max(dp[1][n], dp[2][n]));

    return 0;                                        
}

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

int main() {
	int a,b; char c;
	while(cin>>a>>c>>b){
		switch(c){
			case '?': return 0; break;
			case '+':cout<<a+b<<endl; break;
			case '-':cout<<a-b<<endl; break;
			case '*':cout<<a*b<<endl; break;
			case '/':cout<<a/b<<endl; break;
		}
	} 
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
    int N;
    vector <int> v;

    cin >> N;

    while(0 < N){
        int tmp = N % 10;
        v.push_back(tmp);
        N /= 10;
    }

    if(v[3]+v[2]+v[1]+v[0] == 7) cout << v[3] << "+" << v[2] << "+" << v[1] << "+" << v[0] << "=7" << endl;
    else if(v[3]+v[2]+v[1]-v[0] == 7) cout << v[3] << "+" << v[2] << "+" << v[1] << "-" << v[0] << "=7" << endl;
    else if(v[3]+v[2]-v[1]+v[0] == 7) cout << v[3] << "+" << v[2] << "-" << v[1] << "+" << v[0] << "=7" << endl;
    else if(v[3]+v[2]-v[1]-v[0] == 7) cout << v[3] << "+" << v[2] << "-" << v[1] << "-" << v[0] << "=7" << endl;

    else if(v[3]-v[2]+v[1]+v[0] == 7) cout << v[3] << "-" << v[2] << "+" << v[1] << "+" << v[0] << "=7" << endl;
    else if(v[3]-v[2]+v[1]-v[0] == 7) cout << v[3] << "-" << v[2] << "+" << v[1] << "-" << v[0] << "=7" << endl;
    else if(v[3]-v[2]-v[1]+v[0] == 7) cout << v[3] << "-" << v[2] << "-" << v[1] << "+" << v[0] << "=7" << endl;
    else if(v[3]-v[2]-v[1]-v[0] == 7) cout << v[3] << "-" << v[2] << "-" << v[1] << "-" << v[0] << "=7" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        cout << min(A - 1, N - B) + 1 + ((B - A - 1) / 2) << endl;
        // int cand1, cand2;
        // {
        //     int arrive = A - 1;
        //     cand1 = arrive + 1 + (B - arrive - 1) / 2;
        //     cout << "goto 1: " << cand1 << endl;
        // }
        // {
        //     int arrive = N - B;
        //     cand2 = arrive + 1 + (N - A - arrive - 1) / 2;
        //     cout << "goto N: " << cand2 << endl;
        // }
        // cout << min(cand1, cand2) << endl;

        // int ans;
        // int arrive = min(A - 1, N - B);
        // if (B + arrive == N) {
        //     ans = arrive + 1 + (N - A + arrive + 1) / 2;
        // } else {
        //     ans = arrive + 1 + (B - arrive - 1 - 1) / 2;
        // }
        // cout << ans << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

bool cmp(int a,int b){
    return a > b;
}
int a[100005];
int main()
{
    int n,h;
    int aa;
    int da = 0;
    cin >> n >> h;
    for(int i = 0; i < n; i++){
        cin >> aa >> a[i];
        if(aa>da)
            da = aa;
    }
    sort(a,a+n,cmp);
    int cnt = 0;
    long long sum = 0;
    int flag = 0;
    for(int i = 0; i < n; i++){
        if(a[i] <= da)
            break;
        //cout << a[i] << endl;
        sum += a[i];
        cnt++;
        if(sum >= h){
            printf("%d\n",cnt);
            return 0;
        }
    }
    h -= sum;
    //cout << h <<endl;
    cnt += h/da;
    if(h%da)
        cnt++;
    cout  << cnt << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int N, K, S; cin >> N >> K >> S;
  int newS;

  rep(i, K) {
    cout << S << " ";
  }
  if(S ==1) S = 2;
  else S--;
  rep(i, N-K) {
    cout << S << " ";
  }
  cout << endl;
}

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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    FasterIO;

    string s;

    while(cin>>s){
        long long b = 0;
        long long ans = 0;

        for(int i=0; i<s.size(); i++){
            if(s[i]=='B')
                b++;
            else{
                ans+=b;
            }
        }

        cout<<ans<<endl;
    }

    return 0;
}



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

int main(){
	int r;
	cin >> r;
	
	int result = 1;
	
	for(int i = 0; i < 2; i++){
	    result *=r;
	}
	result *= 3;
	
	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define dbg(x) cout << #x << " = " << (x) << endl;
const ll MOD = 1000000007;
const ll INF = 1e18;

int n, m;
vector<int> g[100005];
int v[100005];
int ans;

int dfs(int x){
    if (v[x] != -1) return v[x];
    int res = 0;
    for(auto i : g[x]) res = max(res, 1 + dfs(i));
    v[x] = res;
    return res;
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("F:\\Scripts\\input", "r", stdin);
    // freopen("F:\\Scripts\\output", "w", stdout);
    // #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int x, y;
    int vis[n] = {0};
    memset(v, -1, sizeof v);
    for(int i = 0;i < m;i++) cin >> x >> y, x--, y--, g[x].push_back(y), vis[y] = 1; 
    for(int i = 0;i < n;i++) if (!vis[i]) ans = max(ans, dfs(i));
    cout << ans;
    return 0;
    
}

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

int main() {
  string S,s;
  int K;
  cin>>K>>S;
  if(S.size()<=K)
    cout<<S<<endl;
  else{
    for(int i=0; i<K; i++){
      s +=S.at(i);
    }
    cout<<s<<"..."<<endl;
  }
}




Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
int n;
ll m;
int q;
vector<pii> a[2];
int par[N];
int sz[N];

int getPar(int v) {
	return par[v] == -1 ? v : par[v] = getPar(par[v]);
}
bool unite(int v, int u) {
	v = getPar(v);
	u = getPar(u);
	if (v == u) return false;
	if (sz[v] < sz[u]) swap(v, u);
	sz[v] += sz[u];
	par[u] = v;
	return true;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld%d", &n, &m, &q);
	while(q--) {
		int v, u, t;
		scanf("%d%d%d", &v, &u, &t);
		a[t].push_back(mp(v, u));
	}
	if (m < n - 1) {
		printf("No\n");
		return 0;
	}
	if (m == n - 1) {
		if (a[1].empty())
			printf("Yes\n");
		else
			printf("No\n");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		sz[i] = 1;
		par[i] = -1;
	}
	ll C = n;
	for (pii e : a[0]) {
		C -= (int)unite(e.first, e.second);
	}
	for (pii e : a[1]) {
		if (getPar(e.first) == getPar(e.second)) {
			printf("No\n");
			return 0;
		}
	}
	m -= n - C;
	if (C >= 3 && m <= C * (C - 1) / 2)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


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

void solve(int h,int w){
	int i,j;
	for(i=1;i<=w;i++){
		cout<<"#";
		if(i==w) cout<<endl;
	}
	for(j=1;j<=h-2;j++){
		for(i=1;i<=w;i++){
			if(i==1||i==w) cout<<"#";
			else cout<<".";
			if(i==w) cout<<endl;
		}
	}
	if(h!=1&&w!=1){
		for(i=1;i<=w;i++){
			cout<<"#";
			if(i==w) cout<<endl;
		}	
	}
	cout<<endl;
}

int main() {
	// your code goes here
	int h,w;
	cin>>h>>w;
	while(h!=0&&w!=0){
		solve(h,w);
		cin>>h>>w;
	}
	return 0;
}

Measured memory_bytes: 3108
n = int(input())
min, total = 101, 0
for _ in range(n):
    x = int(input())
    total += x
    if x < min and x%10 != 0: 
        min = x

if total % 10 != 0:
    print(total)
elif min != 101:
    print(total-min)
else:
    print(0)
exit(0)

Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, T, A := sc.nextInt(), sc.nextFloat(), sc.nextFloat()
	H := sc.nextIntSlice(N)
	min := float64(1e+9)
	ans := 0
	for i, h := range H {
		temp := T - float64(h)*0.006
		if math.Abs(temp-A) < min {
			min = math.Abs(temp - A)
			ans = i + 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#define N 10001

using namespace std;

int dp[N] = {0};

int main () {
  int n, m, a, b;
  vector<pair<int, int> > A;

  cin >> n >> m;

  A.push_back(make_pair(0, 0));

  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    A.push_back(make_pair(a, b));
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (j - A[i].second >= 0)
        dp[j] = max(A[i].first + dp[j - A[i].second], dp[j]);
    }
    // for (int j = 1; j <= m; j++)
    //   cout << dp[j] << " ";
    // cout << endl;
  }

  // for (int i = 1; i <= n; i++) {
  //   for (int j = 1; j <= m; j++)
  //     cout << dp[i][j] << " ";
  //   cout << endl;
  // }

  cout << dp[m] << endl;

  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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

template <typename T>
T dijkstra(int s,int g,vector<vector<T> > & G){     
  using Pa = pair<T, int>;
  vector<T> D(1010,LINF);//----------------
  priority_queue<Pa,vector<Pa>,greater<Pa> > q;
  D[s]=0;
  q.emplace(D[s],s);//最短距離、ゴール頂点番号

  while(!q.empty()){
    T spath=q.top().first;
    int v=q.top().second;
    q.pop();

    if(D[v]<spath) continue;
    for(int i=0;i<siz(G[v]);i++){
      int u=i;//頂点番号
      T c=G[v][i];//最短距離
      if(D[u]>D[v]+c){
        D[u]=D[v]+c;
        q.emplace(D[u],u);
      }
    }
  }
  return D.at(g);
}

signed main(){
   int n;
   vector<tuple<ll,ll,db>> v(1010);

   rep(i,0,2){
      ll x,y;cin>>x>>y;
      v[i]=make_tuple(x,y,0);
   }

   cin>>n;
   vector<vector<db>> e(n+2,vector<db>(n+2,0));//nの後に

   rep(i,2,n+2){
      ll x,y; db r;
      cin>>x>>y>>r;
      v[i]=make_tuple(x,y,r);
   }

   rep(i,0,n+2){
      rep(j,i+1,n+2){
         ll xi=get<0>(v[i]),yi=get<1>(v[i]),
         xj=get<0>(v[j]),yj=get<1>(v[j]);
         db ri=get<2>(v[i]),rj=get<2>(v[j]);
         db dis=sqrt(pow(xi-xj,2)+pow(yi-yj,2))-ri-rj;
         e[i][j]=e[j][i]=max((db)0,dis);
      }
   }

   cout<<fixed<<setprecision(20)<<(db)dijkstra(0,1,e)<<endl;


}

Measured memory_bytes: 14072
import math
N=int(input())

if 1800<=N:
    print("1")
elif 1600<=N:
    print("2")
elif 1400<=N:
    print("3")
elif 1200<=N:
    print("4")
elif 1000<=N:
    print("5")
elif 800<=N:
    print("6")
elif 600<=N:
    print("7")
else:
    print("8")
   

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

int main() {
  // ここにプログラムを追記
  double a1;
  double b1;
  int a2;
  int b2;
  double x1;
  int x2;
  
  cin >> a1 >> b1;
  a2 = a1;
  b2 = b1;
  x1 = (a1+b1)/2;
  x2 = (a2+b2)/2;
  if (x1 > x2 ) {
    x2 ++;
  }
  cout << x2 << endl;
}


Measured memory_bytes: 256
delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, field, count, lb, ub, min_count):
	if count >= min_count:
		return min_count
	ans = min_count
	for dx, dy in delta:
		nx, ny = (here[0]+dx,here[1]+dy)
		neighbor = (nx, ny)
		while lb[0] <= nx <= ub[0] and lb[1] <= ny <= ub[1]:
			if field[ny][nx] == 1:
				if (nx, ny) != neighbor:
					field[ny][nx] = 0
					ans = ds((nx-dx,ny-dy),field, count+1, lb, ub, ans)
		    		field[ny][nx] = 1
				break
			if field[ny][nx] == 3:
				if count + 1 < ans:
					ans = count + 1
				break
			nx += dx
			ny += dy
	return ans
while 1:
	w, h = map(int,raw_input().split(" "))
	if w == h == 0: break
	board = [ map(int,raw_input().split(" ")) for _ in range(h)]
	for j in range(h):
		for i in range(w):
			if board[j][i] == 2:
				start = (i,j)
	result = ds(start, board, 0, (0,0), (w-1,h-1), 11)
	print result if result < 11 else -1

Measured memory_bytes: 4304
#include<iostream>
using namespace std;
int main()
{
    int k = 0, i, n, m;
    double sum = 0;
    cin>>n>>m;
    int a[n];
    for(i = 0; i < n; i++)
    {
        int b;
        cin>>b;
        a[i] = b;
        sum += b;
    }
    double y = sum/(4.0*m);
    for(i = 0; i < n; i++)
    {
        if(a[i] >= y)
        {
            k++;
        }
    }
    if (k >= m)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
P = [int(p) for p in input().split()]

diff = 103
ans = X
for i in range(101):
    a = X - i
    b = X + i
    if a not in P:
        ans = a
        break
    elif b not in P:
        ans = b
        break
print(ans)


Measured memory_bytes: 9176
#include <cstdio>

int main() {
    int N,Y;
    scanf("%d %d",&N,&Y);
    int x,y,z,yen;
    yen = Y/1000;
    x = yen/10;
    y = (yen%10)/5;
    z = (yen%10)%5;
    N -= x+y+z; //Nは最小でx+y+z
    while (N > 0 && x >= 0) {
        if (N >= 9 && x >= 1) {
        //10000円札->1000円札    
            x -= 1;
            z += 10;
            N -= 9;
        } else if (N >= 4 && y >= 1) {
        //5000円札->1000円札
            y -= 1; 
            z += 5;
            N -= 4;
        } else {      
        //10000円札->5000円札
            x -= 1;
            y += 2;
            N -= 1;
        }
    }
    if (N == 0 && x >= 0)
        printf("%d %d %d\n",x,y,z);
    else
        printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    vector<vector<int> >s(20,vector<int>(n));
    for(int i=0;i<20;i++){
        if(a[0]&(1<<i)){
            s[i][0] = 1;
        }
    }
    for(int i=0;i<20;i++){
        for(int j=1;j<n;j++){
            if(a[j]&(1<<i)){
                s[i][j] = s[i][j-1]+1;
            }else{
                s[i][j] = s[i][j-1];
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(i==n-1){
            ans+=1;
            break;
        }
        ll x = 100000000;
        for(int j=0;j<20;j++){
            if(i>0)x = min(x,(ll)(upper_bound(s[j].begin()+i,s[j].end(),s[j][i-1]+1)-s[j].begin()-i));
            if(i==0)x = min(x,(ll)(upper_bound(s[j].begin()+i,s[j].end(),1)-s[j].begin()-i));
        }
        ans +=x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17536
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nmc = br.readLine().split(" ");
        int n = Integer.parseInt(nmc[0]);
        int m = Integer.parseInt(nmc[1]);
        int c = Integer.parseInt(nmc[2]);
        String[] sbs = br.readLine().split(" ");
        int[] bs = new int[m];
        for (int i = 0; i < m; i++) {
            bs[i] = Integer.parseInt(sbs[i]);
        }
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            String[] sas = br.readLine().split(" ");
            int[] as = new int[m];
            for (int k = 0; k < m; k++) {
                as[k] = Integer.parseInt(sas[k]);
            }
        
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += as[j]*bs[j];
            }
            sum += c;
            if (sum>0) count++;
        }
        
        
        System.out.println(count);
    }
}



Measured memory_bytes: 23252
use proconio::input;
use std::mem::swap;
use std::cmp::max;

fn gcd(mut a: i32, mut b: i32) -> i32 {
    if a < b {
        let t = a;
        a = b;
        b = t;
    }
    let c = a % b;
    if c == 0 {
        b
    } else {
        gcd(b, c)
    }
}

fn main() {
    input! {
    n:usize,
    a:[i32;n],
    }

    let mut ans = 1;
    let mut v = vec![1; n];
    v[n - 1] = a[n - 1];
    for i in (0..n - 1).rev() {
        v[i] = gcd(v[i + 1], a[i]);
    }

    let mut m = a[0];
    for i in 1..n - 1 {
        ans = max(ans, gcd(m, v[i + 1]));
        m = gcd(m, a[i]);
    }
    ans = max(ans, max(m, v[1]));

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

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c, s = 0, g = 0;
	cin >> a >> b >> c;
	if (a == 5)g++;
	else s++;
	if (b == 5)g++;
	else s++;
	if (c == 5)g++;
	else s++;
	if (g == 2 && s == 1)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())

if x==0:
  if y>0:
    print(y)
  elif y<0:
    print(abs(y)+1)
    
elif y==0:
  if x>0:
    print(abs(x)+1)
  elif x<0:
    print(abs(x))
    
elif x>0 and y>0:
  # 3 -> 5
  if y>=x:
    print(y-x)
  # 5 -> 3  
  else:
    print(x-y+2)

elif x>0 and y<0:
  # 5 -> -3
  if x >= abs(y):
    print(x-abs(y)+1)
  # 3 -> -5  
  else:
    print(abs(y)-x+1)

elif x<0 and y>0:
  # -3 -> 5
  if y >= abs(x):
    print(y-abs(x)+1)
  # -5 -> 3
  else:
    print(abs(x)-y+1)
  
else:
  # -5 -> -3
  if abs(x) >= abs(y):
    print(abs(x)-abs(y))
  # -3 -> -5  
  else:
    print(abs(y)-abs(x)+2)  

    

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 1e5+5;



int main() {
	int n;
	cin >> n;
	vector<int> a(n);

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


	ll ans = 0;
	
	
	for (int i = 0; i < n - 1; i++) {
		ans += a[i] / 2;
		


		if (a[i]%2 == 1 && a[i + 1] != 0) {
			a[i + 1]--;
			ans++;
		}


	}

	ans += a[n - 1] / 2;

	
	cout << ans << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    long long int A, B;
    cin >> A >> B;
    long long int X, preX;
    cin >> preX;
    long long int ans=0;
    for(int n=1; n<N; n++) {
        cin >> X;
        ans += min((X-preX)*A, B);
        preX = X;
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

	int a,b,m;
	cin >> a >> b >> m;

	int i,mmin,sum;

	vector<int> aa(a);
	vector<int> bb(b);
	vector<int> tmp(3*m);
	vector<int> ttmp(3*m);

	for(i=0;i<a;i++){
		cin >> aa[i];
	}
	for(i=0;i<b;i++){
		cin >> bb[i];
	}

	mmin = 2000000;
	for(i=0;i<m*3;i++){
		cin >> tmp[i%3];

		if((i%3)==0){
			ttmp[0] = aa[tmp[i%3]-1];
			//cout << ttmp[0] << endl;
		}else if((i%3)==1){
			ttmp[1] = bb[tmp[i%3]-1];
			//cout << ttmp[1] << endl;
		}else if((i%3)==2){
			//ttmp[2] = aa[2];
			//cout << tmp[2] << endl;
            
			sum = ttmp[0] + ttmp[1] - tmp[2];
			mmin = min(sum,mmin);

		}

	}
	
	int aa_min = *min_element(aa.begin(), aa.end());
	int bb_min = *min_element(bb.begin(), bb.end());

    mmin = min(mmin,aa_min + bb_min);
    

	cout << mmin << endl ;

    return 0;
}


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

#define LLINF (1LL<<60)
typedef long long ll;

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

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> d(N);
    rep(i,N) cin >> d[i];
    
    //-----------------------------------
    sort(d.begin(),d.end());
    int ans=d[N/2]-d[N/2-1];


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

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e7);
bool p[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  loop(i,2,M){
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int Q[4] = {-8,-6,-2,0};
  int n;
  while(cin>>n,n){
    if(n%2==0)n--;
    for(int i = n ; ; i -=2){
      bool find = true;
      rep(j,4)if(!p[i+Q[j]])find = false;
      if(find){
	cout<<i<<endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 10920
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

vector<int> vec;

bool solve(){
  int n=vec.size();
  int odd=0;
  int even=0;
  int oi=-1;
  rep(i,n){
    if(vec[i]%2==0) even++;
    else oi=i,odd++;
  }
  if(even%2==1) return true;
  else if(even%2==0 && odd!=1) return false;
  else { // 偶数が偶数個，奇数が1個，全部偶数にして再チェック
    if(even==0) return false;
    if(vec[oi]==1) return false;
    vec[oi]--;
    int g=__gcd(vec[0], vec[1]);
    repl(i,2,n) g = __gcd(g, vec[i]);
    rep(i,n) vec[i]/=g;
    return !solve();
  }
}

int main(){
  int n;
  cin>>n;
  vec.resize(n);
  rep(i,n) cin>>vec[i];

  if(solve()) cout<<"First"<<endl;
  else cout<<"Second"<<endl;

  return 0;
}


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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define printFix(n,i) cout << fixed << setprecision(i) << n << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
#define bitrep(i,n) for (int i = 0; i < (1<<(n));i++)
#define isOne(bit,i) (bit & (1 << i))
using ll = long long;
using pii = pair<int, int>;

const ll modseed = pow(10,9) + 7;
const int INF = 100'000'000;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
int N,cnt;

int main(){
  cin >> N;
  auto P = getValues<int>(N);
  auto Q = getValues<int>(N);
  int p =0;
  int q=0;
  vector<int> cases(N);
  rep(i,N){
    cases.at(i) = i+1;
  }
  int counter = 0;
  do{
    counter++;
    if(cases==P){
      p = counter;
    }
    if(cases==Q){
      q = counter;
    }
  }while(next_permutation(cases.begin(),cases.end()));
  print(abs(p-q));
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  vector<ll> dp(n, INF);
  dp[0] = 0;
  rep(i, n) {
    for (int j = max(i - k, 0LL); j < i; j++) {
      chmin(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n - 1] << endl;
  ret;
}


Measured memory_bytes: 4792
import java.util.Scanner;

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

    int a = scanner.nextInt();
    int b = scanner.nextInt();

    if (a<b) {
      System.out.println("a < b");
    } else if (a>b) {
      System.out.println("a > b");
    } else {
      System.out.println("a == b");
    }
  }
}


Measured memory_bytes: 26160
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{␣"; for(auto nth : list){ cout << nth << "␣"; } cout << "}" << endl;

using namespace std;

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

int main() {
    string S;
    string cmp = "CODEFESTIVAL2016";
    cin >> S;

    int ans = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != cmp[i]) ans++;
    }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int N;
int M;
int A[1010][1010];
vector<int> g[1000100];
vector<int> topo;
int rev[1000100];
bool used[1000100];
int dp[1000100];
int encode(int a,int b){
	if(a>b)swap(a,b); 
	return N*a+b;
}
void dfs(int v){
	used[v] = true;
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(used[u])continue;
		dfs(u);
	}
	topo.pb(v);
	return;
}
void tsort(){
	memset(used,false,sizeof(used));
	for(int i=0;i<M;i++){
		if(!used[i])dfs(i);
	}
	reverse(all(topo));
	memset(rev,-1,sizeof(rev));
	for(int i=0;i<topo.size();i++){
		rev[topo[i]] = i;
	}
	return;
}
bool DAGcheck(){
	for(int i=0;i<topo.size();i++){
		int a = topo[i];
		for(int j=0;j<g[a].size();j++){
			int b = g[a][j];
			if(rev[a]>rev[b])return false;
		}
	}
	return true;
}
int main(){
	cin >> N;
	M = N*N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N-1;j++){
			cin >> A[i][j];
			A[i][j]--;
			if(j>0){
				// cout << i << ',' << A[i][j-1] << " -> " << i << ',' << A[i][j] << endl;
				// cout << encode(i,A[i][j-1]) << ' ' << encode(i,A[i][j]) << endl;
				g[encode(i,A[i][j-1])].pb(encode(i,A[i][j]));
			}
		}
	}
	tsort();
	// dump(topo);
	if(!DAGcheck()){
		cout << -1 << endl;
		return 0;
	}
	int ans = 0;
	for(int i=0;i<topo.size();i++){
		int a = topo[i];
		for(int j=0;j<g[a].size();j++){
			int b = g[a][j];
			chmax(dp[b],dp[a]+1);
		}
		chmax(ans,dp[a]);
	}
	cout << ++ans << endl;
	return 0;
}


Measured memory_bytes: 56048
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int par[200005],sz[200005],n,k,l,p[200005],q[200005],r[200005],s[200005],ans[200005],par1[200005],sz1[200005];

int f(int i)
{
	if(par[i]!=i)
	par[i]=f(par[i]);
	return par[i];
}

void merge(int a,int b)
{
	a=f(a),b=f(b);
	if(a==b)return;
	par[a]=b;
	sz[b]+=sz[a];
}

int f1(int i)
{
	if(par1[i]!=i)
	par1[i]=f1(par1[i]);
	return par1[i];
}

void merge1(int a,int b)
{
	a=f1(a),b=f1(b);
	if(a==b)return;
	par1[a]=b;
	sz1[b]+=sz1[a];
}

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>k>>l;

rep(i,0,k-1)cin>>p[i]>>q[i];
rep(i,0,l-1)cin>>r[i]>>s[i];

rep(i,1,n)par[i]=i,sz[i]=1;

rep(i,0,k-1)
{
	merge(p[i],q[i]);
}

rep(i,1,n)par1[i]=i,sz1[i]=1;

rep(i,0,l-1)
{
	merge1(r[i],s[i]);
}
map<pii,int> m;

rep(i,1,n)m[mp(f(i),f1(i))]++;

rep(i,1,n)
{
	ol(m[mp(f(i),f1(i))]);os;
}

return 0;
}


Measured memory_bytes: 16640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();

    println!("{}", s.into_iter().filter(|x| *x == '1').count());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;

  vector<char> ans;

  REP(i, s.size()){
    if(s[i] == 'B' && ans.size()) ans.pop_back();
    else if(s[i] != 'B') ans.pb(s[i]);
  }

  REP(i, ans.size()) cout << ans[i];

  return 0;
}


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

int main(void)
{
	int m,n,i,j;
	char s[10001][100];
	int pl[1001],flg;
	int p,sum,cnt,f,nn;
	
	while(1)	{
		scanf("%d %d",&m,&n);
		if(m==0 && n==0)	break;
		for(i=1;i<=n;i++)	scanf("%s",s[i]);
		for(i=1;i<=m;i++)	pl[i]=i;
		p=1;	
		cnt=m;
		for(i=1;i<=n;i++)	{
			flg=1;
			if(i%15==0)	{
				if(strcmp(s[i],"FizzBuzz")!=0)	{
					flg=0;	cnt--;
				}
			}
			else if(i%3==0)	{
				if(strcmp(s[i],"Fizz")!=0)	{
//					printf("p=%d pl=%d\n",p,pl[p]);
					flg=0;	cnt--;
				}
			}
			else if(i%5==0)	{
				if(strcmp(s[i],"Buzz")!=0)	{
//					printf("p=%d pl=%d\n",p,pl[p]);				
					flg=0;	cnt--;
				}
			}
			else {
				nn=strlen(s[i]);
				sum=0;
				for(j=0;j<nn;j++)	{
					sum*=10;
					sum+=s[i][j]-'0';
				}
//				printf("sum=%d\n",sum);
				if(sum!=i)	{
					flg=0;	cnt--;
//					printf("ccc\n");
				}
			}
			if(flg==0)	{
				for(j=p;j<=cnt;j++)	{
					pl[j]=pl[j+1];
//					printf("pl=%d \n",pl[j]);
				}
			}
			else {
				p++;
			}
			if(p>cnt)	p=1;	
			if(cnt==1)	break;
		}
		f=1;
		for(i=1;i<=cnt;i++)	{
			if(f==1)	{
				printf("%d",pl[i]);
				f=0;
			}
			else {
				printf(" %d",pl[i]);
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2016
#include <stdio.h>

int main(void){
    int n = 0,
        a = 0,
        maximum = -1000000,
        minimum = 1000000;
    long sum = 0;
    
    scanf("%d", &n);
    
    while(scanf("%d", &a) != EOF || n > 0){
        sum += a;
        if ( a >= maximum ) {
            maximum = a;
        }
        if ( a <= minimum ) {
            minimum = a;
        }
        n--;
    }
    
    printf("%d %d %ld\n", minimum, maximum, sum);
}

Measured memory_bytes: 1848
A,B,C=map(int,input().split())

if A==B:
    if B==C:
        flg=False
    else:
        flg=True
elif B==C:
    flg=True
elif A==C:
    flg=True
else:
    flg=False

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9104
def lcm(a, b):
    x, y = a, b
    while y != 0:
        x, y = y, x % y
    return a * b // x

N = int(input())
T = [int(input()) for _ in range(N)]

ans = 1
for t in T:
    ans = lcm(ans, t)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<double> a(n);  rep(i, 0, n) cin >> a.at(i);
  
  sort(all(a));
  
  rep(i, 0, n-1)
    a.at(i+1) = (a.at(i) +a.at(i+1)) /2;
  
  cout << a.at(n-1) << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i <= n-1; i++) {
		cin >> a[i];
	}
	
	int count = 0;
	for (int i = 0; i <= n-1; i++) {
		int flag = 1;
		while (flag) {
			flag = 0;
			for (int j = n-1; j >= 1; j--) {
				if (a[j] < a[j-1]) {
					int tmp = a[j];
					a[j] = a[j-1];
					a[j-1] = tmp;
					flag = 1;
					count++;
				}
			}
		}
	}
	
	for (int i = 0; i <= n-1; i++) {
		cout << a[i];
		if (i < n-1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3104
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, A, B = map(int, input().split())

dis = B - A
if dis % 2 == 0:
    ans = dis // 2
else:
    ans = min(A - 1, N - B) + 1 + ((B - A) // 2)

print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <string>

using namespace std;

int A[101][101];

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

    fill(A[0], A[101], 0);

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            A[i][j] = A[i][j] + A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
        }
    }

    int ans = -100000001;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int ii = i + 1; ii <= n; ii++) {
                for (int jj = j + 1; jj <= n; jj++) {
                    ans = max(ans, A[ii][jj] - A[i][jj] - A[ii][j] + A[i][j]);
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3152
#include<stdio.h>

int main()
{
    int A,B,C,D,x=0,y=0;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if(1<=A && A<=10000 && 1<=B && B<=10000 && 1<=C && C<=10000 && 1<=D && D<=10000)
    {
        x=A*B;
        y=C*D;
        if(x>y || x==y) printf("%d",x);
        else printf("%d",y);
    }

return 0;
}

Measured memory_bytes: 1692
#include <stdio.h>
#include <stdlib.h>

int minimum(int a, int b){ return a < b ? a : b; }

int main(){
	int N, K, i, x[100000], ans=2000000000, n1, n2;

	scanf("%d %d", &N, &K);

	for(i=0; i<N; i++)
		scanf("%d", &x[i]);

	for(i=0; (i+K-1)<N; i++){
		n1 = abs(x[i])+abs(x[i]-x[i+K-1]);
		n2 = abs(x[i+K-1])+abs(x[i+K-1]-x[i]);

		ans = minimum(ans, minimum(n1, n2));
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007;

int main (void){
	long long n,m,i,lcm,gcd,flag=0;
	char s[100001],t[100001];
	cin >> n >> m;
	cin >> s >> t;
	for(i=n;i>=1;i--){
		if(n%i==0&&m%i==0){
			gcd=i;
			break;
		}
	}
	lcm=n*m/gcd;
	n=n/gcd;
	m=m/gcd;
	for(i=0;i<gcd;i++){
		if(s[n*i]!=t[m*i]) {
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << lcm << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
	int k , index=0;	cin>>k;
	vector<long long>v;
	for(int i=1;i<10;i++)
		v.push_back(i);
	while(v.size()<k)
	{
		int ed=v.size();
		for(int i=index;i<ed;i++){
			if(v[i]%10!=0)
				v.push_back(v[i]*10+(v[i]%10)-1);
			v.push_back(v[i]*10+(v[i]%10));
			if(v[i]%10!=9)
				v.push_back(v[i]*10+(v[i]%10)+1);
		}
		index=ed;
	}
	cout<<v[k-1]<<endl;
	
}

Measured memory_bytes: 2420