akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

class Dice3{
public:
	Dice3(){
		number = new int[6];
		checkTable = new int[101];
		for(int i = 0; i < 101; i++) checkTable[i] = -1;
	};
	~Dice3(){
		delete[] number;
		delete[] checkTable;
	};

	void setLabel(int index,int num){
		number[index] = num;
		checkTable[num] = index;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isValidMember(int inputed[]){
		for(int i = 0; i < 6; i++)
		{
			if(checkTable[inputed[i]] == -1)
				return false;
		}
		return true;
	}
	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* checkTable;
};

int main(){
	Dice3 dice3;
	int tmp,inputed[6];
	for(int i = 0; i < 6; i++){
		scanf("%d",&tmp);
		dice3.setLabel(i,tmp);
	}
	for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);

	if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2616
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	cin >> N;
	vector<string>S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < N; i++) {
		sort(S[i].begin(), S[i].end());
	}
	sort(S.begin(), S.end());
	LLI cnt = 0;
	LLI a = 1;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			a++;
		}
		else {
			cnt += nCr(a,2);
			a = 1;
		}
	}
	cnt += nCr(a, 2);
	cout << cnt << endl;
}

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

int sort(int* A, int N);

int main(void){
    int N;
    cin>>N;
    int* A = (int*)malloc(sizeof(int)*N);
    int count;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    count=sort(A,N);
    for(int i=0;i<N-1;i++){
        cout<<A[i]<<" ";
    }
    cout<<A[N-1]<<endl;
    cout<<count<<endl;
    return 0;
}

int sort(int* A, int N){
    int mini;
    int tmp;
    int count=0;
    for(int i=0;i<N;i++){
        mini=i;
        for(int j=i;j<N;j++){
            if(A[j]<A[mini]){
                mini=j;
            }
        }
        tmp=A[i];
        A[i]=A[mini];
        A[mini]=tmp;
        if(mini!=i){
            count++;
        }
    }
    return count;
}



Measured memory_bytes: 3100
#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 ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n, m;
    cin >> n >> m;
    int t = 1900 * m + 100 * (n - m);
    // double p = pow(1.0 / 2, m);
    // double ans = 0.0;
    // rep(i, (int)1e5) {
    //     ans += (i + 1) * t * pow(1 - p, i) * p;
    // }
    // cout << (int)(ans + 0.001) << endl;
    int e = 1;
    rep(i, m) {
        e *= 2;
    }
    cout << t * e << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {


  int n;
  cin >> n;
  int arr[n];
  for (auto &test : arr) {
    cin >> test;
  }
  vector <int> dp(n, 0x3f3f3f3f);
  dp[0] = 0;
  for (int j = 1; j < n; ++j) {
    for (int k : {j - 1, j - 2}) {
      if (k >= 0) {
        dp[j] = min(dp[k] + abs(arr[k] - arr[j]), dp[j]);
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ll a, b, k;
    scan(a, b, k);

    ll eat = a - k;
    ll tak = max(0LL, a - k);
    ll aok = b;
    if (0 < -eat)
        aok = max(0LL, aok + eat);
    print(tak, aok);

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
  int n;
  cin >> n;
  
 vector<int> s(n);
  for(int i =0; i<n; i++){
    cin >> s.at(i);}
  
  int ans=0;
  
     for(int i = 1; i<n-1; i++){
       if(s.at(i-1)<s.at(i)&&s.at(i)<s.at(i+1)||s.at(i-1)>s.at(i)&&s.at(i)>s.at(i+1)){
         ans++;}}
       
       cout << ans << endl;}
         

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

bool is_ss(string s){
    if(s.length()%2) return false;

    bool flg;
    rep(i, s.length()/2){
        if(s[i]!=s[i+s.length()/2]) return false;
    }
    return true;
}

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

    string s;
    cin >> s;

    int res = s.length()-1;

    rep(i, s.length()){
        string tmp = s.substr(0, s.length()-(i+1));
        if(is_ss(tmp)) break;
        else --res;
    }

    cout << res << endl;

}

Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()
	c := nextString()
	fmt.Println(string(c[0] + 1))
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
const int MAX=1e5+5;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int>a(2*n,0);
	for(int i=0;i<n;i++)
	cin>>a[i];
	vector<pair<int,int> >v(m);
	for(int i=0;i<m;i++)
	{
		cin>>v[i].second>>v[i].first;
	 } 
	 sort(v.begin(),v.end());
	 reverse(v.begin(),v.end());
	 for(int z=0,j=n;z<m;z++){
 	 for(int i = 0; i < v[z].second && j < 2*n; i++, j++) {
 				a[j] = v[z].first;
			 }
 		}
	 sort(a.begin(), a.end());
 	 reverse(a.begin(), a.end());
	 long long sum=0;
	 for(int i=0;i<n;i++)
	 {
	 	sum+=a[i];
	 }
	 cout<<sum;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>


using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1), b(n);
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] + a[i + 1] <= b[i]) {
			sum += a[i] + a[i + 1];
			a[i + 1] = 0;
		}
		else {
			sum += b[i];
			if (a[i] < b[i])a[i + 1] = a[i + 1] - (b[i] - a[i]);
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define ROW 101
#define COL 101

int main(void) {
  int r,c,i,j;
  int matrix[ROW][COL]={0};
  scanf("%d %d",&r,&c);
  for(i=0;i<r;i++)
    for(j=0;j<c;j++){
      scanf("%d",&matrix[i][j]);
      matrix[i][c]+=matrix[i][j];
      matrix[r][j]+=matrix[i][j];
    }
  for(i=0;i<r;i++)
    matrix[r][c]+=matrix[i][c];
  for(i=0;i<=r;i++)
    for(j=0;j<=c;j++){
      printf("%d",matrix[i][j]);
      if(j<c)
	printf(" ");
      else
	printf("\n");
    }
  return 0;
}

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

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;


int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	int n = 0, q = 0;
	
	std::cin >> n;
	std::vector<int> S(n);
	for (int i = 0; i < n; i++) {
		std::cin >> S[i];
	}

	std::cin >> q;
	std::vector<int> T(q);
	for (int i = 0; i < q; i++) {
		std::cin >> T[i];
	}

	int ans = 0;
	for (int i = 0; i < q; i++) {
		if (std::binary_search(S.begin(),S.end(),T[i])) {
			ans++;
		}
	}

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

}

Measured memory_bytes: 3320
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for L in range(min(N, K) + 1):
    for R in range(min(N - L, K - L) + 1):
        js = V[:L] + V[-R:] if R >= 1 else V[:L]
        t = K - L - R
        s = 0
        for j in sorted(js):
            if j < 0 and t > 0:
                s += -j
                t -= 1
        ans = max(ans, sum(js) + s)

print(ans)


Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ant=[a,b,c,d,e]
for i in range(5):
    for j in range(5):
        if abs(ant[i]-ant[j]) > k:
            print(":(")
            quit()
print("Yay!")


Measured memory_bytes: 3064
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a[300001],ans,sum[64];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int i=n;i;--i)
	{
		for(int j=0;j<63;++j)
		{
			if((a[i]>>j)&1)
			{
				++sum[j];
			}
		}
	}
	for(int i=0;i<63;++i)
	{
		ans=(ans+((sum[i]*(n-sum[i]))%1000000007)*((1ll<<i)%1000000007))%1000000007;
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b - c - d > 0) printf("Left\n");
    else if (a + b - c - d == 0) printf("Balanced\n");
    else printf("Right\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	if(s=="AAA" || s=="BBB")
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200010;

ll n,m,md,ans;
ll a[maxn],pre[maxn];;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	ans = 0 ;
	memset(pre,0,sizeof(pre));
	n=read();
	
	for(ll i=1;i<=n;i++)
	{
		a[i] = read();
		pre[i] = a[i];
		pre[i] += pre[i-1];
	}
//	for(ll i=1;i<=n;i++){
//		printf("%d ",pre[i]);
//	}printf("\n");
	
		ll ans1=0,ans2=0;
		md = 0;
		pre[0]=-1;
		for(ll i=0;i<n;i++){
			ll tmp = md;
	//		printf("%d\n",tmp);
			if(((pre[i]+tmp) * (pre[i+1]+tmp) >= 0)){
				if((pre[i]+tmp) < 0){
					md += (1ll - (pre[i+1]+tmp));
					ans1 += (1ll - (pre[i+1]+tmp));
				}else {
					md -= ((pre[i+1]+tmp) + 1ll);
					ans1 += (1ll + (pre[i+1]+tmp));
				}
			}
		}
		
		md = 0;
		pre[0]=1;
		for(ll i=0;i<n;i++){
			ll tmp = md;
	//		printf("%d\n",tmp);
			if(((pre[i]+tmp) * (pre[i+1]+tmp) >= 0)){
				if((pre[i]+tmp) < 0){
					md += (1ll - (pre[i+1]+tmp));
					ans2 += (1ll - (pre[i+1]+tmp));
				}else {
					md -= ((pre[i+1]+tmp) + 1ll);
					ans2 += (1ll + (pre[i+1]+tmp));
				}
			}
		}
		ans = min(ans1, ans2);
	
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 6072
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <cmath>
#include "cstdlib"

using namespace std;

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

	double mean = 0;

	vector<int> a(N);

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

	mean /= (double)N;

	double min = 100000000;
	int out = 0;

	for(int i = 0; i < N; i++) {
		if(fabs(mean - a[i]) < min){
			min = fabs(mean - (double)a[i]);
			out = i;
		}
	}

	cout << out << endl;
}

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

const int N = 1e5 + 5;

inline long long read()
{
    long long f = 1, sum = 0;  char ch = getchar();
    while ( !isdigit(ch) ) { if ( ch == '-' ) f = -1; ch = getchar(); }
    while ( isdigit(ch) ) { sum = (sum<<1) + (sum<<3) + (ch^48); ch = getchar(); }
    return f * sum;
}

int n, sa, sb;
int a[N], b[N], ta[N], tb[N], d[N], fa[N];
map < int, int > q;

inline int find ( register int x )
{
    return fa[x] == x ? fa[x] : fa[x] = find ( fa[x] );
}

inline int unionn ( register int x, register int y )
{
    fa[x] = y;
}

int main()
{
    n = read();
    for ( register int i = 1 ; i <= n ; i ++ )  a[i] = read(), sa ^= a[i]; a[n+1] = sa;
    for ( register int i = 1 ; i <= n ; i ++ )  b[i] = read(), sb ^= b[i]; b[n+1] = sb;
    n ++;
    memcpy ( ta, a, sizeof(a) ), memcpy ( tb, b, sizeof(b) );
    sort ( ta + 1, ta + n + 1 ), sort ( tb + 1, tb + n + 1 );
    for ( register int i = 1 ; i < n ; i ++ )
        if ( ta[i] != tb[i] )
            return puts ( "-1" ), 0;
    register int ans = 0, num = 0;
    for ( register int i = 1 ; i <= n ; i ++ )
        if ( a[i] != b[i] || i == n )
        {
            d[++num] = a[i], d[++num] = b[i];
            if ( i < n )  ans ++;
        }
    if ( ans == 0 )  return puts ( "0" ), 0;
    sort ( d + 1, d + num + 1 );
    num = unique ( d + 1, d + num + 1 ) - d - 1;
    for ( register int i = 1 ; i <= num ; i ++ )  fa[i] = i;
    for ( register int i = 1 ; i <= n ; i ++ )
        if ( a[i] != b[i] )
        {
            a[i] = lower_bound ( d + 1, d + num + 1, a[i] ) - d;
            b[i] = lower_bound ( d + 1, d + num + 1, b[i] ) - d;
            if ( !q[a[i]] )  q[a[i]] = 1;
            if ( !q[b[i]] )  q[b[i]] = 1;
            unionn ( find ( a[i] ), find ( b[i] ) );
        }
    for ( register int i = 1 ; i <= num ; i ++ )
        if ( fa[i] == i )
            ++ ans;
    printf ( "%d", ans - 1 );
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,j,m,p,k,q;
	char c,w;
  while(cin>>n,n){
  	int a[26]={0},i,f=1,q=0;
    for(i=1;i<=n;i++){
	  cin>>c;
	  for(a[c-'A']++,m=j=0;j<26;j++)if(max(m,a[j])==a[j]){k=j;m=a[j];}
	  for(p=j=0;j<26;j++)if(j!=k)p=max(p,a[j]);
	  if(m>n-i+p&&f){
	  	q=i;
	  	w=k+'A';
	  	f=0;
	  }
	}
	if(q>0)cout<<w<<' '<<q<<endl;
	else cout<<"TIE"<<endl;
  }
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int N; cin >> N;
  if(N >= 64){cout << 64 << endl; return 0;}
  if(N >= 32){cout << 32 << endl; return 0;}
  if(N >= 16){cout << 16 << endl; return 0;}
  if(N >= 8){cout << 8 << endl; return 0;}
  if(N >= 4){cout << 4 << endl; return 0;}
  if(N >= 2){cout << 2 << endl; return 0;}
  cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3648
def main():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        divisors.sort(reverse = True)
        return divisors
    n, m = list(map(int, input().split()))
    for i in make_divisors(m):
        if m // i >= n:
            print(i)
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

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

        int num = 0;

        while(true){
            String sent = scn.next();
            if(sent.equals("END_OF_TEXT")) break;

            String sent_l = sent.toLowerCase();

            if(sent_l.equals(word)) num++;
        }

        System.out.println(num);
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p, a(n);
	int count = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		//a[i] = i + 1;
		if (x != (i + 1)) count++;
	}

	if (count == 2 || count == 0) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#00:30
n = int(input())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
now = [0]
pre = [10**6 for _ in range(n)]
pst = [[] for _ in range(n)]
seen = [0 for _ in range(n)]
seen[0] = 1
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        pre[y] = x
        pst[x].append(y)
        now.append(y)
#print(pre)
r = 0
z = n-1
while True:
  r += 1
  z = pre[z]
  if z == 0:
    break
z = n-1
for _ in range(r-r//2-1):
  z = pre[z]
cnt = 0
nowz = [z]
#print(z)
while nowz:
  lastz = nowz
  nowz = []
  cnt += len(lastz)
  for x in lastz:
    nowz += pst[x]
  #print(lastz)
if cnt >= (n+1)//2:
  print('Snuke')
else:
  print('Fennec')
#print(cnt)

Measured memory_bytes: 69280
#include<iostream>
using namespace std;
const int INF = 1e9;

int n, k, w[100000];
int w_mx = 0;

bool b_search(int p)
{
  int pointer = 0;
  for(int i = 0; i < k && pointer < n; i++){
    int truck = 0;
    while(pointer < n && truck + w[pointer] <= p)
      truck += w[pointer++];
  }
  
  if(pointer < n)
    return false;
  return true;
}

int main()
{
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> w[i];

  int s = 0, e = INF;
  while(e - s > 1){
    int mid = (s + e) / 2;
    if(b_search(mid))
      e = mid;
    else
      s = mid;
  }

  cout << e << endl;
  return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int PalindNum(int n){
    int A[5], i = 0;
    while (n > 0){
        A[i] = n % 10;
        n /= 10;
        i++;
    }
    if (A[0] == A[4] && A[1] == A[3]) {
        return 1;
    }else return 0;
}

int main(){
    int A, B;
    cin >> A >> B;
    
    int cnt = 0, total=0;
    
    for (int i = A; i <= B; i++) {
        total += PalindNum(i);
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b = [int(x) for x in input().split()]
s = input()

passed = 0
outer = 0

for i in range(n):
    if s[i] == "a":
        if passed < a+b:
            passed += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "b":
        if passed < a+b and outer < b:
            passed += 1
            outer += 1
            print("Yes")
        else:
            outer += 1
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
n=int(input())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ans = 0

for i in range(n-1,-1,-1):
    ans += (ab[i][1]-(ab[i][0]+ans)%ab[i][1])%ab[i][1]
print(ans)

Measured memory_bytes: 59864
b[101][101];xg,yg;r(x,y,c){if(c!=b[x][y])return 0;if(x==xg&&y==yg)return 1;b[x][y]=0;return r(x+1,y,c)||r(x,y+1,c)||r(x-1,y,c)||r(x,y-1,c)?1:0;}main(xs,ys,n,c,d,x,y){for(;scanf("%d%d",&x,&y),x;puts(b[xs][ys]&&b[xg][yg]&&b[xs][ys]==b[xg][yg]&&r(xs,ys,b[xs][ys])?"OK":"NG"))for(scanf("%d%d%d%d%d",&xs,&ys,&xg,&yg,&n);n;n--)if(scanf("%d%d%d%d",&c,&d,&x,&y),d)b[x][y]=b[x+1][y]=b[x][y+1]=b[x+1][y+1]=b[x][y+2]=b[x+1][y+2]=b[x][y+3]=b[x+1][y+3]=c;else b[x][y]=b[x+1][y]=b[x+2][y]=b[x+3][y]=b[x][y+1]=b[x+1][y+1]=b[x+2][y+1]=b[x+3][y+1]=c;exit(0);}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int n,l,a[100001],sum=0,flag1=0,flag2=0;
int main(){
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		a[i]=l+i-1;
		sum+=a[i];
		if(a[i]>0)flag1++;
		if(a[i]<0)flag2++;
	}
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			cout<<sum;
			return 0;
		}
	}
	sort(a+1,a+n+1);
	if(flag1==n){
		cout<<sum-a[1];
		return 0;
	}
	else{
		cout<<sum-a[n];
	}
	return 0;
} //-2 -1 -3

Measured memory_bytes: 256
#include <stdio.h>
int n,x,i,j,k,a[101],b[101][101],ans=-99999;
int main(void){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&x);
			a[j]=x+a[j-1];
		}
		for(j=1;j<=n;j++){
			for(k=j;k<=n;k++){
				b[j][k]+=a[k]-a[j-1];
				if(b[j][k]>ans)ans=b[j][k];
				if(b[j][k]<0)b[j][k]=0;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
S = str(input())
fr = int(S[0]+S[1])
sc = int(S[2]+S[3])

if fr<=12 and fr!=0:
  if sc<=12 and sc!=0:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if sc<=12 and sc!=0:
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    
    vector <int> cnt(4);
    for (int i = 0; i < 3; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        cnt[a]++; cnt[b]++;
    }
    
    bool f = true;
    for (int i = 0; i < 4; i++){
        if (1 <= cnt[i] && cnt[i] <= 2){
        }else{
            f = false;
        }
    }

    if (f == true) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
// #define long long llint
long long n2place(long long a, long long b){
    return b==1?a%2:n2place(a/2,b-1);
}
typedef struct{
        long long aa;
        long long bb;
    }s;
int cmp( const void *p, const void *q ) {
    return ((s*)p)->bb - ((s*)q)->bb;
}
long long standnum2(long long a){
    long long count=1,i,b;
    b=a;
    while(1){
        if(b/2==0) break;
        count++;
        b/=2;
    }
    long long stand=0;
    for(i=0;i<count;i++){
        if(n2place(a,i+1)==1) stand++;
    }
    return stand;
}

int main(void){
    long long i,j,k,n,count,honest=0;
    scanf("%lld",&n);
    long long a[n],x[250],y[250],suma[n+1],judge[n];
    suma[0]=0;
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
        for(j=0;j<a[i];j++){
            scanf("%lld",&x[suma[i]+j]);
            scanf("%lld",&y[suma[i]+j]);
        }
        suma[i+1]=suma[i]+a[i];
    }
    // for(j=0;j<n+1;j++){
    //         printf("%lld ",suma[j]);
    //     }
    count = pow(2,n);
    s number[count];
    for(i=0;i<count;i++){
        number[i].aa=i;
    }
    for(i=0;i<count;i++){
        number[i].bb=standnum2(i);
    }
    qsort(number,count,sizeof(s),cmp);
    // for(i=0;i<count;i++){
    //     printf("%lld ",number[i].bb);
    // }

    for(i=count;i>0;i--){
        for(j=0;j<n;j++){
            judge[j] = n2place(number[i-1].aa,j+1);
            // if(n2place(count,j+1) == 0){
            //     judge[j]=0;
            //     for(k=0;)
            // }else{
            //     judge[j]=1;
            // }
        }
        // for(j=0;j<n;j++){
        //     printf("%lld ",judge[j]);
        // }
        // printf("\n");
        for(j=0;j<n;j++){
            if(judge[j]==0) continue;
            for(k=suma[j];k<suma[j+1];k++){
                if(y[k]!=judge[x[k]-1]) break;
            }
            if(k!=suma[j+1]) break;
        }
        if(j==n){
            for(j=0;j<n;j++){
                if(judge[j]==1) honest++;
            }
            break;
        }
    }
    if(i==0) honest=i;

    printf("%lld\n",honest);
    return 0;
}

Measured memory_bytes: 1148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int max = ((n-1) * (n-2))/2;
		
		if(k > max)
		{
			System.out.println(-1);
			return;
		}
		
		StringBuilder sb = new StringBuilder();
		int e = n-1 + (max-k);
		sb.append(e + "\n");
		for(int i = 2; i <= n; i++)
		{
			sb.append(1 + " " + i + "\n");
		}
		int xe = max - k;
		int xed = 0;
		
		for(int x = 2; x <= n && xed < xe; x++)
			for(int y = x+1; y <= n && xed < xe; y++)
			{
				sb.append(x + " " + y + "\n");
				xed++;
			}

		System.out.print(sb);
	}

}


Measured memory_bytes: 23764
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  vll b(n);
  rep(i,n-1){
    cin >> b[i];
  }
  ll ans = 0;
  for(int i = n-2; i >= 0; i--){
    /*
    if(b[i-1] > b[i] and i != 0){
      b[i-1] = b[i];
    }*/
    if(b[i] > b[i+1] and i != n-2){
      ans += b[i+1];
    }else{
      ans += b[i];
    }
  }
  ans += b[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
  
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
 
//Appropriately Changed
using edge=struct{int to,cost;};
using G=vector<vector<edge>>;
 
//Appropriately Changed
void add_edge(G &graph,int from,int to,int cost){ 
    graph[from].push_back({to,cost});
}
 
G chu_liu(const G &graph,int root){
    using W=int; const W inf=1<<28;
    const int n=graph.size();

    vector<int> cost(n,inf),pv(n,-1);
    rep(v,n) for(auto &e:graph[v]) if(chmin(cost[e.to],e.cost)) pv[e.to]=v;
 	
    int led=-1,unuse=-1;
    vector<int> comp(n),used(n,-1);
    iota(begin(comp),end(comp),0);

    rep(v,n)if(used[v]== -1 and pv[v]!=-1 and v!=root){
        int cur=used[v]=v;
        for(cur=pv[cur]; cur!=root && used[cur] == -1; cur=pv[cur]) used[cur]=v;
 
        if(used[cur]!=v) continue;
    	led=cur,comp[cur]=cur,v=n; 
    	for(int w=pv[cur]; w != cur; w=pv[w]) comp[w]=cur;
    }
 
    G ngraph(n),ret(n);
    using E=tuple<int,int,int>; map<E,E> dict;

    if(led==-1){
      	rep(v,n) if(v!=root and pv[v]!=-1)add_edge(ret,pv[v],v,cost[v]);
    }else{
		rep(v,n) for(auto &e:graph[v]){
			int a=comp[v],b=comp[e.to],c=e.cost;
			if(comp[e.to]==led) c-=cost[e.to];
			if(a==b) continue;
			dict[E(a,b,c)]=E(v,e.to,e.cost);
			add_edge(ngraph,a,b,c);
		}
		
		auto ntree=chu_liu(ngraph,comp[root]);

		rep(v,n) for(auto &e:ntree[v]){
			int a,b,c;
			tie(a,b,c)=dict[E(v,e.to,e.cost)];
			if(comp[b]==led) unuse=b;
			add_edge(ret,a,b,c);
		}

		rep(v,n) if(comp[v]==led and v!=unuse) add_edge(ret,pv[v],v,cost[v]);
	}
    return ret;
}

int main(void){
    int v,e,r;
    cin >> v >> e >> r;
    G graph(v);
    rep(i,e){
        int a,b,w;
        cin >> a >> b >> w;
        add_edge(graph,a,b,w);
    }
 
    auto tree=chu_liu(graph,r);
    int ans=0;
    rep(i,v) for(auto &e:tree[i]) ans+=e.cost;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	int x = n / 1.08;

	if((int)(x * 1.08) == n){
		cout << x;
	}
	else if((int)((x + 1) * 1.08) == n){
		cout << x + 1;
	}
	else{
		cout << ":(";
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
  int n,f=0;
  char s[99];
  scanf("%s",s);
  
  n=strlen(s);
  
  for(int i=0;i<(n-1)/2;i++)
  {
    if(s[i]!=s[n-i-1])
      f=1;
  }
  
  if(f==0)
  {
    for(int i=0;i<(n-1)/4;i++)
    {
      if(s[i]!=s[(n-1)/2-i-1])
      f=2;
    }
  }
  
  if(f==0)
  {
    for(int i=(n+3)/2-1;i<n;i++)
    {
      if(s[i]!=s[n-i+(n+3)/2-2])
      f=3;
    }
  }
  
  if(f==0)
  printf("Yes");
  else
    printf("No");

}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

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

		char[] moji = new char[S.length()];

	    for(int i = 0; i < S.length(); i++){
	            moji[i] = S.charAt(i);
	    }
	    if(S.length()>K) {
	    	for(int i =0; i<K; i++) {
	    		System.out.print(moji[i]);
	    	}
	    	System.out.println("...");
	    }else {
	    	System.out.println(S);
	    }

}
}

Measured memory_bytes: 35624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; cin >> n;
    ll a = INF;
    ll b = -INF;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        ll tmp; cin >> tmp;
        a = min(a,tmp);
        b = max(b,tmp);
        sum += tmp;
    }
    cout << a << ' ' << b << ' ' << sum << endl;
}


Measured memory_bytes: 3104
import java.util.Scanner;

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

		if (s.equals("SUN"))
			System.out.println(7);
		else if (s.equals("SAT"))
			System.out.println(1);
		else if (s.equals("FRI"))
			System.out.println(2);
		else if (s.equals("THU"))
			System.out.println(3);
		else if (s.equals("WED"))
			System.out.println(4);
		else if (s.equals("TUE"))
			System.out.println(5);
		else if (s.equals("MON"))
			System.out.println(6);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define mod pow(10,9)+7
#define lim pow(10,7)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int x=0,y=0;
	if(s[0]==s[1])
	{
		x=1;
		y=2;
	}
	else
	{
		for(int i=2;i<s.length();i++)
		{
			if(s[i]==s[i-1])
			{
				y=i+1;
				x=i;
				break;
			}
			else
			if(s[i]==s[i-2])
			{
				y=i+1;
				x=i-1;
				break;
			}
		}
	}
	if(x!=0)
		cout<<x<<" "<<y<<endl;
	else
		cout<<"-1 -1"<<endl;
	return 0;
}


Measured memory_bytes: 512
N, M = gets.split.map(&:to_i)
Xs = gets.split.map(&:to_i).sort

if M <= N
  ans = 0
else
  diffs = Xs[1..-1].zip(Xs[0..-2]).map{|x1, x2| x1 - x2}.sort.reverse
  ans = diffs[(N-1)..-1].reduce(&:+)
end

puts ans

Measured memory_bytes: 15456
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){

    int n;
    cin >> n;
    vector<int> v(n), u(n), w(n);
    vector< vector < int > > to(n), cost(n);
    for(int i=0; i<n-1; i++){
        int v, u, w;
        cin >> v >> u >> w;
        v--;
        u--;

        to[v].push_back(u);
        to[u].push_back(v);

        cost[v].push_back(w);
        cost[u].push_back(w);
    }

    vector<int> ans(n, -1);
    queue<int> q;

    q.push(0);
    ans[0] = 0;

    while(!q.empty()){
        int v = q.front();
        q.pop();
        // cout << "v=" << v << endl;

        for(int i=0;i<to[v].size();i++){
            int u = to[v][i];
            // cout << "u=" << u << endl;
            if (ans[u]!=-1)
                continue;
            int w = cost[v][i];
            ans[u] = (ans[v]+w)%2;
            q.push(u);
        }
    }

    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 13056
X,N=map(int,input().split())
U=list(range(-1,102))
for i in [int(x) for x in input().split()]:
  del U[U.index(i)]

m=10**3
for i in U:
  if abs(i-X)<m or (abs(i-X)==m and i<d):
    m,d=abs(i-X),i
print(d)


Measured memory_bytes: 9180
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
ans = 0
for i in range(1, N+1, 2):
    yaku = 0
    for j in range(1, i+1):
        if i%j==0:
            yaku += 1
    if yaku == 8:
        ans += 1
print(ans)


Measured memory_bytes: 9064
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
      cin>>c;
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, a, b, duplet = 0, i;
    bool check = false;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (a == b)
            duplet++;
        else
            duplet = 0;
        if (duplet == 3)
            check = true;
    }
    if (check)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  rep(i, M) {
    cin >> s[i] >> c[i];
    s[i]--;
  }

  repp(i, 0, 999) {
    string num = to_string(i);
    if (len(num) != N)
      continue;

    bool ok = true;
    rep(j, M) {
      if (num[s[j]] - '0' != c[j])
        ok = false;
    }

    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int len(unsigned long long int tmp)
{
	int ans = 0;
	while (tmp > 0)
	{
		tmp /= 10;
	}
	return ans;
}

int main()
{
	int n;
	cin >> n;
	vecll v(n);
	bool is_zero = false;
	bool is_overflow = false;
	rep(i, n)
	{
		cin >> v[i];
		if (v[i] == 0)
		{
			is_zero = true;
		}
	}
	if (is_zero)
	{
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	rep(i, n)
	{
		ll pre_ans = ans;
		ans *= v[i];
		if (ans < pre_ans)
		{
			is_overflow = true;
		}
	}
	if (is_overflow)
	{
		cout << -1 << endl;
	}
	else if (ans > 1000000000000000000)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define fi first
#define se second
#define inf (int)1e8
using namespace std;

struct data {
  int p;
  int c;
};

bool operator<(const data &l, const data &r) {
  if(l.c != r.c) return l.c > r.c;
  return l.p > r.p;
}

int n, x;
vector<int> dp;
vector<pair<int, int>> v;
priority_queue<data> pq;

bool ch(data nextp) {
  return nextp.p >= 0 && nextp.p < dp.size();
}
int solve();

int main() {
  cin >> n >> x;
  v.resize(n);
  dp.assign(4 * 100000 + 100, inf);
  for(int i = 0; i < n; ++i) cin >> v[i].fi >> v[i].se;
  cout << solve() << endl;
  return 0;
}

int solve() {
  x += 100050;
  pq.push({100050, 0});
  dp[100050] = 0;
  while(!pq.empty()) {
    data now = pq.top();
    pq.pop();
    for(int i = 0; i < n; ++i) {
      data nextp = now;
      nextp.p += v[i].fi;
      nextp.c += v[i].se;
      if(ch(nextp) && dp[nextp.p] > nextp.c) {
        dp[nextp.p] = nextp.c;
        pq.push(nextp);
      }
      nextp.p -= v[i].fi * 2;
      if(ch(nextp) && dp[nextp.p] > nextp.c) {
        dp[nextp.p] = nextp.c;
        pq.push(nextp);
      }
    }
  }
  if(dp[x] == inf)
    return -1;
  else
    return dp[x];
}


Measured memory_bytes: 8500
s = input()
t = input()

counters = []
for i in range(len(s) - len(t) + 1):
  part_of_s = s[i: i + len(t)]
  counter = 0
  for sss, ttt in zip(part_of_s, t):
    if sss != ttt:
      counter += 1
  counters.append(counter)
print(min(counters))

Measured memory_bytes: 9112
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    string S;cin>>S;
    string list[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i=0;i<7;i++){
        if(list[i]==S)cout<<7-i<<endl;
    }
    return 0;
}


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

const int DIM = 1e5 + 5;


int main(void) {
    ios::sync_with_stdio(false);
    
    string str;
    cin >> str;
    
    for (int l = (int) str.size() - 2; l >= 0; l -= 2) {
        bool ok = true;
        
        for (int i = 0, j = l / 2; i < l / 2; ++i, ++j)
            ok &= str[i] == str[j];
        
        if (ok) {
            cout << l;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        String ans = "No";
        if(C>=A&&C<=B) ans = "Yes";
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt() , b = scan.nextInt();

        int d = a / b;
        int r = a % b;

        String f = String.format("%.5f", ((double)a / (double)b));
        System.out.println(d + " " + r + " " + f);
    }
}

Measured memory_bytes: 26476
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

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

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

int n,a[200010],minv[200010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	minv[1]=a[1];
	for(int i=2;i<=n;i++){
		minv[i]=min(minv[i-1],a[i]);
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]<=minv[i]) cnt++; 
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main (){
  string s ;
  cin>>s;
  if(s=="BBB"){
    cout<<"No"<<endl;
  }
  else if(s=="AAA"){
    cout<<"No"<<endl;
  }
  else {
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256