akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

class UnionFind {
 protected:
  vi data;

 public:
  UnionFind(int size) : data(size, -1) {}
  bool unite(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 same(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)]; }
};

int main() {
  //
  ll n, m;
  cin>>n>>m;
  UnionFind uf(n);
  vvl l(m, vl());
  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll tmp;
      cin >> tmp;
      tmp--;
      l[tmp].emplace_back(i);
    }
  }
  rep(i, m) {
    rep(j, (ll)l[i].size() - 1) {
      uf.unite(l[i][j], l[i][j+1]);
    }
  }

  rep(i, n-1) {
    if (!uf.same(i, i+1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 4736
s = input()
a = [-1]
count = [0]*len(s)

for i in range(len(s)-1):
  if s[i] != s[i+1]:
    a.append(i)
a.append(len(s)-1)

for i in range(len(a)):
  if i%2:
    count[a[i]] += (a[i]-a[i-1]+1) // 2 + (a[i+1]-a[i]) // 2
    count[a[i]+1] += (a[i+1]-a[i]+1) // 2 + (a[i]-a[i-1]) // 2

for j in count:
  print(j, end=" ")

Measured memory_bytes: 8768
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 10
for i in range(N):
  if i+K-1 >= N:
    continue
  tmp = x[i+K-1] - x[i] + min(abs(x[i]), abs(x[i+K-1]))
  if tmp < ans:
    ans = tmp
print(ans)

Measured memory_bytes: 62576
import sys
import itertools
import copy

input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()

def make_divisors(n):
    result = []
    i = 1
    while i*i <= n:
        if n % i == 0:
            result.append(max(len(str(i)), len(str(n // i))))
        i += 1
    return result

result = make_divisors(n)
print(min(result))

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

typedef long long int ll;

int main()
{
	ll n,temp;
	scanf("%lld",&n);
	ll arr[10005]={0};
	for (int i = 1; i < 100; ++i)
	{
		for (int j = 1; j < 100; ++j)
		{
			for (int k = 1; k < 100; ++k)
			{
				temp=i*i+j*j+k*k+i*j+j*k+k*i;
				if(temp<=10000)
					arr[temp]++;
			}
		}
	}
	for (int i = 1; i <= n; ++i)
		printf("%lld\n",arr[i]);
}



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

using namespace std;

vector<long> vertex;

long root(long x) {
    if(vertex[x]<0){
        return x;
    }
    return vertex[x] = root(vertex[x]);
}

void unite(long x, long y) {
    x = root(x);
    y = root(y);

    if (x == y){
        return;
    }
    if(-vertex[x] < -vertex[y]){
        swap(x, y);
    }
    vertex[x] -= -vertex[y];
    vertex[y] = x;
}

bool same(long x, long y) {
    return root(x) == root(y);
}
long size(long x) {
    return -vertex[root(x)];
}


int main(){
    long N, M;
    cin>>N>>M;

    vector<long> ans(M, 0);
    ans[M-1] = N*(N-1)/2;

    vertex.resize(N+1, 0);
    for(int i=1; i<=N; ++i){
        vertex[i] = -1;
    }

    vector<long> A(M), B(M);
    for(int i=0; i<M; ++i){
        cin>>A[i]>>B[i];
    }


    for(int i=M-1; i>0; --i){
        if(same(A[i], B[i])){
            ans[i-1] = ans[i];
        }else{
            ans[i-1] = ans[i] - size(A[i]) * size(B[i]);
            unite(A[i], B[i]);
        }
    }

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

    return 0;
}


Measured memory_bytes: 4480
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  int n;
  int w[110];
  cin>>n;
  rep(i,n)cin>>w[i];

  int csum[110];
  csum[0]=0;
  reps(i,n+1)csum[i]=csum[i-1]+w[i-1];
  // rep(i,n+1)cout<<csum[i]<<endl;
  int min=200;
  reps(i,n){
    if(abs((csum[n]-csum[i])-(csum[i]-csum[0]))<min)min=abs((csum[n]-csum[i])-(csum[i]-csum[0]));
  }

  cout<<min<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int N ;
    vector<int> A;
    cin >> N;
    for (int i = 0; i < N ; ++i) {
       int tmp;
       cin >> tmp;
       A.push_back(tmp);
    }
    auto maxVal = *max_element(A.begin(),A.end());
    auto minVal = *min_element(A.begin(),A.end());
    cout <<  maxVal-minVal << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(x,a)for(auto &x: a)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll>pii;
typedef vector<ll>vi;
typedef map<ll,ll>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
int k[100000];
void find(vector<int>a[],int *d,int u)
{
	queue<int>q;
	int v[100000];
	fll(v);
	d[u]=0;
	v[u]=1;
	q.push(u);
	while(q.size())
	{
		int p=q.front();
		//cout<<p<<endl;
		q.pop();
		trav(x,a[p])
		{
			if(a[p].size()==1 && v[x]==1)
				{k[p]=1;}//cout<<p<<endl;}
			if(v[x]==0)
			{
				v[x]=1;
				d[x]=1+d[p];
				q.push(x);
			}
		}

	}
}
int main()
{
	//fopen();
	fastio;
	int n,u,v;
	cin>>n>>u>>v;
	vector<int>a[n];
	u=u-1;v=v-1;
	rep(i,n-1)
	{
		int p,q;
		cin>>p>>q;
		a[p-1].pb(q-1);
		a[q-1].pb(p-1);
	}
	fll(k);
	//cout<<a[4][1]<<endl;
	int d1[n],d2[n];
	fll(d1);fll(d2);
	find(a,d1,u);
	find(a,d2,v);
	int j=u,m=0;
	rep(i,n)
	{
		//cout<<k[i];
		if(k[i]==1 && d1[i]-d2[i]<0 && d2[i]-1>m)
			{m=d2[i]-1;}
	}
	cout<<m;

}
	


Measured memory_bytes: 7424
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int num[3];
	cin>>num[0]>>num[1]>>num[2];
	sort(num,num+3);
	cout<<num[0]*num[1]/2;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
road_list = [[] for i in range(N)]

for i in range(N-1):
    a,b=list(map(int,input().split()))
    a=a-1
    b=b-1
    road_list[a].append(b)
    road_list[b].append(a)
c = list(map(int,input().split()))
from collections import deque
Q = deque([[0,0]])
ans = []
checked_list = [False for i in range(N)]
checked_list[0]=True
count_list = [10**9 for i in range(N)]
count_list[0] = 0

while len(Q)>0:
    v,count = Q.pop()
    count+=1
    for v1 in road_list[v]:        
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.append([v1,count])
            count_list[v1]=count

c.sort()

count_list = [[i,count_list[i]] for i in range(N)]
count_list = sorted(count_list, key=lambda x:x[1],reverse=True)
d = [[count_list[i][0],c[i]] for i in range(N)]
d = sorted(d, key=lambda x:x[0])
d = [d[i][1] for i in range(N)]
print(sum(c[:-1]))
print(*d)


Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long res = 0;
		sc.close();
		System.out.println(sum(res,S));
	}

	private static long sum(long res, String s) {
		long num = 0;
		long snum = Long.parseLong(s);
		for(int i = 0;i < s.length();i++) {
			if(i == 0) {
				num = res + snum;
			}else {
				num += sum(res+Long.parseLong(s.substring(0,i)),s.substring(i,s.length()));
			}
		}
		return num;
	}
}

Measured memory_bytes: 23764
n,m = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
check = []
for i in range(m):
    a,b = map(int,input().split())
    check.append([a,b])
check.sort(key =  lambda x: x[1],reverse=True)

count = 0
for a,b in check:
    for j in range(a):
        if l[count] < b:
            l[count] = b
        count += 1
        
        if count == n:
            print(sum(l))
            exit()
print(sum(l))
        
        


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

int main() {
    ll l, r;
    cin >> l >> r;
    
    int ans = 2019;
    int mod;
    r = min(r, l + 2019);
    
    for (ll i = l; i <= r; i++) {
        for (ll j = (i + 1); j <= r; j++) {
            mod = (i * j) % 2019;
            ans = min(ans, mod);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    LEARNING DP:    FROG 1
        + Frog need to reach stone N
        + Can jump to Stone i + 1 or i + 2 when the Frog is on Stone i
        + Cost |hi - hj|
        => Imagine if the frog were at stone i + 1 or i + 2,
        What is the minium cost to reach on Stone i.

    PRE DP:
        +FIRST STATE: i = 0 => cost = 0
*/
#include <bits/stdc++.h>
using namespace std;

#define DB(_x)      cout << #_x << " is " << (_x) << "\n";
#define FOR(_a,_b)  for (_a = 0; _a < _b; ++_a)
//#define IOFILE

using LL = long long;
using LD = long double;
using VI = vector<int>;
using PI = pair<int,int>;

void Excalibur(){
    int n;
    while (cin >> n){
        VI a(n);
        for (auto &x: a) cin >> x;

        VI dp(n, 1e9);
        int i;
        dp[0] = 0;
        FOR (i,n){
            if (i-1 >= 0) dp[i] = min(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
            if (i-2 >= 0) dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }

        cout << dp[n-1] << "\n";
    }
}

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

#ifdef  IOFILE
    freopen("INPUT.in", "r", stdin);
    freopen("OUTPUT.out", "w", stdout);
#endif

Excalibur();
return 0;}


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

int main() {

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

  int n;
  cin >> n;

  multiset<int> s;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    if (s.size() == 0) s.insert(x);
    else {
      auto j = s.lower_bound(x);
      if (j == s.begin()) s.insert(x);
      else {
        --j;
        s.erase(j);
        s.insert(x);
      }
    }
  }

  cout << s.size() << '\n';
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main()
{
    int N, M, A[10001], sum=0;
    cin>>N>>M;
    for(int i=1; i<=M; i++) {
        cin>>A[i];
        sum=sum+A[i];
    } 
    if(sum>N) {
        cout<<"-1"<<endl;
    } else {
        cout<<N-sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 3648
def resolve():
    from collections import deque
    A = [i for i in input().split()]
    que = deque()
    for s in A:
        if s in "+-*":
            b = que.pop()
            a = que.pop()
            tmp = str(eval(a + s + b))
            que.append(tmp)
        else:
            que.append(s)
    print(que.popleft())


resolve()



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

// 2 dimentional vector
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]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    cin>>s;
    rep(i,s.size()){
        string x = s[i]=='1'?"9":"1";
        cout<<x;
    }
    cout<<endl;
    return  0;
}


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

int main(){

int n;
cin >> n;
vector<string> s(100010);
int a=0, w=0, t=0, r=0;
rep(i,n) {
    cin >> s[i];
    if(s[i]=="AC") a++;
    if(s[i]=="WA") w++;
    if(s[i]=="TLE") t++;
    if(s[i]=="RE") r++;
}
cout << "AC x " << a << endl;
cout << "WA x " << w << endl;
cout << "TLE x " << t << endl;
cout << "RE x " << r << endl;

}

Measured memory_bytes: 6424
from collections import Counter
import itertools
N,A,B,C=map(int,input().split())
l=[]
for i in range(N):
  l.append(int(input()))
ans=float('inf')
for item in itertools.product(range(4),repeat=N):
  c=Counter(item)
  if c[0]==0 or c[1]==0 or c[2]==0:
    continue
  d=[0,0,0,0]
  for i in range(N):
    d[item[i]]+=l[i]
  kans=(abs(A-d[0])+abs(B-d[1])+abs(C-d[2])+10*(c[0]+c[1]+c[2]-3))
  ans=min(ans,kans)
print(ans)

Measured memory_bytes: 3316
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        var c = int.Parse(input[2]);

        var ret = c - (a - b);

        Console.Write(ret < 0 ? 0 : ret);
    }
}



Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#ifdef LOCAL  //デバッグ出力
#define dout cout
#define debug() if (true)
#else
#define dout \
  if (false) cout
#define debug() if (false)
#endif

using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if (a < 10 and b < 10) {
  cout << a*b;
  } else {
  cout << -1;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	int N = S.size(); 
	int ans = 1000; 
	for(char c = 'a'; c <= 'z'; c++){
		bool B[110][110] = {}; bool A[110] = {}; 
		fill(A, A + 105, true); 
		for(int i = 0; i < N; i++){
			if(S.at(i) == c) B[0][i] = true; 
			A[0] &= B[0][i]; 
		}
		for(int i = 1; i < N; i++){
			for(int j = 0; j < N - i; j++){
				B[i][j] = (B[i-1][j] | B[i-1][j+1]); 
				A[i] &= B[i][j];
			}
		}
		int index = 110; 
		for(int i = 0; i < N; i++){
			if(A[i]){
				index = i; break;
			} 
		}
		ans = min(ans, index); 
	}
	cout << ans << endl; 
}

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

int main() {
 double N,D;
  cin >> N >> D;
  double X,Y;
   double d = D*D;
  int c = 0;
   for ( int i = 0; i < N; i++ ){
    cin >> X >> Y;
     double p = X*X + Y*Y;
    if ( p <= d ){
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin >> A >>B;
    
    if(((A*B)%2)==0){
        cout <<"No"<<endl;
    }else{
        cout << "Yes" <<endl;
        
    }
}


Measured memory_bytes: 256
/**
 *	@file: B.cpp
 *	@author: Huy Le
 *	@created: 08/02/2020 19:13:59
**/


#include<bits/stdc++.h>
using namespace std;

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n, d;

void solve() {
	read(n,d);
	vector<vector<int>> a(n);
	for(int i = 0; i < n; ++i) {
		int x,y;
		read(x,y);
		a[i].push_back(x);
		a[i].push_back(y);
	}
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(abs(a[i][0] > d || abs(a[i][1]) > d))
			continue;
		ld tmp = sqrt(((ld)a[i][0] * a[i][0]) + ((ld)a[i][1] * a[i][1]));
		if(tmp <= d)
			++ans;
	}
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


Measured memory_bytes: 14292
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {

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

	int A, B; cin >> A >> B;
	if ((A + B) % 2 == 1)puts("IMPOSSIBLE");
	else cout << (A + B) / 2 << "\n";

	return 0;
}


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

int main(){
	char str2[1000][320]={'\0'};
	char str1[1000]={'\0'};
	int  max=0,max_num=0,find[1000]={0},find_max=0,find_number=0;
	int i,ans=0,j=0,k,m=0;
	
	fgets(str1,sizeof(str1),stdin);
		
	for(i=0,k=0;i<strlen(str1)-1;i++,k++){
		if(str1[i]==' '){
			j++;
			i++;
			k=0;
		}
		str2[j][k]=str1[i];
	}
	for(i=0;i<=j;i++){
		if(max<strlen(str2[i])){
			max=strlen(str2[i]);
			max_num=i;
		}
	}
	
	for(i=0;i<=j;i++){
		for(m=i;m<=j;m++){
			if( m!=j && strcmp(str2[i],str2[m])==0)find[i]++;
		}
	}
	
	for(i=0;i<=j;i++){
		if(find_max<find[i]){
			find_max=find[i];
			find_number=i;
		}
	}
	printf("%s %s\n",str2[find_number],str2[max_num]);
	
return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a,long long int b){
  if(a%b==0){
    return b;
  }
  return gcd(b, a%b);
}
int main(void){
  int k;
  cin>>k;
  long long int ans=0;
  for(int i=1; i<=k; i++){
    for(int j=1; j<=k; j++){
      for(int l=1; l<=k; l++){
        ans+=gcd(gcd(i,j),l);
      }
    }
  }
  cout<<ans<<endl;
}

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

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

    int n = s.length();

    int flag = 0;
    for(int i = 0; i < n; i++){
        if(flag == 0 && s[i] == 'C'){
            flag = 1;
        }

        if(flag == 1 && s[i] == 'F'){
            flag = 2;
            break;
        }
    }

    if(flag == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    vector<ll> A(p+1,0);
    ll ans=0;
    ll ofs=0;
    ll acc=1;
    ll i10=inv(10,p);
    REP(i,n){
        ll d=s[i]-'0';
        if(p==2||p==5){
            if(d%p==0){
                ans+=(i+1);
            }
        }else{
            A[ofs]+=1;
            acc=acc*i10%p;
            ll r=d%p*acc%p;
            ofs=(ofs+r)%p;
            ans+=A[ofs];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 720
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N, M; std::cin >> N >> M;
  std::vector<int> likes(M, 0);
  for (int i = 0; i < N; ++i) {
    int K; std::cin >> K;
    for (int k = 0; k < K; ++k) {
      int a; std::cin >> a;
      ++likes[a-1];
    }
  }

  int cnt = 0;
  for (int like : likes) {
    if (like == N) ++cnt;
  }

  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def gindex(l,r):
    L,R=l+N0,r+N0
    lm=L//(L&-L)>>1
    rm=R//(R&-R)>>1
    while L<R:
        if R<=rm:
            yield R
        if L<=lm:
            yield L
        L>>=1
        R>>=1
    while L:
        yield L
        L>>=1
def propagates(*ids):
    for i in reversed(ids):
        v=lazy[i-1]
        if v==None:
            continue
        lazy[2*i-1]=v
        lazy[2*i]=v
        data[2*i-1]=v
        data[2*i]=v
        lazy[i-1]=None
def update(l,r,x):#1-index [s,t)
    L,R=N0+l,N0+r
    *ids,=gindex(l,r)
    propagates(*ids)
    while L<R:#上から
        if R&1:
            R-=1
            lazy[R-1]=x
            data[R-1]=x
        if L&1:
            lazy[L-1]=x
            data[L-1]=x
            L+=1
        L>>=1
        R>>=1
    for i in ids:#下から
        data[i-1]=min(data[2*i-1],data[2*i])
def query(l,r):
    propagates(*gindex(l,r))
    L,R=N0+l,N0+r
    s=INF
    while L<R:
        if R&1:
            R-=1
            s=min(s,data[R-1])
        if L&1:
            s=min(s,data[L-1])
            L+=1
        L>>=1
        R>>=1
    return s
n,q=map(int,input().split())

LV=n.bit_length()
N0=2**LV
INF=2**40
data=[2**31-1]*2*N0
lazy=[None]*2*N0
for i in range(q):
    l=list(map(int,input().split()))
    if l[0]==0:
        s,t,x=l[1:]
        update(s,t+1,x)
    else:
        s,t=l[1:]
        print(query(s,t+1))



Measured memory_bytes: 12440
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define mod(i) (i%(ll)(1e9 + 7))

int cost(int a,int b){
	return ( a-b)*(a-b);
}

int main(){
	int n,a[200]={},ave =0;
	cin >> n;
	rep(i,0,n){
		cin>> a[i];
		ave += a[i];
	}
	ave /= n;
   // cout << ave << endl;          
	int ans = 0;
	rep(i,0,n)ans += cost(a[i],ave);
	int ans2 = 0;
	rep(i,0,n)ans2 += cost(a[i],ave-1);
	ans = min(ans,ans2);
	ans2 = 0;
	rep(i,0,n)ans2 += cost(a[i],ave+1);
	ans = min(ans,ans2);


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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
 
using namespace std;
const int MAX = 8;
const int BLACK = 1;
const int WHITE = 0;
typedef pair<int,int> P;
 
vector<int> V[MAX][MAX];
vector<P> VP;
int n,m,p;
 
void init(){
  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++) V[i][j].clear();
  VP.clear();
}
 
bool isInside(const int x, const int y, const int z){return 0<x&&x<=n&&0<y&&y<=n&&0<z&&z<=n;}
bool isOK(int color){
  int move[13][3] = 
    {{1,0,0},{0,1,0},{0,0,1},
     {1,1,0},{1,-1,0},{0,1,1},{0,1,-1},{1,0,1},{1,0,-1},
     {1,1,1},{1,-1,1},{1,-1,-1},{-1,-1,1}};

 
  for(int i = 0; i < 13; i++){
    int dx = move[i][0], dy = move[i][1], dz = move[i][2];
     
    for(int x = 1; x <= n; x++)
      for(int y = 1; y <= n; y++)
    for(int z = 1; z <= n; z++){
      if((int)V[x][y].size() < z) break;
       
      int nx = x, ny = y, nz = z;
 
      for(int cnt = 0; cnt < m; cnt++){
        if(!isInside(nx,ny,nz)) break;
        if((int)V[nx][ny].size() < nz) break;
        if(V[nx][ny][nz-1] != color) break;
        nx += dx;
        ny += dy;
        nz += dz;
        if(cnt == m-1) return true;
      }
    }
  }
  return false;
}
 
void input(){
  VP.resize(p);
  for(int i = 0; i < p; i++) cin >> VP[i].first >> VP[i].second;
}
 
void solve(){
  for(int i = 0; i < p; i++){
    int x = VP[i].first,y=VP[i].second;
 
 
    if(i%2) V[x][y].push_back(WHITE);
    else V[x][y].push_back(BLACK);
 
    if(i < m-1) continue;
 
    if(isOK(WHITE)){
      cout << "White " << i+1 << endl;
      return;
    }
    if(isOK(BLACK)){
      cout << "Black " << i+1 << endl;
      return ;
    }
  }
  cout << "Draw" << endl;
}
 
 
int main(){
   
  while(cin >> n >> m >> p && n+m+p){
    init();
    input();
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 1220
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない
       2n回呼び出されるので，リストを作るのに時間がかかるならメモ化すること *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 経路に負閉路が含まれる頂点を覚えるやつ *)
    let neg = Array.make n false in
    d.(s) <- Weight.zero;
    (* n回目以降の反復を行う関数
       途中の反復で更新が行われなければfalseを返す *)
    let rec loop' n =
      n <= 0 ||
      es.fold (fun (u, v, c) b -> (* bは更新の有無 *)
        let open Weight in
        if neg.(u) then neg.(v) <- true;
        (* 原点から到達できない頂点は更新しない *)
        0 < Weight.compare inf d.(u)
        (* c は u から v への辺の重さ
           d.(u) + c < d.(v) *)
        && 0 < Weight.compare d.(v) (d.(u) + c)
        (* n 回目以降に変更が起こった場合，v までの経路に負閉路が含まれている *)
        && (d.(v) <- d.(u) + c; neg.(v) <- true; true) || b) false
      && loop' (n - 1) in
    (* n-1回目までの反復
       途中の反復で更新が行われなければfalseを返す *)
    let rec loop n =
      n <= 0 ||
      es.fold (fun (u, v, c) b ->
        let open Weight in
        (* 原点から到達できない頂点は更新しない *)
        0 < Weight.compare inf d.(u)
        && 0 < Weight.compare d.(v) (d.(u) + c)
        && (d.(v) <- d.(u) + c; true) || b) false
      && loop (n - 1) in
    if loop (n - 1) then ignore (loop' n);
    fun v -> if neg.(v) then Weight.neg_inf else d.(v)
end


module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let inf = min_int
  let neg_inf = max_int
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m p ->
  let abc = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c - p in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abc } 0 (n - 1) in
  if max_int <= d
  then print_endline "-1"
  else Printf.printf "%d\n" @@ max 0 d


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

int main()
{
  int N, p, cnt = 0;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++)
  {
    cin >> P.at(i);
  }
  for (int i = 0; i < N - 1; i++)
  {
    if (P.at(i) == i + 1 && P.at(i + 1) == i + 2)
    {
      swap(P.at(i), P.at(i + 1));
      cnt++;
    }
  }
  for (int i = 0; i < N; i++)
  {
    if (P.at(i) == i + 1)
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
from itertools import accumulate
from collections import defaultdict


def main():
    n = int(input())
    prime_counter = defaultdict(int)  # key ^ value
    accum = tuple(accumulate(range(1, 42)))  # because 10^12 < 2^39

    def facs(n):
        yield 2
        for x in range(3, int(pow(n, 0.5)) + 1, 2):
            yield x

    for fac in facs(n):
        while n % fac == 0:
            n //= fac
            prime_counter[fac] += 1
            # ここで if fac * fac > n: braek を入れると，
            # 計算量の少ないケースでは早く，多いケースでは遅くなる。
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter.values():
        for accum_count, accum_value in enumerate(accum):
            if c < accum_value:
                break
        ans += accum_count
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int a,b,c,d;
    while(scanf("%d %d %d %d",&a,&b,&c,&d)==4)
    {
        int f=0,t1,t2,t3;
    t1=a-c;
    t2=a-b;t3=b-c;
    if(t1<0)
        t1=0-t1;
    if(t2<0)
        t2=0-t2;
    if(t3<0)
        t3=0-t3;
    if(t1<=d||(t2<=d&&t3<=d))
        f=1;
    if(f)
        printf("Yes\n");
    else
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	string s;
	cin>>s;
	for (int i=0; i<s.size(); i++) {
		if (s[i]=='C') {
			for (int j=i+1; j<s.size(); j++) {
				if (s[j]=='F') {
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

    for (int i=0;i<n;i++) { 
         cin >> num[i];   
    } 
     
    sort(num.begin(),num.end());
    
    cout << num[n/2] - num[n/2-1] << endl; 
}



Measured memory_bytes: 640
#include <stdio.h>

int GenNextRand(int s);

int main(void){
    int seed,next;
    int n;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%d",&seed);
        printf("Case %d:\n",i+1);
        for (int j=0; j<10; j++){
            next = GenNextRand(seed);
            printf("%d\n", next);
            seed = next;
        }
    }
    
    return 0;
}

int GenNextRand(int s){
    int tmp;
    
    tmp = s*s;
    return (tmp/100) % 10000;
}

Measured memory_bytes: 1020
#include <iostream>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
  int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;
  cin >> N;
  int Ai[N];
  for(int i=0;i<N;i++){
    cin >> Ai[i];
  }
  sort(Ai, Ai+N);
  int count=0;
  for(int i=0;i<N-1;i++){
    if(Ai[i]==Ai[i+1]){
      count++;
    }
    if(count>0){
      break;
    }
  }
  if(count==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" <<endl;
  }
  //cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve(n):
    s = [input() for i in range(n)]
    v = defaultdict(lambda : [])
    f = [1]*n
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if s[i] in s[j]:
                f[i] = 0
                break
    s = [s[i] for i in range(n) if f[i]]
    n = len(s)
    pre = [set([s[i][:j] for j in range(len(s[i])+1)]) for i in range(n)]
    for i in range(n):
        si = s[i]
        for j in range(n):
            sj = s[j]
            p = pre[j]
            if i == j:
                continue
            for k in range(len(si)):
                if s[i][k:] in p:
                    k -= 1
                    break
            l = len(si)-k-1
            v[i].append((j,len(sj)-l))
    m = 1<<n
    dp = [[float("inf")]*n for i in range(m)]
    for i in range(n):
        dp[1<<i][i] = len(s[i])
    for b in range(m):
        for i in range(n):
            if not b&(1<<i):
                continue
            d = dp[b][i]
            for j,w in v[i]:
                k = 1<<j
                if b&k:
                    continue
                nb = b|k
                nd = d+w
                if nd < dp[nb][j]:
                    dp[nb][j] = nd
    print(min(dp[m-1]))
    return

#Solve
if __name__ == "__main__":
    while 1:
        n = I()
        if n == 0:
            break
        solve(n)



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

const int inf = 1e9+5;

int sum(int num){
    int ans = 0;
    while (num){
        ans += num%10;
        num /= 10;
    }

    return ans;
}

int main(){
    int n, ans = inf;
    scanf("%d", &n);
    for (int i = 1; i < n; i++)
        ans = min(ans, sum(i) + sum(n-i));

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


Measured memory_bytes: 256
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    cout<<setprecision(15);
    ll n;
    cin>>n;
    vector<double> v(n+1);
    rep(i,1,n) cin>>v[i];
    double dp[n+1][n+1];
    rep(i,0,n) rep(j,0,n) dp[i][j]=0.0;
    dp[1][0]=1-v[1];
    dp[1][1]=v[1];
    // memset(dp,1.0,sizeof(dp));
    rep(i,2,n){
        dp[i][0]=dp[i-1][0]*(1-v[i]);
        rep(j,1,i){
            dp[i][j]=(dp[i-1][j]*(1-v[i]))+(dp[i-1][j-1]*v[i]);
        }
    }
    // rep(i,0,n) cout<<dp[n][i]<<" ";
    double ans=0;
    rep(i,n/2+1,n){
        ans+=dp[n][i];
    }
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 70656
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char s[4];
    rep(i,4) cin>>s[i];
    
    sort(s,s+4);
    
    if(s[0]=='1'&&s[1]=='4'&&s[2]=='7'&&s[3]=='9'){
        cout1("YES")
    }else{
        cout1("NO")
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,b[200005],w[200005],minf=1145141,p,pp;
string s;
main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='#')p++;
        b[i]=p;
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='.')pp++;
        w[i]=pp;
    }
    for(int i=0;i<n;i++) if(minf>(b[i]+w[i]-1))minf=b[i]+w[i]-1;
    cout<<minf<<endl;
}

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

int gcd(int m, int n) {
	if (n == 0) return m;
	return gcd(n, m%n);
}

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> num(N);
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		num[i] = abs(tmp - X);
	}
	int max_num = num[0];
	for (int i = 1; i < N; i++) {
		max_num = gcd(num[i], max_num);
	}
	cout << max_num;
	return 0;

}

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

int main(){
  long long N,K;
  cin>>N>>K;
  vector<pair<int,int>> p(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)={a,b};
  }
  
  sort(p.begin(),p.end());
  int i=0;
  long long sum=0;
  while(sum<K){
    sum+=p.at(i).second;
    i++;
  }
  
  cout<<p.at(i-1).first<<endl;
}

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

#define BUF_SIZE 12
#define BUCKET_SIZE 100

struct list {
  struct list* next;
  char str[BUF_SIZE];
  int point;
};

struct list* create_htable(int size) {
  struct list* htable = malloc(sizeof(struct list)*size);
  int i;
  for(i = 0; i < size; i++) {
    htable[i].next = &htable[i];
  }
  return htable;
}

int get_key(char* str, int len) {
  return (str[0] + str[len-2]) % BUCKET_SIZE;
}

struct list* find(struct list* htable, char* str, size_t len) {
  struct list* head = &htable[get_key(str, len)];
  struct list* tmp;
  for(tmp = head->next; tmp != head; tmp = tmp->next) {
    if(!strncmp(str, tmp->str, len)) {
      return tmp;
    }
  }
  return NULL;
}

void insert(struct list* htable, char* str, int len, int point) {
  struct list *elem = find(htable, str, len);
  if(elem) {
    elem->point += point;
    return;
  }
  struct list* head = &htable[get_key(str, len)];
  elem = malloc(sizeof(struct list));
  elem->next = head->next;
  strncpy(elem->str, str, len);
  elem->point = point;
  head->next = elem;
  return;
}

int get_maxpoint(struct list* htable) {
  int max = 0;
  int i;
  for(i = 0; i < BUCKET_SIZE; i++) {
    struct list* head = &htable[i];
    struct list *tmp;
    for(tmp = head->next; tmp != head; tmp = tmp->next) {
      if(tmp->point > max) max = tmp->point;
    }
  }
  return max;
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  int i;
  struct list* htable = create_htable(BUCKET_SIZE);
  // blue
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int blue_cnt;
  sscanf(line, "%d", &blue_cnt);
  for(i = 0; i < blue_cnt; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int len = strlen(line); line[len-1] = '\0';
    insert(htable, line, len, 1);
  }

  // red
  int red_cnt;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d", &red_cnt);
  for(i = 0; i < red_cnt; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int len = strlen(line); line[len-1] = '\0';
    insert(htable, line, len, -1);
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int K,s,ans=0;cin>>K>>s;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            int k=s-i-j;
            if(0<=k&&k<=K)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, int> plp;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//--------------------------------//

int N;
int c[100];
bool dp[100][101][10];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", c + i);
	
	REP(i, N - 1) if (c[i] == c[i + 1]) dp[i][i + 2][c[i]] = true;
	
	FOR(s, 2, N + 1) {
		REP(l, N - s + 1) {
			int r = l + s;
			
			REP(i, 10) REP(j, 10) {
				FOR(k, l + 1, r) {
					dp[l][r][0] |= dp[l][k][i] & dp[k][r][j]; // xx
					
					if (c[l] == c[r - 1]) {
						dp[l][r][c[l]] |= dp[l + 1][r - 1][i]; // 1x1
						if (c[l] == c[k]) dp[l][r][c[l]] |= dp[l + 1][k][i] & dp[k + 1][r - 1][j]; // 1x1x1
					}
				}
			}
			
			if (l > 0) dp[l - 1][r][c[l - 1]] |= dp[l][r][c[l - 1]];
			if (r < N) dp[l][r + 1][c[r]] |= dp[l][r][c[r]];
		}
	}
	
	bool ans = false;
	REP(i, 10) ans |= dp[0][N][i];
	puts(ans ? "yes" : "no");
	return 0;
}

Measured memory_bytes: 3252
N,K = list(map(int,input().split()))
S = input()

T = [0]
now = S[0]
start = now
for i in range(1,N):
    if S[i]!=now:
        now=S[i]
        T.append(i)

T.append(N)
max_score = 0
for i in range(len(T)):
    if start=="0":
        if i%2==0:
            r=min(2*K+i,len(T)-1)
            l=max(0,i-1)
            max_score = max(T[r]-T[l],max_score)
    else:
        if i%2==1:
            r=min(2*K+i,len(T)-1)
            l=max(0,i-1)
            max_score = max(T[r]-T[l],max_score)
            
print(max_score)

Measured memory_bytes: 7160
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0) 
#define inf                   998244353
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    vector<int> h(n);
    f(i,n)
    {
        cin>>h[i];
    }
    vector<int> dp(n+1);
    f(i,n)
    {
        if(i-1>=0)
        {
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
        if(i-2>=0)
        {
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
package main
import "fmt"
func main() {
	var a, b,c, d int
	fmt.Scan(&a, &b, &c, &d) 
	for a > 0 {
		c -= b
		if c <= 0 {
			fmt.Println("Yes")
			return
		}
		a -= d
	}
	fmt.Println("No")
}

Measured memory_bytes: 1752