akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool ss[200000];
int l[200001];
int r[200001];

int main() {
  int n, k, c; string s;
  cin >> n >> k >> c >> s;
  rep(i, n) ss[i] = (s[i] == 'x') ? false : true;
  
  int cnt = 0, i = 0;
  l[0] = 0;
  while (i < n) {
    if (ss[i]) {
      cnt++;
      int j = 0;
      while ((i < n) && (j < c + 1)) {
        l[i+1] = cnt;
        i++; j++;
      }
      while ((i < n) && (!ss[i])) {
        l[i+1] = cnt; i++;
      }
    } else {
      l[i+1] = cnt; i++;
    }
  }
  
  cnt = k+1; i = n-1;
  r[n] = k+1;
  while (i >= 0) {
    if (ss[i]) {
      cnt--;
      int j = 0;
      while ((i >= 0) && (j < c + 1)) {
        r[i] = cnt;
        i--; j++;
      }
      while ((i >= 0) && (!ss[i])) {
        r[i] = cnt; i--;
      }
    } else {
      r[i] = cnt; i--;
    }
  }
  
  //rep(i, n+1) cout << l[i] << " "; cout << endl;
  //rep(i, n+1) cout << r[i] << " "; cout << endl;
  
  rep(i, n) {
    if (r[i+1] - l[i] == 2) cout << i + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5460
n = int(input())
a = list(map(int, input().split()))

ma = max(a)
tmp = 1
m = 0
while True:
    if tmp >= ma:
        break
    tmp *= 2
    m += 1

memo = [0 for i in range(m+1)]

for j in range(m+1):
    cnt0 = 0
    cnt1 = 0
    for ai in a:
        if ai & (1 << j):
            cnt1 += 1
        else:
            cnt0 += 1
    if cnt1 % 2 == 0 and cnt0 % 2 == 0:
        memo[j] = 1

ans = []


for ai in a:
    ansi = 0
    for j in range(m+1):
        if ai & (1 << j):
            if memo[j]:
                ansi += 2 ** j
        else:
            if memo[j] == 0:
                ansi += 2 ** j

    ans.append(str(ansi))

print(" ".join(ans))



Measured memory_bytes: 105148
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

#define N_MAX 100000
int main() {
	int n, a[N_MAX], buf = -1, c = 0, r = 0;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), cmp);
	REP(i, n - 1) {
		if (a[i] == a[i + 1]) {
			c = 1;
			buf *= -1;
		}
		else {
			c = 0;
			if (buf ==  -1)r++;
			buf = -1;
		}
	}
	if (buf == -1)r++;
	printf("%d", r);
	return 0;
}

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

using namespace std;

#define MAX 25

class TreeNode
{
public:
	int Parent()
	{
		if (!pParent) return -1;
		else return pParent->id;
	}

	int Sibling()
	{
		if (!pParent) return -1;
		if (pParent->pLeft != this)
		{
			if (!pParent->pLeft) return -1;
			else return pParent->pLeft->id;
		}
		if (pParent->pRight != this)
		{
			if (!pParent->pRight) return -1;
			else return pParent->pRight->id;
		}
	}

	int Degree()
	{
		int degree = 0;
		if (pLeft) ++degree;
		if (pRight) ++degree;

		return degree;
	}

	int Depth()
	{
		int depth = 0;
		TreeNode* currentNode = pParent;
		while (currentNode)
		{
			++depth;
			currentNode = currentNode->pParent;
		}

		return depth;
	}

	int Height()
	{
		return Height(this);
	}

	int Height(TreeNode* currentNode)
	{
		if (!currentNode->pLeft && !currentNode->pRight) return 0;
		
		int v1 = 0;
		int v2 = 0;
		if(currentNode->pLeft)
			v1 = Height(currentNode->pLeft) + 1;
		if (currentNode->pRight)
			v2 = Height(currentNode->pRight) + 1;

		return max(v1, v2);
	}

	const char* Type()
	{
		if (!pParent) return "root";
		else if (!pLeft && !pRight) return "leaf";
		else return "internal node";
	}

public:
	int id;
	TreeNode* pParent;
	TreeNode* pLeft;
	TreeNode* pRight;
};

TreeNode nodes[MAX];

int main()
{
	int n; cin >> n;
	int id, left, right;
	for (int i = 0; i < n; ++i)
	{
		cin >> id;
		nodes[id].id = id;
		cin >> left >> right;
		if (left == -1) nodes[id].pLeft = 0;
		else
		{
			nodes[id].pLeft = &nodes[left];
			nodes[left].pParent = &nodes[id];
		}
		if (right == -1) nodes[id].pRight = 0;
		else
		{
			nodes[id].pRight = &nodes[right];
			nodes[right].pParent = &nodes[id];
		}
	}

	for (int i = 0; i < n; ++i)
	{
		cout << "node " << nodes[i].id << ": ";
		cout << "parent = " << nodes[i].Parent() << ", ";
		cout << "sibling = " << nodes[i].Sibling() << ", ";
		cout << "degree = " << nodes[i].Degree() << ", ";
		cout << "depth = " << nodes[i].Depth() << ", ";
		cout << "height = " << nodes[i].Height() << ", ";
		cout << nodes[i].Type() << endl;
	}

	return 0;
}


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

int main() {
	int A, B;

	cin >> A >> B;

	if (B%A == 0) {
		cout << A + B << "\n";
	}
	else {
		cout << B - A << "\n";
	}
	return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || b + c == a || c + a == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S[10] = { " ","',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ" };
string H;
int main() {
	while (cin >> H) {
		string T = ""; int cnt = 0;
		if (H[H.size() - 1] != '0')H += '0';
		for (int i = 1; i < H.size(); i++) {
			if (H[i] == H[i - 1]) {
				if (H[i] =='0')T += " ";
				else { cnt++; }
			}
			else {
				if (H[i - 1] == '0')cnt = 0;
				else {
					int NUM = H[i - 1] - '0';
					T += S[NUM][cnt%S[NUM].size()]; cnt = 0;
				}
			}
		}
		cout << T << endl;
	}
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A<=C&&C<=B)||(B<=C&&C<=A)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int cnt=0;
    rep(i,n){
        int m;
        cin >> m;
        while(m%2==0){
            m/=2;
            cnt+=1;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
import sys
import collections


def solve():
    MOD = 998244353
    N, *d_l = map(int, open(0).read().split())
    ans = 1
    
    if d_l[0] != 0:
        print(0)
        sys.exit()
    
    d_max = max(d_l)
    count_dic = collections.Counter(d_l)
    if count_dic[0] != 1:
        print(0)
        sys.exit()
    
    for i in range(2, d_max+1):
        ans *= count_dic[i-1] ** count_dic[i]
    
    print(ans%MOD)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 18992
def bubble_sort(array):
	N = len(array)
	count = 0
	
	for i in range(N - 1):
		flag = 0
		
		for j in range(N - 1, i, -1):
			if array[j - 1] > array[j]:
				array[j - 1], array[j] = array[j], array[j - 1]
				count += 1
				flag = 1
				
		if flag == 0:
			break
	
	return array, count
	
n = int(input())
array = [int(i) for i in input().split()]
result = bubble_sort(array)
print(*result[0])
print(result[1])

Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

ll dp[2001];
ll n;

ll solve(int sum){
	if(sum==n) return 1;
	if(sum>n) return 0;
	
	ll& res = dp[sum];
	if(res!=-1) return res;
	res=0;
	for(int i=3;i<=n;i++){
		if(sum+i>n) break;
		res = add(res, solve(sum+i));
	}
	return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	
	cin>>n;
	memset(dp, -1, sizeof(dp));
 	cout<<solve(0);

    return 0;
}


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

using namespace std;

int pick(int k) {
    return k*(k-1)/2;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = pick(n) + pick(m);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<map>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const double PI=acos(-1.0);
int a[200005];
int main()
{
    int n,xx;
    scanf("%d %d",&xx,&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int maxx=xx-a[n]+a[1];
    for(int i=1;i<n;i++)
    {
        maxx=max(maxx,a[i+1]-a[i]);
    }
    printf("%d\n",xx-maxx);
    return 0;
}


Measured memory_bytes: 1024
K,N = map(int,input().split())
A=list(map(int, input().split()))

A.sort()
#print(A)

B = A[1:]
B.append(A[0])
#print(B)

SUB = [b-a for (a, b) in zip(A,B)]

SUB[-1] += K
#print(SUB)

print(sum(SUB)-max(SUB))

Measured memory_bytes: 26060
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define ls rt << 1
#define rs rt << 1 | 1
#define sz(x) (int)(x).size()
#define ALL(x) (x).insgin(), (x).end()
#define vi vector<int>
#define EPS 1e-8
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

const double pi = acos(-1);
int n;
struct Node
{
	int x, y; 
}a[101];
Node operator-(Node a,Node b)
{ 
	return (Node){a.x - b.x, a.y - b.y}; 
}
double s[101];
int main()
{
	n = read();
	rep(i, 1, n) a[i].x = read(), a[i].y = read();
	rep(i, 1, n)
	{
		int m = 0;
		rep(j, 1, n)
			if(j != i)
			{
				Node b = a[j] - a[i];
				s[++ m] = atan2(b.y, b.x);
			}
		sort(s + 1, s + m + 1);
		s[0] = s[m] - 2 * pi;
		double R = 0;
		rep(j, 1, m) R = max(R, s[j] - s[j - 1]);
		R -= pi;
		if(R >= 0) printf("%.10lf\n", R / (2 * pi));
		else printf("0\n");
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	s[256];
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	if (a + b == 3) {
		printf("3\n");
	} else if (a + b == 4) {
		printf("2\n");
	} else if (a + b == 5) {
		printf("1\n");
	}



	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String s[]=br.readLine().split(" ");

	int a=Integer.parseInt(s[0]);
	int b=Integer.parseInt(s[1]);

	int c=a+b;

	if(a%3==0||b%3==0||c%3==0){
	    System.out.println("Possible");
	}else{
	    System.out.println("Impossible");
	}
    }
}


Measured memory_bytes: 22996
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        if(a <= b){
            System.out.println("unsafe");
        } else{
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 35728
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;

int main() {
	ll n, a, b; cin >> n >> a >> b;
	if ((a-b) % 2 == 0)
		cout << (b-a)/2 << endl;
	else
		cout << min(a + (b-a - 1) / 2, (n - (a+n-b+1)) / 2 + (n - b + 1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a>b){
		cout << a-1 << endl;
	}else if(a<=b){
		cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
numc = (b//c)-((a-1)//c)
numd = (b//d)-((a-1)//d)

cd = int(c*d/gcd(c,d))
numcd = (b//cd)-((a-1)//cd)

print(b-a+1-numc-numd+numcd)

Measured memory_bytes: 38536
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s; cin >> s;
    ll ans = 111111;
    for(int i=0;i<s.size();i++){
        string ss = s.substr(i,3);
        if(ss.size() != 3) continue;

        ans = min<ll>(ans,abs(753-stoi(ss)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	bool ch=true;
	if(a==b&&a!=c){
		ch=false;
	}
	if(b==c&&b!=a){
		ch=false;
	}
	if(c==a&&a!=b){
		ch=false;
	}
	cout << (ch?"No":"Yes");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][] num = new int[4][13];
		for (int i = 0; i < n; i++) {
			String mark = scan.next();
			int innum = scan.nextInt();
			if (mark.equals("S")) {
				num[0][innum-1] = 1;
			}
			else if (mark.equals("H")) {
				num[1][innum-1] = 1;
			}
			else if (mark.equals("C")) {
				num[2][innum-1] = 1;
			}
			else if (mark.equals("D")) {
				num[3][innum-1] = 1;
			}
		}
		for (int k = 0; k < 4; k++) {
			for (int m = 0; m < 13; m++) {
				if (num[k][m] == 0) {
					int l = m;
					l++;
					if (k == 0) System.out.println("S " + l);
					else if (k == 1) System.out.println("H " + l);
					else if (k == 2) System.out.println("C " + l);
					else if (k == 3) System.out.println("D " + l);
				}
			}
		}
	}
}


Measured memory_bytes: 26224
list = list(map(str,input().split()))
for x in list:
    if x=='A':
        x = 10
    elif x=='B':
        x = 11
    elif x=='C':
        x = 12
    elif x=='D':
        x = 13
    elif x=='E':
        x = 14
    elif x=='F':
        x = 15
if list[0]<list[1]:
    print('<')
elif list[0]>list[1]:
    print('>')
else:
    print('=')

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	long long N,B,R;
  cin >> N >> B >> R;
  long long count = N / (B + R);
  N %= (B + R);
  long long b;
  if(N >= B){
    b = B;
  }else{
    b = N;
  }
  cout << count*B + b << endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL a,b,c,na,nb,nc;
  cin >> a >> b >> c;
  LL ans=0;
  for(int i=0;i<100000000;i++){
    if(a%2==0&&b%2==0&&c%2==0&&(a!=b||b!=c||c!=a)){
      na=(b+c)/2;
      nb=(a+c)/2;
      nc=(a+b)/2;
      a=na,b=nb,c=nc;
      ans++;
    }else break;
  }
  if(a==b&&b==c&&a%2==0) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr int64_t INF = 1'010'000'000'000'000'017LL;

constexpr int64_t MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = asin(-1.0);
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int n,max=0,c;
     cin >> n;
    vector<int> a(n);
  vector<int> b(n);
    REP(i, n)cin >> a[i];
   REP(i, n)b[i]=a[i];
  SORT(a);
    REP(i,n){
      if(a[n-1]==b[i]){
      cout <<a[n-2]<<endl;
      }else{
        cout <<a[n-1]<<endl;
      }
         }

}

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

int main()
{
    int a=0;
    scanf("%d",&a);
    int num4 = a % 10;
    int num3 = a/10%10;
    int num2 = a/100%10;
    int num1 = a/1000;
    if(num1 + num2 + num3 + num4 == 7)
        printf("%d+%d+%d+%d=7",num1,num2,num3,num4);
    else if(num1 + num2 + num3 - num4 == 7)
        printf("%d+%d+%d-%d=7",num1,num2,num3,num4);
    else if(num1 + num2 - num3 - num4 == 7)
        printf("%d+%d-%d-%d=7",num1,num2,num3,num4);
    else if(num1 + num2 - num3 + num4 == 7)
        printf("%d+%d-%d+%d=7",num1,num2,num3,num4);
    else if(num1 - num2 - num3 - num4 == 7)
        printf("%d-%d-%d-%d=7",num1,num2,num3,num4);
    else if(num1 - num2 + num3 - num4 == 7)
        printf("%d-%d+%d-%d=7",num1,num2,num3,num4);
    else if(num1 - num2 + num3 + num4 == 7)
        printf("%d-%d+%d+%d=7",num1,num2,num3,num4);
    else if(num1 - num2 - num3 + num4 == 7)
        printf("%d-%d-%d+%d=7",num1,num2,num3,num4);
    return 0;
}


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

int n, m, s, p, x, t[105];
int main()
{
	int i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf("%d", &t[i]);
		s += t[i];
	}
	cin >> m;
	while (m--) {
		scanf("%d %d", &p, &x);
		printf("%d\n", s + x - t[p]);
	}
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

long long modpow(long long a, long long b){ 
  long long r = 1LL;

  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r%MOD;
}

long long nCr(long long n, long long r){ 
  long long ret = 1LL;

  for(int i = 1; i <= r; ++i){
    ret = (ret * ((n - i + 1) % MOD)) % MOD;
  }
  for(int i = 1; i <= r; ++i){
    ret = (ret * modpow(i, MOD - 2)) % MOD;
  }
  return ret%MOD;
}

int main() {
	ll n,k;
	cin>>n>>k;
	rep(i,1,k+1){
		ll blue = i;
		ll red = blue-1;
		ll blue2 = k-blue;
		ll red2 = (n-k)-red;
		ll blue_p = blue;
		ll red_p = red+2;
		if(red2<0){
			cout << "0" << endl;
		}
		else{
			ll ans1 = nCr(blue2+blue_p-1,blue2);
			ll ans2 = nCr(red2+red_p-1,red2);
			ll ans3 = ans1*ans2;
			ans3 %= MOD;
			cout << ans3 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=109;
int n,m,x,c[N],a[N][N],p[N],ans=0x3f3f3f3f;
void dfs(int s,int price){
	if(s==n+1){
		for(int i=1;i<=m;i++) if(p[i]<x) return;
		ans=min(ans,price); 
		return;
	}
	dfs(s+1,price);
	for(int i=1;i<=m;i++) p[i]+=a[s][i];
	dfs(s+1,price+c[s]);
	for(int i=1;i<=m;i++) p[i]-=a[s][i];
}
int main(){
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++) cin>>a[i][j];
	}
	dfs(1,0);
	if(ans>1e9) cout<<-1;
	else cout<<ans;
	return 0;
}

Measured memory_bytes: 3684
from queue import PriorityQueue

N, M = map(int, input().split())
A = list(map(int, input().split()))
queue = PriorityQueue()
for a in A:
    queue.put(-a)
for _ in range(M):
    v = -queue.get()
    queue.put(-(v // 2))

total = 0
while not queue.empty():
    total += -(queue.get())
print(total)

Measured memory_bytes: 77032
def min(a,b); a < b ? a : b; end
  
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
S = Array.new(N + 1, 0)
dp = Hash.new {|h,k| h[k] = [] }

A.each_with_index do |a,i|
  S[i + 1] = S[i] + a
end

(0 .. N).each do |i|
  dp[(S[i] - i) % K] << i
end

ans = dp.inject(0) do |sum, (mod, mods)|
  count = 0
  mods.each_index.inject(0) do |l, r|
    (l .. r).find{|l_| mods[r] - mods[l_] < K }.tap{|l_| count += (r - l_) }
  end
  sum + count
end
puts ans

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

int N, M, Q;
#define MAX_N 100000
vector<int> Adj[MAX_N];
int X[MAX_N]; /* vから距離X[v]までは既に塗られている; -1のとき塗られていない*/
#define MAX_Q 100000
int V[MAX_Q], D[MAX_Q], C[MAX_Q];
int R[MAX_N];

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b; --a; --b; Adj[a].push_back(b); Adj[b].push_back(a);
  }
  cin >> Q;
  for(int q = 0; q < Q; ++q) {
    cin >> V[q] >> D[q] >> C[q]; --V[q];
  }
  for(int v = 0; v < N; ++v) X[v] = -1;
  for(int q = Q - 1; q >= 0; --q) {
    int c = C[q];
    queue<pair<int, int>> que; que.push(make_pair(V[q], D[q]));
    while(!que.empty()) {
      int v = que.front().first, d = que.front().second; que.pop();
      if(d <= X[v]) continue;
      if(X[v] < 0) R[v] = c;
      X[v] = d;
      if(d == 0) continue;
      for(int w : Adj[v]) que.push(make_pair(w, d - 1));
    }
  }
  for(int v = 0; v < N; ++v) cout << R[v] << endl;
  return 0;
}


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

int cmp_num(char c, char t){
  if(c == 'I' && (t == 'V' || t == 'X')){
    return 1;
  }else if(c == 'X' && (t == 'L'|| t == 'C')){
    return 1;
  }else if(c == 'C' && (t == 'D' || t == 'M')){
    return 1;
  }else{
    return 0;
  }
}
int main(){
  char num[100];
  int len;
  int i, cnt;
  while(scanf("%s", num) != EOF){
    len = strlen(num);
    cnt = 0;
    for(i=0;i<len;i++){
      if(i != len-1 && cmp_num(num[i], num[i+1])){
	switch(num[i]){
	case 'I':
	  cnt -= 1;
	  break;
	case 'V':
	  cnt -= 5;
	  break;
	case 'X':
	  cnt -= 10;
	  break;
	case 'L':
	  cnt -= 50;
	  break;
	case 'C':
	  cnt -= 100;
	  break;
	case 'D':
	  cnt -= 500;
	  break;
	}
      }else{
	switch(num[i]){
	case 'I':
	  cnt += 1;
	  break;
	case 'V':
	  cnt += 5;
	  break;
	case 'X':
	  cnt += 10;
	  break;
	case 'L':
	  cnt += 50;
	  break;
	case 'C':
	  cnt += 100;
	  break;
	case 'D':
	  cnt += 500;
	  break;
	case 'M':
	  cnt += 1000;
	  break;
	}
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <string>
using namespace std;
const int MAX_N = 105;
int B[MAX_N];

int main()
{
	int N,K;
	cin >> N >> K;
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size()-1; ++i)
	{
		if (S[i] == S[i+1])
		{
			ans++;
		}
	}

	cout << min(ans + 2 * K, N-1) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>

int main()
{
  int N,M;
  std::cin >> N >> M;
  std::vector<int> tests;
  for(int i=0; i<M; i++)
  {
    int k;
    std::cin >> k;
    int test = 0;
    for(int i=0; i<k; i++)
    {
      int s;
      std::cin >> s;
      test += (1 << (s-1));
    }
    tests.push_back(test);
  }

  std::vector<int> accepts; 
  for(int i=0; i<M; i++)
  {
    int p;
    std::cin >> p;
    accepts.push_back(p);
  }
  
  const int patterns = (1 << N);
  int count = 0;
  for(int i=0; i<patterns; i++)
  {
    bool ok = true;
    for(int j=0; j<tests.size(); j++)
    {
       if( std::bitset<16>(tests[j] & i).count() % 2 != accepts[j] )
       {
         ok = false; break;
       }
    }
    if( ok ) { count += 1; }
  }

  std::cout << count;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    string s,l;
    cin >> s >>l;
    cout <<l<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

#define PI 3.1415926535897932

int main(){
    int a,b,theta=90;
    double x=0,y=0,pi=PI;
    for(;;){
        scanf("%d,%d",&a,&b);
        if(a==0 && b==0){
            break;
        }
        y+=a*sin(theta/180.0*pi);
        x+=a*cos(theta/180.0*pi);
        theta+=b;
    }
    printf("%d\n%d\n",(int)-x,(int)y);
    return 0;
}

Measured memory_bytes: 3452
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	int num, kazu, poll[200000] = { 0 }, max = 0, many = 0;
	char names[200000][11], win[200000][11];
	scanf("%d", &num);

	for (int i = 0; i < num; i++) {
		scanf("%s", names[i]);
	}
	qsort(names, num, 11, strcmp);
	kazu = 0;
	strcpy(win[0],names[0]);


	for (int i = 1; i < num; i++) {
		if (strcmp(names[i], names[i - 1]) == 0) {
			poll[kazu]++;
		}
		else {
			kazu++;
			strcpy(win[kazu],names[i]);
		}
	}

	for (int i = 0; i <= kazu; i++) {
		if (poll[i] > max)max = poll[i];
	}

	for (int i = 0; i <= kazu; i++) {
		if (poll[i] == max) printf("%s\n",win[i]);
	}

	return 0;
}


Measured memory_bytes: 7036
import numpy as np
S = list(map(str,input().split()))
S = [c for c in S[0]]

result = 0
for i in range(len(S)):
    if (i % 2 == 1) and ((S[i] == 'L') or (S[i] == 'U') or (S[i] == 'D')):
        result += 1
    if (i % 2 == 0) and ((S[i] == 'R') or (S[i] == 'U') or (S[i] == 'D')):
        result += 1
        
if result == len(S):
    print('Yes')
else:
    print('No')

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

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, m, c, cnt = 0, a;
	cin >> n >> m >> c;

	vector<int> b(m);

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

	for (int i = 0; i < n; ++i) {
		int sum = 0;
		for (int j = 0; j < m; ++j) {
			cin >> a;
			sum += a * b[j];
		}

		if (sum + c > 0) {
			cnt++;
		}
	}

	cout << cnt;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int A, B, C;
  cin >> A >> B >> C;

  int ans;
  ans = min(C, B / A);
  cout << ans << endl;

  return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i <=(int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int x ,  y ;
  cin >> x >> y ;
  string ans = "No";
  rep(i,x){
    int a = i*2 + (x-i)*4 ;
    if(a == y) ans ="Yes" ;
  }
  
  cout << ans ;
  


}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        if(a >= h && b >= w) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
x = min(h)

for i in range (0,N-1):
  if h[i] > h[i+1]:
    x = x + (h[i] - h[i+1])
x = x + (h[N-1] - min(h))
print(x)

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

using namespace std;
int main(void){
    // Your code here!
    int a,b,d;
    int c[100]={};
    
    cin>>a;
    for(int z=1;z<=a;z++){
        cin>>c[z];
    }
    cin>>b;
    for(int z=1;z<=b;z++){
        cin>>d;
        if(c[d]+1!=c[d+1]){
            if(c[d]!=2019){
                c[d]++;
            }
        }
    }
    for(int z=1;z<=a;z++){
        cout<<c[z]<<endl;
    }
    
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

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


Measured memory_bytes: 256
import javax.swing.plaf.synth.SynthLookAndFeel;
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int lowerBound
            (Integer[] array, int length, int value) {
        int l = 0;
        int r = length;
        while (l < r) {
            int mid = (l + r) / 2;
            if (value < array[mid]) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }
    public static long gcd(long a, long b){
        if (b == 0)
            return a;
        else return gcd(b, a % b);
    }
    public static void main(String [] args)  {
       // int T = sc.nextInt();while (T--!=0)
        {
            solve();
        }
    }
    public static void solve()  {
//////////////////////////////////////////////////////////////////////
        long n = sc.nextLong();
        System.out.println( n + n*n + n*n* n);
///////////////////////////////////////////////////////////////////////
    }

}

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

int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<long long int,long int> num; long long int temp;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> temp;
        num[temp]++;
    }
    long long int m1 = 0,m2 = 0;
    map<long long int,long int>::iterator it = num.begin();
    while(it != num.end())
    {
        if(it->second > 1 && it->second < 4)
        {
            if(it->first > m1)
            {
                m2 = m1;
                m1 = it->first;
            }
            else if(it->first > m2)
            m2 = it->first;
        }
        else if(it->second > 3)
        {
            if(it->first > m1)
            {
                m1 = it->first;
                m2 = m1;
            }
            else if(it->first > m2)
            m2 = it->first;
        }
        it++;
    }
    long long int res = m1*m2;
    cout << res << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==5 && a[1]==5 && a[2]==7)
    cout<<"YES";
  else
    cout<<"NO";
  
}

Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
x = -((-sum(a))//n)
y = x-1
result = 0
for i in range(n):
    result += (x-a[i])**2
result_y = 0
for i in range(n):
    result_y += (y-a[i])**2
print(min([result, result_y]))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
    return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


#define N 100005
ll p[N+1];
vector<ll>chi[N+1];
vector<ll>v[N+1];
ll d[N+1];
void dfs(ll k){
    for(auto x:v[k]){
        if(p[x]==0){
            p[x]=k;
            chi[k].pb(x);
            d[x]=d[k]+1;
            dfs(x);
        }
    }
}
void no(){cout<<"NO"<<endl;}

int main(){fastio
    ll n;cin>>n;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    p[1]=-1;dfs(1);
    vector<ll>dep[N];
    rep(i,1,n)dep[d[i]].pb(i);
    /*
    rep(i,0,5){
        cout<<i<<":";
        for(auto x:dep[i])cout<<x<<" ";cout<<endl;
    }
     */
    for(ll i=N-1;i>=0;i--){
        for(auto x:dep[i]){
            ll k;
            if(chi[x].size()==0)continue;
            ll sum=0,ma=0;
            for(auto y:chi[x]){
                Max(ma,a[y]);
                sum+=a[y];
            }
            if(a[x]>sum){
                no();return 0;
            }
            if(a[x]<ma||a[x]*2<sum){
                no();return 0;
            }
            a[x]-=(sum-a[x]);
            if(a[x]<0){
                no();return 0;
            }
        }
    }
    //rep(i,1,n)cout<<a[i]<<" ";cout<<endl;
    if(a[1]!=0){
        if(chi[1].size()==1){
            if(a[1]==a[chi[1][0]]){
                cout<<"YES";return 0;
            }
        }
        cout<<"NO"<<endl;
    }else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
#define X first
#define Y second
#define INF 1000 * 1000 * 1000
using namespace std;
const LL mod = 1000 * 1000 * 1000 + 7;
const LL ob = (mod + 1) >> 1;
int n , k;
int a[100005];
vector<vector<int> > g(100005);
vector<int> path;
int P[100005];
int deleted[100005];
int kth[100005];
vector<pair<int , int> > v;
void dfs(int u , int p = -1)
{
	v.PB({path.size() , u});
	P[u] = p;
	path.PB(u);
	if(path.size() >= k)
	{
		kth[u] = path[path.size() - k];
	}
	for(auto v : g[u])
	{
		if(v != p)
			dfs(v , u);
	}
	path.pop_back();
}
void dfs2(int u , int p)
{
	deleted[u] = 1;
	for(auto v : g[u])
	{
		if(!deleted[v] && v != p)
		{
			dfs2(v , u);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	cin >> a[0];
	a[0]--;
	for(int i = 1; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
		g[a[i]].PB(i);
		g[i].PB(a[i]);
	}
	int ans = a[0] != 0;
	dfs(0);
	sort(v.begin() , v.end());
	
	while(v.size())
	{
		int u = v.back().Y , d = v.back().X;
		v.pop_back();
		if(deleted[u])
			continue;
		if(d <= k)
			break;
		
		ans++;
		dfs2(kth[u] , P[kth[u]]);
	}
	cout << ans;
}




Measured memory_bytes: 15220
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

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


int main(){
	int H,W;
	cin >> H >> W;
	vector<string> s(H);
	rep(i,H){
		cin >> s[i];
	}
	rep(i,H){
		rep(j,W){
			int cnt = 0;
			if(s[i][j]!='#'){
				for(int k=0;k<8;k++){
				int x = i+dx[k];
				int y = j+dy[k];
				if(0<=x && x<H && 0<=y && y<W && s[x][y]=='#'){
					cnt++;
				}
			}
			//cout <<cnt << endl;
			cout << cnt;
			}else{
				cout << "#";
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var t int
  var a,b,c,d,g int64
  fmt.Scan(&t)
  for i:=0;i<t;i++ {
    fmt.Scan(&a,&b,&c,&d)
    if a < b || d < b {
      fmt.Println("No")
      continue
    }
    if c >= b {
      fmt.Println("Yes")
      continue
    }
    g = gcd(d,b)
    if b-g+a%g > c {
      fmt.Println("No")
    } else {
      fmt.Println("Yes")
    }
  }
}
func gcd(x,y int64) int64 {
  if x < y { return gcd(y,x) }
  if x%y == 0 { return y }
  return gcd(y,x%y)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

const int mod = 998244353;//
const int inv2 = (mod + 1) / 2;

void plusle (int &a, int b) {
    if (( a += b) >= mod ) a -= mod ;
}
void minun (int &a, int b) {
    if ((a -= b) < 0) a += mod ;
}
int add (int a, int b) {
    return (( a += b ) >= mod ) ? a - mod  : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + mod : a;
}
int mul (int a, int b) {
    return 1LL * a * b % mod;
}
int power (int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}

int n, s, a[nax];
int f[3010];
int p[3010];
int in[3010];
int w[3010];
int pn = 1;

int main () {

    scanf("%d %d", &n, &s);

    in[0] = 1;

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d", a + i);
        in[i] = mul(in[i - 1], inv2);
        pn = add(pn, pn);
    }

    int ans = 0;

    f[0] = 1;

    for (int i = 1 ; i <= n ; ++ i) {


        memset(p, 0, sizeof(p));
        for (int j = s ; j - a[i] >= 0 ; -- j) {
            p[j] = f[j - a[i]];
        }

        plusle(ans, mul(p[s], pn));

        for (int j = 0 ; j <= s ; ++ j) {
            plusle(f[j], mul(p[j], inv2));
        }
    }

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


}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3880
#include <stdio.h>
int main()
{
    int rows, cols, i, j;
    while(1){
    scanf("%d %d",&rows,&cols);
     if(rows==0 && cols==0){
                break;
    }
    for(i=1; i<=rows; i++){
        for(j=1; j<=cols; j++){
            if((i+j) % 2==0){
                printf("#");
            }
            else{
                printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
}
    return 0;
}




Measured memory_bytes: 2032
L,R = map(int,input().split())
if R-L+1 >= 2019:
    print(0)
    exit()
R %= 2019
L %= 2019
if R <= L:
    print(0)
    exit()
ans = float("inf")
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%2019)
print(ans)

Measured memory_bytes: 9084