akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
inline __int128 read(){
    __int128 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 void print(__int128 x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}


int main(){
    __int128 a=read(),b=read(),c=read();
    if(c<a+b){
        printf("No");
        return 0;
    }
    if(4*a*b<c*c+a*a+b*b-2*a*c-2*b*c+2*a*b){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const int N = 2e5 + 5;
const ll mod = 1000000007;
using namespace std;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
//	cin >> tc;

	while (tc--) {
		ll n, m, i, j, fl;
		ll k;

		cin >> n >> k;
		map<ll, ll> mp;
		while (k--) {
			ll d;
			cin >> d;

			for (i = 0; i < d; i++) {
				ll x;
				cin >> x;
				mp[x] = i;
			}
		}

		cout << n - mp.size() << endl;
	}
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long int ll;
struct edge{ int to,cost; };
#define M (1e12+1)

int main(void){
	ll v,e;
	cin>>v>>e;
vector<vector<edge> > g(v);
vector<vector<ll> > ans(v,vector<ll>(v,M));
for(int i=0;i<v;i++){
	ans[i][i]=0;
}
ll s,t,d;
for(int i=0;i<e;i++){
	cin>>s>>t>>d;
//	g[s].push_back((edge){t,d});
ans[s][t]=d;
}
for(int k=0;k<v;k++){
for(int i=0;i<v;i++){
	for(int j=0;j<v;j++){
		//for(int k=0;k<v;k++){
			if(ans[i][k]!=M&&ans[k][j]!=M){
				ans[i][j]=min(ans[i][j],ans[i][k]+ans[k][j]);
			}
		}
	}
}
bool f=true;
for(int i=0;i<v;i++){
	if(ans[i][i]!=0)f=false;
}
if(f){
	for(int i=0;i<v;i++){
		for(int j=0;j<v;j++){
			if(ans[i][j]>=M){
				cout<<"INF";
			}else{
				cout<<ans[i][j];
			}
			if(j!=v-1)cout<<' ';
		}
		cout<<endl;
	}
}else{
	cout<<"NEGATIVE CYCLE"<<endl;
}
	return 0;
}


Measured memory_bytes: 3232
program tak_and_cards
  implicit none
  integer                :: n, a, x(50), lbnd, ubnd, i, j
  integer(8),allocatable :: dp(:,:)
  x = 0
  read(*,*) n, a
  read(*,*) x(1:n)
  x(1:n) = x(1:n) - a
  call merge_sort(x(1:n))
  lbnd = sum(x(1:n),mask=x(1:n)<0)
  ubnd = sum(x(1:n),mask=x(1:n)>0)
  allocate(dp(0:n,lbnd:ubnd))
  dp = 0_8
  dp(0,0) = 1_8
  do j = 1, n
    do i = lbnd, ubnd
      dp(j,i) = dp(j-1,i)
      if ((lbnd.le.i-x(j)).and.(i-x(j).le.ubnd)) then
        dp(j,i) = dp(j,i) + dp(j-1,i-x(j))
      end if 
    end do
  end do
  write(*,'(i0)') dp(n,0)-1_8
  deallocate(dp)
  stop
contains
  subroutine merge_sort(c)
    implicit none
    integer, intent(inout) :: c(:)
    integer                :: n, num, lng, i, ubnd
    n = size(c)
    num = n
    lng = 1
    do while (num.gt.1)
      do i = 1, num/2
        ubnd = min(2*i*lng,n)
        call merge(c(2*(i-1)*lng+1:(2*i-1)*lng),c((2*i-1)*lng+1:ubnd))
      end do
      lng = 2*lng
      num = (num+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merge(c1,c2)
    implicit none
    integer, intent(inout) :: c1(:), c2(:)
    integer                :: c(size(c1)+size(c2))
    integer                :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1)
    n2 = size(c2)
    do while (i1.le.n1.and.i2.le.n2)
      if (c1(i1).le.c2(i2)) then
        c(i1+i2-1) = c1(i1)
        i1 = i1+1
      else
        c(i1+i2-1) = c2(i2)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2) = c1(i1:n1)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2) = c2(i2:n2)
    end if
    c1 = c(1:n1)
    c2 = c(n1+1:n1+n2)
    return
  end subroutine merge
end program tak_and_cards

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



Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n);
    rep(i, q){
        int a;
        cin >> a;
        v[a-1]++;
    }
    rep(i, n){
        v[i] = (k - (q - v[i]));
    }
    rep(i, n){
        if(v[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main()
{
	int grid[9], ans = 0;
	for (int i = 0; i < 9; i++)
	{
		cin >> grid[i];
	}
	
	if (grid[0] - grid[1] == grid[3] - grid[4] && grid[0] - grid[1] == grid[6] - grid[7]) ans++;
	if (grid[1] - grid[2] == grid[4] - grid[5] && grid[1] - grid[2] == grid[7] - grid[8]) ans++;
	if (grid[0] - grid[3] == grid[1] - grid[4] && grid[0] - grid[3] == grid[2] - grid[5]) ans++;
	if (grid[3] - grid[6] == grid[4] - grid[7] && grid[3] - grid[6] == grid[5] - grid[8]) ans++;
	
	cout << ((ans == 4) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
X = int(input())

prime = [True for i in range(10**6)]
prime[0] = False
prime[1] = False

for i in range(2, 10**5+4):
  if prime[i]:
    for j in range(2, (10**5+4)//i + 1):
        prime[i*j] = False
for i, is_prime in enumerate(prime):
  if i >= X and is_prime:
    ret = i
    break
    
print(ret)

Measured memory_bytes: 10904
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

current_bottom = a[0]
ans = 1
if current_bottom == 2:
    print(ans)
    exit()

for _ in range(N):
    current_bottom = a[current_bottom-1]
    ans += 1
    if current_bottom == 2:
        print(ans)
        exit()
print(-1)

Measured memory_bytes: 7084
/*
[abc129] B - Balance
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100;
const int INF = 1e9;

int N;
int W[MAX_N];

ll solve() {
    int ans = INF;
    for (int t = 0; t < N; t++) {
        ans = min(ans,
                  abs(accumulate(W, W + t, 0) - accumulate(W + t, W + N, 0)));
    }
    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
#define MAX_M 100000
using namespace std;

int n, m;
int k[MAX_N];
vector< int > l[MAX_N];
vector< int > graph[MAX_N];

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

class UnionFindTree{
  public:
    int size;
    vector< int > parent;
    vector< int > rank;

    UnionFindTree(int n):
      size(n), parent(n, -1), rank(n, 0){}

    int root(int x){
      return ((parent[x] < 0) ?
        x : parent[x] = root(parent[x]));
    }

    bool unite(int x, int y){
      int rx = root(x), ry = root(y);
      if(rx == ry){
        return false;
      }
      if(rank[rx] < rank[ry]){
        parent[rx] = ry;
      }
      else{
        parent[ry] = rx;
      }
      if(rank[rx] == rank[ry]){
        ++rank[rx];
      }
      --size;
      return true;
    }

    bool same(int x, int y){
      return root(x) == root(y);
    }
};

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  cin >> n >> m;
  for(int i = 0; i < n; i++){
    cin >> k[i];
    for(int j = 0; j < k[i]; j++){
      int tmp;
      cin >> tmp;
      l[i].push_back(tmp - 1);
    }
  }

  UnionFindTree uf(n + m);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < k[i]; j++){
      uf.unite(i, n + l[i][j]);
    }
  }

  for(int i = 1; i < n; i++){
    if(!uf.same(0, i)){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 9984
import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Int): Int = scala.math.pow(i, exp).intValue
  }

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0
    def isOdd = !isEven

    def ** (exp: Long): Long = scala.math.pow(i, exp).longValue
  }
}

object Main extends App {
  import Helpers._

  val k = readInt
  val Array(a, b) = readIntLine

  println(if ((a to b).exists(_ % k == 0)) "OK" else "NG")
}



Measured memory_bytes: 54840
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
using namespace std;

const int N = 100;
const int inf = 1e10;
int n ,d;
int x[100][20];

signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> n >> d;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=d;j++){
            cin >> x[i][j];
        }
    }
    int cnt=0;
    for (int i=2;i<=n;i++){
        for (int j=1;j<i;j++){
            double tt = 0;
            for (int k=1;k<=d;k++){
                tt = tt + (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            double t = sqrt(tt);
            if (round(t) == t){
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


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



int dp[1000][1000], mod = 1e9 + 7;
char grid[1000][1000];
int main() {
        int n, m; scanf("%d%d",&n,&m);
        for (int i = 0; i < n; i++) scanf("%s", grid[i]);

        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                        if (grid[i][j] == '#') continue;
                        if (i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                        if (j - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
                }
        }

        printf("%d", dp[n - 1][m - 1]);
}

Measured memory_bytes: 8624
#include <algorithm>
#include <cmath>
#include <iostream>

int digit(long n) {
  int d = 1;
  while (n >= 10) {
    d++;
    n /= 10;
  }
  return d;
}

int f(long a, long b) { return std::max(digit(a), digit(b)); }

int main() {
  long N;
  std::cin >> N;

  int min = 11;
  for (int a = 1; a <= sqrt(N); ++a) {
    if (N % a == 0) {
      min = std::min(min, f(a, N / a));
    }
  }
  std::cout << min << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    
    UnionFind uf(n);
    vector<int> e(n, 0);
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a]++; e[b]++;
        uf.unite(a, b);
    }
    vector<int> x(n);
    rep (i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        if (uf.same(c, d)) {
            x[c]++; x[d]++;
        }
    }
    
    rep (i, n)
        cout << uf.size(i) - e[i] - x[i] - 1 << " " << flush;
    
    return 0;
}


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

using namespace std;

int main() {

	int a, b,c,x;
	cin >> a >> b >> c >> x;

	int counter = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) {
					counter++;
				}
			}
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define llu ll unsigned
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ft first
#define sd second
using namespace std;
const int MOD=(int)1e9+7;
// #pragma comment(linker, "/STACK:2000000")

string to_string(string s){return '"'+s+'"';}string to_string(const char* s){return to_string((string)s);}template <typename A, typename B>string to_string(pair<A, B> p){return "("+to_string(p.first)+", "+to_string(p.second)+")";}template<typename A>string to_string(A v){bool first=true;string res="{";for(const auto&x:v){if(!first){res+=", ";}first = false;res+=to_string(x);}res += "}";return res;}void debug_out(){cerr<<endl;}template<typename Head,typename... Tail>void debug_out(Head H,Tail... T){cerr<<" "<<to_string(H);debug_out(T...);}
#ifdef LOCAL
#define err(...)cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define err(...) 42
#endif
#ifdef SUBLIME
#define IO freopen("in.txt","r",stdin)//;freopen("out1.txt","w",stdout)
#else
#define IO
#endif

const int N=1e3+9;
typedef long double ld;
const ll inf = 2e9+9;
const ld eps = 1e-11;


int a,b,c,d;
 
int main(){

    IO;  ios::sync_with_stdio(false);cin.tie(0);
    cin>>a>>b>>c>>d;
    if(a+b==c+d){
        cout<<"Balanced";
    } else if(a+b<c+d){
        cout<<"Right";
    } else {
        cout<<"Left";
    }
    return 0; 
} 




Measured memory_bytes: 256
import sys
def solve():
    person = 0
    for i in range(0,H):
        for j in range(0,W):
            if geo[i][j] is not "_":
                search(i,j)
                person += 1
    print(person)
 
def search(i,j):
    temp = geo[i][j]
    geo[i][j] = "_"
    for a in range(0,4):
        idx, jdy = i + dx[a], j + dy[a]
        if(isOnMap(idx, jdy)):
            if(isNeededToSolve(temp, idx, jdy)):
                search(idx,jdy)
 
def isOnMap(i,j): return (0<=i and 0<=j and i<H and j<W)
 
def isNeededToSolve(temp,i,j):
    target = geo[i][j]
    return (target is not "_" and temp is target)
 
limit = 10**7
sys.setrecursionlimit(limit)
 
H, W, tempH = -1, -1, 0
dx = [-1,0,1,0]
dy = [0,-1,0,1]
geo = [[0 for i in range(1)]for j in range(1)]
while True:
    line = input()
    if H is -1 and W is -1:
        p = line.split(" ")
        H, W = int(p[0]), int(p[1])
        geo = [[0 for i in range(W)] for j in range(H)]
    else:
        geo[tempH] = list(line)
        tempH+=1
    if H is 0 and W is 0:break
    if tempH is H:
        solve()
        H, W, tempH = -1, -1, 0

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

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

    string s;
    cin>>s;
    int res=0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]){
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int n;
vector<vector<vector<double>>> dp(310, vector<vector<double>>(310, vector<double>(310, -1)));
// 寿司の残った数が1,2,3個である皿がi,j,k枚である状態から全ての寿司が無くなるまでの操作回数の期待値

double rec(int i, int j, int k){
  if (dp.at(i).at(j).at(k) != -1) return dp.at(i).at(j).at(k);

  /*
  dp[i][j][k] = (dp[i][j][k] + 1) * (n-i-j-k)/n
                + (dp[i-1][j][k] + 1) * i/n
                + (dp[i+1][j-1][k] + 1) * j/n
                + (dp[i][j+1][k-1] + 1) * k/n
              = dp[i][j][k] * (n-i-j-k)/n + dp[i-1][j][k] * i/n + dp[i+1][j-1][k] * j/n + dp[i][j+1][k-1] * k/n + 1
  dp[i][j][k] * (i+j+k) / n = dp[i-1][j][k] * i/n + dp[i+1][j-1][k] * j/n + dp[i][j+1][k-1] * k/n + 1
  dp[i][j][k] * (i+j+k) = dp[i-1][j][k] * i + dp[i+1][j-1][k] * j + dp[i][j+1][k-1] * k + n
  dp[i][j][k] = (dp[i-1][j][k] * i + dp[i+1][j-1][k] * j + dp[i][j+1][k-1] * k + n) / (i+j+k)
  */
  double res = 0.0;
  if (i>0) res += rec(i-1,j,k) * i;
  if (j>0) res += rec(i+1,j-1,k) * j;
  if (k>0) res += rec(i,j+1,k-1) * k;
  res += n;
  res *= 1.0 / (i+j+k);

  dp.at(i).at(j).at(k) = res;
  return res;
}

int main() {
  cin >>n;
  vector<int> vec(4, 0);
  rep(i, n){
    int a; cin >>a;
    vec.at(a)++;
  }
  dp.at(0).at(0).at(0) = 0.0;

  cout <<fixed <<setprecision(10) <<rec(vec.at(1), vec.at(2), vec.at(3)) <<endl;
}

Measured memory_bytes: 237568
#include<stdio.h>
float line(float x1, float y1, float x2, float y2, float x, float y)
{
	return (x1-x2)*(y-y1)+(y1-y2)*(x1-x);
}
int line_cross(float x1, float y1, float x2, float y2, float xa, float ya, float xb, float yb)
{
	return line(x1, y1, x2, y2, xa, ya) * line(x1, y1, x2, y2, xb, yb) <= 0;
}
int is_inner_triangle(float x1, float y1, float x2, float y2, float x3, float y3, float x, float y)
{
	float xg = (x1+x2+x3)/3;
	float yg = (y1+y2+y3)/3;
	return
		!line_cross(x1, y1, x2, y2, xg, yg, x, y) &&
		!line_cross(x2, y2, x3, y3, xg, yg, x, y) &&
		!line_cross(x3, y3, x1, y1, xg, yg, x, y);
}
int main()
{
	float x1, y1, x2, y2, x3, y3, xp, yp;
	while(scanf("%f%f%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)>0) {
		puts(is_inner_triangle(x1, y1, x2, y2, x3, y3, xp, yp) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 0
#include<string>
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
  int a[9][9],n;
  bool OKNG[9][9];
  cin >> n;
  for(int i=0; i < n ;i++){
    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	cin >> a[j][k];
	OKNG[j][k]=true;
      }
    }
    for(int l=0;l < 9 ; l++){
      for(int j=0; j < 9; j++){
	for(int k=0;k < 9; k++){
	  if(a[l][j]==a[l][k]&&j!=k){
	    OKNG[l][j] = false;
	  }
	}
	for(int k=0;k < 9;k++){
	  if(a[l][j]==a[k][j]&&l!=k){
	    OKNG[l][j] = false;
	  }
	}
	int x=l/3,y=j/3;
	for(int k=x*3;k<x*3+3;k++){
	  for(int v=y*3;v<y*3+3;v++){
	    if(a[l][j]==a[k][v] && (l!=k&&j!=v)){
	      OKNG[l][j] = false;
	    }
	  }
	}
      }
    }

    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	if(OKNG[j][k]==true)cout << " ";
	else cout << "*";
	cout << a[j][k];
      }
      cout << endl;
    }
    if(i!=n-1)cout << endl;
  }
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();

        Tuple<long, int>[] stores = new Tuple<long, int>[n];
        for (int i = 0; i < n; i++)
        {
            stores[i] = Tuple.Create(sc.NextLong(), sc.NextInt());
        }
        stores = stores.OrderBy(i => i.Item1).ToArray();

        long answer = 0;
        for (int i = 0; i < n; i++)
        {
            var store = stores[i];
            if (store.Item2 >= m)
            {
                answer += store.Item1 * m;
                break;
            }
            else
            {
                answer += store.Item1 * store.Item2;
                m -= store.Item2;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 25920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int n;
	cin >> n;
	int x=n,cnt=0;
	while(x){
		if(x%10==2){
			cnt++;
		}
		x=x/10;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n;
cin>>n;
unsigned long long int min;
long long int ans1,ans2;
for(long long int i=1;i<=sqrt(n);i++)
{if(n%i==0)
 {long long int j=n/i;
 unsigned long long int min1=sqrt(pow(i-1,2)+pow(j-1,2));
 if(min1<min or i==1)
 {min=min1;
 ans1=i;
 ans2=j;}
 }
}
cout<<(ans1-1)+(ans2-1);
return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) throws Exception {
	 Scanner sc=new Scanner(System.in);
	 int r=sc.nextInt();
		int []w=mul(r,r*3);
	 for(int i=w.length-1;i>=0;i--)
		 if(i==w.length-1 && w[i]==0)
			 continue;
		 else
		     System.out.print(w[i]);
		}
    public static String solution(int i) {
    return "";
    }
    public static int [] mul(int x,int y) {
      int x1=x;
      int y1=y;
      int n=0;
      int m=0;
    	while(x1>0) {
    		x1/=10;
    	n++;
    	}
    	while(y1>0) {
    		y1/=10;
    	m++;
    	}
    	
    	int []a=new int [n];
    	int []b=new int [m];
    	for(int i=0;i<n;i++) {
    		a[i]=x%10;
    		x/=10;
    	}
    	for(int i=0;i<m;i++) {
    		b[i]=y%10;
    		y/=10;
    	}
   // 	System.out.println(Arrays.toString(a)+" "+Arrays.toString(b));
    	int []ans=new int [n+m];
    	for(int i=0;i<n;i++) {
    		for(int j=0;j<m;j++) {
    			int k=a[i]*b[j];
    			int mo=k+ans[i+j];
    			ans[i+j]=mo%10;
    			ans[i+j+1]+=mo/10;
    		}
    //		System.out.println(Arrays.toString(ans));
    	}
    	return ans;
    }
    
}


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

int main(){

 int n,x,y;
  cin>>n>>x>>y;
  vector<int>ans(n,0);
   int kira=0,kira1=0;

  for(int i=1;i<=n-1;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
       kira = j-i;
       kira1 = abs(i-x)+abs(j-y)+1;
       ans[min(kira,kira1)]++;
    }
  }

 for(int k=1;k<n;k++)
    cout<<ans[k]<<endl;


return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x=-1,y=-1,i;
    string str;
    cin>>str;
    for(i=0; str[i]; i++)
        if(str[i]=='A'){
            x=i;
            break;}
    for(i=str.length()-1;i>=0;i--)
        if(str[i]=='Z'){
            y=i;
            break;}
    if(x==-1 || y==-1 || y<x)
        cout<<0<<endl;
    else
        cout<<(y-x+1)<<endl;
    return 0;
}


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

int a[10009], ans[109][109];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int w, h, n; cin >> h >> w >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int c = 0, ti = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			if (c == a[ti]) {
				c = 0; ti++;
			}
			if (i % 2 == 0) ans[i][j] = ti + 1;
			else ans[i][w - j - 1] = ti + 1;
			c++;
		}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)
			cout << ans[i][j] << " ";
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust";
    else cout << "win";
}


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

int n;
string s;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin >> n;
    set <string> S;
    while (n--) {
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
    return 0;
}


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

const int N = 100010;
vector<int> G[N];
vector<int> D(N);
vector<int> B(N);

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

    int n, m;
    cin >> n >> m;
    while(m--){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(int i = 0; i < N; i++){
        D[i] = 1e9;
    }
    D[0] = 0;
    B[0] = -1;

    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(auto x: G[now]){
            int to = x;
            if(D[to] > D[now] + 1){
                D[to] = D[now] + 1;
                B[to] = now + 1;
                q.push(to);
            }
        }
    }
    
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << B[i] << endl;
    }


    return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    long double r; cin >> r;
    cout << r * 2.0 * 3.141592 << endl;
}

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

const int mod = 1e9 + 7;

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

    long long power = 1;
    for (int i = 1; i <= n; i++) {
        power = power * i % mod;
    }

    cout << power << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    int slen = s.size(), res=0;
    rep(i, slen){
        if(i%2){
            if(s[i]=='g'){
                res++;
            }
        }else{
            if(s[i]=='p'){
                res--;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3732
A, B = map(int, input().split())
print(100, 100)
ans = [["."]*50 + ["#"]*50 for i in range(100)]
for a in range(A - 1):
    ans[2*(a // 25)][99 - 2*(a % 25)] = "."
for b in range(B - 1):
    ans[2*(b // 25)][2*(b % 25)] = "#"
for l in ans:
    print("".join(l))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[300010];
multiset<ll> f, b;
ll fs = 0, bs = 0;
ll fl[100010], bl[100010];

int main(){
    int n;
    cin >> n;
    rep(i, 3*n) cin >> a[i];

    rep(i, n) {
        f.insert(a[i]);
        fs += a[i];
        b.insert(a[3*n-i-1]);
        bs += a[3*n-i-1];
    }
    fl[0] = fs;
    rep(i, n){
        ll tmp = *f.begin();
        if (a[n+i] > tmp){
            f.erase(f.find(tmp));
            f.insert(a[n+i]);
            fs += (a[n+i] - tmp);
        }
        fl[i+1] = fs;
    }
    bl[n] = bs;
    rep(i, n){
        ll tmp = *b.rbegin();
        if (a[2*n-i-1] < tmp){
            b.erase(b.find(tmp));
            b.insert(a[2*n-i-1]);
            bs += (a[2*n-i-1] - tmp);
        }
        bl[n-i-1] = bs;
    }

    // rep(i, n+1) cout << fl[i] << " ";
    // cout << endl;
    // rep(i, n+1) cout << bl[i] << " ";
    // cout << endl;

    ll ans = -LINF;

    rep(i, n+1) ans = max(ans, fl[i]-bl[i]);

    cout << ans << endl;

    return 0;
}


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

int main(){
  vector<int>a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  
  if(a.at(0)==a.at(1))
    cout << a.at(2) << endl;
  else
    cout << a.at(0) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	s := make([]string, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		s[i] = SortString(sc.Text())
	}
	sort.Strings(s)

	result := 0
	count := 1
	for i := 0; i < N; i++ {
		if i < N-1 && s[i] == s[i+1] {
			count += 1
		} else {
			result += count * (count - 1) / 2
			count = 1
		}
	}
	fmt.Println(result)
}

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}



Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int par[200000];
int rank1[200000];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank1[x] < rank1[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank1[x] == rank1[y])rank1[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int main(){
	int n, m, k, l;
	cin >> n >> m;
	int i,j; bool f = true;
	init(200000);
	for (i = 0; i < n; i++) {
		cin >> k;
		for (j = 0; j < k; j++) {
			cin >> l; l--;
			unite(n + l, i);
		}
	}
	for (i = 1; i < n; i++) {
		if (!same(0, i))f = false;
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
sin = list(map(int,input().split()))
wa = []
sa = []
for i in range(n):
    wa.append(i+1+sin[i])
from collections import Counter
wa = Counter(wa)
ans = 0
for i in range(n):
    sa = (i+1)-sin[i]
    ans += wa[sa]
print(ans)

Measured memory_bytes: 42612
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
const int MAXN = 2e5 + 9;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
//////////////////////////////////////////////////////////////
int n, A[500000], ch = 0;

void Merge(int left, int mid, int right) {
  int n1 = mid - left, n2 = right - mid;
  vector<int> L(n1 + 1, INF), R(n2 + 1, INF);
  for (int i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (int i = 0; i < n2; i++)
    R[i] = A[mid + i];
  for (int i = 0, j = 0, k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
    ch++;
  }
}

void MergeSort(int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    MergeSort(left, mid);
    MergeSort(mid, right);
    Merge(left, mid, right);
  }
}
int main() {
  cin >> n;
  rep(i, 0, n) cin >> A[i];
  MergeSort(0, n);
  rep(i, 0, n) cout << A[i] << ((i != n - 1) ? " " : "\n");
  cout << ch << endl;
  return 0;
}


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

int main(){
  int n; cin>>n;
  if(n%100>0 && n%100<13){
    if(n/100>0 && n/100<13) cout<<"AMBIGUOUS"<<endl;
    else cout<<"YYMM"<<endl;
  }
  else if(n/100>0 && n/100<13) cout<<"MMYY"<<endl;
  else cout<<"NA"<<endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

ll cnt[10], h, w;
map <pii, bool> mp;

ll check(ll x, ll y){
	if (x <= 0 || x >= h - 1 || y <= 0 || y >= w - 1) return -1;
	ll tmp = 0;
	for (int a = -1; a < 2; a++){
		for (int b = -1; b < 2; b++){
			tmp += mp[{x + a, y + b}];
		}
	}
	return tmp;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> h >> w;
	int n; cin >> n;
	cnt[0] = (h - 2) * (w - 2);
	for (int i = 0; i < n; i++){
		ll x, y;
		cin >> x >> y;
		x--; y--;
		mp[{x, y}] = true;
		for (int j = -1; j < 2; j++){
			for (int k = -1; k < 2; k++){
				int c = check(x + j, y + k);
				if (c == -1) continue;
				cnt[c] += 1;
				cnt[c - 1] -= 1;
			}
		}
	}
	for (int i = 0; i < 10; i++){
		cout << cnt[i] << endl;
	}
	return 0;
}



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

int main(int argc, char const *argv[])
{
	string s, t; cin >> s >> t;
	bool f = false;

	rep(i, s.size()) {
		int idx = i;
		string d;
		rep(j, s.size()) d += s[(idx + j) % s.size()];
		// cout << d << endl;
		if (d == t) f = true;
	}
	printf("%s\n", f ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
using namespace std;
int n,m,cnt;
char s[100000];
int main(){
	scanf("%s",s);
	scanf("%d",&n);
	int len=strlen(s);
	for (int i=0;i<=len-1;++i){
		if (s[i]=='1'){
			--n;
			if (n==0){
				printf("1"); break;
			}
		} else {
			printf("%c",s[i]); break;
		}
	}
	return 0;
}

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

vector<int> graph[210];

bool memo[210] = {};

bool dfs(int i, int x){
  if(memo[i]) return false ;

  memo[i] = true;
  bool ans = false;;
  for(int j = 0;j < graph[i].size();j++){
    if(graph[i][j] == x){
      return true;
    }else{
      ans = ans | dfs(graph[i][j],x);
    }
  }

  return ans;
}

int main(){
  int n;
  cin >> n;
  int a,b;
  string s;

  for(int i = 0;i < n;i++){
    cin >> a >> s >> b;
    if(s == "lock"){
      graph[a].push_back(b+100);
    }else{
      graph[b+100].push_back(a);
    }
  }

  for(int i = 0;i < 210;i++){
    memset(memo,false,sizeof(memo));
    if(dfs(i,i)){
      cout << 1 << endl;
      return 0;
    }
  }

  cout << 0 << endl;
  return 0;

}



Measured memory_bytes: 3236
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int a, b; cin >> a >> b;
  int ans = 100000;
  for(int num = 1; num <= 1000; num++) {
    int A = (num * 8) / 100;
    int B = (num * 10) / 100;
    if(a == A and b == B) {
      ans = min(ans, num);
    }
  }
  
  if (ans == 100000) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
for(;;)
{
if(a==b){cout<<"Draw";break;}
if(a==1){cout<<"Alice";break;}
if(b==1){cout<<"Bob";break;}
if(a<b){cout<<"Bob";break;}
if(a>b){cout<<"Alice";break;}
}
cout<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for(int i = 0 ; i < n ; i++) s[i] = sc.next();
		String word = "";
		for(char c = 'a' ; c <= 'z' ; c++) {
			int min = 10000100;
			for(int i = 0 ; i < n ; i++) {
				int cnt = 0;
				for(int j = 0 ; j < s[i].length() ; j++) {
					if(s[i].charAt(j) == c) cnt++;
				}
				min = Math.min(min, cnt);
			}
			for(int j = 0 ; j < min ; j++) {
				word += c;
			}
		}
		System.out.println(word);
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include <vector>
using namespace std;
int ar[12];
vector<int> a,b;
bool dfs(int i)
{
	bool flag = true;
	if(i!=10)
	{
		if(a.empty()||a.back()<ar[i])
		{
			a.push_back(ar[i]);
			flag =  dfs(i+1);
		}
		else if(b.empty()||b.back()<ar[i])
		{
			b.push_back(ar[i]);
			flag = dfs(i+1);
		}
		else flag = false;
	}
	return flag;
}
int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		for(int i = 0;i<10;i++)
			cin >> ar[i]; 
		cout<<(dfs(0)?"YES":"NO")<<endl;
		a.clear();b.clear();
	}
 } 

Measured memory_bytes: 1204
import sys
input = sys.stdin.readline
import math
def main():
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for i in range(N)]
    DIST, CNT = 0, 0
    for i in range(N-1):
        for j in range(i+1,N):
            for d in range(D):
                DIST += abs(X[i][d] - X[j][d])**2
            if math.sqrt(DIST).is_integer():
                CNT +=1
            DIST = 0
    print(CNT)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void)
{
    int d1[6], d2[6], i;
    char ch;
 
    for (i = 0; i < 6; i++)
        scanf("%d", &d1[i]);
 
    ch = getchar();
 
    while (1) {
        ch = getchar();
 
        if (ch == 'N') {
            d2[0] = d1[1];
            d2[1] = d1[5];
            d2[2] = d1[2];
            d2[3] = d1[3];
            d2[4] = d1[0];
            d2[5] = d1[4];
        }
        else if(ch == 'E') {
            d2[0] = d1[3];
            d2[1] = d1[1];
            d2[2] = d1[0];
            d2[3] = d1[5];
            d2[4] = d1[4];
            d2[5] = d1[2];
        }
        else if (ch == 'S') {
            d2[0] = d1[4];
            d2[1] = d1[0];
            d2[2] = d1[2];
            d2[3] = d1[3];
            d2[4] = d1[5];
            d2[5] = d1[1];
        }
        else if (ch == 'W') {
            d2[0] = d1[2];
            d2[1] = d1[1];
            d2[2] = d1[5];
            d2[3] = d1[0];
            d2[4] = d1[4];
            d2[5] = d1[3];
        }
        else if(ch == '\n') break;
 
        for (i = 0; i < 6; i++)
            d1[i] = d2[i];
    }
 
    printf("%d\n", d1[0]);
 
    return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
using namespace std;
using ll = long long;
const int mod = 1000000007;


int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    ll minus=0;
    ll res=0;
    ll _min=(ll)2e9;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        if(A[i]<0){
            minus++;
        }
        res+=abs(A[i]);
        _min = min(_min,abs(A[i]));
    }
    if(minus%2==0){
        cout<<res<<endl;
        return 0;
    }

    
    cout<<res-2*_min<<endl;

}

Measured memory_bytes: 1024
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let v = read_t_in_line::<i32>();
    let (a, b, k) = (v[0], v[1], v[2]);
    let mut l = vec![];
    for i in 1..min(a, b)+1 {
        if a % i == 0 && b % i == 0 {
            l.push(i);
        }
    }
    l.reverse();
    println!("{}", l[(k - 1) as usize]);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#define LEN 110000

typedef struct{
    char name[100];
    int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1)%LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1)%LEN;
    return x;
}

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

int main(){
    int elaps = 0, c;
    int i, q;
    P u;

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

    for(i=1; i<=n; i++){
        scanf("%s", &Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n+1;

    while( head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0){
            enqueue(u);
        }else{
            printf("%s %d\n", u.name, elaps);
        }
    }

    return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    string s;
    cin>>n>>s;
    int cnt=1;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  int west = 0, east = 0;
  for(int i = 0; i < n; ++i){
    if(s[i] == 'E') east++;
  }

  int ans = n;
  for(int i = 0; i < n; ++i){
    if(s[i] == 'E') east--;
    ans = min(ans, east + west);
    if(s[i] == 'W') west++;
  }

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

Measured memory_bytes: 720